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.umd.js

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

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