@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.umd.js
CHANGED
|
@@ -265,47 +265,7 @@
|
|
|
265
265
|
const cache = createCache(LAST_NUMBER_WEAK_MAP);
|
|
266
266
|
const generateUniqueNumber = createGenerateUniqueNumber(cache, LAST_NUMBER_WEAK_MAP);
|
|
267
267
|
|
|
268
|
-
const
|
|
269
|
-
return typeof sender.start === 'function';
|
|
270
|
-
};
|
|
271
|
-
|
|
272
|
-
const PORT_MAP = new WeakMap();
|
|
273
|
-
|
|
274
|
-
const extendBrokerImplementation = (partialBrokerImplementation) => ({
|
|
275
|
-
...partialBrokerImplementation,
|
|
276
|
-
connect: ({ call }) => {
|
|
277
|
-
return async () => {
|
|
278
|
-
const { port1, port2 } = new MessageChannel();
|
|
279
|
-
const portId = await call('connect', { port: port1 }, [port1]);
|
|
280
|
-
PORT_MAP.set(port2, portId);
|
|
281
|
-
return port2;
|
|
282
|
-
};
|
|
283
|
-
},
|
|
284
|
-
disconnect: ({ call }) => {
|
|
285
|
-
return async (port) => {
|
|
286
|
-
const portId = PORT_MAP.get(port);
|
|
287
|
-
if (portId === undefined) {
|
|
288
|
-
throw new Error('The given port is not connected.');
|
|
289
|
-
}
|
|
290
|
-
await call('disconnect', { portId });
|
|
291
|
-
};
|
|
292
|
-
},
|
|
293
|
-
isSupported: ({ call }) => {
|
|
294
|
-
return () => call('isSupported');
|
|
295
|
-
}
|
|
296
|
-
});
|
|
297
|
-
|
|
298
|
-
const ONGOING_REQUESTS = new WeakMap();
|
|
299
|
-
const createOrGetOngoingRequests = (sender) => {
|
|
300
|
-
if (ONGOING_REQUESTS.has(sender)) {
|
|
301
|
-
// @todo TypeScript needs to be convinced that has() works as expected.
|
|
302
|
-
return ONGOING_REQUESTS.get(sender);
|
|
303
|
-
}
|
|
304
|
-
const ongoingRequests = new Map();
|
|
305
|
-
ONGOING_REQUESTS.set(sender, ongoingRequests);
|
|
306
|
-
return ongoingRequests;
|
|
307
|
-
};
|
|
308
|
-
const createBroker = (brokerImplementation) => {
|
|
268
|
+
const createBrokerFactory = (createOrGetOngoingRequests, extendBrokerImplementation, generateUniqueNumber, isMessagePort) => (brokerImplementation) => {
|
|
309
269
|
const fullBrokerImplementation = extendBrokerImplementation(brokerImplementation);
|
|
310
270
|
return (sender) => {
|
|
311
271
|
const ongoingRequests = createOrGetOngoingRequests(sender);
|
|
@@ -348,81 +308,115 @@
|
|
|
348
308
|
};
|
|
349
309
|
};
|
|
350
310
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
311
|
+
const createCreateOrGetOngoingRequests = (ongoingRequestsMap) => (sender) => {
|
|
312
|
+
if (ongoingRequestsMap.has(sender)) {
|
|
313
|
+
// @todo TypeScript needs to be convinced that has() works as expected.
|
|
314
|
+
return ongoingRequestsMap.get(sender);
|
|
315
|
+
}
|
|
316
|
+
const ongoingRequests = new Map();
|
|
317
|
+
ongoingRequestsMap.set(sender, ongoingRequests);
|
|
318
|
+
return ongoingRequests;
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
const createExtendBrokerImplementation = (portMap) => (partialBrokerImplementation) => ({
|
|
322
|
+
...partialBrokerImplementation,
|
|
323
|
+
connect: ({ call }) => {
|
|
324
|
+
return async () => {
|
|
325
|
+
const { port1, port2 } = new MessageChannel();
|
|
326
|
+
const portId = await call('connect', { port: port1 }, [port1]);
|
|
327
|
+
portMap.set(port2, portId);
|
|
328
|
+
return port2;
|
|
363
329
|
};
|
|
364
330
|
},
|
|
365
|
-
|
|
366
|
-
return (
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
scheduledTimeoutsState.delete(timerId);
|
|
371
|
-
});
|
|
331
|
+
disconnect: ({ call }) => {
|
|
332
|
+
return async (port) => {
|
|
333
|
+
const portId = portMap.get(port);
|
|
334
|
+
if (portId === undefined) {
|
|
335
|
+
throw new Error('The given port is not connected.');
|
|
372
336
|
}
|
|
337
|
+
await call('disconnect', { portId });
|
|
373
338
|
};
|
|
374
339
|
},
|
|
375
|
-
|
|
376
|
-
return (
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
};
|
|
401
|
-
},
|
|
402
|
-
setTimeout: ({ call }) => {
|
|
403
|
-
return (func, delay = 0, ...args) => {
|
|
404
|
-
const symbol = Symbol();
|
|
405
|
-
const timerId = generateUniqueNumber(scheduledTimeoutsState);
|
|
406
|
-
scheduledTimeoutsState.set(timerId, symbol);
|
|
407
|
-
call('set', {
|
|
408
|
-
delay,
|
|
409
|
-
now: performance.timeOrigin + performance.now(),
|
|
410
|
-
timerId,
|
|
411
|
-
timerType: 'timeout'
|
|
412
|
-
}).then(() => {
|
|
413
|
-
const state = scheduledTimeoutsState.get(timerId);
|
|
414
|
-
if (state === undefined) {
|
|
415
|
-
throw new Error('The timer is in an undefined state.');
|
|
416
|
-
}
|
|
417
|
-
if (state === symbol) {
|
|
418
|
-
// A timeout can be savely deleted because it is only called once.
|
|
419
|
-
scheduledTimeoutsState.delete(timerId);
|
|
420
|
-
func(...args);
|
|
421
|
-
}
|
|
422
|
-
});
|
|
423
|
-
return timerId;
|
|
424
|
-
};
|
|
340
|
+
isSupported: ({ call }) => {
|
|
341
|
+
return () => call('isSupported');
|
|
342
|
+
}
|
|
343
|
+
});
|
|
344
|
+
|
|
345
|
+
const isMessagePort = (sender) => {
|
|
346
|
+
return typeof sender.start === 'function';
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
const createBroker = createBrokerFactory(createCreateOrGetOngoingRequests(new WeakMap()), createExtendBrokerImplementation(new WeakMap()), generateUniqueNumber, isMessagePort);
|
|
350
|
+
|
|
351
|
+
const createClearIntervalFactory = (scheduledIntervalsState) => (clear) => (timerId) => {
|
|
352
|
+
if (typeof scheduledIntervalsState.get(timerId) === 'symbol') {
|
|
353
|
+
scheduledIntervalsState.set(timerId, null);
|
|
354
|
+
clear(timerId).then(() => {
|
|
355
|
+
scheduledIntervalsState.delete(timerId);
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
};
|
|
359
|
+
|
|
360
|
+
const createClearTimeoutFactory = (scheduledTimeoutsState) => (clear) => (timerId) => {
|
|
361
|
+
if (typeof scheduledTimeoutsState.get(timerId) === 'symbol') {
|
|
362
|
+
scheduledTimeoutsState.set(timerId, null);
|
|
363
|
+
clear(timerId).then(() => {
|
|
364
|
+
scheduledTimeoutsState.delete(timerId);
|
|
365
|
+
});
|
|
425
366
|
}
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
const createSetIntervalFactory = (generateUniqueNumber, scheduledIntervalsState) => (set) => (func, delay = 0, ...args) => {
|
|
370
|
+
const symbol = Symbol();
|
|
371
|
+
const timerId = generateUniqueNumber(scheduledIntervalsState);
|
|
372
|
+
scheduledIntervalsState.set(timerId, symbol);
|
|
373
|
+
const schedule = () => set(delay, timerId).then(() => {
|
|
374
|
+
const state = scheduledIntervalsState.get(timerId);
|
|
375
|
+
if (state === undefined) {
|
|
376
|
+
throw new Error('The timer is in an undefined state.');
|
|
377
|
+
}
|
|
378
|
+
if (state === symbol) {
|
|
379
|
+
func(...args);
|
|
380
|
+
// Doublecheck if the interval should still be rescheduled because it could have been cleared inside of func().
|
|
381
|
+
if (scheduledIntervalsState.get(timerId) === symbol) {
|
|
382
|
+
schedule();
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
});
|
|
386
|
+
schedule();
|
|
387
|
+
return timerId;
|
|
388
|
+
};
|
|
389
|
+
|
|
390
|
+
const createSetTimeoutFactory = (generateUniqueNumber, scheduledTimeoutsState) => (set) => (func, delay = 0, ...args) => {
|
|
391
|
+
const symbol = Symbol();
|
|
392
|
+
const timerId = generateUniqueNumber(scheduledTimeoutsState);
|
|
393
|
+
scheduledTimeoutsState.set(timerId, symbol);
|
|
394
|
+
set(delay, timerId).then(() => {
|
|
395
|
+
const state = scheduledTimeoutsState.get(timerId);
|
|
396
|
+
if (state === undefined) {
|
|
397
|
+
throw new Error('The timer is in an undefined state.');
|
|
398
|
+
}
|
|
399
|
+
if (state === symbol) {
|
|
400
|
+
// A timeout can be savely deleted because it is only called once.
|
|
401
|
+
scheduledTimeoutsState.delete(timerId);
|
|
402
|
+
func(...args);
|
|
403
|
+
}
|
|
404
|
+
});
|
|
405
|
+
return timerId;
|
|
406
|
+
};
|
|
407
|
+
|
|
408
|
+
// Prefilling the Maps with a function indexed by zero is necessary to be compliant with the specification.
|
|
409
|
+
const scheduledIntervalsState = new Map([[0, null]]); // tslint:disable-line no-empty
|
|
410
|
+
const scheduledTimeoutsState = new Map([[0, null]]); // tslint:disable-line no-empty
|
|
411
|
+
const createClearInterval = createClearIntervalFactory(scheduledIntervalsState);
|
|
412
|
+
const createClearTimeout = createClearTimeoutFactory(scheduledTimeoutsState);
|
|
413
|
+
const createSetInterval = createSetIntervalFactory(generateUniqueNumber, scheduledIntervalsState);
|
|
414
|
+
const createSetTimeout = createSetTimeoutFactory(generateUniqueNumber, scheduledTimeoutsState);
|
|
415
|
+
const wrap = createBroker({
|
|
416
|
+
clearInterval: ({ call }) => createClearInterval((timerId) => call('clear', { timerId, timerType: 'interval' })),
|
|
417
|
+
clearTimeout: ({ call }) => createClearTimeout((timerId) => call('clear', { timerId, timerType: 'timeout' })),
|
|
418
|
+
setInterval: ({ call }) => createSetInterval((delay, timerId) => call('set', { delay, now: performance.timeOrigin + performance.now(), timerId, timerType: 'interval' })),
|
|
419
|
+
setTimeout: ({ call }) => createSetTimeout((delay, timerId) => call('set', { delay, now: performance.timeOrigin + performance.now(), timerId, timerType: 'timeout' }))
|
|
426
420
|
});
|
|
427
421
|
const load = (url) => {
|
|
428
422
|
const worker = new Worker(url);
|
|
@@ -445,7 +439,7 @@
|
|
|
445
439
|
};
|
|
446
440
|
|
|
447
441
|
// This is the minified and stringified code of the worker-timers-worker package.
|
|
448
|
-
const worker = `(()=>{var e={455
|
|
442
|
+
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
|
|
449
443
|
|
|
450
444
|
const loadOrReturnBroker = createLoadOrReturnBroker(load, worker);
|
|
451
445
|
const clearInterval$1 = (timerId) => loadOrReturnBroker().clearInterval(timerId);
|
|
@@ -526,7 +520,7 @@
|
|
|
526
520
|
* @param propName
|
|
527
521
|
*/
|
|
528
522
|
delete(target, propName) {
|
|
529
|
-
if (typeof Reflect === "object" && Reflect.deleteProperty) {
|
|
523
|
+
if (typeof Reflect === "object" && typeof Reflect.deleteProperty === "function") {
|
|
530
524
|
Reflect.deleteProperty(target, propName);
|
|
531
525
|
}
|
|
532
526
|
else {
|
|
@@ -1032,13 +1026,13 @@
|
|
|
1032
1026
|
if (element == null) {
|
|
1033
1027
|
return;
|
|
1034
1028
|
}
|
|
1035
|
-
let
|
|
1029
|
+
let $elList = [];
|
|
1036
1030
|
if (element instanceof NodeList || Array.isArray(element)) {
|
|
1037
1031
|
element = element;
|
|
1038
|
-
|
|
1032
|
+
$elList = $elList.concat(element);
|
|
1039
1033
|
}
|
|
1040
1034
|
else {
|
|
1041
|
-
|
|
1035
|
+
$elList.push(element);
|
|
1042
1036
|
}
|
|
1043
1037
|
let eventTypeList = [];
|
|
1044
1038
|
if (Array.isArray(eventType)) {
|
|
@@ -1089,7 +1083,7 @@
|
|
|
1089
1083
|
// 目标函数、事件名、回调函数、事件配置、过滤函数
|
|
1090
1084
|
filter = option;
|
|
1091
1085
|
}
|
|
1092
|
-
|
|
1086
|
+
$elList.forEach((elementItem) => {
|
|
1093
1087
|
// 获取对象上的事件
|
|
1094
1088
|
const elementEvents = Reflect.get(elementItem, SymbolEvents) || {};
|
|
1095
1089
|
eventTypeList.forEach((eventName) => {
|
|
@@ -1136,18 +1130,19 @@
|
|
|
1136
1130
|
* @param eventType (可选)需要取消监听的事件
|
|
1137
1131
|
*/
|
|
1138
1132
|
offAll(element, eventType) {
|
|
1133
|
+
const that = this;
|
|
1139
1134
|
if (typeof element === "string") {
|
|
1140
|
-
element =
|
|
1135
|
+
element = that.selectorAll(element);
|
|
1141
1136
|
}
|
|
1142
1137
|
if (element == null) {
|
|
1143
1138
|
return;
|
|
1144
1139
|
}
|
|
1145
|
-
let
|
|
1140
|
+
let $elList = [];
|
|
1146
1141
|
if (element instanceof NodeList || Array.isArray(element)) {
|
|
1147
|
-
|
|
1142
|
+
$elList = $elList.concat(Array.from(element));
|
|
1148
1143
|
}
|
|
1149
1144
|
else {
|
|
1150
|
-
|
|
1145
|
+
$elList.push(element);
|
|
1151
1146
|
}
|
|
1152
1147
|
let eventTypeList = [];
|
|
1153
1148
|
if (Array.isArray(eventType)) {
|
|
@@ -1156,12 +1151,13 @@
|
|
|
1156
1151
|
else if (typeof eventType === "string") {
|
|
1157
1152
|
eventTypeList = eventTypeList.concat(eventType.split(" "));
|
|
1158
1153
|
}
|
|
1159
|
-
|
|
1160
|
-
Object.getOwnPropertySymbols(
|
|
1161
|
-
|
|
1154
|
+
$elList.forEach(($elItem) => {
|
|
1155
|
+
const symbolList = [...new Set([...Object.getOwnPropertySymbols($elItem), SymbolEvents])];
|
|
1156
|
+
symbolList.forEach((symbolItem) => {
|
|
1157
|
+
if (!symbolItem.toString().startsWith("Symbol(events_")) {
|
|
1162
1158
|
return;
|
|
1163
1159
|
}
|
|
1164
|
-
const elementEvents =
|
|
1160
|
+
const elementEvents = Reflect.get($elItem, symbolItem) || {};
|
|
1165
1161
|
const iterEventNameList = eventTypeList.length ? eventTypeList : Object.keys(elementEvents);
|
|
1166
1162
|
iterEventNameList.forEach((eventName) => {
|
|
1167
1163
|
const handlers = elementEvents[eventName];
|
|
@@ -1169,11 +1165,12 @@
|
|
|
1169
1165
|
return;
|
|
1170
1166
|
}
|
|
1171
1167
|
for (const handler of handlers) {
|
|
1172
|
-
|
|
1168
|
+
$elItem.removeEventListener(eventName, handler.callback, {
|
|
1173
1169
|
capture: handler["option"]["capture"],
|
|
1174
1170
|
});
|
|
1175
1171
|
}
|
|
1176
|
-
|
|
1172
|
+
const events = Reflect.get($elItem, symbolItem);
|
|
1173
|
+
popsUtils.delete(events, eventName);
|
|
1177
1174
|
});
|
|
1178
1175
|
});
|
|
1179
1176
|
});
|
|
@@ -1916,7 +1913,8 @@
|
|
|
1916
1913
|
}
|
|
1917
1914
|
return $el.classList.contains(className);
|
|
1918
1915
|
}
|
|
1919
|
-
css(
|
|
1916
|
+
css($el, property, value) {
|
|
1917
|
+
const that = this;
|
|
1920
1918
|
/**
|
|
1921
1919
|
* 把纯数字没有px的加上
|
|
1922
1920
|
*/
|
|
@@ -1930,10 +1928,33 @@
|
|
|
1930
1928
|
}
|
|
1931
1929
|
return propertyValue;
|
|
1932
1930
|
}
|
|
1933
|
-
if (typeof
|
|
1934
|
-
|
|
1931
|
+
if (typeof $el === "string") {
|
|
1932
|
+
$el = that.selectorAll($el);
|
|
1935
1933
|
}
|
|
1936
|
-
if (
|
|
1934
|
+
if ($el == null) {
|
|
1935
|
+
return;
|
|
1936
|
+
}
|
|
1937
|
+
if (Array.isArray($el) || $el instanceof NodeList) {
|
|
1938
|
+
if (typeof property === "string") {
|
|
1939
|
+
if (value == null) {
|
|
1940
|
+
// 获取属性
|
|
1941
|
+
return that.css($el[0], property);
|
|
1942
|
+
}
|
|
1943
|
+
else {
|
|
1944
|
+
// 设置属性
|
|
1945
|
+
$el.forEach(($elItem) => {
|
|
1946
|
+
that.css($elItem, property);
|
|
1947
|
+
});
|
|
1948
|
+
return;
|
|
1949
|
+
}
|
|
1950
|
+
}
|
|
1951
|
+
else if (typeof property === "object") {
|
|
1952
|
+
// 设置属性
|
|
1953
|
+
$el.forEach(($elItem) => {
|
|
1954
|
+
that.css($elItem, property);
|
|
1955
|
+
});
|
|
1956
|
+
return;
|
|
1957
|
+
}
|
|
1937
1958
|
return;
|
|
1938
1959
|
}
|
|
1939
1960
|
const setStyleProperty = (propertyName, propertyValue) => {
|
|
@@ -1942,16 +1963,16 @@
|
|
|
1942
1963
|
.trim()
|
|
1943
1964
|
.replace(/!important$/gi, "")
|
|
1944
1965
|
.trim();
|
|
1945
|
-
|
|
1966
|
+
$el.style.setProperty(propertyName, propertyValue, "important");
|
|
1946
1967
|
}
|
|
1947
1968
|
else {
|
|
1948
1969
|
propertyValue = handlePixe(propertyName, propertyValue);
|
|
1949
|
-
|
|
1970
|
+
$el.style.setProperty(propertyName, propertyValue);
|
|
1950
1971
|
}
|
|
1951
1972
|
};
|
|
1952
1973
|
if (typeof property === "string") {
|
|
1953
1974
|
if (value == null) {
|
|
1954
|
-
return getComputedStyle(
|
|
1975
|
+
return PopsCore.globalThis.getComputedStyle($el).getPropertyValue(property);
|
|
1955
1976
|
}
|
|
1956
1977
|
else {
|
|
1957
1978
|
setStyleProperty(property, value);
|
|
@@ -1963,6 +1984,10 @@
|
|
|
1963
1984
|
setStyleProperty(prop, value);
|
|
1964
1985
|
}
|
|
1965
1986
|
}
|
|
1987
|
+
else {
|
|
1988
|
+
// 其他情况
|
|
1989
|
+
throw new TypeError("property must be string or object");
|
|
1990
|
+
}
|
|
1966
1991
|
}
|
|
1967
1992
|
/**
|
|
1968
1993
|
* 创建元素
|
|
@@ -3097,16 +3122,16 @@
|
|
|
3097
3122
|
},
|
|
3098
3123
|
/**
|
|
3099
3124
|
* 删除配置中对应的对象
|
|
3100
|
-
* @param
|
|
3125
|
+
* @param totalInstConfigList 配置实例列表
|
|
3101
3126
|
* @param guid 唯一标识
|
|
3102
3127
|
* @param isAll 是否全部删除
|
|
3103
3128
|
*/
|
|
3104
|
-
removeInstance(
|
|
3129
|
+
async removeInstance(totalInstConfigList, guid, isAll = false) {
|
|
3105
3130
|
/**
|
|
3106
3131
|
* 移除元素实例
|
|
3107
3132
|
* @param instCommonConfig
|
|
3108
3133
|
*/
|
|
3109
|
-
function
|
|
3134
|
+
const removeInst = function (instCommonConfig) {
|
|
3110
3135
|
if (typeof instCommonConfig.beforeRemoveCallBack === "function") {
|
|
3111
3136
|
// 调用移除签的回调
|
|
3112
3137
|
instCommonConfig.beforeRemoveCallBack(instCommonConfig);
|
|
@@ -3115,39 +3140,44 @@
|
|
|
3115
3140
|
instCommonConfig?.$pops?.remove();
|
|
3116
3141
|
instCommonConfig?.$mask?.remove();
|
|
3117
3142
|
instCommonConfig?.$shadowContainer?.remove();
|
|
3118
|
-
}
|
|
3143
|
+
};
|
|
3144
|
+
const asyncInstTask = [];
|
|
3119
3145
|
// [ inst[], inst[],...]
|
|
3120
|
-
|
|
3146
|
+
totalInstConfigList.forEach((instConfigList) => {
|
|
3121
3147
|
// inst[]
|
|
3122
|
-
instConfigList.forEach((instConfigItem, index) => {
|
|
3148
|
+
instConfigList.forEach(async (instConfigItem, index) => {
|
|
3123
3149
|
// 移除全部或者guid相同
|
|
3124
|
-
if (isAll ||
|
|
3150
|
+
if (isAll || (typeof guid === "string" && instConfigItem.guid === guid)) {
|
|
3125
3151
|
// 判断是否有动画
|
|
3126
3152
|
const animName = instConfigItem.$anim.getAttribute("anim");
|
|
3127
3153
|
if (PopsAnimation.hasAnim(animName)) {
|
|
3128
3154
|
const reverseAnimName = animName + "-reverse";
|
|
3129
|
-
instConfigItem.$anim
|
|
3130
|
-
instConfigItem.$anim
|
|
3131
|
-
instConfigItem.$anim
|
|
3132
|
-
if (PopsAnimation.hasAnim(instConfigItem.$anim
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3155
|
+
popsDOMUtils.css(instConfigItem.$anim, "width", "100%");
|
|
3156
|
+
popsDOMUtils.css(instConfigItem.$anim, "height", "100%");
|
|
3157
|
+
popsDOMUtils.css(instConfigItem.$anim, "animation-name", reverseAnimName);
|
|
3158
|
+
if (PopsAnimation.hasAnim(popsDOMUtils.css(instConfigItem.$anim, "animation-name"))) {
|
|
3159
|
+
asyncInstTask.push(new Promise((resolve) => {
|
|
3160
|
+
popsDOMUtils.on(instConfigItem.$anim, popsDOMUtils.getAnimationEndNameList(), function () {
|
|
3161
|
+
removeInst(instConfigItem);
|
|
3162
|
+
resolve();
|
|
3163
|
+
}, {
|
|
3164
|
+
capture: true,
|
|
3165
|
+
});
|
|
3166
|
+
}));
|
|
3138
3167
|
}
|
|
3139
3168
|
else {
|
|
3140
|
-
|
|
3169
|
+
removeInst(instConfigItem);
|
|
3141
3170
|
}
|
|
3142
3171
|
}
|
|
3143
3172
|
else {
|
|
3144
|
-
|
|
3173
|
+
removeInst(instConfigItem);
|
|
3145
3174
|
}
|
|
3146
3175
|
instConfigList.splice(index, 1);
|
|
3147
3176
|
}
|
|
3148
3177
|
});
|
|
3149
3178
|
});
|
|
3150
|
-
|
|
3179
|
+
await Promise.all(asyncInstTask);
|
|
3180
|
+
return totalInstConfigList;
|
|
3151
3181
|
},
|
|
3152
3182
|
/**
|
|
3153
3183
|
* 隐藏
|
|
@@ -3292,8 +3322,9 @@
|
|
|
3292
3322
|
* @param config
|
|
3293
3323
|
* @param $anim
|
|
3294
3324
|
*/
|
|
3295
|
-
close(config, popsType, instConfigList, guid, $anim) {
|
|
3296
|
-
|
|
3325
|
+
async close(config, popsType, instConfigList, guid, $anim) {
|
|
3326
|
+
// eslint-disable-next-line no-async-promise-executor
|
|
3327
|
+
await new Promise(async (resolve) => {
|
|
3297
3328
|
const $pops = $anim.querySelector(".pops[type-value]");
|
|
3298
3329
|
const drawerConfig = config;
|
|
3299
3330
|
/**
|
|
@@ -3303,12 +3334,12 @@
|
|
|
3303
3334
|
/**
|
|
3304
3335
|
* 弹窗已关闭的回调
|
|
3305
3336
|
*/
|
|
3306
|
-
function closeCallBack(event) {
|
|
3337
|
+
async function closeCallBack(event) {
|
|
3307
3338
|
if (event.propertyName !== "transform") {
|
|
3308
3339
|
return;
|
|
3309
3340
|
}
|
|
3310
|
-
popsDOMUtils.off($pops, popsDOMUtils.getTransitionEndNameList(),
|
|
3311
|
-
PopsInstanceUtils.removeInstance([instConfigList], guid);
|
|
3341
|
+
popsDOMUtils.off($pops, popsDOMUtils.getTransitionEndNameList(), closeCallBack);
|
|
3342
|
+
await PopsInstanceUtils.removeInstance([instConfigList], guid);
|
|
3312
3343
|
resolve();
|
|
3313
3344
|
}
|
|
3314
3345
|
// 监听过渡结束
|
|
@@ -3340,10 +3371,32 @@
|
|
|
3340
3371
|
}, drawerConfig.closeDelay);
|
|
3341
3372
|
}
|
|
3342
3373
|
else {
|
|
3343
|
-
PopsInstanceUtils.removeInstance([instConfigList], guid);
|
|
3374
|
+
await PopsInstanceUtils.removeInstance([instConfigList], guid);
|
|
3344
3375
|
resolve();
|
|
3345
3376
|
}
|
|
3346
3377
|
});
|
|
3378
|
+
// 判断组件内是否有rightClickMenu、tooltip、searchSuggestion组件
|
|
3379
|
+
// 有的话也需要关闭
|
|
3380
|
+
PopsInstData.rightClickMenu.forEach((itemConfig) => {
|
|
3381
|
+
const config = itemConfig.config;
|
|
3382
|
+
if (config.$target instanceof HTMLElement) {
|
|
3383
|
+
const $root = config.$target.getRootNode();
|
|
3384
|
+
if ($root instanceof HTMLElement && $root.parentElement == null) {
|
|
3385
|
+
// 触发销毁元素
|
|
3386
|
+
itemConfig.destory();
|
|
3387
|
+
}
|
|
3388
|
+
}
|
|
3389
|
+
});
|
|
3390
|
+
PopsInstData.tooltip.forEach((itemConfig) => {
|
|
3391
|
+
const config = itemConfig.config;
|
|
3392
|
+
if (config.$target instanceof HTMLElement) {
|
|
3393
|
+
const $root = config.$target.getRootNode();
|
|
3394
|
+
if ($root instanceof HTMLElement && $root.parentElement == null) {
|
|
3395
|
+
// 触发销毁元素
|
|
3396
|
+
itemConfig.destory();
|
|
3397
|
+
}
|
|
3398
|
+
}
|
|
3399
|
+
});
|
|
3347
3400
|
},
|
|
3348
3401
|
/**
|
|
3349
3402
|
* 拖拽元素
|
|
@@ -3682,12 +3735,12 @@
|
|
|
3682
3735
|
element.hasAttribute("anim"));
|
|
3683
3736
|
}
|
|
3684
3737
|
// 判断按下的元素是否是pops-anim
|
|
3685
|
-
popsDOMUtils.on(config.animElement, ["touchstart", "mousedown"],
|
|
3738
|
+
popsDOMUtils.on(config.animElement, ["touchstart", "mousedown"], (event) => {
|
|
3686
3739
|
const $click = event.composedPath()[0];
|
|
3687
3740
|
isMaskClick = isAnimElement($click);
|
|
3688
3741
|
});
|
|
3689
3742
|
// 如果有动画层,在动画层上监听点击事件
|
|
3690
|
-
popsDOMUtils.on(config.animElement, "click",
|
|
3743
|
+
popsDOMUtils.on(config.animElement, "click", (event) => {
|
|
3691
3744
|
const $click = event.composedPath()[0];
|
|
3692
3745
|
if (isAnimElement($click) && isMaskClick) {
|
|
3693
3746
|
return clickEvent(event);
|
|
@@ -3695,7 +3748,7 @@
|
|
|
3695
3748
|
});
|
|
3696
3749
|
// 在遮罩层监听点击事件
|
|
3697
3750
|
// 如果有动画层,那么该点击事件触发不了
|
|
3698
|
-
popsDOMUtils.on(result.maskElement, "click",
|
|
3751
|
+
popsDOMUtils.on(result.maskElement, "click", (event) => {
|
|
3699
3752
|
isMaskClick = true;
|
|
3700
3753
|
clickEvent(event);
|
|
3701
3754
|
});
|
|
@@ -3838,13 +3891,13 @@
|
|
|
3838
3891
|
* @param guid
|
|
3839
3892
|
* @param $shadowContainer
|
|
3840
3893
|
* @param $shadowRoot
|
|
3841
|
-
* @param
|
|
3894
|
+
* @param type 当前弹窗类型
|
|
3842
3895
|
* @param $anim 动画层
|
|
3843
3896
|
* @param $pops 主元素
|
|
3844
3897
|
* @param $mask 遮罩层
|
|
3845
3898
|
* @param config 当前配置
|
|
3846
3899
|
*/
|
|
3847
|
-
handleEventConfig(config, guid, $shadowContainer, $shadowRoot,
|
|
3900
|
+
handleEventConfig(config, guid, $shadowContainer, $shadowRoot, type, $anim, $pops, $mask) {
|
|
3848
3901
|
return {
|
|
3849
3902
|
$shadowContainer: $shadowContainer,
|
|
3850
3903
|
$shadowRoot: $shadowRoot,
|
|
@@ -3852,44 +3905,47 @@
|
|
|
3852
3905
|
$anim: $anim,
|
|
3853
3906
|
$pops: $pops,
|
|
3854
3907
|
$mask: $mask,
|
|
3855
|
-
mode:
|
|
3908
|
+
mode: type,
|
|
3856
3909
|
guid: guid,
|
|
3857
3910
|
close() {
|
|
3858
|
-
return PopsInstanceUtils.close(config,
|
|
3911
|
+
return PopsInstanceUtils.close(config, type, PopsInstData[type], guid, $anim);
|
|
3859
3912
|
},
|
|
3860
3913
|
hide() {
|
|
3861
|
-
return PopsInstanceUtils.hide(config,
|
|
3914
|
+
return PopsInstanceUtils.hide(config, type, PopsInstData[type], guid, $anim, $mask);
|
|
3862
3915
|
},
|
|
3863
|
-
show() {
|
|
3864
|
-
|
|
3916
|
+
show($parent) {
|
|
3917
|
+
if ($parent) {
|
|
3918
|
+
$parent.appendChild(PopsInstData[type][0].$shadowRoot);
|
|
3919
|
+
}
|
|
3920
|
+
return PopsInstanceUtils.show(config, type, PopsInstData[type], guid, $anim, $mask);
|
|
3865
3921
|
},
|
|
3866
3922
|
};
|
|
3867
3923
|
},
|
|
3868
3924
|
/**
|
|
3869
3925
|
* 获取loading的事件配置
|
|
3870
3926
|
* @param guid
|
|
3871
|
-
* @param
|
|
3927
|
+
* @param type 当前弹窗类型
|
|
3872
3928
|
* @param $anim 动画层
|
|
3873
3929
|
* @param $pops 主元素
|
|
3874
3930
|
* @param $mask 遮罩层
|
|
3875
3931
|
* @param config 当前配置
|
|
3876
3932
|
*/
|
|
3877
|
-
handleLoadingEventConfig(config, guid,
|
|
3933
|
+
handleLoadingEventConfig(config, guid, type, $anim, $pops, $mask) {
|
|
3878
3934
|
return {
|
|
3879
3935
|
$el: $anim,
|
|
3880
3936
|
$anim: $anim,
|
|
3881
3937
|
$pops: $pops,
|
|
3882
3938
|
$mask: $mask,
|
|
3883
|
-
mode:
|
|
3939
|
+
mode: type,
|
|
3884
3940
|
guid: guid,
|
|
3885
3941
|
close() {
|
|
3886
|
-
return PopsInstanceUtils.close(config,
|
|
3942
|
+
return PopsInstanceUtils.close(config, type, PopsInstData[type], guid, $anim);
|
|
3887
3943
|
},
|
|
3888
3944
|
hide() {
|
|
3889
|
-
return PopsInstanceUtils.hide(config,
|
|
3945
|
+
return PopsInstanceUtils.hide(config, type, PopsInstData[type], guid, $anim, $mask);
|
|
3890
3946
|
},
|
|
3891
3947
|
show() {
|
|
3892
|
-
return PopsInstanceUtils.show(config,
|
|
3948
|
+
return PopsInstanceUtils.show(config, type, PopsInstData[type], guid, $anim, $mask);
|
|
3893
3949
|
},
|
|
3894
3950
|
};
|
|
3895
3951
|
},
|
|
@@ -4002,8 +4058,8 @@
|
|
|
4002
4058
|
handleOnly(type, config) {
|
|
4003
4059
|
if (config.only) {
|
|
4004
4060
|
// .loading
|
|
4005
|
-
// .tooltip
|
|
4006
4061
|
// .rightClickMenu
|
|
4062
|
+
// .tooltip
|
|
4007
4063
|
// 单独处理
|
|
4008
4064
|
if (type === "loading" || type === "tooltip" || type === "rightClickMenu") {
|
|
4009
4065
|
const inst = PopsInstData[type];
|
|
@@ -4015,11 +4071,11 @@
|
|
|
4015
4071
|
PopsInstanceUtils.removeInstance([
|
|
4016
4072
|
PopsInstData.alert,
|
|
4017
4073
|
PopsInstData.confirm,
|
|
4018
|
-
PopsInstData.prompt,
|
|
4019
|
-
PopsInstData.iframe,
|
|
4020
4074
|
PopsInstData.drawer,
|
|
4021
4075
|
PopsInstData.folder,
|
|
4076
|
+
PopsInstData.iframe,
|
|
4022
4077
|
PopsInstData.panel,
|
|
4078
|
+
PopsInstData.prompt,
|
|
4023
4079
|
], "", true);
|
|
4024
4080
|
}
|
|
4025
4081
|
}
|
|
@@ -4183,6 +4239,7 @@
|
|
|
4183
4239
|
}
|
|
4184
4240
|
// 处理返回的配置
|
|
4185
4241
|
const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, $mask);
|
|
4242
|
+
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
4186
4243
|
// 为顶部右边的关闭按钮添加点击事件
|
|
4187
4244
|
PopsHandler.handleClickEvent("close", $headerCloseBtn, evtConfig, config.btn.close?.callback);
|
|
4188
4245
|
// 为底部ok按钮添加点击事件
|
|
@@ -4205,6 +4262,8 @@
|
|
|
4205
4262
|
$mask: $mask,
|
|
4206
4263
|
$shadowContainer: $shadowContainer,
|
|
4207
4264
|
$shadowRoot: $shadowRoot,
|
|
4265
|
+
config: config,
|
|
4266
|
+
destory: result.close,
|
|
4208
4267
|
});
|
|
4209
4268
|
// 拖拽
|
|
4210
4269
|
if (config.drag) {
|
|
@@ -4216,7 +4275,6 @@
|
|
|
4216
4275
|
endCallBack: config.dragEndCallBack,
|
|
4217
4276
|
});
|
|
4218
4277
|
}
|
|
4219
|
-
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
4220
4278
|
return result;
|
|
4221
4279
|
},
|
|
4222
4280
|
};
|
|
@@ -4390,6 +4448,7 @@
|
|
|
4390
4448
|
$elList.push($mask);
|
|
4391
4449
|
}
|
|
4392
4450
|
const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, $mask);
|
|
4451
|
+
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
4393
4452
|
PopsHandler.handleClickEvent("close", $btnClose, evtConfig, config.btn.close.callback);
|
|
4394
4453
|
PopsHandler.handleClickEvent("ok", $btnOk, evtConfig, config.btn.ok.callback);
|
|
4395
4454
|
PopsHandler.handleClickEvent("cancel", $btnCancel, evtConfig, config.btn.cancel.callback);
|
|
@@ -4410,6 +4469,8 @@
|
|
|
4410
4469
|
$mask: $mask,
|
|
4411
4470
|
$shadowContainer: $shadowContainer,
|
|
4412
4471
|
$shadowRoot: $shadowRoot,
|
|
4472
|
+
config: config,
|
|
4473
|
+
destory: result.close,
|
|
4413
4474
|
});
|
|
4414
4475
|
// 拖拽
|
|
4415
4476
|
if (config.drag) {
|
|
@@ -4421,7 +4482,6 @@
|
|
|
4421
4482
|
endCallBack: config.dragEndCallBack,
|
|
4422
4483
|
});
|
|
4423
4484
|
}
|
|
4424
|
-
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
4425
4485
|
return result;
|
|
4426
4486
|
},
|
|
4427
4487
|
};
|
|
@@ -4600,6 +4660,7 @@
|
|
|
4600
4660
|
$elList.push($mask);
|
|
4601
4661
|
}
|
|
4602
4662
|
const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, $mask);
|
|
4663
|
+
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
4603
4664
|
// 处理方向
|
|
4604
4665
|
$pops.setAttribute("direction", config.direction);
|
|
4605
4666
|
// 处理border-radius
|
|
@@ -4695,8 +4756,9 @@
|
|
|
4695
4756
|
$mask: $mask,
|
|
4696
4757
|
$shadowContainer: $shadowContainer,
|
|
4697
4758
|
$shadowRoot: $shadowRoot,
|
|
4759
|
+
config: config,
|
|
4760
|
+
destory: result.close,
|
|
4698
4761
|
});
|
|
4699
|
-
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
4700
4762
|
return result;
|
|
4701
4763
|
},
|
|
4702
4764
|
};
|
|
@@ -5205,6 +5267,7 @@
|
|
|
5205
5267
|
}
|
|
5206
5268
|
// 事件
|
|
5207
5269
|
const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, $mask);
|
|
5270
|
+
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
5208
5271
|
PopsHandler.handleClickEvent("close", $btnCloseBtn, evtConfig, config.btn.close.callback);
|
|
5209
5272
|
PopsHandler.handleClickEvent("ok", btnOkElement, evtConfig, config.btn.ok.callback);
|
|
5210
5273
|
PopsHandler.handleClickEvent("cancel", btnCancelElement, evtConfig, config.btn.cancel.callback);
|
|
@@ -5784,8 +5847,9 @@
|
|
|
5784
5847
|
$mask: $mask,
|
|
5785
5848
|
$shadowContainer: $shadowContainer,
|
|
5786
5849
|
$shadowRoot: $shadowRoot,
|
|
5850
|
+
config: config,
|
|
5851
|
+
destory: result.close,
|
|
5787
5852
|
});
|
|
5788
|
-
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
5789
5853
|
return result;
|
|
5790
5854
|
},
|
|
5791
5855
|
};
|
|
@@ -5941,6 +6005,7 @@
|
|
|
5941
6005
|
const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, $mask);
|
|
5942
6006
|
// 赋值额外的$iframe参数
|
|
5943
6007
|
evtConfig.$iframe = $iframe;
|
|
6008
|
+
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
5944
6009
|
popsDOMUtils.on($anim, popsDOMUtils.getAnimationEndNameList(), function () {
|
|
5945
6010
|
// 动画加载完毕
|
|
5946
6011
|
$anim.style.width = "0%";
|
|
@@ -6072,10 +6137,10 @@
|
|
|
6072
6137
|
capture: true,
|
|
6073
6138
|
});
|
|
6074
6139
|
// 关闭按钮点击事件
|
|
6075
|
-
popsDOMUtils.on(headerCloseBtnElement, "click", (event) => {
|
|
6140
|
+
popsDOMUtils.on(headerCloseBtnElement, "click", async (event) => {
|
|
6076
6141
|
event.preventDefault();
|
|
6077
6142
|
event.stopPropagation();
|
|
6078
|
-
PopsInstanceUtils.removeInstance([PopsInstData.iframe], guid, false);
|
|
6143
|
+
await PopsInstanceUtils.removeInstance([PopsInstData.iframe], guid, false);
|
|
6079
6144
|
if (typeof config?.btn?.close?.callback === "function") {
|
|
6080
6145
|
config.btn.close.callback(evtConfig, event);
|
|
6081
6146
|
}
|
|
@@ -6089,8 +6154,9 @@
|
|
|
6089
6154
|
$mask: $mask,
|
|
6090
6155
|
$shadowContainer: $shadowContainer,
|
|
6091
6156
|
$shadowRoot: $shadowRoot,
|
|
6157
|
+
config: config,
|
|
6158
|
+
destory: result.close,
|
|
6092
6159
|
});
|
|
6093
|
-
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
6094
6160
|
return result;
|
|
6095
6161
|
},
|
|
6096
6162
|
};
|
|
@@ -7056,7 +7122,7 @@
|
|
|
7056
7122
|
isFixed: false,
|
|
7057
7123
|
alwaysShow: false,
|
|
7058
7124
|
onShowEventName: "mouseenter touchstart",
|
|
7059
|
-
onCloseEventName: "mouseleave touchend",
|
|
7125
|
+
onCloseEventName: "mouseleave touchend touchcancel",
|
|
7060
7126
|
zIndex: 10000,
|
|
7061
7127
|
only: false,
|
|
7062
7128
|
eventOption: {
|
|
@@ -7282,12 +7348,12 @@
|
|
|
7282
7348
|
changePosition(event) {
|
|
7283
7349
|
const positionInfo = this.calcToolTipPosition(this.$data.config.$target, this.$data.config.arrowDistance, this.$data.config.otherDistance, event);
|
|
7284
7350
|
const positionKey = this.$data.config.position.toUpperCase();
|
|
7285
|
-
const
|
|
7286
|
-
if (
|
|
7287
|
-
this.$el.$toolTip.style.left =
|
|
7288
|
-
this.$el.$toolTip.style.top =
|
|
7289
|
-
this.$el.$toolTip.setAttribute("data-motion",
|
|
7290
|
-
this.$el.$arrow.setAttribute("data-position",
|
|
7351
|
+
const position = positionInfo[positionKey];
|
|
7352
|
+
if (position) {
|
|
7353
|
+
this.$el.$toolTip.style.left = position.left + "px";
|
|
7354
|
+
this.$el.$toolTip.style.top = position.top + "px";
|
|
7355
|
+
this.$el.$toolTip.setAttribute("data-motion", position.motion);
|
|
7356
|
+
this.$el.$arrow.setAttribute("data-position", position.arrow);
|
|
7291
7357
|
}
|
|
7292
7358
|
else {
|
|
7293
7359
|
console.error("不存在该位置", this.$data.config.position);
|
|
@@ -7393,9 +7459,7 @@
|
|
|
7393
7459
|
* 取消绑定 显示事件
|
|
7394
7460
|
*/
|
|
7395
7461
|
offShowEvent() {
|
|
7396
|
-
popsDOMUtils.off(this.$data.config.$target, this.$data.config.onShowEventName, this.show,
|
|
7397
|
-
capture: true,
|
|
7398
|
-
});
|
|
7462
|
+
popsDOMUtils.off(this.$data.config.$target, this.$data.config.onShowEventName, this.show, this.$data.config.eventOption);
|
|
7399
7463
|
}
|
|
7400
7464
|
/**
|
|
7401
7465
|
* 关闭提示框
|
|
@@ -7454,22 +7518,20 @@
|
|
|
7454
7518
|
* 取消绑定 关闭事件
|
|
7455
7519
|
*/
|
|
7456
7520
|
offCloseEvent() {
|
|
7457
|
-
popsDOMUtils.off(this.$data.config.$target, this.$data.config.onCloseEventName, this.close,
|
|
7458
|
-
capture: true,
|
|
7459
|
-
});
|
|
7521
|
+
popsDOMUtils.off(this.$data.config.$target, this.$data.config.onCloseEventName, this.close, this.$data.config.eventOption);
|
|
7460
7522
|
}
|
|
7461
7523
|
/**
|
|
7462
7524
|
* 销毁元素
|
|
7463
7525
|
*/
|
|
7464
7526
|
destory() {
|
|
7465
7527
|
if (this.$el.$toolTip) {
|
|
7466
|
-
this.$el.$
|
|
7528
|
+
this.$el.$toolTip.remove();
|
|
7467
7529
|
}
|
|
7468
|
-
// @ts-
|
|
7530
|
+
// @ts-expect-error
|
|
7469
7531
|
this.$el.$toolTip = null;
|
|
7470
|
-
// @ts-
|
|
7532
|
+
// @ts-expect-error
|
|
7471
7533
|
this.$el.$arrow = null;
|
|
7472
|
-
// @ts-
|
|
7534
|
+
// @ts-expect-error
|
|
7473
7535
|
this.$el.$content = null;
|
|
7474
7536
|
}
|
|
7475
7537
|
/**
|
|
@@ -7517,29 +7579,29 @@
|
|
|
7517
7579
|
popsDOMUtils.on(this.$el.$toolTip, "mouseenter touchstart", this.toolTipMouseEnterEvent, this.$data.config.eventOption);
|
|
7518
7580
|
}
|
|
7519
7581
|
/**
|
|
7520
|
-
*
|
|
7582
|
+
* 取消监听事件 - 鼠标|触摸
|
|
7521
7583
|
*/
|
|
7522
7584
|
offToolTipMouseEnterEvent() {
|
|
7523
7585
|
popsDOMUtils.off(this.$el.$toolTip, "mouseenter touchstart", this.toolTipMouseEnterEvent, this.$data.config.eventOption);
|
|
7524
7586
|
}
|
|
7525
7587
|
/**
|
|
7526
|
-
*
|
|
7588
|
+
* 离开事件 - 鼠标|触摸
|
|
7527
7589
|
*/
|
|
7528
7590
|
toolTipMouseLeaveEvent(event) {
|
|
7529
7591
|
this.close(event);
|
|
7530
7592
|
// this.$el.$toolTip.style.animationPlayState = "running";
|
|
7531
7593
|
}
|
|
7532
7594
|
/**
|
|
7533
|
-
*
|
|
7595
|
+
* 监听离开事件 - 鼠标|触摸
|
|
7534
7596
|
*/
|
|
7535
7597
|
onToolTipMouseLeaveEvent() {
|
|
7536
|
-
popsDOMUtils.on(this.$el.$toolTip, "mouseleave touchend", this.toolTipMouseLeaveEvent, this.$data.config.eventOption);
|
|
7598
|
+
popsDOMUtils.on(this.$el.$toolTip, "mouseleave touchend touchcancel", this.toolTipMouseLeaveEvent, this.$data.config.eventOption);
|
|
7537
7599
|
}
|
|
7538
7600
|
/**
|
|
7539
|
-
*
|
|
7601
|
+
* 取消监听离开事件 - 鼠标|触摸
|
|
7540
7602
|
*/
|
|
7541
7603
|
offToolTipMouseLeaveEvent() {
|
|
7542
|
-
popsDOMUtils.off(this.$el.$toolTip, "mouseleave touchend", this.toolTipMouseLeaveEvent, this.$data.config.eventOption);
|
|
7604
|
+
popsDOMUtils.off(this.$el.$toolTip, "mouseleave touchend touchcancel", this.toolTipMouseLeaveEvent, this.$data.config.eventOption);
|
|
7543
7605
|
}
|
|
7544
7606
|
}
|
|
7545
7607
|
const PopsTooltip = {
|
|
@@ -7554,6 +7616,15 @@
|
|
|
7554
7616
|
throw new TypeError("config.target 必须是HTMLElement类型");
|
|
7555
7617
|
}
|
|
7556
7618
|
config = PopsHandler.handleOnly(popsType, config);
|
|
7619
|
+
if (config.position === "follow") {
|
|
7620
|
+
config.onShowEventName = config.onShowEventName.trim();
|
|
7621
|
+
const showEventNameSplit = config.onShowEventName.split(" ");
|
|
7622
|
+
["mousemove", "touchmove"].forEach((it) => {
|
|
7623
|
+
if (showEventNameSplit.includes(it))
|
|
7624
|
+
return;
|
|
7625
|
+
config.onShowEventName += ` ${it}`;
|
|
7626
|
+
});
|
|
7627
|
+
}
|
|
7557
7628
|
const { $shadowContainer, $shadowRoot } = PopsHandler.handlerShadow(config);
|
|
7558
7629
|
PopsHandler.handleInit($shadowRoot, [
|
|
7559
7630
|
{
|
|
@@ -8818,7 +8889,7 @@
|
|
|
8818
8889
|
* 监听输入框内容改变
|
|
8819
8890
|
*/
|
|
8820
8891
|
onValueChange() {
|
|
8821
|
-
popsDOMUtils.on(this.$el.input, ["input", "propertychange"],
|
|
8892
|
+
popsDOMUtils.on(this.$el.input, ["input", "propertychange"], (event) => {
|
|
8822
8893
|
this.$data.value = this.$el.input.value;
|
|
8823
8894
|
if (inputType !== "password") {
|
|
8824
8895
|
// 不是密码框
|
|
@@ -9191,7 +9262,7 @@
|
|
|
9191
9262
|
* 监听点击事件
|
|
9192
9263
|
*/
|
|
9193
9264
|
onClick() {
|
|
9194
|
-
popsDOMUtils.on(this.$el.$select, "click",
|
|
9265
|
+
popsDOMUtils.on(this.$el.$select, "click", (event) => {
|
|
9195
9266
|
this.setSelectOptionsDisableStatus();
|
|
9196
9267
|
if (typeof viewConfig.clickCallBack === "function") {
|
|
9197
9268
|
const $isSelectedElement = this.$el.$select[this.$el.$select.selectedIndex];
|
|
@@ -10958,7 +11029,7 @@
|
|
|
10958
11029
|
* 设置按钮的点击事件
|
|
10959
11030
|
*/
|
|
10960
11031
|
onButtonClick() {
|
|
10961
|
-
popsDOMUtils.on(this.$ele.button, "click",
|
|
11032
|
+
popsDOMUtils.on(this.$ele.button, "click", (event) => {
|
|
10962
11033
|
if (typeof viewConfig.callback === "function") {
|
|
10963
11034
|
viewConfig.callback(event);
|
|
10964
11035
|
}
|
|
@@ -11027,13 +11098,13 @@
|
|
|
11027
11098
|
initContainerItem($container, formItemConfig) {
|
|
11028
11099
|
const containerViewConfig = formItemConfig;
|
|
11029
11100
|
if (containerViewConfig.type === "container") {
|
|
11030
|
-
const
|
|
11101
|
+
const childViewConfig = containerViewConfig["views"];
|
|
11031
11102
|
// 每一项<li>元素
|
|
11032
|
-
const
|
|
11103
|
+
const $itemLi = popsDOMUtils.createElement("li");
|
|
11033
11104
|
// 每一项<li>内的子<ul>元素
|
|
11034
|
-
const
|
|
11035
|
-
|
|
11036
|
-
|
|
11105
|
+
const $itemUL = popsDOMUtils.createElement("ul");
|
|
11106
|
+
$itemUL.classList.add("pops-panel-forms-container-item-formlist");
|
|
11107
|
+
$itemLi.classList.add("pops-panel-forms-container-item");
|
|
11037
11108
|
// 区域头部的文字
|
|
11038
11109
|
const formHeaderDivElement = popsDOMUtils.createElement("div", {
|
|
11039
11110
|
className: "pops-panel-forms-container-item-header-text",
|
|
@@ -11053,42 +11124,42 @@
|
|
|
11053
11124
|
`);
|
|
11054
11125
|
// 添加点击事件
|
|
11055
11126
|
popsDOMUtils.on(formHeaderDivElement, "click", () => {
|
|
11056
|
-
if (
|
|
11057
|
-
|
|
11127
|
+
if ($itemLi.hasAttribute("data-fold-enable")) {
|
|
11128
|
+
$itemLi.removeAttribute("data-fold-enable");
|
|
11058
11129
|
}
|
|
11059
11130
|
else {
|
|
11060
|
-
|
|
11131
|
+
$itemLi.setAttribute("data-fold-enable", "");
|
|
11061
11132
|
}
|
|
11062
11133
|
});
|
|
11063
11134
|
popsDOMUtils.addClassName(formHeaderDivElement, "pops-panel-forms-fold-container");
|
|
11064
11135
|
popsDOMUtils.addClassName(formHeaderDivElement, PopsCommonCSSClassName.userSelectNone);
|
|
11065
|
-
|
|
11136
|
+
$itemLi.setAttribute("data-fold-enable", "");
|
|
11066
11137
|
popsDOMUtils.addClassName(formHeaderDivElement, "pops-panel-forms-fold");
|
|
11067
|
-
|
|
11138
|
+
$itemLi.appendChild(formHeaderDivElement);
|
|
11068
11139
|
}
|
|
11069
11140
|
else {
|
|
11070
11141
|
// 加进容器内
|
|
11071
|
-
|
|
11142
|
+
$itemLi.appendChild(formHeaderDivElement);
|
|
11072
11143
|
}
|
|
11073
|
-
that.setElementClassName(
|
|
11074
|
-
that.setElementAttributes(
|
|
11075
|
-
that.setElementProps(
|
|
11076
|
-
|
|
11144
|
+
that.setElementClassName($itemLi, formItemConfig.className);
|
|
11145
|
+
that.setElementAttributes($itemLi, formItemConfig.attributes);
|
|
11146
|
+
that.setElementProps($itemLi, formItemConfig.props);
|
|
11147
|
+
$itemLi.appendChild($itemUL);
|
|
11148
|
+
$container.appendChild($itemLi);
|
|
11149
|
+
childViewConfig.forEach((childViewConfig) => {
|
|
11077
11150
|
that.uListContainerAddItem(childViewConfig, {
|
|
11078
|
-
ulElement:
|
|
11151
|
+
ulElement: $itemUL,
|
|
11079
11152
|
sectionContainerULElement: that.sectionContainerULElement,
|
|
11080
|
-
formContainerListElement:
|
|
11153
|
+
formContainerListElement: $itemLi,
|
|
11081
11154
|
formHeaderDivElement: formHeaderDivElement,
|
|
11082
11155
|
});
|
|
11083
11156
|
});
|
|
11084
|
-
formContainerListElement.appendChild(formContainerULElement);
|
|
11085
|
-
$container.appendChild(formContainerListElement);
|
|
11086
11157
|
if (typeof containerViewConfig.afterAddToUListCallBack === "function") {
|
|
11087
11158
|
containerViewConfig.afterAddToUListCallBack(viewConfig, {
|
|
11088
|
-
target:
|
|
11089
|
-
ulElement:
|
|
11159
|
+
target: $itemLi,
|
|
11160
|
+
ulElement: $itemUL,
|
|
11090
11161
|
sectionContainerULElement: that.sectionContainerULElement,
|
|
11091
|
-
formContainerListElement:
|
|
11162
|
+
formContainerListElement: $itemLi,
|
|
11092
11163
|
formHeaderDivElement: formHeaderDivElement,
|
|
11093
11164
|
});
|
|
11094
11165
|
}
|
|
@@ -11227,7 +11298,7 @@
|
|
|
11227
11298
|
},
|
|
11228
11299
|
/** 设置项的点击事件 */
|
|
11229
11300
|
onLiClick() {
|
|
11230
|
-
popsDOMUtils.on($li, "click",
|
|
11301
|
+
popsDOMUtils.on($li, "click", async (event) => {
|
|
11231
11302
|
if (typeof viewConfig.clickCallBack === "function") {
|
|
11232
11303
|
const result = await viewConfig.clickCallBack(event, viewConfig);
|
|
11233
11304
|
if (result) {
|
|
@@ -11555,6 +11626,7 @@
|
|
|
11555
11626
|
}
|
|
11556
11627
|
// 处理返回的配置
|
|
11557
11628
|
const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, $mask);
|
|
11629
|
+
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
11558
11630
|
// 为顶部右边的关闭按钮添加点击事件
|
|
11559
11631
|
PopsHandler.handleClickEvent("close", $headerBtnClose, evtConfig, config.btn?.close?.callback);
|
|
11560
11632
|
// 创建到页面中
|
|
@@ -11592,6 +11664,8 @@
|
|
|
11592
11664
|
$mask: $mask,
|
|
11593
11665
|
$shadowContainer: $shadowContainer,
|
|
11594
11666
|
$shadowRoot: $shadowRoot,
|
|
11667
|
+
config: config,
|
|
11668
|
+
destory: result.close,
|
|
11595
11669
|
});
|
|
11596
11670
|
// 拖拽
|
|
11597
11671
|
if (config.drag) {
|
|
@@ -11603,7 +11677,6 @@
|
|
|
11603
11677
|
endCallBack: config.dragEndCallBack,
|
|
11604
11678
|
});
|
|
11605
11679
|
}
|
|
11606
|
-
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
11607
11680
|
return {
|
|
11608
11681
|
...result,
|
|
11609
11682
|
addEventListener: (event, listener, options) => {
|
|
@@ -11795,6 +11868,7 @@
|
|
|
11795
11868
|
$elList.push($mask);
|
|
11796
11869
|
}
|
|
11797
11870
|
const evtConfig = PopsHandler.handleEventConfig(config, guid, $shadowContainer, $shadowRoot, popsType, $anim, $pops, $mask);
|
|
11871
|
+
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
11798
11872
|
// 输入框赋值初始值
|
|
11799
11873
|
$input.value = config.content.text;
|
|
11800
11874
|
PopsHandler.handlePromptClickEvent("close", $input, $btnClose, evtConfig, config.btn.close.callback);
|
|
@@ -11817,6 +11891,8 @@
|
|
|
11817
11891
|
$mask: $mask,
|
|
11818
11892
|
$shadowContainer: $shadowContainer,
|
|
11819
11893
|
$shadowRoot: $shadowRoot,
|
|
11894
|
+
config: config,
|
|
11895
|
+
destory: result.close,
|
|
11820
11896
|
});
|
|
11821
11897
|
// 拖拽
|
|
11822
11898
|
if (config.drag) {
|
|
@@ -11836,7 +11912,6 @@
|
|
|
11836
11912
|
if (config.content.select) {
|
|
11837
11913
|
$input.select();
|
|
11838
11914
|
}
|
|
11839
|
-
const result = PopsHandler.handleResultConfig(evtConfig);
|
|
11840
11915
|
return result;
|
|
11841
11916
|
},
|
|
11842
11917
|
};
|
|
@@ -11938,6 +12013,7 @@
|
|
|
11938
12013
|
beforeAppendToPageCallBack() { },
|
|
11939
12014
|
limitPositionXInView: true,
|
|
11940
12015
|
limitPositionYInView: true,
|
|
12016
|
+
beforeShowCallBack() { },
|
|
11941
12017
|
};
|
|
11942
12018
|
};
|
|
11943
12019
|
|
|
@@ -11997,6 +12073,8 @@
|
|
|
11997
12073
|
return;
|
|
11998
12074
|
}
|
|
11999
12075
|
if ($click.className && $click.className === "pops-shadow-container" && $click.shadowRoot != null) {
|
|
12076
|
+
// pops的shadow-container
|
|
12077
|
+
PopsContextMenu.shadowRootCheckClickEvent(event);
|
|
12000
12078
|
return;
|
|
12001
12079
|
}
|
|
12002
12080
|
PopsContextMenu.closeAllMenu(PopsContextMenu.$el.$root);
|
|
@@ -12009,7 +12087,7 @@
|
|
|
12009
12087
|
if (!PopsContextMenu.$el.$root) {
|
|
12010
12088
|
return;
|
|
12011
12089
|
}
|
|
12012
|
-
const $click = event.
|
|
12090
|
+
const $click = event.composedPath()[0];
|
|
12013
12091
|
if ($click.closest(`.pops-${popsType}`)) {
|
|
12014
12092
|
return;
|
|
12015
12093
|
}
|
|
@@ -12019,13 +12097,13 @@
|
|
|
12019
12097
|
* 添加全局点击检测事件
|
|
12020
12098
|
*/
|
|
12021
12099
|
addWindowCheckClickListener() {
|
|
12022
|
-
popsDOMUtils.on(globalThis, "click touchstart",
|
|
12100
|
+
popsDOMUtils.on(globalThis, "click touchstart", PopsContextMenu.windowCheckClickEvent, {
|
|
12023
12101
|
capture: true,
|
|
12024
12102
|
});
|
|
12025
12103
|
if (config.$target instanceof Node) {
|
|
12026
12104
|
const $shadowRoot = config.$target.getRootNode();
|
|
12027
12105
|
if ($shadowRoot instanceof ShadowRoot) {
|
|
12028
|
-
popsDOMUtils.on($shadowRoot, "click touchstart",
|
|
12106
|
+
popsDOMUtils.on($shadowRoot, "click touchstart", PopsContextMenu.shadowRootCheckClickEvent, {
|
|
12029
12107
|
capture: true,
|
|
12030
12108
|
});
|
|
12031
12109
|
}
|
|
@@ -12035,13 +12113,13 @@
|
|
|
12035
12113
|
* 移除全局点击检测事件
|
|
12036
12114
|
*/
|
|
12037
12115
|
removeWindowCheckClickListener() {
|
|
12038
|
-
popsDOMUtils.off(globalThis, "click touchstart",
|
|
12116
|
+
popsDOMUtils.off(globalThis, "click touchstart", PopsContextMenu.windowCheckClickEvent, {
|
|
12039
12117
|
capture: true,
|
|
12040
12118
|
});
|
|
12041
12119
|
if (config.$target instanceof Node) {
|
|
12042
12120
|
const $shadowRoot = config.$target.getRootNode();
|
|
12043
12121
|
if ($shadowRoot instanceof ShadowRoot) {
|
|
12044
|
-
popsDOMUtils.off($shadowRoot, "click touchstart",
|
|
12122
|
+
popsDOMUtils.off($shadowRoot, "click touchstart", PopsContextMenu.windowCheckClickEvent, {
|
|
12045
12123
|
capture: true,
|
|
12046
12124
|
});
|
|
12047
12125
|
}
|
|
@@ -12052,7 +12130,7 @@
|
|
|
12052
12130
|
* @param event
|
|
12053
12131
|
* @param selectorTarget
|
|
12054
12132
|
*/
|
|
12055
|
-
contextMenuEvent(event, selectorTarget) {
|
|
12133
|
+
async contextMenuEvent(event, selectorTarget) {
|
|
12056
12134
|
if (config.preventDefault) {
|
|
12057
12135
|
popsDOMUtils.preventEvent(event);
|
|
12058
12136
|
}
|
|
@@ -12061,6 +12139,10 @@
|
|
|
12061
12139
|
PopsContextMenu.closeAllMenu(PopsContextMenu.$el.$root);
|
|
12062
12140
|
}
|
|
12063
12141
|
selectorTarget = selectorTarget ?? config.$target;
|
|
12142
|
+
const beforeShowCallBackResult = await config?.beforeShowCallBack(event);
|
|
12143
|
+
if (typeof beforeShowCallBackResult === "boolean" && !beforeShowCallBackResult) {
|
|
12144
|
+
return;
|
|
12145
|
+
}
|
|
12064
12146
|
const rootElement = PopsContextMenu.showMenu(event, config.data, selectorTarget);
|
|
12065
12147
|
PopsContextMenu.$el.$root = rootElement;
|
|
12066
12148
|
if (config.only) {
|
|
@@ -12073,6 +12155,10 @@
|
|
|
12073
12155
|
beforeRemoveCallBack(instCommonConfig) {
|
|
12074
12156
|
PopsContextMenu.closeAllMenu(instCommonConfig.$pops);
|
|
12075
12157
|
},
|
|
12158
|
+
config: config,
|
|
12159
|
+
destory: () => {
|
|
12160
|
+
PopsContextMenu.closeAllMenu(rootElement);
|
|
12161
|
+
},
|
|
12076
12162
|
});
|
|
12077
12163
|
}
|
|
12078
12164
|
},
|
|
@@ -12376,7 +12462,8 @@
|
|
|
12376
12462
|
menuLiElement.appendChild(iconElement);
|
|
12377
12463
|
}
|
|
12378
12464
|
// 插入文字
|
|
12379
|
-
|
|
12465
|
+
const text = typeof item.text === "function" ? item.text() : item.text;
|
|
12466
|
+
menuLiElement.insertAdjacentHTML("beforeend", PopsSafeUtils.getSafeHTML(`<span>${text}</span>`));
|
|
12380
12467
|
// 如果存在子数据,显示
|
|
12381
12468
|
if (item.item && Array.isArray(item.item)) {
|
|
12382
12469
|
popsDOMUtils.addClassName(menuLiElement, `pops-${popsType}-item`);
|
|
@@ -13015,10 +13102,10 @@
|
|
|
13015
13102
|
setShowEvent(option = defaultListenerOption) {
|
|
13016
13103
|
/* 焦点|点击事件*/
|
|
13017
13104
|
if (config.followPosition === "target") {
|
|
13018
|
-
popsDOMUtils.on([config.$target], ["focus", "click"],
|
|
13105
|
+
popsDOMUtils.on([config.$target], ["focus", "click"], SearchSuggestion.showEvent, option);
|
|
13019
13106
|
}
|
|
13020
13107
|
else if (config.followPosition === "input") {
|
|
13021
|
-
popsDOMUtils.on([config.$inputTarget], ["focus", "click"],
|
|
13108
|
+
popsDOMUtils.on([config.$inputTarget], ["focus", "click"], SearchSuggestion.showEvent, option);
|
|
13022
13109
|
}
|
|
13023
13110
|
else if (config.followPosition === "inputCursor") {
|
|
13024
13111
|
popsDOMUtils.on([config.$inputTarget], ["focus", "click", "input"], SearchSuggestion.showEvent, option);
|
|
@@ -13032,9 +13119,9 @@
|
|
|
13032
13119
|
*/
|
|
13033
13120
|
removeShowEvent(option = defaultListenerOption) {
|
|
13034
13121
|
/* 焦点|点击事件*/
|
|
13035
|
-
popsDOMUtils.off([config.$target, config.$inputTarget], ["focus", "click"],
|
|
13122
|
+
popsDOMUtils.off([config.$target, config.$inputTarget], ["focus", "click"], SearchSuggestion.showEvent, option);
|
|
13036
13123
|
// 内容改变事件
|
|
13037
|
-
popsDOMUtils.off([config.$inputTarget], ["input"],
|
|
13124
|
+
popsDOMUtils.off([config.$inputTarget], ["input"], SearchSuggestion.showEvent, option);
|
|
13038
13125
|
},
|
|
13039
13126
|
/**
|
|
13040
13127
|
* 隐藏搜索建议框的事件
|
|
@@ -13065,7 +13152,7 @@
|
|
|
13065
13152
|
// 全局触摸屏点击事件
|
|
13066
13153
|
if (Array.isArray(SearchSuggestion.selfDocument)) {
|
|
13067
13154
|
SearchSuggestion.selfDocument.forEach(($checkParent) => {
|
|
13068
|
-
popsDOMUtils.on($checkParent, ["click", "touchstart"],
|
|
13155
|
+
popsDOMUtils.on($checkParent, ["click", "touchstart"], SearchSuggestion.hideEvent, option);
|
|
13069
13156
|
});
|
|
13070
13157
|
}
|
|
13071
13158
|
else {
|
|
@@ -13078,11 +13165,11 @@
|
|
|
13078
13165
|
removeHideEvent(option = defaultListenerOption) {
|
|
13079
13166
|
if (Array.isArray(SearchSuggestion.selfDocument)) {
|
|
13080
13167
|
SearchSuggestion.selfDocument.forEach(($checkParent) => {
|
|
13081
|
-
popsDOMUtils.off($checkParent, ["click", "touchstart"],
|
|
13168
|
+
popsDOMUtils.off($checkParent, ["click", "touchstart"], SearchSuggestion.hideEvent, option);
|
|
13082
13169
|
});
|
|
13083
13170
|
}
|
|
13084
13171
|
else {
|
|
13085
|
-
popsDOMUtils.off(SearchSuggestion.selfDocument, ["click", "touchstart"],
|
|
13172
|
+
popsDOMUtils.off(SearchSuggestion.selfDocument, ["click", "touchstart"], SearchSuggestion.hideEvent, option);
|
|
13086
13173
|
}
|
|
13087
13174
|
},
|
|
13088
13175
|
/**
|
|
@@ -13343,7 +13430,7 @@
|
|
|
13343
13430
|
},
|
|
13344
13431
|
};
|
|
13345
13432
|
|
|
13346
|
-
const version = "3.
|
|
13433
|
+
const version = "3.2.0";
|
|
13347
13434
|
|
|
13348
13435
|
class Pops {
|
|
13349
13436
|
/** 配置 */
|