@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.esm.js
CHANGED
|
@@ -259,47 +259,7 @@ const LAST_NUMBER_WEAK_MAP = new WeakMap();
|
|
|
259
259
|
const cache = createCache(LAST_NUMBER_WEAK_MAP);
|
|
260
260
|
const generateUniqueNumber = createGenerateUniqueNumber(cache, LAST_NUMBER_WEAK_MAP);
|
|
261
261
|
|
|
262
|
-
const
|
|
263
|
-
return typeof sender.start === 'function';
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
const PORT_MAP = new WeakMap();
|
|
267
|
-
|
|
268
|
-
const extendBrokerImplementation = (partialBrokerImplementation) => ({
|
|
269
|
-
...partialBrokerImplementation,
|
|
270
|
-
connect: ({ call }) => {
|
|
271
|
-
return async () => {
|
|
272
|
-
const { port1, port2 } = new MessageChannel();
|
|
273
|
-
const portId = await call('connect', { port: port1 }, [port1]);
|
|
274
|
-
PORT_MAP.set(port2, portId);
|
|
275
|
-
return port2;
|
|
276
|
-
};
|
|
277
|
-
},
|
|
278
|
-
disconnect: ({ call }) => {
|
|
279
|
-
return async (port) => {
|
|
280
|
-
const portId = PORT_MAP.get(port);
|
|
281
|
-
if (portId === undefined) {
|
|
282
|
-
throw new Error('The given port is not connected.');
|
|
283
|
-
}
|
|
284
|
-
await call('disconnect', { portId });
|
|
285
|
-
};
|
|
286
|
-
},
|
|
287
|
-
isSupported: ({ call }) => {
|
|
288
|
-
return () => call('isSupported');
|
|
289
|
-
}
|
|
290
|
-
});
|
|
291
|
-
|
|
292
|
-
const ONGOING_REQUESTS = new WeakMap();
|
|
293
|
-
const createOrGetOngoingRequests = (sender) => {
|
|
294
|
-
if (ONGOING_REQUESTS.has(sender)) {
|
|
295
|
-
// @todo TypeScript needs to be convinced that has() works as expected.
|
|
296
|
-
return ONGOING_REQUESTS.get(sender);
|
|
297
|
-
}
|
|
298
|
-
const ongoingRequests = new Map();
|
|
299
|
-
ONGOING_REQUESTS.set(sender, ongoingRequests);
|
|
300
|
-
return ongoingRequests;
|
|
301
|
-
};
|
|
302
|
-
const createBroker = (brokerImplementation) => {
|
|
262
|
+
const createBrokerFactory = (createOrGetOngoingRequests, extendBrokerImplementation, generateUniqueNumber, isMessagePort) => (brokerImplementation) => {
|
|
303
263
|
const fullBrokerImplementation = extendBrokerImplementation(brokerImplementation);
|
|
304
264
|
return (sender) => {
|
|
305
265
|
const ongoingRequests = createOrGetOngoingRequests(sender);
|
|
@@ -342,81 +302,115 @@ const createBroker = (brokerImplementation) => {
|
|
|
342
302
|
};
|
|
343
303
|
};
|
|
344
304
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
305
|
+
const createCreateOrGetOngoingRequests = (ongoingRequestsMap) => (sender) => {
|
|
306
|
+
if (ongoingRequestsMap.has(sender)) {
|
|
307
|
+
// @todo TypeScript needs to be convinced that has() works as expected.
|
|
308
|
+
return ongoingRequestsMap.get(sender);
|
|
309
|
+
}
|
|
310
|
+
const ongoingRequests = new Map();
|
|
311
|
+
ongoingRequestsMap.set(sender, ongoingRequests);
|
|
312
|
+
return ongoingRequests;
|
|
313
|
+
};
|
|
314
|
+
|
|
315
|
+
const createExtendBrokerImplementation = (portMap) => (partialBrokerImplementation) => ({
|
|
316
|
+
...partialBrokerImplementation,
|
|
317
|
+
connect: ({ call }) => {
|
|
318
|
+
return async () => {
|
|
319
|
+
const { port1, port2 } = new MessageChannel();
|
|
320
|
+
const portId = await call('connect', { port: port1 }, [port1]);
|
|
321
|
+
portMap.set(port2, portId);
|
|
322
|
+
return port2;
|
|
357
323
|
};
|
|
358
324
|
},
|
|
359
|
-
|
|
360
|
-
return (
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
scheduledTimeoutsState.delete(timerId);
|
|
365
|
-
});
|
|
325
|
+
disconnect: ({ call }) => {
|
|
326
|
+
return async (port) => {
|
|
327
|
+
const portId = portMap.get(port);
|
|
328
|
+
if (portId === undefined) {
|
|
329
|
+
throw new Error('The given port is not connected.');
|
|
366
330
|
}
|
|
331
|
+
await call('disconnect', { portId });
|
|
367
332
|
};
|
|
368
333
|
},
|
|
369
|
-
|
|
370
|
-
return (
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
};
|
|
395
|
-
},
|
|
396
|
-
setTimeout: ({ call }) => {
|
|
397
|
-
return (func, delay = 0, ...args) => {
|
|
398
|
-
const symbol = Symbol();
|
|
399
|
-
const timerId = generateUniqueNumber(scheduledTimeoutsState);
|
|
400
|
-
scheduledTimeoutsState.set(timerId, symbol);
|
|
401
|
-
call('set', {
|
|
402
|
-
delay,
|
|
403
|
-
now: performance.timeOrigin + performance.now(),
|
|
404
|
-
timerId,
|
|
405
|
-
timerType: 'timeout'
|
|
406
|
-
}).then(() => {
|
|
407
|
-
const state = scheduledTimeoutsState.get(timerId);
|
|
408
|
-
if (state === undefined) {
|
|
409
|
-
throw new Error('The timer is in an undefined state.');
|
|
410
|
-
}
|
|
411
|
-
if (state === symbol) {
|
|
412
|
-
// A timeout can be savely deleted because it is only called once.
|
|
413
|
-
scheduledTimeoutsState.delete(timerId);
|
|
414
|
-
func(...args);
|
|
415
|
-
}
|
|
416
|
-
});
|
|
417
|
-
return timerId;
|
|
418
|
-
};
|
|
334
|
+
isSupported: ({ call }) => {
|
|
335
|
+
return () => call('isSupported');
|
|
336
|
+
}
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
const isMessagePort = (sender) => {
|
|
340
|
+
return typeof sender.start === 'function';
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
const createBroker = createBrokerFactory(createCreateOrGetOngoingRequests(new WeakMap()), createExtendBrokerImplementation(new WeakMap()), generateUniqueNumber, isMessagePort);
|
|
344
|
+
|
|
345
|
+
const createClearIntervalFactory = (scheduledIntervalsState) => (clear) => (timerId) => {
|
|
346
|
+
if (typeof scheduledIntervalsState.get(timerId) === 'symbol') {
|
|
347
|
+
scheduledIntervalsState.set(timerId, null);
|
|
348
|
+
clear(timerId).then(() => {
|
|
349
|
+
scheduledIntervalsState.delete(timerId);
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
};
|
|
353
|
+
|
|
354
|
+
const createClearTimeoutFactory = (scheduledTimeoutsState) => (clear) => (timerId) => {
|
|
355
|
+
if (typeof scheduledTimeoutsState.get(timerId) === 'symbol') {
|
|
356
|
+
scheduledTimeoutsState.set(timerId, null);
|
|
357
|
+
clear(timerId).then(() => {
|
|
358
|
+
scheduledTimeoutsState.delete(timerId);
|
|
359
|
+
});
|
|
419
360
|
}
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
const createSetIntervalFactory = (generateUniqueNumber, scheduledIntervalsState) => (set) => (func, delay = 0, ...args) => {
|
|
364
|
+
const symbol = Symbol();
|
|
365
|
+
const timerId = generateUniqueNumber(scheduledIntervalsState);
|
|
366
|
+
scheduledIntervalsState.set(timerId, symbol);
|
|
367
|
+
const schedule = () => set(delay, timerId).then(() => {
|
|
368
|
+
const state = scheduledIntervalsState.get(timerId);
|
|
369
|
+
if (state === undefined) {
|
|
370
|
+
throw new Error('The timer is in an undefined state.');
|
|
371
|
+
}
|
|
372
|
+
if (state === symbol) {
|
|
373
|
+
func(...args);
|
|
374
|
+
// Doublecheck if the interval should still be rescheduled because it could have been cleared inside of func().
|
|
375
|
+
if (scheduledIntervalsState.get(timerId) === symbol) {
|
|
376
|
+
schedule();
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
schedule();
|
|
381
|
+
return timerId;
|
|
382
|
+
};
|
|
383
|
+
|
|
384
|
+
const createSetTimeoutFactory = (generateUniqueNumber, scheduledTimeoutsState) => (set) => (func, delay = 0, ...args) => {
|
|
385
|
+
const symbol = Symbol();
|
|
386
|
+
const timerId = generateUniqueNumber(scheduledTimeoutsState);
|
|
387
|
+
scheduledTimeoutsState.set(timerId, symbol);
|
|
388
|
+
set(delay, timerId).then(() => {
|
|
389
|
+
const state = scheduledTimeoutsState.get(timerId);
|
|
390
|
+
if (state === undefined) {
|
|
391
|
+
throw new Error('The timer is in an undefined state.');
|
|
392
|
+
}
|
|
393
|
+
if (state === symbol) {
|
|
394
|
+
// A timeout can be savely deleted because it is only called once.
|
|
395
|
+
scheduledTimeoutsState.delete(timerId);
|
|
396
|
+
func(...args);
|
|
397
|
+
}
|
|
398
|
+
});
|
|
399
|
+
return timerId;
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
// Prefilling the Maps with a function indexed by zero is necessary to be compliant with the specification.
|
|
403
|
+
const scheduledIntervalsState = new Map([[0, null]]); // tslint:disable-line no-empty
|
|
404
|
+
const scheduledTimeoutsState = new Map([[0, null]]); // tslint:disable-line no-empty
|
|
405
|
+
const createClearInterval = createClearIntervalFactory(scheduledIntervalsState);
|
|
406
|
+
const createClearTimeout = createClearTimeoutFactory(scheduledTimeoutsState);
|
|
407
|
+
const createSetInterval = createSetIntervalFactory(generateUniqueNumber, scheduledIntervalsState);
|
|
408
|
+
const createSetTimeout = createSetTimeoutFactory(generateUniqueNumber, scheduledTimeoutsState);
|
|
409
|
+
const wrap = createBroker({
|
|
410
|
+
clearInterval: ({ call }) => createClearInterval((timerId) => call('clear', { timerId, timerType: 'interval' })),
|
|
411
|
+
clearTimeout: ({ call }) => createClearTimeout((timerId) => call('clear', { timerId, timerType: 'timeout' })),
|
|
412
|
+
setInterval: ({ call }) => createSetInterval((delay, timerId) => call('set', { delay, now: performance.timeOrigin + performance.now(), timerId, timerType: 'interval' })),
|
|
413
|
+
setTimeout: ({ call }) => createSetTimeout((delay, timerId) => call('set', { delay, now: performance.timeOrigin + performance.now(), timerId, timerType: 'timeout' }))
|
|
420
414
|
});
|
|
421
415
|
const load = (url) => {
|
|
422
416
|
const worker = new Worker(url);
|
|
@@ -439,7 +433,7 @@ const createLoadOrReturnBroker = (loadBroker, worker) => {
|
|
|
439
433
|
};
|
|
440
434
|
|
|
441
435
|
// This is the minified and stringified code of the worker-timers-worker package.
|
|
442
|
-
const worker = `(()=>{var e={455
|
|
436
|
+
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
|
|
443
437
|
|
|
444
438
|
const loadOrReturnBroker = createLoadOrReturnBroker(load, worker);
|
|
445
439
|
const clearInterval$1 = (timerId) => loadOrReturnBroker().clearInterval(timerId);
|
|
@@ -520,7 +514,7 @@ class PopsUtils {
|
|
|
520
514
|
* @param propName
|
|
521
515
|
*/
|
|
522
516
|
delete(target, propName) {
|
|
523
|
-
if (typeof Reflect === "object" && Reflect.deleteProperty) {
|
|
517
|
+
if (typeof Reflect === "object" && typeof Reflect.deleteProperty === "function") {
|
|
524
518
|
Reflect.deleteProperty(target, propName);
|
|
525
519
|
}
|
|
526
520
|
else {
|
|
@@ -1026,13 +1020,13 @@ class PopsDOMUtilsEvent {
|
|
|
1026
1020
|
if (element == null) {
|
|
1027
1021
|
return;
|
|
1028
1022
|
}
|
|
1029
|
-
let
|
|
1023
|
+
let $elList = [];
|
|
1030
1024
|
if (element instanceof NodeList || Array.isArray(element)) {
|
|
1031
1025
|
element = element;
|
|
1032
|
-
|
|
1026
|
+
$elList = $elList.concat(element);
|
|
1033
1027
|
}
|
|
1034
1028
|
else {
|
|
1035
|
-
|
|
1029
|
+
$elList.push(element);
|
|
1036
1030
|
}
|
|
1037
1031
|
let eventTypeList = [];
|
|
1038
1032
|
if (Array.isArray(eventType)) {
|
|
@@ -1083,7 +1077,7 @@ class PopsDOMUtilsEvent {
|
|
|
1083
1077
|
// 目标函数、事件名、回调函数、事件配置、过滤函数
|
|
1084
1078
|
filter = option;
|
|
1085
1079
|
}
|
|
1086
|
-
|
|
1080
|
+
$elList.forEach((elementItem) => {
|
|
1087
1081
|
// 获取对象上的事件
|
|
1088
1082
|
const elementEvents = Reflect.get(elementItem, SymbolEvents) || {};
|
|
1089
1083
|
eventTypeList.forEach((eventName) => {
|
|
@@ -1130,18 +1124,19 @@ class PopsDOMUtilsEvent {
|
|
|
1130
1124
|
* @param eventType (可选)需要取消监听的事件
|
|
1131
1125
|
*/
|
|
1132
1126
|
offAll(element, eventType) {
|
|
1127
|
+
const that = this;
|
|
1133
1128
|
if (typeof element === "string") {
|
|
1134
|
-
element =
|
|
1129
|
+
element = that.selectorAll(element);
|
|
1135
1130
|
}
|
|
1136
1131
|
if (element == null) {
|
|
1137
1132
|
return;
|
|
1138
1133
|
}
|
|
1139
|
-
let
|
|
1134
|
+
let $elList = [];
|
|
1140
1135
|
if (element instanceof NodeList || Array.isArray(element)) {
|
|
1141
|
-
|
|
1136
|
+
$elList = $elList.concat(Array.from(element));
|
|
1142
1137
|
}
|
|
1143
1138
|
else {
|
|
1144
|
-
|
|
1139
|
+
$elList.push(element);
|
|
1145
1140
|
}
|
|
1146
1141
|
let eventTypeList = [];
|
|
1147
1142
|
if (Array.isArray(eventType)) {
|
|
@@ -1150,12 +1145,13 @@ class PopsDOMUtilsEvent {
|
|
|
1150
1145
|
else if (typeof eventType === "string") {
|
|
1151
1146
|
eventTypeList = eventTypeList.concat(eventType.split(" "));
|
|
1152
1147
|
}
|
|
1153
|
-
|
|
1154
|
-
Object.getOwnPropertySymbols(
|
|
1155
|
-
|
|
1148
|
+
$elList.forEach(($elItem) => {
|
|
1149
|
+
const symbolList = [...new Set([...Object.getOwnPropertySymbols($elItem), SymbolEvents])];
|
|
1150
|
+
symbolList.forEach((symbolItem) => {
|
|
1151
|
+
if (!symbolItem.toString().startsWith("Symbol(events_")) {
|
|
1156
1152
|
return;
|
|
1157
1153
|
}
|
|
1158
|
-
const elementEvents =
|
|
1154
|
+
const elementEvents = Reflect.get($elItem, symbolItem) || {};
|
|
1159
1155
|
const iterEventNameList = eventTypeList.length ? eventTypeList : Object.keys(elementEvents);
|
|
1160
1156
|
iterEventNameList.forEach((eventName) => {
|
|
1161
1157
|
const handlers = elementEvents[eventName];
|
|
@@ -1163,11 +1159,12 @@ class PopsDOMUtilsEvent {
|
|
|
1163
1159
|
return;
|
|
1164
1160
|
}
|
|
1165
1161
|
for (const handler of handlers) {
|
|
1166
|
-
|
|
1162
|
+
$elItem.removeEventListener(eventName, handler.callback, {
|
|
1167
1163
|
capture: handler["option"]["capture"],
|
|
1168
1164
|
});
|
|
1169
1165
|
}
|
|
1170
|
-
|
|
1166
|
+
const events = Reflect.get($elItem, symbolItem);
|
|
1167
|
+
popsUtils.delete(events, eventName);
|
|
1171
1168
|
});
|
|
1172
1169
|
});
|
|
1173
1170
|
});
|
|
@@ -1910,7 +1907,8 @@ class PopsDOMUtils extends PopsDOMUtilsEvent {
|
|
|
1910
1907
|
}
|
|
1911
1908
|
return $el.classList.contains(className);
|
|
1912
1909
|
}
|
|
1913
|
-
css(
|
|
1910
|
+
css($el, property, value) {
|
|
1911
|
+
const that = this;
|
|
1914
1912
|
/**
|
|
1915
1913
|
* 把纯数字没有px的加上
|
|
1916
1914
|
*/
|
|
@@ -1924,10 +1922,33 @@ class PopsDOMUtils extends PopsDOMUtilsEvent {
|
|
|
1924
1922
|
}
|
|
1925
1923
|
return propertyValue;
|
|
1926
1924
|
}
|
|
1927
|
-
if (typeof
|
|
1928
|
-
|
|
1925
|
+
if (typeof $el === "string") {
|
|
1926
|
+
$el = that.selectorAll($el);
|
|
1929
1927
|
}
|
|
1930
|
-
if (
|
|
1928
|
+
if ($el == null) {
|
|
1929
|
+
return;
|
|
1930
|
+
}
|
|
1931
|
+
if (Array.isArray($el) || $el instanceof NodeList) {
|
|
1932
|
+
if (typeof property === "string") {
|
|
1933
|
+
if (value == null) {
|
|
1934
|
+
// 获取属性
|
|
1935
|
+
return that.css($el[0], property);
|
|
1936
|
+
}
|
|
1937
|
+
else {
|
|
1938
|
+
// 设置属性
|
|
1939
|
+
$el.forEach(($elItem) => {
|
|
1940
|
+
that.css($elItem, property);
|
|
1941
|
+
});
|
|
1942
|
+
return;
|
|
1943
|
+
}
|
|
1944
|
+
}
|
|
1945
|
+
else if (typeof property === "object") {
|
|
1946
|
+
// 设置属性
|
|
1947
|
+
$el.forEach(($elItem) => {
|
|
1948
|
+
that.css($elItem, property);
|
|
1949
|
+
});
|
|
1950
|
+
return;
|
|
1951
|
+
}
|
|
1931
1952
|
return;
|
|
1932
1953
|
}
|
|
1933
1954
|
const setStyleProperty = (propertyName, propertyValue) => {
|
|
@@ -1936,16 +1957,16 @@ class PopsDOMUtils extends PopsDOMUtilsEvent {
|
|
|
1936
1957
|
.trim()
|
|
1937
1958
|
.replace(/!important$/gi, "")
|
|
1938
1959
|
.trim();
|
|
1939
|
-
|
|
1960
|
+
$el.style.setProperty(propertyName, propertyValue, "important");
|
|
1940
1961
|
}
|
|
1941
1962
|
else {
|
|
1942
1963
|
propertyValue = handlePixe(propertyName, propertyValue);
|
|
1943
|
-
|
|
1964
|
+
$el.style.setProperty(propertyName, propertyValue);
|
|
1944
1965
|
}
|
|
1945
1966
|
};
|
|
1946
1967
|
if (typeof property === "string") {
|
|
1947
1968
|
if (value == null) {
|
|
1948
|
-
return getComputedStyle(
|
|
1969
|
+
return PopsCore.globalThis.getComputedStyle($el).getPropertyValue(property);
|
|
1949
1970
|
}
|
|
1950
1971
|
else {
|
|
1951
1972
|
setStyleProperty(property, value);
|
|
@@ -1957,6 +1978,10 @@ class PopsDOMUtils extends PopsDOMUtilsEvent {
|
|
|
1957
1978
|
setStyleProperty(prop, value);
|
|
1958
1979
|
}
|
|
1959
1980
|
}
|
|
1981
|
+
else {
|
|
1982
|
+
// 其他情况
|
|
1983
|
+
throw new TypeError("property must be string or object");
|
|
1984
|
+
}
|
|
1960
1985
|
}
|
|
1961
1986
|
/**
|
|
1962
1987
|
* 创建元素
|
|
@@ -3091,16 +3116,16 @@ const PopsInstanceUtils = {
|
|
|
3091
3116
|
},
|
|
3092
3117
|
/**
|
|
3093
3118
|
* 删除配置中对应的对象
|
|
3094
|
-
* @param
|
|
3119
|
+
* @param totalInstConfigList 配置实例列表
|
|
3095
3120
|
* @param guid 唯一标识
|
|
3096
3121
|
* @param isAll 是否全部删除
|
|
3097
3122
|
*/
|
|
3098
|
-
removeInstance(
|
|
3123
|
+
async removeInstance(totalInstConfigList, guid, isAll = false) {
|
|
3099
3124
|
/**
|
|
3100
3125
|
* 移除元素实例
|
|
3101
3126
|
* @param instCommonConfig
|
|
3102
3127
|
*/
|
|
3103
|
-
function
|
|
3128
|
+
const removeInst = function (instCommonConfig) {
|
|
3104
3129
|
if (typeof instCommonConfig.beforeRemoveCallBack === "function") {
|
|
3105
3130
|
// 调用移除签的回调
|
|
3106
3131
|
instCommonConfig.beforeRemoveCallBack(instCommonConfig);
|
|
@@ -3109,39 +3134,44 @@ const PopsInstanceUtils = {
|
|
|
3109
3134
|
instCommonConfig?.$pops?.remove();
|
|
3110
3135
|
instCommonConfig?.$mask?.remove();
|
|
3111
3136
|
instCommonConfig?.$shadowContainer?.remove();
|
|
3112
|
-
}
|
|
3137
|
+
};
|
|
3138
|
+
const asyncInstTask = [];
|
|
3113
3139
|
// [ inst[], inst[],...]
|
|
3114
|
-
|
|
3140
|
+
totalInstConfigList.forEach((instConfigList) => {
|
|
3115
3141
|
// inst[]
|
|
3116
|
-
instConfigList.forEach((instConfigItem, index) => {
|
|
3142
|
+
instConfigList.forEach(async (instConfigItem, index) => {
|
|
3117
3143
|
// 移除全部或者guid相同
|
|
3118
|
-
if (isAll ||
|
|
3144
|
+
if (isAll || (typeof guid === "string" && instConfigItem.guid === guid)) {
|
|
3119
3145
|
// 判断是否有动画
|
|
3120
3146
|
const animName = instConfigItem.$anim.getAttribute("anim");
|
|
3121
3147
|
if (PopsAnimation.hasAnim(animName)) {
|
|
3122
3148
|
const reverseAnimName = animName + "-reverse";
|
|
3123
|
-
instConfigItem.$anim
|
|
3124
|
-
instConfigItem.$anim
|
|
3125
|
-
instConfigItem.$anim
|
|
3126
|
-
if (PopsAnimation.hasAnim(instConfigItem.$anim
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3149
|
+
popsDOMUtils.css(instConfigItem.$anim, "width", "100%");
|
|
3150
|
+
popsDOMUtils.css(instConfigItem.$anim, "height", "100%");
|
|
3151
|
+
popsDOMUtils.css(instConfigItem.$anim, "animation-name", reverseAnimName);
|
|
3152
|
+
if (PopsAnimation.hasAnim(popsDOMUtils.css(instConfigItem.$anim, "animation-name"))) {
|
|
3153
|
+
asyncInstTask.push(new Promise((resolve) => {
|
|
3154
|
+
popsDOMUtils.on(instConfigItem.$anim, popsDOMUtils.getAnimationEndNameList(), function () {
|
|
3155
|
+
removeInst(instConfigItem);
|
|
3156
|
+
resolve();
|
|
3157
|
+
}, {
|
|
3158
|
+
capture: true,
|
|
3159
|
+
});
|
|
3160
|
+
}));
|
|
3132
3161
|
}
|
|
3133
3162
|
else {
|
|
3134
|
-
|
|
3163
|
+
removeInst(instConfigItem);
|
|
3135
3164
|
}
|
|
3136
3165
|
}
|
|
3137
3166
|
else {
|
|
3138
|
-
|
|
3167
|
+
removeInst(instConfigItem);
|
|
3139
3168
|
}
|
|
3140
3169
|
instConfigList.splice(index, 1);
|
|
3141
3170
|
}
|
|
3142
3171
|
});
|
|
3143
3172
|
});
|
|
3144
|
-
|
|
3173
|
+
await Promise.all(asyncInstTask);
|
|
3174
|
+
return totalInstConfigList;
|
|
3145
3175
|
},
|
|
3146
3176
|
/**
|
|
3147
3177
|
* 隐藏
|
|
@@ -3286,8 +3316,9 @@ const PopsInstanceUtils = {
|
|
|
3286
3316
|
* @param config
|
|
3287
3317
|
* @param $anim
|
|
3288
3318
|
*/
|
|
3289
|
-
close(config, popsType, instConfigList, guid, $anim) {
|
|
3290
|
-
|
|
3319
|
+
async close(config, popsType, instConfigList, guid, $anim) {
|
|
3320
|
+
// eslint-disable-next-line no-async-promise-executor
|
|
3321
|
+
await new Promise(async (resolve) => {
|
|
3291
3322
|
const $pops = $anim.querySelector(".pops[type-value]");
|
|
3292
3323
|
const drawerConfig = config;
|
|
3293
3324
|
/**
|
|
@@ -3297,12 +3328,12 @@ const PopsInstanceUtils = {
|
|
|
3297
3328
|
/**
|
|
3298
3329
|
* 弹窗已关闭的回调
|
|
3299
3330
|
*/
|
|
3300
|
-
function closeCallBack(event) {
|
|
3331
|
+
async function closeCallBack(event) {
|
|
3301
3332
|
if (event.propertyName !== "transform") {
|
|
3302
3333
|
return;
|
|
3303
3334
|
}
|
|
3304
|
-
popsDOMUtils.off($pops, popsDOMUtils.getTransitionEndNameList(),
|
|
3305
|
-
PopsInstanceUtils.removeInstance([instConfigList], guid);
|
|
3335
|
+
popsDOMUtils.off($pops, popsDOMUtils.getTransitionEndNameList(), closeCallBack);
|
|
3336
|
+
await PopsInstanceUtils.removeInstance([instConfigList], guid);
|
|
3306
3337
|
resolve();
|
|
3307
3338
|
}
|
|
3308
3339
|
// 监听过渡结束
|
|
@@ -3334,10 +3365,32 @@ const PopsInstanceUtils = {
|
|
|
3334
3365
|
}, drawerConfig.closeDelay);
|
|
3335
3366
|
}
|
|
3336
3367
|
else {
|
|
3337
|
-
PopsInstanceUtils.removeInstance([instConfigList], guid);
|
|
3368
|
+
await PopsInstanceUtils.removeInstance([instConfigList], guid);
|
|
3338
3369
|
resolve();
|
|
3339
3370
|
}
|
|
3340
3371
|
});
|
|
3372
|
+
// 判断组件内是否有rightClickMenu、tooltip、searchSuggestion组件
|
|
3373
|
+
// 有的话也需要关闭
|
|
3374
|
+
PopsInstData.rightClickMenu.forEach((itemConfig) => {
|
|
3375
|
+
const config = itemConfig.config;
|
|
3376
|
+
if (config.$target instanceof HTMLElement) {
|
|
3377
|
+
const $root = config.$target.getRootNode();
|
|
3378
|
+
if ($root instanceof HTMLElement && $root.parentElement == null) {
|
|
3379
|
+
// 触发销毁元素
|
|
3380
|
+
itemConfig.destory();
|
|
3381
|
+
}
|
|
3382
|
+
}
|
|
3383
|
+
});
|
|
3384
|
+
PopsInstData.tooltip.forEach((itemConfig) => {
|
|
3385
|
+
const config = itemConfig.config;
|
|
3386
|
+
if (config.$target instanceof HTMLElement) {
|
|
3387
|
+
const $root = config.$target.getRootNode();
|
|
3388
|
+
if ($root instanceof HTMLElement && $root.parentElement == null) {
|
|
3389
|
+
// 触发销毁元素
|
|
3390
|
+
itemConfig.destory();
|
|
3391
|
+
}
|
|
3392
|
+
}
|
|
3393
|
+
});
|
|
3341
3394
|
},
|
|
3342
3395
|
/**
|
|
3343
3396
|
* 拖拽元素
|
|
@@ -3676,12 +3729,12 @@ const PopsHandler = {
|
|
|
3676
3729
|
element.hasAttribute("anim"));
|
|
3677
3730
|
}
|
|
3678
3731
|
// 判断按下的元素是否是pops-anim
|
|
3679
|
-
popsDOMUtils.on(config.animElement, ["touchstart", "mousedown"],
|
|
3732
|
+
popsDOMUtils.on(config.animElement, ["touchstart", "mousedown"], (event) => {
|
|
3680
3733
|
const $click = event.composedPath()[0];
|
|
3681
3734
|
isMaskClick = isAnimElement($click);
|
|
3682
3735
|
});
|
|
3683
3736
|
// 如果有动画层,在动画层上监听点击事件
|
|
3684
|
-
popsDOMUtils.on(config.animElement, "click",
|
|
3737
|
+
popsDOMUtils.on(config.animElement, "click", (event) => {
|
|
3685
3738
|
const $click = event.composedPath()[0];
|
|
3686
3739
|
if (isAnimElement($click) && isMaskClick) {
|
|
3687
3740
|
return clickEvent(event);
|
|
@@ -3689,7 +3742,7 @@ const PopsHandler = {
|
|
|
3689
3742
|
});
|
|
3690
3743
|
// 在遮罩层监听点击事件
|
|
3691
3744
|
// 如果有动画层,那么该点击事件触发不了
|
|
3692
|
-
popsDOMUtils.on(result.maskElement, "click",
|
|
3745
|
+
popsDOMUtils.on(result.maskElement, "click", (event) => {
|
|
3693
3746
|
isMaskClick = true;
|
|
3694
3747
|
clickEvent(event);
|
|
3695
3748
|
});
|
|
@@ -3832,13 +3885,13 @@ const PopsHandler = {
|
|
|
3832
3885
|
* @param guid
|
|
3833
3886
|
* @param $shadowContainer
|
|
3834
3887
|
* @param $shadowRoot
|
|
3835
|
-
* @param
|
|
3888
|
+
* @param type 当前弹窗类型
|
|
3836
3889
|
* @param $anim 动画层
|
|
3837
3890
|
* @param $pops 主元素
|
|
3838
3891
|
* @param $mask 遮罩层
|
|
3839
3892
|
* @param config 当前配置
|
|
3840
3893
|
*/
|
|
3841
|
-
handleEventConfig(config, guid, $shadowContainer, $shadowRoot,
|
|
3894
|
+
handleEventConfig(config, guid, $shadowContainer, $shadowRoot, type, $anim, $pops, $mask) {
|
|
3842
3895
|
return {
|
|
3843
3896
|
$shadowContainer: $shadowContainer,
|
|
3844
3897
|
$shadowRoot: $shadowRoot,
|
|
@@ -3846,44 +3899,47 @@ const PopsHandler = {
|
|
|
3846
3899
|
$anim: $anim,
|
|
3847
3900
|
$pops: $pops,
|
|
3848
3901
|
$mask: $mask,
|
|
3849
|
-
mode:
|
|
3902
|
+
mode: type,
|
|
3850
3903
|
guid: guid,
|
|
3851
3904
|
close() {
|
|
3852
|
-
return PopsInstanceUtils.close(config,
|
|
3905
|
+
return PopsInstanceUtils.close(config, type, PopsInstData[type], guid, $anim);
|
|
3853
3906
|
},
|
|
3854
3907
|
hide() {
|
|
3855
|
-
return PopsInstanceUtils.hide(config,
|
|
3908
|
+
return PopsInstanceUtils.hide(config, type, PopsInstData[type], guid, $anim, $mask);
|
|
3856
3909
|
},
|
|
3857
|
-
show() {
|
|
3858
|
-
|
|
3910
|
+
show($parent) {
|
|
3911
|
+
if ($parent) {
|
|
3912
|
+
$parent.appendChild(PopsInstData[type][0].$shadowRoot);
|
|
3913
|
+
}
|
|
3914
|
+
return PopsInstanceUtils.show(config, type, PopsInstData[type], guid, $anim, $mask);
|
|
3859
3915
|
},
|
|
3860
3916
|
};
|
|
3861
3917
|
},
|
|
3862
3918
|
/**
|
|
3863
3919
|
* 获取loading的事件配置
|
|
3864
3920
|
* @param guid
|
|
3865
|
-
* @param
|
|
3921
|
+
* @param type 当前弹窗类型
|
|
3866
3922
|
* @param $anim 动画层
|
|
3867
3923
|
* @param $pops 主元素
|
|
3868
3924
|
* @param $mask 遮罩层
|
|
3869
3925
|
* @param config 当前配置
|
|
3870
3926
|
*/
|
|
3871
|
-
handleLoadingEventConfig(config, guid,
|
|
3927
|
+
handleLoadingEventConfig(config, guid, type, $anim, $pops, $mask) {
|
|
3872
3928
|
return {
|
|
3873
3929
|
$el: $anim,
|
|
3874
3930
|
$anim: $anim,
|
|
3875
3931
|
$pops: $pops,
|
|
3876
3932
|
$mask: $mask,
|
|
3877
|
-
mode:
|
|
3933
|
+
mode: type,
|
|
3878
3934
|
guid: guid,
|
|
3879
3935
|
close() {
|
|
3880
|
-
return PopsInstanceUtils.close(config,
|
|
3936
|
+
return PopsInstanceUtils.close(config, type, PopsInstData[type], guid, $anim);
|
|
3881
3937
|
},
|
|
3882
3938
|
hide() {
|
|
3883
|
-
return PopsInstanceUtils.hide(config,
|
|
3939
|
+
return PopsInstanceUtils.hide(config, type, PopsInstData[type], guid, $anim, $mask);
|
|
3884
3940
|
},
|
|
3885
3941
|
show() {
|
|
3886
|
-
return PopsInstanceUtils.show(config,
|
|
3942
|
+
return PopsInstanceUtils.show(config, type, PopsInstData[type], guid, $anim, $mask);
|
|
3887
3943
|
},
|
|
3888
3944
|
};
|
|
3889
3945
|
},
|
|
@@ -3996,8 +4052,8 @@ const PopsHandler = {
|
|
|
3996
4052
|
handleOnly(type, config) {
|
|
3997
4053
|
if (config.only) {
|
|
3998
4054
|
// .loading
|
|
3999
|
-
// .tooltip
|
|
4000
4055
|
// .rightClickMenu
|
|
4056
|
+
// .tooltip
|
|
4001
4057
|
// 单独处理
|
|
4002
4058
|
if (type === "loading" || type === "tooltip" || type === "rightClickMenu") {
|
|
4003
4059
|
const inst = PopsInstData[type];
|
|
@@ -4009,11 +4065,11 @@ const PopsHandler = {
|
|
|
4009
4065
|
PopsInstanceUtils.removeInstance([
|
|
4010
4066
|
PopsInstData.alert,
|
|
4011
4067
|
PopsInstData.confirm,
|
|
4012
|
-
PopsInstData.prompt,
|
|
4013
|
-
PopsInstData.iframe,
|
|
4014
4068
|
PopsInstData.drawer,
|
|
4015
4069
|
PopsInstData.folder,
|
|
4070
|
+
PopsInstData.iframe,
|
|
4016
4071
|
PopsInstData.panel,
|
|
4072
|
+
PopsInstData.prompt,
|
|
4017
4073
|
], "", true);
|
|
4018
4074
|
}
|
|
4019
4075
|
}
|
|
@@ -4177,6 +4233,7 @@ const PopsAlert = {
|
|
|
4177
4233
|
}
|
|
4178
4234
|
// 处理返回的配置
|
|
4179
4235
|
const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, $mask);
|
|
4236
|
+
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
4180
4237
|
// 为顶部右边的关闭按钮添加点击事件
|
|
4181
4238
|
PopsHandler.handleClickEvent("close", $headerCloseBtn, evtConfig, config.btn.close?.callback);
|
|
4182
4239
|
// 为底部ok按钮添加点击事件
|
|
@@ -4199,6 +4256,8 @@ const PopsAlert = {
|
|
|
4199
4256
|
$mask: $mask,
|
|
4200
4257
|
$shadowContainer: $shadowContainer,
|
|
4201
4258
|
$shadowRoot: $shadowRoot,
|
|
4259
|
+
config: config,
|
|
4260
|
+
destory: result.close,
|
|
4202
4261
|
});
|
|
4203
4262
|
// 拖拽
|
|
4204
4263
|
if (config.drag) {
|
|
@@ -4210,7 +4269,6 @@ const PopsAlert = {
|
|
|
4210
4269
|
endCallBack: config.dragEndCallBack,
|
|
4211
4270
|
});
|
|
4212
4271
|
}
|
|
4213
|
-
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
4214
4272
|
return result;
|
|
4215
4273
|
},
|
|
4216
4274
|
};
|
|
@@ -4384,6 +4442,7 @@ const PopsConfirm = {
|
|
|
4384
4442
|
$elList.push($mask);
|
|
4385
4443
|
}
|
|
4386
4444
|
const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, $mask);
|
|
4445
|
+
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
4387
4446
|
PopsHandler.handleClickEvent("close", $btnClose, evtConfig, config.btn.close.callback);
|
|
4388
4447
|
PopsHandler.handleClickEvent("ok", $btnOk, evtConfig, config.btn.ok.callback);
|
|
4389
4448
|
PopsHandler.handleClickEvent("cancel", $btnCancel, evtConfig, config.btn.cancel.callback);
|
|
@@ -4404,6 +4463,8 @@ const PopsConfirm = {
|
|
|
4404
4463
|
$mask: $mask,
|
|
4405
4464
|
$shadowContainer: $shadowContainer,
|
|
4406
4465
|
$shadowRoot: $shadowRoot,
|
|
4466
|
+
config: config,
|
|
4467
|
+
destory: result.close,
|
|
4407
4468
|
});
|
|
4408
4469
|
// 拖拽
|
|
4409
4470
|
if (config.drag) {
|
|
@@ -4415,7 +4476,6 @@ const PopsConfirm = {
|
|
|
4415
4476
|
endCallBack: config.dragEndCallBack,
|
|
4416
4477
|
});
|
|
4417
4478
|
}
|
|
4418
|
-
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
4419
4479
|
return result;
|
|
4420
4480
|
},
|
|
4421
4481
|
};
|
|
@@ -4594,6 +4654,7 @@ const PopsDrawer = {
|
|
|
4594
4654
|
$elList.push($mask);
|
|
4595
4655
|
}
|
|
4596
4656
|
const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, $mask);
|
|
4657
|
+
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
4597
4658
|
// 处理方向
|
|
4598
4659
|
$pops.setAttribute("direction", config.direction);
|
|
4599
4660
|
// 处理border-radius
|
|
@@ -4689,8 +4750,9 @@ const PopsDrawer = {
|
|
|
4689
4750
|
$mask: $mask,
|
|
4690
4751
|
$shadowContainer: $shadowContainer,
|
|
4691
4752
|
$shadowRoot: $shadowRoot,
|
|
4753
|
+
config: config,
|
|
4754
|
+
destory: result.close,
|
|
4692
4755
|
});
|
|
4693
|
-
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
4694
4756
|
return result;
|
|
4695
4757
|
},
|
|
4696
4758
|
};
|
|
@@ -5199,6 +5261,7 @@ const PopsFolder = {
|
|
|
5199
5261
|
}
|
|
5200
5262
|
// 事件
|
|
5201
5263
|
const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, $mask);
|
|
5264
|
+
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
5202
5265
|
PopsHandler.handleClickEvent("close", $btnCloseBtn, evtConfig, config.btn.close.callback);
|
|
5203
5266
|
PopsHandler.handleClickEvent("ok", btnOkElement, evtConfig, config.btn.ok.callback);
|
|
5204
5267
|
PopsHandler.handleClickEvent("cancel", btnCancelElement, evtConfig, config.btn.cancel.callback);
|
|
@@ -5778,8 +5841,9 @@ const PopsFolder = {
|
|
|
5778
5841
|
$mask: $mask,
|
|
5779
5842
|
$shadowContainer: $shadowContainer,
|
|
5780
5843
|
$shadowRoot: $shadowRoot,
|
|
5844
|
+
config: config,
|
|
5845
|
+
destory: result.close,
|
|
5781
5846
|
});
|
|
5782
|
-
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
5783
5847
|
return result;
|
|
5784
5848
|
},
|
|
5785
5849
|
};
|
|
@@ -5935,6 +5999,7 @@ const PopsIframe = {
|
|
|
5935
5999
|
const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, $mask);
|
|
5936
6000
|
// 赋值额外的$iframe参数
|
|
5937
6001
|
evtConfig.$iframe = $iframe;
|
|
6002
|
+
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
5938
6003
|
popsDOMUtils.on($anim, popsDOMUtils.getAnimationEndNameList(), function () {
|
|
5939
6004
|
// 动画加载完毕
|
|
5940
6005
|
$anim.style.width = "0%";
|
|
@@ -6066,10 +6131,10 @@ const PopsIframe = {
|
|
|
6066
6131
|
capture: true,
|
|
6067
6132
|
});
|
|
6068
6133
|
// 关闭按钮点击事件
|
|
6069
|
-
popsDOMUtils.on(headerCloseBtnElement, "click", (event) => {
|
|
6134
|
+
popsDOMUtils.on(headerCloseBtnElement, "click", async (event) => {
|
|
6070
6135
|
event.preventDefault();
|
|
6071
6136
|
event.stopPropagation();
|
|
6072
|
-
PopsInstanceUtils.removeInstance([PopsInstData.iframe], guid, false);
|
|
6137
|
+
await PopsInstanceUtils.removeInstance([PopsInstData.iframe], guid, false);
|
|
6073
6138
|
if (typeof config?.btn?.close?.callback === "function") {
|
|
6074
6139
|
config.btn.close.callback(evtConfig, event);
|
|
6075
6140
|
}
|
|
@@ -6083,8 +6148,9 @@ const PopsIframe = {
|
|
|
6083
6148
|
$mask: $mask,
|
|
6084
6149
|
$shadowContainer: $shadowContainer,
|
|
6085
6150
|
$shadowRoot: $shadowRoot,
|
|
6151
|
+
config: config,
|
|
6152
|
+
destory: result.close,
|
|
6086
6153
|
});
|
|
6087
|
-
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
6088
6154
|
return result;
|
|
6089
6155
|
},
|
|
6090
6156
|
};
|
|
@@ -7050,7 +7116,7 @@ const PopsTooltipDefaultConfig = () => {
|
|
|
7050
7116
|
isFixed: false,
|
|
7051
7117
|
alwaysShow: false,
|
|
7052
7118
|
onShowEventName: "mouseenter touchstart",
|
|
7053
|
-
onCloseEventName: "mouseleave touchend",
|
|
7119
|
+
onCloseEventName: "mouseleave touchend touchcancel",
|
|
7054
7120
|
zIndex: 10000,
|
|
7055
7121
|
only: false,
|
|
7056
7122
|
eventOption: {
|
|
@@ -7276,12 +7342,12 @@ class ToolTip {
|
|
|
7276
7342
|
changePosition(event) {
|
|
7277
7343
|
const positionInfo = this.calcToolTipPosition(this.$data.config.$target, this.$data.config.arrowDistance, this.$data.config.otherDistance, event);
|
|
7278
7344
|
const positionKey = this.$data.config.position.toUpperCase();
|
|
7279
|
-
const
|
|
7280
|
-
if (
|
|
7281
|
-
this.$el.$toolTip.style.left =
|
|
7282
|
-
this.$el.$toolTip.style.top =
|
|
7283
|
-
this.$el.$toolTip.setAttribute("data-motion",
|
|
7284
|
-
this.$el.$arrow.setAttribute("data-position",
|
|
7345
|
+
const position = positionInfo[positionKey];
|
|
7346
|
+
if (position) {
|
|
7347
|
+
this.$el.$toolTip.style.left = position.left + "px";
|
|
7348
|
+
this.$el.$toolTip.style.top = position.top + "px";
|
|
7349
|
+
this.$el.$toolTip.setAttribute("data-motion", position.motion);
|
|
7350
|
+
this.$el.$arrow.setAttribute("data-position", position.arrow);
|
|
7285
7351
|
}
|
|
7286
7352
|
else {
|
|
7287
7353
|
console.error("不存在该位置", this.$data.config.position);
|
|
@@ -7387,9 +7453,7 @@ class ToolTip {
|
|
|
7387
7453
|
* 取消绑定 显示事件
|
|
7388
7454
|
*/
|
|
7389
7455
|
offShowEvent() {
|
|
7390
|
-
popsDOMUtils.off(this.$data.config.$target, this.$data.config.onShowEventName, this.show,
|
|
7391
|
-
capture: true,
|
|
7392
|
-
});
|
|
7456
|
+
popsDOMUtils.off(this.$data.config.$target, this.$data.config.onShowEventName, this.show, this.$data.config.eventOption);
|
|
7393
7457
|
}
|
|
7394
7458
|
/**
|
|
7395
7459
|
* 关闭提示框
|
|
@@ -7448,22 +7512,20 @@ class ToolTip {
|
|
|
7448
7512
|
* 取消绑定 关闭事件
|
|
7449
7513
|
*/
|
|
7450
7514
|
offCloseEvent() {
|
|
7451
|
-
popsDOMUtils.off(this.$data.config.$target, this.$data.config.onCloseEventName, this.close,
|
|
7452
|
-
capture: true,
|
|
7453
|
-
});
|
|
7515
|
+
popsDOMUtils.off(this.$data.config.$target, this.$data.config.onCloseEventName, this.close, this.$data.config.eventOption);
|
|
7454
7516
|
}
|
|
7455
7517
|
/**
|
|
7456
7518
|
* 销毁元素
|
|
7457
7519
|
*/
|
|
7458
7520
|
destory() {
|
|
7459
7521
|
if (this.$el.$toolTip) {
|
|
7460
|
-
this.$el.$
|
|
7522
|
+
this.$el.$toolTip.remove();
|
|
7461
7523
|
}
|
|
7462
|
-
// @ts-
|
|
7524
|
+
// @ts-expect-error
|
|
7463
7525
|
this.$el.$toolTip = null;
|
|
7464
|
-
// @ts-
|
|
7526
|
+
// @ts-expect-error
|
|
7465
7527
|
this.$el.$arrow = null;
|
|
7466
|
-
// @ts-
|
|
7528
|
+
// @ts-expect-error
|
|
7467
7529
|
this.$el.$content = null;
|
|
7468
7530
|
}
|
|
7469
7531
|
/**
|
|
@@ -7511,29 +7573,29 @@ class ToolTip {
|
|
|
7511
7573
|
popsDOMUtils.on(this.$el.$toolTip, "mouseenter touchstart", this.toolTipMouseEnterEvent, this.$data.config.eventOption);
|
|
7512
7574
|
}
|
|
7513
7575
|
/**
|
|
7514
|
-
*
|
|
7576
|
+
* 取消监听事件 - 鼠标|触摸
|
|
7515
7577
|
*/
|
|
7516
7578
|
offToolTipMouseEnterEvent() {
|
|
7517
7579
|
popsDOMUtils.off(this.$el.$toolTip, "mouseenter touchstart", this.toolTipMouseEnterEvent, this.$data.config.eventOption);
|
|
7518
7580
|
}
|
|
7519
7581
|
/**
|
|
7520
|
-
*
|
|
7582
|
+
* 离开事件 - 鼠标|触摸
|
|
7521
7583
|
*/
|
|
7522
7584
|
toolTipMouseLeaveEvent(event) {
|
|
7523
7585
|
this.close(event);
|
|
7524
7586
|
// this.$el.$toolTip.style.animationPlayState = "running";
|
|
7525
7587
|
}
|
|
7526
7588
|
/**
|
|
7527
|
-
*
|
|
7589
|
+
* 监听离开事件 - 鼠标|触摸
|
|
7528
7590
|
*/
|
|
7529
7591
|
onToolTipMouseLeaveEvent() {
|
|
7530
|
-
popsDOMUtils.on(this.$el.$toolTip, "mouseleave touchend", this.toolTipMouseLeaveEvent, this.$data.config.eventOption);
|
|
7592
|
+
popsDOMUtils.on(this.$el.$toolTip, "mouseleave touchend touchcancel", this.toolTipMouseLeaveEvent, this.$data.config.eventOption);
|
|
7531
7593
|
}
|
|
7532
7594
|
/**
|
|
7533
|
-
*
|
|
7595
|
+
* 取消监听离开事件 - 鼠标|触摸
|
|
7534
7596
|
*/
|
|
7535
7597
|
offToolTipMouseLeaveEvent() {
|
|
7536
|
-
popsDOMUtils.off(this.$el.$toolTip, "mouseleave touchend", this.toolTipMouseLeaveEvent, this.$data.config.eventOption);
|
|
7598
|
+
popsDOMUtils.off(this.$el.$toolTip, "mouseleave touchend touchcancel", this.toolTipMouseLeaveEvent, this.$data.config.eventOption);
|
|
7537
7599
|
}
|
|
7538
7600
|
}
|
|
7539
7601
|
const PopsTooltip = {
|
|
@@ -7548,6 +7610,15 @@ const PopsTooltip = {
|
|
|
7548
7610
|
throw new TypeError("config.target 必须是HTMLElement类型");
|
|
7549
7611
|
}
|
|
7550
7612
|
config = PopsHandler.handleOnly(popsType, config);
|
|
7613
|
+
if (config.position === "follow") {
|
|
7614
|
+
config.onShowEventName = config.onShowEventName.trim();
|
|
7615
|
+
const showEventNameSplit = config.onShowEventName.split(" ");
|
|
7616
|
+
["mousemove", "touchmove"].forEach((it) => {
|
|
7617
|
+
if (showEventNameSplit.includes(it))
|
|
7618
|
+
return;
|
|
7619
|
+
config.onShowEventName += ` ${it}`;
|
|
7620
|
+
});
|
|
7621
|
+
}
|
|
7551
7622
|
const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
|
|
7552
7623
|
PopsHandler.handleInit($shadowRoot, [
|
|
7553
7624
|
{
|
|
@@ -8812,7 +8883,7 @@ const PanelHandlerComponents = () => {
|
|
|
8812
8883
|
* 监听输入框内容改变
|
|
8813
8884
|
*/
|
|
8814
8885
|
onValueChange() {
|
|
8815
|
-
popsDOMUtils.on(this.$el.input, ["input", "propertychange"],
|
|
8886
|
+
popsDOMUtils.on(this.$el.input, ["input", "propertychange"], (event) => {
|
|
8816
8887
|
this.$data.value = this.$el.input.value;
|
|
8817
8888
|
if (inputType !== "password") {
|
|
8818
8889
|
// 不是密码框
|
|
@@ -9185,7 +9256,7 @@ const PanelHandlerComponents = () => {
|
|
|
9185
9256
|
* 监听点击事件
|
|
9186
9257
|
*/
|
|
9187
9258
|
onClick() {
|
|
9188
|
-
popsDOMUtils.on(this.$el.$select, "click",
|
|
9259
|
+
popsDOMUtils.on(this.$el.$select, "click", (event) => {
|
|
9189
9260
|
this.setSelectOptionsDisableStatus();
|
|
9190
9261
|
if (typeof viewConfig.clickCallBack === "function") {
|
|
9191
9262
|
const $isSelectedElement = this.$el.$select[this.$el.$select.selectedIndex];
|
|
@@ -10952,7 +11023,7 @@ const PanelHandlerComponents = () => {
|
|
|
10952
11023
|
* 设置按钮的点击事件
|
|
10953
11024
|
*/
|
|
10954
11025
|
onButtonClick() {
|
|
10955
|
-
popsDOMUtils.on(this.$ele.button, "click",
|
|
11026
|
+
popsDOMUtils.on(this.$ele.button, "click", (event) => {
|
|
10956
11027
|
if (typeof viewConfig.callback === "function") {
|
|
10957
11028
|
viewConfig.callback(event);
|
|
10958
11029
|
}
|
|
@@ -11021,13 +11092,13 @@ const PanelHandlerComponents = () => {
|
|
|
11021
11092
|
initContainerItem($container, formItemConfig) {
|
|
11022
11093
|
const containerViewConfig = formItemConfig;
|
|
11023
11094
|
if (containerViewConfig.type === "container") {
|
|
11024
|
-
const
|
|
11095
|
+
const childViewConfig = containerViewConfig["views"];
|
|
11025
11096
|
// 每一项<li>元素
|
|
11026
|
-
const
|
|
11097
|
+
const $itemLi = popsDOMUtils.createElement("li");
|
|
11027
11098
|
// 每一项<li>内的子<ul>元素
|
|
11028
|
-
const
|
|
11029
|
-
|
|
11030
|
-
|
|
11099
|
+
const $itemUL = popsDOMUtils.createElement("ul");
|
|
11100
|
+
$itemUL.classList.add("pops-panel-forms-container-item-formlist");
|
|
11101
|
+
$itemLi.classList.add("pops-panel-forms-container-item");
|
|
11031
11102
|
// 区域头部的文字
|
|
11032
11103
|
const formHeaderDivElement = popsDOMUtils.createElement("div", {
|
|
11033
11104
|
className: "pops-panel-forms-container-item-header-text",
|
|
@@ -11047,42 +11118,42 @@ const PanelHandlerComponents = () => {
|
|
|
11047
11118
|
`);
|
|
11048
11119
|
// 添加点击事件
|
|
11049
11120
|
popsDOMUtils.on(formHeaderDivElement, "click", () => {
|
|
11050
|
-
if (
|
|
11051
|
-
|
|
11121
|
+
if ($itemLi.hasAttribute("data-fold-enable")) {
|
|
11122
|
+
$itemLi.removeAttribute("data-fold-enable");
|
|
11052
11123
|
}
|
|
11053
11124
|
else {
|
|
11054
|
-
|
|
11125
|
+
$itemLi.setAttribute("data-fold-enable", "");
|
|
11055
11126
|
}
|
|
11056
11127
|
});
|
|
11057
11128
|
popsDOMUtils.addClassName(formHeaderDivElement, "pops-panel-forms-fold-container");
|
|
11058
11129
|
popsDOMUtils.addClassName(formHeaderDivElement, PopsCommonCSSClassName.userSelectNone);
|
|
11059
|
-
|
|
11130
|
+
$itemLi.setAttribute("data-fold-enable", "");
|
|
11060
11131
|
popsDOMUtils.addClassName(formHeaderDivElement, "pops-panel-forms-fold");
|
|
11061
|
-
|
|
11132
|
+
$itemLi.appendChild(formHeaderDivElement);
|
|
11062
11133
|
}
|
|
11063
11134
|
else {
|
|
11064
11135
|
// 加进容器内
|
|
11065
|
-
|
|
11136
|
+
$itemLi.appendChild(formHeaderDivElement);
|
|
11066
11137
|
}
|
|
11067
|
-
that.setElementClassName(
|
|
11068
|
-
that.setElementAttributes(
|
|
11069
|
-
that.setElementProps(
|
|
11070
|
-
|
|
11138
|
+
that.setElementClassName($itemLi, formItemConfig.className);
|
|
11139
|
+
that.setElementAttributes($itemLi, formItemConfig.attributes);
|
|
11140
|
+
that.setElementProps($itemLi, formItemConfig.props);
|
|
11141
|
+
$itemLi.appendChild($itemUL);
|
|
11142
|
+
$container.appendChild($itemLi);
|
|
11143
|
+
childViewConfig.forEach((childViewConfig) => {
|
|
11071
11144
|
that.uListContainerAddItem(childViewConfig, {
|
|
11072
|
-
ulElement:
|
|
11145
|
+
ulElement: $itemUL,
|
|
11073
11146
|
sectionContainerULElement: that.sectionContainerULElement,
|
|
11074
|
-
formContainerListElement:
|
|
11147
|
+
formContainerListElement: $itemLi,
|
|
11075
11148
|
formHeaderDivElement: formHeaderDivElement,
|
|
11076
11149
|
});
|
|
11077
11150
|
});
|
|
11078
|
-
formContainerListElement.appendChild(formContainerULElement);
|
|
11079
|
-
$container.appendChild(formContainerListElement);
|
|
11080
11151
|
if (typeof containerViewConfig.afterAddToUListCallBack === "function") {
|
|
11081
11152
|
containerViewConfig.afterAddToUListCallBack(viewConfig, {
|
|
11082
|
-
target:
|
|
11083
|
-
ulElement:
|
|
11153
|
+
target: $itemLi,
|
|
11154
|
+
ulElement: $itemUL,
|
|
11084
11155
|
sectionContainerULElement: that.sectionContainerULElement,
|
|
11085
|
-
formContainerListElement:
|
|
11156
|
+
formContainerListElement: $itemLi,
|
|
11086
11157
|
formHeaderDivElement: formHeaderDivElement,
|
|
11087
11158
|
});
|
|
11088
11159
|
}
|
|
@@ -11221,7 +11292,7 @@ const PanelHandlerComponents = () => {
|
|
|
11221
11292
|
},
|
|
11222
11293
|
/** 设置项的点击事件 */
|
|
11223
11294
|
onLiClick() {
|
|
11224
|
-
popsDOMUtils.on($li, "click",
|
|
11295
|
+
popsDOMUtils.on($li, "click", async (event) => {
|
|
11225
11296
|
if (typeof viewConfig.clickCallBack === "function") {
|
|
11226
11297
|
const result = await viewConfig.clickCallBack(event, viewConfig);
|
|
11227
11298
|
if (result) {
|
|
@@ -11549,6 +11620,7 @@ const PopsPanel = {
|
|
|
11549
11620
|
}
|
|
11550
11621
|
// 处理返回的配置
|
|
11551
11622
|
const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, $mask);
|
|
11623
|
+
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
11552
11624
|
// 为顶部右边的关闭按钮添加点击事件
|
|
11553
11625
|
PopsHandler.handleClickEvent("close", $headerBtnClose, evtConfig, config.btn?.close?.callback);
|
|
11554
11626
|
// 创建到页面中
|
|
@@ -11586,6 +11658,8 @@ const PopsPanel = {
|
|
|
11586
11658
|
$mask: $mask,
|
|
11587
11659
|
$shadowContainer: $shadowContainer,
|
|
11588
11660
|
$shadowRoot: $shadowRoot,
|
|
11661
|
+
config: config,
|
|
11662
|
+
destory: result.close,
|
|
11589
11663
|
});
|
|
11590
11664
|
// 拖拽
|
|
11591
11665
|
if (config.drag) {
|
|
@@ -11597,7 +11671,6 @@ const PopsPanel = {
|
|
|
11597
11671
|
endCallBack: config.dragEndCallBack,
|
|
11598
11672
|
});
|
|
11599
11673
|
}
|
|
11600
|
-
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
11601
11674
|
return {
|
|
11602
11675
|
...result,
|
|
11603
11676
|
addEventListener: (event, listener, options) => {
|
|
@@ -11789,6 +11862,7 @@ const PopsPrompt = {
|
|
|
11789
11862
|
$elList.push($mask);
|
|
11790
11863
|
}
|
|
11791
11864
|
const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, $mask);
|
|
11865
|
+
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
11792
11866
|
// 输入框赋值初始值
|
|
11793
11867
|
$input.value = config.content.text;
|
|
11794
11868
|
PopsHandler.handlePromptClickEvent("close", $input, $btnClose, evtConfig, config.btn.close.callback);
|
|
@@ -11811,6 +11885,8 @@ const PopsPrompt = {
|
|
|
11811
11885
|
$mask: $mask,
|
|
11812
11886
|
$shadowContainer: $shadowContainer,
|
|
11813
11887
|
$shadowRoot: $shadowRoot,
|
|
11888
|
+
config: config,
|
|
11889
|
+
destory: result.close,
|
|
11814
11890
|
});
|
|
11815
11891
|
// 拖拽
|
|
11816
11892
|
if (config.drag) {
|
|
@@ -11830,7 +11906,6 @@ const PopsPrompt = {
|
|
|
11830
11906
|
if (config.content.select) {
|
|
11831
11907
|
$input.select();
|
|
11832
11908
|
}
|
|
11833
|
-
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
11834
11909
|
return result;
|
|
11835
11910
|
},
|
|
11836
11911
|
};
|
|
@@ -11932,6 +12007,7 @@ const PopsRightClickMenuDefaultConfig = () => {
|
|
|
11932
12007
|
beforeAppendToPageCallBack() { },
|
|
11933
12008
|
limitPositionXInView: true,
|
|
11934
12009
|
limitPositionYInView: true,
|
|
12010
|
+
beforeShowCallBack() { },
|
|
11935
12011
|
};
|
|
11936
12012
|
};
|
|
11937
12013
|
|
|
@@ -11991,6 +12067,8 @@ const PopsRightClickMenu = {
|
|
|
11991
12067
|
return;
|
|
11992
12068
|
}
|
|
11993
12069
|
if ($click.className && $click.className === "pops-shadow-container" && $click.shadowRoot != null) {
|
|
12070
|
+
// pops的shadow-container
|
|
12071
|
+
PopsContextMenu.shadowRootCheckClickEvent(event);
|
|
11994
12072
|
return;
|
|
11995
12073
|
}
|
|
11996
12074
|
PopsContextMenu.closeAllMenu(PopsContextMenu.$el.$root);
|
|
@@ -12003,7 +12081,7 @@ const PopsRightClickMenu = {
|
|
|
12003
12081
|
if (!PopsContextMenu.$el.$root) {
|
|
12004
12082
|
return;
|
|
12005
12083
|
}
|
|
12006
|
-
const $click = event.
|
|
12084
|
+
const $click = event.composedPath()[0];
|
|
12007
12085
|
if ($click.closest(`.pops-${popsType}`)) {
|
|
12008
12086
|
return;
|
|
12009
12087
|
}
|
|
@@ -12013,13 +12091,13 @@ const PopsRightClickMenu = {
|
|
|
12013
12091
|
* 添加全局点击检测事件
|
|
12014
12092
|
*/
|
|
12015
12093
|
addWindowCheckClickListener() {
|
|
12016
|
-
popsDOMUtils.on(globalThis, "click touchstart",
|
|
12094
|
+
popsDOMUtils.on(globalThis, "click touchstart", PopsContextMenu.windowCheckClickEvent, {
|
|
12017
12095
|
capture: true,
|
|
12018
12096
|
});
|
|
12019
12097
|
if (config.$target instanceof Node) {
|
|
12020
12098
|
const $shadowRoot = config.$target.getRootNode();
|
|
12021
12099
|
if ($shadowRoot instanceof ShadowRoot) {
|
|
12022
|
-
popsDOMUtils.on($shadowRoot, "click touchstart",
|
|
12100
|
+
popsDOMUtils.on($shadowRoot, "click touchstart", PopsContextMenu.shadowRootCheckClickEvent, {
|
|
12023
12101
|
capture: true,
|
|
12024
12102
|
});
|
|
12025
12103
|
}
|
|
@@ -12029,13 +12107,13 @@ const PopsRightClickMenu = {
|
|
|
12029
12107
|
* 移除全局点击检测事件
|
|
12030
12108
|
*/
|
|
12031
12109
|
removeWindowCheckClickListener() {
|
|
12032
|
-
popsDOMUtils.off(globalThis, "click touchstart",
|
|
12110
|
+
popsDOMUtils.off(globalThis, "click touchstart", PopsContextMenu.windowCheckClickEvent, {
|
|
12033
12111
|
capture: true,
|
|
12034
12112
|
});
|
|
12035
12113
|
if (config.$target instanceof Node) {
|
|
12036
12114
|
const $shadowRoot = config.$target.getRootNode();
|
|
12037
12115
|
if ($shadowRoot instanceof ShadowRoot) {
|
|
12038
|
-
popsDOMUtils.off($shadowRoot, "click touchstart",
|
|
12116
|
+
popsDOMUtils.off($shadowRoot, "click touchstart", PopsContextMenu.windowCheckClickEvent, {
|
|
12039
12117
|
capture: true,
|
|
12040
12118
|
});
|
|
12041
12119
|
}
|
|
@@ -12046,7 +12124,7 @@ const PopsRightClickMenu = {
|
|
|
12046
12124
|
* @param event
|
|
12047
12125
|
* @param selectorTarget
|
|
12048
12126
|
*/
|
|
12049
|
-
contextMenuEvent(event, selectorTarget) {
|
|
12127
|
+
async contextMenuEvent(event, selectorTarget) {
|
|
12050
12128
|
if (config.preventDefault) {
|
|
12051
12129
|
popsDOMUtils.preventEvent(event);
|
|
12052
12130
|
}
|
|
@@ -12055,6 +12133,10 @@ const PopsRightClickMenu = {
|
|
|
12055
12133
|
PopsContextMenu.closeAllMenu(PopsContextMenu.$el.$root);
|
|
12056
12134
|
}
|
|
12057
12135
|
selectorTarget = selectorTarget ?? config.$target;
|
|
12136
|
+
const beforeShowCallBackResult = await config?.beforeShowCallBack(event);
|
|
12137
|
+
if (typeof beforeShowCallBackResult === "boolean" && !beforeShowCallBackResult) {
|
|
12138
|
+
return;
|
|
12139
|
+
}
|
|
12058
12140
|
const rootElement = PopsContextMenu.showMenu(event, config.data, selectorTarget);
|
|
12059
12141
|
PopsContextMenu.$el.$root = rootElement;
|
|
12060
12142
|
if (config.only) {
|
|
@@ -12067,6 +12149,10 @@ const PopsRightClickMenu = {
|
|
|
12067
12149
|
beforeRemoveCallBack(instCommonConfig) {
|
|
12068
12150
|
PopsContextMenu.closeAllMenu(instCommonConfig.$pops);
|
|
12069
12151
|
},
|
|
12152
|
+
config: config,
|
|
12153
|
+
destory: () => {
|
|
12154
|
+
PopsContextMenu.closeAllMenu(rootElement);
|
|
12155
|
+
},
|
|
12070
12156
|
});
|
|
12071
12157
|
}
|
|
12072
12158
|
},
|
|
@@ -12370,7 +12456,8 @@ const PopsRightClickMenu = {
|
|
|
12370
12456
|
menuLiElement.appendChild(iconElement);
|
|
12371
12457
|
}
|
|
12372
12458
|
// 插入文字
|
|
12373
|
-
|
|
12459
|
+
const text = typeof item.text === "function" ? item.text() : item.text;
|
|
12460
|
+
menuLiElement.insertAdjacentHTML("beforeend", PopsSafeUtils.getSafeHTML(`<span>${text}</span>`));
|
|
12374
12461
|
// 如果存在子数据,显示
|
|
12375
12462
|
if (item.item && Array.isArray(item.item)) {
|
|
12376
12463
|
popsDOMUtils.addClassName(menuLiElement, `pops-${popsType}-item`);
|
|
@@ -13009,10 +13096,10 @@ const PopsSearchSuggestion = {
|
|
|
13009
13096
|
setShowEvent(option = defaultListenerOption) {
|
|
13010
13097
|
/* 焦点|点击事件*/
|
|
13011
13098
|
if (config.followPosition === "target") {
|
|
13012
|
-
popsDOMUtils.on([config.$target], ["focus", "click"],
|
|
13099
|
+
popsDOMUtils.on([config.$target], ["focus", "click"], SearchSuggestion.showEvent, option);
|
|
13013
13100
|
}
|
|
13014
13101
|
else if (config.followPosition === "input") {
|
|
13015
|
-
popsDOMUtils.on([config.$inputTarget], ["focus", "click"],
|
|
13102
|
+
popsDOMUtils.on([config.$inputTarget], ["focus", "click"], SearchSuggestion.showEvent, option);
|
|
13016
13103
|
}
|
|
13017
13104
|
else if (config.followPosition === "inputCursor") {
|
|
13018
13105
|
popsDOMUtils.on([config.$inputTarget], ["focus", "click", "input"], SearchSuggestion.showEvent, option);
|
|
@@ -13026,9 +13113,9 @@ const PopsSearchSuggestion = {
|
|
|
13026
13113
|
*/
|
|
13027
13114
|
removeShowEvent(option = defaultListenerOption) {
|
|
13028
13115
|
/* 焦点|点击事件*/
|
|
13029
|
-
popsDOMUtils.off([config.$target, config.$inputTarget], ["focus", "click"],
|
|
13116
|
+
popsDOMUtils.off([config.$target, config.$inputTarget], ["focus", "click"], SearchSuggestion.showEvent, option);
|
|
13030
13117
|
// 内容改变事件
|
|
13031
|
-
popsDOMUtils.off([config.$inputTarget], ["input"],
|
|
13118
|
+
popsDOMUtils.off([config.$inputTarget], ["input"], SearchSuggestion.showEvent, option);
|
|
13032
13119
|
},
|
|
13033
13120
|
/**
|
|
13034
13121
|
* 隐藏搜索建议框的事件
|
|
@@ -13059,7 +13146,7 @@ const PopsSearchSuggestion = {
|
|
|
13059
13146
|
// 全局触摸屏点击事件
|
|
13060
13147
|
if (Array.isArray(SearchSuggestion.selfDocument)) {
|
|
13061
13148
|
SearchSuggestion.selfDocument.forEach(($checkParent) => {
|
|
13062
|
-
popsDOMUtils.on($checkParent, ["click", "touchstart"],
|
|
13149
|
+
popsDOMUtils.on($checkParent, ["click", "touchstart"], SearchSuggestion.hideEvent, option);
|
|
13063
13150
|
});
|
|
13064
13151
|
}
|
|
13065
13152
|
else {
|
|
@@ -13072,11 +13159,11 @@ const PopsSearchSuggestion = {
|
|
|
13072
13159
|
removeHideEvent(option = defaultListenerOption) {
|
|
13073
13160
|
if (Array.isArray(SearchSuggestion.selfDocument)) {
|
|
13074
13161
|
SearchSuggestion.selfDocument.forEach(($checkParent) => {
|
|
13075
|
-
popsDOMUtils.off($checkParent, ["click", "touchstart"],
|
|
13162
|
+
popsDOMUtils.off($checkParent, ["click", "touchstart"], SearchSuggestion.hideEvent, option);
|
|
13076
13163
|
});
|
|
13077
13164
|
}
|
|
13078
13165
|
else {
|
|
13079
|
-
popsDOMUtils.off(SearchSuggestion.selfDocument, ["click", "touchstart"],
|
|
13166
|
+
popsDOMUtils.off(SearchSuggestion.selfDocument, ["click", "touchstart"], SearchSuggestion.hideEvent, option);
|
|
13080
13167
|
}
|
|
13081
13168
|
},
|
|
13082
13169
|
/**
|
|
@@ -13337,7 +13424,7 @@ const PopsSearchSuggestion = {
|
|
|
13337
13424
|
},
|
|
13338
13425
|
};
|
|
13339
13426
|
|
|
13340
|
-
const version = "3.
|
|
13427
|
+
const version = "3.2.0";
|
|
13341
13428
|
|
|
13342
13429
|
class Pops {
|
|
13343
13430
|
/** 配置 */
|