vue-tippy 6.0.0-alpha.4 → 6.0.0-alpha.43

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,9 +1,9 @@
1
1
  /*!
2
- * vue-tippy v6.0.0-alpha.3
3
- * (c) 2020 Georges KABBOUCHI
2
+ * vue-tippy v6.0.0-alpha.43
3
+ * (c) 2021
4
4
  * @license MIT
5
5
  */
6
- import { ref, getCurrentInstance, onMounted, onUnmounted, isRef, isReactive, watch, isVNode, render as render$1, h, defineComponent } from 'vue';
6
+ import { getCurrentInstance, ref, onMounted, onUnmounted, isRef, isReactive, watch, isVNode, render as render$1, h, defineComponent, nextTick, unref } from 'vue';
7
7
 
8
8
  var top = 'top';
9
9
  var bottom = 'bottom';
@@ -41,10 +41,11 @@ function getNodeName(element) {
41
41
  return element ? (element.nodeName || '').toLowerCase() : null;
42
42
  }
43
43
 
44
- /*:: import type { Window } from '../types'; */
45
-
46
- /*:: declare function getWindow(node: Node | Window): Window; */
47
44
  function getWindow(node) {
45
+ if (node == null) {
46
+ return window;
47
+ }
48
+
48
49
  if (node.toString() !== '[object Window]') {
49
50
  var ownerDocument = node.ownerDocument;
50
51
  return ownerDocument ? ownerDocument.defaultView || window : window;
@@ -53,26 +54,22 @@ function getWindow(node) {
53
54
  return node;
54
55
  }
55
56
 
56
- /*:: declare function isElement(node: mixed): boolean %checks(node instanceof
57
- Element); */
58
-
59
57
  function isElement(node) {
60
58
  var OwnElement = getWindow(node).Element;
61
59
  return node instanceof OwnElement || node instanceof Element;
62
60
  }
63
- /*:: declare function isHTMLElement(node: mixed): boolean %checks(node instanceof
64
- HTMLElement); */
65
-
66
61
 
67
62
  function isHTMLElement(node) {
68
63
  var OwnElement = getWindow(node).HTMLElement;
69
64
  return node instanceof OwnElement || node instanceof HTMLElement;
70
65
  }
71
- /*:: declare function isShadowRoot(node: mixed): boolean %checks(node instanceof
72
- ShadowRoot); */
73
-
74
66
 
75
67
  function isShadowRoot(node) {
68
+ // IE 11 has no ShadowRoot
69
+ if (typeof ShadowRoot === 'undefined') {
70
+ return false;
71
+ }
72
+
76
73
  var OwnElement = getWindow(node).ShadowRoot;
77
74
  return node instanceof OwnElement || node instanceof ShadowRoot;
78
75
  }
@@ -90,7 +87,7 @@ function applyStyles(_ref) {
90
87
  return;
91
88
  } // Flow doesn't support to extend this property, but it's the most
92
89
  // effective way to apply styles to an HTMLElement
93
- // $FlowFixMe
90
+ // $FlowFixMe[cannot-write]
94
91
 
95
92
 
96
93
  Object.assign(element.style, style);
@@ -121,6 +118,7 @@ function effect(_ref2) {
121
118
  reference: {}
122
119
  };
123
120
  Object.assign(state.elements.popper.style, initialStyles.popper);
121
+ state.styles = initialStyles;
124
122
 
125
123
  if (state.elements.arrow) {
126
124
  Object.assign(state.elements.arrow.style, initialStyles.arrow);
@@ -139,10 +137,7 @@ function effect(_ref2) {
139
137
 
140
138
  if (!isHTMLElement(element) || !getNodeName(element)) {
141
139
  return;
142
- } // Flow doesn't support to extend this property, but it's the most
143
- // effective way to apply styles to an HTMLElement
144
- // $FlowFixMe
145
-
140
+ }
146
141
 
147
142
  Object.assign(element.style, style);
148
143
  Object.keys(attributes).forEach(function (attribute) {
@@ -166,14 +161,67 @@ function getBasePlacement(placement) {
166
161
  return placement.split('-')[0];
167
162
  }
168
163
 
169
- // Returns the layout rect of an element relative to its offsetParent. Layout
164
+ var max = Math.max;
165
+ var min = Math.min;
166
+ var round = Math.round;
167
+
168
+ function getBoundingClientRect(element, includeScale) {
169
+ if (includeScale === void 0) {
170
+ includeScale = false;
171
+ }
172
+
173
+ var rect = element.getBoundingClientRect();
174
+ var scaleX = 1;
175
+ var scaleY = 1;
176
+
177
+ if (isHTMLElement(element) && includeScale) {
178
+ var offsetHeight = element.offsetHeight;
179
+ var offsetWidth = element.offsetWidth; // Do not attempt to divide by 0, otherwise we get `Infinity` as scale
180
+ // Fallback to 1 in case both values are `0`
181
+
182
+ if (offsetWidth > 0) {
183
+ scaleX = round(rect.width) / offsetWidth || 1;
184
+ }
185
+
186
+ if (offsetHeight > 0) {
187
+ scaleY = round(rect.height) / offsetHeight || 1;
188
+ }
189
+ }
190
+
191
+ return {
192
+ width: rect.width / scaleX,
193
+ height: rect.height / scaleY,
194
+ top: rect.top / scaleY,
195
+ right: rect.right / scaleX,
196
+ bottom: rect.bottom / scaleY,
197
+ left: rect.left / scaleX,
198
+ x: rect.left / scaleX,
199
+ y: rect.top / scaleY
200
+ };
201
+ }
202
+
170
203
  // means it doesn't take into account transforms.
204
+
171
205
  function getLayoutRect(element) {
206
+ var clientRect = getBoundingClientRect(element); // Use the clientRect sizes if it's not been transformed.
207
+ // Fixes https://github.com/popperjs/popper-core/issues/1223
208
+
209
+ var width = element.offsetWidth;
210
+ var height = element.offsetHeight;
211
+
212
+ if (Math.abs(clientRect.width - width) <= 1) {
213
+ width = clientRect.width;
214
+ }
215
+
216
+ if (Math.abs(clientRect.height - height) <= 1) {
217
+ height = clientRect.height;
218
+ }
219
+
172
220
  return {
173
221
  x: element.offsetLeft,
174
222
  y: element.offsetTop,
175
- width: element.offsetWidth,
176
- height: element.offsetHeight
223
+ width: width,
224
+ height: height
177
225
  };
178
226
  }
179
227
 
@@ -189,7 +237,7 @@ function contains(parent, child) {
189
237
  do {
190
238
  if (next && parent.isSameNode(next)) {
191
239
  return true;
192
- } // $FlowFixMe: need a better way to handle this...
240
+ } // $FlowFixMe[prop-missing]: need a better way to handle this...
193
241
 
194
242
 
195
243
  next = next.parentNode || next.host;
@@ -209,8 +257,9 @@ function isTableElement(element) {
209
257
  }
210
258
 
211
259
  function getDocumentElement(element) {
212
- // $FlowFixMe: assume body is always available
213
- return ((isElement(element) ? element.ownerDocument : element.document) || window.document).documentElement;
260
+ // $FlowFixMe[incompatible-return]: assume body is always available
261
+ return ((isElement(element) ? element.ownerDocument : // $FlowFixMe[prop-missing]
262
+ element.document) || window.document).documentElement;
214
263
  }
215
264
 
216
265
  function getParentNode(element) {
@@ -218,12 +267,13 @@ function getParentNode(element) {
218
267
  return element;
219
268
  }
220
269
 
221
- return (// $FlowFixMe: this is a quicker (but less type safe) way to save quite some bytes from the bundle
270
+ return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
271
+ // $FlowFixMe[incompatible-return]
272
+ // $FlowFixMe[prop-missing]
222
273
  element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
223
- element.parentNode || // DOM Element detected
224
- // $FlowFixMe: need a better way to handle this...
225
- element.host || // ShadowRoot detected
226
- // $FlowFixMe: HTMLElement is a Node
274
+ element.parentNode || ( // DOM Element detected
275
+ isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
276
+ // $FlowFixMe[incompatible-call]: HTMLElement is a Node
227
277
  getDocumentElement(element) // fallback
228
278
 
229
279
  );
@@ -235,29 +285,32 @@ function getTrueOffsetParent(element) {
235
285
  return null;
236
286
  }
237
287
 
238
- var offsetParent = element.offsetParent;
239
-
240
- if (offsetParent) {
241
- var html = getDocumentElement(offsetParent);
242
-
243
- if (getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static' && getComputedStyle(html).position !== 'static') {
244
- return html;
245
- }
246
- }
247
-
248
- return offsetParent;
288
+ return element.offsetParent;
249
289
  } // `.offsetParent` reports `null` for fixed elements, while absolute elements
250
290
  // return the containing block
251
291
 
252
292
 
253
293
  function getContainingBlock(element) {
294
+ var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') !== -1;
295
+ var isIE = navigator.userAgent.indexOf('Trident') !== -1;
296
+
297
+ if (isIE && isHTMLElement(element)) {
298
+ // In IE 9, 10 and 11 fixed elements containing block is always established by the viewport
299
+ var elementCss = getComputedStyle(element);
300
+
301
+ if (elementCss.position === 'fixed') {
302
+ return null;
303
+ }
304
+ }
305
+
254
306
  var currentNode = getParentNode(element);
255
307
 
256
308
  while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
257
309
  var css = getComputedStyle(currentNode); // This is non-exhaustive but covers the most common CSS properties that
258
310
  // create a containing block.
311
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
259
312
 
260
- if (css.transform !== 'none' || css.perspective !== 'none' || css.willChange && css.willChange !== 'auto') {
313
+ if (css.transform !== 'none' || css.perspective !== 'none' || css.contain === 'paint' || ['transform', 'perspective'].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === 'filter' || isFirefox && css.filter && css.filter !== 'none') {
261
314
  return currentNode;
262
315
  } else {
263
316
  currentNode = currentNode.parentNode;
@@ -277,7 +330,7 @@ function getOffsetParent(element) {
277
330
  offsetParent = getTrueOffsetParent(offsetParent);
278
331
  }
279
332
 
280
- if (offsetParent && getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static') {
333
+ if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static')) {
281
334
  return window;
282
335
  }
283
336
 
@@ -288,8 +341,12 @@ function getMainAxisFromPlacement(placement) {
288
341
  return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
289
342
  }
290
343
 
291
- function within(min, value, max) {
292
- return Math.max(min, Math.min(value, max));
344
+ function within(min$1, value, max$1) {
345
+ return max(min$1, min(value, max$1));
346
+ }
347
+ function withinMaxClamp(min, value, max) {
348
+ var v = within(min, value, max);
349
+ return v > max ? max : v;
293
350
  }
294
351
 
295
352
  function getFreshSideObject() {
@@ -302,7 +359,7 @@ function getFreshSideObject() {
302
359
  }
303
360
 
304
361
  function mergePaddingObject(paddingObject) {
305
- return Object.assign(Object.assign({}, getFreshSideObject()), paddingObject);
362
+ return Object.assign({}, getFreshSideObject(), paddingObject);
306
363
  }
307
364
 
308
365
  function expandToHashMap(value, keys) {
@@ -312,11 +369,19 @@ function expandToHashMap(value, keys) {
312
369
  }, {});
313
370
  }
314
371
 
372
+ var toPaddingObject = function toPaddingObject(padding, state) {
373
+ padding = typeof padding === 'function' ? padding(Object.assign({}, state.rects, {
374
+ placement: state.placement
375
+ })) : padding;
376
+ return mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
377
+ };
378
+
315
379
  function arrow(_ref) {
316
380
  var _state$modifiersData$;
317
381
 
318
382
  var state = _ref.state,
319
- name = _ref.name;
383
+ name = _ref.name,
384
+ options = _ref.options;
320
385
  var arrowElement = state.elements.arrow;
321
386
  var popperOffsets = state.modifiersData.popperOffsets;
322
387
  var basePlacement = getBasePlacement(state.placement);
@@ -328,7 +393,7 @@ function arrow(_ref) {
328
393
  return;
329
394
  }
330
395
 
331
- var paddingObject = state.modifiersData[name + "#persistent"].padding;
396
+ var paddingObject = toPaddingObject(options.padding, state);
332
397
  var arrowRect = getLayoutRect(arrowElement);
333
398
  var minProp = axis === 'y' ? top : left;
334
399
  var maxProp = axis === 'y' ? bottom : right;
@@ -350,12 +415,9 @@ function arrow(_ref) {
350
415
 
351
416
  function effect$1(_ref2) {
352
417
  var state = _ref2.state,
353
- options = _ref2.options,
354
- name = _ref2.name;
418
+ options = _ref2.options;
355
419
  var _options$element = options.element,
356
- arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element,
357
- _options$padding = options.padding,
358
- padding = _options$padding === void 0 ? 0 : _options$padding;
420
+ arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element;
359
421
 
360
422
  if (arrowElement == null) {
361
423
  return;
@@ -370,15 +432,21 @@ function effect$1(_ref2) {
370
432
  }
371
433
  }
372
434
 
435
+ if (process.env.NODE_ENV !== "production") {
436
+ if (!isHTMLElement(arrowElement)) {
437
+ console.error(['Popper: "arrow" element must be an HTMLElement (not an SVGElement).', 'To use an SVG arrow, wrap it in an HTMLElement that will be used as', 'the arrow.'].join(' '));
438
+ }
439
+ }
440
+
373
441
  if (!contains(state.elements.popper, arrowElement)) {
442
+ if (process.env.NODE_ENV !== "production") {
443
+ console.error(['Popper: "arrow" modifier\'s `element` must be a child of the popper', 'element.'].join(' '));
444
+ }
374
445
 
375
446
  return;
376
447
  }
377
448
 
378
449
  state.elements.arrow = arrowElement;
379
- state.modifiersData[name + "#persistent"] = {
380
- padding: mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements))
381
- };
382
450
  } // eslint-disable-next-line import/no-unused-modules
383
451
 
384
452
 
@@ -392,6 +460,10 @@ var arrow$1 = {
392
460
  requiresIfExists: ['preventOverflow']
393
461
  };
394
462
 
463
+ function getVariation(placement) {
464
+ return placement.split('-')[1];
465
+ }
466
+
395
467
  var unsetSides = {
396
468
  top: 'auto',
397
469
  right: 'auto',
@@ -401,14 +473,14 @@ var unsetSides = {
401
473
  // Zooming can change the DPR, but it seems to report a value that will
402
474
  // cleanly divide the values into the appropriate subpixels.
403
475
 
404
- function roundOffsets(_ref) {
476
+ function roundOffsetsByDPR(_ref) {
405
477
  var x = _ref.x,
406
478
  y = _ref.y;
407
479
  var win = window;
408
480
  var dpr = win.devicePixelRatio || 1;
409
481
  return {
410
- x: Math.round(x * dpr) / dpr || 0,
411
- y: Math.round(y * dpr) / dpr || 0
482
+ x: round(x * dpr) / dpr || 0,
483
+ y: round(y * dpr) / dpr || 0
412
484
  };
413
485
  }
414
486
 
@@ -418,14 +490,19 @@ function mapToStyles(_ref2) {
418
490
  var popper = _ref2.popper,
419
491
  popperRect = _ref2.popperRect,
420
492
  placement = _ref2.placement,
493
+ variation = _ref2.variation,
421
494
  offsets = _ref2.offsets,
422
495
  position = _ref2.position,
423
496
  gpuAcceleration = _ref2.gpuAcceleration,
424
- adaptive = _ref2.adaptive;
497
+ adaptive = _ref2.adaptive,
498
+ roundOffsets = _ref2.roundOffsets,
499
+ isFixed = _ref2.isFixed;
425
500
 
426
- var _roundOffsets = roundOffsets(offsets),
427
- x = _roundOffsets.x,
428
- y = _roundOffsets.y;
501
+ var _ref3 = roundOffsets === true ? roundOffsetsByDPR(offsets) : typeof roundOffsets === 'function' ? roundOffsets(offsets) : offsets,
502
+ _ref3$x = _ref3.x,
503
+ x = _ref3$x === void 0 ? 0 : _ref3$x,
504
+ _ref3$y = _ref3.y,
505
+ y = _ref3$y === void 0 ? 0 : _ref3$y;
429
506
 
430
507
  var hasX = offsets.hasOwnProperty('x');
431
508
  var hasY = offsets.hasOwnProperty('y');
@@ -435,23 +512,34 @@ function mapToStyles(_ref2) {
435
512
 
436
513
  if (adaptive) {
437
514
  var offsetParent = getOffsetParent(popper);
515
+ var heightProp = 'clientHeight';
516
+ var widthProp = 'clientWidth';
438
517
 
439
518
  if (offsetParent === getWindow(popper)) {
440
519
  offsetParent = getDocumentElement(popper);
441
- } // $FlowFixMe: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it
442
520
 
443
- /*:: offsetParent = (offsetParent: Element); */
521
+ if (getComputedStyle(offsetParent).position !== 'static' && position === 'absolute') {
522
+ heightProp = 'scrollHeight';
523
+ widthProp = 'scrollWidth';
524
+ }
525
+ } // $FlowFixMe[incompatible-cast]: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it
526
+
444
527
 
528
+ offsetParent = offsetParent;
445
529
 
446
- if (placement === top) {
530
+ if (placement === top || (placement === left || placement === right) && variation === end) {
447
531
  sideY = bottom;
448
- y -= offsetParent.clientHeight - popperRect.height;
532
+ var offsetY = isFixed && win.visualViewport ? win.visualViewport.height : // $FlowFixMe[prop-missing]
533
+ offsetParent[heightProp];
534
+ y -= offsetY - popperRect.height;
449
535
  y *= gpuAcceleration ? 1 : -1;
450
536
  }
451
537
 
452
- if (placement === left) {
538
+ if (placement === left || (placement === top || placement === bottom) && variation === end) {
453
539
  sideX = right;
454
- x -= offsetParent.clientWidth - popperRect.width;
540
+ var offsetX = isFixed && win.visualViewport ? win.visualViewport.width : // $FlowFixMe[prop-missing]
541
+ offsetParent[widthProp];
542
+ x -= offsetX - popperRect.width;
455
543
  x *= gpuAcceleration ? 1 : -1;
456
544
  }
457
545
  }
@@ -463,44 +551,60 @@ function mapToStyles(_ref2) {
463
551
  if (gpuAcceleration) {
464
552
  var _Object$assign;
465
553
 
466
- return Object.assign(Object.assign({}, commonStyles), {}, (_Object$assign = {}, _Object$assign[sideY] = hasY ? '0' : '', _Object$assign[sideX] = hasX ? '0' : '', _Object$assign.transform = (win.devicePixelRatio || 1) < 2 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
554
+ return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? '0' : '', _Object$assign[sideX] = hasX ? '0' : '', _Object$assign.transform = (win.devicePixelRatio || 1) <= 1 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
467
555
  }
468
556
 
469
- return Object.assign(Object.assign({}, commonStyles), {}, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
557
+ return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
470
558
  }
471
559
 
472
- function computeStyles(_ref3) {
473
- var state = _ref3.state,
474
- options = _ref3.options;
560
+ function computeStyles(_ref4) {
561
+ var state = _ref4.state,
562
+ options = _ref4.options;
475
563
  var _options$gpuAccelerat = options.gpuAcceleration,
476
564
  gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
477
565
  _options$adaptive = options.adaptive,
478
- adaptive = _options$adaptive === void 0 ? true : _options$adaptive;
566
+ adaptive = _options$adaptive === void 0 ? true : _options$adaptive,
567
+ _options$roundOffsets = options.roundOffsets,
568
+ roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
569
+
570
+ if (process.env.NODE_ENV !== "production") {
571
+ var transitionProperty = getComputedStyle(state.elements.popper).transitionProperty || '';
572
+
573
+ if (adaptive && ['transform', 'top', 'right', 'bottom', 'left'].some(function (property) {
574
+ return transitionProperty.indexOf(property) >= 0;
575
+ })) {
576
+ console.warn(['Popper: Detected CSS transitions on at least one of the following', 'CSS properties: "transform", "top", "right", "bottom", "left".', '\n\n', 'Disable the "computeStyles" modifier\'s `adaptive` option to allow', 'for smooth transitions, or remove these properties from the CSS', 'transition declaration on the popper element if only transitioning', 'opacity or background-color for example.', '\n\n', 'We recommend using the popper element as a wrapper around an inner', 'element that can have any CSS property transitioned for animations.'].join(' '));
577
+ }
578
+ }
479
579
 
480
580
  var commonStyles = {
481
581
  placement: getBasePlacement(state.placement),
582
+ variation: getVariation(state.placement),
482
583
  popper: state.elements.popper,
483
584
  popperRect: state.rects.popper,
484
- gpuAcceleration: gpuAcceleration
585
+ gpuAcceleration: gpuAcceleration,
586
+ isFixed: state.options.strategy === 'fixed'
485
587
  };
486
588
 
487
589
  if (state.modifiersData.popperOffsets != null) {
488
- state.styles.popper = Object.assign(Object.assign({}, state.styles.popper), mapToStyles(Object.assign(Object.assign({}, commonStyles), {}, {
590
+ state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
489
591
  offsets: state.modifiersData.popperOffsets,
490
592
  position: state.options.strategy,
491
- adaptive: adaptive
593
+ adaptive: adaptive,
594
+ roundOffsets: roundOffsets
492
595
  })));
493
596
  }
494
597
 
495
598
  if (state.modifiersData.arrow != null) {
496
- state.styles.arrow = Object.assign(Object.assign({}, state.styles.arrow), mapToStyles(Object.assign(Object.assign({}, commonStyles), {}, {
599
+ state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
497
600
  offsets: state.modifiersData.arrow,
498
601
  position: 'absolute',
499
- adaptive: false
602
+ adaptive: false,
603
+ roundOffsets: roundOffsets
500
604
  })));
501
605
  }
502
606
 
503
- state.attributes.popper = Object.assign(Object.assign({}, state.attributes.popper), {}, {
607
+ state.attributes.popper = Object.assign({}, state.attributes.popper, {
504
608
  'data-popper-placement': state.placement
505
609
  });
506
610
  } // eslint-disable-next-line import/no-unused-modules
@@ -584,20 +688,6 @@ function getOppositeVariationPlacement(placement) {
584
688
  });
585
689
  }
586
690
 
587
- function getBoundingClientRect(element) {
588
- var rect = element.getBoundingClientRect();
589
- return {
590
- width: rect.width,
591
- height: rect.height,
592
- top: rect.top,
593
- right: rect.right,
594
- bottom: rect.bottom,
595
- left: rect.left,
596
- x: rect.left,
597
- y: rect.top
598
- };
599
- }
600
-
601
691
  function getWindowScroll(node) {
602
692
  var win = getWindow(node);
603
693
  var scrollLeft = win.pageXOffset;
@@ -660,16 +750,18 @@ function getViewportRect(element) {
660
750
  // of the `<html>` and `<body>` rect bounds if horizontally scrollable
661
751
 
662
752
  function getDocumentRect(element) {
753
+ var _element$ownerDocumen;
754
+
663
755
  var html = getDocumentElement(element);
664
756
  var winScroll = getWindowScroll(element);
665
- var body = element.ownerDocument.body;
666
- var width = Math.max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
667
- var height = Math.max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
757
+ var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
758
+ var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
759
+ var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
668
760
  var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
669
761
  var y = -winScroll.scrollTop;
670
762
 
671
763
  if (getComputedStyle(body || html).direction === 'rtl') {
672
- x += Math.max(html.clientWidth, body ? body.clientWidth : 0) - width;
764
+ x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
673
765
  }
674
766
 
675
767
  return {
@@ -692,7 +784,7 @@ function isScrollParent(element) {
692
784
 
693
785
  function getScrollParent(node) {
694
786
  if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
695
- // $FlowFixMe: assume body is always available
787
+ // $FlowFixMe[incompatible-return]: assume body is always available
696
788
  return node.ownerDocument.body;
697
789
  }
698
790
 
@@ -706,26 +798,28 @@ function getScrollParent(node) {
706
798
  /*
707
799
  given a DOM element, return the list of all scroll parents, up the list of ancesors
708
800
  until we get to the top window object. This list is what we attach scroll listeners
709
- to, because if any of these parent elements scroll, we'll need to re-calculate the
801
+ to, because if any of these parent elements scroll, we'll need to re-calculate the
710
802
  reference element's position.
711
803
  */
712
804
 
713
805
  function listScrollParents(element, list) {
806
+ var _element$ownerDocumen;
807
+
714
808
  if (list === void 0) {
715
809
  list = [];
716
810
  }
717
811
 
718
812
  var scrollParent = getScrollParent(element);
719
- var isBody = getNodeName(scrollParent) === 'body';
813
+ var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
720
814
  var win = getWindow(scrollParent);
721
815
  var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
722
816
  var updatedList = list.concat(target);
723
- return isBody ? updatedList : // $FlowFixMe: isBody tells us target will be an HTMLElement here
817
+ return isBody ? updatedList : // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
724
818
  updatedList.concat(listScrollParents(getParentNode(target)));
725
819
  }
726
820
 
727
821
  function rectToClientRect(rect) {
728
- return Object.assign(Object.assign({}, rect), {}, {
822
+ return Object.assign({}, rect, {
729
823
  left: rect.x,
730
824
  top: rect.y,
731
825
  right: rect.x + rect.width,
@@ -747,7 +841,7 @@ function getInnerBoundingClientRect(element) {
747
841
  }
748
842
 
749
843
  function getClientRectFromMixedType(element, clippingParent) {
750
- return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isHTMLElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
844
+ return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
751
845
  } // A "clipping parent" is an overflowable container with the characteristic of
752
846
  // clipping (or hiding) overflowing elements with a position different from
753
847
  // `initial`
@@ -760,11 +854,11 @@ function getClippingParents(element) {
760
854
 
761
855
  if (!isElement(clipperElement)) {
762
856
  return [];
763
- } // $FlowFixMe: https://github.com/facebook/flow/issues/1414
857
+ } // $FlowFixMe[incompatible-return]: https://github.com/facebook/flow/issues/1414
764
858
 
765
859
 
766
860
  return clippingParents.filter(function (clippingParent) {
767
- return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';
861
+ return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body' && (canEscapeClipping ? getComputedStyle(clippingParent).position !== 'static' : true);
768
862
  });
769
863
  } // Gets the maximum area that the element is visible in due to any number of
770
864
  // clipping parents
@@ -776,10 +870,10 @@ function getClippingRect(element, boundary, rootBoundary) {
776
870
  var firstClippingParent = clippingParents[0];
777
871
  var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
778
872
  var rect = getClientRectFromMixedType(element, clippingParent);
779
- accRect.top = Math.max(rect.top, accRect.top);
780
- accRect.right = Math.min(rect.right, accRect.right);
781
- accRect.bottom = Math.min(rect.bottom, accRect.bottom);
782
- accRect.left = Math.max(rect.left, accRect.left);
873
+ accRect.top = max(rect.top, accRect.top);
874
+ accRect.right = min(rect.right, accRect.right);
875
+ accRect.bottom = min(rect.bottom, accRect.bottom);
876
+ accRect.left = max(rect.left, accRect.left);
783
877
  return accRect;
784
878
  }, getClientRectFromMixedType(element, firstClippingParent));
785
879
  clippingRect.width = clippingRect.right - clippingRect.left;
@@ -789,10 +883,6 @@ function getClippingRect(element, boundary, rootBoundary) {
789
883
  return clippingRect;
790
884
  }
791
885
 
792
- function getVariation(placement) {
793
- return placement.split('-')[1];
794
- }
795
-
796
886
  function computeOffsets(_ref) {
797
887
  var reference = _ref.reference,
798
888
  element = _ref.element,
@@ -846,11 +936,11 @@ function computeOffsets(_ref) {
846
936
 
847
937
  switch (variation) {
848
938
  case start:
849
- offsets[mainAxis] = Math.floor(offsets[mainAxis]) - Math.floor(reference[len] / 2 - element[len] / 2);
939
+ offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
850
940
  break;
851
941
 
852
942
  case end:
853
- offsets[mainAxis] = Math.floor(offsets[mainAxis]) + Math.ceil(reference[len] / 2 - element[len] / 2);
943
+ offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
854
944
  break;
855
945
  }
856
946
  }
@@ -878,18 +968,17 @@ function detectOverflow(state, options) {
878
968
  padding = _options$padding === void 0 ? 0 : _options$padding;
879
969
  var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
880
970
  var altContext = elementContext === popper ? reference : popper;
881
- var referenceElement = state.elements.reference;
882
971
  var popperRect = state.rects.popper;
883
972
  var element = state.elements[altBoundary ? altContext : elementContext];
884
973
  var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
885
- var referenceClientRect = getBoundingClientRect(referenceElement);
974
+ var referenceClientRect = getBoundingClientRect(state.elements.reference);
886
975
  var popperOffsets = computeOffsets({
887
976
  reference: referenceClientRect,
888
977
  element: popperRect,
889
978
  strategy: 'absolute',
890
979
  placement: placement
891
980
  });
892
- var popperClientRect = rectToClientRect(Object.assign(Object.assign({}, popperRect), popperOffsets));
981
+ var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets));
893
982
  var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect
894
983
  // 0 or negative = within the clipping rect
895
984
 
@@ -913,9 +1002,6 @@ function detectOverflow(state, options) {
913
1002
  return overflowOffsets;
914
1003
  }
915
1004
 
916
- /*:: type OverflowsMap = { [ComputedPlacement]: number }; */
917
-
918
- /*;; type OverflowsMap = { [key in ComputedPlacement]: number }; */
919
1005
  function computeAutoPlacement(state, options) {
920
1006
  if (options === void 0) {
921
1007
  options = {};
@@ -932,15 +1018,18 @@ function computeAutoPlacement(state, options) {
932
1018
  var variation = getVariation(placement);
933
1019
  var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function (placement) {
934
1020
  return getVariation(placement) === variation;
935
- }) : basePlacements; // $FlowFixMe
936
-
1021
+ }) : basePlacements;
937
1022
  var allowedPlacements = placements$1.filter(function (placement) {
938
1023
  return allowedAutoPlacements.indexOf(placement) >= 0;
939
1024
  });
940
1025
 
941
1026
  if (allowedPlacements.length === 0) {
942
1027
  allowedPlacements = placements$1;
943
- } // $FlowFixMe: Flow seems to have problems with two array unions...
1028
+
1029
+ if (process.env.NODE_ENV !== "production") {
1030
+ console.error(['Popper: The `allowedAutoPlacements` option did not allow any', 'placements. Ensure the `placement` option matches the variation', 'of the allowed placements.', 'For example, "auto" cannot be used to allow "bottom-start".', 'Use "auto-start" instead.'].join(' '));
1031
+ }
1032
+ } // $FlowFixMe[incompatible-type]: Flow seems to have problems with two array unions...
944
1033
 
945
1034
 
946
1035
  var overflows = allowedPlacements.reduce(function (acc, placement) {
@@ -1141,7 +1230,7 @@ function hide(_ref) {
1141
1230
  isReferenceHidden: isReferenceHidden,
1142
1231
  hasPopperEscaped: hasPopperEscaped
1143
1232
  };
1144
- state.attributes.popper = Object.assign(Object.assign({}, state.attributes.popper), {}, {
1233
+ state.attributes.popper = Object.assign({}, state.attributes.popper, {
1145
1234
  'data-popper-reference-hidden': isReferenceHidden,
1146
1235
  'data-popper-escaped': hasPopperEscaped
1147
1236
  });
@@ -1160,7 +1249,7 @@ function distanceAndSkiddingToXY(placement, rects, offset) {
1160
1249
  var basePlacement = getBasePlacement(placement);
1161
1250
  var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1;
1162
1251
 
1163
- var _ref = typeof offset === 'function' ? offset(Object.assign(Object.assign({}, rects), {}, {
1252
+ var _ref = typeof offset === 'function' ? offset(Object.assign({}, rects, {
1164
1253
  placement: placement
1165
1254
  })) : offset,
1166
1255
  skidding = _ref[0],
@@ -1266,9 +1355,17 @@ function preventOverflow(_ref) {
1266
1355
  var popperOffsets = state.modifiersData.popperOffsets;
1267
1356
  var referenceRect = state.rects.reference;
1268
1357
  var popperRect = state.rects.popper;
1269
- var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign(Object.assign({}, state.rects), {}, {
1358
+ var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, {
1270
1359
  placement: state.placement
1271
1360
  })) : tetherOffset;
1361
+ var normalizedTetherOffsetValue = typeof tetherOffsetValue === 'number' ? {
1362
+ mainAxis: tetherOffsetValue,
1363
+ altAxis: tetherOffsetValue
1364
+ } : Object.assign({
1365
+ mainAxis: 0,
1366
+ altAxis: 0
1367
+ }, tetherOffsetValue);
1368
+ var offsetModifierState = state.modifiersData.offset ? state.modifiersData.offset[state.placement] : null;
1272
1369
  var data = {
1273
1370
  x: 0,
1274
1371
  y: 0
@@ -1279,12 +1376,14 @@ function preventOverflow(_ref) {
1279
1376
  }
1280
1377
 
1281
1378
  if (checkMainAxis) {
1379
+ var _offsetModifierState$;
1380
+
1282
1381
  var mainSide = mainAxis === 'y' ? top : left;
1283
1382
  var altSide = mainAxis === 'y' ? bottom : right;
1284
1383
  var len = mainAxis === 'y' ? 'height' : 'width';
1285
1384
  var offset = popperOffsets[mainAxis];
1286
- var min = popperOffsets[mainAxis] + overflow[mainSide];
1287
- var max = popperOffsets[mainAxis] - overflow[altSide];
1385
+ var min$1 = offset + overflow[mainSide];
1386
+ var max$1 = offset - overflow[altSide];
1288
1387
  var additive = tether ? -popperRect[len] / 2 : 0;
1289
1388
  var minLen = variation === start ? referenceRect[len] : popperRect[len];
1290
1389
  var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go
@@ -1304,30 +1403,42 @@ function preventOverflow(_ref) {
1304
1403
  // width or height)
1305
1404
 
1306
1405
  var arrowLen = within(0, referenceRect[len], arrowRect[len]);
1307
- var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - tetherOffsetValue : minLen - arrowLen - arrowPaddingMin - tetherOffsetValue;
1308
- var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + tetherOffsetValue : maxLen + arrowLen + arrowPaddingMax + tetherOffsetValue;
1406
+ var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis : minLen - arrowLen - arrowPaddingMin - normalizedTetherOffsetValue.mainAxis;
1407
+ var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis : maxLen + arrowLen + arrowPaddingMax + normalizedTetherOffsetValue.mainAxis;
1309
1408
  var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow);
1310
1409
  var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0;
1311
- var offsetModifierValue = state.modifiersData.offset ? state.modifiersData.offset[state.placement][mainAxis] : 0;
1312
- var tetherMin = popperOffsets[mainAxis] + minOffset - offsetModifierValue - clientOffset;
1313
- var tetherMax = popperOffsets[mainAxis] + maxOffset - offsetModifierValue;
1314
- var preventedOffset = within(tether ? Math.min(min, tetherMin) : min, offset, tether ? Math.max(max, tetherMax) : max);
1410
+ var offsetModifierValue = (_offsetModifierState$ = offsetModifierState == null ? void 0 : offsetModifierState[mainAxis]) != null ? _offsetModifierState$ : 0;
1411
+ var tetherMin = offset + minOffset - offsetModifierValue - clientOffset;
1412
+ var tetherMax = offset + maxOffset - offsetModifierValue;
1413
+ var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1);
1315
1414
  popperOffsets[mainAxis] = preventedOffset;
1316
1415
  data[mainAxis] = preventedOffset - offset;
1317
1416
  }
1318
1417
 
1319
1418
  if (checkAltAxis) {
1419
+ var _offsetModifierState$2;
1420
+
1320
1421
  var _mainSide = mainAxis === 'x' ? top : left;
1321
1422
 
1322
1423
  var _altSide = mainAxis === 'x' ? bottom : right;
1323
1424
 
1324
1425
  var _offset = popperOffsets[altAxis];
1325
1426
 
1427
+ var _len = altAxis === 'y' ? 'height' : 'width';
1428
+
1326
1429
  var _min = _offset + overflow[_mainSide];
1327
1430
 
1328
1431
  var _max = _offset - overflow[_altSide];
1329
1432
 
1330
- var _preventedOffset = within(_min, _offset, _max);
1433
+ var isOriginSide = [top, left].indexOf(basePlacement) !== -1;
1434
+
1435
+ var _offsetModifierValue = (_offsetModifierState$2 = offsetModifierState == null ? void 0 : offsetModifierState[altAxis]) != null ? _offsetModifierState$2 : 0;
1436
+
1437
+ var _tetherMin = isOriginSide ? _min : _offset - referenceRect[_len] - popperRect[_len] - _offsetModifierValue + normalizedTetherOffsetValue.altAxis;
1438
+
1439
+ var _tetherMax = isOriginSide ? _offset + referenceRect[_len] + popperRect[_len] - _offsetModifierValue - normalizedTetherOffsetValue.altAxis : _max;
1440
+
1441
+ var _preventedOffset = tether && isOriginSide ? withinMaxClamp(_tetherMin, _offset, _tetherMax) : within(tether ? _tetherMin : _min, _offset, tether ? _tetherMax : _max);
1331
1442
 
1332
1443
  popperOffsets[altAxis] = _preventedOffset;
1333
1444
  data[altAxis] = _preventedOffset - _offset;
@@ -1360,16 +1471,24 @@ function getNodeScroll(node) {
1360
1471
  }
1361
1472
  }
1362
1473
 
1474
+ function isElementScaled(element) {
1475
+ var rect = element.getBoundingClientRect();
1476
+ var scaleX = round(rect.width) / element.offsetWidth || 1;
1477
+ var scaleY = round(rect.height) / element.offsetHeight || 1;
1478
+ return scaleX !== 1 || scaleY !== 1;
1479
+ } // Returns the composite rect of an element relative to its offsetParent.
1363
1480
  // Composite means it takes into account transforms as well as layout.
1364
1481
 
1482
+
1365
1483
  function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
1366
1484
  if (isFixed === void 0) {
1367
1485
  isFixed = false;
1368
1486
  }
1369
1487
 
1370
- var documentElement = getDocumentElement(offsetParent);
1371
- var rect = getBoundingClientRect(elementOrVirtualElement);
1372
1488
  var isOffsetParentAnElement = isHTMLElement(offsetParent);
1489
+ var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
1490
+ var documentElement = getDocumentElement(offsetParent);
1491
+ var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled);
1373
1492
  var scroll = {
1374
1493
  scrollLeft: 0,
1375
1494
  scrollTop: 0
@@ -1386,7 +1505,7 @@ function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
1386
1505
  }
1387
1506
 
1388
1507
  if (isHTMLElement(offsetParent)) {
1389
- offsets = getBoundingClientRect(offsetParent);
1508
+ offsets = getBoundingClientRect(offsetParent, true);
1390
1509
  offsets.x += offsetParent.clientLeft;
1391
1510
  offsets.y += offsetParent.clientTop;
1392
1511
  } else if (documentElement) {
@@ -1461,12 +1580,114 @@ function debounce(fn) {
1461
1580
  };
1462
1581
  }
1463
1582
 
1583
+ function format(str) {
1584
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1585
+ args[_key - 1] = arguments[_key];
1586
+ }
1587
+
1588
+ return [].concat(args).reduce(function (p, c) {
1589
+ return p.replace(/%s/, c);
1590
+ }, str);
1591
+ }
1592
+
1593
+ var INVALID_MODIFIER_ERROR = 'Popper: modifier "%s" provided an invalid %s property, expected %s but got %s';
1594
+ var MISSING_DEPENDENCY_ERROR = 'Popper: modifier "%s" requires "%s", but "%s" modifier is not available';
1595
+ var VALID_PROPERTIES = ['name', 'enabled', 'phase', 'fn', 'effect', 'requires', 'options'];
1596
+ function validateModifiers(modifiers) {
1597
+ modifiers.forEach(function (modifier) {
1598
+ [].concat(Object.keys(modifier), VALID_PROPERTIES) // IE11-compatible replacement for `new Set(iterable)`
1599
+ .filter(function (value, index, self) {
1600
+ return self.indexOf(value) === index;
1601
+ }).forEach(function (key) {
1602
+ switch (key) {
1603
+ case 'name':
1604
+ if (typeof modifier.name !== 'string') {
1605
+ console.error(format(INVALID_MODIFIER_ERROR, String(modifier.name), '"name"', '"string"', "\"" + String(modifier.name) + "\""));
1606
+ }
1607
+
1608
+ break;
1609
+
1610
+ case 'enabled':
1611
+ if (typeof modifier.enabled !== 'boolean') {
1612
+ console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"enabled"', '"boolean"', "\"" + String(modifier.enabled) + "\""));
1613
+ }
1614
+
1615
+ break;
1616
+
1617
+ case 'phase':
1618
+ if (modifierPhases.indexOf(modifier.phase) < 0) {
1619
+ console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"phase"', "either " + modifierPhases.join(', '), "\"" + String(modifier.phase) + "\""));
1620
+ }
1621
+
1622
+ break;
1623
+
1624
+ case 'fn':
1625
+ if (typeof modifier.fn !== 'function') {
1626
+ console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"fn"', '"function"', "\"" + String(modifier.fn) + "\""));
1627
+ }
1628
+
1629
+ break;
1630
+
1631
+ case 'effect':
1632
+ if (modifier.effect != null && typeof modifier.effect !== 'function') {
1633
+ console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"effect"', '"function"', "\"" + String(modifier.fn) + "\""));
1634
+ }
1635
+
1636
+ break;
1637
+
1638
+ case 'requires':
1639
+ if (modifier.requires != null && !Array.isArray(modifier.requires)) {
1640
+ console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requires"', '"array"', "\"" + String(modifier.requires) + "\""));
1641
+ }
1642
+
1643
+ break;
1644
+
1645
+ case 'requiresIfExists':
1646
+ if (!Array.isArray(modifier.requiresIfExists)) {
1647
+ console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requiresIfExists"', '"array"', "\"" + String(modifier.requiresIfExists) + "\""));
1648
+ }
1649
+
1650
+ break;
1651
+
1652
+ case 'options':
1653
+ case 'data':
1654
+ break;
1655
+
1656
+ default:
1657
+ console.error("PopperJS: an invalid property has been provided to the \"" + modifier.name + "\" modifier, valid properties are " + VALID_PROPERTIES.map(function (s) {
1658
+ return "\"" + s + "\"";
1659
+ }).join(', ') + "; but \"" + key + "\" was provided.");
1660
+ }
1661
+
1662
+ modifier.requires && modifier.requires.forEach(function (requirement) {
1663
+ if (modifiers.find(function (mod) {
1664
+ return mod.name === requirement;
1665
+ }) == null) {
1666
+ console.error(format(MISSING_DEPENDENCY_ERROR, String(modifier.name), requirement, requirement));
1667
+ }
1668
+ });
1669
+ });
1670
+ });
1671
+ }
1672
+
1673
+ function uniqueBy(arr, fn) {
1674
+ var identifiers = new Set();
1675
+ return arr.filter(function (item) {
1676
+ var identifier = fn(item);
1677
+
1678
+ if (!identifiers.has(identifier)) {
1679
+ identifiers.add(identifier);
1680
+ return true;
1681
+ }
1682
+ });
1683
+ }
1684
+
1464
1685
  function mergeByName(modifiers) {
1465
1686
  var merged = modifiers.reduce(function (merged, current) {
1466
1687
  var existing = merged[current.name];
1467
- merged[current.name] = existing ? Object.assign(Object.assign(Object.assign({}, existing), current), {}, {
1468
- options: Object.assign(Object.assign({}, existing.options), current.options),
1469
- data: Object.assign(Object.assign({}, existing.data), current.data)
1688
+ merged[current.name] = existing ? Object.assign({}, existing, current, {
1689
+ options: Object.assign({}, existing.options, current.options),
1690
+ data: Object.assign({}, existing.data, current.data)
1470
1691
  }) : current;
1471
1692
  return merged;
1472
1693
  }, {}); // IE11 does not support Object.values
@@ -1476,6 +1697,8 @@ function mergeByName(modifiers) {
1476
1697
  });
1477
1698
  }
1478
1699
 
1700
+ var INVALID_ELEMENT_ERROR = 'Popper: Invalid reference or popper argument provided. They must be either a DOM element or virtual element.';
1701
+ var INFINITE_LOOP_ERROR = 'Popper: An infinite loop in the modifiers cycle has been detected! The cycle has been interrupted to prevent a browser crash.';
1479
1702
  var DEFAULT_OPTIONS = {
1480
1703
  placement: 'bottom',
1481
1704
  modifiers: [],
@@ -1510,7 +1733,7 @@ function popperGenerator(generatorOptions) {
1510
1733
  var state = {
1511
1734
  placement: 'bottom',
1512
1735
  orderedModifiers: [],
1513
- options: Object.assign(Object.assign({}, DEFAULT_OPTIONS), defaultOptions),
1736
+ options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
1514
1737
  modifiersData: {},
1515
1738
  elements: {
1516
1739
  reference: reference,
@@ -1523,9 +1746,10 @@ function popperGenerator(generatorOptions) {
1523
1746
  var isDestroyed = false;
1524
1747
  var instance = {
1525
1748
  state: state,
1526
- setOptions: function setOptions(options) {
1749
+ setOptions: function setOptions(setOptionsAction) {
1750
+ var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction;
1527
1751
  cleanupModifierEffects();
1528
- state.options = Object.assign(Object.assign(Object.assign({}, defaultOptions), state.options), options);
1752
+ state.options = Object.assign({}, defaultOptions, state.options, options);
1529
1753
  state.scrollParents = {
1530
1754
  reference: isElement(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
1531
1755
  popper: listScrollParents(popper)
@@ -1537,6 +1761,40 @@ function popperGenerator(generatorOptions) {
1537
1761
  state.orderedModifiers = orderedModifiers.filter(function (m) {
1538
1762
  return m.enabled;
1539
1763
  }); // Validate the provided modifiers so that the consumer will get warned
1764
+ // if one of the modifiers is invalid for any reason
1765
+
1766
+ if (process.env.NODE_ENV !== "production") {
1767
+ var modifiers = uniqueBy([].concat(orderedModifiers, state.options.modifiers), function (_ref) {
1768
+ var name = _ref.name;
1769
+ return name;
1770
+ });
1771
+ validateModifiers(modifiers);
1772
+
1773
+ if (getBasePlacement(state.options.placement) === auto) {
1774
+ var flipModifier = state.orderedModifiers.find(function (_ref2) {
1775
+ var name = _ref2.name;
1776
+ return name === 'flip';
1777
+ });
1778
+
1779
+ if (!flipModifier) {
1780
+ console.error(['Popper: "auto" placements require the "flip" modifier be', 'present and enabled to work.'].join(' '));
1781
+ }
1782
+ }
1783
+
1784
+ var _getComputedStyle = getComputedStyle(popper),
1785
+ marginTop = _getComputedStyle.marginTop,
1786
+ marginRight = _getComputedStyle.marginRight,
1787
+ marginBottom = _getComputedStyle.marginBottom,
1788
+ marginLeft = _getComputedStyle.marginLeft; // We no longer take into account `margins` on the popper, and it can
1789
+ // cause bugs with positioning, so we'll warn the consumer
1790
+
1791
+
1792
+ if ([marginTop, marginRight, marginBottom, marginLeft].some(function (margin) {
1793
+ return parseFloat(margin);
1794
+ })) {
1795
+ console.warn(['Popper: CSS "margin" styles cannot be used to apply padding', 'between the popper and its reference element or boundary.', 'To replicate margin, use the `offset` modifier, as well as', 'the `padding` option in the `preventOverflow` and `flip`', 'modifiers.'].join(' '));
1796
+ }
1797
+ }
1540
1798
 
1541
1799
  runModifierEffects();
1542
1800
  return instance.update();
@@ -1557,6 +1815,9 @@ function popperGenerator(generatorOptions) {
1557
1815
  // anymore
1558
1816
 
1559
1817
  if (!areValidElements(reference, popper)) {
1818
+ if (process.env.NODE_ENV !== "production") {
1819
+ console.error(INVALID_ELEMENT_ERROR);
1820
+ }
1560
1821
 
1561
1822
  return;
1562
1823
  } // Store the reference and popper rects to be read by modifiers
@@ -1580,8 +1841,17 @@ function popperGenerator(generatorOptions) {
1580
1841
  state.orderedModifiers.forEach(function (modifier) {
1581
1842
  return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
1582
1843
  });
1844
+ var __debug_loops__ = 0;
1583
1845
 
1584
1846
  for (var index = 0; index < state.orderedModifiers.length; index++) {
1847
+ if (process.env.NODE_ENV !== "production") {
1848
+ __debug_loops__ += 1;
1849
+
1850
+ if (__debug_loops__ > 100) {
1851
+ console.error(INFINITE_LOOP_ERROR);
1852
+ break;
1853
+ }
1854
+ }
1585
1855
 
1586
1856
  if (state.reset === true) {
1587
1857
  state.reset = false;
@@ -1620,6 +1890,9 @@ function popperGenerator(generatorOptions) {
1620
1890
  };
1621
1891
 
1622
1892
  if (!areValidElements(reference, popper)) {
1893
+ if (process.env.NODE_ENV !== "production") {
1894
+ console.error(INVALID_ELEMENT_ERROR);
1895
+ }
1623
1896
 
1624
1897
  return instance;
1625
1898
  }
@@ -1673,10 +1946,12 @@ var createPopper = /*#__PURE__*/popperGenerator({
1673
1946
  }); // eslint-disable-next-line import/no-unused-modules
1674
1947
 
1675
1948
  /**!
1676
- * tippy.js v6.2.7
1677
- * (c) 2017-2020 atomiks
1949
+ * tippy.js v6.3.7
1950
+ * (c) 2017-2021 atomiks
1678
1951
  * MIT License
1679
1952
  */
1953
+
1954
+ var ROUND_ARROW = '<svg width="16" height="6" xmlns="http://www.w3.org/2000/svg"><path d="M0 6s1.796-.013 4.67-3.615C5.851.9 6.93.006 8 0c1.07-.006 2.148.887 3.343 2.385C14.233 6.005 16 6 16 6H0z"></svg>';
1680
1955
  var BOX_CLASS = "tippy-box";
1681
1956
  var CONTENT_CLASS = "tippy-content";
1682
1957
  var BACKDROP_CLASS = "tippy-backdrop";
@@ -1686,6 +1961,13 @@ var TOUCH_OPTIONS = {
1686
1961
  passive: true,
1687
1962
  capture: true
1688
1963
  };
1964
+ var TIPPY_DEFAULT_APPEND_TO = function TIPPY_DEFAULT_APPEND_TO() {
1965
+ return document.body;
1966
+ };
1967
+
1968
+ function hasOwnProperty(obj, key) {
1969
+ return {}.hasOwnProperty.call(obj, key);
1970
+ }
1689
1971
  function getValueAtIndexOrReturn(value, index, defaultValue) {
1690
1972
  if (Array.isArray(value)) {
1691
1973
  var v = value[index];
@@ -1801,10 +2083,13 @@ function setVisibilityState(els, state) {
1801
2083
  });
1802
2084
  }
1803
2085
  function getOwnerDocument(elementOrElements) {
2086
+ var _element$ownerDocumen;
2087
+
1804
2088
  var _normalizeToArray = normalizeToArray(elementOrElements),
1805
- element = _normalizeToArray[0];
2089
+ element = _normalizeToArray[0]; // Elements created via a <template> have an ownerDocument with no reference to the body
2090
+
1806
2091
 
1807
- return element ? element.ownerDocument || document : document;
2092
+ return element != null && (_element$ownerDocumen = element.ownerDocument) != null && _element$ownerDocumen.body ? element.ownerDocument : document;
1808
2093
  }
1809
2094
  function isCursorOutsideInteractiveBorder(popperTreeData, event) {
1810
2095
  var clientX = event.clientX,
@@ -1840,6 +2125,26 @@ function updateTransitionEndListener(box, action, listener) {
1840
2125
  box[method](event, listener);
1841
2126
  });
1842
2127
  }
2128
+ /**
2129
+ * Compared to xxx.contains, this function works for dom structures with shadow
2130
+ * dom
2131
+ */
2132
+
2133
+ function actualContains(parent, child) {
2134
+ var target = child;
2135
+
2136
+ while (target) {
2137
+ var _target$getRootNode;
2138
+
2139
+ if (parent.contains(target)) {
2140
+ return true;
2141
+ }
2142
+
2143
+ target = target.getRootNode == null ? void 0 : (_target$getRootNode = target.getRootNode()) == null ? void 0 : _target$getRootNode.host;
2144
+ }
2145
+
2146
+ return false;
2147
+ }
1843
2148
 
1844
2149
  var currentInput = {
1845
2150
  isTouch: false
@@ -1903,8 +2208,63 @@ function bindGlobalEventListeners() {
1903
2208
  }
1904
2209
 
1905
2210
  var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
1906
- var ua = isBrowser ? navigator.userAgent : '';
1907
- var isIE = /MSIE |Trident\//.test(ua);
2211
+ var isIE11 = isBrowser ? // @ts-ignore
2212
+ !!window.msCrypto : false;
2213
+
2214
+ function createMemoryLeakWarning(method) {
2215
+ var txt = method === 'destroy' ? 'n already-' : ' ';
2216
+ return [method + "() was called on a" + txt + "destroyed instance. This is a no-op but", 'indicates a potential memory leak.'].join(' ');
2217
+ }
2218
+ function clean(value) {
2219
+ var spacesAndTabs = /[ \t]{2,}/g;
2220
+ var lineStartWithSpaces = /^[ \t]*/gm;
2221
+ return value.replace(spacesAndTabs, ' ').replace(lineStartWithSpaces, '').trim();
2222
+ }
2223
+
2224
+ function getDevMessage(message) {
2225
+ return clean("\n %ctippy.js\n\n %c" + clean(message) + "\n\n %c\uD83D\uDC77\u200D This is a development-only message. It will be removed in production.\n ");
2226
+ }
2227
+
2228
+ function getFormattedMessage(message) {
2229
+ return [getDevMessage(message), // title
2230
+ 'color: #00C584; font-size: 1.3em; font-weight: bold;', // message
2231
+ 'line-height: 1.5', // footer
2232
+ 'color: #a6a095;'];
2233
+ } // Assume warnings and errors never have the same message
2234
+
2235
+ var visitedMessages;
2236
+
2237
+ if (process.env.NODE_ENV !== "production") {
2238
+ resetVisitedMessages();
2239
+ }
2240
+
2241
+ function resetVisitedMessages() {
2242
+ visitedMessages = new Set();
2243
+ }
2244
+ function warnWhen(condition, message) {
2245
+ if (condition && !visitedMessages.has(message)) {
2246
+ var _console;
2247
+
2248
+ visitedMessages.add(message);
2249
+
2250
+ (_console = console).warn.apply(_console, getFormattedMessage(message));
2251
+ }
2252
+ }
2253
+ function errorWhen(condition, message) {
2254
+ if (condition && !visitedMessages.has(message)) {
2255
+ var _console2;
2256
+
2257
+ visitedMessages.add(message);
2258
+
2259
+ (_console2 = console).error.apply(_console2, getFormattedMessage(message));
2260
+ }
2261
+ }
2262
+ function validateTargets(targets) {
2263
+ var didPassFalsyValue = !targets;
2264
+ var didPassPlainObject = Object.prototype.toString.call(targets) === '[object Object]' && !targets.addEventListener;
2265
+ errorWhen(didPassFalsyValue, ['tippy() was passed', '`' + String(targets) + '`', 'as its targets (first) argument. Valid types are: String, Element,', 'Element[], or NodeList.'].join(' '));
2266
+ errorWhen(didPassPlainObject, ['tippy() was passed a plain object which is not supported as an argument', 'for virtual positioning. Use props.getReferenceClientRect instead.'].join(' '));
2267
+ }
1908
2268
 
1909
2269
  var pluginProps = {
1910
2270
  animateFill: false,
@@ -1924,9 +2284,7 @@ var renderProps = {
1924
2284
  zIndex: 9999
1925
2285
  };
1926
2286
  var defaultProps = Object.assign({
1927
- appendTo: function appendTo() {
1928
- return document.body;
1929
- },
2287
+ appendTo: TIPPY_DEFAULT_APPEND_TO,
1930
2288
  aria: {
1931
2289
  content: 'auto',
1932
2290
  expanded: 'auto'
@@ -1961,9 +2319,13 @@ var defaultProps = Object.assign({
1961
2319
  touch: true,
1962
2320
  trigger: 'mouseenter focus',
1963
2321
  triggerTarget: null
1964
- }, pluginProps, {}, renderProps);
2322
+ }, pluginProps, renderProps);
1965
2323
  var defaultKeys = Object.keys(defaultProps);
1966
2324
  var setDefaultProps = function setDefaultProps(partialProps) {
2325
+ /* istanbul ignore else */
2326
+ if (process.env.NODE_ENV !== "production") {
2327
+ validateProps(partialProps, []);
2328
+ }
1967
2329
 
1968
2330
  var keys = Object.keys(partialProps);
1969
2331
  keys.forEach(function (key) {
@@ -1977,12 +2339,14 @@ function getExtendedPassedProps(passedProps) {
1977
2339
  defaultValue = plugin.defaultValue;
1978
2340
 
1979
2341
  if (name) {
1980
- acc[name] = passedProps[name] !== undefined ? passedProps[name] : defaultValue;
2342
+ var _name;
2343
+
2344
+ acc[name] = passedProps[name] !== undefined ? passedProps[name] : (_name = defaultProps[name]) != null ? _name : defaultValue;
1981
2345
  }
1982
2346
 
1983
2347
  return acc;
1984
2348
  }, {});
1985
- return Object.assign({}, passedProps, {}, pluginProps);
2349
+ return Object.assign({}, passedProps, pluginProps);
1986
2350
  }
1987
2351
  function getDataAttributeProps(reference, plugins) {
1988
2352
  var propKeys = plugins ? Object.keys(getExtendedPassedProps(Object.assign({}, defaultProps, {
@@ -2013,13 +2377,36 @@ function evaluateProps(reference, props) {
2013
2377
  var out = Object.assign({}, props, {
2014
2378
  content: invokeWithArgsOrReturn(props.content, [reference])
2015
2379
  }, props.ignoreAttributes ? {} : getDataAttributeProps(reference, props.plugins));
2016
- out.aria = Object.assign({}, defaultProps.aria, {}, out.aria);
2380
+ out.aria = Object.assign({}, defaultProps.aria, out.aria);
2017
2381
  out.aria = {
2018
2382
  expanded: out.aria.expanded === 'auto' ? props.interactive : out.aria.expanded,
2019
2383
  content: out.aria.content === 'auto' ? props.interactive ? null : 'describedby' : out.aria.content
2020
2384
  };
2021
2385
  return out;
2022
2386
  }
2387
+ function validateProps(partialProps, plugins) {
2388
+ if (partialProps === void 0) {
2389
+ partialProps = {};
2390
+ }
2391
+
2392
+ if (plugins === void 0) {
2393
+ plugins = [];
2394
+ }
2395
+
2396
+ var keys = Object.keys(partialProps);
2397
+ keys.forEach(function (prop) {
2398
+ var nonPluginProps = removeProperties(defaultProps, Object.keys(pluginProps));
2399
+ var didPassUnknownProp = !hasOwnProperty(nonPluginProps, prop); // Check if the prop exists in `plugins`
2400
+
2401
+ if (didPassUnknownProp) {
2402
+ didPassUnknownProp = plugins.filter(function (plugin) {
2403
+ return plugin.name === prop;
2404
+ }).length === 0;
2405
+ }
2406
+
2407
+ warnWhen(didPassUnknownProp, ["`" + prop + "`", "is not a valid prop. You may have spelled it incorrectly, or if it's", 'a plugin, forgot to pass it in an array as props.plugins.', '\n\n', 'All props: https://atomiks.github.io/tippyjs/v6/all-props/\n', 'Plugins: https://atomiks.github.io/tippyjs/v6/plugins/'].join(' '));
2408
+ });
2409
+ }
2023
2410
 
2024
2411
  var innerHTML = function innerHTML() {
2025
2412
  return 'innerHTML';
@@ -2151,7 +2538,7 @@ var mouseMoveListeners = []; // Used by `hideAll()`
2151
2538
 
2152
2539
  var mountedInstances = [];
2153
2540
  function createTippy(reference, passedProps) {
2154
- var props = evaluateProps(reference, Object.assign({}, defaultProps, {}, getExtendedPassedProps(removeUndefinedProps(passedProps)))); // ===========================================================================
2541
+ var props = evaluateProps(reference, Object.assign({}, defaultProps, getExtendedPassedProps(removeUndefinedProps(passedProps)))); // ===========================================================================
2155
2542
  // 🔒 Private members
2156
2543
  // ===========================================================================
2157
2544
 
@@ -2212,6 +2599,9 @@ function createTippy(reference, passedProps) {
2212
2599
  /* istanbul ignore if */
2213
2600
 
2214
2601
  if (!props.render) {
2602
+ if (process.env.NODE_ENV !== "production") {
2603
+ errorWhen(true, 'render() function has not been supplied.');
2604
+ }
2215
2605
 
2216
2606
  return instance;
2217
2607
  } // ===========================================================================
@@ -2248,10 +2638,9 @@ function createTippy(reference, passedProps) {
2248
2638
  instance.clearDelayTimeouts();
2249
2639
  }
2250
2640
  });
2251
- popper.addEventListener('mouseleave', function (event) {
2641
+ popper.addEventListener('mouseleave', function () {
2252
2642
  if (instance.props.interactive && instance.props.trigger.indexOf('mouseenter') >= 0) {
2253
2643
  getDocument().addEventListener('mousemove', debouncedOnMouseMove);
2254
- debouncedOnMouseMove(event);
2255
2644
  }
2256
2645
  });
2257
2646
  return instance; // ===========================================================================
@@ -2271,7 +2660,7 @@ function createTippy(reference, passedProps) {
2271
2660
  var _instance$props$rende;
2272
2661
 
2273
2662
  // @ts-ignore
2274
- return !!((_instance$props$rende = instance.props.render) == null ? void 0 : _instance$props$rende.$$tippy);
2663
+ return !!((_instance$props$rende = instance.props.render) != null && _instance$props$rende.$$tippy);
2275
2664
  }
2276
2665
 
2277
2666
  function getCurrentTarget() {
@@ -2298,8 +2687,12 @@ function createTippy(reference, passedProps) {
2298
2687
  return getValueAtIndexOrReturn(instance.props.delay, isShow ? 0 : 1, defaultProps.delay);
2299
2688
  }
2300
2689
 
2301
- function handleStyles() {
2302
- popper.style.pointerEvents = instance.props.interactive && instance.state.isVisible ? '' : 'none';
2690
+ function handleStyles(fromHide) {
2691
+ if (fromHide === void 0) {
2692
+ fromHide = false;
2693
+ }
2694
+
2695
+ popper.style.pointerEvents = instance.props.interactive && !fromHide ? '' : 'none';
2303
2696
  popper.style.zIndex = "" + instance.props.zIndex;
2304
2697
  }
2305
2698
 
@@ -2310,7 +2703,7 @@ function createTippy(reference, passedProps) {
2310
2703
 
2311
2704
  pluginsHooks.forEach(function (pluginHooks) {
2312
2705
  if (pluginHooks[hook]) {
2313
- pluginHooks[hook].apply(void 0, args);
2706
+ pluginHooks[hook].apply(pluginHooks, args);
2314
2707
  }
2315
2708
  });
2316
2709
 
@@ -2376,15 +2769,18 @@ function createTippy(reference, passedProps) {
2376
2769
  if (didTouchMove || event.type === 'mousedown') {
2377
2770
  return;
2378
2771
  }
2379
- } // Clicked on interactive popper
2772
+ }
2380
2773
 
2774
+ var actualTarget = event.composedPath && event.composedPath()[0] || event.target; // Clicked on interactive popper
2381
2775
 
2382
- if (instance.props.interactive && popper.contains(event.target)) {
2776
+ if (instance.props.interactive && actualContains(popper, actualTarget)) {
2383
2777
  return;
2384
2778
  } // Clicked on the event listeners target
2385
2779
 
2386
2780
 
2387
- if (getCurrentTarget().contains(event.target)) {
2781
+ if (normalizeToArray(instance.props.triggerTarget || reference).some(function (el) {
2782
+ return actualContains(el, actualTarget);
2783
+ })) {
2388
2784
  if (currentInput.isTouch) {
2389
2785
  return;
2390
2786
  }
@@ -2512,7 +2908,7 @@ function createTippy(reference, passedProps) {
2512
2908
  break;
2513
2909
 
2514
2910
  case 'focus':
2515
- on(isIE ? 'focusout' : 'blur', onBlurOrFocusOut);
2911
+ on(isIE11 ? 'focusout' : 'blur', onBlurOrFocusOut);
2516
2912
  break;
2517
2913
 
2518
2914
  case 'focusin':
@@ -2738,7 +3134,7 @@ function createTippy(reference, passedProps) {
2738
3134
 
2739
3135
  var node = getCurrentTarget();
2740
3136
 
2741
- if (instance.props.interactive && appendTo === defaultProps.appendTo || appendTo === 'parent') {
3137
+ if (instance.props.interactive && appendTo === TIPPY_DEFAULT_APPEND_TO || appendTo === 'parent') {
2742
3138
  parentNode = node.parentNode;
2743
3139
  } else {
2744
3140
  parentNode = invokeWithArgsOrReturn(appendTo, [node]);
@@ -2750,7 +3146,14 @@ function createTippy(reference, passedProps) {
2750
3146
  parentNode.appendChild(popper);
2751
3147
  }
2752
3148
 
3149
+ instance.state.isMounted = true;
2753
3150
  createPopperInstance();
3151
+ /* istanbul ignore else */
3152
+
3153
+ if (process.env.NODE_ENV !== "production") {
3154
+ // Accessibility check
3155
+ warnWhen(instance.props.interactive && appendTo === defaultProps.appendTo && node.nextElementSibling !== popper, ['Interactive tippy element may not be accessible via keyboard', 'navigation because it is not directly after the reference element', 'in the DOM source order.', '\n\n', 'Using a wrapper <div> or <span> tag around the reference element', 'solves this by creating a new parentNode context.', '\n\n', 'Specifying `appendTo: document.body` silences this warning, but it', 'assumes you are using a focus management solution to handle', 'keyboard navigation.', '\n\n', 'See: https://atomiks.github.io/tippyjs/v6/accessibility/#interactivity'].join(' '));
3156
+ }
2754
3157
  }
2755
3158
 
2756
3159
  function getNestedPopperTree() {
@@ -2839,6 +3242,10 @@ function createTippy(reference, passedProps) {
2839
3242
  }
2840
3243
 
2841
3244
  function setProps(partialProps) {
3245
+ /* istanbul ignore else */
3246
+ if (process.env.NODE_ENV !== "production") {
3247
+ warnWhen(instance.state.isDestroyed, createMemoryLeakWarning('setProps'));
3248
+ }
2842
3249
 
2843
3250
  if (instance.state.isDestroyed) {
2844
3251
  return;
@@ -2847,7 +3254,7 @@ function createTippy(reference, passedProps) {
2847
3254
  invokeHook('onBeforeUpdate', [instance, partialProps]);
2848
3255
  removeListeners();
2849
3256
  var prevProps = instance.props;
2850
- var nextProps = evaluateProps(reference, Object.assign({}, instance.props, {}, partialProps, {
3257
+ var nextProps = evaluateProps(reference, Object.assign({}, prevProps, removeUndefinedProps(partialProps), {
2851
3258
  ignoreAttributes: true
2852
3259
  }));
2853
3260
  instance.props = nextProps;
@@ -2897,6 +3304,10 @@ function createTippy(reference, passedProps) {
2897
3304
  }
2898
3305
 
2899
3306
  function show() {
3307
+ /* istanbul ignore else */
3308
+ if (process.env.NODE_ENV !== "production") {
3309
+ warnWhen(instance.state.isDestroyed, createMemoryLeakWarning('show'));
3310
+ } // Early bail-out
2900
3311
 
2901
3312
 
2902
3313
  var isAlreadyVisible = instance.state.isVisible;
@@ -2946,6 +3357,8 @@ function createTippy(reference, passedProps) {
2946
3357
  }
2947
3358
 
2948
3359
  onFirstUpdate = function onFirstUpdate() {
3360
+ var _instance$popperInsta2;
3361
+
2949
3362
  if (!instance.state.isVisible || ignoreOnFirstUpdate) {
2950
3363
  return;
2951
3364
  }
@@ -2966,8 +3379,10 @@ function createTippy(reference, passedProps) {
2966
3379
 
2967
3380
  handleAriaContentAttribute();
2968
3381
  handleAriaExpandedAttribute();
2969
- pushIfUnique(mountedInstances, instance);
2970
- instance.state.isMounted = true;
3382
+ pushIfUnique(mountedInstances, instance); // certain modifiers (e.g. `maxSize`) require a second update after the
3383
+ // popper has been positioned for the first time
3384
+
3385
+ (_instance$popperInsta2 = instance.popperInstance) == null ? void 0 : _instance$popperInsta2.forceUpdate();
2971
3386
  invokeHook('onMount', [instance]);
2972
3387
 
2973
3388
  if (instance.props.animation && getIsDefaultRenderFn()) {
@@ -2982,6 +3397,10 @@ function createTippy(reference, passedProps) {
2982
3397
  }
2983
3398
 
2984
3399
  function hide() {
3400
+ /* istanbul ignore else */
3401
+ if (process.env.NODE_ENV !== "production") {
3402
+ warnWhen(instance.state.isDestroyed, createMemoryLeakWarning('hide'));
3403
+ } // Early bail-out
2985
3404
 
2986
3405
 
2987
3406
  var isAlreadyHidden = !instance.state.isVisible;
@@ -3010,7 +3429,7 @@ function createTippy(reference, passedProps) {
3010
3429
 
3011
3430
  cleanupInteractiveMouseListeners();
3012
3431
  removeDocumentPress();
3013
- handleStyles();
3432
+ handleStyles(true);
3014
3433
 
3015
3434
  if (getIsDefaultRenderFn()) {
3016
3435
  var _getDefaultTemplateCh4 = getDefaultTemplateChildren(),
@@ -3036,6 +3455,10 @@ function createTippy(reference, passedProps) {
3036
3455
  }
3037
3456
 
3038
3457
  function hideWithInteractivity(event) {
3458
+ /* istanbul ignore else */
3459
+ if (process.env.NODE_ENV !== "production") {
3460
+ warnWhen(instance.state.isDestroyed, createMemoryLeakWarning('hideWithInteractivity'));
3461
+ }
3039
3462
 
3040
3463
  getDocument().addEventListener('mousemove', debouncedOnMouseMove);
3041
3464
  pushIfUnique(mouseMoveListeners, debouncedOnMouseMove);
@@ -3043,6 +3466,10 @@ function createTippy(reference, passedProps) {
3043
3466
  }
3044
3467
 
3045
3468
  function unmount() {
3469
+ /* istanbul ignore else */
3470
+ if (process.env.NODE_ENV !== "production") {
3471
+ warnWhen(instance.state.isDestroyed, createMemoryLeakWarning('unmount'));
3472
+ }
3046
3473
 
3047
3474
  if (instance.state.isVisible) {
3048
3475
  instance.hide();
@@ -3072,6 +3499,10 @@ function createTippy(reference, passedProps) {
3072
3499
  }
3073
3500
 
3074
3501
  function destroy() {
3502
+ /* istanbul ignore else */
3503
+ if (process.env.NODE_ENV !== "production") {
3504
+ warnWhen(instance.state.isDestroyed, createMemoryLeakWarning('destroy'));
3505
+ }
3075
3506
 
3076
3507
  if (instance.state.isDestroyed) {
3077
3508
  return;
@@ -3092,12 +3523,25 @@ function tippy(targets, optionalProps) {
3092
3523
  }
3093
3524
 
3094
3525
  var plugins = defaultProps.plugins.concat(optionalProps.plugins || []);
3526
+ /* istanbul ignore else */
3527
+
3528
+ if (process.env.NODE_ENV !== "production") {
3529
+ validateTargets(targets);
3530
+ validateProps(optionalProps, plugins);
3531
+ }
3095
3532
 
3096
3533
  bindGlobalEventListeners();
3097
3534
  var passedProps = Object.assign({}, optionalProps, {
3098
3535
  plugins: plugins
3099
3536
  });
3100
3537
  var elements = getArrayOfElements(targets);
3538
+ /* istanbul ignore else */
3539
+
3540
+ if (process.env.NODE_ENV !== "production") {
3541
+ var isSingleContentElement = isElement$1(passedProps.content);
3542
+ var isMoreThanOneReferenceElement = elements.length > 1;
3543
+ warnWhen(isSingleContentElement && isMoreThanOneReferenceElement, ['tippy() was passed an Element as the `content` prop, but more than', 'one tippy instance was created by this invocation. This means the', 'content element will only be appended to the last tippy instance.', '\n\n', 'Instead, pass the .innerHTML of the element, or use a function that', 'returns a cloned version of the element instead.', '\n\n', '1) content: element.innerHTML\n', '2) content: () => element.cloneNode(true)'].join(' '));
3544
+ }
3101
3545
 
3102
3546
  var instances = elements.reduce(function (acc, reference) {
3103
3547
  var instance = reference && createTippy(reference, passedProps);
@@ -3115,16 +3559,63 @@ tippy.defaultProps = defaultProps;
3115
3559
  tippy.setDefaultProps = setDefaultProps;
3116
3560
  tippy.currentInput = currentInput;
3117
3561
 
3562
+ // every time the popper is destroyed (i.e. a new target), removing the styles
3563
+ // and causing transitions to break for singletons when the console is open, but
3564
+ // most notably for non-transform styles being used, `gpuAcceleration: false`.
3565
+
3566
+ var applyStylesModifier = Object.assign({}, applyStyles$1, {
3567
+ effect: function effect(_ref) {
3568
+ var state = _ref.state;
3569
+ var initialStyles = {
3570
+ popper: {
3571
+ position: state.options.strategy,
3572
+ left: '0',
3573
+ top: '0',
3574
+ margin: '0'
3575
+ },
3576
+ arrow: {
3577
+ position: 'absolute'
3578
+ },
3579
+ reference: {}
3580
+ };
3581
+ Object.assign(state.elements.popper.style, initialStyles.popper);
3582
+ state.styles = initialStyles;
3583
+
3584
+ if (state.elements.arrow) {
3585
+ Object.assign(state.elements.arrow.style, initialStyles.arrow);
3586
+ } // intentionally return no cleanup function
3587
+ // return () => { ... }
3588
+
3589
+ }
3590
+ });
3591
+
3118
3592
  var createSingleton = function createSingleton(tippyInstances, optionalProps) {
3593
+ var _optionalProps$popper;
3594
+
3119
3595
  if (optionalProps === void 0) {
3120
3596
  optionalProps = {};
3121
3597
  }
3122
3598
 
3599
+ /* istanbul ignore else */
3600
+ if (process.env.NODE_ENV !== "production") {
3601
+ errorWhen(!Array.isArray(tippyInstances), ['The first argument passed to createSingleton() must be an array of', 'tippy instances. The passed value was', String(tippyInstances)].join(' '));
3602
+ }
3603
+
3123
3604
  var individualInstances = tippyInstances;
3124
3605
  var references = [];
3606
+ var triggerTargets = [];
3125
3607
  var currentTarget;
3126
3608
  var overrides = optionalProps.overrides;
3127
3609
  var interceptSetPropsCleanups = [];
3610
+ var shownOnCreate = false;
3611
+
3612
+ function setTriggerTargets() {
3613
+ triggerTargets = individualInstances.map(function (instance) {
3614
+ return normalizeToArray(instance.props.triggerTarget || instance.reference);
3615
+ }).reduce(function (acc, item) {
3616
+ return acc.concat(item);
3617
+ }, []);
3618
+ }
3128
3619
 
3129
3620
  function setReferences() {
3130
3621
  references = individualInstances.map(function (instance) {
@@ -3158,42 +3649,123 @@ var createSingleton = function createSingleton(tippyInstances, optionalProps) {
3158
3649
  instance.setProps = originalSetProps;
3159
3650
  };
3160
3651
  });
3652
+ } // have to pass singleton, as it maybe undefined on first call
3653
+
3654
+
3655
+ function prepareInstance(singleton, target) {
3656
+ var index = triggerTargets.indexOf(target); // bail-out
3657
+
3658
+ if (target === currentTarget) {
3659
+ return;
3660
+ }
3661
+
3662
+ currentTarget = target;
3663
+ var overrideProps = (overrides || []).concat('content').reduce(function (acc, prop) {
3664
+ acc[prop] = individualInstances[index].props[prop];
3665
+ return acc;
3666
+ }, {});
3667
+ singleton.setProps(Object.assign({}, overrideProps, {
3668
+ getReferenceClientRect: typeof overrideProps.getReferenceClientRect === 'function' ? overrideProps.getReferenceClientRect : function () {
3669
+ var _references$index;
3670
+
3671
+ return (_references$index = references[index]) == null ? void 0 : _references$index.getBoundingClientRect();
3672
+ }
3673
+ }));
3161
3674
  }
3162
3675
 
3163
3676
  enableInstances(false);
3164
3677
  setReferences();
3678
+ setTriggerTargets();
3165
3679
  var plugin = {
3166
3680
  fn: function fn() {
3167
3681
  return {
3168
3682
  onDestroy: function onDestroy() {
3169
3683
  enableInstances(true);
3170
3684
  },
3171
- onTrigger: function onTrigger(instance, event) {
3172
- var target = event.currentTarget;
3173
- var index = references.indexOf(target); // bail-out
3174
-
3175
- if (target === currentTarget) {
3176
- return;
3685
+ onHidden: function onHidden() {
3686
+ currentTarget = null;
3687
+ },
3688
+ onClickOutside: function onClickOutside(instance) {
3689
+ if (instance.props.showOnCreate && !shownOnCreate) {
3690
+ shownOnCreate = true;
3691
+ currentTarget = null;
3177
3692
  }
3178
-
3179
- currentTarget = target;
3180
- var overrideProps = (overrides || []).concat('content').reduce(function (acc, prop) {
3181
- acc[prop] = individualInstances[index].props[prop];
3182
- return acc;
3183
- }, {});
3184
- instance.setProps(Object.assign({}, overrideProps, {
3185
- getReferenceClientRect: typeof overrideProps.getReferenceClientRect === 'function' ? overrideProps.getReferenceClientRect : function () {
3186
- return target.getBoundingClientRect();
3187
- }
3188
- }));
3693
+ },
3694
+ onShow: function onShow(instance) {
3695
+ if (instance.props.showOnCreate && !shownOnCreate) {
3696
+ shownOnCreate = true;
3697
+ prepareInstance(instance, references[0]);
3698
+ }
3699
+ },
3700
+ onTrigger: function onTrigger(instance, event) {
3701
+ prepareInstance(instance, event.currentTarget);
3189
3702
  }
3190
3703
  };
3191
3704
  }
3192
3705
  };
3193
3706
  var singleton = tippy(div(), Object.assign({}, removeProperties(optionalProps, ['overrides']), {
3194
3707
  plugins: [plugin].concat(optionalProps.plugins || []),
3195
- triggerTarget: references
3708
+ triggerTarget: triggerTargets,
3709
+ popperOptions: Object.assign({}, optionalProps.popperOptions, {
3710
+ modifiers: [].concat(((_optionalProps$popper = optionalProps.popperOptions) == null ? void 0 : _optionalProps$popper.modifiers) || [], [applyStylesModifier])
3711
+ })
3196
3712
  }));
3713
+ var originalShow = singleton.show;
3714
+
3715
+ singleton.show = function (target) {
3716
+ originalShow(); // first time, showOnCreate or programmatic call with no params
3717
+ // default to showing first instance
3718
+
3719
+ if (!currentTarget && target == null) {
3720
+ return prepareInstance(singleton, references[0]);
3721
+ } // triggered from event (do nothing as prepareInstance already called by onTrigger)
3722
+ // programmatic call with no params when already visible (do nothing again)
3723
+
3724
+
3725
+ if (currentTarget && target == null) {
3726
+ return;
3727
+ } // target is index of instance
3728
+
3729
+
3730
+ if (typeof target === 'number') {
3731
+ return references[target] && prepareInstance(singleton, references[target]);
3732
+ } // target is a child tippy instance
3733
+
3734
+
3735
+ if (individualInstances.indexOf(target) >= 0) {
3736
+ var ref = target.reference;
3737
+ return prepareInstance(singleton, ref);
3738
+ } // target is a ReferenceElement
3739
+
3740
+
3741
+ if (references.indexOf(target) >= 0) {
3742
+ return prepareInstance(singleton, target);
3743
+ }
3744
+ };
3745
+
3746
+ singleton.showNext = function () {
3747
+ var first = references[0];
3748
+
3749
+ if (!currentTarget) {
3750
+ return singleton.show(0);
3751
+ }
3752
+
3753
+ var index = references.indexOf(currentTarget);
3754
+ singleton.show(references[index + 1] || first);
3755
+ };
3756
+
3757
+ singleton.showPrevious = function () {
3758
+ var last = references[references.length - 1];
3759
+
3760
+ if (!currentTarget) {
3761
+ return singleton.show(last);
3762
+ }
3763
+
3764
+ var index = references.indexOf(currentTarget);
3765
+ var target = references[index - 1] || last;
3766
+ singleton.show(target);
3767
+ };
3768
+
3197
3769
  var originalSetProps = singleton.setProps;
3198
3770
 
3199
3771
  singleton.setProps = function (props) {
@@ -3209,9 +3781,10 @@ var createSingleton = function createSingleton(tippyInstances, optionalProps) {
3209
3781
  individualInstances = nextInstances;
3210
3782
  enableInstances(false);
3211
3783
  setReferences();
3212
- interceptSetProps(singleton);
3784
+ setTriggerTargets();
3785
+ interceptSetPropsCleanups = interceptSetProps(singleton);
3213
3786
  singleton.setProps({
3214
- triggerTarget: references
3787
+ triggerTarget: triggerTargets
3215
3788
  });
3216
3789
  };
3217
3790
 
@@ -3226,7 +3799,10 @@ var animateFill = {
3226
3799
  var _instance$props$rende;
3227
3800
 
3228
3801
  // @ts-ignore
3229
- if (!((_instance$props$rende = instance.props.render) == null ? void 0 : _instance$props$rende.$$tippy)) {
3802
+ if (!((_instance$props$rende = instance.props.render) != null && _instance$props$rende.$$tippy)) {
3803
+ if (process.env.NODE_ENV !== "production") {
3804
+ errorWhen(instance.props.animateFill, 'The `animateFill` plugin requires the default render function.');
3805
+ }
3230
3806
 
3231
3807
  return {};
3232
3808
  }
@@ -3348,6 +3924,7 @@ var followCursor = {
3348
3924
 
3349
3925
  if (isCursorOverReference || !instance.props.interactive) {
3350
3926
  instance.setProps({
3927
+ // @ts-ignore - unneeded DOMRect properties
3351
3928
  getReferenceClientRect: function getReferenceClientRect() {
3352
3929
  var rect = reference.getBoundingClientRect();
3353
3930
  var x = clientX;
@@ -3484,6 +4061,7 @@ var inlinePositioning = {
3484
4061
  var placement;
3485
4062
  var cursorRectIndex = -1;
3486
4063
  var isInternalUpdate = false;
4064
+ var triedPlacements = [];
3487
4065
  var modifier = {
3488
4066
  name: 'tippyInlinePositioning',
3489
4067
  enabled: true,
@@ -3492,8 +4070,14 @@ var inlinePositioning = {
3492
4070
  var state = _ref2.state;
3493
4071
 
3494
4072
  if (isEnabled()) {
3495
- if (placement !== state.placement) {
4073
+ if (triedPlacements.indexOf(state.placement) !== -1) {
4074
+ triedPlacements = [];
4075
+ }
4076
+
4077
+ if (placement !== state.placement && triedPlacements.indexOf(state.placement) === -1) {
4078
+ triedPlacements.push(state.placement);
3496
4079
  instance.setProps({
4080
+ // @ts-ignore - unneeded DOMRect properties
3497
4081
  getReferenceClientRect: function getReferenceClientRect() {
3498
4082
  return _getReferenceClientRect(state.placement);
3499
4083
  }
@@ -3530,10 +4114,11 @@ var inlinePositioning = {
3530
4114
  var cursorRect = rects.find(function (rect) {
3531
4115
  return rect.left - 2 <= event.clientX && rect.right + 2 >= event.clientX && rect.top - 2 <= event.clientY && rect.bottom + 2 >= event.clientY;
3532
4116
  });
3533
- cursorRectIndex = rects.indexOf(cursorRect);
4117
+ var index = rects.indexOf(cursorRect);
4118
+ cursorRectIndex = index > -1 ? index : cursorRectIndex;
3534
4119
  }
3535
4120
  },
3536
- onUntrigger: function onUntrigger() {
4121
+ onHidden: function onHidden() {
3537
4122
  cursorRectIndex = -1;
3538
4123
  }
3539
4124
  };
@@ -3677,7 +4262,15 @@ tippy.setDefaultProps({
3677
4262
  },
3678
4263
  });
3679
4264
  function useTippy(el, opts = {}, settings = { mount: true }) {
4265
+ const vm = getCurrentInstance();
3680
4266
  const instance = ref();
4267
+ const state = ref({
4268
+ isEnabled: false,
4269
+ isVisible: false,
4270
+ isDestroyed: false,
4271
+ isMounted: false,
4272
+ isShown: false,
4273
+ });
3681
4274
  let container = null;
3682
4275
  const getContainer = () => {
3683
4276
  if (container)
@@ -3691,11 +4284,18 @@ function useTippy(el, opts = {}, settings = { mount: true }) {
3691
4284
  ? content.value
3692
4285
  : content;
3693
4286
  if (isVNode(unwrappedContent)) {
4287
+ if (vm) {
4288
+ unwrappedContent.appContext = vm.appContext;
4289
+ }
3694
4290
  render$1(unwrappedContent, getContainer());
3695
4291
  newContent = () => getContainer();
3696
4292
  }
3697
4293
  else if (typeof unwrappedContent === 'object') {
3698
- render$1(h(unwrappedContent), getContainer());
4294
+ let comp = h(unwrappedContent);
4295
+ if (vm) {
4296
+ comp.appContext = vm.appContext;
4297
+ }
4298
+ render$1(comp, getContainer());
3699
4299
  newContent = () => getContainer();
3700
4300
  }
3701
4301
  else {
@@ -3706,7 +4306,7 @@ function useTippy(el, opts = {}, settings = { mount: true }) {
3706
4306
  const getProps = (opts) => {
3707
4307
  let options = {};
3708
4308
  if (isRef(opts)) {
3709
- options = opts.value;
4309
+ options = opts.value || {};
3710
4310
  }
3711
4311
  else if (isReactive(opts)) {
3712
4312
  options = { ...opts };
@@ -3714,8 +4314,51 @@ function useTippy(el, opts = {}, settings = { mount: true }) {
3714
4314
  else {
3715
4315
  options = { ...opts };
3716
4316
  }
3717
- if (options.content)
4317
+ if (options.content) {
3718
4318
  options.content = getContent(options.content);
4319
+ }
4320
+ if (options.triggerTarget) {
4321
+ options.triggerTarget = isRef(options.triggerTarget)
4322
+ ? options.triggerTarget.value
4323
+ : options.triggerTarget;
4324
+ }
4325
+ if (!options.plugins || !Array.isArray(options.plugins)) {
4326
+ options.plugins = [];
4327
+ }
4328
+ options.plugins = options.plugins.filter((plugin) => plugin.name !== 'vueTippyReactiveState');
4329
+ options.plugins.push({
4330
+ name: 'vueTippyReactiveState',
4331
+ fn: () => {
4332
+ return {
4333
+ onCreate() {
4334
+ state.value.isEnabled = true;
4335
+ },
4336
+ onMount() {
4337
+ state.value.isMounted = true;
4338
+ },
4339
+ onShow() {
4340
+ state.value.isMounted = true;
4341
+ state.value.isVisible = true;
4342
+ },
4343
+ onShown() {
4344
+ state.value.isShown = true;
4345
+ },
4346
+ onHide() {
4347
+ state.value.isMounted = false;
4348
+ state.value.isVisible = false;
4349
+ },
4350
+ onHidden() {
4351
+ state.value.isShown = false;
4352
+ },
4353
+ onUnmounted() {
4354
+ state.value.isMounted = false;
4355
+ },
4356
+ onDestroy() {
4357
+ state.value.isDestroyed = true;
4358
+ },
4359
+ };
4360
+ }
4361
+ });
3719
4362
  return options;
3720
4363
  };
3721
4364
  const refresh = () => {
@@ -3754,10 +4397,12 @@ function useTippy(el, opts = {}, settings = { mount: true }) {
3754
4397
  const disable = () => {
3755
4398
  var _a;
3756
4399
  (_a = instance.value) === null || _a === void 0 ? void 0 : _a.disable();
4400
+ state.value.isEnabled = false;
3757
4401
  };
3758
4402
  const enable = () => {
3759
4403
  var _a;
3760
4404
  (_a = instance.value) === null || _a === void 0 ? void 0 : _a.enable();
4405
+ state.value.isEnabled = true;
3761
4406
  };
3762
4407
  const unmount = () => {
3763
4408
  var _a;
@@ -3788,9 +4433,9 @@ function useTippy(el, opts = {}, settings = { mount: true }) {
3788
4433
  enable,
3789
4434
  unmount,
3790
4435
  mount,
4436
+ state,
3791
4437
  };
3792
4438
  if (settings.mount) {
3793
- const vm = getCurrentInstance();
3794
4439
  if (vm) {
3795
4440
  if (vm.isMounted) {
3796
4441
  mount();
@@ -3815,6 +4460,46 @@ function useTippy(el, opts = {}, settings = { mount: true }) {
3815
4460
  return response;
3816
4461
  }
3817
4462
 
4463
+ function useTippyComponent(opts = {}, children) {
4464
+ const instance = ref();
4465
+ return {
4466
+ instance,
4467
+ TippyComponent: h(TippyComponent, {
4468
+ ...opts,
4469
+ onVnodeMounted: vnode => {
4470
+ //@ts-ignore
4471
+ instance.value = vnode.component.ctx;
4472
+ },
4473
+ }, children),
4474
+ };
4475
+ }
4476
+
4477
+ function useSingleton(instances, optionalProps) {
4478
+ const singleton = ref();
4479
+ onMounted(() => {
4480
+ const pendingTippyInstances = Array.isArray(instances)
4481
+ ? instances.map(i => i.value)
4482
+ : typeof instances === 'function'
4483
+ ? instances()
4484
+ : instances.value;
4485
+ const tippyInstances = pendingTippyInstances
4486
+ .map((instance) => {
4487
+ if (instance instanceof Element) {
4488
+ //@ts-ignore
4489
+ return instance._tippy;
4490
+ }
4491
+ return instance;
4492
+ })
4493
+ .filter(Boolean);
4494
+ singleton.value = createSingleton(tippyInstances, optionalProps
4495
+ ? { allowHTML: true, ...optionalProps }
4496
+ : { allowHTML: true });
4497
+ });
4498
+ return {
4499
+ singleton,
4500
+ };
4501
+ }
4502
+
3818
4503
  // const pluginProps = [
3819
4504
  // 'animateFill',
3820
4505
  // 'followCursor',
@@ -3855,50 +4540,157 @@ Object.keys(tippy.defaultProps).forEach((prop) => {
3855
4540
  };
3856
4541
  }
3857
4542
  });
4543
+ props['to'] = {};
4544
+ props['tag'] = {
4545
+ default: 'span'
4546
+ };
4547
+ props['contentTag'] = {
4548
+ default: 'span'
4549
+ };
4550
+ props['contentClass'] = {
4551
+ default: null
4552
+ };
3858
4553
  const TippyComponent = defineComponent({
3859
4554
  props,
3860
- setup(props) {
4555
+ emits: ['state'],
4556
+ setup(props, { slots, emit }) {
3861
4557
  const elem = ref();
3862
- const tippy = useTippy(elem, props);
3863
- return { elem, ...tippy };
4558
+ const contentElem = ref();
4559
+ const mounted = ref(false);
4560
+ let options = { ...props };
4561
+ for (const prop of ['to', 'tag', 'contentTag', 'contentClass']) {
4562
+ if (options.hasOwnProperty(prop)) {
4563
+ // @ts-ignore
4564
+ delete options[prop];
4565
+ }
4566
+ }
4567
+ let target = elem;
4568
+ if (props.to) {
4569
+ if (typeof Element !== 'undefined' && props.to instanceof Element) {
4570
+ target = () => props.to;
4571
+ }
4572
+ else if (typeof props.to === 'string' || props.to instanceof String) {
4573
+ target = () => document.querySelector(props.to);
4574
+ }
4575
+ }
4576
+ const tippy = useTippy(target, options);
4577
+ onMounted(() => {
4578
+ mounted.value = true;
4579
+ nextTick(() => {
4580
+ if (slots.content)
4581
+ tippy.setContent(() => contentElem.value);
4582
+ });
4583
+ });
4584
+ watch(tippy.state, () => {
4585
+ emit('state', unref(tippy.state));
4586
+ }, { immediate: true, deep: true });
4587
+ return { elem, contentElem, mounted, ...tippy };
4588
+ },
4589
+ render() {
4590
+ let slot = this.$slots.default ? this.$slots.default(this) : [];
4591
+ return h(this.tag, { ref: 'elem', 'data-v-tippy': '' }, this.$slots.content ? [
4592
+ slot,
4593
+ h(this.contentTag, { ref: 'contentElem', style: { display: this.mounted ? 'inherit' : 'none' }, class: this.contentClass }, this.$slots.content(this)),
4594
+ ] : slot);
4595
+ },
4596
+ });
4597
+
4598
+ const booleanProps$1 = [
4599
+ 'a11y',
4600
+ 'allowHTML',
4601
+ 'arrow',
4602
+ 'flip',
4603
+ 'flipOnUpdate',
4604
+ 'hideOnClick',
4605
+ 'ignoreAttributes',
4606
+ 'inertia',
4607
+ 'interactive',
4608
+ 'lazy',
4609
+ 'multiple',
4610
+ 'showOnInit',
4611
+ 'touch',
4612
+ 'touchHold',
4613
+ ];
4614
+ let props$1 = {};
4615
+ Object.keys(tippy.defaultProps).forEach((prop) => {
4616
+ if (booleanProps$1.includes(prop)) {
4617
+ props$1[prop] = {
4618
+ type: Boolean,
4619
+ default: function () {
4620
+ return tippy.defaultProps[prop];
4621
+ },
4622
+ };
4623
+ }
4624
+ else {
4625
+ props$1[prop] = {
4626
+ default: function () {
4627
+ return tippy.defaultProps[prop];
4628
+ },
4629
+ };
4630
+ }
4631
+ });
4632
+ const TippySingleton = defineComponent({
4633
+ props: props$1,
4634
+ setup(props) {
4635
+ const instances = ref([]);
4636
+ const { singleton } = useSingleton(instances, props);
4637
+ return { instances, singleton };
4638
+ },
4639
+ mounted() {
4640
+ var _a;
4641
+ const parent = this.$el.parentElement;
4642
+ const elements = parent.querySelectorAll('[data-v-tippy]');
4643
+ this.instances = Array.from(elements)
4644
+ .map((el) => el._tippy)
4645
+ .filter(Boolean);
4646
+ (_a = this.singleton) === null || _a === void 0 ? void 0 : _a.setInstances(this.instances);
3864
4647
  },
3865
4648
  render() {
3866
4649
  let slot = this.$slots.default ? this.$slots.default() : [];
3867
- return h('span', { ref: 'elem' }, slot);
4650
+ return h(() => slot);
3868
4651
  },
3869
4652
  });
3870
4653
 
3871
4654
  const directive = {
3872
4655
  mounted(el, binding, vnode) {
3873
- const opts = binding.value || {};
3874
- if (vnode.props && vnode.props.onShow) {
4656
+ const opts = typeof binding.value === "string" ? { content: binding.value } : binding.value || {};
4657
+ const modifiers = Object.keys(binding.modifiers || {});
4658
+ const placement = modifiers.find(modifier => modifier !== 'arrow');
4659
+ const withArrow = modifiers.findIndex(modifier => modifier === 'arrow') !== -1;
4660
+ if (placement) {
4661
+ opts.placement = opts.placement || placement;
4662
+ }
4663
+ if (withArrow) {
4664
+ opts.arrow = opts.arrow !== undefined ? opts.arrow : true;
4665
+ }
4666
+ if (vnode.props && vnode.props.onTippyShow) {
3875
4667
  opts.onShow = function (...args) {
3876
4668
  var _a;
3877
- return (_a = vnode.props) === null || _a === void 0 ? void 0 : _a.onShow(...args);
4669
+ return (_a = vnode.props) === null || _a === void 0 ? void 0 : _a.onTippyShow(...args);
3878
4670
  };
3879
4671
  }
3880
- if (vnode.props && vnode.props.onShown) {
4672
+ if (vnode.props && vnode.props.onTippyShown) {
3881
4673
  opts.onShown = function (...args) {
3882
4674
  var _a;
3883
- return (_a = vnode.props) === null || _a === void 0 ? void 0 : _a.onShown(...args);
4675
+ return (_a = vnode.props) === null || _a === void 0 ? void 0 : _a.onTippyShown(...args);
3884
4676
  };
3885
4677
  }
3886
- if (vnode.props && vnode.props.onHidden) {
4678
+ if (vnode.props && vnode.props.onTippyHidden) {
3887
4679
  opts.onHidden = function (...args) {
3888
4680
  var _a;
3889
- return (_a = vnode.props) === null || _a === void 0 ? void 0 : _a.onHidden(...args);
4681
+ return (_a = vnode.props) === null || _a === void 0 ? void 0 : _a.onTippyHidden(...args);
3890
4682
  };
3891
4683
  }
3892
- if (vnode.props && vnode.props.onHide) {
4684
+ if (vnode.props && vnode.props.onTippyHide) {
3893
4685
  opts.onHide = function (...args) {
3894
4686
  var _a;
3895
- return (_a = vnode.props) === null || _a === void 0 ? void 0 : _a.onHide(...args);
4687
+ return (_a = vnode.props) === null || _a === void 0 ? void 0 : _a.onTippyHide(...args);
3896
4688
  };
3897
4689
  }
3898
- if (vnode.props && vnode.props.onMount) {
4690
+ if (vnode.props && vnode.props.onTippyMount) {
3899
4691
  opts.onMount = function (...args) {
3900
4692
  var _a;
3901
- return (_a = vnode.props) === null || _a === void 0 ? void 0 : _a.onMount(...args);
4693
+ return (_a = vnode.props) === null || _a === void 0 ? void 0 : _a.onTippyMount(...args);
3902
4694
  };
3903
4695
  }
3904
4696
  if (el.getAttribute('title') && !opts.content) {
@@ -3919,7 +4711,7 @@ const directive = {
3919
4711
  }
3920
4712
  },
3921
4713
  updated(el, binding) {
3922
- const opts = binding.value || {};
4714
+ const opts = typeof binding.value === "string" ? { content: binding.value } : binding.value || {};
3923
4715
  if (el.getAttribute('title') && !opts.content) {
3924
4716
  opts.content = el.getAttribute('title');
3925
4717
  el.removeAttribute('title');
@@ -3941,65 +4733,15 @@ const plugin = {
3941
4733
  tippy.setDefaultProps(options.defaultProps || {});
3942
4734
  app.directive(options.directive || 'tippy', directive);
3943
4735
  app.component(options.component || 'tippy', TippyComponent);
4736
+ app.component(options.componentSingleton || 'tippy-singleton', TippySingleton);
3944
4737
  },
3945
4738
  };
3946
4739
 
3947
- function useSingleton(instances, optionalProps) {
3948
- const singleton = ref();
3949
- onMounted(() => {
3950
- const pendingTippyInstances = Array.isArray(instances)
3951
- ? instances.map(i => i.value)
3952
- : instances.value;
3953
- const tippyInstances = pendingTippyInstances
3954
- .map((instance) => {
3955
- if (instance instanceof Element) {
3956
- //@ts-ignore
3957
- return instance._tippy;
3958
- }
3959
- return instance;
3960
- })
3961
- .filter(Boolean);
3962
- singleton.value = createSingleton(tippyInstances, optionalProps);
3963
- });
3964
- return {
3965
- singleton,
3966
- };
3967
- }
3968
-
3969
- function styleInject(css, ref) {
3970
- if ( ref === void 0 ) ref = {};
3971
- var insertAt = ref.insertAt;
3972
-
3973
- if (!css || typeof document === 'undefined') { return; }
3974
-
3975
- var head = document.head || document.getElementsByTagName('head')[0];
3976
- var style = document.createElement('style');
3977
- style.type = 'text/css';
3978
-
3979
- if (insertAt === 'top') {
3980
- if (head.firstChild) {
3981
- head.insertBefore(style, head.firstChild);
3982
- } else {
3983
- head.appendChild(style);
3984
- }
3985
- } else {
3986
- head.appendChild(style);
3987
- }
3988
-
3989
- if (style.styleSheet) {
3990
- style.styleSheet.cssText = css;
3991
- } else {
3992
- style.appendChild(document.createTextNode(css));
3993
- }
3994
- }
3995
-
3996
- var css_248z = ".tippy-box[data-animation=fade][data-state=hidden]{opacity:0}[data-tippy-root]{max-width:calc(100vw - 10px)}.tippy-box{position:relative;background-color:#333;color:#fff;border-radius:4px;font-size:14px;line-height:1.4;outline:0;transition-property:transform,visibility,opacity}.tippy-box[data-placement^=top]>.tippy-arrow{bottom:0}.tippy-box[data-placement^=top]>.tippy-arrow:before{bottom:-7px;left:0;border-width:8px 8px 0;border-top-color:initial;transform-origin:center top}.tippy-box[data-placement^=bottom]>.tippy-arrow{top:0}.tippy-box[data-placement^=bottom]>.tippy-arrow:before{top:-7px;left:0;border-width:0 8px 8px;border-bottom-color:initial;transform-origin:center bottom}.tippy-box[data-placement^=left]>.tippy-arrow{right:0}.tippy-box[data-placement^=left]>.tippy-arrow:before{border-width:8px 0 8px 8px;border-left-color:initial;right:-7px;transform-origin:center left}.tippy-box[data-placement^=right]>.tippy-arrow{left:0}.tippy-box[data-placement^=right]>.tippy-arrow:before{left:-7px;border-width:8px 8px 8px 0;border-right-color:initial;transform-origin:center right}.tippy-box[data-inertia][data-state=visible]{transition-timing-function:cubic-bezier(.54,1.5,.38,1.11)}.tippy-arrow{width:16px;height:16px;color:#333}.tippy-arrow:before{content:\"\";position:absolute;border-color:transparent;border-style:solid}.tippy-content{position:relative;padding:5px 9px;z-index:1}";
3997
- styleInject(css_248z);
3998
-
3999
4740
  const setDefaultProps$1 = tippy.setDefaultProps;
4000
4741
  setDefaultProps$1({
4742
+ ignoreAttributes: true,
4001
4743
  plugins: [sticky, inlinePositioning, followCursor, animateFill],
4002
4744
  });
4003
4745
 
4004
4746
  export default plugin;
4005
- export { TippyComponent as Tippy, directive, setDefaultProps$1 as setDefaultProps, tippy, useSingleton, useTippy };
4747
+ export { TippyComponent as Tippy, TippySingleton, directive, plugin, ROUND_ARROW as roundArrow, setDefaultProps$1 as setDefaultProps, tippy, useSingleton, useTippy, useTippyComponent };