@whitesev/pops 3.1.2 → 3.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 +337 -250
- 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 +337 -250
- 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 +337 -250
- 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 +337 -250
- 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 +337 -250
- 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 +337 -250
- 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 +10 -10
- package/dist/types/src/components/panel/index.d.ts +2 -2
- package/dist/types/src/components/rightClickMenu/index.d.ts +1 -1
- package/dist/types/src/components/rightClickMenu/types/index.d.ts +8 -1
- package/dist/types/src/components/tooltip/index.d.ts +5 -5
- package/dist/types/src/components/tooltip/types/index.d.ts +15 -14
- package/dist/types/src/handler/PopsHandler.d.ts +4 -4
- package/dist/types/src/types/PopsDOMUtilsEventType.d.ts +39 -0
- package/dist/types/src/types/components.d.ts +2 -1
- package/dist/types/src/types/event.d.ts +13 -3
- package/dist/types/src/types/inst.d.ts +4 -0
- package/dist/types/src/utils/PopsDOMUtils.d.ts +10 -12
- package/dist/types/src/utils/PopsInstanceUtils.d.ts +2 -2
- package/package.json +9 -9
- package/src/components/alert/index.ts +3 -1
- package/src/components/confirm/index.ts +3 -1
- package/src/components/drawer/index.ts +3 -1
- package/src/components/folder/index.ts +3 -1
- package/src/components/iframe/index.ts +6 -4
- package/src/components/panel/handlerComponents.ts +26 -26
- package/src/components/panel/index.ts +3 -1
- package/src/components/prompt/index.ts +3 -1
- package/src/components/rightClickMenu/defaultConfig.ts +1 -0
- package/src/components/rightClickMenu/index.ts +18 -7
- package/src/components/rightClickMenu/types/index.ts +8 -1
- package/src/components/searchSuggestion/index.ts +7 -19
- package/src/components/tooltip/defaultConfig.ts +1 -1
- package/src/components/tooltip/index.ts +38 -23
- package/src/components/tooltip/types/index.ts +15 -14
- package/src/handler/PopsHandler.ts +22 -19
- package/src/types/PopsDOMUtilsEventType.d.ts +39 -0
- package/src/types/components.d.ts +2 -1
- package/src/types/event.d.ts +13 -3
- package/src/types/inst.d.ts +4 -0
- package/src/utils/PopsDOMUtils.ts +71 -40
- package/src/utils/PopsInstanceUtils.ts +62 -30
- package/src/utils/PopsUtils.ts +1 -1
package/dist/index.iife.js
CHANGED
|
@@ -262,47 +262,7 @@ var pops = (function () {
|
|
|
262
262
|
const cache = createCache(LAST_NUMBER_WEAK_MAP);
|
|
263
263
|
const generateUniqueNumber = createGenerateUniqueNumber(cache, LAST_NUMBER_WEAK_MAP);
|
|
264
264
|
|
|
265
|
-
const
|
|
266
|
-
return typeof sender.start === 'function';
|
|
267
|
-
};
|
|
268
|
-
|
|
269
|
-
const PORT_MAP = new WeakMap();
|
|
270
|
-
|
|
271
|
-
const extendBrokerImplementation = (partialBrokerImplementation) => ({
|
|
272
|
-
...partialBrokerImplementation,
|
|
273
|
-
connect: ({ call }) => {
|
|
274
|
-
return async () => {
|
|
275
|
-
const { port1, port2 } = new MessageChannel();
|
|
276
|
-
const portId = await call('connect', { port: port1 }, [port1]);
|
|
277
|
-
PORT_MAP.set(port2, portId);
|
|
278
|
-
return port2;
|
|
279
|
-
};
|
|
280
|
-
},
|
|
281
|
-
disconnect: ({ call }) => {
|
|
282
|
-
return async (port) => {
|
|
283
|
-
const portId = PORT_MAP.get(port);
|
|
284
|
-
if (portId === undefined) {
|
|
285
|
-
throw new Error('The given port is not connected.');
|
|
286
|
-
}
|
|
287
|
-
await call('disconnect', { portId });
|
|
288
|
-
};
|
|
289
|
-
},
|
|
290
|
-
isSupported: ({ call }) => {
|
|
291
|
-
return () => call('isSupported');
|
|
292
|
-
}
|
|
293
|
-
});
|
|
294
|
-
|
|
295
|
-
const ONGOING_REQUESTS = new WeakMap();
|
|
296
|
-
const createOrGetOngoingRequests = (sender) => {
|
|
297
|
-
if (ONGOING_REQUESTS.has(sender)) {
|
|
298
|
-
// @todo TypeScript needs to be convinced that has() works as expected.
|
|
299
|
-
return ONGOING_REQUESTS.get(sender);
|
|
300
|
-
}
|
|
301
|
-
const ongoingRequests = new Map();
|
|
302
|
-
ONGOING_REQUESTS.set(sender, ongoingRequests);
|
|
303
|
-
return ongoingRequests;
|
|
304
|
-
};
|
|
305
|
-
const createBroker = (brokerImplementation) => {
|
|
265
|
+
const createBrokerFactory = (createOrGetOngoingRequests, extendBrokerImplementation, generateUniqueNumber, isMessagePort) => (brokerImplementation) => {
|
|
306
266
|
const fullBrokerImplementation = extendBrokerImplementation(brokerImplementation);
|
|
307
267
|
return (sender) => {
|
|
308
268
|
const ongoingRequests = createOrGetOngoingRequests(sender);
|
|
@@ -345,81 +305,115 @@ var pops = (function () {
|
|
|
345
305
|
};
|
|
346
306
|
};
|
|
347
307
|
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
308
|
+
const createCreateOrGetOngoingRequests = (ongoingRequestsMap) => (sender) => {
|
|
309
|
+
if (ongoingRequestsMap.has(sender)) {
|
|
310
|
+
// @todo TypeScript needs to be convinced that has() works as expected.
|
|
311
|
+
return ongoingRequestsMap.get(sender);
|
|
312
|
+
}
|
|
313
|
+
const ongoingRequests = new Map();
|
|
314
|
+
ongoingRequestsMap.set(sender, ongoingRequests);
|
|
315
|
+
return ongoingRequests;
|
|
316
|
+
};
|
|
317
|
+
|
|
318
|
+
const createExtendBrokerImplementation = (portMap) => (partialBrokerImplementation) => ({
|
|
319
|
+
...partialBrokerImplementation,
|
|
320
|
+
connect: ({ call }) => {
|
|
321
|
+
return async () => {
|
|
322
|
+
const { port1, port2 } = new MessageChannel();
|
|
323
|
+
const portId = await call('connect', { port: port1 }, [port1]);
|
|
324
|
+
portMap.set(port2, portId);
|
|
325
|
+
return port2;
|
|
360
326
|
};
|
|
361
327
|
},
|
|
362
|
-
|
|
363
|
-
return (
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
scheduledTimeoutsState.delete(timerId);
|
|
368
|
-
});
|
|
328
|
+
disconnect: ({ call }) => {
|
|
329
|
+
return async (port) => {
|
|
330
|
+
const portId = portMap.get(port);
|
|
331
|
+
if (portId === undefined) {
|
|
332
|
+
throw new Error('The given port is not connected.');
|
|
369
333
|
}
|
|
334
|
+
await call('disconnect', { portId });
|
|
370
335
|
};
|
|
371
336
|
},
|
|
372
|
-
|
|
373
|
-
return (
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
};
|
|
398
|
-
},
|
|
399
|
-
setTimeout: ({ call }) => {
|
|
400
|
-
return (func, delay = 0, ...args) => {
|
|
401
|
-
const symbol = Symbol();
|
|
402
|
-
const timerId = generateUniqueNumber(scheduledTimeoutsState);
|
|
403
|
-
scheduledTimeoutsState.set(timerId, symbol);
|
|
404
|
-
call('set', {
|
|
405
|
-
delay,
|
|
406
|
-
now: performance.timeOrigin + performance.now(),
|
|
407
|
-
timerId,
|
|
408
|
-
timerType: 'timeout'
|
|
409
|
-
}).then(() => {
|
|
410
|
-
const state = scheduledTimeoutsState.get(timerId);
|
|
411
|
-
if (state === undefined) {
|
|
412
|
-
throw new Error('The timer is in an undefined state.');
|
|
413
|
-
}
|
|
414
|
-
if (state === symbol) {
|
|
415
|
-
// A timeout can be savely deleted because it is only called once.
|
|
416
|
-
scheduledTimeoutsState.delete(timerId);
|
|
417
|
-
func(...args);
|
|
418
|
-
}
|
|
419
|
-
});
|
|
420
|
-
return timerId;
|
|
421
|
-
};
|
|
337
|
+
isSupported: ({ call }) => {
|
|
338
|
+
return () => call('isSupported');
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
const isMessagePort = (sender) => {
|
|
343
|
+
return typeof sender.start === 'function';
|
|
344
|
+
};
|
|
345
|
+
|
|
346
|
+
const createBroker = createBrokerFactory(createCreateOrGetOngoingRequests(new WeakMap()), createExtendBrokerImplementation(new WeakMap()), generateUniqueNumber, isMessagePort);
|
|
347
|
+
|
|
348
|
+
const createClearIntervalFactory = (scheduledIntervalsState) => (clear) => (timerId) => {
|
|
349
|
+
if (typeof scheduledIntervalsState.get(timerId) === 'symbol') {
|
|
350
|
+
scheduledIntervalsState.set(timerId, null);
|
|
351
|
+
clear(timerId).then(() => {
|
|
352
|
+
scheduledIntervalsState.delete(timerId);
|
|
353
|
+
});
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
|
|
357
|
+
const createClearTimeoutFactory = (scheduledTimeoutsState) => (clear) => (timerId) => {
|
|
358
|
+
if (typeof scheduledTimeoutsState.get(timerId) === 'symbol') {
|
|
359
|
+
scheduledTimeoutsState.set(timerId, null);
|
|
360
|
+
clear(timerId).then(() => {
|
|
361
|
+
scheduledTimeoutsState.delete(timerId);
|
|
362
|
+
});
|
|
422
363
|
}
|
|
364
|
+
};
|
|
365
|
+
|
|
366
|
+
const createSetIntervalFactory = (generateUniqueNumber, scheduledIntervalsState) => (set) => (func, delay = 0, ...args) => {
|
|
367
|
+
const symbol = Symbol();
|
|
368
|
+
const timerId = generateUniqueNumber(scheduledIntervalsState);
|
|
369
|
+
scheduledIntervalsState.set(timerId, symbol);
|
|
370
|
+
const schedule = () => set(delay, timerId).then(() => {
|
|
371
|
+
const state = scheduledIntervalsState.get(timerId);
|
|
372
|
+
if (state === undefined) {
|
|
373
|
+
throw new Error('The timer is in an undefined state.');
|
|
374
|
+
}
|
|
375
|
+
if (state === symbol) {
|
|
376
|
+
func(...args);
|
|
377
|
+
// Doublecheck if the interval should still be rescheduled because it could have been cleared inside of func().
|
|
378
|
+
if (scheduledIntervalsState.get(timerId) === symbol) {
|
|
379
|
+
schedule();
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
schedule();
|
|
384
|
+
return timerId;
|
|
385
|
+
};
|
|
386
|
+
|
|
387
|
+
const createSetTimeoutFactory = (generateUniqueNumber, scheduledTimeoutsState) => (set) => (func, delay = 0, ...args) => {
|
|
388
|
+
const symbol = Symbol();
|
|
389
|
+
const timerId = generateUniqueNumber(scheduledTimeoutsState);
|
|
390
|
+
scheduledTimeoutsState.set(timerId, symbol);
|
|
391
|
+
set(delay, timerId).then(() => {
|
|
392
|
+
const state = scheduledTimeoutsState.get(timerId);
|
|
393
|
+
if (state === undefined) {
|
|
394
|
+
throw new Error('The timer is in an undefined state.');
|
|
395
|
+
}
|
|
396
|
+
if (state === symbol) {
|
|
397
|
+
// A timeout can be savely deleted because it is only called once.
|
|
398
|
+
scheduledTimeoutsState.delete(timerId);
|
|
399
|
+
func(...args);
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
return timerId;
|
|
403
|
+
};
|
|
404
|
+
|
|
405
|
+
// Prefilling the Maps with a function indexed by zero is necessary to be compliant with the specification.
|
|
406
|
+
const scheduledIntervalsState = new Map([[0, null]]); // tslint:disable-line no-empty
|
|
407
|
+
const scheduledTimeoutsState = new Map([[0, null]]); // tslint:disable-line no-empty
|
|
408
|
+
const createClearInterval = createClearIntervalFactory(scheduledIntervalsState);
|
|
409
|
+
const createClearTimeout = createClearTimeoutFactory(scheduledTimeoutsState);
|
|
410
|
+
const createSetInterval = createSetIntervalFactory(generateUniqueNumber, scheduledIntervalsState);
|
|
411
|
+
const createSetTimeout = createSetTimeoutFactory(generateUniqueNumber, scheduledTimeoutsState);
|
|
412
|
+
const wrap = createBroker({
|
|
413
|
+
clearInterval: ({ call }) => createClearInterval((timerId) => call('clear', { timerId, timerType: 'interval' })),
|
|
414
|
+
clearTimeout: ({ call }) => createClearTimeout((timerId) => call('clear', { timerId, timerType: 'timeout' })),
|
|
415
|
+
setInterval: ({ call }) => createSetInterval((delay, timerId) => call('set', { delay, now: performance.timeOrigin + performance.now(), timerId, timerType: 'interval' })),
|
|
416
|
+
setTimeout: ({ call }) => createSetTimeout((delay, timerId) => call('set', { delay, now: performance.timeOrigin + performance.now(), timerId, timerType: 'timeout' }))
|
|
423
417
|
});
|
|
424
418
|
const load = (url) => {
|
|
425
419
|
const worker = new Worker(url);
|
|
@@ -442,7 +436,7 @@ var pops = (function () {
|
|
|
442
436
|
};
|
|
443
437
|
|
|
444
438
|
// This is the minified and stringified code of the worker-timers-worker package.
|
|
445
|
-
const worker = `(()=>{var e={455
|
|
439
|
+
const worker = `(()=>{var e={455(e,t){!function(e){"use strict";var t=function(e){return function(t){var r=e(t);return t.add(r),r}},r=function(e){return function(t,r){return e.set(t,r),r}},n=void 0===Number.MAX_SAFE_INTEGER?9007199254740991:Number.MAX_SAFE_INTEGER,o=536870912,s=2*o,a=function(e,t){return function(r){var a=t.get(r),i=void 0===a?r.size:a<s?a+1:0;if(!r.has(i))return e(r,i);if(r.size<o){for(;r.has(i);)i=Math.floor(Math.random()*s);return e(r,i)}if(r.size>n)throw new Error("Congratulations, you created a collection of unique numbers which uses all available integers!");for(;r.has(i);)i=Math.floor(Math.random()*n);return e(r,i)}},i=new WeakMap,u=r(i),c=a(u,i),l=t(c);e.addUniqueNumber=l,e.generateUniqueNumber=c}(t)}},t={};function r(n){var o=t[n];if(void 0!==o)return o.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,r),s.exports}(()=>{"use strict";const e=-32603,t=-32602,n=-32601,o=(e,t)=>Object.assign(new Error(e),{status:t}),s=t=>o('The handler of the method called "'.concat(t,'" returned an unexpected result.'),e),a=(t,r)=>async({data:{id:a,method:i,params:u}})=>{const c=r[i];try{if(void 0===c)throw(e=>o('The requested method called "'.concat(e,'" is not supported.'),n))(i);const r=void 0===u?c():c(u);if(void 0===r)throw(t=>o('The handler of the method called "'.concat(t,'" returned no required result.'),e))(i);const l=r instanceof Promise?await r:r;if(null===a){if(void 0!==l.result)throw s(i)}else{if(void 0===l.result)throw s(i);const{result:e,transferables:r=[]}=l;t.postMessage({id:a,result:e},r)}}catch(e){const{message:r,status:n=-32603}=e;t.postMessage({error:{code:n,message:r},id:a})}};var i=r(455);const u=new Map,c=(e,r,n)=>({...r,connect:({port:t})=>{t.start();const n=e(t,r),o=(0,i.generateUniqueNumber)(u);return u.set(o,()=>{n(),t.close(),u.delete(o)}),{result:o}},disconnect:({portId:e})=>{const r=u.get(e);if(void 0===r)throw(e=>o('The specified parameter called "portId" with the given value "'.concat(e,'" does not identify a port connected to this worker.'),t))(e);return r(),{result:null}},isSupported:async()=>{if(await new Promise(e=>{const t=new ArrayBuffer(0),{port1:r,port2:n}=new MessageChannel;r.onmessage=({data:t})=>e(null!==t),n.postMessage(t,[t])})){const e=n();return{result:e instanceof Promise?await e:e}}return{result:!1}}}),l=(e,t,r=()=>!0)=>{const n=c(l,t,r),o=a(e,n);return e.addEventListener("message",o),()=>e.removeEventListener("message",o)},d=(e,t)=>r=>{const n=t.get(r);if(void 0===n)return Promise.resolve(!1);const[o,s]=n;return e(o),t.delete(r),s(!1),Promise.resolve(!0)},m=(e,t,r,n)=>(o,s,a)=>{const i=o+s-t.timeOrigin,u=i-t.now();return new Promise(t=>{e.set(a,[r(n,u,i,e,t,a),t])})},f=new Map,h=d(globalThis.clearTimeout,f),p=new Map,v=d(globalThis.clearTimeout,p),w=((e,t)=>{const r=(n,o,s,a)=>{const i=n-e.now();i>0?o.set(a,[t(r,i,n,o,s,a),s]):(o.delete(a),s(!0))};return r})(performance,globalThis.setTimeout),g=m(f,performance,globalThis.setTimeout,w),T=m(p,performance,globalThis.setTimeout,w);l(self,{clear:async({timerId:e,timerType:t})=>({result:await("interval"===t?h(e):v(e))}),set:async({delay:e,now:t,timerId:r,timerType:n})=>({result:await("interval"===n?g:T)(e,t,r)})})})()})();`; // tslint:disable-line:max-line-length
|
|
446
440
|
|
|
447
441
|
const loadOrReturnBroker = createLoadOrReturnBroker(load, worker);
|
|
448
442
|
const clearInterval$1 = (timerId) => loadOrReturnBroker().clearInterval(timerId);
|
|
@@ -523,7 +517,7 @@ var pops = (function () {
|
|
|
523
517
|
* @param propName
|
|
524
518
|
*/
|
|
525
519
|
delete(target, propName) {
|
|
526
|
-
if (typeof Reflect === "object" && Reflect.deleteProperty) {
|
|
520
|
+
if (typeof Reflect === "object" && typeof Reflect.deleteProperty === "function") {
|
|
527
521
|
Reflect.deleteProperty(target, propName);
|
|
528
522
|
}
|
|
529
523
|
else {
|
|
@@ -1029,13 +1023,13 @@ var pops = (function () {
|
|
|
1029
1023
|
if (element == null) {
|
|
1030
1024
|
return;
|
|
1031
1025
|
}
|
|
1032
|
-
let
|
|
1026
|
+
let $elList = [];
|
|
1033
1027
|
if (element instanceof NodeList || Array.isArray(element)) {
|
|
1034
1028
|
element = element;
|
|
1035
|
-
|
|
1029
|
+
$elList = $elList.concat(element);
|
|
1036
1030
|
}
|
|
1037
1031
|
else {
|
|
1038
|
-
|
|
1032
|
+
$elList.push(element);
|
|
1039
1033
|
}
|
|
1040
1034
|
let eventTypeList = [];
|
|
1041
1035
|
if (Array.isArray(eventType)) {
|
|
@@ -1086,7 +1080,7 @@ var pops = (function () {
|
|
|
1086
1080
|
// 目标函数、事件名、回调函数、事件配置、过滤函数
|
|
1087
1081
|
filter = option;
|
|
1088
1082
|
}
|
|
1089
|
-
|
|
1083
|
+
$elList.forEach((elementItem) => {
|
|
1090
1084
|
// 获取对象上的事件
|
|
1091
1085
|
const elementEvents = Reflect.get(elementItem, SymbolEvents) || {};
|
|
1092
1086
|
eventTypeList.forEach((eventName) => {
|
|
@@ -1133,18 +1127,19 @@ var pops = (function () {
|
|
|
1133
1127
|
* @param eventType (可选)需要取消监听的事件
|
|
1134
1128
|
*/
|
|
1135
1129
|
offAll(element, eventType) {
|
|
1130
|
+
const that = this;
|
|
1136
1131
|
if (typeof element === "string") {
|
|
1137
|
-
element =
|
|
1132
|
+
element = that.selectorAll(element);
|
|
1138
1133
|
}
|
|
1139
1134
|
if (element == null) {
|
|
1140
1135
|
return;
|
|
1141
1136
|
}
|
|
1142
|
-
let
|
|
1137
|
+
let $elList = [];
|
|
1143
1138
|
if (element instanceof NodeList || Array.isArray(element)) {
|
|
1144
|
-
|
|
1139
|
+
$elList = $elList.concat(Array.from(element));
|
|
1145
1140
|
}
|
|
1146
1141
|
else {
|
|
1147
|
-
|
|
1142
|
+
$elList.push(element);
|
|
1148
1143
|
}
|
|
1149
1144
|
let eventTypeList = [];
|
|
1150
1145
|
if (Array.isArray(eventType)) {
|
|
@@ -1153,12 +1148,13 @@ var pops = (function () {
|
|
|
1153
1148
|
else if (typeof eventType === "string") {
|
|
1154
1149
|
eventTypeList = eventTypeList.concat(eventType.split(" "));
|
|
1155
1150
|
}
|
|
1156
|
-
|
|
1157
|
-
Object.getOwnPropertySymbols(
|
|
1158
|
-
|
|
1151
|
+
$elList.forEach(($elItem) => {
|
|
1152
|
+
const symbolList = [...new Set([...Object.getOwnPropertySymbols($elItem), SymbolEvents])];
|
|
1153
|
+
symbolList.forEach((symbolItem) => {
|
|
1154
|
+
if (!symbolItem.toString().startsWith("Symbol(events_")) {
|
|
1159
1155
|
return;
|
|
1160
1156
|
}
|
|
1161
|
-
const elementEvents =
|
|
1157
|
+
const elementEvents = Reflect.get($elItem, symbolItem) || {};
|
|
1162
1158
|
const iterEventNameList = eventTypeList.length ? eventTypeList : Object.keys(elementEvents);
|
|
1163
1159
|
iterEventNameList.forEach((eventName) => {
|
|
1164
1160
|
const handlers = elementEvents[eventName];
|
|
@@ -1166,11 +1162,12 @@ var pops = (function () {
|
|
|
1166
1162
|
return;
|
|
1167
1163
|
}
|
|
1168
1164
|
for (const handler of handlers) {
|
|
1169
|
-
|
|
1165
|
+
$elItem.removeEventListener(eventName, handler.callback, {
|
|
1170
1166
|
capture: handler["option"]["capture"],
|
|
1171
1167
|
});
|
|
1172
1168
|
}
|
|
1173
|
-
|
|
1169
|
+
const events = Reflect.get($elItem, symbolItem);
|
|
1170
|
+
popsUtils.delete(events, eventName);
|
|
1174
1171
|
});
|
|
1175
1172
|
});
|
|
1176
1173
|
});
|
|
@@ -1913,7 +1910,8 @@ var pops = (function () {
|
|
|
1913
1910
|
}
|
|
1914
1911
|
return $el.classList.contains(className);
|
|
1915
1912
|
}
|
|
1916
|
-
css(
|
|
1913
|
+
css($el, property, value) {
|
|
1914
|
+
const that = this;
|
|
1917
1915
|
/**
|
|
1918
1916
|
* 把纯数字没有px的加上
|
|
1919
1917
|
*/
|
|
@@ -1927,10 +1925,33 @@ var pops = (function () {
|
|
|
1927
1925
|
}
|
|
1928
1926
|
return propertyValue;
|
|
1929
1927
|
}
|
|
1930
|
-
if (typeof
|
|
1931
|
-
|
|
1928
|
+
if (typeof $el === "string") {
|
|
1929
|
+
$el = that.selectorAll($el);
|
|
1932
1930
|
}
|
|
1933
|
-
if (
|
|
1931
|
+
if ($el == null) {
|
|
1932
|
+
return;
|
|
1933
|
+
}
|
|
1934
|
+
if (Array.isArray($el) || $el instanceof NodeList) {
|
|
1935
|
+
if (typeof property === "string") {
|
|
1936
|
+
if (value == null) {
|
|
1937
|
+
// 获取属性
|
|
1938
|
+
return that.css($el[0], property);
|
|
1939
|
+
}
|
|
1940
|
+
else {
|
|
1941
|
+
// 设置属性
|
|
1942
|
+
$el.forEach(($elItem) => {
|
|
1943
|
+
that.css($elItem, property);
|
|
1944
|
+
});
|
|
1945
|
+
return;
|
|
1946
|
+
}
|
|
1947
|
+
}
|
|
1948
|
+
else if (typeof property === "object") {
|
|
1949
|
+
// 设置属性
|
|
1950
|
+
$el.forEach(($elItem) => {
|
|
1951
|
+
that.css($elItem, property);
|
|
1952
|
+
});
|
|
1953
|
+
return;
|
|
1954
|
+
}
|
|
1934
1955
|
return;
|
|
1935
1956
|
}
|
|
1936
1957
|
const setStyleProperty = (propertyName, propertyValue) => {
|
|
@@ -1939,16 +1960,16 @@ var pops = (function () {
|
|
|
1939
1960
|
.trim()
|
|
1940
1961
|
.replace(/!important$/gi, "")
|
|
1941
1962
|
.trim();
|
|
1942
|
-
|
|
1963
|
+
$el.style.setProperty(propertyName, propertyValue, "important");
|
|
1943
1964
|
}
|
|
1944
1965
|
else {
|
|
1945
1966
|
propertyValue = handlePixe(propertyName, propertyValue);
|
|
1946
|
-
|
|
1967
|
+
$el.style.setProperty(propertyName, propertyValue);
|
|
1947
1968
|
}
|
|
1948
1969
|
};
|
|
1949
1970
|
if (typeof property === "string") {
|
|
1950
1971
|
if (value == null) {
|
|
1951
|
-
return getComputedStyle(
|
|
1972
|
+
return PopsCore.globalThis.getComputedStyle($el).getPropertyValue(property);
|
|
1952
1973
|
}
|
|
1953
1974
|
else {
|
|
1954
1975
|
setStyleProperty(property, value);
|
|
@@ -1960,6 +1981,10 @@ var pops = (function () {
|
|
|
1960
1981
|
setStyleProperty(prop, value);
|
|
1961
1982
|
}
|
|
1962
1983
|
}
|
|
1984
|
+
else {
|
|
1985
|
+
// 其他情况
|
|
1986
|
+
throw new TypeError("property must be string or object");
|
|
1987
|
+
}
|
|
1963
1988
|
}
|
|
1964
1989
|
/**
|
|
1965
1990
|
* 创建元素
|
|
@@ -3094,16 +3119,16 @@ var pops = (function () {
|
|
|
3094
3119
|
},
|
|
3095
3120
|
/**
|
|
3096
3121
|
* 删除配置中对应的对象
|
|
3097
|
-
* @param
|
|
3122
|
+
* @param totalInstConfigList 配置实例列表
|
|
3098
3123
|
* @param guid 唯一标识
|
|
3099
3124
|
* @param isAll 是否全部删除
|
|
3100
3125
|
*/
|
|
3101
|
-
removeInstance(
|
|
3126
|
+
async removeInstance(totalInstConfigList, guid, isAll = false) {
|
|
3102
3127
|
/**
|
|
3103
3128
|
* 移除元素实例
|
|
3104
3129
|
* @param instCommonConfig
|
|
3105
3130
|
*/
|
|
3106
|
-
function
|
|
3131
|
+
const removeInst = function (instCommonConfig) {
|
|
3107
3132
|
if (typeof instCommonConfig.beforeRemoveCallBack === "function") {
|
|
3108
3133
|
// 调用移除签的回调
|
|
3109
3134
|
instCommonConfig.beforeRemoveCallBack(instCommonConfig);
|
|
@@ -3112,39 +3137,44 @@ var pops = (function () {
|
|
|
3112
3137
|
instCommonConfig?.$pops?.remove();
|
|
3113
3138
|
instCommonConfig?.$mask?.remove();
|
|
3114
3139
|
instCommonConfig?.$shadowContainer?.remove();
|
|
3115
|
-
}
|
|
3140
|
+
};
|
|
3141
|
+
const asyncInstTask = [];
|
|
3116
3142
|
// [ inst[], inst[],...]
|
|
3117
|
-
|
|
3143
|
+
totalInstConfigList.forEach((instConfigList) => {
|
|
3118
3144
|
// inst[]
|
|
3119
|
-
instConfigList.forEach((instConfigItem, index) => {
|
|
3145
|
+
instConfigList.forEach(async (instConfigItem, index) => {
|
|
3120
3146
|
// 移除全部或者guid相同
|
|
3121
|
-
if (isAll ||
|
|
3147
|
+
if (isAll || (typeof guid === "string" && instConfigItem.guid === guid)) {
|
|
3122
3148
|
// 判断是否有动画
|
|
3123
3149
|
const animName = instConfigItem.$anim.getAttribute("anim");
|
|
3124
3150
|
if (PopsAnimation.hasAnim(animName)) {
|
|
3125
3151
|
const reverseAnimName = animName + "-reverse";
|
|
3126
|
-
instConfigItem.$anim
|
|
3127
|
-
instConfigItem.$anim
|
|
3128
|
-
instConfigItem.$anim
|
|
3129
|
-
if (PopsAnimation.hasAnim(instConfigItem.$anim
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3152
|
+
popsDOMUtils.css(instConfigItem.$anim, "width", "100%");
|
|
3153
|
+
popsDOMUtils.css(instConfigItem.$anim, "height", "100%");
|
|
3154
|
+
popsDOMUtils.css(instConfigItem.$anim, "animation-name", reverseAnimName);
|
|
3155
|
+
if (PopsAnimation.hasAnim(popsDOMUtils.css(instConfigItem.$anim, "animation-name"))) {
|
|
3156
|
+
asyncInstTask.push(new Promise((resolve) => {
|
|
3157
|
+
popsDOMUtils.on(instConfigItem.$anim, popsDOMUtils.getAnimationEndNameList(), function () {
|
|
3158
|
+
removeInst(instConfigItem);
|
|
3159
|
+
resolve();
|
|
3160
|
+
}, {
|
|
3161
|
+
capture: true,
|
|
3162
|
+
});
|
|
3163
|
+
}));
|
|
3135
3164
|
}
|
|
3136
3165
|
else {
|
|
3137
|
-
|
|
3166
|
+
removeInst(instConfigItem);
|
|
3138
3167
|
}
|
|
3139
3168
|
}
|
|
3140
3169
|
else {
|
|
3141
|
-
|
|
3170
|
+
removeInst(instConfigItem);
|
|
3142
3171
|
}
|
|
3143
3172
|
instConfigList.splice(index, 1);
|
|
3144
3173
|
}
|
|
3145
3174
|
});
|
|
3146
3175
|
});
|
|
3147
|
-
|
|
3176
|
+
await Promise.all(asyncInstTask);
|
|
3177
|
+
return totalInstConfigList;
|
|
3148
3178
|
},
|
|
3149
3179
|
/**
|
|
3150
3180
|
* 隐藏
|
|
@@ -3289,8 +3319,9 @@ var pops = (function () {
|
|
|
3289
3319
|
* @param config
|
|
3290
3320
|
* @param $anim
|
|
3291
3321
|
*/
|
|
3292
|
-
close(config, popsType, instConfigList, guid, $anim) {
|
|
3293
|
-
|
|
3322
|
+
async close(config, popsType, instConfigList, guid, $anim) {
|
|
3323
|
+
// eslint-disable-next-line no-async-promise-executor
|
|
3324
|
+
await new Promise(async (resolve) => {
|
|
3294
3325
|
const $pops = $anim.querySelector(".pops[type-value]");
|
|
3295
3326
|
const drawerConfig = config;
|
|
3296
3327
|
/**
|
|
@@ -3300,12 +3331,12 @@ var pops = (function () {
|
|
|
3300
3331
|
/**
|
|
3301
3332
|
* 弹窗已关闭的回调
|
|
3302
3333
|
*/
|
|
3303
|
-
function closeCallBack(event) {
|
|
3334
|
+
async function closeCallBack(event) {
|
|
3304
3335
|
if (event.propertyName !== "transform") {
|
|
3305
3336
|
return;
|
|
3306
3337
|
}
|
|
3307
|
-
popsDOMUtils.off($pops, popsDOMUtils.getTransitionEndNameList(),
|
|
3308
|
-
PopsInstanceUtils.removeInstance([instConfigList], guid);
|
|
3338
|
+
popsDOMUtils.off($pops, popsDOMUtils.getTransitionEndNameList(), closeCallBack);
|
|
3339
|
+
await PopsInstanceUtils.removeInstance([instConfigList], guid);
|
|
3309
3340
|
resolve();
|
|
3310
3341
|
}
|
|
3311
3342
|
// 监听过渡结束
|
|
@@ -3337,10 +3368,32 @@ var pops = (function () {
|
|
|
3337
3368
|
}, drawerConfig.closeDelay);
|
|
3338
3369
|
}
|
|
3339
3370
|
else {
|
|
3340
|
-
PopsInstanceUtils.removeInstance([instConfigList], guid);
|
|
3371
|
+
await PopsInstanceUtils.removeInstance([instConfigList], guid);
|
|
3341
3372
|
resolve();
|
|
3342
3373
|
}
|
|
3343
3374
|
});
|
|
3375
|
+
// 判断组件内是否有rightClickMenu、tooltip、searchSuggestion组件
|
|
3376
|
+
// 有的话也需要关闭
|
|
3377
|
+
PopsInstData.rightClickMenu.forEach((itemConfig) => {
|
|
3378
|
+
const config = itemConfig.config;
|
|
3379
|
+
if (config.$target instanceof HTMLElement) {
|
|
3380
|
+
const $root = config.$target.getRootNode();
|
|
3381
|
+
if ($root instanceof HTMLElement && $root.parentElement == null) {
|
|
3382
|
+
// 触发销毁元素
|
|
3383
|
+
itemConfig.destory();
|
|
3384
|
+
}
|
|
3385
|
+
}
|
|
3386
|
+
});
|
|
3387
|
+
PopsInstData.tooltip.forEach((itemConfig) => {
|
|
3388
|
+
const config = itemConfig.config;
|
|
3389
|
+
if (config.$target instanceof HTMLElement) {
|
|
3390
|
+
const $root = config.$target.getRootNode();
|
|
3391
|
+
if ($root instanceof HTMLElement && $root.parentElement == null) {
|
|
3392
|
+
// 触发销毁元素
|
|
3393
|
+
itemConfig.destory();
|
|
3394
|
+
}
|
|
3395
|
+
}
|
|
3396
|
+
});
|
|
3344
3397
|
},
|
|
3345
3398
|
/**
|
|
3346
3399
|
* 拖拽元素
|
|
@@ -3679,12 +3732,12 @@ var pops = (function () {
|
|
|
3679
3732
|
element.hasAttribute("anim"));
|
|
3680
3733
|
}
|
|
3681
3734
|
// 判断按下的元素是否是pops-anim
|
|
3682
|
-
popsDOMUtils.on(config.animElement, ["touchstart", "mousedown"],
|
|
3735
|
+
popsDOMUtils.on(config.animElement, ["touchstart", "mousedown"], (event) => {
|
|
3683
3736
|
const $click = event.composedPath()[0];
|
|
3684
3737
|
isMaskClick = isAnimElement($click);
|
|
3685
3738
|
});
|
|
3686
3739
|
// 如果有动画层,在动画层上监听点击事件
|
|
3687
|
-
popsDOMUtils.on(config.animElement, "click",
|
|
3740
|
+
popsDOMUtils.on(config.animElement, "click", (event) => {
|
|
3688
3741
|
const $click = event.composedPath()[0];
|
|
3689
3742
|
if (isAnimElement($click) && isMaskClick) {
|
|
3690
3743
|
return clickEvent(event);
|
|
@@ -3692,7 +3745,7 @@ var pops = (function () {
|
|
|
3692
3745
|
});
|
|
3693
3746
|
// 在遮罩层监听点击事件
|
|
3694
3747
|
// 如果有动画层,那么该点击事件触发不了
|
|
3695
|
-
popsDOMUtils.on(result.maskElement, "click",
|
|
3748
|
+
popsDOMUtils.on(result.maskElement, "click", (event) => {
|
|
3696
3749
|
isMaskClick = true;
|
|
3697
3750
|
clickEvent(event);
|
|
3698
3751
|
});
|
|
@@ -3835,13 +3888,13 @@ var pops = (function () {
|
|
|
3835
3888
|
* @param guid
|
|
3836
3889
|
* @param $shadowContainer
|
|
3837
3890
|
* @param $shadowRoot
|
|
3838
|
-
* @param
|
|
3891
|
+
* @param type 当前弹窗类型
|
|
3839
3892
|
* @param $anim 动画层
|
|
3840
3893
|
* @param $pops 主元素
|
|
3841
3894
|
* @param $mask 遮罩层
|
|
3842
3895
|
* @param config 当前配置
|
|
3843
3896
|
*/
|
|
3844
|
-
handleEventConfig(config, guid, $shadowContainer, $shadowRoot,
|
|
3897
|
+
handleEventConfig(config, guid, $shadowContainer, $shadowRoot, type, $anim, $pops, $mask) {
|
|
3845
3898
|
return {
|
|
3846
3899
|
$shadowContainer: $shadowContainer,
|
|
3847
3900
|
$shadowRoot: $shadowRoot,
|
|
@@ -3849,44 +3902,47 @@ var pops = (function () {
|
|
|
3849
3902
|
$anim: $anim,
|
|
3850
3903
|
$pops: $pops,
|
|
3851
3904
|
$mask: $mask,
|
|
3852
|
-
mode:
|
|
3905
|
+
mode: type,
|
|
3853
3906
|
guid: guid,
|
|
3854
3907
|
close() {
|
|
3855
|
-
return PopsInstanceUtils.close(config,
|
|
3908
|
+
return PopsInstanceUtils.close(config, type, PopsInstData[type], guid, $anim);
|
|
3856
3909
|
},
|
|
3857
3910
|
hide() {
|
|
3858
|
-
return PopsInstanceUtils.hide(config,
|
|
3911
|
+
return PopsInstanceUtils.hide(config, type, PopsInstData[type], guid, $anim, $mask);
|
|
3859
3912
|
},
|
|
3860
|
-
show() {
|
|
3861
|
-
|
|
3913
|
+
show($parent) {
|
|
3914
|
+
if ($parent) {
|
|
3915
|
+
$parent.appendChild(PopsInstData[type][0].$shadowRoot);
|
|
3916
|
+
}
|
|
3917
|
+
return PopsInstanceUtils.show(config, type, PopsInstData[type], guid, $anim, $mask);
|
|
3862
3918
|
},
|
|
3863
3919
|
};
|
|
3864
3920
|
},
|
|
3865
3921
|
/**
|
|
3866
3922
|
* 获取loading的事件配置
|
|
3867
3923
|
* @param guid
|
|
3868
|
-
* @param
|
|
3924
|
+
* @param type 当前弹窗类型
|
|
3869
3925
|
* @param $anim 动画层
|
|
3870
3926
|
* @param $pops 主元素
|
|
3871
3927
|
* @param $mask 遮罩层
|
|
3872
3928
|
* @param config 当前配置
|
|
3873
3929
|
*/
|
|
3874
|
-
handleLoadingEventConfig(config, guid,
|
|
3930
|
+
handleLoadingEventConfig(config, guid, type, $anim, $pops, $mask) {
|
|
3875
3931
|
return {
|
|
3876
3932
|
$el: $anim,
|
|
3877
3933
|
$anim: $anim,
|
|
3878
3934
|
$pops: $pops,
|
|
3879
3935
|
$mask: $mask,
|
|
3880
|
-
mode:
|
|
3936
|
+
mode: type,
|
|
3881
3937
|
guid: guid,
|
|
3882
3938
|
close() {
|
|
3883
|
-
return PopsInstanceUtils.close(config,
|
|
3939
|
+
return PopsInstanceUtils.close(config, type, PopsInstData[type], guid, $anim);
|
|
3884
3940
|
},
|
|
3885
3941
|
hide() {
|
|
3886
|
-
return PopsInstanceUtils.hide(config,
|
|
3942
|
+
return PopsInstanceUtils.hide(config, type, PopsInstData[type], guid, $anim, $mask);
|
|
3887
3943
|
},
|
|
3888
3944
|
show() {
|
|
3889
|
-
return PopsInstanceUtils.show(config,
|
|
3945
|
+
return PopsInstanceUtils.show(config, type, PopsInstData[type], guid, $anim, $mask);
|
|
3890
3946
|
},
|
|
3891
3947
|
};
|
|
3892
3948
|
},
|
|
@@ -3999,8 +4055,8 @@ var pops = (function () {
|
|
|
3999
4055
|
handleOnly(type, config) {
|
|
4000
4056
|
if (config.only) {
|
|
4001
4057
|
// .loading
|
|
4002
|
-
// .tooltip
|
|
4003
4058
|
// .rightClickMenu
|
|
4059
|
+
// .tooltip
|
|
4004
4060
|
// 单独处理
|
|
4005
4061
|
if (type === "loading" || type === "tooltip" || type === "rightClickMenu") {
|
|
4006
4062
|
const inst = PopsInstData[type];
|
|
@@ -4012,11 +4068,11 @@ var pops = (function () {
|
|
|
4012
4068
|
PopsInstanceUtils.removeInstance([
|
|
4013
4069
|
PopsInstData.alert,
|
|
4014
4070
|
PopsInstData.confirm,
|
|
4015
|
-
PopsInstData.prompt,
|
|
4016
|
-
PopsInstData.iframe,
|
|
4017
4071
|
PopsInstData.drawer,
|
|
4018
4072
|
PopsInstData.folder,
|
|
4073
|
+
PopsInstData.iframe,
|
|
4019
4074
|
PopsInstData.panel,
|
|
4075
|
+
PopsInstData.prompt,
|
|
4020
4076
|
], "", true);
|
|
4021
4077
|
}
|
|
4022
4078
|
}
|
|
@@ -4180,6 +4236,7 @@ var pops = (function () {
|
|
|
4180
4236
|
}
|
|
4181
4237
|
// 处理返回的配置
|
|
4182
4238
|
const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, $mask);
|
|
4239
|
+
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
4183
4240
|
// 为顶部右边的关闭按钮添加点击事件
|
|
4184
4241
|
PopsHandler.handleClickEvent("close", $headerCloseBtn, evtConfig, config.btn.close?.callback);
|
|
4185
4242
|
// 为底部ok按钮添加点击事件
|
|
@@ -4202,6 +4259,8 @@ var pops = (function () {
|
|
|
4202
4259
|
$mask: $mask,
|
|
4203
4260
|
$shadowContainer: $shadowContainer,
|
|
4204
4261
|
$shadowRoot: $shadowRoot,
|
|
4262
|
+
config: config,
|
|
4263
|
+
destory: result.close,
|
|
4205
4264
|
});
|
|
4206
4265
|
// 拖拽
|
|
4207
4266
|
if (config.drag) {
|
|
@@ -4213,7 +4272,6 @@ var pops = (function () {
|
|
|
4213
4272
|
endCallBack: config.dragEndCallBack,
|
|
4214
4273
|
});
|
|
4215
4274
|
}
|
|
4216
|
-
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
4217
4275
|
return result;
|
|
4218
4276
|
},
|
|
4219
4277
|
};
|
|
@@ -4387,6 +4445,7 @@ var pops = (function () {
|
|
|
4387
4445
|
$elList.push($mask);
|
|
4388
4446
|
}
|
|
4389
4447
|
const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, $mask);
|
|
4448
|
+
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
4390
4449
|
PopsHandler.handleClickEvent("close", $btnClose, evtConfig, config.btn.close.callback);
|
|
4391
4450
|
PopsHandler.handleClickEvent("ok", $btnOk, evtConfig, config.btn.ok.callback);
|
|
4392
4451
|
PopsHandler.handleClickEvent("cancel", $btnCancel, evtConfig, config.btn.cancel.callback);
|
|
@@ -4407,6 +4466,8 @@ var pops = (function () {
|
|
|
4407
4466
|
$mask: $mask,
|
|
4408
4467
|
$shadowContainer: $shadowContainer,
|
|
4409
4468
|
$shadowRoot: $shadowRoot,
|
|
4469
|
+
config: config,
|
|
4470
|
+
destory: result.close,
|
|
4410
4471
|
});
|
|
4411
4472
|
// 拖拽
|
|
4412
4473
|
if (config.drag) {
|
|
@@ -4418,7 +4479,6 @@ var pops = (function () {
|
|
|
4418
4479
|
endCallBack: config.dragEndCallBack,
|
|
4419
4480
|
});
|
|
4420
4481
|
}
|
|
4421
|
-
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
4422
4482
|
return result;
|
|
4423
4483
|
},
|
|
4424
4484
|
};
|
|
@@ -4597,6 +4657,7 @@ var pops = (function () {
|
|
|
4597
4657
|
$elList.push($mask);
|
|
4598
4658
|
}
|
|
4599
4659
|
const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, $mask);
|
|
4660
|
+
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
4600
4661
|
// 处理方向
|
|
4601
4662
|
$pops.setAttribute("direction", config.direction);
|
|
4602
4663
|
// 处理border-radius
|
|
@@ -4692,8 +4753,9 @@ var pops = (function () {
|
|
|
4692
4753
|
$mask: $mask,
|
|
4693
4754
|
$shadowContainer: $shadowContainer,
|
|
4694
4755
|
$shadowRoot: $shadowRoot,
|
|
4756
|
+
config: config,
|
|
4757
|
+
destory: result.close,
|
|
4695
4758
|
});
|
|
4696
|
-
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
4697
4759
|
return result;
|
|
4698
4760
|
},
|
|
4699
4761
|
};
|
|
@@ -5202,6 +5264,7 @@ var pops = (function () {
|
|
|
5202
5264
|
}
|
|
5203
5265
|
// 事件
|
|
5204
5266
|
const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, $mask);
|
|
5267
|
+
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
5205
5268
|
PopsHandler.handleClickEvent("close", $btnCloseBtn, evtConfig, config.btn.close.callback);
|
|
5206
5269
|
PopsHandler.handleClickEvent("ok", btnOkElement, evtConfig, config.btn.ok.callback);
|
|
5207
5270
|
PopsHandler.handleClickEvent("cancel", btnCancelElement, evtConfig, config.btn.cancel.callback);
|
|
@@ -5781,8 +5844,9 @@ var pops = (function () {
|
|
|
5781
5844
|
$mask: $mask,
|
|
5782
5845
|
$shadowContainer: $shadowContainer,
|
|
5783
5846
|
$shadowRoot: $shadowRoot,
|
|
5847
|
+
config: config,
|
|
5848
|
+
destory: result.close,
|
|
5784
5849
|
});
|
|
5785
|
-
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
5786
5850
|
return result;
|
|
5787
5851
|
},
|
|
5788
5852
|
};
|
|
@@ -5938,6 +6002,7 @@ var pops = (function () {
|
|
|
5938
6002
|
const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, $mask);
|
|
5939
6003
|
// 赋值额外的$iframe参数
|
|
5940
6004
|
evtConfig.$iframe = $iframe;
|
|
6005
|
+
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
5941
6006
|
popsDOMUtils.on($anim, popsDOMUtils.getAnimationEndNameList(), function () {
|
|
5942
6007
|
// 动画加载完毕
|
|
5943
6008
|
$anim.style.width = "0%";
|
|
@@ -6069,10 +6134,10 @@ var pops = (function () {
|
|
|
6069
6134
|
capture: true,
|
|
6070
6135
|
});
|
|
6071
6136
|
// 关闭按钮点击事件
|
|
6072
|
-
popsDOMUtils.on(headerCloseBtnElement, "click", (event) => {
|
|
6137
|
+
popsDOMUtils.on(headerCloseBtnElement, "click", async (event) => {
|
|
6073
6138
|
event.preventDefault();
|
|
6074
6139
|
event.stopPropagation();
|
|
6075
|
-
PopsInstanceUtils.removeInstance([PopsInstData.iframe], guid, false);
|
|
6140
|
+
await PopsInstanceUtils.removeInstance([PopsInstData.iframe], guid, false);
|
|
6076
6141
|
if (typeof config?.btn?.close?.callback === "function") {
|
|
6077
6142
|
config.btn.close.callback(evtConfig, event);
|
|
6078
6143
|
}
|
|
@@ -6086,8 +6151,9 @@ var pops = (function () {
|
|
|
6086
6151
|
$mask: $mask,
|
|
6087
6152
|
$shadowContainer: $shadowContainer,
|
|
6088
6153
|
$shadowRoot: $shadowRoot,
|
|
6154
|
+
config: config,
|
|
6155
|
+
destory: result.close,
|
|
6089
6156
|
});
|
|
6090
|
-
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
6091
6157
|
return result;
|
|
6092
6158
|
},
|
|
6093
6159
|
};
|
|
@@ -7053,7 +7119,7 @@ var pops = (function () {
|
|
|
7053
7119
|
isFixed: false,
|
|
7054
7120
|
alwaysShow: false,
|
|
7055
7121
|
onShowEventName: "mouseenter touchstart",
|
|
7056
|
-
onCloseEventName: "mouseleave touchend",
|
|
7122
|
+
onCloseEventName: "mouseleave touchend touchcancel",
|
|
7057
7123
|
zIndex: 10000,
|
|
7058
7124
|
only: false,
|
|
7059
7125
|
eventOption: {
|
|
@@ -7279,12 +7345,12 @@ var pops = (function () {
|
|
|
7279
7345
|
changePosition(event) {
|
|
7280
7346
|
const positionInfo = this.calcToolTipPosition(this.$data.config.$target, this.$data.config.arrowDistance, this.$data.config.otherDistance, event);
|
|
7281
7347
|
const positionKey = this.$data.config.position.toUpperCase();
|
|
7282
|
-
const
|
|
7283
|
-
if (
|
|
7284
|
-
this.$el.$toolTip.style.left =
|
|
7285
|
-
this.$el.$toolTip.style.top =
|
|
7286
|
-
this.$el.$toolTip.setAttribute("data-motion",
|
|
7287
|
-
this.$el.$arrow.setAttribute("data-position",
|
|
7348
|
+
const position = positionInfo[positionKey];
|
|
7349
|
+
if (position) {
|
|
7350
|
+
this.$el.$toolTip.style.left = position.left + "px";
|
|
7351
|
+
this.$el.$toolTip.style.top = position.top + "px";
|
|
7352
|
+
this.$el.$toolTip.setAttribute("data-motion", position.motion);
|
|
7353
|
+
this.$el.$arrow.setAttribute("data-position", position.arrow);
|
|
7288
7354
|
}
|
|
7289
7355
|
else {
|
|
7290
7356
|
console.error("不存在该位置", this.$data.config.position);
|
|
@@ -7390,9 +7456,7 @@ var pops = (function () {
|
|
|
7390
7456
|
* 取消绑定 显示事件
|
|
7391
7457
|
*/
|
|
7392
7458
|
offShowEvent() {
|
|
7393
|
-
popsDOMUtils.off(this.$data.config.$target, this.$data.config.onShowEventName, this.show,
|
|
7394
|
-
capture: true,
|
|
7395
|
-
});
|
|
7459
|
+
popsDOMUtils.off(this.$data.config.$target, this.$data.config.onShowEventName, this.show, this.$data.config.eventOption);
|
|
7396
7460
|
}
|
|
7397
7461
|
/**
|
|
7398
7462
|
* 关闭提示框
|
|
@@ -7451,22 +7515,20 @@ var pops = (function () {
|
|
|
7451
7515
|
* 取消绑定 关闭事件
|
|
7452
7516
|
*/
|
|
7453
7517
|
offCloseEvent() {
|
|
7454
|
-
popsDOMUtils.off(this.$data.config.$target, this.$data.config.onCloseEventName, this.close,
|
|
7455
|
-
capture: true,
|
|
7456
|
-
});
|
|
7518
|
+
popsDOMUtils.off(this.$data.config.$target, this.$data.config.onCloseEventName, this.close, this.$data.config.eventOption);
|
|
7457
7519
|
}
|
|
7458
7520
|
/**
|
|
7459
7521
|
* 销毁元素
|
|
7460
7522
|
*/
|
|
7461
7523
|
destory() {
|
|
7462
7524
|
if (this.$el.$toolTip) {
|
|
7463
|
-
this.$el.$
|
|
7525
|
+
this.$el.$toolTip.remove();
|
|
7464
7526
|
}
|
|
7465
|
-
// @ts-
|
|
7527
|
+
// @ts-expect-error
|
|
7466
7528
|
this.$el.$toolTip = null;
|
|
7467
|
-
// @ts-
|
|
7529
|
+
// @ts-expect-error
|
|
7468
7530
|
this.$el.$arrow = null;
|
|
7469
|
-
// @ts-
|
|
7531
|
+
// @ts-expect-error
|
|
7470
7532
|
this.$el.$content = null;
|
|
7471
7533
|
}
|
|
7472
7534
|
/**
|
|
@@ -7514,29 +7576,29 @@ var pops = (function () {
|
|
|
7514
7576
|
popsDOMUtils.on(this.$el.$toolTip, "mouseenter touchstart", this.toolTipMouseEnterEvent, this.$data.config.eventOption);
|
|
7515
7577
|
}
|
|
7516
7578
|
/**
|
|
7517
|
-
*
|
|
7579
|
+
* 取消监听事件 - 鼠标|触摸
|
|
7518
7580
|
*/
|
|
7519
7581
|
offToolTipMouseEnterEvent() {
|
|
7520
7582
|
popsDOMUtils.off(this.$el.$toolTip, "mouseenter touchstart", this.toolTipMouseEnterEvent, this.$data.config.eventOption);
|
|
7521
7583
|
}
|
|
7522
7584
|
/**
|
|
7523
|
-
*
|
|
7585
|
+
* 离开事件 - 鼠标|触摸
|
|
7524
7586
|
*/
|
|
7525
7587
|
toolTipMouseLeaveEvent(event) {
|
|
7526
7588
|
this.close(event);
|
|
7527
7589
|
// this.$el.$toolTip.style.animationPlayState = "running";
|
|
7528
7590
|
}
|
|
7529
7591
|
/**
|
|
7530
|
-
*
|
|
7592
|
+
* 监听离开事件 - 鼠标|触摸
|
|
7531
7593
|
*/
|
|
7532
7594
|
onToolTipMouseLeaveEvent() {
|
|
7533
|
-
popsDOMUtils.on(this.$el.$toolTip, "mouseleave touchend", this.toolTipMouseLeaveEvent, this.$data.config.eventOption);
|
|
7595
|
+
popsDOMUtils.on(this.$el.$toolTip, "mouseleave touchend touchcancel", this.toolTipMouseLeaveEvent, this.$data.config.eventOption);
|
|
7534
7596
|
}
|
|
7535
7597
|
/**
|
|
7536
|
-
*
|
|
7598
|
+
* 取消监听离开事件 - 鼠标|触摸
|
|
7537
7599
|
*/
|
|
7538
7600
|
offToolTipMouseLeaveEvent() {
|
|
7539
|
-
popsDOMUtils.off(this.$el.$toolTip, "mouseleave touchend", this.toolTipMouseLeaveEvent, this.$data.config.eventOption);
|
|
7601
|
+
popsDOMUtils.off(this.$el.$toolTip, "mouseleave touchend touchcancel", this.toolTipMouseLeaveEvent, this.$data.config.eventOption);
|
|
7540
7602
|
}
|
|
7541
7603
|
}
|
|
7542
7604
|
const PopsTooltip = {
|
|
@@ -7551,6 +7613,15 @@ var pops = (function () {
|
|
|
7551
7613
|
throw new TypeError("config.target 必须是HTMLElement类型");
|
|
7552
7614
|
}
|
|
7553
7615
|
config = PopsHandler.handleOnly(popsType, config);
|
|
7616
|
+
if (config.position === "follow") {
|
|
7617
|
+
config.onShowEventName = config.onShowEventName.trim();
|
|
7618
|
+
const showEventNameSplit = config.onShowEventName.split(" ");
|
|
7619
|
+
["mousemove", "touchmove"].forEach((it) => {
|
|
7620
|
+
if (showEventNameSplit.includes(it))
|
|
7621
|
+
return;
|
|
7622
|
+
config.onShowEventName += ` ${it}`;
|
|
7623
|
+
});
|
|
7624
|
+
}
|
|
7554
7625
|
const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
|
|
7555
7626
|
PopsHandler.handleInit($shadowRoot, [
|
|
7556
7627
|
{
|
|
@@ -8815,7 +8886,7 @@ var pops = (function () {
|
|
|
8815
8886
|
* 监听输入框内容改变
|
|
8816
8887
|
*/
|
|
8817
8888
|
onValueChange() {
|
|
8818
|
-
popsDOMUtils.on(this.$el.input, ["input", "propertychange"],
|
|
8889
|
+
popsDOMUtils.on(this.$el.input, ["input", "propertychange"], (event) => {
|
|
8819
8890
|
this.$data.value = this.$el.input.value;
|
|
8820
8891
|
if (inputType !== "password") {
|
|
8821
8892
|
// 不是密码框
|
|
@@ -9188,7 +9259,7 @@ var pops = (function () {
|
|
|
9188
9259
|
* 监听点击事件
|
|
9189
9260
|
*/
|
|
9190
9261
|
onClick() {
|
|
9191
|
-
popsDOMUtils.on(this.$el.$select, "click",
|
|
9262
|
+
popsDOMUtils.on(this.$el.$select, "click", (event) => {
|
|
9192
9263
|
this.setSelectOptionsDisableStatus();
|
|
9193
9264
|
if (typeof viewConfig.clickCallBack === "function") {
|
|
9194
9265
|
const $isSelectedElement = this.$el.$select[this.$el.$select.selectedIndex];
|
|
@@ -10955,7 +11026,7 @@ var pops = (function () {
|
|
|
10955
11026
|
* 设置按钮的点击事件
|
|
10956
11027
|
*/
|
|
10957
11028
|
onButtonClick() {
|
|
10958
|
-
popsDOMUtils.on(this.$ele.button, "click",
|
|
11029
|
+
popsDOMUtils.on(this.$ele.button, "click", (event) => {
|
|
10959
11030
|
if (typeof viewConfig.callback === "function") {
|
|
10960
11031
|
viewConfig.callback(event);
|
|
10961
11032
|
}
|
|
@@ -11024,13 +11095,13 @@ var pops = (function () {
|
|
|
11024
11095
|
initContainerItem($container, formItemConfig) {
|
|
11025
11096
|
const containerViewConfig = formItemConfig;
|
|
11026
11097
|
if (containerViewConfig.type === "container") {
|
|
11027
|
-
const
|
|
11098
|
+
const childViewConfig = containerViewConfig["views"];
|
|
11028
11099
|
// 每一项<li>元素
|
|
11029
|
-
const
|
|
11100
|
+
const $itemLi = popsDOMUtils.createElement("li");
|
|
11030
11101
|
// 每一项<li>内的子<ul>元素
|
|
11031
|
-
const
|
|
11032
|
-
|
|
11033
|
-
|
|
11102
|
+
const $itemUL = popsDOMUtils.createElement("ul");
|
|
11103
|
+
$itemUL.classList.add("pops-panel-forms-container-item-formlist");
|
|
11104
|
+
$itemLi.classList.add("pops-panel-forms-container-item");
|
|
11034
11105
|
// 区域头部的文字
|
|
11035
11106
|
const formHeaderDivElement = popsDOMUtils.createElement("div", {
|
|
11036
11107
|
className: "pops-panel-forms-container-item-header-text",
|
|
@@ -11050,42 +11121,42 @@ var pops = (function () {
|
|
|
11050
11121
|
`);
|
|
11051
11122
|
// 添加点击事件
|
|
11052
11123
|
popsDOMUtils.on(formHeaderDivElement, "click", () => {
|
|
11053
|
-
if (
|
|
11054
|
-
|
|
11124
|
+
if ($itemLi.hasAttribute("data-fold-enable")) {
|
|
11125
|
+
$itemLi.removeAttribute("data-fold-enable");
|
|
11055
11126
|
}
|
|
11056
11127
|
else {
|
|
11057
|
-
|
|
11128
|
+
$itemLi.setAttribute("data-fold-enable", "");
|
|
11058
11129
|
}
|
|
11059
11130
|
});
|
|
11060
11131
|
popsDOMUtils.addClassName(formHeaderDivElement, "pops-panel-forms-fold-container");
|
|
11061
11132
|
popsDOMUtils.addClassName(formHeaderDivElement, PopsCommonCSSClassName.userSelectNone);
|
|
11062
|
-
|
|
11133
|
+
$itemLi.setAttribute("data-fold-enable", "");
|
|
11063
11134
|
popsDOMUtils.addClassName(formHeaderDivElement, "pops-panel-forms-fold");
|
|
11064
|
-
|
|
11135
|
+
$itemLi.appendChild(formHeaderDivElement);
|
|
11065
11136
|
}
|
|
11066
11137
|
else {
|
|
11067
11138
|
// 加进容器内
|
|
11068
|
-
|
|
11139
|
+
$itemLi.appendChild(formHeaderDivElement);
|
|
11069
11140
|
}
|
|
11070
|
-
that.setElementClassName(
|
|
11071
|
-
that.setElementAttributes(
|
|
11072
|
-
that.setElementProps(
|
|
11073
|
-
|
|
11141
|
+
that.setElementClassName($itemLi, formItemConfig.className);
|
|
11142
|
+
that.setElementAttributes($itemLi, formItemConfig.attributes);
|
|
11143
|
+
that.setElementProps($itemLi, formItemConfig.props);
|
|
11144
|
+
$itemLi.appendChild($itemUL);
|
|
11145
|
+
$container.appendChild($itemLi);
|
|
11146
|
+
childViewConfig.forEach((childViewConfig) => {
|
|
11074
11147
|
that.uListContainerAddItem(childViewConfig, {
|
|
11075
|
-
ulElement:
|
|
11148
|
+
ulElement: $itemUL,
|
|
11076
11149
|
sectionContainerULElement: that.sectionContainerULElement,
|
|
11077
|
-
formContainerListElement:
|
|
11150
|
+
formContainerListElement: $itemLi,
|
|
11078
11151
|
formHeaderDivElement: formHeaderDivElement,
|
|
11079
11152
|
});
|
|
11080
11153
|
});
|
|
11081
|
-
formContainerListElement.appendChild(formContainerULElement);
|
|
11082
|
-
$container.appendChild(formContainerListElement);
|
|
11083
11154
|
if (typeof containerViewConfig.afterAddToUListCallBack === "function") {
|
|
11084
11155
|
containerViewConfig.afterAddToUListCallBack(viewConfig, {
|
|
11085
|
-
target:
|
|
11086
|
-
ulElement:
|
|
11156
|
+
target: $itemLi,
|
|
11157
|
+
ulElement: $itemUL,
|
|
11087
11158
|
sectionContainerULElement: that.sectionContainerULElement,
|
|
11088
|
-
formContainerListElement:
|
|
11159
|
+
formContainerListElement: $itemLi,
|
|
11089
11160
|
formHeaderDivElement: formHeaderDivElement,
|
|
11090
11161
|
});
|
|
11091
11162
|
}
|
|
@@ -11224,7 +11295,7 @@ var pops = (function () {
|
|
|
11224
11295
|
},
|
|
11225
11296
|
/** 设置项的点击事件 */
|
|
11226
11297
|
onLiClick() {
|
|
11227
|
-
popsDOMUtils.on($li, "click",
|
|
11298
|
+
popsDOMUtils.on($li, "click", async (event) => {
|
|
11228
11299
|
if (typeof viewConfig.clickCallBack === "function") {
|
|
11229
11300
|
const result = await viewConfig.clickCallBack(event, viewConfig);
|
|
11230
11301
|
if (result) {
|
|
@@ -11552,6 +11623,7 @@ var pops = (function () {
|
|
|
11552
11623
|
}
|
|
11553
11624
|
// 处理返回的配置
|
|
11554
11625
|
const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, $mask);
|
|
11626
|
+
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
11555
11627
|
// 为顶部右边的关闭按钮添加点击事件
|
|
11556
11628
|
PopsHandler.handleClickEvent("close", $headerBtnClose, evtConfig, config.btn?.close?.callback);
|
|
11557
11629
|
// 创建到页面中
|
|
@@ -11589,6 +11661,8 @@ var pops = (function () {
|
|
|
11589
11661
|
$mask: $mask,
|
|
11590
11662
|
$shadowContainer: $shadowContainer,
|
|
11591
11663
|
$shadowRoot: $shadowRoot,
|
|
11664
|
+
config: config,
|
|
11665
|
+
destory: result.close,
|
|
11592
11666
|
});
|
|
11593
11667
|
// 拖拽
|
|
11594
11668
|
if (config.drag) {
|
|
@@ -11600,7 +11674,6 @@ var pops = (function () {
|
|
|
11600
11674
|
endCallBack: config.dragEndCallBack,
|
|
11601
11675
|
});
|
|
11602
11676
|
}
|
|
11603
|
-
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
11604
11677
|
return {
|
|
11605
11678
|
...result,
|
|
11606
11679
|
addEventListener: (event, listener, options) => {
|
|
@@ -11792,6 +11865,7 @@ var pops = (function () {
|
|
|
11792
11865
|
$elList.push($mask);
|
|
11793
11866
|
}
|
|
11794
11867
|
const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, $mask);
|
|
11868
|
+
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
11795
11869
|
// 输入框赋值初始值
|
|
11796
11870
|
$input.value = config.content.text;
|
|
11797
11871
|
PopsHandler.handlePromptClickEvent("close", $input, $btnClose, evtConfig, config.btn.close.callback);
|
|
@@ -11814,6 +11888,8 @@ var pops = (function () {
|
|
|
11814
11888
|
$mask: $mask,
|
|
11815
11889
|
$shadowContainer: $shadowContainer,
|
|
11816
11890
|
$shadowRoot: $shadowRoot,
|
|
11891
|
+
config: config,
|
|
11892
|
+
destory: result.close,
|
|
11817
11893
|
});
|
|
11818
11894
|
// 拖拽
|
|
11819
11895
|
if (config.drag) {
|
|
@@ -11833,7 +11909,6 @@ var pops = (function () {
|
|
|
11833
11909
|
if (config.content.select) {
|
|
11834
11910
|
$input.select();
|
|
11835
11911
|
}
|
|
11836
|
-
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
11837
11912
|
return result;
|
|
11838
11913
|
},
|
|
11839
11914
|
};
|
|
@@ -11935,6 +12010,7 @@ var pops = (function () {
|
|
|
11935
12010
|
beforeAppendToPageCallBack() { },
|
|
11936
12011
|
limitPositionXInView: true,
|
|
11937
12012
|
limitPositionYInView: true,
|
|
12013
|
+
beforeShowCallBack() { },
|
|
11938
12014
|
};
|
|
11939
12015
|
};
|
|
11940
12016
|
|
|
@@ -11994,6 +12070,8 @@ var pops = (function () {
|
|
|
11994
12070
|
return;
|
|
11995
12071
|
}
|
|
11996
12072
|
if ($click.className && $click.className === "pops-shadow-container" && $click.shadowRoot != null) {
|
|
12073
|
+
// pops的shadow-container
|
|
12074
|
+
PopsContextMenu.shadowRootCheckClickEvent(event);
|
|
11997
12075
|
return;
|
|
11998
12076
|
}
|
|
11999
12077
|
PopsContextMenu.closeAllMenu(PopsContextMenu.$el.$root);
|
|
@@ -12006,7 +12084,7 @@ var pops = (function () {
|
|
|
12006
12084
|
if (!PopsContextMenu.$el.$root) {
|
|
12007
12085
|
return;
|
|
12008
12086
|
}
|
|
12009
|
-
const $click = event.
|
|
12087
|
+
const $click = event.composedPath()[0];
|
|
12010
12088
|
if ($click.closest(`.pops-${popsType}`)) {
|
|
12011
12089
|
return;
|
|
12012
12090
|
}
|
|
@@ -12016,13 +12094,13 @@ var pops = (function () {
|
|
|
12016
12094
|
* 添加全局点击检测事件
|
|
12017
12095
|
*/
|
|
12018
12096
|
addWindowCheckClickListener() {
|
|
12019
|
-
popsDOMUtils.on(globalThis, "click touchstart",
|
|
12097
|
+
popsDOMUtils.on(globalThis, "click touchstart", PopsContextMenu.windowCheckClickEvent, {
|
|
12020
12098
|
capture: true,
|
|
12021
12099
|
});
|
|
12022
12100
|
if (config.$target instanceof Node) {
|
|
12023
12101
|
const $shadowRoot = config.$target.getRootNode();
|
|
12024
12102
|
if ($shadowRoot instanceof ShadowRoot) {
|
|
12025
|
-
popsDOMUtils.on($shadowRoot, "click touchstart",
|
|
12103
|
+
popsDOMUtils.on($shadowRoot, "click touchstart", PopsContextMenu.shadowRootCheckClickEvent, {
|
|
12026
12104
|
capture: true,
|
|
12027
12105
|
});
|
|
12028
12106
|
}
|
|
@@ -12032,13 +12110,13 @@ var pops = (function () {
|
|
|
12032
12110
|
* 移除全局点击检测事件
|
|
12033
12111
|
*/
|
|
12034
12112
|
removeWindowCheckClickListener() {
|
|
12035
|
-
popsDOMUtils.off(globalThis, "click touchstart",
|
|
12113
|
+
popsDOMUtils.off(globalThis, "click touchstart", PopsContextMenu.windowCheckClickEvent, {
|
|
12036
12114
|
capture: true,
|
|
12037
12115
|
});
|
|
12038
12116
|
if (config.$target instanceof Node) {
|
|
12039
12117
|
const $shadowRoot = config.$target.getRootNode();
|
|
12040
12118
|
if ($shadowRoot instanceof ShadowRoot) {
|
|
12041
|
-
popsDOMUtils.off($shadowRoot, "click touchstart",
|
|
12119
|
+
popsDOMUtils.off($shadowRoot, "click touchstart", PopsContextMenu.windowCheckClickEvent, {
|
|
12042
12120
|
capture: true,
|
|
12043
12121
|
});
|
|
12044
12122
|
}
|
|
@@ -12049,7 +12127,7 @@ var pops = (function () {
|
|
|
12049
12127
|
* @param event
|
|
12050
12128
|
* @param selectorTarget
|
|
12051
12129
|
*/
|
|
12052
|
-
contextMenuEvent(event, selectorTarget) {
|
|
12130
|
+
async contextMenuEvent(event, selectorTarget) {
|
|
12053
12131
|
if (config.preventDefault) {
|
|
12054
12132
|
popsDOMUtils.preventEvent(event);
|
|
12055
12133
|
}
|
|
@@ -12058,6 +12136,10 @@ var pops = (function () {
|
|
|
12058
12136
|
PopsContextMenu.closeAllMenu(PopsContextMenu.$el.$root);
|
|
12059
12137
|
}
|
|
12060
12138
|
selectorTarget = selectorTarget ?? config.$target;
|
|
12139
|
+
const beforeShowCallBackResult = await config?.beforeShowCallBack(event);
|
|
12140
|
+
if (typeof beforeShowCallBackResult === "boolean" && !beforeShowCallBackResult) {
|
|
12141
|
+
return;
|
|
12142
|
+
}
|
|
12061
12143
|
const rootElement = PopsContextMenu.showMenu(event, config.data, selectorTarget);
|
|
12062
12144
|
PopsContextMenu.$el.$root = rootElement;
|
|
12063
12145
|
if (config.only) {
|
|
@@ -12070,6 +12152,10 @@ var pops = (function () {
|
|
|
12070
12152
|
beforeRemoveCallBack(instCommonConfig) {
|
|
12071
12153
|
PopsContextMenu.closeAllMenu(instCommonConfig.$pops);
|
|
12072
12154
|
},
|
|
12155
|
+
config: config,
|
|
12156
|
+
destory: () => {
|
|
12157
|
+
PopsContextMenu.closeAllMenu(rootElement);
|
|
12158
|
+
},
|
|
12073
12159
|
});
|
|
12074
12160
|
}
|
|
12075
12161
|
},
|
|
@@ -12373,7 +12459,8 @@ var pops = (function () {
|
|
|
12373
12459
|
menuLiElement.appendChild(iconElement);
|
|
12374
12460
|
}
|
|
12375
12461
|
// 插入文字
|
|
12376
|
-
|
|
12462
|
+
const text = typeof item.text === "function" ? item.text() : item.text;
|
|
12463
|
+
menuLiElement.insertAdjacentHTML("beforeend", PopsSafeUtils.getSafeHTML(`<span>${text}</span>`));
|
|
12377
12464
|
// 如果存在子数据,显示
|
|
12378
12465
|
if (item.item && Array.isArray(item.item)) {
|
|
12379
12466
|
popsDOMUtils.addClassName(menuLiElement, `pops-${popsType}-item`);
|
|
@@ -13012,10 +13099,10 @@ var pops = (function () {
|
|
|
13012
13099
|
setShowEvent(option = defaultListenerOption) {
|
|
13013
13100
|
/* 焦点|点击事件*/
|
|
13014
13101
|
if (config.followPosition === "target") {
|
|
13015
|
-
popsDOMUtils.on([config.$target], ["focus", "click"],
|
|
13102
|
+
popsDOMUtils.on([config.$target], ["focus", "click"], SearchSuggestion.showEvent, option);
|
|
13016
13103
|
}
|
|
13017
13104
|
else if (config.followPosition === "input") {
|
|
13018
|
-
popsDOMUtils.on([config.$inputTarget], ["focus", "click"],
|
|
13105
|
+
popsDOMUtils.on([config.$inputTarget], ["focus", "click"], SearchSuggestion.showEvent, option);
|
|
13019
13106
|
}
|
|
13020
13107
|
else if (config.followPosition === "inputCursor") {
|
|
13021
13108
|
popsDOMUtils.on([config.$inputTarget], ["focus", "click", "input"], SearchSuggestion.showEvent, option);
|
|
@@ -13029,9 +13116,9 @@ var pops = (function () {
|
|
|
13029
13116
|
*/
|
|
13030
13117
|
removeShowEvent(option = defaultListenerOption) {
|
|
13031
13118
|
/* 焦点|点击事件*/
|
|
13032
|
-
popsDOMUtils.off([config.$target, config.$inputTarget], ["focus", "click"],
|
|
13119
|
+
popsDOMUtils.off([config.$target, config.$inputTarget], ["focus", "click"], SearchSuggestion.showEvent, option);
|
|
13033
13120
|
// 内容改变事件
|
|
13034
|
-
popsDOMUtils.off([config.$inputTarget], ["input"],
|
|
13121
|
+
popsDOMUtils.off([config.$inputTarget], ["input"], SearchSuggestion.showEvent, option);
|
|
13035
13122
|
},
|
|
13036
13123
|
/**
|
|
13037
13124
|
* 隐藏搜索建议框的事件
|
|
@@ -13062,7 +13149,7 @@ var pops = (function () {
|
|
|
13062
13149
|
// 全局触摸屏点击事件
|
|
13063
13150
|
if (Array.isArray(SearchSuggestion.selfDocument)) {
|
|
13064
13151
|
SearchSuggestion.selfDocument.forEach(($checkParent) => {
|
|
13065
|
-
popsDOMUtils.on($checkParent, ["click", "touchstart"],
|
|
13152
|
+
popsDOMUtils.on($checkParent, ["click", "touchstart"], SearchSuggestion.hideEvent, option);
|
|
13066
13153
|
});
|
|
13067
13154
|
}
|
|
13068
13155
|
else {
|
|
@@ -13075,11 +13162,11 @@ var pops = (function () {
|
|
|
13075
13162
|
removeHideEvent(option = defaultListenerOption) {
|
|
13076
13163
|
if (Array.isArray(SearchSuggestion.selfDocument)) {
|
|
13077
13164
|
SearchSuggestion.selfDocument.forEach(($checkParent) => {
|
|
13078
|
-
popsDOMUtils.off($checkParent, ["click", "touchstart"],
|
|
13165
|
+
popsDOMUtils.off($checkParent, ["click", "touchstart"], SearchSuggestion.hideEvent, option);
|
|
13079
13166
|
});
|
|
13080
13167
|
}
|
|
13081
13168
|
else {
|
|
13082
|
-
popsDOMUtils.off(SearchSuggestion.selfDocument, ["click", "touchstart"],
|
|
13169
|
+
popsDOMUtils.off(SearchSuggestion.selfDocument, ["click", "touchstart"], SearchSuggestion.hideEvent, option);
|
|
13083
13170
|
}
|
|
13084
13171
|
},
|
|
13085
13172
|
/**
|
|
@@ -13340,7 +13427,7 @@ var pops = (function () {
|
|
|
13340
13427
|
},
|
|
13341
13428
|
};
|
|
13342
13429
|
|
|
13343
|
-
const version = "3.
|
|
13430
|
+
const version = "3.2.0";
|
|
13344
13431
|
|
|
13345
13432
|
class Pops {
|
|
13346
13433
|
/** 配置 */
|