PluginProbe
Booking Calendar / 11.9
Booking Calendar v11.9
11.9 11.8.4 11.8.3 11.8.2 11.8.1 11.8 11.7 11.6.1 11.6 11.5 11.4.3 11.4.2 11.4.1 11.4 11.3 11.2.1 11.2 11.1 11.0 10.15.7 10.15.6 10.1.3 10.10 10.10.1 10.10.2 All 205 releases
booking / vendors / _custom / tippy.js / dist / tippy-bundle.umd.js

tippy-bundle.umd.js in Booking Calendar 11.9, at vendors/_custom/tippy.js/dist/tippy-bundle.umd.js

2,519 lines 78.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**!
2 * tippy.js v6.3.7
3 * (c) 2017-2021 atomiks
4 * MIT License
5 *
6 * Docs: https://atomiks.github.io/tippyjs/v6/all-props/
7 */
8 (function (global, factory) {
9 typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@popperjs/core')) :
10 typeof define === 'function' && define.amd ? define(['@popperjs/core'], factory) :
11 (global = global || self, global.wpbc_tippy = factory(global.wpbc_Popper));
12 }(this, (function (core) { 'use strict';
13
14 var css = ".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;white-space:normal;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}";
15
16 function injectCSS(css) {
17 var style = document.createElement('style');
18 style.textContent = css;
19 style.setAttribute('data-tippy-stylesheet', '');
20 var head = document.head;
21 var firstStyleOrLinkTag = document.querySelector('head>style,head>link');
22
23 if (firstStyleOrLinkTag) {
24 head.insertBefore(style, firstStyleOrLinkTag);
25 } else {
26 head.appendChild(style);
27 }
28 }
29
30 var isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined';
31 var isIE11 = isBrowser ? // @ts-ignore
32 !!window.msCrypto : false;
33
34 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>';
35 var BOX_CLASS = "tippy-box";
36 var CONTENT_CLASS = "tippy-content";
37 var BACKDROP_CLASS = "tippy-backdrop";
38 var ARROW_CLASS = "tippy-arrow";
39 var SVG_ARROW_CLASS = "tippy-svg-arrow";
40 var TOUCH_OPTIONS = {
41 passive: true,
42 capture: true
43 };
44 var TIPPY_DEFAULT_APPEND_TO = function TIPPY_DEFAULT_APPEND_TO() {
45 return document.body;
46 };
47
48 function hasOwnProperty(obj, key) {
49 return {}.hasOwnProperty.call(obj, key);
50 }
51 function getValueAtIndexOrReturn(value, index, defaultValue) {
52 if (Array.isArray(value)) {
53 var v = value[index];
54 return v == null ? Array.isArray(defaultValue) ? defaultValue[index] : defaultValue : v;
55 }
56
57 return value;
58 }
59 function isType(value, type) {
60 var str = {}.toString.call(value);
61 return str.indexOf('[object') === 0 && str.indexOf(type + "]") > -1;
62 }
63 function invokeWithArgsOrReturn(value, args) {
64 return typeof value === 'function' ? value.apply(void 0, args) : value;
65 }
66 function debounce(fn, ms) {
67 // Avoid wrapping in `setTimeout` if ms is 0 anyway
68 if (ms === 0) {
69 return fn;
70 }
71
72 var timeout;
73 return function (arg) {
74 clearTimeout(timeout);
75 timeout = setTimeout(function () {
76 fn(arg);
77 }, ms);
78 };
79 }
80 function removeProperties(obj, keys) {
81 var clone = Object.assign({}, obj);
82 keys.forEach(function (key) {
83 delete clone[key];
84 });
85 return clone;
86 }
87 function splitBySpaces(value) {
88 return value.split(/\s+/).filter(Boolean);
89 }
90 function normalizeToArray(value) {
91 return [].concat(value);
92 }
93 function pushIfUnique(arr, value) {
94 if (arr.indexOf(value) === -1) {
95 arr.push(value);
96 }
97 }
98 function unique(arr) {
99 return arr.filter(function (item, index) {
100 return arr.indexOf(item) === index;
101 });
102 }
103 function getBasePlacement(placement) {
104 return placement.split('-')[0];
105 }
106 function arrayFrom(value) {
107 return [].slice.call(value);
108 }
109 function removeUndefinedProps(obj) {
110 return Object.keys(obj).reduce(function (acc, key) {
111 if (obj[key] !== undefined) {
112 acc[key] = obj[key];
113 }
114
115 return acc;
116 }, {});
117 }
118
119 function div() {
120 return document.createElement('div');
121 }
122 function isElement(value) {
123 return ['Element', 'Fragment'].some(function (type) {
124 return isType(value, type);
125 });
126 }
127 function isNodeList(value) {
128 return isType(value, 'NodeList');
129 }
130 function isMouseEvent(value) {
131 return isType(value, 'MouseEvent');
132 }
133 function isReferenceElement(value) {
134 return !!(value && value._tippy && value._tippy.reference === value);
135 }
136 function getArrayOfElements(value) {
137 if (isElement(value)) {
138 return [value];
139 }
140
141 if (isNodeList(value)) {
142 return arrayFrom(value);
143 }
144
145 if (Array.isArray(value)) {
146 return value;
147 }
148
149 return arrayFrom(document.querySelectorAll(value));
150 }
151 function setTransitionDuration(els, value) {
152 els.forEach(function (el) {
153 if (el) {
154 el.style.transitionDuration = value + "ms";
155 }
156 });
157 }
158 function setVisibilityState(els, state) {
159 els.forEach(function (el) {
160 if (el) {
161 el.setAttribute('data-state', state);
162 }
163 });
164 }
165 function getOwnerDocument(elementOrElements) {
166 var _element$ownerDocumen;
167
168 var _normalizeToArray = normalizeToArray(elementOrElements),
169 element = _normalizeToArray[0]; // Elements created via a <template> have an ownerDocument with no reference to the body
170
171
172 return element != null && (_element$ownerDocumen = element.ownerDocument) != null && _element$ownerDocumen.body ? element.ownerDocument : document;
173 }
174 function isCursorOutsideInteractiveBorder(popperTreeData, event) {
175 var clientX = event.clientX,
176 clientY = event.clientY;
177 return popperTreeData.every(function (_ref) {
178 var popperRect = _ref.popperRect,
179 popperState = _ref.popperState,
180 props = _ref.props;
181 var interactiveBorder = props.interactiveBorder;
182 var basePlacement = getBasePlacement(popperState.placement);
183 var offsetData = popperState.modifiersData.offset;
184
185 if (!offsetData) {
186 return true;
187 }
188
189 var topDistance = basePlacement === 'bottom' ? offsetData.top.y : 0;
190 var bottomDistance = basePlacement === 'top' ? offsetData.bottom.y : 0;
191 var leftDistance = basePlacement === 'right' ? offsetData.left.x : 0;
192 var rightDistance = basePlacement === 'left' ? offsetData.right.x : 0;
193 var exceedsTop = popperRect.top - clientY + topDistance > interactiveBorder;
194 var exceedsBottom = clientY - popperRect.bottom - bottomDistance > interactiveBorder;
195 var exceedsLeft = popperRect.left - clientX + leftDistance > interactiveBorder;
196 var exceedsRight = clientX - popperRect.right - rightDistance > interactiveBorder;
197 return exceedsTop || exceedsBottom || exceedsLeft || exceedsRight;
198 });
199 }
200 function updateTransitionEndListener(box, action, listener) {
201 var method = action + "EventListener"; // some browsers apparently support `transition` (unprefixed) but only fire
202 // `webkitTransitionEnd`...
203
204 ['transitionend', 'webkitTransitionEnd'].forEach(function (event) {
205 box[method](event, listener);
206 });
207 }
208 /**
209 * Compared to xxx.contains, this function works for dom structures with shadow
210 * dom
211 */
212
213 function actualContains(parent, child) {
214 var target = child;
215
216 while (target) {
217 var _target$getRootNode;
218
219 if (parent.contains(target)) {
220 return true;
221 }
222
223 target = target.getRootNode == null ? void 0 : (_target$getRootNode = target.getRootNode()) == null ? void 0 : _target$getRootNode.host;
224 }
225
226 return false;
227 }
228
229 var currentInput = {
230 isTouch: false
231 };
232 var lastMouseMoveTime = 0;
233 /**
234 * When a `touchstart` event is fired, it's assumed the user is using touch
235 * input. We'll bind a `mousemove` event listener to listen for mouse input in
236 * the future. This way, the `isTouch` property is fully dynamic and will handle
237 * hybrid devices that use a mix of touch + mouse input.
238 */
239
240 function onDocumentTouchStart() {
241 if (currentInput.isTouch) {
242 return;
243 }
244
245 currentInput.isTouch = true;
246
247 if (window.performance) {
248 document.addEventListener('mousemove', onDocumentMouseMove);
249 }
250 }
251 /**
252 * When two `mousemove` event are fired consecutively within 20ms, it's assumed
253 * the user is using mouse input again. `mousemove` can fire on touch devices as
254 * well, but very rarely that quickly.
255 */
256
257 function onDocumentMouseMove() {
258 var now = performance.now();
259
260 if (now - lastMouseMoveTime < 20) {
261 currentInput.isTouch = false;
262 document.removeEventListener('mousemove', onDocumentMouseMove);
263 }
264
265 lastMouseMoveTime = now;
266 }
267 /**
268 * When an element is in focus and has a tippy, leaving the tab/window and
269 * returning causes it to show again. For mouse users this is unexpected, but
270 * for keyboard use it makes sense.
271 * TODO: find a better technique to solve this problem
272 */
273
274 function onWindowBlur() {
275 var activeElement = document.activeElement;
276
277 if (isReferenceElement(activeElement)) {
278 var instance = activeElement._tippy;
279
280 if (activeElement.blur && !instance.state.isVisible) {
281 activeElement.blur();
282 }
283 }
284 }
285 function bindGlobalEventListeners() {
286 document.addEventListener('touchstart', onDocumentTouchStart, TOUCH_OPTIONS);
287 window.addEventListener('blur', onWindowBlur);
288 }
289
290 function createMemoryLeakWarning(method) {
291 var txt = method === 'destroy' ? 'n already-' : ' ';
292 return [method + "() was called on a" + txt + "destroyed instance. This is a no-op but", 'indicates a potential memory leak.'].join(' ');
293 }
294 function clean(value) {
295 var spacesAndTabs = /[ \t]{2,}/g;
296 var lineStartWithSpaces = /^[ \t]*/gm;
297 return value.replace(spacesAndTabs, ' ').replace(lineStartWithSpaces, '').trim();
298 }
299
300 function getDevMessage(message) {
301 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 ");
302 }
303
304 function getFormattedMessage(message) {
305 return [getDevMessage(message), // title
306 'color: #00C584; font-size: 1.3em; font-weight: bold;', // message
307 'line-height: 1.5', // footer
308 'color: #a6a095;'];
309 } // Assume warnings and errors never have the same message
310
311 var visitedMessages;
312
313 {
314 resetVisitedMessages();
315 }
316
317 function resetVisitedMessages() {
318 visitedMessages = new Set();
319 }
320 function warnWhen(condition, message) {
321 if (condition && !visitedMessages.has(message)) {
322 var _console;
323
324 visitedMessages.add(message);
325
326 (_console = console).warn.apply(_console, getFormattedMessage(message));
327 }
328 }
329 function errorWhen(condition, message) {
330 if (condition && !visitedMessages.has(message)) {
331 var _console2;
332
333 visitedMessages.add(message);
334
335 (_console2 = console).error.apply(_console2, getFormattedMessage(message));
336 }
337 }
338 function validateTargets(targets) {
339 var didPassFalsyValue = !targets;
340 var didPassPlainObject = Object.prototype.toString.call(targets) === '[object Object]' && !targets.addEventListener;
341 errorWhen(didPassFalsyValue, ['tippy() was passed', '`' + String(targets) + '`', 'as its targets (first) argument. Valid types are: String, Element,', 'Element[], or NodeList.'].join(' '));
342 errorWhen(didPassPlainObject, ['tippy() was passed a plain object which is not supported as an argument', 'for virtual positioning. Use props.getReferenceClientRect instead.'].join(' '));
343 }
344
345 var pluginProps = {
346 animateFill: false,
347 followCursor: false,
348 inlinePositioning: false,
349 sticky: false
350 };
351 var renderProps = {
352 allowHTML: false,
353 animation: 'fade',
354 arrow: true,
355 content: '',
356 inertia: false,
357 maxWidth: 350,
358 role: 'tooltip',
359 theme: '',
360 zIndex: 9999
361 };
362 var defaultProps = Object.assign({
363 appendTo: TIPPY_DEFAULT_APPEND_TO,
364 aria: {
365 content: 'auto',
366 expanded: 'auto'
367 },
368 delay: 0,
369 duration: [300, 250],
370 getReferenceClientRect: null,
371 hideOnClick: true,
372 ignoreAttributes: false,
373 interactive: false,
374 interactiveBorder: 2,
375 interactiveDebounce: 0,
376 moveTransition: '',
377 offset: [0, 10],
378 onAfterUpdate: function onAfterUpdate() {},
379 onBeforeUpdate: function onBeforeUpdate() {},
380 onCreate: function onCreate() {},
381 onDestroy: function onDestroy() {},
382 onHidden: function onHidden() {},
383 onHide: function onHide() {},
384 onMount: function onMount() {},
385 onShow: function onShow() {},
386 onShown: function onShown() {},
387 onTrigger: function onTrigger() {},
388 onUntrigger: function onUntrigger() {},
389 onClickOutside: function onClickOutside() {},
390 placement: 'top',
391 plugins: [],
392 popperOptions: {},
393 render: null,
394 showOnCreate: false,
395 touch: true,
396 trigger: 'mouseenter focus',
397 triggerTarget: null
398 }, pluginProps, renderProps);
399 var defaultKeys = Object.keys(defaultProps);
400 var setDefaultProps = function setDefaultProps(partialProps) {
401 /* istanbul ignore else */
402 {
403 validateProps(partialProps, []);
404 }
405
406 var keys = Object.keys(partialProps);
407 keys.forEach(function (key) {
408 defaultProps[key] = partialProps[key];
409 });
410 };
411 function getExtendedPassedProps(passedProps) {
412 var plugins = passedProps.plugins || [];
413 var pluginProps = plugins.reduce(function (acc, plugin) {
414 var name = plugin.name,
415 defaultValue = plugin.defaultValue;
416
417 if (name) {
418 var _name;
419
420 acc[name] = passedProps[name] !== undefined ? passedProps[name] : (_name = defaultProps[name]) != null ? _name : defaultValue;
421 }
422
423 return acc;
424 }, {});
425 return Object.assign({}, passedProps, pluginProps);
426 }
427 function getDataAttributeProps(reference, plugins) {
428 var propKeys = plugins ? Object.keys(getExtendedPassedProps(Object.assign({}, defaultProps, {
429 plugins: plugins
430 }))) : defaultKeys;
431 var props = propKeys.reduce(function (acc, key) {
432 var valueAsString = (reference.getAttribute("data-tippy-" + key) || '').trim();
433
434 if (!valueAsString) {
435 return acc;
436 }
437
438 if (key === 'content') {
439 acc[key] = valueAsString;
440 } else {
441 try {
442 acc[key] = JSON.parse(valueAsString);
443 } catch (e) {
444 acc[key] = valueAsString;
445 }
446 }
447
448 return acc;
449 }, {});
450 return props;
451 }
452 function evaluateProps(reference, props) {
453 var out = Object.assign({}, props, {
454 content: invokeWithArgsOrReturn(props.content, [reference])
455 }, props.ignoreAttributes ? {} : getDataAttributeProps(reference, props.plugins));
456 out.aria = Object.assign({}, defaultProps.aria, out.aria);
457 out.aria = {
458 expanded: out.aria.expanded === 'auto' ? props.interactive : out.aria.expanded,
459 content: out.aria.content === 'auto' ? props.interactive ? null : 'describedby' : out.aria.content
460 };
461 return out;
462 }
463 function validateProps(partialProps, plugins) {
464 if (partialProps === void 0) {
465 partialProps = {};
466 }
467
468 if (plugins === void 0) {
469 plugins = [];
470 }
471
472 var keys = Object.keys(partialProps);
473 keys.forEach(function (prop) {
474 var nonPluginProps = removeProperties(defaultProps, Object.keys(pluginProps));
475 var didPassUnknownProp = !hasOwnProperty(nonPluginProps, prop); // Check if the prop exists in `plugins`
476
477 if (didPassUnknownProp) {
478 didPassUnknownProp = plugins.filter(function (plugin) {
479 return plugin.name === prop;
480 }).length === 0;
481 }
482
483 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(' '));
484 });
485 }
486
487 var innerHTML = function innerHTML() {
488 return 'innerHTML';
489 };
490
491 function dangerouslySetInnerHTML(element, html) {
492 element[innerHTML()] = html;
493 }
494
495 function createArrowElement(value) {
496 var arrow = div();
497
498 if (value === true) {
499 arrow.className = ARROW_CLASS;
500 } else {
501 arrow.className = SVG_ARROW_CLASS;
502
503 if (isElement(value)) {
504 arrow.appendChild(value);
505 } else {
506 dangerouslySetInnerHTML(arrow, value);
507 }
508 }
509
510 return arrow;
511 }
512
513 function setContent(content, props) {
514 if (isElement(props.content)) {
515 dangerouslySetInnerHTML(content, '');
516 content.appendChild(props.content);
517 } else if (typeof props.content !== 'function') {
518 if (props.allowHTML) {
519 dangerouslySetInnerHTML(content, props.content);
520 } else {
521 content.textContent = props.content;
522 }
523 }
524 }
525 function getChildren(popper) {
526 var box = popper.firstElementChild;
527 var boxChildren = arrayFrom(box.children);
528 return {
529 box: box,
530 content: boxChildren.find(function (node) {
531 return node.classList.contains(CONTENT_CLASS);
532 }),
533 arrow: boxChildren.find(function (node) {
534 return node.classList.contains(ARROW_CLASS) || node.classList.contains(SVG_ARROW_CLASS);
535 }),
536 backdrop: boxChildren.find(function (node) {
537 return node.classList.contains(BACKDROP_CLASS);
538 })
539 };
540 }
541 function render(instance) {
542 var popper = div();
543 var box = div();
544 box.className = BOX_CLASS;
545 box.setAttribute('data-state', 'hidden');
546 box.setAttribute('tabindex', '-1');
547 var content = div();
548 content.className = CONTENT_CLASS;
549 content.setAttribute('data-state', 'hidden');
550 setContent(content, instance.props);
551 popper.appendChild(box);
552 box.appendChild(content);
553 onUpdate(instance.props, instance.props);
554
555 function onUpdate(prevProps, nextProps) {
556 var _getChildren = getChildren(popper),
557 box = _getChildren.box,
558 content = _getChildren.content,
559 arrow = _getChildren.arrow;
560
561 if (nextProps.theme) {
562 box.setAttribute('data-theme', nextProps.theme);
563 } else {
564 box.removeAttribute('data-theme');
565 }
566
567 if (typeof nextProps.animation === 'string') {
568 box.setAttribute('data-animation', nextProps.animation);
569 } else {
570 box.removeAttribute('data-animation');
571 }
572
573 if (nextProps.inertia) {
574 box.setAttribute('data-inertia', '');
575 } else {
576 box.removeAttribute('data-inertia');
577 }
578
579 box.style.maxWidth = typeof nextProps.maxWidth === 'number' ? nextProps.maxWidth + "px" : nextProps.maxWidth;
580
581 if (nextProps.role) {
582 box.setAttribute('role', nextProps.role);
583 } else {
584 box.removeAttribute('role');
585 }
586
587 if (prevProps.content !== nextProps.content || prevProps.allowHTML !== nextProps.allowHTML) {
588 setContent(content, instance.props);
589 }
590
591 if (nextProps.arrow) {
592 if (!arrow) {
593 box.appendChild(createArrowElement(nextProps.arrow));
594 } else if (prevProps.arrow !== nextProps.arrow) {
595 box.removeChild(arrow);
596 box.appendChild(createArrowElement(nextProps.arrow));
597 }
598 } else if (arrow) {
599 box.removeChild(arrow);
600 }
601 }
602
603 return {
604 popper: popper,
605 onUpdate: onUpdate
606 };
607 } // Runtime check to identify if the render function is the default one; this
608 // way we can apply default CSS transitions logic and it can be tree-shaken away
609
610 render.$$tippy = true;
611
612 var idCounter = 1;
613 var mouseMoveListeners = []; // Used by `hideAll()`
614
615 var mountedInstances = [];
616 function createTippy(reference, passedProps) {
617 var props = evaluateProps(reference, Object.assign({}, defaultProps, getExtendedPassedProps(removeUndefinedProps(passedProps)))); // ===========================================================================
618 // 🔒 Private members
619 // ===========================================================================
620
621 var showTimeout;
622 var hideTimeout;
623 var scheduleHideAnimationFrame;
624 var isVisibleFromClick = false;
625 var didHideDueToDocumentMouseDown = false;
626 var didTouchMove = false;
627 var ignoreOnFirstUpdate = false;
628 var lastTriggerEvent;
629 var currentTransitionEndListener;
630 var onFirstUpdate;
631 var listeners = [];
632 var debouncedOnMouseMove = debounce(onMouseMove, props.interactiveDebounce);
633 var currentTarget; // ===========================================================================
634 // 🔑 Public members
635 // ===========================================================================
636
637 var id = idCounter++;
638 var popperInstance = null;
639 var plugins = unique(props.plugins);
640 var state = {
641 // Is the instance currently enabled?
642 isEnabled: true,
643 // Is the tippy currently showing and not transitioning out?
644 isVisible: false,
645 // Has the instance been destroyed?
646 isDestroyed: false,
647 // Is the tippy currently mounted to the DOM?
648 isMounted: false,
649 // Has the tippy finished transitioning in?
650 isShown: false
651 };
652 var instance = {
653 // properties
654 id: id,
655 reference: reference,
656 popper: div(),
657 popperInstance: popperInstance,
658 props: props,
659 state: state,
660 plugins: plugins,
661 // methods
662 clearDelayTimeouts: clearDelayTimeouts,
663 setProps: setProps,
664 setContent: setContent,
665 show: show,
666 hide: hide,
667 hideWithInteractivity: hideWithInteractivity,
668 enable: enable,
669 disable: disable,
670 unmount: unmount,
671 destroy: destroy
672 }; // TODO: Investigate why this early return causes a TDZ error in the tests —
673 // it doesn't seem to happen in the browser
674
675 /* istanbul ignore if */
676
677 if (!props.render) {
678 {
679 errorWhen(true, 'render() function has not been supplied.');
680 }
681
682 return instance;
683 } // ===========================================================================
684 // Initial mutations
685 // ===========================================================================
686
687
688 var _props$render = props.render(instance),
689 popper = _props$render.popper,
690 onUpdate = _props$render.onUpdate;
691
692 popper.setAttribute('data-tippy-root', '');
693 popper.id = "tippy-" + instance.id;
694 instance.popper = popper;
695 reference._tippy = instance;
696 popper._tippy = instance;
697 var pluginsHooks = plugins.map(function (plugin) {
698 return plugin.fn(instance);
699 });
700 var hasAriaExpanded = reference.hasAttribute('aria-expanded');
701 addListeners();
702 handleAriaExpandedAttribute();
703 handleStyles();
704 invokeHook('onCreate', [instance]);
705
706 if (props.showOnCreate) {
707 scheduleShow();
708 } // Prevent a tippy with a delay from hiding if the cursor left then returned
709 // before it started hiding
710
711
712 popper.addEventListener('mouseenter', function () {
713 if (instance.props.interactive && instance.state.isVisible) {
714 instance.clearDelayTimeouts();
715 }
716 });
717 popper.addEventListener('mouseleave', function () {
718 if (instance.props.interactive && instance.props.trigger.indexOf('mouseenter') >= 0) {
719 getDocument().addEventListener('mousemove', debouncedOnMouseMove);
720 }
721 });
722 return instance; // ===========================================================================
723 // 🔒 Private methods
724 // ===========================================================================
725
726 function getNormalizedTouchSettings() {
727 var touch = instance.props.touch;
728 return Array.isArray(touch) ? touch : [touch, 0];
729 }
730
731 function getIsCustomTouchBehavior() {
732 return getNormalizedTouchSettings()[0] === 'hold';
733 }
734
735 function getIsDefaultRenderFn() {
736 var _instance$props$rende;
737
738 // @ts-ignore
739 return !!((_instance$props$rende = instance.props.render) != null && _instance$props$rende.$$tippy);
740 }
741
742 function getCurrentTarget() {
743 return currentTarget || reference;
744 }
745
746 function getDocument() {
747 var parent = getCurrentTarget().parentNode;
748 return parent ? getOwnerDocument(parent) : document;
749 }
750
751 function getDefaultTemplateChildren() {
752 return getChildren(popper);
753 }
754
755 function getDelay(isShow) {
756 // For touch or keyboard input, force `0` delay for UX reasons
757 // Also if the instance is mounted but not visible (transitioning out),
758 // ignore delay
759 if (instance.state.isMounted && !instance.state.isVisible || currentInput.isTouch || lastTriggerEvent && lastTriggerEvent.type === 'focus') {
760 return 0;
761 }
762
763 return getValueAtIndexOrReturn(instance.props.delay, isShow ? 0 : 1, defaultProps.delay);
764 }
765
766 function handleStyles(fromHide) {
767 if (fromHide === void 0) {
768 fromHide = false;
769 }
770
771 popper.style.pointerEvents = instance.props.interactive && !fromHide ? '' : 'none';
772 popper.style.zIndex = "" + instance.props.zIndex;
773 }
774
775 function invokeHook(hook, args, shouldInvokePropsHook) {
776 if (shouldInvokePropsHook === void 0) {
777 shouldInvokePropsHook = true;
778 }
779
780 pluginsHooks.forEach(function (pluginHooks) {
781 if (pluginHooks[hook]) {
782 pluginHooks[hook].apply(pluginHooks, args);
783 }
784 });
785
786 if (shouldInvokePropsHook) {
787 var _instance$props;
788
789 (_instance$props = instance.props)[hook].apply(_instance$props, args);
790 }
791 }
792
793 function handleAriaContentAttribute() {
794 var aria = instance.props.aria;
795
796 if (!aria.content) {
797 return;
798 }
799
800 var attr = "aria-" + aria.content;
801 var id = popper.id;
802 var nodes = normalizeToArray(instance.props.triggerTarget || reference);
803 nodes.forEach(function (node) {
804 var currentValue = node.getAttribute(attr);
805
806 if (instance.state.isVisible) {
807 node.setAttribute(attr, currentValue ? currentValue + " " + id : id);
808 } else {
809 var nextValue = currentValue && currentValue.replace(id, '').trim();
810
811 if (nextValue) {
812 node.setAttribute(attr, nextValue);
813 } else {
814 node.removeAttribute(attr);
815 }
816 }
817 });
818 }
819
820 function handleAriaExpandedAttribute() {
821 if (hasAriaExpanded || !instance.props.aria.expanded) {
822 return;
823 }
824
825 var nodes = normalizeToArray(instance.props.triggerTarget || reference);
826 nodes.forEach(function (node) {
827 if (instance.props.interactive) {
828 node.setAttribute('aria-expanded', instance.state.isVisible && node === getCurrentTarget() ? 'true' : 'false');
829 } else {
830 node.removeAttribute('aria-expanded');
831 }
832 });
833 }
834
835 function cleanupInteractiveMouseListeners() {
836 getDocument().removeEventListener('mousemove', debouncedOnMouseMove);
837 mouseMoveListeners = mouseMoveListeners.filter(function (listener) {
838 return listener !== debouncedOnMouseMove;
839 });
840 }
841
842 function onDocumentPress(event) {
843 // Moved finger to scroll instead of an intentional tap outside
844 if (currentInput.isTouch) {
845 if (didTouchMove || event.type === 'mousedown') {
846 return;
847 }
848 }
849
850 var actualTarget = event.composedPath && event.composedPath()[0] || event.target; // Clicked on interactive popper
851
852 if (instance.props.interactive && actualContains(popper, actualTarget)) {
853 return;
854 } // Clicked on the event listeners target
855
856
857 if (normalizeToArray(instance.props.triggerTarget || reference).some(function (el) {
858 return actualContains(el, actualTarget);
859 })) {
860 if (currentInput.isTouch) {
861 return;
862 }
863
864 if (instance.state.isVisible && instance.props.trigger.indexOf('click') >= 0) {
865 return;
866 }
867 } else {
868 invokeHook('onClickOutside', [instance, event]);
869 }
870
871 if (instance.props.hideOnClick === true) {
872 instance.clearDelayTimeouts();
873 instance.hide(); // `mousedown` event is fired right before `focus` if pressing the
874 // currentTarget. This lets a tippy with `focus` trigger know that it
875 // should not show
876
877 didHideDueToDocumentMouseDown = true;
878 setTimeout(function () {
879 didHideDueToDocumentMouseDown = false;
880 }); // The listener gets added in `scheduleShow()`, but this may be hiding it
881 // before it shows, and hide()'s early bail-out behavior can prevent it
882 // from being cleaned up
883
884 if (!instance.state.isMounted) {
885 removeDocumentPress();
886 }
887 }
888 }
889
890 function onTouchMove() {
891 didTouchMove = true;
892 }
893
894 function onTouchStart() {
895 didTouchMove = false;
896 }
897
898 function addDocumentPress() {
899 var doc = getDocument();
900 doc.addEventListener('mousedown', onDocumentPress, true);
901 doc.addEventListener('touchend', onDocumentPress, TOUCH_OPTIONS);
902 doc.addEventListener('touchstart', onTouchStart, TOUCH_OPTIONS);
903 doc.addEventListener('touchmove', onTouchMove, TOUCH_OPTIONS);
904 }
905
906 function removeDocumentPress() {
907 var doc = getDocument();
908 doc.removeEventListener('mousedown', onDocumentPress, true);
909 doc.removeEventListener('touchend', onDocumentPress, TOUCH_OPTIONS);
910 doc.removeEventListener('touchstart', onTouchStart, TOUCH_OPTIONS);
911 doc.removeEventListener('touchmove', onTouchMove, TOUCH_OPTIONS);
912 }
913
914 function onTransitionedOut(duration, callback) {
915 onTransitionEnd(duration, function () {
916 if (!instance.state.isVisible && popper.parentNode && popper.parentNode.contains(popper)) {
917 callback();
918 }
919 });
920 }
921
922 function onTransitionedIn(duration, callback) {
923 onTransitionEnd(duration, callback);
924 }
925
926 function onTransitionEnd(duration, callback) {
927 var box = getDefaultTemplateChildren().box;
928
929 function listener(event) {
930 if (event.target === box) {
931 updateTransitionEndListener(box, 'remove', listener);
932 callback();
933 }
934 } // Make callback synchronous if duration is 0
935 // `transitionend` won't fire otherwise
936
937
938 if (duration === 0) {
939 return callback();
940 }
941
942 updateTransitionEndListener(box, 'remove', currentTransitionEndListener);
943 updateTransitionEndListener(box, 'add', listener);
944 currentTransitionEndListener = listener;
945 }
946
947 function on(eventType, handler, options) {
948 if (options === void 0) {
949 options = false;
950 }
951
952 var nodes = normalizeToArray(instance.props.triggerTarget || reference);
953 nodes.forEach(function (node) {
954 node.addEventListener(eventType, handler, options);
955 listeners.push({
956 node: node,
957 eventType: eventType,
958 handler: handler,
959 options: options
960 });
961 });
962 }
963
964 function addListeners() {
965 if (getIsCustomTouchBehavior()) {
966 on('touchstart', onTrigger, {
967 passive: true
968 });
969 on('touchend', onMouseLeave, {
970 passive: true
971 });
972 }
973
974 splitBySpaces(instance.props.trigger).forEach(function (eventType) {
975 if (eventType === 'manual') {
976 return;
977 }
978
979 on(eventType, onTrigger);
980
981 switch (eventType) {
982 case 'mouseenter':
983 on('mouseleave', onMouseLeave);
984 break;
985
986 case 'focus':
987 on(isIE11 ? 'focusout' : 'blur', onBlurOrFocusOut);
988 break;
989
990 case 'focusin':
991 on('focusout', onBlurOrFocusOut);
992 break;
993 }
994 });
995 }
996
997 function removeListeners() {
998 listeners.forEach(function (_ref) {
999 var node = _ref.node,
1000 eventType = _ref.eventType,
1001 handler = _ref.handler,
1002 options = _ref.options;
1003 node.removeEventListener(eventType, handler, options);
1004 });
1005 listeners = [];
1006 }
1007
1008 function onTrigger(event) {
1009 var _lastTriggerEvent;
1010
1011 var shouldScheduleClickHide = false;
1012
1013 if (!instance.state.isEnabled || isEventListenerStopped(event) || didHideDueToDocumentMouseDown) {
1014 return;
1015 }
1016
1017 var wasFocused = ((_lastTriggerEvent = lastTriggerEvent) == null ? void 0 : _lastTriggerEvent.type) === 'focus';
1018 lastTriggerEvent = event;
1019 currentTarget = event.currentTarget;
1020 handleAriaExpandedAttribute();
1021
1022 if (!instance.state.isVisible && isMouseEvent(event)) {
1023 // If scrolling, `mouseenter` events can be fired if the cursor lands
1024 // over a new target, but `mousemove` events don't get fired. This
1025 // causes interactive tooltips to get stuck open until the cursor is
1026 // moved
1027 mouseMoveListeners.forEach(function (listener) {
1028 return listener(event);
1029 });
1030 } // Toggle show/hide when clicking click-triggered tooltips
1031
1032
1033 if (event.type === 'click' && (instance.props.trigger.indexOf('mouseenter') < 0 || isVisibleFromClick) && instance.props.hideOnClick !== false && instance.state.isVisible) {
1034 shouldScheduleClickHide = true;
1035 } else {
1036 scheduleShow(event);
1037 }
1038
1039 if (event.type === 'click') {
1040 isVisibleFromClick = !shouldScheduleClickHide;
1041 }
1042
1043 if (shouldScheduleClickHide && !wasFocused) {
1044 scheduleHide(event);
1045 }
1046 }
1047
1048 function onMouseMove(event) {
1049 var target = event.target;
1050 var isCursorOverReferenceOrPopper = getCurrentTarget().contains(target) || popper.contains(target);
1051
1052 if (event.type === 'mousemove' && isCursorOverReferenceOrPopper) {
1053 return;
1054 }
1055
1056 var popperTreeData = getNestedPopperTree().concat(popper).map(function (popper) {
1057 var _instance$popperInsta;
1058
1059 var instance = popper._tippy;
1060 var state = (_instance$popperInsta = instance.popperInstance) == null ? void 0 : _instance$popperInsta.state;
1061
1062 if (state) {
1063 return {
1064 popperRect: popper.getBoundingClientRect(),
1065 popperState: state,
1066 props: props
1067 };
1068 }
1069
1070 return null;
1071 }).filter(Boolean);
1072
1073 if (isCursorOutsideInteractiveBorder(popperTreeData, event)) {
1074 cleanupInteractiveMouseListeners();
1075 scheduleHide(event);
1076 }
1077 }
1078
1079 function onMouseLeave(event) {
1080 var shouldBail = isEventListenerStopped(event) || instance.props.trigger.indexOf('click') >= 0 && isVisibleFromClick;
1081
1082 if (shouldBail) {
1083 return;
1084 }
1085
1086 if (instance.props.interactive) {
1087 instance.hideWithInteractivity(event);
1088 return;
1089 }
1090
1091 scheduleHide(event);
1092 }
1093
1094 function onBlurOrFocusOut(event) {
1095 if (instance.props.trigger.indexOf('focusin') < 0 && event.target !== getCurrentTarget()) {
1096 return;
1097 } // If focus was moved to within the popper
1098
1099
1100 if (instance.props.interactive && event.relatedTarget && popper.contains(event.relatedTarget)) {
1101 return;
1102 }
1103
1104 scheduleHide(event);
1105 }
1106
1107 function isEventListenerStopped(event) {
1108 return currentInput.isTouch ? getIsCustomTouchBehavior() !== event.type.indexOf('touch') >= 0 : false;
1109 }
1110
1111 function createPopperInstance() {
1112 destroyPopperInstance();
1113 var _instance$props2 = instance.props,
1114 popperOptions = _instance$props2.popperOptions,
1115 placement = _instance$props2.placement,
1116 offset = _instance$props2.offset,
1117 getReferenceClientRect = _instance$props2.getReferenceClientRect,
1118 moveTransition = _instance$props2.moveTransition;
1119 var arrow = getIsDefaultRenderFn() ? getChildren(popper).arrow : null;
1120 var computedReference = getReferenceClientRect ? {
1121 getBoundingClientRect: getReferenceClientRect,
1122 contextElement: getReferenceClientRect.contextElement || getCurrentTarget()
1123 } : reference;
1124 var tippyModifier = {
1125 name: '$$tippy',
1126 enabled: true,
1127 phase: 'beforeWrite',
1128 requires: ['computeStyles'],
1129 fn: function fn(_ref2) {
1130 var state = _ref2.state;
1131
1132 if (getIsDefaultRenderFn()) {
1133 var _getDefaultTemplateCh = getDefaultTemplateChildren(),
1134 box = _getDefaultTemplateCh.box;
1135
1136 ['placement', 'reference-hidden', 'escaped'].forEach(function (attr) {
1137 if (attr === 'placement') {
1138 box.setAttribute('data-placement', state.placement);
1139 } else {
1140 if (state.attributes.popper["data-popper-" + attr]) {
1141 box.setAttribute("data-" + attr, '');
1142 } else {
1143 box.removeAttribute("data-" + attr);
1144 }
1145 }
1146 });
1147 state.attributes.popper = {};
1148 }
1149 }
1150 };
1151 var modifiers = [{
1152 name: 'offset',
1153 options: {
1154 offset: offset
1155 }
1156 }, {
1157 name: 'preventOverflow',
1158 options: {
1159 padding: {
1160 top: 2,
1161 bottom: 2,
1162 left: 5,
1163 right: 5
1164 }
1165 }
1166 }, {
1167 name: 'flip',
1168 options: {
1169 padding: 5
1170 }
1171 }, {
1172 name: 'computeStyles',
1173 options: {
1174 adaptive: !moveTransition
1175 }
1176 }, tippyModifier];
1177
1178 if (getIsDefaultRenderFn() && arrow) {
1179 modifiers.push({
1180 name: 'arrow',
1181 options: {
1182 element: arrow,
1183 padding: 3
1184 }
1185 });
1186 }
1187
1188 modifiers.push.apply(modifiers, (popperOptions == null ? void 0 : popperOptions.modifiers) || []);
1189 instance.popperInstance = core.createPopper(computedReference, popper, Object.assign({}, popperOptions, {
1190 placement: placement,
1191 onFirstUpdate: onFirstUpdate,
1192 modifiers: modifiers
1193 }));
1194 }
1195
1196 function destroyPopperInstance() {
1197 if (instance.popperInstance) {
1198 instance.popperInstance.destroy();
1199 instance.popperInstance = null;
1200 }
1201 }
1202
1203 function mount() {
1204 var appendTo = instance.props.appendTo;
1205 var parentNode; // By default, we'll append the popper to the triggerTargets's parentNode so
1206 // it's directly after the reference element so the elements inside the
1207 // tippy can be tabbed to
1208 // If there are clipping issues, the user can specify a different appendTo
1209 // and ensure focus management is handled correctly manually
1210
1211 var node = getCurrentTarget();
1212
1213 if (instance.props.interactive && appendTo === TIPPY_DEFAULT_APPEND_TO || appendTo === 'parent') {
1214 parentNode = node.parentNode;
1215 } else {
1216 parentNode = invokeWithArgsOrReturn(appendTo, [node]);
1217 } // The popper element needs to exist on the DOM before its position can be
1218 // updated as Popper needs to read its dimensions
1219
1220
1221 if (!parentNode.contains(popper)) {
1222 parentNode.appendChild(popper);
1223 }
1224
1225 instance.state.isMounted = true;
1226 createPopperInstance();
1227 /* istanbul ignore else */
1228
1229 {
1230 // Accessibility check
1231 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(' '));
1232 }
1233 }
1234
1235 function getNestedPopperTree() {
1236 return arrayFrom(popper.querySelectorAll('[data-tippy-root]'));
1237 }
1238
1239 function scheduleShow(event) {
1240 instance.clearDelayTimeouts();
1241
1242 if (event) {
1243 invokeHook('onTrigger', [instance, event]);
1244 }
1245
1246 addDocumentPress();
1247 var delay = getDelay(true);
1248
1249 var _getNormalizedTouchSe = getNormalizedTouchSettings(),
1250 touchValue = _getNormalizedTouchSe[0],
1251 touchDelay = _getNormalizedTouchSe[1];
1252
1253 if (currentInput.isTouch && touchValue === 'hold' && touchDelay) {
1254 delay = touchDelay;
1255 }
1256
1257 if (delay) {
1258 showTimeout = setTimeout(function () {
1259 instance.show();
1260 }, delay);
1261 } else {
1262 instance.show();
1263 }
1264 }
1265
1266 function scheduleHide(event) {
1267 instance.clearDelayTimeouts();
1268 invokeHook('onUntrigger', [instance, event]);
1269
1270 if (!instance.state.isVisible) {
1271 removeDocumentPress();
1272 return;
1273 } // For interactive tippies, scheduleHide is added to a document.body handler
1274 // from onMouseLeave so must intercept scheduled hides from mousemove/leave
1275 // events when trigger contains mouseenter and click, and the tip is
1276 // currently shown as a result of a click.
1277
1278
1279 if (instance.props.trigger.indexOf('mouseenter') >= 0 && instance.props.trigger.indexOf('click') >= 0 && ['mouseleave', 'mousemove'].indexOf(event.type) >= 0 && isVisibleFromClick) {
1280 return;
1281 }
1282
1283 var delay = getDelay(false);
1284
1285 if (delay) {
1286 hideTimeout = setTimeout(function () {
1287 if (instance.state.isVisible) {
1288 instance.hide();
1289 }
1290 }, delay);
1291 } else {
1292 // Fixes a `transitionend` problem when it fires 1 frame too
1293 // late sometimes, we don't want hide() to be called.
1294 scheduleHideAnimationFrame = requestAnimationFrame(function () {
1295 instance.hide();
1296 });
1297 }
1298 } // ===========================================================================
1299 // 🔑 Public methods
1300 // ===========================================================================
1301
1302
1303 function enable() {
1304 instance.state.isEnabled = true;
1305 }
1306
1307 function disable() {
1308 // Disabling the instance should also hide it
1309 // https://github.com/atomiks/tippy.js-react/issues/106
1310 instance.hide();
1311 instance.state.isEnabled = false;
1312 }
1313
1314 function clearDelayTimeouts() {
1315 clearTimeout(showTimeout);
1316 clearTimeout(hideTimeout);
1317 cancelAnimationFrame(scheduleHideAnimationFrame);
1318 }
1319
1320 function setProps(partialProps) {
1321 /* istanbul ignore else */
1322 {
1323 warnWhen(instance.state.isDestroyed, createMemoryLeakWarning('setProps'));
1324 }
1325
1326 if (instance.state.isDestroyed) {
1327 return;
1328 }
1329
1330 invokeHook('onBeforeUpdate', [instance, partialProps]);
1331 removeListeners();
1332 var prevProps = instance.props;
1333 var nextProps = evaluateProps(reference, Object.assign({}, prevProps, removeUndefinedProps(partialProps), {
1334 ignoreAttributes: true
1335 }));
1336 instance.props = nextProps;
1337 addListeners();
1338
1339 if (prevProps.interactiveDebounce !== nextProps.interactiveDebounce) {
1340 cleanupInteractiveMouseListeners();
1341 debouncedOnMouseMove = debounce(onMouseMove, nextProps.interactiveDebounce);
1342 } // Ensure stale aria-expanded attributes are removed
1343
1344
1345 if (prevProps.triggerTarget && !nextProps.triggerTarget) {
1346 normalizeToArray(prevProps.triggerTarget).forEach(function (node) {
1347 node.removeAttribute('aria-expanded');
1348 });
1349 } else if (nextProps.triggerTarget) {
1350 reference.removeAttribute('aria-expanded');
1351 }
1352
1353 handleAriaExpandedAttribute();
1354 handleStyles();
1355
1356 if (onUpdate) {
1357 onUpdate(prevProps, nextProps);
1358 }
1359
1360 if (instance.popperInstance) {
1361 createPopperInstance(); // Fixes an issue with nested tippies if they are all getting re-rendered,
1362 // and the nested ones get re-rendered first.
1363 // https://github.com/atomiks/tippyjs-react/issues/177
1364 // TODO: find a cleaner / more efficient solution(!)
1365
1366 getNestedPopperTree().forEach(function (nestedPopper) {
1367 // React (and other UI libs likely) requires a rAF wrapper as it flushes
1368 // its work in one
1369 requestAnimationFrame(nestedPopper._tippy.popperInstance.forceUpdate);
1370 });
1371 }
1372
1373 invokeHook('onAfterUpdate', [instance, partialProps]);
1374 }
1375
1376 function setContent(content) {
1377 instance.setProps({
1378 content: content
1379 });
1380 }
1381
1382 function show() {
1383 /* istanbul ignore else */
1384 {
1385 warnWhen(instance.state.isDestroyed, createMemoryLeakWarning('show'));
1386 } // Early bail-out
1387
1388
1389 var isAlreadyVisible = instance.state.isVisible;
1390 var isDestroyed = instance.state.isDestroyed;
1391 var isDisabled = !instance.state.isEnabled;
1392 var isTouchAndTouchDisabled = currentInput.isTouch && !instance.props.touch;
1393 var duration = getValueAtIndexOrReturn(instance.props.duration, 0, defaultProps.duration);
1394
1395 if (isAlreadyVisible || isDestroyed || isDisabled || isTouchAndTouchDisabled) {
1396 return;
1397 } // Normalize `disabled` behavior across browsers.
1398 // Firefox allows events on disabled elements, but Chrome doesn't.
1399 // Using a wrapper element (i.e. <span>) is recommended.
1400
1401
1402 if (getCurrentTarget().hasAttribute('disabled')) {
1403 return;
1404 }
1405
1406 invokeHook('onShow', [instance], false);
1407
1408 if (instance.props.onShow(instance) === false) {
1409 return;
1410 }
1411
1412 instance.state.isVisible = true;
1413
1414 if (getIsDefaultRenderFn()) {
1415 popper.style.visibility = 'visible';
1416 }
1417
1418 handleStyles();
1419 addDocumentPress();
1420
1421 if (!instance.state.isMounted) {
1422 popper.style.transition = 'none';
1423 } // If flipping to the opposite side after hiding at least once, the
1424 // animation will use the wrong placement without resetting the duration
1425
1426
1427 if (getIsDefaultRenderFn()) {
1428 var _getDefaultTemplateCh2 = getDefaultTemplateChildren(),
1429 box = _getDefaultTemplateCh2.box,
1430 content = _getDefaultTemplateCh2.content;
1431
1432 setTransitionDuration([box, content], 0);
1433 }
1434
1435 onFirstUpdate = function onFirstUpdate() {
1436 var _instance$popperInsta2;
1437
1438 if (!instance.state.isVisible || ignoreOnFirstUpdate) {
1439 return;
1440 }
1441
1442 ignoreOnFirstUpdate = true; // reflow
1443
1444 void popper.offsetHeight;
1445 popper.style.transition = instance.props.moveTransition;
1446
1447 if (getIsDefaultRenderFn() && instance.props.animation) {
1448 var _getDefaultTemplateCh3 = getDefaultTemplateChildren(),
1449 _box = _getDefaultTemplateCh3.box,
1450 _content = _getDefaultTemplateCh3.content;
1451
1452 setTransitionDuration([_box, _content], duration);
1453 setVisibilityState([_box, _content], 'visible');
1454 }
1455
1456 handleAriaContentAttribute();
1457 handleAriaExpandedAttribute();
1458 pushIfUnique(mountedInstances, instance); // certain modifiers (e.g. `maxSize`) require a second update after the
1459 // popper has been positioned for the first time
1460
1461 (_instance$popperInsta2 = instance.popperInstance) == null ? void 0 : _instance$popperInsta2.forceUpdate();
1462 invokeHook('onMount', [instance]);
1463
1464 if (instance.props.animation && getIsDefaultRenderFn()) {
1465 onTransitionedIn(duration, function () {
1466 instance.state.isShown = true;
1467 invokeHook('onShown', [instance]);
1468 });
1469 }
1470 };
1471
1472 mount();
1473 }
1474
1475 function hide() {
1476 /* istanbul ignore else */
1477 {
1478 warnWhen(instance.state.isDestroyed, createMemoryLeakWarning('hide'));
1479 } // Early bail-out
1480
1481
1482 var isAlreadyHidden = !instance.state.isVisible;
1483 var isDestroyed = instance.state.isDestroyed;
1484 var isDisabled = !instance.state.isEnabled;
1485 var duration = getValueAtIndexOrReturn(instance.props.duration, 1, defaultProps.duration);
1486
1487 if (isAlreadyHidden || isDestroyed || isDisabled) {
1488 return;
1489 }
1490
1491 invokeHook('onHide', [instance], false);
1492
1493 if (instance.props.onHide(instance) === false) {
1494 return;
1495 }
1496
1497 instance.state.isVisible = false;
1498 instance.state.isShown = false;
1499 ignoreOnFirstUpdate = false;
1500 isVisibleFromClick = false;
1501
1502 if (getIsDefaultRenderFn()) {
1503 popper.style.visibility = 'hidden';
1504 }
1505
1506 cleanupInteractiveMouseListeners();
1507 removeDocumentPress();
1508 handleStyles(true);
1509
1510 if (getIsDefaultRenderFn()) {
1511 var _getDefaultTemplateCh4 = getDefaultTemplateChildren(),
1512 box = _getDefaultTemplateCh4.box,
1513 content = _getDefaultTemplateCh4.content;
1514
1515 if (instance.props.animation) {
1516 setTransitionDuration([box, content], duration);
1517 setVisibilityState([box, content], 'hidden');
1518 }
1519 }
1520
1521 handleAriaContentAttribute();
1522 handleAriaExpandedAttribute();
1523
1524 if (instance.props.animation) {
1525 if (getIsDefaultRenderFn()) {
1526 onTransitionedOut(duration, instance.unmount);
1527 }
1528 } else {
1529 instance.unmount();
1530 }
1531 }
1532
1533 function hideWithInteractivity(event) {
1534 /* istanbul ignore else */
1535 {
1536 warnWhen(instance.state.isDestroyed, createMemoryLeakWarning('hideWithInteractivity'));
1537 }
1538
1539 getDocument().addEventListener('mousemove', debouncedOnMouseMove);
1540 pushIfUnique(mouseMoveListeners, debouncedOnMouseMove);
1541 debouncedOnMouseMove(event);
1542 }
1543
1544 function unmount() {
1545 /* istanbul ignore else */
1546 {
1547 warnWhen(instance.state.isDestroyed, createMemoryLeakWarning('unmount'));
1548 }
1549
1550 if (instance.state.isVisible) {
1551 instance.hide();
1552 }
1553
1554 if (!instance.state.isMounted) {
1555 return;
1556 }
1557
1558 destroyPopperInstance(); // If a popper is not interactive, it will be appended outside the popper
1559 // tree by default. This seems mainly for interactive tippies, but we should
1560 // find a workaround if possible
1561
1562 getNestedPopperTree().forEach(function (nestedPopper) {
1563 nestedPopper._tippy.unmount();
1564 });
1565
1566 if (popper.parentNode) {
1567 popper.parentNode.removeChild(popper);
1568 }
1569
1570 mountedInstances = mountedInstances.filter(function (i) {
1571 return i !== instance;
1572 });
1573 instance.state.isMounted = false;
1574 invokeHook('onHidden', [instance]);
1575 }
1576
1577 function destroy() {
1578 /* istanbul ignore else */
1579 {
1580 warnWhen(instance.state.isDestroyed, createMemoryLeakWarning('destroy'));
1581 }
1582
1583 if (instance.state.isDestroyed) {
1584 return;
1585 }
1586
1587 instance.clearDelayTimeouts();
1588 instance.unmount();
1589 removeListeners();
1590 delete reference._tippy;
1591 instance.state.isDestroyed = true;
1592 invokeHook('onDestroy', [instance]);
1593 }
1594 }
1595
1596 function tippy(targets, optionalProps) {
1597 if (optionalProps === void 0) {
1598 optionalProps = {};
1599 }
1600
1601 var plugins = defaultProps.plugins.concat(optionalProps.plugins || []);
1602 /* istanbul ignore else */
1603
1604 {
1605 validateTargets(targets);
1606 validateProps(optionalProps, plugins);
1607 }
1608
1609 bindGlobalEventListeners();
1610 var passedProps = Object.assign({}, optionalProps, {
1611 plugins: plugins
1612 });
1613 var elements = getArrayOfElements(targets);
1614 /* istanbul ignore else */
1615
1616 {
1617 var isSingleContentElement = isElement(passedProps.content);
1618 var isMoreThanOneReferenceElement = elements.length > 1;
1619 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(' '));
1620 }
1621
1622 var instances = elements.reduce(function (acc, reference) {
1623 var instance = reference && createTippy(reference, passedProps);
1624
1625 if (instance) {
1626 acc.push(instance);
1627 }
1628
1629 return acc;
1630 }, []);
1631 return isElement(targets) ? instances[0] : instances;
1632 }
1633
1634 tippy.defaultProps = defaultProps;
1635 tippy.setDefaultProps = setDefaultProps;
1636 tippy.currentInput = currentInput;
1637 var hideAll = function hideAll(_temp) {
1638 var _ref = _temp === void 0 ? {} : _temp,
1639 excludedReferenceOrInstance = _ref.exclude,
1640 duration = _ref.duration;
1641
1642 mountedInstances.forEach(function (instance) {
1643 var isExcluded = false;
1644
1645 if (excludedReferenceOrInstance) {
1646 isExcluded = isReferenceElement(excludedReferenceOrInstance) ? instance.reference === excludedReferenceOrInstance : instance.popper === excludedReferenceOrInstance.popper;
1647 }
1648
1649 if (!isExcluded) {
1650 var originalDuration = instance.props.duration;
1651 instance.setProps({
1652 duration: duration
1653 });
1654 instance.hide();
1655
1656 if (!instance.state.isDestroyed) {
1657 instance.setProps({
1658 duration: originalDuration
1659 });
1660 }
1661 }
1662 });
1663 };
1664
1665 // every time the popper is destroyed (i.e. a new target), removing the styles
1666 // and causing transitions to break for singletons when the console is open, but
1667 // most notably for non-transform styles being used, `gpuAcceleration: false`.
1668
1669 var applyStylesModifier = Object.assign({}, core.applyStyles, {
1670 effect: function effect(_ref) {
1671 var state = _ref.state;
1672 var initialStyles = {
1673 popper: {
1674 position: state.options.strategy,
1675 left: '0',
1676 top: '0',
1677 margin: '0'
1678 },
1679 arrow: {
1680 position: 'absolute'
1681 },
1682 reference: {}
1683 };
1684 Object.assign(state.elements.popper.style, initialStyles.popper);
1685 state.styles = initialStyles;
1686
1687 if (state.elements.arrow) {
1688 Object.assign(state.elements.arrow.style, initialStyles.arrow);
1689 } // intentionally return no cleanup function
1690 // return () => { ... }
1691
1692 }
1693 });
1694
1695 var createSingleton = function createSingleton(tippyInstances, optionalProps) {
1696 var _optionalProps$popper;
1697
1698 if (optionalProps === void 0) {
1699 optionalProps = {};
1700 }
1701
1702 /* istanbul ignore else */
1703 {
1704 errorWhen(!Array.isArray(tippyInstances), ['The first argument passed to createSingleton() must be an array of', 'tippy instances. The passed value was', String(tippyInstances)].join(' '));
1705 }
1706
1707 var individualInstances = tippyInstances;
1708 var references = [];
1709 var triggerTargets = [];
1710 var currentTarget;
1711 var overrides = optionalProps.overrides;
1712 var interceptSetPropsCleanups = [];
1713 var shownOnCreate = false;
1714
1715 function setTriggerTargets() {
1716 triggerTargets = individualInstances.map(function (instance) {
1717 return normalizeToArray(instance.props.triggerTarget || instance.reference);
1718 }).reduce(function (acc, item) {
1719 return acc.concat(item);
1720 }, []);
1721 }
1722
1723 function setReferences() {
1724 references = individualInstances.map(function (instance) {
1725 return instance.reference;
1726 });
1727 }
1728
1729 function enableInstances(isEnabled) {
1730 individualInstances.forEach(function (instance) {
1731 if (isEnabled) {
1732 instance.enable();
1733 } else {
1734 instance.disable();
1735 }
1736 });
1737 }
1738
1739 function interceptSetProps(singleton) {
1740 return individualInstances.map(function (instance) {
1741 var originalSetProps = instance.setProps;
1742
1743 instance.setProps = function (props) {
1744 originalSetProps(props);
1745
1746 if (instance.reference === currentTarget) {
1747 singleton.setProps(props);
1748 }
1749 };
1750
1751 return function () {
1752 instance.setProps = originalSetProps;
1753 };
1754 });
1755 } // have to pass singleton, as it maybe undefined on first call
1756
1757
1758 function prepareInstance(singleton, target) {
1759 var index = triggerTargets.indexOf(target); // bail-out
1760
1761 if (target === currentTarget) {
1762 return;
1763 }
1764
1765 currentTarget = target;
1766 var overrideProps = (overrides || []).concat('content').reduce(function (acc, prop) {
1767 acc[prop] = individualInstances[index].props[prop];
1768 return acc;
1769 }, {});
1770 singleton.setProps(Object.assign({}, overrideProps, {
1771 getReferenceClientRect: typeof overrideProps.getReferenceClientRect === 'function' ? overrideProps.getReferenceClientRect : function () {
1772 var _references$index;
1773
1774 return (_references$index = references[index]) == null ? void 0 : _references$index.getBoundingClientRect();
1775 }
1776 }));
1777 }
1778
1779 enableInstances(false);
1780 setReferences();
1781 setTriggerTargets();
1782 var plugin = {
1783 fn: function fn() {
1784 return {
1785 onDestroy: function onDestroy() {
1786 enableInstances(true);
1787 },
1788 onHidden: function onHidden() {
1789 currentTarget = null;
1790 },
1791 onClickOutside: function onClickOutside(instance) {
1792 if (instance.props.showOnCreate && !shownOnCreate) {
1793 shownOnCreate = true;
1794 currentTarget = null;
1795 }
1796 },
1797 onShow: function onShow(instance) {
1798 if (instance.props.showOnCreate && !shownOnCreate) {
1799 shownOnCreate = true;
1800 prepareInstance(instance, references[0]);
1801 }
1802 },
1803 onTrigger: function onTrigger(instance, event) {
1804 prepareInstance(instance, event.currentTarget);
1805 }
1806 };
1807 }
1808 };
1809 var singleton = tippy(div(), Object.assign({}, removeProperties(optionalProps, ['overrides']), {
1810 plugins: [plugin].concat(optionalProps.plugins || []),
1811 triggerTarget: triggerTargets,
1812 popperOptions: Object.assign({}, optionalProps.popperOptions, {
1813 modifiers: [].concat(((_optionalProps$popper = optionalProps.popperOptions) == null ? void 0 : _optionalProps$popper.modifiers) || [], [applyStylesModifier])
1814 })
1815 }));
1816 var originalShow = singleton.show;
1817
1818 singleton.show = function (target) {
1819 originalShow(); // first time, showOnCreate or programmatic call with no params
1820 // default to showing first instance
1821
1822 if (!currentTarget && target == null) {
1823 return prepareInstance(singleton, references[0]);
1824 } // triggered from event (do nothing as prepareInstance already called by onTrigger)
1825 // programmatic call with no params when already visible (do nothing again)
1826
1827
1828 if (currentTarget && target == null) {
1829 return;
1830 } // target is index of instance
1831
1832
1833 if (typeof target === 'number') {
1834 return references[target] && prepareInstance(singleton, references[target]);
1835 } // target is a child tippy instance
1836
1837
1838 if (individualInstances.indexOf(target) >= 0) {
1839 var ref = target.reference;
1840 return prepareInstance(singleton, ref);
1841 } // target is a ReferenceElement
1842
1843
1844 if (references.indexOf(target) >= 0) {
1845 return prepareInstance(singleton, target);
1846 }
1847 };
1848
1849 singleton.showNext = function () {
1850 var first = references[0];
1851
1852 if (!currentTarget) {
1853 return singleton.show(0);
1854 }
1855
1856 var index = references.indexOf(currentTarget);
1857 singleton.show(references[index + 1] || first);
1858 };
1859
1860 singleton.showPrevious = function () {
1861 var last = references[references.length - 1];
1862
1863 if (!currentTarget) {
1864 return singleton.show(last);
1865 }
1866
1867 var index = references.indexOf(currentTarget);
1868 var target = references[index - 1] || last;
1869 singleton.show(target);
1870 };
1871
1872 var originalSetProps = singleton.setProps;
1873
1874 singleton.setProps = function (props) {
1875 overrides = props.overrides || overrides;
1876 originalSetProps(props);
1877 };
1878
1879 singleton.setInstances = function (nextInstances) {
1880 enableInstances(true);
1881 interceptSetPropsCleanups.forEach(function (fn) {
1882 return fn();
1883 });
1884 individualInstances = nextInstances;
1885 enableInstances(false);
1886 setReferences();
1887 setTriggerTargets();
1888 interceptSetPropsCleanups = interceptSetProps(singleton);
1889 singleton.setProps({
1890 triggerTarget: triggerTargets
1891 });
1892 };
1893
1894 interceptSetPropsCleanups = interceptSetProps(singleton);
1895 return singleton;
1896 };
1897
1898 var BUBBLING_EVENTS_MAP = {
1899 mouseover: 'mouseenter',
1900 focusin: 'focus',
1901 click: 'click'
1902 };
1903 /**
1904 * Creates a delegate instance that controls the creation of tippy instances
1905 * for child elements (`target` CSS selector).
1906 */
1907
1908 function delegate(targets, props) {
1909 /* istanbul ignore else */
1910 {
1911 errorWhen(!(props && props.target), ['You must specity a `target` prop indicating a CSS selector string matching', 'the target elements that should receive a tippy.'].join(' '));
1912 }
1913
1914 var listeners = [];
1915 var childTippyInstances = [];
1916 var disabled = false;
1917 var target = props.target;
1918 var nativeProps = removeProperties(props, ['target']);
1919 var parentProps = Object.assign({}, nativeProps, {
1920 trigger: 'manual',
1921 touch: false
1922 });
1923 var childProps = Object.assign({
1924 touch: defaultProps.touch
1925 }, nativeProps, {
1926 showOnCreate: true
1927 });
1928 var returnValue = tippy(targets, parentProps);
1929 var normalizedReturnValue = normalizeToArray(returnValue);
1930
1931 function onTrigger(event) {
1932 if (!event.target || disabled) {
1933 return;
1934 }
1935
1936 var targetNode = event.target.closest(target);
1937
1938 if (!targetNode) {
1939 return;
1940 } // Get relevant trigger with fallbacks:
1941 // 1. Check `data-tippy-trigger` attribute on target node
1942 // 2. Fallback to `trigger` passed to `delegate()`
1943 // 3. Fallback to `defaultProps.trigger`
1944
1945
1946 var trigger = targetNode.getAttribute('data-tippy-trigger') || props.trigger || defaultProps.trigger; // @ts-ignore
1947
1948 if (targetNode._tippy) {
1949 return;
1950 }
1951
1952 if (event.type === 'touchstart' && typeof childProps.touch === 'boolean') {
1953 return;
1954 }
1955
1956 if (event.type !== 'touchstart' && trigger.indexOf(BUBBLING_EVENTS_MAP[event.type]) < 0) {
1957 return;
1958 }
1959
1960 var instance = tippy(targetNode, childProps);
1961
1962 if (instance) {
1963 childTippyInstances = childTippyInstances.concat(instance);
1964 }
1965 }
1966
1967 function on(node, eventType, handler, options) {
1968 if (options === void 0) {
1969 options = false;
1970 }
1971
1972 node.addEventListener(eventType, handler, options);
1973 listeners.push({
1974 node: node,
1975 eventType: eventType,
1976 handler: handler,
1977 options: options
1978 });
1979 }
1980
1981 function addEventListeners(instance) {
1982 var reference = instance.reference;
1983 on(reference, 'touchstart', onTrigger, TOUCH_OPTIONS);
1984 on(reference, 'mouseover', onTrigger);
1985 on(reference, 'focusin', onTrigger);
1986 on(reference, 'click', onTrigger);
1987 }
1988
1989 function removeEventListeners() {
1990 listeners.forEach(function (_ref) {
1991 var node = _ref.node,
1992 eventType = _ref.eventType,
1993 handler = _ref.handler,
1994 options = _ref.options;
1995 node.removeEventListener(eventType, handler, options);
1996 });
1997 listeners = [];
1998 }
1999
2000 function applyMutations(instance) {
2001 var originalDestroy = instance.destroy;
2002 var originalEnable = instance.enable;
2003 var originalDisable = instance.disable;
2004
2005 instance.destroy = function (shouldDestroyChildInstances) {
2006 if (shouldDestroyChildInstances === void 0) {
2007 shouldDestroyChildInstances = true;
2008 }
2009
2010 if (shouldDestroyChildInstances) {
2011 childTippyInstances.forEach(function (instance) {
2012 instance.destroy();
2013 });
2014 }
2015
2016 childTippyInstances = [];
2017 removeEventListeners();
2018 originalDestroy();
2019 };
2020
2021 instance.enable = function () {
2022 originalEnable();
2023 childTippyInstances.forEach(function (instance) {
2024 return instance.enable();
2025 });
2026 disabled = false;
2027 };
2028
2029 instance.disable = function () {
2030 originalDisable();
2031 childTippyInstances.forEach(function (instance) {
2032 return instance.disable();
2033 });
2034 disabled = true;
2035 };
2036
2037 addEventListeners(instance);
2038 }
2039
2040 normalizedReturnValue.forEach(applyMutations);
2041 return returnValue;
2042 }
2043
2044 var animateFill = {
2045 name: 'animateFill',
2046 defaultValue: false,
2047 fn: function fn(instance) {
2048 var _instance$props$rende;
2049
2050 // @ts-ignore
2051 if (!((_instance$props$rende = instance.props.render) != null && _instance$props$rende.$$tippy)) {
2052 {
2053 errorWhen(instance.props.animateFill, 'The `animateFill` plugin requires the default render function.');
2054 }
2055
2056 return {};
2057 }
2058
2059 var _getChildren = getChildren(instance.popper),
2060 box = _getChildren.box,
2061 content = _getChildren.content;
2062
2063 var backdrop = instance.props.animateFill ? createBackdropElement() : null;
2064 return {
2065 onCreate: function onCreate() {
2066 if (backdrop) {
2067 box.insertBefore(backdrop, box.firstElementChild);
2068 box.setAttribute('data-animatefill', '');
2069 box.style.overflow = 'hidden';
2070 instance.setProps({
2071 arrow: false,
2072 animation: 'shift-away'
2073 });
2074 }
2075 },
2076 onMount: function onMount() {
2077 if (backdrop) {
2078 var transitionDuration = box.style.transitionDuration;
2079 var duration = Number(transitionDuration.replace('ms', '')); // The content should fade in after the backdrop has mostly filled the
2080 // tooltip element. `clip-path` is the other alternative but is not
2081 // well-supported and is buggy on some devices.
2082
2083 content.style.transitionDelay = Math.round(duration / 10) + "ms";
2084 backdrop.style.transitionDuration = transitionDuration;
2085 setVisibilityState([backdrop], 'visible');
2086 }
2087 },
2088 onShow: function onShow() {
2089 if (backdrop) {
2090 backdrop.style.transitionDuration = '0ms';
2091 }
2092 },
2093 onHide: function onHide() {
2094 if (backdrop) {
2095 setVisibilityState([backdrop], 'hidden');
2096 }
2097 }
2098 };
2099 }
2100 };
2101
2102 function createBackdropElement() {
2103 var backdrop = div();
2104 backdrop.className = BACKDROP_CLASS;
2105 setVisibilityState([backdrop], 'hidden');
2106 return backdrop;
2107 }
2108
2109 var mouseCoords = {
2110 clientX: 0,
2111 clientY: 0
2112 };
2113 var activeInstances = [];
2114
2115 function storeMouseCoords(_ref) {
2116 var clientX = _ref.clientX,
2117 clientY = _ref.clientY;
2118 mouseCoords = {
2119 clientX: clientX,
2120 clientY: clientY
2121 };
2122 }
2123
2124 function addMouseCoordsListener(doc) {
2125 doc.addEventListener('mousemove', storeMouseCoords);
2126 }
2127
2128 function removeMouseCoordsListener(doc) {
2129 doc.removeEventListener('mousemove', storeMouseCoords);
2130 }
2131
2132 var followCursor = {
2133 name: 'followCursor',
2134 defaultValue: false,
2135 fn: function fn(instance) {
2136 var reference = instance.reference;
2137 var doc = getOwnerDocument(instance.props.triggerTarget || reference);
2138 var isInternalUpdate = false;
2139 var wasFocusEvent = false;
2140 var isUnmounted = true;
2141 var prevProps = instance.props;
2142
2143 function getIsInitialBehavior() {
2144 return instance.props.followCursor === 'initial' && instance.state.isVisible;
2145 }
2146
2147 function addListener() {
2148 doc.addEventListener('mousemove', onMouseMove);
2149 }
2150
2151 function removeListener() {
2152 doc.removeEventListener('mousemove', onMouseMove);
2153 }
2154
2155 function unsetGetReferenceClientRect() {
2156 isInternalUpdate = true;
2157 instance.setProps({
2158 getReferenceClientRect: null
2159 });
2160 isInternalUpdate = false;
2161 }
2162
2163 function onMouseMove(event) {
2164 // If the instance is interactive, avoid updating the position unless it's
2165 // over the reference element
2166 var isCursorOverReference = event.target ? reference.contains(event.target) : true;
2167 var followCursor = instance.props.followCursor;
2168 var clientX = event.clientX,
2169 clientY = event.clientY;
2170 var rect = reference.getBoundingClientRect();
2171 var relativeX = clientX - rect.left;
2172 var relativeY = clientY - rect.top;
2173
2174 if (isCursorOverReference || !instance.props.interactive) {
2175 instance.setProps({
2176 // @ts-ignore - unneeded DOMRect properties
2177 getReferenceClientRect: function getReferenceClientRect() {
2178 var rect = reference.getBoundingClientRect();
2179 var x = clientX;
2180 var y = clientY;
2181
2182 if (followCursor === 'initial') {
2183 x = rect.left + relativeX;
2184 y = rect.top + relativeY;
2185 }
2186
2187 var top = followCursor === 'horizontal' ? rect.top : y;
2188 var right = followCursor === 'vertical' ? rect.right : x;
2189 var bottom = followCursor === 'horizontal' ? rect.bottom : y;
2190 var left = followCursor === 'vertical' ? rect.left : x;
2191 return {
2192 width: right - left,
2193 height: bottom - top,
2194 top: top,
2195 right: right,
2196 bottom: bottom,
2197 left: left
2198 };
2199 }
2200 });
2201 }
2202 }
2203
2204 function create() {
2205 if (instance.props.followCursor) {
2206 activeInstances.push({
2207 instance: instance,
2208 doc: doc
2209 });
2210 addMouseCoordsListener(doc);
2211 }
2212 }
2213
2214 function destroy() {
2215 activeInstances = activeInstances.filter(function (data) {
2216 return data.instance !== instance;
2217 });
2218
2219 if (activeInstances.filter(function (data) {
2220 return data.doc === doc;
2221 }).length === 0) {
2222 removeMouseCoordsListener(doc);
2223 }
2224 }
2225
2226 return {
2227 onCreate: create,
2228 onDestroy: destroy,
2229 onBeforeUpdate: function onBeforeUpdate() {
2230 prevProps = instance.props;
2231 },
2232 onAfterUpdate: function onAfterUpdate(_, _ref2) {
2233 var followCursor = _ref2.followCursor;
2234
2235 if (isInternalUpdate) {
2236 return;
2237 }
2238
2239 if (followCursor !== undefined && prevProps.followCursor !== followCursor) {
2240 destroy();
2241
2242 if (followCursor) {
2243 create();
2244
2245 if (instance.state.isMounted && !wasFocusEvent && !getIsInitialBehavior()) {
2246 addListener();
2247 }
2248 } else {
2249 removeListener();
2250 unsetGetReferenceClientRect();
2251 }
2252 }
2253 },
2254 onMount: function onMount() {
2255 if (instance.props.followCursor && !wasFocusEvent) {
2256 if (isUnmounted) {
2257 onMouseMove(mouseCoords);
2258 isUnmounted = false;
2259 }
2260
2261 if (!getIsInitialBehavior()) {
2262 addListener();
2263 }
2264 }
2265 },
2266 onTrigger: function onTrigger(_, event) {
2267 if (isMouseEvent(event)) {
2268 mouseCoords = {
2269 clientX: event.clientX,
2270 clientY: event.clientY
2271 };
2272 }
2273
2274 wasFocusEvent = event.type === 'focus';
2275 },
2276 onHidden: function onHidden() {
2277 if (instance.props.followCursor) {
2278 unsetGetReferenceClientRect();
2279 removeListener();
2280 isUnmounted = true;
2281 }
2282 }
2283 };
2284 }
2285 };
2286
2287 function getProps(props, modifier) {
2288 var _props$popperOptions;
2289
2290 return {
2291 popperOptions: Object.assign({}, props.popperOptions, {
2292 modifiers: [].concat((((_props$popperOptions = props.popperOptions) == null ? void 0 : _props$popperOptions.modifiers) || []).filter(function (_ref) {
2293 var name = _ref.name;
2294 return name !== modifier.name;
2295 }), [modifier])
2296 })
2297 };
2298 }
2299
2300 var inlinePositioning = {
2301 name: 'inlinePositioning',
2302 defaultValue: false,
2303 fn: function fn(instance) {
2304 var reference = instance.reference;
2305
2306 function isEnabled() {
2307 return !!instance.props.inlinePositioning;
2308 }
2309
2310 var placement;
2311 var cursorRectIndex = -1;
2312 var isInternalUpdate = false;
2313 var triedPlacements = [];
2314 var modifier = {
2315 name: 'tippyInlinePositioning',
2316 enabled: true,
2317 phase: 'afterWrite',
2318 fn: function fn(_ref2) {
2319 var state = _ref2.state;
2320
2321 if (isEnabled()) {
2322 if (triedPlacements.indexOf(state.placement) !== -1) {
2323 triedPlacements = [];
2324 }
2325
2326 if (placement !== state.placement && triedPlacements.indexOf(state.placement) === -1) {
2327 triedPlacements.push(state.placement);
2328 instance.setProps({
2329 // @ts-ignore - unneeded DOMRect properties
2330 getReferenceClientRect: function getReferenceClientRect() {
2331 return _getReferenceClientRect(state.placement);
2332 }
2333 });
2334 }
2335
2336 placement = state.placement;
2337 }
2338 }
2339 };
2340
2341 function _getReferenceClientRect(placement) {
2342 return getInlineBoundingClientRect(getBasePlacement(placement), reference.getBoundingClientRect(), arrayFrom(reference.getClientRects()), cursorRectIndex);
2343 }
2344
2345 function setInternalProps(partialProps) {
2346 isInternalUpdate = true;
2347 instance.setProps(partialProps);
2348 isInternalUpdate = false;
2349 }
2350
2351 function addModifier() {
2352 if (!isInternalUpdate) {
2353 setInternalProps(getProps(instance.props, modifier));
2354 }
2355 }
2356
2357 return {
2358 onCreate: addModifier,
2359 onAfterUpdate: addModifier,
2360 onTrigger: function onTrigger(_, event) {
2361 if (isMouseEvent(event)) {
2362 var rects = arrayFrom(instance.reference.getClientRects());
2363 var cursorRect = rects.find(function (rect) {
2364 return rect.left - 2 <= event.clientX && rect.right + 2 >= event.clientX && rect.top - 2 <= event.clientY && rect.bottom + 2 >= event.clientY;
2365 });
2366 var index = rects.indexOf(cursorRect);
2367 cursorRectIndex = index > -1 ? index : cursorRectIndex;
2368 }
2369 },
2370 onHidden: function onHidden() {
2371 cursorRectIndex = -1;
2372 }
2373 };
2374 }
2375 };
2376 function getInlineBoundingClientRect(currentBasePlacement, boundingRect, clientRects, cursorRectIndex) {
2377 // Not an inline element, or placement is not yet known
2378 if (clientRects.length < 2 || currentBasePlacement === null) {
2379 return boundingRect;
2380 } // There are two rects and they are disjoined
2381
2382
2383 if (clientRects.length === 2 && cursorRectIndex >= 0 && clientRects[0].left > clientRects[1].right) {
2384 return clientRects[cursorRectIndex] || boundingRect;
2385 }
2386
2387 switch (currentBasePlacement) {
2388 case 'top':
2389 case 'bottom':
2390 {
2391 var firstRect = clientRects[0];
2392 var lastRect = clientRects[clientRects.length - 1];
2393 var isTop = currentBasePlacement === 'top';
2394 var top = firstRect.top;
2395 var bottom = lastRect.bottom;
2396 var left = isTop ? firstRect.left : lastRect.left;
2397 var right = isTop ? firstRect.right : lastRect.right;
2398 var width = right - left;
2399 var height = bottom - top;
2400 return {
2401 top: top,
2402 bottom: bottom,
2403 left: left,
2404 right: right,
2405 width: width,
2406 height: height
2407 };
2408 }
2409
2410 case 'left':
2411 case 'right':
2412 {
2413 var minLeft = Math.min.apply(Math, clientRects.map(function (rects) {
2414 return rects.left;
2415 }));
2416 var maxRight = Math.max.apply(Math, clientRects.map(function (rects) {
2417 return rects.right;
2418 }));
2419 var measureRects = clientRects.filter(function (rect) {
2420 return currentBasePlacement === 'left' ? rect.left === minLeft : rect.right === maxRight;
2421 });
2422 var _top = measureRects[0].top;
2423 var _bottom = measureRects[measureRects.length - 1].bottom;
2424 var _left = minLeft;
2425 var _right = maxRight;
2426
2427 var _width = _right - _left;
2428
2429 var _height = _bottom - _top;
2430
2431 return {
2432 top: _top,
2433 bottom: _bottom,
2434 left: _left,
2435 right: _right,
2436 width: _width,
2437 height: _height
2438 };
2439 }
2440
2441 default:
2442 {
2443 return boundingRect;
2444 }
2445 }
2446 }
2447
2448 var sticky = {
2449 name: 'sticky',
2450 defaultValue: false,
2451 fn: function fn(instance) {
2452 var reference = instance.reference,
2453 popper = instance.popper;
2454
2455 function getReference() {
2456 return instance.popperInstance ? instance.popperInstance.state.elements.reference : reference;
2457 }
2458
2459 function shouldCheck(value) {
2460 return instance.props.sticky === true || instance.props.sticky === value;
2461 }
2462
2463 var prevRefRect = null;
2464 var prevPopRect = null;
2465
2466 function updatePosition() {
2467 var currentRefRect = shouldCheck('reference') ? getReference().getBoundingClientRect() : null;
2468 var currentPopRect = shouldCheck('popper') ? popper.getBoundingClientRect() : null;
2469
2470 if (currentRefRect && areRectsDifferent(prevRefRect, currentRefRect) || currentPopRect && areRectsDifferent(prevPopRect, currentPopRect)) {
2471 if (instance.popperInstance) {
2472 instance.popperInstance.update();
2473 }
2474 }
2475
2476 prevRefRect = currentRefRect;
2477 prevPopRect = currentPopRect;
2478
2479 if (instance.state.isMounted) {
2480 requestAnimationFrame(updatePosition);
2481 }
2482 }
2483
2484 return {
2485 onMount: function onMount() {
2486 if (instance.props.sticky) {
2487 updatePosition();
2488 }
2489 }
2490 };
2491 }
2492 };
2493
2494 function areRectsDifferent(rectA, rectB) {
2495 if (rectA && rectB) {
2496 return rectA.top !== rectB.top || rectA.right !== rectB.right || rectA.bottom !== rectB.bottom || rectA.left !== rectB.left;
2497 }
2498
2499 return true;
2500 }
2501
2502 if (isBrowser) {
2503 injectCSS(css);
2504 }
2505
2506 tippy.setDefaultProps({
2507 plugins: [animateFill, followCursor, inlinePositioning, sticky],
2508 render: render
2509 });
2510 tippy.createSingleton = createSingleton;
2511 tippy.delegate = delegate;
2512 tippy.hideAll = hideAll;
2513 tippy.roundArrow = ROUND_ARROW;
2514
2515 return tippy;
2516
2517 })));
2518 //# sourceMappingURL=tippy-bundle.umd.js.map
2519