cbvirtua 1.0.6 → 1.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/menu/wzc-option.vue +74 -0
  2. package/menu/wzc-select.vue +209 -0
  3. package/package.json +1 -1
  4. package/v2/App.vue +0 -56
  5. package/v2/components/Dropdown.vue +0 -28
  6. package/v2/components/Menu.vue +0 -9
  7. package/v2/components/Popper.js +0 -1011
  8. package/v2/components/PopperContent.vue +0 -270
  9. package/v2/components/PopperMethods.js +0 -17
  10. package/v2/components/PopperWrapper.vue +0 -101
  11. package/v2/components/ResizeObserver.vue +0 -151
  12. package/v2/components/ThemeClass.js +0 -9
  13. package/v2/components/Tooltip.vue +0 -22
  14. package/v2/components/TooltipDirective.vue +0 -171
  15. package/v2/config.js +0 -133
  16. package/v2/directives/v-close-popper.js +0 -67
  17. package/v2/directives/v-tooltip.js +0 -116
  18. package/v2/floating-ui/core/computeCoordsFromPlacement.js +0 -39
  19. package/v2/floating-ui/core/computePosition.js +0 -52
  20. package/v2/floating-ui/core/detectOverflow.js +0 -36
  21. package/v2/floating-ui/core/enums.js +0 -7
  22. package/v2/floating-ui/core/index.js +0 -11
  23. package/v2/floating-ui/core/middleware/arrow.js +0 -52
  24. package/v2/floating-ui/core/middleware/autoPlacement.js +0 -84
  25. package/v2/floating-ui/core/middleware/flip.js +0 -82
  26. package/v2/floating-ui/core/middleware/hide.js +0 -36
  27. package/v2/floating-ui/core/middleware/inline.js +0 -100
  28. package/v2/floating-ui/core/middleware/offset.js +0 -26
  29. package/v2/floating-ui/core/middleware/shift.js +0 -99
  30. package/v2/floating-ui/core/middleware/size.js +0 -58
  31. package/v2/floating-ui/core/types.js +0 -11
  32. package/v2/floating-ui/core/utils/expandPaddingObject.js +0 -3
  33. package/v2/floating-ui/core/utils/getAlignment.js +0 -3
  34. package/v2/floating-ui/core/utils/getAlignmentSides.js +0 -23
  35. package/v2/floating-ui/core/utils/getBasePlacement.js +0 -3
  36. package/v2/floating-ui/core/utils/getCrossAxis.js +0 -3
  37. package/v2/floating-ui/core/utils/getExpandedPlacements.js +0 -10
  38. package/v2/floating-ui/core/utils/getLengthFromAxis.js +0 -3
  39. package/v2/floating-ui/core/utils/getMainAxisFromPlacement.js +0 -4
  40. package/v2/floating-ui/core/utils/getOppositeAlignmentPlacement.js +0 -4
  41. package/v2/floating-ui/core/utils/getOppositePlacement.js +0 -4
  42. package/v2/floating-ui/core/utils/getPaddingObject.js +0 -6
  43. package/v2/floating-ui/core/utils/math.js +0 -2
  44. package/v2/floating-ui/core/utils/rectToClientRect.js +0 -9
  45. package/v2/floating-ui/core/utils/within.js +0 -4
  46. package/v2/floating-ui/dom/index.js +0 -5
  47. package/v2/floating-ui/dom/platform.js +0 -20
  48. package/v2/floating-ui/dom/utils/contains.js +0 -22
  49. package/v2/floating-ui/dom/utils/convertOffsetParentRelativeRectToViewportRelativeRect.js +0 -35
  50. package/v2/floating-ui/dom/utils/getBoundingClientRect.js +0 -27
  51. package/v2/floating-ui/dom/utils/getClippingClientRect.js +0 -76
  52. package/v2/floating-ui/dom/utils/getComputedStyle.js +0 -4
  53. package/v2/floating-ui/dom/utils/getDimensions.js +0 -6
  54. package/v2/floating-ui/dom/utils/getDocumentElement.js +0 -4
  55. package/v2/floating-ui/dom/utils/getDocumentRect.js +0 -21
  56. package/v2/floating-ui/dom/utils/getNodeName.js +0 -4
  57. package/v2/floating-ui/dom/utils/getNodeScroll.js +0 -13
  58. package/v2/floating-ui/dom/utils/getOffsetParent.js +0 -43
  59. package/v2/floating-ui/dom/utils/getParentNode.js +0 -16
  60. package/v2/floating-ui/dom/utils/getRectRelativeToOffsetParent.js +0 -40
  61. package/v2/floating-ui/dom/utils/getScrollParent.js +0 -13
  62. package/v2/floating-ui/dom/utils/getScrollParents.js +0 -18
  63. package/v2/floating-ui/dom/utils/getViewportRect.js +0 -25
  64. package/v2/floating-ui/dom/utils/getWindowScrollBarX.js +0 -9
  65. package/v2/floating-ui/dom/utils/is.js +0 -38
  66. package/v2/floating-ui/dom/utils/math.js +0 -3
  67. package/v2/floating-ui/dom/utils/window.js +0 -13
  68. package/v2/index.js +0 -75
  69. package/v2/util/assign-deep.js +0 -12
  70. package/v2/util/env.js +0 -18
  71. package/v2/util/events.js +0 -12
  72. package/v2/util/frame.js +0 -5
  73. package/v2/util/lang.js +0 -6
  74. package/v2/util/popper.js +0 -5
@@ -1,1011 +0,0 @@
1
- import { autoPlacement, computePosition, offset, shift, flip, arrow, getScrollParents, size, } from '../floating-ui/dom/';
2
- import { supportsPassive, isIOS } from '../util/env';
3
- import { placements } from '../util/popper';
4
- import { SHOW_EVENT_MAP, HIDE_EVENT_MAP } from '../util/events';
5
- import { removeFromArray } from '../util/lang';
6
- import { nextFrame } from '../util/frame';
7
- import { getDefaultConfig, getAllParentThemes } from '../config';
8
- const shownPoppers = [];
9
- let hidingPopper = null;
10
- const shownPoppersByTheme = {};
11
- function getShownPoppersByTheme(theme) {
12
- let list = shownPoppersByTheme[theme];
13
- if (!list) {
14
- list = shownPoppersByTheme[theme] = [];
15
- }
16
- return list;
17
- }
18
- let Element = function () { };
19
- if (typeof window !== 'undefined') {
20
- Element = window.Element;
21
- }
22
- function defaultPropFactory(prop) {
23
- return function () {
24
- const props = this.$props;
25
- return getDefaultConfig(props.theme, prop);
26
- };
27
- }
28
- const PROVIDE_KEY = '__floating-vue__popper';
29
- export default () => ({
30
- name: 'VPopper',
31
- props: {
32
- theme: {
33
- type: String,
34
- required: true,
35
- },
36
- targetNodes: {
37
- type: Function,
38
- required: true,
39
- },
40
- referenceNode: {
41
- type: Function,
42
- required: true,
43
- },
44
- popperNode: {
45
- type: Function,
46
- required: true,
47
- },
48
- shown: {
49
- type: Boolean,
50
- default: false,
51
- },
52
- showGroup: {
53
- type: String,
54
- default: null,
55
- },
56
- // eslint-disable-next-line vue/require-prop-types
57
- ariaId: {
58
- default: null,
59
- },
60
- disabled: {
61
- type: Boolean,
62
- default: defaultPropFactory('disabled'),
63
- },
64
- positioningDisabled: {
65
- type: Boolean,
66
- default: defaultPropFactory('positioningDisabled'),
67
- },
68
- placement: {
69
- type: String,
70
- default: defaultPropFactory('placement'),
71
- validator: value => placements.includes(value),
72
- },
73
- delay: {
74
- type: [String, Number, Object],
75
- default: defaultPropFactory('delay'),
76
- },
77
- distance: {
78
- type: [Number, String],
79
- default: defaultPropFactory('distance'),
80
- },
81
- skidding: {
82
- type: [Number, String],
83
- default: defaultPropFactory('skidding'),
84
- },
85
- triggers: {
86
- type: Array,
87
- default: defaultPropFactory('triggers'),
88
- },
89
- showTriggers: {
90
- type: [Array, Function],
91
- default: defaultPropFactory('showTriggers'),
92
- },
93
- hideTriggers: {
94
- type: [Array, Function],
95
- default: defaultPropFactory('hideTriggers'),
96
- },
97
- popperTriggers: {
98
- type: Array,
99
- default: defaultPropFactory('popperTriggers'),
100
- },
101
- popperShowTriggers: {
102
- type: [Array, Function],
103
- default: defaultPropFactory('popperShowTriggers'),
104
- },
105
- popperHideTriggers: {
106
- type: [Array, Function],
107
- default: defaultPropFactory('popperHideTriggers'),
108
- },
109
- container: {
110
- type: [String, Object, Element, Boolean],
111
- default: defaultPropFactory('container'),
112
- },
113
- boundary: {
114
- type: [String, Element],
115
- default: defaultPropFactory('boundary'),
116
- },
117
- strategy: {
118
- type: String,
119
- validator: value => ['absolute', 'fixed'].includes(value),
120
- default: defaultPropFactory('strategy'),
121
- },
122
- autoHide: {
123
- type: [Boolean, Function],
124
- default: defaultPropFactory('autoHide'),
125
- },
126
- handleResize: {
127
- type: Boolean,
128
- default: defaultPropFactory('handleResize'),
129
- },
130
- instantMove: {
131
- type: Boolean,
132
- default: defaultPropFactory('instantMove'),
133
- },
134
- eagerMount: {
135
- type: Boolean,
136
- default: defaultPropFactory('eagerMount'),
137
- },
138
- popperClass: {
139
- type: [String, Array, Object],
140
- default: defaultPropFactory('popperClass'),
141
- },
142
- computeTransformOrigin: {
143
- type: Boolean,
144
- default: defaultPropFactory('computeTransformOrigin'),
145
- },
146
- /**
147
- * @deprecated
148
- */
149
- autoMinSize: {
150
- type: Boolean,
151
- default: defaultPropFactory('autoMinSize'),
152
- },
153
- autoSize: {
154
- type: [Boolean, String],
155
- default: defaultPropFactory('autoSize'),
156
- },
157
- /**
158
- * @deprecated
159
- */
160
- autoMaxSize: {
161
- type: Boolean,
162
- default: defaultPropFactory('autoMaxSize'),
163
- },
164
- autoBoundaryMaxSize: {
165
- type: Boolean,
166
- default: defaultPropFactory('autoBoundaryMaxSize'),
167
- },
168
- preventOverflow: {
169
- type: Boolean,
170
- default: defaultPropFactory('preventOverflow'),
171
- },
172
- overflowPadding: {
173
- type: [Number, String],
174
- default: defaultPropFactory('overflowPadding'),
175
- },
176
- arrowPadding: {
177
- type: [Number, String],
178
- default: defaultPropFactory('arrowPadding'),
179
- },
180
- arrowOverflow: {
181
- type: Boolean,
182
- default: defaultPropFactory('arrowOverflow'),
183
- },
184
- flip: {
185
- type: Boolean,
186
- default: defaultPropFactory('flip'),
187
- },
188
- shift: {
189
- type: Boolean,
190
- default: defaultPropFactory('shift'),
191
- },
192
- shiftCrossAxis: {
193
- type: Boolean,
194
- default: defaultPropFactory('shiftCrossAxis'),
195
- },
196
- noAutoFocus: {
197
- type: Boolean,
198
- default: defaultPropFactory('noAutoFocus'),
199
- },
200
- },
201
- provide() {
202
- return {
203
- [PROVIDE_KEY]: {
204
- parentPopper: this,
205
- },
206
- };
207
- },
208
- inject: {
209
- [PROVIDE_KEY]: { default: null },
210
- },
211
- data() {
212
- return {
213
- isShown: false,
214
- isMounted: false,
215
- skipTransition: false,
216
- classes: {
217
- showFrom: false,
218
- showTo: false,
219
- hideFrom: false,
220
- hideTo: true,
221
- },
222
- result: {
223
- x: 0,
224
- y: 0,
225
- placement: '',
226
- strategy: this.strategy,
227
- arrow: {
228
- x: 0,
229
- y: 0,
230
- centerOffset: 0,
231
- },
232
- transformOrigin: null,
233
- },
234
- shownChildren: new Set(),
235
- lastAutoHide: true,
236
- };
237
- },
238
- computed: {
239
- popperId() {
240
- return this.ariaId != null ? this.ariaId : this.randomId;
241
- },
242
- shouldMountContent() {
243
- return this.eagerMount || this.isMounted;
244
- },
245
- slotData() {
246
- return {
247
- popperId: this.popperId,
248
- isShown: this.isShown,
249
- shouldMountContent: this.shouldMountContent,
250
- skipTransition: this.skipTransition,
251
- autoHide: typeof this.autoHide === 'function' ? this.lastAutoHide : this.autoHide,
252
- show: this.show,
253
- hide: this.hide,
254
- handleResize: this.handleResize,
255
- onResize: this.onResize,
256
- classes: {
257
- ...this.classes,
258
- popperClass: this.popperClass,
259
- },
260
- result: this.positioningDisabled ? null : this.result,
261
- };
262
- },
263
- parentPopper() {
264
- var _a;
265
- return (_a = this[PROVIDE_KEY]) === null || _a === void 0 ? void 0 : _a.parentPopper;
266
- },
267
- hasPopperShowTriggerHover() {
268
- var _a, _b;
269
- return ((_a = this.popperTriggers) === null || _a === void 0 ? void 0 : _a.includes('hover')) || ((_b = this.popperShowTriggers) === null || _b === void 0 ? void 0 : _b.includes('hover'));
270
- },
271
- },
272
- watch: {
273
- shown: '$_autoShowHide',
274
- disabled(value) {
275
- if (value) {
276
- this.dispose();
277
- }
278
- else {
279
- this.init();
280
- }
281
- },
282
- async container() {
283
- if (this.isShown) {
284
- this.$_ensureTeleport();
285
- await this.$_computePosition();
286
- }
287
- },
288
- ...[
289
- 'triggers',
290
- 'positioningDisabled',
291
- ].reduce((acc, prop) => {
292
- acc[prop] = '$_refreshListeners';
293
- return acc;
294
- }, {}),
295
- ...[
296
- 'placement',
297
- 'distance',
298
- 'skidding',
299
- 'boundary',
300
- 'strategy',
301
- 'overflowPadding',
302
- 'arrowPadding',
303
- 'preventOverflow',
304
- 'shift',
305
- 'shiftCrossAxis',
306
- 'flip',
307
- ].reduce((acc, prop) => {
308
- acc[prop] = '$_computePosition';
309
- return acc;
310
- }, {}),
311
- },
312
- created() {
313
- this.$_isDisposed = true;
314
- this.randomId = `popper_${[Math.random(), Date.now()].map(n => n.toString(36).substring(2, 10)).join('_')}`;
315
- if (this.autoMinSize) {
316
- console.warn('[floating-vue] `autoMinSize` option is deprecated. Use `autoSize="min"` instead.');
317
- }
318
- if (this.autoMaxSize) {
319
- console.warn('[floating-vue] `autoMaxSize` option is deprecated. Use `autoBoundaryMaxSize` instead.');
320
- }
321
- },
322
- mounted() {
323
- this.init();
324
- this.$_detachPopperNode();
325
- },
326
- activated() {
327
- this.$_autoShowHide();
328
- },
329
- deactivated() {
330
- this.hide();
331
- },
332
- beforeDestroy() {
333
- this.dispose();
334
- },
335
- methods: {
336
- show({ event = null, skipDelay = false, force = false } = {}) {
337
- var _a, _b;
338
- if (((_a = this.parentPopper) === null || _a === void 0 ? void 0 : _a.lockedChild) && this.parentPopper.lockedChild !== this)
339
- return;
340
- this.$_pendingHide = false;
341
- if (force || !this.disabled) {
342
- if (((_b = this.parentPopper) === null || _b === void 0 ? void 0 : _b.lockedChild) === this) {
343
- this.parentPopper.lockedChild = null;
344
- }
345
- this.$_scheduleShow(event, skipDelay);
346
- this.$emit('show');
347
- // Prevent hiding with global handler
348
- this.$_showFrameLocked = true;
349
- requestAnimationFrame(() => {
350
- this.$_showFrameLocked = false;
351
- });
352
- }
353
- this.$emit('update:shown', true);
354
- },
355
- hide({ event = null, skipDelay = false, skipAiming = false } = {}) {
356
- var _a;
357
- if (this.$_hideInProgress)
358
- return;
359
- // Abort if child is shown
360
- if (this.shownChildren.size > 0) {
361
- this.$_pendingHide = true;
362
- return;
363
- }
364
- // Abort if aiming for the popper
365
- if (!skipAiming && this.hasPopperShowTriggerHover && this.$_isAimingPopper()) {
366
- if (this.parentPopper) {
367
- this.parentPopper.lockedChild = this;
368
- clearTimeout(this.parentPopper.lockedChildTimer);
369
- this.parentPopper.lockedChildTimer = setTimeout(() => {
370
- if (this.parentPopper.lockedChild === this) {
371
- this.parentPopper.lockedChild.hide({ skipDelay });
372
- this.parentPopper.lockedChild = null;
373
- }
374
- }, 1000);
375
- }
376
- return;
377
- }
378
- if (((_a = this.parentPopper) === null || _a === void 0 ? void 0 : _a.lockedChild) === this) {
379
- this.parentPopper.lockedChild = null;
380
- }
381
- this.$_pendingHide = false;
382
- this.$_scheduleHide(event, skipDelay);
383
- this.$emit('hide');
384
- this.$emit('update:shown', false);
385
- },
386
- init() {
387
- if (!this.$_isDisposed)
388
- return;
389
- this.$_isDisposed = false;
390
- this.isMounted = false;
391
- this.$_events = [];
392
- this.$_preventShow = false;
393
- // Nodes
394
- this.$_referenceNode = this.referenceNode();
395
- this.$_targetNodes = this.targetNodes().filter(e => e.nodeType === e.ELEMENT_NODE);
396
- this.$_popperNode = this.popperNode();
397
- this.$_innerNode = this.$_popperNode.querySelector('.v-popper__inner');
398
- this.$_arrowNode = this.$_popperNode.querySelector('.v-popper__arrow-container');
399
- this.$_swapTargetAttrs('title', 'data-original-title');
400
- this.$_detachPopperNode();
401
- if (this.triggers.length) {
402
- this.$_addEventListeners();
403
- }
404
- if (this.shown) {
405
- this.show();
406
- }
407
- },
408
- dispose() {
409
- if (this.$_isDisposed)
410
- return;
411
- this.$_isDisposed = true;
412
- this.$_removeEventListeners();
413
- this.hide({ skipDelay: true });
414
- this.$_detachPopperNode();
415
- this.isMounted = false;
416
- this.isShown = false;
417
- this.$_updateParentShownChildren(false);
418
- this.$_swapTargetAttrs('data-original-title', 'title');
419
- this.$emit('dispose');
420
- },
421
- async onResize() {
422
- if (this.isShown) {
423
- await this.$_computePosition();
424
- this.$emit('resize');
425
- }
426
- },
427
- async $_computePosition() {
428
- var _a;
429
- if (this.$_isDisposed || this.positioningDisabled)
430
- return;
431
- const options = {
432
- strategy: this.strategy,
433
- middleware: [],
434
- };
435
- // Offset
436
- if (this.distance || this.skidding) {
437
- options.middleware.push(offset({
438
- mainAxis: this.distance,
439
- crossAxis: this.skidding,
440
- }));
441
- }
442
- // Placement
443
- const isPlacementAuto = this.placement.startsWith('auto');
444
- if (isPlacementAuto) {
445
- options.middleware.push(autoPlacement({
446
- alignment: (_a = this.placement.split('-')[1]) !== null && _a !== void 0 ? _a : '',
447
- }));
448
- }
449
- else {
450
- options.placement = this.placement;
451
- }
452
- if (this.preventOverflow) {
453
- // Shift
454
- if (this.shift) {
455
- options.middleware.push(shift({
456
- padding: this.overflowPadding,
457
- boundary: this.boundary,
458
- crossAxis: this.shiftCrossAxis,
459
- }));
460
- }
461
- // Flip
462
- if (!isPlacementAuto && this.flip) {
463
- options.middleware.push(flip({
464
- padding: this.overflowPadding,
465
- boundary: this.boundary,
466
- }));
467
- }
468
- }
469
- // Arrow
470
- options.middleware.push(arrow({
471
- element: this.$_arrowNode,
472
- padding: this.arrowPadding,
473
- }));
474
- // Arrow overflow
475
- if (this.arrowOverflow) {
476
- options.middleware.push({
477
- name: 'arrowOverflow',
478
- fn: ({ placement, rects, middlewareData }) => {
479
- let overflow;
480
- const { centerOffset } = middlewareData.arrow;
481
- if (placement.startsWith('top') || placement.startsWith('bottom')) {
482
- overflow = Math.abs(centerOffset) > rects.reference.width / 2;
483
- }
484
- else {
485
- overflow = Math.abs(centerOffset) > rects.reference.height / 2;
486
- }
487
- return {
488
- data: {
489
- overflow,
490
- },
491
- };
492
- },
493
- });
494
- }
495
- // Auto min size for the popper inner
496
- if (this.autoMinSize || this.autoSize) {
497
- const autoSize = this.autoSize ? this.autoSize : this.autoMinSize ? 'min' : null;
498
- options.middleware.push({
499
- name: 'autoSize',
500
- fn: ({ rects, placement, middlewareData }) => {
501
- var _a;
502
- if ((_a = middlewareData.autoSize) === null || _a === void 0 ? void 0 : _a.skip) {
503
- return {};
504
- }
505
- let width;
506
- let height;
507
- if (placement.startsWith('top') || placement.startsWith('bottom')) {
508
- width = rects.reference.width;
509
- }
510
- else {
511
- height = rects.reference.height;
512
- }
513
- // Apply and re-compute
514
- this.$_innerNode.style[autoSize === 'min' ? 'minWidth' : autoSize === 'max' ? 'maxWidth' : 'width'] = width != null ? `${width}px` : null;
515
- this.$_innerNode.style[autoSize === 'min' ? 'minHeight' : autoSize === 'max' ? 'maxHeight' : 'height'] = height != null ? `${height}px` : null;
516
- return {
517
- data: {
518
- skip: true,
519
- },
520
- reset: {
521
- rects: true,
522
- },
523
- };
524
- },
525
- });
526
- }
527
- // Auto max size for the popper inner
528
- if (this.autoMaxSize || this.autoBoundaryMaxSize) {
529
- // Reset size to bestFit strategy can apply
530
- this.$_innerNode.style.maxWidth = null;
531
- this.$_innerNode.style.maxHeight = null;
532
- options.middleware.push(size({
533
- boundary: this.boundary,
534
- padding: this.overflowPadding,
535
- apply: ({ width, height }) => {
536
- // Apply and re-compute
537
- this.$_innerNode.style.maxWidth = width != null ? `${width}px` : null;
538
- this.$_innerNode.style.maxHeight = height != null ? `${height}px` : null;
539
- },
540
- }));
541
- }
542
- const data = await computePosition(this.$_referenceNode, this.$_popperNode, options);
543
- Object.assign(this.result, {
544
- x: data.x,
545
- y: data.y,
546
- placement: data.placement,
547
- strategy: data.strategy,
548
- arrow: {
549
- ...data.middlewareData.arrow,
550
- ...data.middlewareData.arrowOverflow,
551
- },
552
- });
553
- },
554
- $_scheduleShow(event = null, skipDelay = false) {
555
- this.$_updateParentShownChildren(true);
556
- this.$_hideInProgress = false;
557
- clearTimeout(this.$_scheduleTimer);
558
- if (hidingPopper && this.instantMove && hidingPopper.instantMove && hidingPopper !== this.parentPopper) {
559
- hidingPopper.$_applyHide(true);
560
- this.$_applyShow(true);
561
- return;
562
- }
563
- if (skipDelay) {
564
- this.$_applyShow();
565
- }
566
- else {
567
- this.$_scheduleTimer = setTimeout(this.$_applyShow.bind(this), this.$_computeDelay('show'));
568
- }
569
- },
570
- $_scheduleHide(event = null, skipDelay = false) {
571
- if (this.shownChildren.size > 0) {
572
- this.$_pendingHide = true;
573
- return;
574
- }
575
- this.$_updateParentShownChildren(false);
576
- this.$_hideInProgress = true;
577
- clearTimeout(this.$_scheduleTimer);
578
- if (this.isShown) {
579
- hidingPopper = this;
580
- }
581
- if (skipDelay) {
582
- this.$_applyHide();
583
- }
584
- else {
585
- this.$_scheduleTimer = setTimeout(this.$_applyHide.bind(this), this.$_computeDelay('hide'));
586
- }
587
- },
588
- $_computeDelay(type) {
589
- const delay = this.delay;
590
- return parseInt((delay && delay[type]) || delay || 0);
591
- },
592
- async $_applyShow(skipTransition = false) {
593
- clearTimeout(this.$_disposeTimer);
594
- clearTimeout(this.$_scheduleTimer);
595
- this.skipTransition = skipTransition;
596
- // Already shown
597
- if (this.isShown) {
598
- return;
599
- }
600
- this.$_ensureTeleport();
601
- await nextFrame();
602
- await this.$_computePosition();
603
- await this.$_applyShowEffect();
604
- // Scroll
605
- if (!this.positioningDisabled) {
606
- this.$_registerEventListeners([
607
- ...getScrollParents(this.$_referenceNode),
608
- ...getScrollParents(this.$_popperNode),
609
- ], 'scroll', () => {
610
- this.$_computePosition();
611
- });
612
- }
613
- },
614
- async $_applyShowEffect() {
615
- if (this.$_hideInProgress)
616
- return;
617
- // Advanced animations
618
- if (this.computeTransformOrigin) {
619
- const bounds = this.$_referenceNode.getBoundingClientRect();
620
- const popperWrapper = this.$_popperNode.querySelector('.v-popper__wrapper');
621
- const parentBounds = popperWrapper.parentNode.getBoundingClientRect();
622
- const x = (bounds.x + bounds.width / 2) - (parentBounds.left + popperWrapper.offsetLeft);
623
- const y = (bounds.y + bounds.height / 2) - (parentBounds.top + popperWrapper.offsetTop);
624
- this.result.transformOrigin = `${x}px ${y}px`;
625
- }
626
- this.isShown = true;
627
- this.$_applyAttrsToTarget({
628
- 'aria-describedby': this.popperId,
629
- 'data-popper-shown': '',
630
- });
631
- const showGroup = this.showGroup;
632
- if (showGroup) {
633
- let popover;
634
- for (let i = 0; i < shownPoppers.length; i++) {
635
- popover = shownPoppers[i];
636
- if (popover.showGroup !== showGroup) {
637
- popover.hide();
638
- popover.$emit('close-group');
639
- }
640
- }
641
- }
642
- shownPoppers.push(this);
643
- document.body.classList.add('v-popper--some-open');
644
- for (const theme of getAllParentThemes(this.theme)) {
645
- getShownPoppersByTheme(theme).push(this);
646
- document.body.classList.add(`v-popper--some-open--${theme}`);
647
- }
648
- this.$emit('apply-show');
649
- // Advanced classes
650
- this.classes.showFrom = true;
651
- this.classes.showTo = false;
652
- this.classes.hideFrom = false;
653
- this.classes.hideTo = false;
654
- await nextFrame();
655
- this.classes.showFrom = false;
656
- this.classes.showTo = true;
657
- if (!this.noAutoFocus)
658
- this.$_popperNode.focus();
659
- },
660
- async $_applyHide(skipTransition = false) {
661
- if (this.shownChildren.size > 0) {
662
- this.$_pendingHide = true;
663
- this.$_hideInProgress = false;
664
- return;
665
- }
666
- clearTimeout(this.$_scheduleTimer);
667
- // Already hidden
668
- if (!this.isShown) {
669
- return;
670
- }
671
- this.skipTransition = skipTransition;
672
- removeFromArray(shownPoppers, this);
673
- if (shownPoppers.length === 0) {
674
- document.body.classList.remove('v-popper--some-open');
675
- }
676
- for (const theme of getAllParentThemes(this.theme)) {
677
- const list = getShownPoppersByTheme(theme);
678
- removeFromArray(list, this);
679
- if (list.length === 0) {
680
- document.body.classList.remove(`v-popper--some-open--${theme}`);
681
- }
682
- }
683
- if (hidingPopper === this) {
684
- hidingPopper = null;
685
- }
686
- this.isShown = false;
687
- this.$_applyAttrsToTarget({
688
- 'aria-describedby': undefined,
689
- 'data-popper-shown': undefined,
690
- });
691
- clearTimeout(this.$_disposeTimer);
692
- const disposeTime = getDefaultConfig(this.theme, 'disposeTimeout');
693
- if (disposeTime !== null) {
694
- this.$_disposeTimer = setTimeout(() => {
695
- if (this.$_popperNode) {
696
- // Don't remove popper instance, just the HTML element
697
- this.$_detachPopperNode();
698
- this.isMounted = false;
699
- }
700
- }, disposeTime);
701
- }
702
- this.$_removeEventListeners('scroll');
703
- this.$emit('apply-hide');
704
- // Advanced classes
705
- this.classes.showFrom = false;
706
- this.classes.showTo = false;
707
- this.classes.hideFrom = true;
708
- this.classes.hideTo = false;
709
- await nextFrame();
710
- this.classes.hideFrom = false;
711
- this.classes.hideTo = true;
712
- },
713
- $_autoShowHide() {
714
- if (this.shown) {
715
- this.show();
716
- }
717
- else {
718
- this.hide();
719
- }
720
- },
721
- $_ensureTeleport() {
722
- if (this.$_isDisposed)
723
- return;
724
- let container = this.container;
725
- // if container is a query, get the relative element
726
- if (typeof container === 'string') {
727
- container = window.document.querySelector(container);
728
- }
729
- else if (container === false) {
730
- // if container is `false`, set it to reference parent
731
- container = this.$_targetNodes[0].parentNode;
732
- }
733
- if (!container) {
734
- throw new Error('No container for popover: ' + this.container);
735
- }
736
- container.appendChild(this.$_popperNode);
737
- this.isMounted = true;
738
- },
739
- $_addEventListeners() {
740
- // Add trigger show events
741
- const handleShow = event => {
742
- if (this.isShown && !this.$_hideInProgress) {
743
- return;
744
- }
745
- event.usedByTooltip = true;
746
- // Prevent open on mobile touch in global close
747
- !this.$_preventShow && this.show({ event });
748
- };
749
- this.$_registerTriggerListeners(this.$_targetNodes, SHOW_EVENT_MAP, this.triggers, this.showTriggers, handleShow);
750
- this.$_registerTriggerListeners([this.$_popperNode], SHOW_EVENT_MAP, this.popperTriggers, this.popperShowTriggers, handleShow);
751
- // Add trigger hide events
752
- const handleHide = (skipAiming) => event => {
753
- if (event.usedByTooltip) {
754
- return;
755
- }
756
- this.hide({ event, skipAiming });
757
- };
758
- this.$_registerTriggerListeners(this.$_targetNodes, HIDE_EVENT_MAP, this.triggers, this.hideTriggers, handleHide(false));
759
- this.$_registerTriggerListeners([this.$_popperNode], HIDE_EVENT_MAP, this.popperTriggers, this.popperHideTriggers, handleHide(true));
760
- },
761
- $_registerEventListeners(targetNodes, eventType, handler) {
762
- this.$_events.push({ targetNodes, eventType, handler });
763
- targetNodes.forEach(node => node.addEventListener(eventType, handler, supportsPassive
764
- ? {
765
- passive: true,
766
- }
767
- : undefined));
768
- },
769
- $_registerTriggerListeners(targetNodes, eventMap, commonTriggers, customTrigger, handler) {
770
- let triggers = commonTriggers;
771
- if (customTrigger != null) {
772
- triggers = typeof customTrigger === 'function' ? customTrigger(triggers) : customTrigger;
773
- }
774
- triggers.forEach(trigger => {
775
- const eventType = eventMap[trigger];
776
- if (eventType) {
777
- this.$_registerEventListeners(targetNodes, eventType, handler);
778
- }
779
- });
780
- },
781
- $_removeEventListeners(filterEventType) {
782
- const newList = [];
783
- this.$_events.forEach(listener => {
784
- const { targetNodes, eventType, handler } = listener;
785
- if (!filterEventType || filterEventType === eventType) {
786
- targetNodes.forEach(node => node.removeEventListener(eventType, handler));
787
- }
788
- else {
789
- newList.push(listener);
790
- }
791
- });
792
- this.$_events = newList;
793
- },
794
- $_refreshListeners() {
795
- if (!this.$_isDisposed) {
796
- this.$_removeEventListeners();
797
- this.$_addEventListeners();
798
- }
799
- },
800
- $_handleGlobalClose(event, touch = false) {
801
- if (this.$_showFrameLocked)
802
- return;
803
- this.hide({ event: event });
804
- if (event.closePopover) {
805
- this.$emit('close-directive');
806
- }
807
- else {
808
- this.$emit('auto-hide');
809
- }
810
- if (touch) {
811
- this.$_preventShow = true;
812
- setTimeout(() => {
813
- this.$_preventShow = false;
814
- }, 300);
815
- }
816
- },
817
- $_detachPopperNode() {
818
- this.$_popperNode.parentNode && this.$_popperNode.parentNode.removeChild(this.$_popperNode);
819
- },
820
- $_swapTargetAttrs(attrFrom, attrTo) {
821
- for (const el of this.$_targetNodes) {
822
- const value = el.getAttribute(attrFrom);
823
- if (value) {
824
- el.removeAttribute(attrFrom);
825
- el.setAttribute(attrTo, value);
826
- }
827
- }
828
- },
829
- $_applyAttrsToTarget(attrs) {
830
- for (const el of this.$_targetNodes) {
831
- for (const n in attrs) {
832
- const value = attrs[n];
833
- if (value == null) {
834
- el.removeAttribute(n);
835
- }
836
- else {
837
- el.setAttribute(n, value);
838
- }
839
- }
840
- }
841
- },
842
- $_updateParentShownChildren(value) {
843
- let parent = this.parentPopper;
844
- while (parent) {
845
- if (value) {
846
- parent.shownChildren.add(this.randomId);
847
- }
848
- else {
849
- parent.shownChildren.delete(this.randomId);
850
- if (parent.$_pendingHide) {
851
- parent.hide();
852
- }
853
- }
854
- parent = parent.parentPopper;
855
- }
856
- },
857
- $_isAimingPopper() {
858
- const referenceBounds = this.$el.getBoundingClientRect();
859
- if (mouseX >= referenceBounds.left && mouseX <= referenceBounds.right && mouseY >= referenceBounds.top && mouseY <= referenceBounds.bottom) {
860
- const popperBounds = this.$_popperNode.getBoundingClientRect();
861
- const vectorX = mouseX - mousePreviousX;
862
- const vectorY = mouseY - mousePreviousY;
863
- const distance = (popperBounds.left + popperBounds.width / 2) - mousePreviousX + (popperBounds.top + popperBounds.height / 2) - mousePreviousY;
864
- // Make the vector long enough to be sure that it can intersect with the popper
865
- const newVectorLength = distance + popperBounds.width + popperBounds.height;
866
- const edgeX = mousePreviousX + vectorX * newVectorLength;
867
- const edgeY = mousePreviousY + vectorY * newVectorLength;
868
- // Check for collision between the vector and the popper bounds
869
- return (lineIntersectsLine(mousePreviousX, mousePreviousY, edgeX, edgeY, popperBounds.left, popperBounds.top, popperBounds.left, popperBounds.bottom) || // Left edge
870
- lineIntersectsLine(mousePreviousX, mousePreviousY, edgeX, edgeY, popperBounds.left, popperBounds.top, popperBounds.right, popperBounds.top) || // Top edge
871
- lineIntersectsLine(mousePreviousX, mousePreviousY, edgeX, edgeY, popperBounds.right, popperBounds.top, popperBounds.right, popperBounds.bottom) || // Right edge
872
- lineIntersectsLine(mousePreviousX, mousePreviousY, edgeX, edgeY, popperBounds.left, popperBounds.bottom, popperBounds.right, popperBounds.bottom) // Bottom edge
873
- );
874
- }
875
- return false;
876
- },
877
- },
878
- render() {
879
- return this.$scopedSlots.default(this.slotData)[0];
880
- },
881
- });
882
- if (typeof document !== 'undefined' && typeof window !== 'undefined') {
883
- if (isIOS) {
884
- document.addEventListener('touchstart', handleGlobalMousedown, supportsPassive
885
- ? {
886
- passive: true,
887
- capture: true,
888
- }
889
- : true);
890
- document.addEventListener('touchend', handleGlobalTouchend, supportsPassive
891
- ? {
892
- passive: true,
893
- capture: true,
894
- }
895
- : true);
896
- }
897
- else {
898
- window.addEventListener('mousedown', handleGlobalMousedown, true);
899
- window.addEventListener('click', handleGlobalClick, true);
900
- }
901
- window.addEventListener('resize', computePositionAllShownPoppers);
902
- }
903
- function handleGlobalMousedown(event) {
904
- for (let i = 0; i < shownPoppers.length; i++) {
905
- const popper = shownPoppers[i];
906
- try {
907
- const popperContent = popper.popperNode();
908
- popper.$_mouseDownContains = popperContent.contains(event.target);
909
- }
910
- catch (e) {
911
- // noop
912
- }
913
- }
914
- }
915
- function handleGlobalClick(event) {
916
- handleGlobalClose(event);
917
- }
918
- function handleGlobalTouchend(event) {
919
- handleGlobalClose(event, true);
920
- }
921
- function handleGlobalClose(event, touch = false) {
922
- const preventClose = {};
923
- for (let i = shownPoppers.length - 1; i >= 0; i--) {
924
- const popper = shownPoppers[i];
925
- try {
926
- const contains = popper.$_containsGlobalTarget = isContainingEventTarget(popper, event);
927
- popper.$_pendingHide = false;
928
- // Delay so that close directive has time to set values (closeAllPopover, closePopover)
929
- requestAnimationFrame(() => {
930
- popper.$_pendingHide = false;
931
- if (preventClose[popper.randomId])
932
- return;
933
- if (shouldAutoHide(popper, contains, event)) {
934
- popper.$_handleGlobalClose(event, touch);
935
- // Only close child popper
936
- if (!event.closeAllPopover && event.closePopover && contains) {
937
- let parent = popper.parentPopper;
938
- while (parent) {
939
- preventClose[parent.randomId] = true;
940
- parent = parent.parentPopper;
941
- }
942
- return;
943
- }
944
- // Auto hide parents
945
- let parent = popper.parentPopper;
946
- while (parent) {
947
- if (shouldAutoHide(parent, parent.$_containsGlobalTarget, event)) {
948
- parent.$_handleGlobalClose(event, touch);
949
- }
950
- else {
951
- break;
952
- }
953
- parent = parent.parentPopper;
954
- }
955
- }
956
- });
957
- }
958
- catch (e) {
959
- // noop
960
- }
961
- }
962
- }
963
- function isContainingEventTarget(popper, event) {
964
- const popperContent = popper.popperNode();
965
- return popper.$_mouseDownContains || popperContent.contains(event.target);
966
- }
967
- function shouldAutoHide(popper, contains, event) {
968
- return event.closeAllPopover || (event.closePopover && contains) || (getAutoHideResult(popper, event) && !contains);
969
- }
970
- function getAutoHideResult(popper, event) {
971
- if (typeof popper.autoHide === 'function') {
972
- const result = popper.autoHide(event);
973
- popper.lastAutoHide = result;
974
- return result;
975
- }
976
- return popper.autoHide;
977
- }
978
- function computePositionAllShownPoppers(event) {
979
- for (let i = 0; i < shownPoppers.length; i++) {
980
- const popper = shownPoppers[i];
981
- popper.$_computePosition(event);
982
- }
983
- }
984
- export function hideAllPoppers() {
985
- for (let i = 0; i < shownPoppers.length; i++) {
986
- const popper = shownPoppers[i];
987
- popper.hide();
988
- }
989
- }
990
- // Track mouse movement to detect aiming at the popper
991
- let mousePreviousX = 0;
992
- let mousePreviousY = 0;
993
- let mouseX = 0;
994
- let mouseY = 0;
995
- if (typeof window !== 'undefined') {
996
- window.addEventListener('mousemove', event => {
997
- mousePreviousX = mouseX;
998
- mousePreviousY = mouseY;
999
- mouseX = event.clientX;
1000
- mouseY = event.clientY;
1001
- }, supportsPassive
1002
- ? {
1003
- passive: true,
1004
- }
1005
- : undefined);
1006
- }
1007
- function lineIntersectsLine(x1, y1, x2, y2, x3, y3, x4, y4) {
1008
- const uA = ((x4 - x3) * (y1 - y3) - (y4 - y3) * (x1 - x3)) / ((y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1));
1009
- const uB = ((x2 - x1) * (y1 - y3) - (y2 - y1) * (x1 - x3)) / ((y4 - y3) * (x2 - x1) - (x4 - x3) * (y2 - y1));
1010
- return (uA >= 0 && uA <= 1 && uB >= 0 && uB <= 1);
1011
- }