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