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