@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.
- package/dist/index.amd.js +363 -275
- package/dist/index.amd.js.map +1 -1
- package/dist/index.amd.min.js +1 -1
- package/dist/index.amd.min.js.map +1 -1
- package/dist/index.cjs.js +363 -275
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.cjs.min.js +1 -1
- package/dist/index.cjs.min.js.map +1 -1
- package/dist/index.esm.js +363 -275
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/dist/index.iife.js +363 -275
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +1 -1
- package/dist/index.iife.min.js.map +1 -1
- package/dist/index.system.js +363 -275
- package/dist/index.system.js.map +1 -1
- package/dist/index.system.min.js +1 -1
- package/dist/index.system.min.js.map +1 -1
- package/dist/index.umd.js +363 -275
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/dist/index.umd.min.js.map +1 -1
- package/dist/types/src/Pops.d.ts +116 -16
- package/dist/types/src/components/loading/types/index.d.ts +1 -1
- package/dist/types/src/components/panel/index.d.ts +3 -2
- package/dist/types/src/components/rightClickMenu/types/index.d.ts +1 -1
- package/dist/types/src/components/searchSuggestion/types/index.d.ts +1 -1
- package/dist/types/src/components/tooltip/index.d.ts +82 -1
- package/dist/types/src/components/tooltip/types/index.d.ts +1 -1
- package/dist/types/src/config/GlobalConfig.d.ts +3 -3
- package/dist/types/src/event/EventEmiter.d.ts +7 -1
- package/dist/types/src/handler/PopsInstHandler.d.ts +4 -4
- package/dist/types/src/types/EventEmitter.d.ts +21 -0
- package/dist/types/src/types/PopsDOMUtilsEventType.d.ts +1 -1
- package/dist/types/src/types/components.d.ts +15 -18
- package/dist/types/src/types/global.d.ts +2 -0
- package/dist/types/src/types/mask.d.ts +6 -6
- package/dist/types/src/utils/PopsDOMUtils.d.ts +2 -2
- package/dist/types/src/utils/PopsInstanceUtils.d.ts +22 -0
- package/dist/types/src/utils/PopsUtils.d.ts +21 -16
- package/package.json +1 -1
- package/src/Pops.ts +11 -11
- package/src/components/alert/defaultConfig.ts +1 -1
- package/src/components/alert/index.ts +1 -1
- package/src/components/confirm/defaultConfig.ts +1 -1
- package/src/components/confirm/index.ts +1 -1
- package/src/components/drawer/defaultConfig.ts +1 -1
- package/src/components/drawer/index.ts +2 -1
- package/src/components/folder/defaultConfig.ts +1 -1
- package/src/components/folder/index.ts +1 -1
- package/src/components/iframe/defaultConfig.ts +1 -1
- package/src/components/iframe/index.ts +10 -6
- package/src/components/loading/defaultConfig.ts +1 -0
- package/src/components/loading/index.ts +10 -10
- package/src/components/loading/types/index.ts +1 -4
- package/src/components/panel/defaultConfig.ts +1 -1
- package/src/components/panel/handlerComponents.ts +4 -4
- package/src/components/panel/index.ts +3 -2
- package/src/components/prompt/defaultConfig.ts +1 -1
- package/src/components/prompt/index.ts +1 -1
- package/src/components/rightClickMenu/defaultConfig.ts +1 -1
- package/src/components/rightClickMenu/index.ts +1 -1
- package/src/components/rightClickMenu/types/index.ts +1 -1
- package/src/components/searchSuggestion/defaultConfig.ts +1 -0
- package/src/components/searchSuggestion/index.ts +1 -1
- package/src/components/searchSuggestion/types/index.ts +1 -1
- package/src/components/tooltip/defaultConfig.ts +1 -1
- package/src/components/tooltip/index.ts +1 -1
- package/src/components/tooltip/types/index.ts +1 -1
- package/src/event/EventEmiter.ts +15 -14
- package/src/handler/PopsHandler.ts +9 -21
- package/src/handler/PopsInstHandler.ts +65 -47
- package/src/types/EventEmitter.d.ts +21 -0
- package/src/types/PopsDOMUtilsEventType.d.ts +1 -1
- package/src/types/components.d.ts +15 -18
- package/src/types/global.d.ts +2 -0
- package/src/types/mask.d.ts +6 -6
- package/src/utils/PopsDOMUtils.ts +6 -3
- package/src/utils/PopsInstanceUtils.ts +50 -0
- package/src/utils/PopsUtils.ts +95 -68
- package/dist/types/src/utils/PopsDOMUtilsEventsConfig.d.ts +0 -4
- package/src/utils/PopsDOMUtilsEventsConfig.ts +0 -4
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const version = "4.0
|
|
1
|
+
const version = "4.2.0";
|
|
2
2
|
|
|
3
3
|
const GlobalConfig = {
|
|
4
4
|
config: {},
|
|
@@ -57,15 +57,16 @@ const GlobalConfig = {
|
|
|
57
57
|
};
|
|
58
58
|
|
|
59
59
|
class EventEmiter {
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
[Symbol.toStringTag] = "EventEmiter";
|
|
61
|
+
type;
|
|
62
|
+
data = new Map();
|
|
62
63
|
constructor(type) {
|
|
63
|
-
this
|
|
64
|
+
this.type = type;
|
|
64
65
|
}
|
|
65
66
|
on(eventName, callback) {
|
|
66
|
-
const eventList = this
|
|
67
|
-
eventList.push({ type: this
|
|
68
|
-
this
|
|
67
|
+
const eventList = this.data.get(eventName) ?? [];
|
|
68
|
+
eventList.push({ type: this.type, time: Date.now(), callback: callback });
|
|
69
|
+
this.data.set(eventName, eventList);
|
|
69
70
|
return {
|
|
70
71
|
off: () => {
|
|
71
72
|
this.off(eventName, callback);
|
|
@@ -76,7 +77,7 @@ class EventEmiter {
|
|
|
76
77
|
};
|
|
77
78
|
}
|
|
78
79
|
off(eventName, callback) {
|
|
79
|
-
const eventList = this
|
|
80
|
+
const eventList = this.data.get(eventName) ?? [];
|
|
80
81
|
let isOffSuccess = false;
|
|
81
82
|
for (let index = eventList.length - 1; index >= 0; index--) {
|
|
82
83
|
if (eventList[index].callback === callback) {
|
|
@@ -86,27 +87,27 @@ class EventEmiter {
|
|
|
86
87
|
}
|
|
87
88
|
if (eventList.length === 0) {
|
|
88
89
|
// empty
|
|
89
|
-
this
|
|
90
|
+
this.data.delete(eventName);
|
|
90
91
|
}
|
|
91
92
|
else {
|
|
92
93
|
if (isOffSuccess) {
|
|
93
94
|
// update
|
|
94
|
-
this
|
|
95
|
+
this.data.set(eventName, eventList);
|
|
95
96
|
}
|
|
96
97
|
}
|
|
97
98
|
}
|
|
98
99
|
async emit(eventName, ...args) {
|
|
99
|
-
const eventList = this
|
|
100
|
+
const eventList = this.data.get(eventName) ?? [];
|
|
100
101
|
for (const item of eventList) {
|
|
101
102
|
await item.callback(...args);
|
|
102
103
|
}
|
|
103
104
|
}
|
|
104
105
|
offAll(eventName) {
|
|
105
106
|
if (typeof eventName === "string") {
|
|
106
|
-
this
|
|
107
|
+
this.data.delete(eventName);
|
|
107
108
|
}
|
|
108
109
|
else {
|
|
109
|
-
this
|
|
110
|
+
this.data.clear();
|
|
110
111
|
}
|
|
111
112
|
}
|
|
112
113
|
/**
|
|
@@ -114,10 +115,10 @@ class EventEmiter {
|
|
|
114
115
|
*/
|
|
115
116
|
getAllEvents(eventName) {
|
|
116
117
|
if (typeof eventName === "string") {
|
|
117
|
-
return this
|
|
118
|
+
return this.data.get(eventName);
|
|
118
119
|
}
|
|
119
120
|
else {
|
|
120
|
-
return Array.from(this
|
|
121
|
+
return Array.from(this.data.values());
|
|
121
122
|
}
|
|
122
123
|
}
|
|
123
124
|
}
|
|
@@ -241,11 +242,6 @@ const PopsIcon = {
|
|
|
241
242
|
},
|
|
242
243
|
};
|
|
243
244
|
|
|
244
|
-
/**
|
|
245
|
-
* 存储在元素属性上的事件名
|
|
246
|
-
*/
|
|
247
|
-
const SymbolEvents = Symbol("events_" + (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1));
|
|
248
|
-
|
|
249
245
|
const OriginPrototype = {
|
|
250
246
|
Object: {
|
|
251
247
|
defineProperty: Object.defineProperty,
|
|
@@ -295,31 +291,31 @@ const PopsCore = {
|
|
|
295
291
|
},
|
|
296
292
|
};
|
|
297
293
|
|
|
298
|
-
|
|
294
|
+
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}
|
|
299
295
|
|
|
300
|
-
|
|
296
|
+
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};
|
|
301
297
|
|
|
302
|
-
function
|
|
298
|
+
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}}}
|
|
303
299
|
|
|
304
|
-
|
|
300
|
+
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}
|
|
305
301
|
|
|
306
|
-
function
|
|
302
|
+
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}
|
|
307
303
|
|
|
308
|
-
|
|
304
|
+
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={};}}
|
|
309
305
|
|
|
310
|
-
const
|
|
306
|
+
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();}}
|
|
311
307
|
|
|
312
|
-
const
|
|
308
|
+
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}
|
|
313
309
|
|
|
314
|
-
const
|
|
310
|
+
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}
|
|
315
311
|
|
|
316
|
-
const
|
|
312
|
+
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}
|
|
317
313
|
|
|
318
|
-
const
|
|
314
|
+
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}
|
|
319
315
|
|
|
320
|
-
|
|
316
|
+
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}
|
|
321
317
|
|
|
322
|
-
class i extends l
|
|
318
|
+
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;
|
|
323
319
|
|
|
324
320
|
class PopsUtils {
|
|
325
321
|
/**
|
|
@@ -428,7 +424,8 @@ class PopsUtils {
|
|
|
428
424
|
if (typeof sourceValue === "object" &&
|
|
429
425
|
sourceValue != null &&
|
|
430
426
|
keyName in target &&
|
|
431
|
-
!UtilsContext.isDOM(sourceValue)
|
|
427
|
+
!UtilsContext.isDOM(sourceValue) &&
|
|
428
|
+
!(sourceValue instanceof EventEmiter)) {
|
|
432
429
|
// 源端的值是object类型,且不是元素节点
|
|
433
430
|
// 如果是数组,那此数组中有值,清空旧的数组再赋值
|
|
434
431
|
let childObjectValue;
|
|
@@ -444,7 +441,7 @@ class PopsUtils {
|
|
|
444
441
|
Reflect.set(target, keyName, childObjectValue);
|
|
445
442
|
}
|
|
446
443
|
else {
|
|
447
|
-
|
|
444
|
+
// 直接赋值
|
|
448
445
|
Reflect.set(target, keyName, sourceValue);
|
|
449
446
|
}
|
|
450
447
|
}
|
|
@@ -634,33 +631,31 @@ class PopsUtils {
|
|
|
634
631
|
if (typeof deviation !== "number" || Number.isNaN(deviation)) {
|
|
635
632
|
deviation = 10;
|
|
636
633
|
}
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
const
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
center,
|
|
663
|
-
];
|
|
634
|
+
/** 坐标偏移 */
|
|
635
|
+
const positionDistance = 10;
|
|
636
|
+
const defaultCalcPostion = [];
|
|
637
|
+
const maxPostionX = globalThis.innerWidth;
|
|
638
|
+
const maxPostionY = globalThis.innerHeight;
|
|
639
|
+
const gridXCount = 8;
|
|
640
|
+
const gridYCount = 8;
|
|
641
|
+
for (let i = 0; i < gridXCount; i++) {
|
|
642
|
+
for (let j = 0; j < gridYCount; j++) {
|
|
643
|
+
const positionX = globalThis.innerWidth * (i / gridXCount) + positionDistance;
|
|
644
|
+
const positionY = globalThis.innerHeight * (j / gridYCount) + positionDistance;
|
|
645
|
+
const position = {
|
|
646
|
+
x: positionX,
|
|
647
|
+
y: positionY,
|
|
648
|
+
};
|
|
649
|
+
if (position.x > maxPostionX) {
|
|
650
|
+
position.x = maxPostionX;
|
|
651
|
+
}
|
|
652
|
+
if (position.y > maxPostionY) {
|
|
653
|
+
position.y = maxPostionY;
|
|
654
|
+
}
|
|
655
|
+
defaultCalcPostion.push(position);
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
const delayHandlerElementPostionList = defaultCalcPostion;
|
|
664
659
|
if ($el) {
|
|
665
660
|
delayHandlerElementPostionList.length = 0;
|
|
666
661
|
if (Array.isArray($el)) {
|
|
@@ -672,61 +667,79 @@ class PopsUtils {
|
|
|
672
667
|
}
|
|
673
668
|
const positionInfoList = delayHandlerElementPostionList
|
|
674
669
|
.map((position) => {
|
|
675
|
-
let
|
|
670
|
+
let $position;
|
|
676
671
|
let positionX;
|
|
677
672
|
let positionY;
|
|
678
673
|
if (position instanceof HTMLElement) {
|
|
679
|
-
|
|
674
|
+
$position = position;
|
|
680
675
|
const nodeRect = position.getBoundingClientRect();
|
|
681
676
|
positionX = nodeRect.x + nodeRect.width / 2;
|
|
682
677
|
positionY = nodeRect.y + nodeRect.height / 2;
|
|
683
678
|
}
|
|
684
679
|
else {
|
|
685
|
-
|
|
680
|
+
$position = document.elementFromPoint(position.x, position.y);
|
|
686
681
|
positionX = position.x;
|
|
687
682
|
positionY = position.y;
|
|
688
683
|
}
|
|
689
|
-
const shadowRoot =
|
|
684
|
+
const shadowRoot = $position?.shadowRoot;
|
|
690
685
|
if (shadowRoot) {
|
|
691
|
-
|
|
686
|
+
// 处理ShadowRoot
|
|
687
|
+
$position = shadowRoot.elementFromPoint(positionX, positionY);
|
|
692
688
|
}
|
|
693
|
-
if (
|
|
694
|
-
return;
|
|
695
|
-
if (positionNode instanceof HTMLScriptElement)
|
|
696
|
-
return;
|
|
697
|
-
if (positionNode instanceof HTMLMetaElement)
|
|
698
|
-
return;
|
|
699
|
-
if (positionNode instanceof HTMLHeadElement)
|
|
700
|
-
return;
|
|
701
|
-
if (!(positionNode instanceof HTMLElement))
|
|
689
|
+
if (!($position instanceof HTMLElement))
|
|
702
690
|
return;
|
|
703
|
-
let parent =
|
|
691
|
+
let $parent = $position;
|
|
704
692
|
let zIndex = 0;
|
|
705
|
-
let maxZIndexNode = null;
|
|
706
|
-
|
|
707
|
-
|
|
693
|
+
let $maxZIndexNode = null;
|
|
694
|
+
let rect = {
|
|
695
|
+
x: 0,
|
|
696
|
+
y: 0,
|
|
697
|
+
width: 0,
|
|
698
|
+
height: 0,
|
|
699
|
+
top: 0,
|
|
700
|
+
right: 0,
|
|
701
|
+
bottom: 0,
|
|
702
|
+
left: 0,
|
|
703
|
+
};
|
|
704
|
+
while ($parent) {
|
|
705
|
+
const nodeStyle = globalThis.getComputedStyle($parent);
|
|
708
706
|
const nodeZIndex = parseInt(nodeStyle.zIndex);
|
|
709
707
|
if (nodeStyle.position !== "static" && !isNaN(nodeZIndex)) {
|
|
710
708
|
if (nodeZIndex > zIndex) {
|
|
711
709
|
zIndex = nodeZIndex;
|
|
712
|
-
maxZIndexNode = parent;
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
parent = parent.parentElement;
|
|
710
|
+
$maxZIndexNode = $parent;
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
$parent = $parent.parentElement;
|
|
714
|
+
}
|
|
715
|
+
if ($maxZIndexNode) {
|
|
716
|
+
const maxRect = $maxZIndexNode.getBoundingClientRect();
|
|
717
|
+
rect = {
|
|
718
|
+
x: maxRect.x,
|
|
719
|
+
y: maxRect.y,
|
|
720
|
+
width: maxRect.width,
|
|
721
|
+
height: maxRect.height,
|
|
722
|
+
top: maxRect.top,
|
|
723
|
+
right: maxRect.right,
|
|
724
|
+
bottom: maxRect.bottom,
|
|
725
|
+
left: maxRect.left,
|
|
726
|
+
};
|
|
716
727
|
}
|
|
717
728
|
return {
|
|
718
|
-
/**
|
|
729
|
+
/** 计算偏移量后的z-index值 */
|
|
719
730
|
zIndex: zIndex + deviation,
|
|
720
|
-
/**
|
|
731
|
+
/** 获取到的最大的z-index值 */
|
|
721
732
|
originZIndex: zIndex,
|
|
722
733
|
/** 拥有最大z-index的元素 */
|
|
723
|
-
node: maxZIndexNode,
|
|
734
|
+
node: $maxZIndexNode,
|
|
724
735
|
/** 目标坐标元素 */
|
|
725
|
-
positionNode:
|
|
726
|
-
/** x坐标 */
|
|
736
|
+
positionNode: $position,
|
|
737
|
+
/** 目标x坐标 */
|
|
727
738
|
positionX: positionX,
|
|
728
|
-
/** y坐标 */
|
|
739
|
+
/** 目标y坐标 */
|
|
729
740
|
positionY: positionY,
|
|
741
|
+
/** node位置信息 */
|
|
742
|
+
rect,
|
|
730
743
|
};
|
|
731
744
|
})
|
|
732
745
|
.filter((it) => it != null);
|
|
@@ -777,11 +790,22 @@ const PopsSafeUtils = {
|
|
|
777
790
|
const PopsCommonCSSClassName = {
|
|
778
791
|
flexCenter: "pops-flex-items-center",
|
|
779
792
|
flexYCenter: "pops-flex-y-center",
|
|
793
|
+
flexXCenter: "pops-flex-x-center",
|
|
780
794
|
hide: "pops-hide",
|
|
781
795
|
hideImportant: "pops-hide-important",
|
|
796
|
+
noBorder: "pops-no-border",
|
|
797
|
+
noBorderImportant: "pops-no-border-important",
|
|
782
798
|
userSelectNone: "pops-user-select-none",
|
|
783
|
-
|
|
799
|
+
lineHeightCenter: "pops-line-height-center",
|
|
800
|
+
widthFill: "pops-width-fill",
|
|
801
|
+
textIsDisabled: "pops-text-is-disabled",
|
|
802
|
+
textIsDisabledImportant: "pops-text-is-disabled-important",
|
|
803
|
+
};
|
|
784
804
|
|
|
805
|
+
/**
|
|
806
|
+
* 存储在元素属性上的事件名
|
|
807
|
+
*/
|
|
808
|
+
const SymbolEvents = Symbol("events_" + (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1));
|
|
785
809
|
class PopsDOMUtilsEvent {
|
|
786
810
|
on(element, eventType, selector, callback, option) {
|
|
787
811
|
/**
|
|
@@ -3126,6 +3150,134 @@ const PopsInstData = {
|
|
|
3126
3150
|
tooltip: [],
|
|
3127
3151
|
};
|
|
3128
3152
|
|
|
3153
|
+
const PopsInstanceUtils = {
|
|
3154
|
+
/**
|
|
3155
|
+
* 获取pops所有弹窗中的最大的z-index
|
|
3156
|
+
* @param deviation
|
|
3157
|
+
*/
|
|
3158
|
+
getPopsMaxZIndex(deviation = 1) {
|
|
3159
|
+
deviation = Number.isNaN(deviation) ? 1 : deviation;
|
|
3160
|
+
// 最大值 2147483647
|
|
3161
|
+
// const browserMaxZIndex = Math.pow(2, 31) - 1;
|
|
3162
|
+
// 比较值 2000000000
|
|
3163
|
+
const maxZIndex = 2 * Math.pow(10, 9);
|
|
3164
|
+
// 当前页面最大的z-index
|
|
3165
|
+
let zIndex = 0;
|
|
3166
|
+
// 当前的最大z-index的元素,调试使用
|
|
3167
|
+
let maxZIndexNode = null;
|
|
3168
|
+
Object.keys(PopsInstData).forEach((instKeyName) => {
|
|
3169
|
+
const instData = PopsInstData[instKeyName];
|
|
3170
|
+
for (let index = 0; index < instData.length; index++) {
|
|
3171
|
+
const inst = instData[index];
|
|
3172
|
+
// 不对position为static和display为none的元素进行获取它们的z-index
|
|
3173
|
+
const $elList = [inst.$anim, inst.$pops, inst.$mask].filter((it) => it instanceof HTMLElement);
|
|
3174
|
+
const nodeZIndexInfoList = popsUtils.getMaxZIndexNodeInfoFromPoint($elList);
|
|
3175
|
+
const maxNodeZIndexInfo = nodeZIndexInfoList[0];
|
|
3176
|
+
if (maxNodeZIndexInfo) {
|
|
3177
|
+
const nodeZIndex = maxNodeZIndexInfo.zIndex;
|
|
3178
|
+
if (nodeZIndex > zIndex) {
|
|
3179
|
+
zIndex = nodeZIndex;
|
|
3180
|
+
maxZIndexNode = maxNodeZIndexInfo.node || maxNodeZIndexInfo.positionNode;
|
|
3181
|
+
}
|
|
3182
|
+
}
|
|
3183
|
+
}
|
|
3184
|
+
});
|
|
3185
|
+
zIndex += deviation;
|
|
3186
|
+
const isOverMaxZIndex = zIndex >= maxZIndex;
|
|
3187
|
+
if (isOverMaxZIndex) {
|
|
3188
|
+
// 超出z-index最大值
|
|
3189
|
+
zIndex = maxZIndex;
|
|
3190
|
+
}
|
|
3191
|
+
return { zIndex: zIndex, animElement: maxZIndexNode, isOverMaxZIndex };
|
|
3192
|
+
},
|
|
3193
|
+
/**
|
|
3194
|
+
* 排序数组
|
|
3195
|
+
* @param getBeforeValueFun
|
|
3196
|
+
* @param getAfterValueFun
|
|
3197
|
+
* @param sortByDesc 排序是否降序,默认降序
|
|
3198
|
+
*/
|
|
3199
|
+
sortElementListByProperty(getBeforeValueFun, getAfterValueFun, sortByDesc = true) {
|
|
3200
|
+
if (typeof sortByDesc !== "boolean") {
|
|
3201
|
+
throw new TypeError("参数 sortByDesc 必须为boolean类型");
|
|
3202
|
+
}
|
|
3203
|
+
if (getBeforeValueFun == null || getAfterValueFun == null) {
|
|
3204
|
+
throw new Error("获取前面的值或后面的值的方法不能为空");
|
|
3205
|
+
}
|
|
3206
|
+
return function (after_obj, before_obj) {
|
|
3207
|
+
const beforeValue = getBeforeValueFun(before_obj); // 前
|
|
3208
|
+
const afterValue = getAfterValueFun(after_obj); // 后
|
|
3209
|
+
if (sortByDesc) {
|
|
3210
|
+
if (afterValue > beforeValue) {
|
|
3211
|
+
return -1;
|
|
3212
|
+
}
|
|
3213
|
+
else if (afterValue < beforeValue) {
|
|
3214
|
+
return 1;
|
|
3215
|
+
}
|
|
3216
|
+
else {
|
|
3217
|
+
return 0;
|
|
3218
|
+
}
|
|
3219
|
+
}
|
|
3220
|
+
else {
|
|
3221
|
+
if (afterValue < beforeValue) {
|
|
3222
|
+
return -1;
|
|
3223
|
+
}
|
|
3224
|
+
else if (afterValue > beforeValue) {
|
|
3225
|
+
return 1;
|
|
3226
|
+
}
|
|
3227
|
+
else {
|
|
3228
|
+
return 0;
|
|
3229
|
+
}
|
|
3230
|
+
}
|
|
3231
|
+
};
|
|
3232
|
+
},
|
|
3233
|
+
/**
|
|
3234
|
+
* 是否是隐藏状态
|
|
3235
|
+
*
|
|
3236
|
+
* 检测以下项:
|
|
3237
|
+
*
|
|
3238
|
+
* + `display`: none
|
|
3239
|
+
* + `visibility`: hidden
|
|
3240
|
+
* + `opacity`: 0
|
|
3241
|
+
* + `使用了pops的自定义的隐藏class类`
|
|
3242
|
+
* @param $el 需要检测的元素
|
|
3243
|
+
*/
|
|
3244
|
+
isHide($el) {
|
|
3245
|
+
let flag = false;
|
|
3246
|
+
if ($el?.classList?.contains(PopsCommonCSSClassName.hide) ||
|
|
3247
|
+
$el?.classList?.contains(PopsCommonCSSClassName.hideImportant)) {
|
|
3248
|
+
flag = true;
|
|
3249
|
+
}
|
|
3250
|
+
else {
|
|
3251
|
+
if ($el instanceof HTMLElement) {
|
|
3252
|
+
const style = $el.style;
|
|
3253
|
+
flag = style.display.includes("none") || style.visibility.includes("hidden") || style.opacity !== "0";
|
|
3254
|
+
}
|
|
3255
|
+
if (!flag) {
|
|
3256
|
+
const style = globalThis.getComputedStyle($el);
|
|
3257
|
+
flag = style.display.includes("none") || style.visibility.includes("hidden") || style.opacity !== "0";
|
|
3258
|
+
}
|
|
3259
|
+
}
|
|
3260
|
+
return flag;
|
|
3261
|
+
},
|
|
3262
|
+
/**
|
|
3263
|
+
* 判断元素是否是在`.pops`内
|
|
3264
|
+
* @param $el 目标元素
|
|
3265
|
+
*/
|
|
3266
|
+
isNodeInPopsNode($el) {
|
|
3267
|
+
return !!($el.closest(".pops") || $el.matches(".pops"));
|
|
3268
|
+
},
|
|
3269
|
+
/**
|
|
3270
|
+
* 判断是否是`.pops-anim`元素
|
|
3271
|
+
* @param $el 目标元素
|
|
3272
|
+
*/
|
|
3273
|
+
isAnimNode($el) {
|
|
3274
|
+
return !!($el?.localName?.toLowerCase() === "div" &&
|
|
3275
|
+
$el.className &&
|
|
3276
|
+
$el.className === "pops-anim" &&
|
|
3277
|
+
$el.hasAttribute("anim"));
|
|
3278
|
+
},
|
|
3279
|
+
};
|
|
3280
|
+
|
|
3129
3281
|
const PopsInstHandler = {
|
|
3130
3282
|
/**
|
|
3131
3283
|
* 删除配置中对应的对象
|
|
@@ -3188,7 +3340,7 @@ const PopsInstHandler = {
|
|
|
3188
3340
|
return totalInstConfigList;
|
|
3189
3341
|
},
|
|
3190
3342
|
/**
|
|
3191
|
-
*
|
|
3343
|
+
* 显示
|
|
3192
3344
|
* @param popsType
|
|
3193
3345
|
* @param instConfigList
|
|
3194
3346
|
* @param guid
|
|
@@ -3196,24 +3348,34 @@ const PopsInstHandler = {
|
|
|
3196
3348
|
* @param $anim
|
|
3197
3349
|
* @param $mask
|
|
3198
3350
|
*/
|
|
3199
|
-
|
|
3351
|
+
show(config, popsType, instConfigList, guid, $anim, $mask) {
|
|
3200
3352
|
// oxlint-disable-next-line no-async-promise-executor
|
|
3201
3353
|
return new Promise(async (resolve) => {
|
|
3202
3354
|
const $pops = $anim.querySelector(".pops[type-value]");
|
|
3203
3355
|
const fintInst = instConfigList.find((instConfigItem) => instConfigItem.guid === guid);
|
|
3204
3356
|
if (fintInst) {
|
|
3205
|
-
//
|
|
3357
|
+
// 由于是隐蔽状态
|
|
3358
|
+
// 先设置好动画状态
|
|
3359
|
+
// 再显示,会自执行动画
|
|
3360
|
+
const checkVisible = () => {
|
|
3361
|
+
if (!PopsInstanceUtils.isHide($anim)) {
|
|
3362
|
+
return true;
|
|
3363
|
+
}
|
|
3364
|
+
else {
|
|
3365
|
+
return false;
|
|
3366
|
+
}
|
|
3367
|
+
};
|
|
3206
3368
|
const startAnim = async () => {
|
|
3207
3369
|
if (popsType === "drawer") {
|
|
3208
3370
|
// drawer是抽屉
|
|
3209
3371
|
// 单独处理动画
|
|
3210
3372
|
const drawerConfig = config;
|
|
3211
|
-
await popsUtils.sleep(drawerConfig.
|
|
3373
|
+
await popsUtils.sleep(drawerConfig.openDelay ?? 0);
|
|
3212
3374
|
if ($mask) {
|
|
3213
|
-
popsDOMUtils.css($mask, "display", "
|
|
3375
|
+
popsDOMUtils.css($mask, "display", "");
|
|
3214
3376
|
}
|
|
3215
3377
|
const direction = drawerConfig.direction;
|
|
3216
|
-
const size =
|
|
3378
|
+
const size = drawerConfig.size.toString();
|
|
3217
3379
|
if (["top", "bottom"].includes(direction)) {
|
|
3218
3380
|
$pops.style.setProperty("height", size);
|
|
3219
3381
|
}
|
|
@@ -3221,26 +3383,26 @@ const PopsInstHandler = {
|
|
|
3221
3383
|
$pops.style.setProperty("width", size);
|
|
3222
3384
|
}
|
|
3223
3385
|
else {
|
|
3224
|
-
console.error("未知direction
|
|
3386
|
+
console.error("未知direction:", direction);
|
|
3225
3387
|
}
|
|
3226
3388
|
}
|
|
3227
3389
|
else {
|
|
3228
|
-
instConfigItem.$anim.style.width = "
|
|
3229
|
-
instConfigItem.$anim.style.height = "
|
|
3230
|
-
Reflect.set(instConfigItem.$anim.style, "animation-name",
|
|
3390
|
+
instConfigItem.$anim.style.width = "";
|
|
3391
|
+
instConfigItem.$anim.style.height = "";
|
|
3392
|
+
Reflect.set(instConfigItem.$anim.style, "animation-name", animName);
|
|
3231
3393
|
}
|
|
3232
|
-
|
|
3233
|
-
const endCallback = () => {
|
|
3234
|
-
instConfigItem.$anim.style.display = "none";
|
|
3394
|
+
instConfigItem.$anim.style.display = "";
|
|
3235
3395
|
if (instConfigItem.$mask) {
|
|
3236
|
-
instConfigItem.$mask.style.display = "
|
|
3396
|
+
instConfigItem.$mask.style.display = "";
|
|
3237
3397
|
}
|
|
3238
|
-
|
|
3398
|
+
};
|
|
3399
|
+
const endCallback = () => {
|
|
3400
|
+
fintInst.emitter.emit("pops:show", instConfigItem);
|
|
3239
3401
|
};
|
|
3240
3402
|
const instConfigItem = fintInst;
|
|
3241
|
-
|
|
3242
|
-
|
|
3243
|
-
if (PopsAnimation.hasAnim(
|
|
3403
|
+
const animName = instConfigItem.$anim.getAttribute("anim").replace("-reverse", "");
|
|
3404
|
+
fintInst.emitter.emit("pops:before-show", instConfigItem);
|
|
3405
|
+
if (checkVisible() && PopsAnimation.hasAnim(animName)) {
|
|
3244
3406
|
/**
|
|
3245
3407
|
* 动画结束的回调
|
|
3246
3408
|
*/
|
|
@@ -3251,22 +3413,23 @@ const PopsInstHandler = {
|
|
|
3251
3413
|
};
|
|
3252
3414
|
const listener = popsDOMUtils.on(instConfigItem.$anim, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
|
|
3253
3415
|
capture: true,
|
|
3254
|
-
once: true,
|
|
3255
3416
|
});
|
|
3417
|
+
await startAnim();
|
|
3256
3418
|
}
|
|
3257
3419
|
else {
|
|
3420
|
+
await startAnim();
|
|
3258
3421
|
endCallback();
|
|
3259
3422
|
resolve();
|
|
3260
3423
|
}
|
|
3261
3424
|
}
|
|
3262
3425
|
else {
|
|
3263
|
-
console.error("
|
|
3426
|
+
console.error("show-error: 该实例未存储");
|
|
3264
3427
|
resolve();
|
|
3265
3428
|
}
|
|
3266
3429
|
});
|
|
3267
3430
|
},
|
|
3268
3431
|
/**
|
|
3269
|
-
*
|
|
3432
|
+
* 隐藏
|
|
3270
3433
|
* @param popsType
|
|
3271
3434
|
* @param instConfigList
|
|
3272
3435
|
* @param guid
|
|
@@ -3274,23 +3437,35 @@ const PopsInstHandler = {
|
|
|
3274
3437
|
* @param $anim
|
|
3275
3438
|
* @param $mask
|
|
3276
3439
|
*/
|
|
3277
|
-
|
|
3440
|
+
hide(config, popsType, instConfigList, guid, $anim, $mask) {
|
|
3278
3441
|
// oxlint-disable-next-line no-async-promise-executor
|
|
3279
3442
|
return new Promise(async (resolve) => {
|
|
3280
3443
|
const $pops = $anim.querySelector(".pops[type-value]");
|
|
3281
3444
|
const fintInst = instConfigList.find((instConfigItem) => instConfigItem.guid === guid);
|
|
3282
3445
|
if (fintInst) {
|
|
3446
|
+
// 由于是已显示状态
|
|
3447
|
+
// 先执行动画
|
|
3448
|
+
// 再隐藏
|
|
3449
|
+
// 存在实例
|
|
3450
|
+
const checkVisible = () => {
|
|
3451
|
+
if (!PopsInstanceUtils.isHide($anim)) {
|
|
3452
|
+
return true;
|
|
3453
|
+
}
|
|
3454
|
+
else {
|
|
3455
|
+
return false;
|
|
3456
|
+
}
|
|
3457
|
+
};
|
|
3283
3458
|
const startAnim = async () => {
|
|
3284
3459
|
if (popsType === "drawer") {
|
|
3285
3460
|
// drawer是抽屉
|
|
3286
3461
|
// 单独处理动画
|
|
3287
3462
|
const drawerConfig = config;
|
|
3288
|
-
await popsUtils.sleep(drawerConfig.
|
|
3463
|
+
await popsUtils.sleep(drawerConfig.closeDelay ?? 0);
|
|
3289
3464
|
if ($mask) {
|
|
3290
|
-
popsDOMUtils.css($mask, "display", "");
|
|
3465
|
+
popsDOMUtils.css($mask, "display", "none");
|
|
3291
3466
|
}
|
|
3292
3467
|
const direction = drawerConfig.direction;
|
|
3293
|
-
const size =
|
|
3468
|
+
const size = "0";
|
|
3294
3469
|
if (["top", "bottom"].includes(direction)) {
|
|
3295
3470
|
$pops.style.setProperty("height", size);
|
|
3296
3471
|
}
|
|
@@ -3298,26 +3473,27 @@ const PopsInstHandler = {
|
|
|
3298
3473
|
$pops.style.setProperty("width", size);
|
|
3299
3474
|
}
|
|
3300
3475
|
else {
|
|
3301
|
-
console.error("未知direction
|
|
3476
|
+
console.error("未知direction: ", direction);
|
|
3302
3477
|
}
|
|
3303
3478
|
}
|
|
3304
3479
|
else {
|
|
3305
|
-
instConfigItem.$anim.style.width = "";
|
|
3306
|
-
instConfigItem.$anim.style.height = "";
|
|
3307
|
-
Reflect.set(instConfigItem.$anim.style, "animation-name",
|
|
3480
|
+
instConfigItem.$anim.style.width = "100%";
|
|
3481
|
+
instConfigItem.$anim.style.height = "100%";
|
|
3482
|
+
Reflect.set(instConfigItem.$anim.style, "animation-name", reverseAnimName);
|
|
3308
3483
|
}
|
|
3309
3484
|
};
|
|
3310
3485
|
const endCallback = () => {
|
|
3311
|
-
instConfigItem.$anim.style.display = "";
|
|
3486
|
+
instConfigItem.$anim.style.display = "none";
|
|
3312
3487
|
if (instConfigItem.$mask) {
|
|
3313
|
-
instConfigItem.$mask.style.display = "";
|
|
3488
|
+
instConfigItem.$mask.style.display = "none";
|
|
3314
3489
|
}
|
|
3315
|
-
fintInst.emitter.emit("pops:
|
|
3490
|
+
fintInst.emitter.emit("pops:hide", instConfigItem);
|
|
3316
3491
|
};
|
|
3317
3492
|
const instConfigItem = fintInst;
|
|
3318
|
-
|
|
3319
|
-
|
|
3320
|
-
|
|
3493
|
+
const animName = instConfigItem.$anim.getAttribute("anim").replace("-reverse", "");
|
|
3494
|
+
const reverseAnimName = animName + "-reverse";
|
|
3495
|
+
fintInst.emitter.emit("pops:before-hide", instConfigItem);
|
|
3496
|
+
if (!checkVisible() && PopsAnimation.hasAnim(reverseAnimName)) {
|
|
3321
3497
|
/**
|
|
3322
3498
|
* 动画结束的回调
|
|
3323
3499
|
*/
|
|
@@ -3328,15 +3504,18 @@ const PopsInstHandler = {
|
|
|
3328
3504
|
};
|
|
3329
3505
|
const listener = popsDOMUtils.on(instConfigItem.$anim, popsDOMUtils.getAnimationEndNameList(), animationendCallBack, {
|
|
3330
3506
|
capture: true,
|
|
3507
|
+
once: true,
|
|
3331
3508
|
});
|
|
3509
|
+
await startAnim();
|
|
3332
3510
|
}
|
|
3333
3511
|
else {
|
|
3512
|
+
await startAnim();
|
|
3334
3513
|
endCallback();
|
|
3335
3514
|
resolve();
|
|
3336
3515
|
}
|
|
3337
3516
|
}
|
|
3338
3517
|
else {
|
|
3339
|
-
console.error("
|
|
3518
|
+
console.error("hide-error: 该实例未存储");
|
|
3340
3519
|
resolve();
|
|
3341
3520
|
}
|
|
3342
3521
|
});
|
|
@@ -3376,7 +3555,7 @@ const PopsInstHandler = {
|
|
|
3376
3555
|
await new Promise(async (resolve) => {
|
|
3377
3556
|
const $pops = $anim.querySelector(".pops[type-value]");
|
|
3378
3557
|
const drawerConfig = config;
|
|
3379
|
-
const
|
|
3558
|
+
const startAnim = () => {
|
|
3380
3559
|
/**
|
|
3381
3560
|
* 弹窗已关闭的回调
|
|
3382
3561
|
*/
|
|
@@ -3417,7 +3596,7 @@ const PopsInstHandler = {
|
|
|
3417
3596
|
};
|
|
3418
3597
|
if (popsType === "drawer") {
|
|
3419
3598
|
await popsUtils.sleep(drawerConfig.closeDelay ?? 0);
|
|
3420
|
-
|
|
3599
|
+
startAnim();
|
|
3421
3600
|
}
|
|
3422
3601
|
else {
|
|
3423
3602
|
await PopsInstHandler.removeInstance([instConfigList], guid);
|
|
@@ -3697,11 +3876,11 @@ const PopsHandler = {
|
|
|
3697
3876
|
* 点击其它区域的事件
|
|
3698
3877
|
* @param event
|
|
3699
3878
|
*/
|
|
3700
|
-
|
|
3879
|
+
const clickEvent = (event) => {
|
|
3701
3880
|
popsDOMUtils.preventEvent(event);
|
|
3702
3881
|
// 获取该类型实例存储列表
|
|
3703
3882
|
const targetInst = PopsInstData[config.type];
|
|
3704
|
-
|
|
3883
|
+
const continueExec = () => {
|
|
3705
3884
|
if (config.config.mask.clickEvent.toClose) {
|
|
3706
3885
|
// 关闭
|
|
3707
3886
|
return PopsInstHandler.close(config.config, config.type, targetInst, config.guid, config.animElement);
|
|
@@ -3710,37 +3889,26 @@ const PopsHandler = {
|
|
|
3710
3889
|
// 隐藏
|
|
3711
3890
|
return PopsInstHandler.hide(config.config, config.type, targetInst, config.guid, config.animElement, result.maskElement);
|
|
3712
3891
|
}
|
|
3713
|
-
}
|
|
3892
|
+
};
|
|
3714
3893
|
if (typeof config.config.mask.clickCallBack === "function") {
|
|
3715
|
-
config.config.mask.clickCallBack(
|
|
3894
|
+
config.config.mask.clickCallBack(continueExec, config.config);
|
|
3716
3895
|
}
|
|
3717
3896
|
else {
|
|
3718
|
-
|
|
3897
|
+
continueExec();
|
|
3719
3898
|
}
|
|
3720
3899
|
return false;
|
|
3721
|
-
}
|
|
3900
|
+
};
|
|
3722
3901
|
// 判断是否启用了遮罩层点击动作
|
|
3723
3902
|
if (config.config.mask.clickEvent.toClose || config.config.mask.clickEvent.toHide) {
|
|
3724
|
-
/**
|
|
3725
|
-
* 判断点击的元素是否是动画层的元素
|
|
3726
|
-
* @param element
|
|
3727
|
-
* @returns
|
|
3728
|
-
*/
|
|
3729
|
-
function isAnimElement(element) {
|
|
3730
|
-
return Boolean(element?.localName?.toLowerCase() === "div" &&
|
|
3731
|
-
element.className &&
|
|
3732
|
-
element.className === "pops-anim" &&
|
|
3733
|
-
element.hasAttribute("anim"));
|
|
3734
|
-
}
|
|
3735
3903
|
// 判断按下的元素是否是pops-anim
|
|
3736
3904
|
popsDOMUtils.on(config.animElement, "pointerup", (event) => {
|
|
3737
3905
|
const $click = event.composedPath()[0];
|
|
3738
|
-
isMaskClick =
|
|
3906
|
+
isMaskClick = PopsInstanceUtils.isAnimNode($click);
|
|
3739
3907
|
});
|
|
3740
3908
|
// 如果有动画层,在动画层上监听点击事件
|
|
3741
3909
|
popsDOMUtils.on(config.animElement, "click", (event) => {
|
|
3742
3910
|
const $click = event.composedPath()[0];
|
|
3743
|
-
if (isMaskClick &&
|
|
3911
|
+
if (isMaskClick && PopsInstanceUtils.isAnimNode($click)) {
|
|
3744
3912
|
return clickEvent(event);
|
|
3745
3913
|
}
|
|
3746
3914
|
});
|
|
@@ -4168,8 +4336,8 @@ const PopsAlertDefaultConfig = () => {
|
|
|
4168
4336
|
style: null,
|
|
4169
4337
|
lightStyle: null,
|
|
4170
4338
|
darkStyle: null,
|
|
4171
|
-
beforeAppendToPageCallBack() { },
|
|
4172
4339
|
stopKeyDownEventPropagation: true,
|
|
4340
|
+
emitter: null,
|
|
4173
4341
|
};
|
|
4174
4342
|
};
|
|
4175
4343
|
|
|
@@ -4178,11 +4346,11 @@ const PopsAlert = {
|
|
|
4178
4346
|
const guid = popsUtils.getRandomGUID();
|
|
4179
4347
|
// 设置当前类型
|
|
4180
4348
|
const popsType = "alert";
|
|
4181
|
-
const emitter = new EventEmiter(popsType);
|
|
4182
4349
|
let config = PopsAlertDefaultConfig();
|
|
4183
4350
|
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
4184
4351
|
config = popsUtils.assign(config, __config__);
|
|
4185
4352
|
config = PopsHandler.handleOnly(popsType, config);
|
|
4353
|
+
const emitter = config.emitter ?? new EventEmiter(popsType);
|
|
4186
4354
|
const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
|
|
4187
4355
|
PopsHandler.handleInit($shadowRoot, [
|
|
4188
4356
|
{
|
|
@@ -4376,8 +4544,8 @@ const PopsConfirmDefaultConfig = () => {
|
|
|
4376
4544
|
style: null,
|
|
4377
4545
|
lightStyle: null,
|
|
4378
4546
|
darkStyle: null,
|
|
4379
|
-
beforeAppendToPageCallBack() { },
|
|
4380
4547
|
stopKeyDownEventPropagation: true,
|
|
4548
|
+
emitter: null,
|
|
4381
4549
|
};
|
|
4382
4550
|
};
|
|
4383
4551
|
|
|
@@ -4386,11 +4554,11 @@ const PopsConfirm = {
|
|
|
4386
4554
|
const guid = popsUtils.getRandomGUID();
|
|
4387
4555
|
// 设置当前类型
|
|
4388
4556
|
const popsType = "confirm";
|
|
4389
|
-
const emitter = new EventEmiter(popsType);
|
|
4390
4557
|
let config = PopsConfirmDefaultConfig();
|
|
4391
4558
|
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
4392
4559
|
config = popsUtils.assign(config, __config__);
|
|
4393
4560
|
config = PopsHandler.handleOnly(popsType, config);
|
|
4561
|
+
const emitter = config.emitter ?? new EventEmiter(popsType);
|
|
4394
4562
|
const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
|
|
4395
4563
|
PopsHandler.handleInit($shadowRoot, [
|
|
4396
4564
|
{
|
|
@@ -4583,9 +4751,9 @@ const PopsDrawerDefaultConfig = () => {
|
|
|
4583
4751
|
style: null,
|
|
4584
4752
|
lightStyle: null,
|
|
4585
4753
|
darkStyle: null,
|
|
4586
|
-
beforeAppendToPageCallBack() { },
|
|
4587
4754
|
forbiddenScroll: false,
|
|
4588
4755
|
stopKeyDownEventPropagation: true,
|
|
4756
|
+
emitter: null,
|
|
4589
4757
|
};
|
|
4590
4758
|
};
|
|
4591
4759
|
|
|
@@ -4594,11 +4762,11 @@ const PopsDrawer = {
|
|
|
4594
4762
|
const guid = popsUtils.getRandomGUID();
|
|
4595
4763
|
// 设置当前类型
|
|
4596
4764
|
const popsType = "drawer";
|
|
4597
|
-
const emitter = new EventEmiter(popsType);
|
|
4598
4765
|
let config = PopsDrawerDefaultConfig();
|
|
4599
4766
|
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
4600
4767
|
config = popsUtils.assign(config, __config__);
|
|
4601
4768
|
config = PopsHandler.handleOnly(popsType, config);
|
|
4769
|
+
const emitter = config.emitter ?? new EventEmiter(popsType);
|
|
4602
4770
|
const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
|
|
4603
4771
|
PopsHandler.handleInit($shadowRoot, [
|
|
4604
4772
|
{
|
|
@@ -4809,6 +4977,7 @@ const PopsLoadingDefaultConfig = () => {
|
|
|
4809
4977
|
darkStyle: null,
|
|
4810
4978
|
addIndexCSS: true,
|
|
4811
4979
|
stopKeyDownEventPropagation: true,
|
|
4980
|
+
emitter: null,
|
|
4812
4981
|
};
|
|
4813
4982
|
};
|
|
4814
4983
|
|
|
@@ -4816,19 +4985,19 @@ const PopsLoading = {
|
|
|
4816
4985
|
init(__config__) {
|
|
4817
4986
|
const guid = popsUtils.getRandomGUID();
|
|
4818
4987
|
// 设置当前类型
|
|
4819
|
-
const
|
|
4820
|
-
const emitter = new EventEmiter(PopsType);
|
|
4988
|
+
const popsType = "loading";
|
|
4821
4989
|
let config = PopsLoadingDefaultConfig();
|
|
4822
4990
|
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
4823
4991
|
config = popsUtils.assign(config, __config__);
|
|
4824
|
-
config = PopsHandler.handleOnly(
|
|
4992
|
+
config = PopsHandler.handleOnly(popsType, config);
|
|
4993
|
+
const emitter = config.emitter ?? new EventEmiter(popsType);
|
|
4825
4994
|
// 先把z-index提取出来
|
|
4826
4995
|
const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
|
|
4827
4996
|
const maskHTML = PopsElementHandler.createMask(guid, zIndex);
|
|
4828
4997
|
const { contentPStyle } = PopsElementHandler.createContentStyle("loading", config);
|
|
4829
|
-
const animHTML = PopsElementHandler.createAnim(guid,
|
|
4998
|
+
const animHTML = PopsElementHandler.createAnim(guid, popsType, config,
|
|
4830
4999
|
/*html*/ `
|
|
4831
|
-
<div class="pops-content pops-${
|
|
5000
|
+
<div class="pops-content pops-${popsType}-content">${config.addIndexCSS
|
|
4832
5001
|
? /*html*/ `
|
|
4833
5002
|
<style data-model-name="index">${PopsCSS.index}</style>
|
|
4834
5003
|
<style data-model-name="anim">${PopsCSS.anim}</style>
|
|
@@ -4839,13 +5008,13 @@ const PopsLoading = {
|
|
|
4839
5008
|
${PopsCSS.loadingCSS}
|
|
4840
5009
|
</style>
|
|
4841
5010
|
${config.style != null ? `<style>${config.style}</style>` : ""}
|
|
4842
|
-
<p pops class="pops-${
|
|
5011
|
+
<p pops class="pops-${popsType}-content-text" style="${contentPStyle}">${config.content.text}</p>
|
|
4843
5012
|
</div>`, "", zIndex);
|
|
4844
5013
|
/**
|
|
4845
5014
|
* 弹窗的主元素,包括动画层
|
|
4846
5015
|
*/
|
|
4847
5016
|
const $anim = PopsElementHandler.parseElement(animHTML);
|
|
4848
|
-
const { $pops: $pops } = PopsHandler.handleQueryElement($anim,
|
|
5017
|
+
const { $pops: $pops } = PopsHandler.handleQueryElement($anim, popsType);
|
|
4849
5018
|
/**
|
|
4850
5019
|
* 遮罩层元素
|
|
4851
5020
|
*/
|
|
@@ -4857,7 +5026,7 @@ const PopsLoading = {
|
|
|
4857
5026
|
if (config.mask.enable) {
|
|
4858
5027
|
// 创建遮罩层
|
|
4859
5028
|
const handleMask = PopsHandler.handleMask({
|
|
4860
|
-
type:
|
|
5029
|
+
type: popsType,
|
|
4861
5030
|
guid: guid,
|
|
4862
5031
|
config: config,
|
|
4863
5032
|
animElement: $anim,
|
|
@@ -4866,12 +5035,12 @@ const PopsLoading = {
|
|
|
4866
5035
|
$mask = handleMask.maskElement;
|
|
4867
5036
|
$elList.push($mask);
|
|
4868
5037
|
}
|
|
4869
|
-
const evtConfig = PopsHandler.handleLoadingEventConfig(config, guid,
|
|
5038
|
+
const evtConfig = PopsHandler.handleLoadingEventConfig(config, guid, popsType, $anim, $pops, emitter, $mask);
|
|
4870
5039
|
popsDOMUtils.append(config.$parent, $elList);
|
|
4871
5040
|
if ($mask != null) {
|
|
4872
5041
|
$anim.after($mask);
|
|
4873
5042
|
}
|
|
4874
|
-
PopsHandler.handlePush(
|
|
5043
|
+
PopsHandler.handlePush(popsType, {
|
|
4875
5044
|
$shadowContainer: $pops,
|
|
4876
5045
|
$shadowRoot: $pops,
|
|
4877
5046
|
guid: guid,
|
|
@@ -5040,8 +5209,8 @@ const PopsFolderDefaultConfig = () => {
|
|
|
5040
5209
|
style: null,
|
|
5041
5210
|
lightStyle: null,
|
|
5042
5211
|
darkStyle: null,
|
|
5043
|
-
beforeAppendToPageCallBack() { },
|
|
5044
5212
|
stopKeyDownEventPropagation: true,
|
|
5213
|
+
emitter: null,
|
|
5045
5214
|
};
|
|
5046
5215
|
};
|
|
5047
5216
|
|
|
@@ -5078,11 +5247,11 @@ const PopsFolder = {
|
|
|
5078
5247
|
const guid = popsUtils.getRandomGUID();
|
|
5079
5248
|
// 设置当前类型
|
|
5080
5249
|
const popsType = "folder";
|
|
5081
|
-
const emitter = new EventEmiter(popsType);
|
|
5082
5250
|
let config = PopsFolderDefaultConfig();
|
|
5083
5251
|
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
5084
5252
|
config = popsUtils.assign(config, __config__);
|
|
5085
5253
|
config = PopsHandler.handleOnly(popsType, config);
|
|
5254
|
+
const emitter = config.emitter ?? new EventEmiter(popsType);
|
|
5086
5255
|
const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
|
|
5087
5256
|
PopsHandler.handleInit($shadowRoot, [
|
|
5088
5257
|
{
|
|
@@ -6005,8 +6174,8 @@ const PopsIframeDefaultConfig = () => {
|
|
|
6005
6174
|
style: null,
|
|
6006
6175
|
lightStyle: null,
|
|
6007
6176
|
darkStyle: null,
|
|
6008
|
-
beforeAppendToPageCallBack() { },
|
|
6009
6177
|
stopKeyDownEventPropagation: true,
|
|
6178
|
+
emitter: null,
|
|
6010
6179
|
};
|
|
6011
6180
|
};
|
|
6012
6181
|
|
|
@@ -6015,7 +6184,6 @@ const PopsIframe = {
|
|
|
6015
6184
|
const guid = popsUtils.getRandomGUID();
|
|
6016
6185
|
// 设置当前类型
|
|
6017
6186
|
const popsType = "iframe";
|
|
6018
|
-
const emitter = new EventEmiter(popsType);
|
|
6019
6187
|
let config = PopsIframeDefaultConfig();
|
|
6020
6188
|
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
6021
6189
|
config = popsUtils.assign(config, __config__);
|
|
@@ -6023,6 +6191,8 @@ const PopsIframe = {
|
|
|
6023
6191
|
throw new TypeError("config.url must not be null.");
|
|
6024
6192
|
}
|
|
6025
6193
|
config = PopsHandler.handleOnly(popsType, config);
|
|
6194
|
+
const emitter = config.emitter ??
|
|
6195
|
+
new EventEmiter(popsType);
|
|
6026
6196
|
const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
|
|
6027
6197
|
PopsHandler.handleInit($shadowRoot, [
|
|
6028
6198
|
{
|
|
@@ -6050,7 +6220,7 @@ const PopsIframe = {
|
|
|
6050
6220
|
css: PopsCSS.iframeCSS,
|
|
6051
6221
|
},
|
|
6052
6222
|
]);
|
|
6053
|
-
const maskExtraStyle = config.animation != null && config.animation != "" ? "position:absolute;" : "";
|
|
6223
|
+
const maskExtraStyle = config.animation != null && config.animation != "" && config.animation ? "position:absolute;" : "";
|
|
6054
6224
|
// 先把z-index提取出来
|
|
6055
6225
|
const zIndex = PopsHandler.getTargerOrFunctionValue(config.zIndex);
|
|
6056
6226
|
const maskHTML = PopsElementHandler.createMask(guid, zIndex, maskExtraStyle);
|
|
@@ -7131,9 +7301,9 @@ const PopsPanelDefaultConfig = () => {
|
|
|
7131
7301
|
style: null,
|
|
7132
7302
|
lightStyle: null,
|
|
7133
7303
|
darkStyle: null,
|
|
7134
|
-
beforeAppendToPageCallBack() { },
|
|
7135
7304
|
stopKeyDownEventPropagation: true,
|
|
7136
7305
|
listenEscapeKeyUpToExitDeepMenu: true,
|
|
7306
|
+
emitter: null,
|
|
7137
7307
|
};
|
|
7138
7308
|
};
|
|
7139
7309
|
|
|
@@ -7245,7 +7415,7 @@ const PopsTooltipDefaultConfig = () => {
|
|
|
7245
7415
|
style: "",
|
|
7246
7416
|
lightStyle: null,
|
|
7247
7417
|
darkStyle: null,
|
|
7248
|
-
|
|
7418
|
+
emitter: null,
|
|
7249
7419
|
};
|
|
7250
7420
|
};
|
|
7251
7421
|
|
|
@@ -7713,7 +7883,6 @@ const PopsTooltip = {
|
|
|
7713
7883
|
const guid = popsUtils.getRandomGUID();
|
|
7714
7884
|
// 设置当前类型
|
|
7715
7885
|
const popsType = "tooltip";
|
|
7716
|
-
const emitter = new EventEmiter(popsType);
|
|
7717
7886
|
let config = PopsTooltipDefaultConfig();
|
|
7718
7887
|
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
7719
7888
|
config = popsUtils.assign(config, __config__);
|
|
@@ -7730,6 +7899,7 @@ const PopsTooltip = {
|
|
|
7730
7899
|
config.onShowEventName += ` ${it}`;
|
|
7731
7900
|
});
|
|
7732
7901
|
}
|
|
7902
|
+
const emitter = config.emitter ?? new EventEmiter(popsType);
|
|
7733
7903
|
const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
|
|
7734
7904
|
PopsHandler.handleInit($shadowRoot, [
|
|
7735
7905
|
{
|
|
@@ -9644,12 +9814,12 @@ const PanelHandlerComponents = () => {
|
|
|
9644
9814
|
},
|
|
9645
9815
|
mask: {
|
|
9646
9816
|
enable: true,
|
|
9647
|
-
clickCallBack(
|
|
9817
|
+
clickCallBack(continueExec) {
|
|
9648
9818
|
const ret = dialogCloseCallback();
|
|
9649
9819
|
if (typeof ret === "boolean" && !ret) {
|
|
9650
9820
|
return;
|
|
9651
9821
|
}
|
|
9652
|
-
|
|
9822
|
+
continueExec();
|
|
9653
9823
|
},
|
|
9654
9824
|
clickEvent: {
|
|
9655
9825
|
toClose: true,
|
|
@@ -10861,8 +11031,8 @@ const PanelHandlerComponents = () => {
|
|
|
10861
11031
|
},
|
|
10862
11032
|
mask: {
|
|
10863
11033
|
enable: true,
|
|
10864
|
-
clickCallBack(
|
|
10865
|
-
|
|
11034
|
+
clickCallBack(continueExec) {
|
|
11035
|
+
continueExec();
|
|
10866
11036
|
dialogCloseCallback();
|
|
10867
11037
|
},
|
|
10868
11038
|
clickEvent: {
|
|
@@ -11595,11 +11765,11 @@ const PopsPanel = {
|
|
|
11595
11765
|
const guid = popsUtils.getRandomGUID();
|
|
11596
11766
|
// 设置当前类型
|
|
11597
11767
|
const popsType = "panel";
|
|
11598
|
-
const emitter = new EventEmiter(popsType);
|
|
11599
11768
|
let config = PopsPanelDefaultConfig();
|
|
11600
11769
|
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
11601
11770
|
config = popsUtils.assign(config, __config__);
|
|
11602
11771
|
config = PopsHandler.handleOnly(popsType, config);
|
|
11772
|
+
const emitter = config.emitter ?? new EventEmiter(popsType);
|
|
11603
11773
|
const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
|
|
11604
11774
|
PopsHandler.handleInit($shadowRoot, [
|
|
11605
11775
|
{
|
|
@@ -11849,8 +12019,8 @@ const PopsPromptDefaultConfig = () => {
|
|
|
11849
12019
|
style: null,
|
|
11850
12020
|
lightStyle: null,
|
|
11851
12021
|
darkStyle: null,
|
|
11852
|
-
beforeAppendToPageCallBack() { },
|
|
11853
12022
|
stopKeyDownEventPropagation: true,
|
|
12023
|
+
emitter: null,
|
|
11854
12024
|
};
|
|
11855
12025
|
};
|
|
11856
12026
|
|
|
@@ -11859,11 +12029,11 @@ const PopsPrompt = {
|
|
|
11859
12029
|
const guid = popsUtils.getRandomGUID();
|
|
11860
12030
|
// 设置当前类型
|
|
11861
12031
|
const popsType = "prompt";
|
|
11862
|
-
const emitter = new EventEmiter(popsType);
|
|
11863
12032
|
let config = PopsPromptDefaultConfig();
|
|
11864
12033
|
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
11865
12034
|
config = popsUtils.assign(config, __config__);
|
|
11866
12035
|
config = PopsHandler.handleOnly(popsType, config);
|
|
12036
|
+
const emitter = config.emitter ?? new EventEmiter(popsType);
|
|
11867
12037
|
const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
|
|
11868
12038
|
PopsHandler.handleInit($shadowRoot, [
|
|
11869
12039
|
{
|
|
@@ -12084,10 +12254,10 @@ const PopsRightClickMenuDefaultConfig = () => {
|
|
|
12084
12254
|
style: null,
|
|
12085
12255
|
lightStyle: null,
|
|
12086
12256
|
darkStyle: null,
|
|
12087
|
-
beforeAppendToPageCallBack() { },
|
|
12088
12257
|
limitPositionXInView: true,
|
|
12089
12258
|
limitPositionYInView: true,
|
|
12090
12259
|
beforeShowCallBack() { },
|
|
12260
|
+
emitter: null,
|
|
12091
12261
|
};
|
|
12092
12262
|
};
|
|
12093
12263
|
|
|
@@ -12096,11 +12266,11 @@ const PopsRightClickMenu = {
|
|
|
12096
12266
|
const guid = popsUtils.getRandomGUID();
|
|
12097
12267
|
// 设置当前类型
|
|
12098
12268
|
const popsType = "rightClickMenu";
|
|
12099
|
-
const emitter = new EventEmiter(popsType);
|
|
12100
12269
|
let config = PopsRightClickMenuDefaultConfig();
|
|
12101
12270
|
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
12102
12271
|
config = popsUtils.assign(config, __config__);
|
|
12103
12272
|
config = PopsHandler.handleOnly(popsType, config);
|
|
12273
|
+
const emitter = config.emitter ?? new EventEmiter(popsType);
|
|
12104
12274
|
const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
|
|
12105
12275
|
PopsHandler.handleInit($shadowRoot, [
|
|
12106
12276
|
{
|
|
@@ -12722,6 +12892,7 @@ const PopsSearchSuggestionDefaultConfig = () => {
|
|
|
12722
12892
|
style: "",
|
|
12723
12893
|
lightStyle: null,
|
|
12724
12894
|
darkStyle: null,
|
|
12895
|
+
emitter: null,
|
|
12725
12896
|
};
|
|
12726
12897
|
};
|
|
12727
12898
|
|
|
@@ -12730,7 +12901,6 @@ const PopsSearchSuggestion = {
|
|
|
12730
12901
|
const guid = popsUtils.getRandomGUID();
|
|
12731
12902
|
// 设置当前类型
|
|
12732
12903
|
const popsType = "searchSuggestion";
|
|
12733
|
-
const emitter = new EventEmiter(popsType);
|
|
12734
12904
|
let config = PopsSearchSuggestionDefaultConfig();
|
|
12735
12905
|
config = popsUtils.assign(config, GlobalConfig.getGlobalConfig());
|
|
12736
12906
|
config = popsUtils.assign(config, __config__);
|
|
@@ -12738,6 +12908,7 @@ const PopsSearchSuggestion = {
|
|
|
12738
12908
|
if (config.$inputTarget == null) {
|
|
12739
12909
|
config.$inputTarget = config.$target;
|
|
12740
12910
|
}
|
|
12911
|
+
const emitter = config.emitter ?? new EventEmiter(popsType);
|
|
12741
12912
|
const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
|
|
12742
12913
|
PopsHandler.handleInit($shadowRoot, [
|
|
12743
12914
|
{
|
|
@@ -13506,93 +13677,12 @@ const PopsSearchSuggestion = {
|
|
|
13506
13677
|
},
|
|
13507
13678
|
};
|
|
13508
13679
|
|
|
13509
|
-
const PopsInstanceUtils = {
|
|
13510
|
-
/**
|
|
13511
|
-
* 获取pops所有弹窗中的最大的z-index
|
|
13512
|
-
* @param deviation
|
|
13513
|
-
*/
|
|
13514
|
-
getPopsMaxZIndex(deviation = 1) {
|
|
13515
|
-
deviation = Number.isNaN(deviation) ? 1 : deviation;
|
|
13516
|
-
// 最大值 2147483647
|
|
13517
|
-
// const browserMaxZIndex = Math.pow(2, 31) - 1;
|
|
13518
|
-
// 比较值 2000000000
|
|
13519
|
-
const maxZIndex = 2 * Math.pow(10, 9);
|
|
13520
|
-
// 当前页面最大的z-index
|
|
13521
|
-
let zIndex = 0;
|
|
13522
|
-
// 当前的最大z-index的元素,调试使用
|
|
13523
|
-
let maxZIndexNode = null;
|
|
13524
|
-
Object.keys(PopsInstData).forEach((instKeyName) => {
|
|
13525
|
-
const instData = PopsInstData[instKeyName];
|
|
13526
|
-
for (let index = 0; index < instData.length; index++) {
|
|
13527
|
-
const inst = instData[index];
|
|
13528
|
-
// 不对position为static和display为none的元素进行获取它们的z-index
|
|
13529
|
-
const $elList = [inst.$anim, inst.$pops, inst.$mask].filter((it) => it instanceof HTMLElement);
|
|
13530
|
-
const nodeZIndexInfoList = popsUtils.getMaxZIndexNodeInfoFromPoint($elList);
|
|
13531
|
-
const maxNodeZIndexInfo = nodeZIndexInfoList[0];
|
|
13532
|
-
if (maxNodeZIndexInfo) {
|
|
13533
|
-
const nodeZIndex = maxNodeZIndexInfo.zIndex;
|
|
13534
|
-
if (nodeZIndex > zIndex) {
|
|
13535
|
-
zIndex = nodeZIndex;
|
|
13536
|
-
maxZIndexNode = maxNodeZIndexInfo.node || maxNodeZIndexInfo.positionNode;
|
|
13537
|
-
}
|
|
13538
|
-
}
|
|
13539
|
-
}
|
|
13540
|
-
});
|
|
13541
|
-
zIndex += deviation;
|
|
13542
|
-
const isOverMaxZIndex = zIndex >= maxZIndex;
|
|
13543
|
-
if (isOverMaxZIndex) {
|
|
13544
|
-
// 超出z-index最大值
|
|
13545
|
-
zIndex = maxZIndex;
|
|
13546
|
-
}
|
|
13547
|
-
return { zIndex: zIndex, animElement: maxZIndexNode, isOverMaxZIndex };
|
|
13548
|
-
},
|
|
13549
|
-
/**
|
|
13550
|
-
* 排序数组
|
|
13551
|
-
* @param getBeforeValueFun
|
|
13552
|
-
* @param getAfterValueFun
|
|
13553
|
-
* @param sortByDesc 排序是否降序,默认降序
|
|
13554
|
-
*/
|
|
13555
|
-
sortElementListByProperty(getBeforeValueFun, getAfterValueFun, sortByDesc = true) {
|
|
13556
|
-
if (typeof sortByDesc !== "boolean") {
|
|
13557
|
-
throw new TypeError("参数 sortByDesc 必须为boolean类型");
|
|
13558
|
-
}
|
|
13559
|
-
if (getBeforeValueFun == null || getAfterValueFun == null) {
|
|
13560
|
-
throw new Error("获取前面的值或后面的值的方法不能为空");
|
|
13561
|
-
}
|
|
13562
|
-
return function (after_obj, before_obj) {
|
|
13563
|
-
const beforeValue = getBeforeValueFun(before_obj); // 前
|
|
13564
|
-
const afterValue = getAfterValueFun(after_obj); // 后
|
|
13565
|
-
if (sortByDesc) {
|
|
13566
|
-
if (afterValue > beforeValue) {
|
|
13567
|
-
return -1;
|
|
13568
|
-
}
|
|
13569
|
-
else if (afterValue < beforeValue) {
|
|
13570
|
-
return 1;
|
|
13571
|
-
}
|
|
13572
|
-
else {
|
|
13573
|
-
return 0;
|
|
13574
|
-
}
|
|
13575
|
-
}
|
|
13576
|
-
else {
|
|
13577
|
-
if (afterValue < beforeValue) {
|
|
13578
|
-
return -1;
|
|
13579
|
-
}
|
|
13580
|
-
else if (afterValue > beforeValue) {
|
|
13581
|
-
return 1;
|
|
13582
|
-
}
|
|
13583
|
-
else {
|
|
13584
|
-
return 0;
|
|
13585
|
-
}
|
|
13586
|
-
}
|
|
13587
|
-
};
|
|
13588
|
-
},
|
|
13589
|
-
};
|
|
13590
|
-
|
|
13591
13680
|
class Pops {
|
|
13592
13681
|
/** 配置 */
|
|
13593
13682
|
config = {
|
|
13594
13683
|
/** 版本号 */
|
|
13595
13684
|
version: version,
|
|
13685
|
+
/** 样式配置 */
|
|
13596
13686
|
cssText: PopsCSS,
|
|
13597
13687
|
/** icon图标的svg代码 */
|
|
13598
13688
|
iconSVG: PopsIcon.$data,
|
|
@@ -13600,12 +13690,9 @@ class Pops {
|
|
|
13600
13690
|
animation: PopsAnimation.$data,
|
|
13601
13691
|
/** 存储已创建的元素 */
|
|
13602
13692
|
instData: PopsInstData,
|
|
13603
|
-
|
|
13604
|
-
|
|
13605
|
-
|
|
13606
|
-
return popsDOMUtils.preventEvent(event);
|
|
13607
|
-
},
|
|
13608
|
-
},
|
|
13693
|
+
};
|
|
13694
|
+
/** 导出的函数 */
|
|
13695
|
+
fn = {
|
|
13609
13696
|
/** pops使用的工具类 */
|
|
13610
13697
|
Utils: popsUtils,
|
|
13611
13698
|
/** pops使用的DOM工具类 */
|
|
@@ -13615,15 +13702,16 @@ class Pops {
|
|
|
13615
13702
|
/** pops处理float类型使用的工具类 */
|
|
13616
13703
|
MathFloatUtils: PopsMathFloatUtils,
|
|
13617
13704
|
/** 实例处理函数 */
|
|
13618
|
-
PopsInstHandler,
|
|
13705
|
+
InstHandler: PopsInstHandler,
|
|
13619
13706
|
/** pops.panel中用于处理各个类型的工具 */
|
|
13620
|
-
PanelHandlerComponents,
|
|
13707
|
+
PanelHandlerComponents: PanelHandlerComponents,
|
|
13621
13708
|
/** pops.panel中的动画 */
|
|
13622
|
-
PopsAnimation,
|
|
13709
|
+
Animation: PopsAnimation,
|
|
13623
13710
|
/** 事件类 */
|
|
13624
|
-
EventEmiter,
|
|
13711
|
+
EventEmiter: EventEmiter,
|
|
13712
|
+
/** 通用的CSS类名 */
|
|
13713
|
+
CommonCSSClassName: PopsCommonCSSClassName,
|
|
13625
13714
|
};
|
|
13626
|
-
init() { }
|
|
13627
13715
|
/**
|
|
13628
13716
|
* 释放原有的pops控制权
|
|
13629
13717
|
* @example
|