1/** 2 * @popperjs/core v2.9.3 - MIT License 3 */ 4 5(function (global, factory) { 6 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : 7 typeof define === 'function' && define.amd ? define(['exports'], factory) : 8 (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Popper = {})); 9}(this, (function (exports) { 'use strict'; 10 11 function getWindow(node) { 12 if (node == null) { 13 return window; 14 } 15 16 if (node.toString() !== '[object Window]') { 17 var ownerDocument = node.ownerDocument; 18 return ownerDocument ? ownerDocument.defaultView || window : window; 19 } 20 21 return node; 22 } 23 24 function isElement(node) { 25 var OwnElement = getWindow(node).Element; 26 return node instanceof OwnElement || node instanceof Element; 27 } 28 29 function isHTMLElement(node) { 30 var OwnElement = getWindow(node).HTMLElement; 31 return node instanceof OwnElement || node instanceof HTMLElement; 32 } 33 34 function isShadowRoot(node) { 35 // IE 11 has no ShadowRoot 36 if (typeof ShadowRoot === 'undefined') { 37 return false; 38 } 39 40 var OwnElement = getWindow(node).ShadowRoot; 41 return node instanceof OwnElement || node instanceof ShadowRoot; 42 } 43 44 var round$1 = Math.round; 45 function getBoundingClientRect(element, includeScale) { 46 if (includeScale === void 0) { 47 includeScale = false; 48 } 49 50 var rect = element.getBoundingClientRect(); 51 var scaleX = 1; 52 var scaleY = 1; 53 54 if (isHTMLElement(element) && includeScale) { 55 // Fallback to 1 in case both values are `0` 56 scaleX = rect.width / element.offsetWidth || 1; 57 scaleY = rect.height / element.offsetHeight || 1; 58 } 59 60 return { 61 width: round$1(rect.width / scaleX), 62 height: round$1(rect.height / scaleY), 63 top: round$1(rect.top / scaleY), 64 right: round$1(rect.right / scaleX), 65 bottom: round$1(rect.bottom / scaleY), 66 left: round$1(rect.left / scaleX), 67 x: round$1(rect.left / scaleX), 68 y: round$1(rect.top / scaleY) 69 }; 70 } 71 72 function getWindowScroll(node) { 73 var win = getWindow(node); 74 var scrollLeft = win.pageXOffset; 75 var scrollTop = win.pageYOffset; 76 return { 77 scrollLeft: scrollLeft, 78 scrollTop: scrollTop 79 }; 80 } 81 82 function getHTMLElementScroll(element) { 83 return { 84 scrollLeft: element.scrollLeft, 85 scrollTop: element.scrollTop 86 }; 87 } 88 89 function getNodeScroll(node) { 90 if (node === getWindow(node) || !isHTMLElement(node)) { 91 return getWindowScroll(node); 92 } else { 93 return getHTMLElementScroll(node); 94 } 95 } 96 97 function getNodeName(element) { 98 return element ? (element.nodeName || '').toLowerCase() : null; 99 } 100 101 function getDocumentElement(element) { 102 // $FlowFixMe[incompatible-return]: assume body is always available 103 return ((isElement(element) ? element.ownerDocument : // $FlowFixMe[prop-missing] 104 element.document) || window.document).documentElement; 105 } 106 107 function getWindowScrollBarX(element) { 108 // If <html> has a CSS width greater than the viewport, then this will be 109 // incorrect for RTL. 110 // Popper 1 is broken in this case and never had a bug report so let's assume 111 // it's not an issue. I don't think anyone ever specifies width on <html> 112 // anyway. 113 // Browsers where the left scrollbar doesn't cause an issue report `0` for 114 // this (e.g. Edge 2019, IE11, Safari) 115 return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft; 116 } 117 118 function getComputedStyle(element) { 119 return getWindow(element).getComputedStyle(element); 120 } 121 122 function isScrollParent(element) { 123 // Firefox wants us to check `-x` and `-y` variations as well 124 var _getComputedStyle = getComputedStyle(element), 125 overflow = _getComputedStyle.overflow, 126 overflowX = _getComputedStyle.overflowX, 127 overflowY = _getComputedStyle.overflowY; 128 129 return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX); 130 } 131 132 function isElementScaled(element) { 133 var rect = element.getBoundingClientRect(); 134 var scaleX = rect.width / element.offsetWidth || 1; 135 var scaleY = rect.height / element.offsetHeight || 1; 136 return scaleX !== 1 || scaleY !== 1; 137 } // Returns the composite rect of an element relative to its offsetParent. 138 // Composite means it takes into account transforms as well as layout. 139 140
vendor: 7,706 bytes, lines 141-357
141 function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) { 142 if (isFixed === void 0) { 143 isFixed = false; 144 } 145 146 var isOffsetParentAnElement = isHTMLElement(offsetParent); 147 var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent); 148 var documentElement = getDocumentElement(offsetParent); 149 var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled); 150 var scroll = { 151 scrollLeft: 0, 152 scrollTop: 0 153 }; 154 var offsets = { 155 x: 0, 156 y: 0 157 }; 158 159 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) { 160 if (getNodeName(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078 161 isScrollParent(documentElement)) { 162 scroll = getNodeScroll(offsetParent); 163 } 164 165 if (isHTMLElement(offsetParent)) { 166 offsets = getBoundingClientRect(offsetParent, true); 167 offsets.x += offsetParent.clientLeft; 168 offsets.y += offsetParent.clientTop; 169 } else if (documentElement) { 170 offsets.x = getWindowScrollBarX(documentElement); 171 } 172 } 173 174 return { 175 x: rect.left + scroll.scrollLeft - offsets.x, 176 y: rect.top + scroll.scrollTop - offsets.y, 177 width: rect.width, 178 height: rect.height 179 }; 180 } 181 182 // means it doesn't take into account transforms. 183 184 function getLayoutRect(element) { 185 var clientRect = getBoundingClientRect(element); // Use the clientRect sizes if it's not been transformed. 186 // Fixes https://github.com/popperjs/popper-core/issues/1223 187 188 var width = element.offsetWidth; 189 var height = element.offsetHeight; 190 191 if (Math.abs(clientRect.width - width) <= 1) { 192 width = clientRect.width; 193 } 194 195 if (Math.abs(clientRect.height - height) <= 1) { 196 height = clientRect.height; 197 } 198 199 return { 200 x: element.offsetLeft, 201 y: element.offsetTop, 202 width: width, 203 height: height 204 }; 205 } 206 207 function getParentNode(element) { 208 if (getNodeName(element) === 'html') { 209 return element; 210 } 211 212 return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle 213 // $FlowFixMe[incompatible-return] 214 // $FlowFixMe[prop-missing] 215 element.assignedSlot || // step into the shadow DOM of the parent of a slotted node 216 element.parentNode || ( // DOM Element detected 217 isShadowRoot(element) ? element.host : null) || // ShadowRoot detected 218 // $FlowFixMe[incompatible-call]: HTMLElement is a Node 219 getDocumentElement(element) // fallback 220 221 ); 222 } 223 224 function getScrollParent(node) { 225 if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) { 226 // $FlowFixMe[incompatible-return]: assume body is always available 227 return node.ownerDocument.body; 228 } 229 230 if (isHTMLElement(node) && isScrollParent(node)) { 231 return node; 232 } 233 234 return getScrollParent(getParentNode(node)); 235 } 236 237 /* 238 given a DOM element, return the list of all scroll parents, up the list of ancesors 239 until we get to the top window object. This list is what we attach scroll listeners 240 to, because if any of these parent elements scroll, we'll need to re-calculate the 241 reference element's position. 242 */ 243 244 function listScrollParents(element, list) { 245 var _element$ownerDocumen; 246 247 if (list === void 0) { 248 list = []; 249 } 250 251 var scrollParent = getScrollParent(element); 252 var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body); 253 var win = getWindow(scrollParent); 254 var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent; 255 var updatedList = list.concat(target); 256 return isBody ? updatedList : // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here 257 updatedList.concat(listScrollParents(getParentNode(target))); 258 } 259 260 function isTableElement(element) { 261 return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0; 262 } 263 264 function getTrueOffsetParent(element) { 265 if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837 266 getComputedStyle(element).position === 'fixed') { 267 return null; 268 } 269 270 return element.offsetParent; 271 } // `.offsetParent` reports `null` for fixed elements, while absolute elements 272 // return the containing block 273 274 275 function getContainingBlock(element) { 276 var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') !== -1; 277 var isIE = navigator.userAgent.indexOf('Trident') !== -1; 278 279 if (isIE && isHTMLElement(element)) { 280 // In IE 9, 10 and 11 fixed elements containing block is always established by the viewport 281 var elementCss = getComputedStyle(element); 282 283 if (elementCss.position === 'fixed') { 284 return null; 285 } 286 } 287 288 var currentNode = getParentNode(element); 289 290 while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) { 291 var css = getComputedStyle(currentNode); // This is non-exhaustive but covers the most common CSS properties that 292 // create a containing block. 293 // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block 294 295 if (css.transform !== 'none' || css.perspective !== 'none' || css.contain === 'paint' || ['transform', 'perspective'].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === 'filter' || isFirefox && css.filter && css.filter !== 'none') { 296 return currentNode; 297 } else { 298 currentNode = currentNode.parentNode; 299 } 300 } 301 302 return null; 303 } // Gets the closest ancestor positioned element. Handles some edge cases, 304 // such as table ancestors and cross browser bugs. 305 306 307 function getOffsetParent(element) { 308 var window = getWindow(element); 309 var offsetParent = getTrueOffsetParent(element); 310 311 while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') { 312 offsetParent = getTrueOffsetParent(offsetParent); 313 } 314 315 if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static')) { 316 return window; 317 } 318 319 return offsetParent || getContainingBlock(element) || window; 320 } 321 322 var top = 'top'; 323 var bottom = 'bottom'; 324 var right = 'right'; 325 var left = 'left'; 326 var auto = 'auto'; 327 var basePlacements = [top, bottom, right, left]; 328 var start = 'start'; 329 var end = 'end'; 330 var clippingParents = 'clippingParents'; 331 var viewport = 'viewport'; 332 var popper = 'popper'; 333 var reference = 'reference'; 334 var variationPlacements = /*#__PURE__*/basePlacements.reduce(function (acc, placement) { 335 return acc.concat([placement + "-" + start, placement + "-" + end]); 336 }, []); 337 var placements = /*#__PURE__*/[].concat(basePlacements, [auto]).reduce(function (acc, placement) { 338 return acc.concat([placement, placement + "-" + start, placement + "-" + end]); 339 }, []); // modifiers that need to read the DOM 340 341 var beforeRead = 'beforeRead'; 342 var read = 'read'; 343 var afterRead = 'afterRead'; // pure-logic modifiers 344 345 var beforeMain = 'beforeMain'; 346 var main = 'main'; 347 var afterMain = 'afterMain'; // modifier with the purpose to write to the DOM (or write into a framework state) 348 349 var beforeWrite = 'beforeWrite'; 350 var write = 'write'; 351 var afterWrite = 'afterWrite'; 352 var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite]; 353 354 function order(modifiers) { 355 var map = new Map(); 356 var visited = new Set(); 357 var result = [];
vendor: 6,266 bytes, lines 358-543
358 modifiers.forEach(function (modifier) { 359 map.set(modifier.name, modifier); 360 }); // On visiting object, check for its dependencies and visit them recursively 361 362 function sort(modifier) { 363 visited.add(modifier.name); 364 var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []); 365 requires.forEach(function (dep) { 366 if (!visited.has(dep)) { 367 var depModifier = map.get(dep); 368 369 if (depModifier) { 370 sort(depModifier); 371 } 372 } 373 }); 374 result.push(modifier); 375 } 376 377 modifiers.forEach(function (modifier) { 378 if (!visited.has(modifier.name)) { 379 // check for visited object 380 sort(modifier); 381 } 382 }); 383 return result; 384 } 385 386 function orderModifiers(modifiers) { 387 // order based on dependencies 388 var orderedModifiers = order(modifiers); // order based on phase 389 390 return modifierPhases.reduce(function (acc, phase) { 391 return acc.concat(orderedModifiers.filter(function (modifier) { 392 return modifier.phase === phase; 393 })); 394 }, []); 395 } 396 397 function debounce(fn) { 398 var pending; 399 return function () { 400 if (!pending) { 401 pending = new Promise(function (resolve) { 402 Promise.resolve().then(function () { 403 pending = undefined; 404 resolve(fn()); 405 }); 406 }); 407 } 408 409 return pending; 410 }; 411 } 412 413 function format(str) { 414 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { 415 args[_key - 1] = arguments[_key]; 416 } 417 418 return [].concat(args).reduce(function (p, c) { 419 return p.replace(/%s/, c); 420 }, str); 421 } 422 423 var INVALID_MODIFIER_ERROR = 'Popper: modifier "%s" provided an invalid %s property, expected %s but got %s'; 424 var MISSING_DEPENDENCY_ERROR = 'Popper: modifier "%s" requires "%s", but "%s" modifier is not available'; 425 var VALID_PROPERTIES = ['name', 'enabled', 'phase', 'fn', 'effect', 'requires', 'options']; 426 function validateModifiers(modifiers) { 427 modifiers.forEach(function (modifier) { 428 Object.keys(modifier).forEach(function (key) { 429 switch (key) { 430 case 'name': 431 if (typeof modifier.name !== 'string') { 432 console.error(format(INVALID_MODIFIER_ERROR, String(modifier.name), '"name"', '"string"', "\"" + String(modifier.name) + "\"")); 433 } 434 435 break; 436 437 case 'enabled': 438 if (typeof modifier.enabled !== 'boolean') { 439 console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"enabled"', '"boolean"', "\"" + String(modifier.enabled) + "\"")); 440 } 441 442 case 'phase': 443 if (modifierPhases.indexOf(modifier.phase) < 0) { 444 console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"phase"', "either " + modifierPhases.join(', '), "\"" + String(modifier.phase) + "\"")); 445 } 446 447 break; 448 449 case 'fn': 450 if (typeof modifier.fn !== 'function') { 451 console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"fn"', '"function"', "\"" + String(modifier.fn) + "\"")); 452 } 453 454 break; 455 456 case 'effect': 457 if (typeof modifier.effect !== 'function') { 458 console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"effect"', '"function"', "\"" + String(modifier.fn) + "\"")); 459 } 460 461 break; 462 463 case 'requires': 464 if (!Array.isArray(modifier.requires)) { 465 console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requires"', '"array"', "\"" + String(modifier.requires) + "\"")); 466 } 467 468 break; 469 470 case 'requiresIfExists': 471 if (!Array.isArray(modifier.requiresIfExists)) { 472 console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requiresIfExists"', '"array"', "\"" + String(modifier.requiresIfExists) + "\"")); 473 } 474 475 break; 476 477 case 'options': 478 case 'data': 479 break; 480 481 default: 482 console.error("PopperJS: an invalid property has been provided to the \"" + modifier.name + "\" modifier, valid properties are " + VALID_PROPERTIES.map(function (s) { 483 return "\"" + s + "\""; 484 }).join(', ') + "; but \"" + key + "\" was provided."); 485 } 486 487 modifier.requires && modifier.requires.forEach(function (requirement) { 488 if (modifiers.find(function (mod) { 489 return mod.name === requirement; 490 }) == null) { 491 console.error(format(MISSING_DEPENDENCY_ERROR, String(modifier.name), requirement, requirement)); 492 } 493 }); 494 }); 495 }); 496 } 497 498 function uniqueBy(arr, fn) { 499 var identifiers = new Set(); 500 return arr.filter(function (item) { 501 var identifier = fn(item); 502 503 if (!identifiers.has(identifier)) { 504 identifiers.add(identifier); 505 return true; 506 } 507 }); 508 } 509 510 function getBasePlacement(placement) { 511 return placement.split('-')[0]; 512 } 513 514 function mergeByName(modifiers) { 515 var merged = modifiers.reduce(function (merged, current) { 516 var existing = merged[current.name]; 517 merged[current.name] = existing ? Object.assign({}, existing, current, { 518 options: Object.assign({}, existing.options, current.options), 519 data: Object.assign({}, existing.data, current.data) 520 }) : current; 521 return merged; 522 }, {}); // IE11 does not support Object.values 523 524 return Object.keys(merged).map(function (key) { 525 return merged[key]; 526 }); 527 } 528 529 function getViewportRect(element) { 530 var win = getWindow(element); 531 var html = getDocumentElement(element); 532 var visualViewport = win.visualViewport; 533 var width = html.clientWidth; 534 var height = html.clientHeight; 535 var x = 0; 536 var y = 0; // NB: This isn't supported on iOS <= 12. If the keyboard is open, the popper 537 // can be obscured underneath it. 538 // Also, `html.clientHeight` adds the bottom bar height in Safari iOS, even 539 // if it isn't open, so if this isn't available, the popper will be detected 540 // to overflow the bottom of the screen too early. 541 542 if (visualViewport) { 543 width = visualViewport.width;
vendor: 4,327 bytes, lines 544-664
544 height = visualViewport.height; // Uses Layout Viewport (like Chrome; Safari does not currently) 545 // In Chrome, it returns a value very close to 0 (+/-) but contains rounding 546 // errors due to floating point numbers, so we need to check precision. 547 // Safari returns a number <= 0, usually < -1 when pinch-zoomed 548 // Feature detection fails in mobile emulation mode in Chrome. 549 // Math.abs(win.innerWidth / visualViewport.scale - visualViewport.width) < 550 // 0.001 551 // Fallback here: "Not Safari" userAgent 552 553 if (!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) { 554 x = visualViewport.offsetLeft; 555 y = visualViewport.offsetTop; 556 } 557 } 558 559 return { 560 width: width, 561 height: height, 562 x: x + getWindowScrollBarX(element), 563 y: y 564 }; 565 } 566 567 var max = Math.max; 568 var min = Math.min; 569 var round = Math.round; 570 571 // of the `<html>` and `<body>` rect bounds if horizontally scrollable 572 573 function getDocumentRect(element) { 574 var _element$ownerDocumen; 575 576 var html = getDocumentElement(element); 577 var winScroll = getWindowScroll(element); 578 var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body; 579 var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0); 580 var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0); 581 var x = -winScroll.scrollLeft + getWindowScrollBarX(element); 582 var y = -winScroll.scrollTop; 583 584 if (getComputedStyle(body || html).direction === 'rtl') { 585 x += max(html.clientWidth, body ? body.clientWidth : 0) - width; 586 } 587 588 return { 589 width: width, 590 height: height, 591 x: x, 592 y: y 593 }; 594 } 595 596 function contains(parent, child) { 597 var rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method 598 599 if (parent.contains(child)) { 600 return true; 601 } // then fallback to custom implementation with Shadow DOM support 602 else if (rootNode && isShadowRoot(rootNode)) { 603 var next = child; 604 605 do { 606 if (next && parent.isSameNode(next)) { 607 return true; 608 } // $FlowFixMe[prop-missing]: need a better way to handle this... 609 610 611 next = next.parentNode || next.host; 612 } while (next); 613 } // Give up, the result is false 614 615 616 return false; 617 } 618 619 function rectToClientRect(rect) { 620 return Object.assign({}, rect, { 621 left: rect.x, 622 top: rect.y, 623 right: rect.x + rect.width, 624 bottom: rect.y + rect.height 625 }); 626 } 627 628 function getInnerBoundingClientRect(element) { 629 var rect = getBoundingClientRect(element); 630 rect.top = rect.top + element.clientTop; 631 rect.left = rect.left + element.clientLeft; 632 rect.bottom = rect.top + element.clientHeight; 633 rect.right = rect.left + element.clientWidth; 634 rect.width = element.clientWidth; 635 rect.height = element.clientHeight; 636 rect.x = rect.left; 637 rect.y = rect.top; 638 return rect; 639 } 640 641 function getClientRectFromMixedType(element, clippingParent) { 642 return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isHTMLElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element))); 643 } // A "clipping parent" is an overflowable container with the cmaiacteristic of 644 // clipping (or hiding) overflowing elements with a position different from 645 // `initial` 646 647 648 function getClippingParents(element) { 649 var clippingParents = listScrollParents(getParentNode(element)); 650 var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle(element).position) >= 0; 651 var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element; 652 653 if (!isElement(clipperElement)) { 654 return []; 655 } // $FlowFixMe[incompatible-return]: https://github.com/facebook/flow/issues/1414 656 657 658 return clippingParents.filter(function (clippingParent) { 659 return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body'; 660 }); 661 } // Gets the maximum area that the element is visible in due to any number of 662 // clipping parents 663 664
vendor: 4,117 bytes, lines 665-794
665 function getClippingRect(element, boundary, rootBoundary) { 666 var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary); 667 var clippingParents = [].concat(mainClippingParents, [rootBoundary]); 668 var firstClippingParent = clippingParents[0]; 669 var clippingRect = clippingParents.reduce(function (accRect, clippingParent) { 670 var rect = getClientRectFromMixedType(element, clippingParent); 671 accRect.top = max(rect.top, accRect.top); 672 accRect.right = min(rect.right, accRect.right); 673 accRect.bottom = min(rect.bottom, accRect.bottom); 674 accRect.left = max(rect.left, accRect.left); 675 return accRect; 676 }, getClientRectFromMixedType(element, firstClippingParent)); 677 clippingRect.width = clippingRect.right - clippingRect.left; 678 clippingRect.height = clippingRect.bottom - clippingRect.top; 679 clippingRect.x = clippingRect.left; 680 clippingRect.y = clippingRect.top; 681 return clippingRect; 682 } 683 684 function getVariation(placement) { 685 return placement.split('-')[1]; 686 } 687 688 function getMainAxisFromPlacement(placement) { 689 return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y'; 690 } 691 692 function computeOffsets(_ref) { 693 var reference = _ref.reference, 694 element = _ref.element, 695 placement = _ref.placement; 696 var basePlacement = placement ? getBasePlacement(placement) : null; 697 var variation = placement ? getVariation(placement) : null; 698 var commonX = reference.x + reference.width / 2 - element.width / 2; 699 var commonY = reference.y + reference.height / 2 - element.height / 2; 700 var offsets; 701 702 switch (basePlacement) { 703 case top: 704 offsets = { 705 x: commonX, 706 y: reference.y - element.height 707 }; 708 break; 709 710 case bottom: 711 offsets = { 712 x: commonX, 713 y: reference.y + reference.height 714 }; 715 break; 716 717 case right: 718 offsets = { 719 x: reference.x + reference.width, 720 y: commonY 721 }; 722 break; 723 724 case left: 725 offsets = { 726 x: reference.x - element.width, 727 y: commonY 728 }; 729 break; 730 731 default: 732 offsets = { 733 x: reference.x, 734 y: reference.y 735 }; 736 } 737 738 var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null; 739 740 if (mainAxis != null) { 741 var len = mainAxis === 'y' ? 'height' : 'width'; 742 743 switch (variation) { 744 case start: 745 offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2); 746 break; 747 748 case end: 749 offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2); 750 break; 751 } 752 } 753 754 return offsets; 755 } 756 757 function getFreshSideObject() { 758 return { 759 top: 0, 760 right: 0, 761 bottom: 0, 762 left: 0 763 }; 764 } 765 766 function mergePaddingObject(paddingObject) { 767 return Object.assign({}, getFreshSideObject(), paddingObject); 768 } 769 770 function expandToHashMap(value, keys) { 771 return keys.reduce(function (hashMap, key) { 772 hashMap[key] = value; 773 return hashMap; 774 }, {}); 775 } 776 777 function detectOverflow(state, options) { 778 if (options === void 0) { 779 options = {}; 780 } 781 782 var _options = options, 783 _options$placement = _options.placement, 784 placement = _options$placement === void 0 ? state.placement : _options$placement, 785 _options$boundary = _options.boundary, 786 boundary = _options$boundary === void 0 ? clippingParents : _options$boundary, 787 _options$rootBoundary = _options.rootBoundary, 788 rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary, 789 _options$elementConte = _options.elementContext, 790 elementContext = _options$elementConte === void 0 ? popper : _options$elementConte, 791 _options$altBoundary = _options.altBoundary, 792 altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary, 793 _options$padding = _options.padding, 794 padding = _options$padding === void 0 ? 0 : _options$padding;
vendor: 4,535 bytes, lines 795-894
795 var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements)); 796 var altContext = elementContext === popper ? reference : popper; 797 var referenceElement = state.elements.reference; 798 var popperRect = state.rects.popper; 799 var element = state.elements[altBoundary ? altContext : elementContext]; 800 var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary); 801 var referenceClientRect = getBoundingClientRect(referenceElement); 802 var popperOffsets = computeOffsets({ 803 reference: referenceClientRect, 804 element: popperRect, 805 strategy: 'absolute', 806 placement: placement 807 }); 808 var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets)); 809 var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect 810 // 0 or negative = within the clipping rect 811 812 var overflowOffsets = { 813 top: clippingClientRect.top - elementClientRect.top + paddingObject.top, 814 bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom, 815 left: clippingClientRect.left - elementClientRect.left + paddingObject.left, 816 right: elementClientRect.right - clippingClientRect.right + paddingObject.right 817 }; 818 var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element 819 820 if (elementContext === popper && offsetData) { 821 var offset = offsetData[placement]; 822 Object.keys(overflowOffsets).forEach(function (key) { 823 var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1; 824 var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x'; 825 overflowOffsets[key] += offset[axis] * multiply; 826 }); 827 } 828 829 return overflowOffsets; 830 } 831 832 var INVALID_ELEMENT_ERROR = 'Popper: Invalid reference or popper argument provided. They must be either a DOM element or virtual element.'; 833 var INFINITE_LOOP_ERROR = 'Popper: An infinite loop in the modifiers cycle has been detected! The cycle has been interrupted to prevent a browser crash.'; 834 var DEFAULT_OPTIONS = { 835 placement: 'bottom', 836 modifiers: [], 837 strategy: 'absolute' 838 }; 839 840 function areValidElements() { 841 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { 842 args[_key] = arguments[_key]; 843 } 844 845 return !args.some(function (element) { 846 return !(element && typeof element.getBoundingClientRect === 'function'); 847 }); 848 } 849 850 function popperGenerator(generatorOptions) { 851 if (generatorOptions === void 0) { 852 generatorOptions = {}; 853 } 854 855 var _generatorOptions = generatorOptions, 856 _generatorOptions$def = _generatorOptions.defaultModifiers, 857 defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def, 858 _generatorOptions$def2 = _generatorOptions.defaultOptions, 859 defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2; 860 return function createPopper(reference, popper, options) { 861 if (options === void 0) { 862 options = defaultOptions; 863 } 864 865 var state = { 866 placement: 'bottom', 867 orderedModifiers: [], 868 options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions), 869 modifiersData: {}, 870 elements: { 871 reference: reference, 872 popper: popper 873 }, 874 attributes: {}, 875 styles: {} 876 }; 877 var effectCleanupFns = []; 878 var isDestroyed = false; 879 var instance = { 880 state: state, 881 setOptions: function setOptions(options) { 882 cleanupModifierEffects(); 883 state.options = Object.assign({}, defaultOptions, state.options, options); 884 state.scrollParents = { 885 reference: isElement(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [], 886 popper: listScrollParents(popper) 887 }; // Orders the modifiers based on their dependencies and `phase` 888 // properties 889 890 var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers))); // Strip out disabled modifiers 891 892 state.orderedModifiers = orderedModifiers.filter(function (m) { 893 return m.enabled; 894 }); // Validate the provided modifiers so that the consumer will get warned
vendor: 4,110 bytes, lines 895-988
895 // if one of the modifiers is invalid for any reason 896 897 { 898 var modifiers = uniqueBy([].concat(orderedModifiers, state.options.modifiers), function (_ref) { 899 var name = _ref.name; 900 return name; 901 }); 902 validateModifiers(modifiers); 903 904 if (getBasePlacement(state.options.placement) === auto) { 905 var flipModifier = state.orderedModifiers.find(function (_ref2) { 906 var name = _ref2.name; 907 return name === 'flip'; 908 }); 909 910 if (!flipModifier) { 911 console.error(['Popper: "auto" placements require the "flip" modifier be', 'present and enabled to work.'].join(' ')); 912 } 913 } 914 915 var _getComputedStyle = getComputedStyle(popper), 916 marginTop = _getComputedStyle.marginTop, 917 marginRight = _getComputedStyle.marginRight, 918 marginBottom = _getComputedStyle.marginBottom, 919 marginLeft = _getComputedStyle.marginLeft; // We no longer take into account `margins` on the popper, and it can 920 // cause bugs with positioning, so we'll warn the consumer 921 922 923 if ([marginTop, marginRight, marginBottom, marginLeft].some(function (margin) { 924 return parseFloat(margin); 925 })) { 926 console.warn(['Popper: CSS "margin" styles cannot be used to apply padding', 'between the popper and its reference element or boundary.', 'To replicate margin, use the `offset` modifier, as well as', 'the `padding` option in the `preventOverflow` and `flip`', 'modifiers.'].join(' ')); 927 } 928 } 929 930 runModifierEffects(); 931 return instance.update(); 932 }, 933 // Sync update â it will always be executed, even if not necessary. This 934 // is useful for low frequency updates where sync behavior simplifies the 935 // logic. 936 // For high frequency updates (e.g. `resize` and `scroll` events), always 937 // prefer the async Popper#update method 938 forceUpdate: function forceUpdate() { 939 if (isDestroyed) { 940 return; 941 } 942 943 var _state$elements = state.elements, 944 reference = _state$elements.reference, 945 popper = _state$elements.popper; // Don't proceed if `reference` or `popper` are not valid elements 946 // anymore 947 948 if (!areValidElements(reference, popper)) { 949 { 950 console.error(INVALID_ELEMENT_ERROR); 951 } 952 953 return; 954 } // Store the reference and popper rects to be read by modifiers 955 956 957 state.rects = { 958 reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'), 959 popper: getLayoutRect(popper) 960 }; // Modifiers have the ability to reset the current update cycle. The 961 // most common use case for this is the `flip` modifier changing the 962 // placement, which then needs to re-run all the modifiers, because the 963 // logic was previously ran for the previous placement and is therefore 964 // stale/incorrect 965 966 state.reset = false; 967 state.placement = state.options.placement; // On each update cycle, the `modifiersData` property for each modifier 968 // is filled with the initial data specified by the modifier. This means 969 // it doesn't persist and is fresh on each update. 970 // To ensure persistent data, use `${name}#persistent` 971 972 state.orderedModifiers.forEach(function (modifier) { 973 return state.modifiersData[modifier.name] = Object.assign({}, modifier.data); 974 }); 975 var __debug_loops__ = 0; 976 977 for (var index = 0; index < state.orderedModifiers.length; index++) { 978 { 979 __debug_loops__ += 1; 980 981 if (__debug_loops__ > 100) { 982 console.error(INFINITE_LOOP_ERROR); 983 break; 984 } 985 } 986 987 if (state.reset === true) { 988 state.reset = false;
vendor: 6,095 bytes, lines 989-1192
989 index = -1; 990 continue; 991 } 992 993 var _state$orderedModifie = state.orderedModifiers[index], 994 fn = _state$orderedModifie.fn, 995 _state$orderedModifie2 = _state$orderedModifie.options, 996 _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2, 997 name = _state$orderedModifie.name; 998 999 if (typeof fn === 'function') { 1000 state = fn({ 1001 state: state, 1002 options: _options, 1003 name: name, 1004 instance: instance 1005 }) || state; 1006 } 1007 } 1008 }, 1009 // Async and optimistically optimized update â it will not be executed if 1010 // not necessary (debounced to run at most once-per-tick) 1011 update: debounce(function () { 1012 return new Promise(function (resolve) { 1013 instance.forceUpdate(); 1014 resolve(state); 1015 }); 1016 }), 1017 destroy: function destroy() { 1018 cleanupModifierEffects(); 1019 isDestroyed = true; 1020 } 1021 }; 1022 1023 if (!areValidElements(reference, popper)) { 1024 { 1025 console.error(INVALID_ELEMENT_ERROR); 1026 } 1027 1028 return instance; 1029 } 1030 1031 instance.setOptions(options).then(function (state) { 1032 if (!isDestroyed && options.onFirstUpdate) { 1033 options.onFirstUpdate(state); 1034 } 1035 }); // Modifiers have the ability to execute arbitrary code before the first 1036 // update cycle runs. They will be executed in the same order as the update 1037 // cycle. This is useful when a modifier adds some persistent data that 1038 // other modifiers need to use, but the modifier is run after the dependent 1039 // one. 1040 1041 function runModifierEffects() { 1042 state.orderedModifiers.forEach(function (_ref3) { 1043 var name = _ref3.name, 1044 _ref3$options = _ref3.options, 1045 options = _ref3$options === void 0 ? {} : _ref3$options, 1046 effect = _ref3.effect; 1047 1048 if (typeof effect === 'function') { 1049 var cleanupFn = effect({ 1050 state: state, 1051 name: name, 1052 instance: instance, 1053 options: options 1054 }); 1055 1056 var noopFn = function noopFn() {}; 1057 1058 effectCleanupFns.push(cleanupFn || noopFn); 1059 } 1060 }); 1061 } 1062 1063 function cleanupModifierEffects() { 1064 effectCleanupFns.forEach(function (fn) { 1065 return fn(); 1066 }); 1067 effectCleanupFns = []; 1068 } 1069 1070 return instance; 1071 }; 1072 } 1073 1074 var passive = { 1075 passive: true 1076 }; 1077 1078 function effect$2(_ref) { 1079 var state = _ref.state, 1080 instance = _ref.instance, 1081 options = _ref.options; 1082 var _options$scroll = options.scroll, 1083 scroll = _options$scroll === void 0 ? true : _options$scroll, 1084 _options$resize = options.resize, 1085 resize = _options$resize === void 0 ? true : _options$resize; 1086 var window = getWindow(state.elements.popper); 1087 var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper); 1088 1089 if (scroll) { 1090 scrollParents.forEach(function (scrollParent) { 1091 scrollParent.addEventListener('scroll', instance.update, passive); 1092 }); 1093 } 1094 1095 if (resize) { 1096 window.addEventListener('resize', instance.update, passive); 1097 } 1098 1099 return function () { 1100 if (scroll) { 1101 scrollParents.forEach(function (scrollParent) { 1102 scrollParent.removeEventListener('scroll', instance.update, passive); 1103 }); 1104 } 1105 1106 if (resize) { 1107 window.removeEventListener('resize', instance.update, passive); 1108 } 1109 }; 1110 } // eslint-disable-next-line import/no-unused-modules 1111 1112 1113 var eventListeners = { 1114 name: 'eventListeners', 1115 enabled: true, 1116 phase: 'write', 1117 fn: function fn() {}, 1118 effect: effect$2, 1119 data: {} 1120 }; 1121 1122 function popperOffsets(_ref) { 1123 var state = _ref.state, 1124 name = _ref.name; 1125 // Offsets are the actual position the popper needs to have to be 1126 // properly positioned near its reference element 1127 // This is the most basic placement, and will be adjusted by 1128 // the modifiers in the next step 1129 state.modifiersData[name] = computeOffsets({ 1130 reference: state.rects.reference, 1131 element: state.rects.popper, 1132 strategy: 'absolute', 1133 placement: state.placement 1134 }); 1135 } // eslint-disable-next-line import/no-unused-modules 1136 1137 1138 var popperOffsets$1 = { 1139 name: 'popperOffsets', 1140 enabled: true, 1141 phase: 'read', 1142 fn: popperOffsets, 1143 data: {} 1144 }; 1145 1146 var unsetSides = { 1147 top: 'auto', 1148 right: 'auto', 1149 bottom: 'auto', 1150 left: 'auto' 1151 }; // Round the offsets to the nearest suitable subpixel based on the DPR. 1152 // Zooming can change the DPR, but it seems to report a value that will 1153 // cleanly divide the values into the appropriate subpixels. 1154 1155 function roundOffsetsByDPR(_ref) { 1156 var x = _ref.x, 1157 y = _ref.y; 1158 var win = window; 1159 var dpr = win.devicePixelRatio || 1; 1160 return { 1161 x: round(round(x * dpr) / dpr) || 0, 1162 y: round(round(y * dpr) / dpr) || 0 1163 }; 1164 } 1165 1166 function mapToStyles(_ref2) { 1167 var _Object$assign2; 1168 1169 var popper = _ref2.popper, 1170 popperRect = _ref2.popperRect, 1171 placement = _ref2.placement, 1172 offsets = _ref2.offsets, 1173 position = _ref2.position, 1174 gpuAcceleration = _ref2.gpuAcceleration, 1175 adaptive = _ref2.adaptive, 1176 roundOffsets = _ref2.roundOffsets; 1177 1178 var _ref3 = roundOffsets === true ? roundOffsetsByDPR(offsets) : typeof roundOffsets === 'function' ? roundOffsets(offsets) : offsets, 1179 _ref3$x = _ref3.x, 1180 x = _ref3$x === void 0 ? 0 : _ref3$x, 1181 _ref3$y = _ref3.y, 1182 y = _ref3$y === void 0 ? 0 : _ref3$y; 1183 1184 var hasX = offsets.hasOwnProperty('x'); 1185 var hasY = offsets.hasOwnProperty('y'); 1186 var sideX = left; 1187 var sideY = top; 1188 var win = window; 1189 1190 if (adaptive) { 1191 var offsetParent = getOffsetParent(popper); 1192 var heightProp = 'clientHeight';
vendor: 4,215 bytes, lines 1193-1297
1193 var widthProp = 'clientWidth'; 1194 1195 if (offsetParent === getWindow(popper)) { 1196 offsetParent = getDocumentElement(popper); 1197 1198 if (getComputedStyle(offsetParent).position !== 'static') { 1199 heightProp = 'scrollHeight'; 1200 widthProp = 'scrollWidth'; 1201 } 1202 } // $FlowFixMe[incompatible-cast]: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it 1203 1204 1205 offsetParent = offsetParent; 1206 1207 if (placement === top) { 1208 sideY = bottom; // $FlowFixMe[prop-missing] 1209 1210 y -= offsetParent[heightProp] - popperRect.height; 1211 y *= gpuAcceleration ? 1 : -1; 1212 } 1213 1214 if (placement === left) { 1215 sideX = right; // $FlowFixMe[prop-missing] 1216 1217 x -= offsetParent[widthProp] - popperRect.width; 1218 x *= gpuAcceleration ? 1 : -1; 1219 } 1220 } 1221 1222 var commonStyles = Object.assign({ 1223 position: position 1224 }, adaptive && unsetSides); 1225 1226 if (gpuAcceleration) { 1227 var _Object$assign; 1228 1229 return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? '0' : '', _Object$assign[sideX] = hasX ? '0' : '', _Object$assign.transform = (win.devicePixelRatio || 1) < 2 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign)); 1230 } 1231 1232 return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2)); 1233 } 1234 1235 function computeStyles(_ref4) { 1236 var state = _ref4.state, 1237 options = _ref4.options; 1238 var _options$gpuAccelerat = options.gpuAcceleration, 1239 gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat, 1240 _options$adaptive = options.adaptive, 1241 adaptive = _options$adaptive === void 0 ? true : _options$adaptive, 1242 _options$roundOffsets = options.roundOffsets, 1243 roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets; 1244 1245 { 1246 var transitionProperty = getComputedStyle(state.elements.popper).transitionProperty || ''; 1247 1248 if (adaptive && ['transform', 'top', 'right', 'bottom', 'left'].some(function (property) { 1249 return transitionProperty.indexOf(property) >= 0; 1250 })) { 1251 console.warn(['Popper: Detected CSS transitions on at least one of the following', 'CSS properties: "transform", "top", "right", "bottom", "left".', '\n\n', 'Disable the "computeStyles" modifier\'s `adaptive` option to allow', 'for smooth transitions, or remove these properties from the CSS', 'transition declaration on the popper element if only transitioning', 'opacity or background-color for example.', '\n\n', 'We recommend using the popper element as a wrapper around an inner', 'element that can have any CSS property transitioned for animations.'].join(' ')); 1252 } 1253 } 1254 1255 var commonStyles = { 1256 placement: getBasePlacement(state.placement), 1257 popper: state.elements.popper, 1258 popperRect: state.rects.popper, 1259 gpuAcceleration: gpuAcceleration 1260 }; 1261 1262 if (state.modifiersData.popperOffsets != null) { 1263 state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, { 1264 offsets: state.modifiersData.popperOffsets, 1265 position: state.options.strategy, 1266 adaptive: adaptive, 1267 roundOffsets: roundOffsets 1268 }))); 1269 } 1270 1271 if (state.modifiersData.arrow != null) { 1272 state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, { 1273 offsets: state.modifiersData.arrow, 1274 position: 'absolute', 1275 adaptive: false, 1276 roundOffsets: roundOffsets 1277 }))); 1278 } 1279 1280 state.attributes.popper = Object.assign({}, state.attributes.popper, { 1281 'data-popper-placement': state.placement 1282 }); 1283 } // eslint-disable-next-line import/no-unused-modules 1284 1285 1286 var computeStyles$1 = { 1287 name: 'computeStyles', 1288 enabled: true, 1289 phase: 'beforeWrite', 1290 fn: computeStyles, 1291 data: {} 1292 }; 1293 1294 // and applies them to the HTMLElements such as popper and arrow 1295 1296 function applyStyles(_ref) { 1297 var state = _ref.state;
vendor: 8,677 bytes, lines 1298-1552
1298 Object.keys(state.elements).forEach(function (name) { 1299 var style = state.styles[name] || {}; 1300 var attributes = state.attributes[name] || {}; 1301 var element = state.elements[name]; // arrow is optional + virtual elements 1302 1303 if (!isHTMLElement(element) || !getNodeName(element)) { 1304 return; 1305 } // Flow doesn't support to extend this property, but it's the most 1306 // effective way to apply styles to an HTMLElement 1307 // $FlowFixMe[cannot-write] 1308 1309 1310 Object.assign(element.style, style); 1311 Object.keys(attributes).forEach(function (name) { 1312 var value = attributes[name]; 1313 1314 if (value === false) { 1315 element.removeAttribute(name); 1316 } else { 1317 element.setAttribute(name, value === true ? '' : value); 1318 } 1319 }); 1320 }); 1321 } 1322 1323 function effect$1(_ref2) { 1324 var state = _ref2.state; 1325 var initialStyles = { 1326 popper: { 1327 position: state.options.strategy, 1328 left: '0', 1329 top: '0', 1330 margin: '0' 1331 }, 1332 arrow: { 1333 position: 'absolute' 1334 }, 1335 reference: {} 1336 }; 1337 Object.assign(state.elements.popper.style, initialStyles.popper); 1338 state.styles = initialStyles; 1339 1340 if (state.elements.arrow) { 1341 Object.assign(state.elements.arrow.style, initialStyles.arrow); 1342 } 1343 1344 return function () { 1345 Object.keys(state.elements).forEach(function (name) { 1346 var element = state.elements[name]; 1347 var attributes = state.attributes[name] || {}; 1348 var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]); // Set all values to an empty string to unset them 1349 1350 var style = styleProperties.reduce(function (style, property) { 1351 style[property] = ''; 1352 return style; 1353 }, {}); // arrow is optional + virtual elements 1354 1355 if (!isHTMLElement(element) || !getNodeName(element)) { 1356 return; 1357 } 1358 1359 Object.assign(element.style, style); 1360 Object.keys(attributes).forEach(function (attribute) { 1361 element.removeAttribute(attribute); 1362 }); 1363 }); 1364 }; 1365 } // eslint-disable-next-line import/no-unused-modules 1366 1367 1368 var applyStyles$1 = { 1369 name: 'applyStyles', 1370 enabled: true, 1371 phase: 'write', 1372 fn: applyStyles, 1373 effect: effect$1, 1374 requires: ['computeStyles'] 1375 }; 1376 1377 function distanceAndSkiddingToXY(placement, rects, offset) { 1378 var basePlacement = getBasePlacement(placement); 1379 var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1; 1380 1381 var _ref = typeof offset === 'function' ? offset(Object.assign({}, rects, { 1382 placement: placement 1383 })) : offset, 1384 skidding = _ref[0], 1385 distance = _ref[1]; 1386 1387 skidding = skidding || 0; 1388 distance = (distance || 0) * invertDistance; 1389 return [left, right].indexOf(basePlacement) >= 0 ? { 1390 x: distance, 1391 y: skidding 1392 } : { 1393 x: skidding, 1394 y: distance 1395 }; 1396 } 1397 1398 function offset(_ref2) { 1399 var state = _ref2.state, 1400 options = _ref2.options, 1401 name = _ref2.name; 1402 var _options$offset = options.offset, 1403 offset = _options$offset === void 0 ? [0, 0] : _options$offset; 1404 var data = placements.reduce(function (acc, placement) { 1405 acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset); 1406 return acc; 1407 }, {}); 1408 var _data$state$placement = data[state.placement], 1409 x = _data$state$placement.x, 1410 y = _data$state$placement.y; 1411 1412 if (state.modifiersData.popperOffsets != null) { 1413 state.modifiersData.popperOffsets.x += x; 1414 state.modifiersData.popperOffsets.y += y; 1415 } 1416 1417 state.modifiersData[name] = data; 1418 } // eslint-disable-next-line import/no-unused-modules 1419 1420 1421 var offset$1 = { 1422 name: 'offset', 1423 enabled: true, 1424 phase: 'main', 1425 requires: ['popperOffsets'], 1426 fn: offset 1427 }; 1428 1429 var hash$1 = { 1430 left: 'right', 1431 right: 'left', 1432 bottom: 'top', 1433 top: 'bottom' 1434 }; 1435 function getOppositePlacement(placement) { 1436 return placement.replace(/left|right|bottom|top/g, function (matched) { 1437 return hash$1[matched]; 1438 }); 1439 } 1440 1441 var hash = { 1442 start: 'end', 1443 end: 'start' 1444 }; 1445 function getOppositeVariationPlacement(placement) { 1446 return placement.replace(/start|end/g, function (matched) { 1447 return hash[matched]; 1448 }); 1449 } 1450 1451 function computeAutoPlacement(state, options) { 1452 if (options === void 0) { 1453 options = {}; 1454 } 1455 1456 var _options = options, 1457 placement = _options.placement, 1458 boundary = _options.boundary, 1459 rootBoundary = _options.rootBoundary, 1460 padding = _options.padding, 1461 flipVariations = _options.flipVariations, 1462 _options$allowedAutoP = _options.allowedAutoPlacements, 1463 allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP; 1464 var variation = getVariation(placement); 1465 var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function (placement) { 1466 return getVariation(placement) === variation; 1467 }) : basePlacements; 1468 var allowedPlacements = placements$1.filter(function (placement) { 1469 return allowedAutoPlacements.indexOf(placement) >= 0; 1470 }); 1471 1472 if (allowedPlacements.length === 0) { 1473 allowedPlacements = placements$1; 1474 1475 { 1476 console.error(['Popper: The `allowedAutoPlacements` option did not allow any', 'placements. Ensure the `placement` option matches the variation', 'of the allowed placements.', 'For example, "auto" cannot be used to allow "bottom-start".', 'Use "auto-start" instead.'].join(' ')); 1477 } 1478 } // $FlowFixMe[incompatible-type]: Flow seems to have problems with two array unions... 1479 1480 1481 var overflows = allowedPlacements.reduce(function (acc, placement) { 1482 acc[placement] = detectOverflow(state, { 1483 placement: placement, 1484 boundary: boundary, 1485 rootBoundary: rootBoundary, 1486 padding: padding 1487 })[getBasePlacement(placement)]; 1488 return acc; 1489 }, {}); 1490 return Object.keys(overflows).sort(function (a, b) { 1491 return overflows[a] - overflows[b]; 1492 }); 1493 } 1494 1495 function getExpandedFallbackPlacements(placement) { 1496 if (getBasePlacement(placement) === auto) { 1497 return []; 1498 } 1499 1500 var oppositePlacement = getOppositePlacement(placement); 1501 return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)]; 1502 } 1503 1504 function flip(_ref) { 1505 var state = _ref.state, 1506 options = _ref.options, 1507 name = _ref.name; 1508 1509 if (state.modifiersData[name]._skip) { 1510 return; 1511 } 1512 1513 var _options$mainAxis = options.mainAxis, 1514 checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis, 1515 _options$altAxis = options.altAxis, 1516 checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis, 1517 specifiedFallbackPlacements = options.fallbackPlacements, 1518 padding = options.padding, 1519 boundary = options.boundary, 1520 rootBoundary = options.rootBoundary, 1521 altBoundary = options.altBoundary, 1522 _options$flipVariatio = options.flipVariations, 1523 flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio, 1524 allowedAutoPlacements = options.allowedAutoPlacements; 1525 var preferredPlacement = state.options.placement; 1526 var basePlacement = getBasePlacement(preferredPlacement); 1527 var isBasePlacement = basePlacement === preferredPlacement; 1528 var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement)); 1529 var placements = [preferredPlacement].concat(fallbackPlacements).reduce(function (acc, placement) { 1530 return acc.concat(getBasePlacement(placement) === auto ? computeAutoPlacement(state, { 1531 placement: placement, 1532 boundary: boundary, 1533 rootBoundary: rootBoundary, 1534 padding: padding, 1535 flipVariations: flipVariations, 1536 allowedAutoPlacements: allowedAutoPlacements 1537 }) : placement); 1538 }, []); 1539 var referenceRect = state.rects.reference; 1540 var popperRect = state.rects.popper; 1541 var checksMap = new Map(); 1542 var makeFallbackChecks = true; 1543 var firstFittingPlacement = placements[0]; 1544 1545 for (var i = 0; i < placements.length; i++) { 1546 var placement = placements[i]; 1547 1548 var _basePlacement = getBasePlacement(placement); 1549 1550 var isStartVariation = getVariation(placement) === start; 1551 var isVertical = [top, bottom].indexOf(_basePlacement) >= 0; 1552 var len = isVertical ? 'width' : 'height';
vendor: 9,084 bytes, lines 1553-1791
1553 var overflow = detectOverflow(state, { 1554 placement: placement, 1555 boundary: boundary, 1556 rootBoundary: rootBoundary, 1557 altBoundary: altBoundary, 1558 padding: padding 1559 }); 1560 var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top; 1561 1562 if (referenceRect[len] > popperRect[len]) { 1563 mainVariationSide = getOppositePlacement(mainVariationSide); 1564 } 1565 1566 var altVariationSide = getOppositePlacement(mainVariationSide); 1567 var checks = []; 1568 1569 if (checkMainAxis) { 1570 checks.push(overflow[_basePlacement] <= 0); 1571 } 1572 1573 if (checkAltAxis) { 1574 checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0); 1575 } 1576 1577 if (checks.every(function (check) { 1578 return check; 1579 })) { 1580 firstFittingPlacement = placement; 1581 makeFallbackChecks = false; 1582 break; 1583 } 1584 1585 checksMap.set(placement, checks); 1586 } 1587 1588 if (makeFallbackChecks) { 1589 // `2` may be desired in some cases â research later 1590 var numberOfChecks = flipVariations ? 3 : 1; 1591 1592 var _loop = function _loop(_i) { 1593 var fittingPlacement = placements.find(function (placement) { 1594 var checks = checksMap.get(placement); 1595 1596 if (checks) { 1597 return checks.slice(0, _i).every(function (check) { 1598 return check; 1599 }); 1600 } 1601 }); 1602 1603 if (fittingPlacement) { 1604 firstFittingPlacement = fittingPlacement; 1605 return "break"; 1606 } 1607 }; 1608 1609 for (var _i = numberOfChecks; _i > 0; _i--) { 1610 var _ret = _loop(_i); 1611 1612 if (_ret === "break") break; 1613 } 1614 } 1615 1616 if (state.placement !== firstFittingPlacement) { 1617 state.modifiersData[name]._skip = true; 1618 state.placement = firstFittingPlacement; 1619 state.reset = true; 1620 } 1621 } // eslint-disable-next-line import/no-unused-modules 1622 1623 1624 var flip$1 = { 1625 name: 'flip', 1626 enabled: true, 1627 phase: 'main', 1628 fn: flip, 1629 requiresIfExists: ['offset'], 1630 data: { 1631 _skip: false 1632 } 1633 }; 1634 1635 function getAltAxis(axis) { 1636 return axis === 'x' ? 'y' : 'x'; 1637 } 1638 1639 function within(min$1, value, max$1) { 1640 return max(min$1, min(value, max$1)); 1641 } 1642 1643 function preventOverflow(_ref) { 1644 var state = _ref.state, 1645 options = _ref.options, 1646 name = _ref.name; 1647 var _options$mainAxis = options.mainAxis, 1648 checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis, 1649 _options$altAxis = options.altAxis, 1650 checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis, 1651 boundary = options.boundary, 1652 rootBoundary = options.rootBoundary, 1653 altBoundary = options.altBoundary, 1654 padding = options.padding, 1655 _options$tether = options.tether, 1656 tether = _options$tether === void 0 ? true : _options$tether, 1657 _options$tetherOffset = options.tetherOffset, 1658 tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset; 1659 var overflow = detectOverflow(state, { 1660 boundary: boundary, 1661 rootBoundary: rootBoundary, 1662 padding: padding, 1663 altBoundary: altBoundary 1664 }); 1665 var basePlacement = getBasePlacement(state.placement); 1666 var variation = getVariation(state.placement); 1667 var isBasePlacement = !variation; 1668 var mainAxis = getMainAxisFromPlacement(basePlacement); 1669 var altAxis = getAltAxis(mainAxis); 1670 var popperOffsets = state.modifiersData.popperOffsets; 1671 var referenceRect = state.rects.reference; 1672 var popperRect = state.rects.popper; 1673 var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, { 1674 placement: state.placement 1675 })) : tetherOffset; 1676 var data = { 1677 x: 0, 1678 y: 0 1679 }; 1680 1681 if (!popperOffsets) { 1682 return; 1683 } 1684 1685 if (checkMainAxis || checkAltAxis) { 1686 var mainSide = mainAxis === 'y' ? top : left; 1687 var altSide = mainAxis === 'y' ? bottom : right; 1688 var len = mainAxis === 'y' ? 'height' : 'width'; 1689 var offset = popperOffsets[mainAxis]; 1690 var min$1 = popperOffsets[mainAxis] + overflow[mainSide]; 1691 var max$1 = popperOffsets[mainAxis] - overflow[altSide]; 1692 var additive = tether ? -popperRect[len] / 2 : 0; 1693 var minLen = variation === start ? referenceRect[len] : popperRect[len]; 1694 var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go 1695 // outside the reference bounds 1696 1697 var arrowElement = state.elements.arrow; 1698 var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : { 1699 width: 0, 1700 height: 0 1701 }; 1702 var arrowPaddingObject = state.modifiersData['arrow#persistent'] ? state.modifiersData['arrow#persistent'].padding : getFreshSideObject(); 1703 var arrowPaddingMin = arrowPaddingObject[mainSide]; 1704 var arrowPaddingMax = arrowPaddingObject[altSide]; // If the reference length is smaller than the arrow length, we don't want 1705 // to include its full size in the calculation. If the reference is small 1706 // and near the edge of a boundary, the popper can overflow even if the 1707 // reference is not overflowing as well (e.g. virtual elements with no 1708 // width or height) 1709 1710 var arrowLen = within(0, referenceRect[len], arrowRect[len]); 1711 var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - tetherOffsetValue : minLen - arrowLen - arrowPaddingMin - tetherOffsetValue; 1712 var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + tetherOffsetValue : maxLen + arrowLen + arrowPaddingMax + tetherOffsetValue; 1713 var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow); 1714 var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0; 1715 var offsetModifierValue = state.modifiersData.offset ? state.modifiersData.offset[state.placement][mainAxis] : 0; 1716 var tetherMin = popperOffsets[mainAxis] + minOffset - offsetModifierValue - clientOffset; 1717 var tetherMax = popperOffsets[mainAxis] + maxOffset - offsetModifierValue; 1718 1719 if (checkMainAxis) { 1720 var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1); 1721 popperOffsets[mainAxis] = preventedOffset; 1722 data[mainAxis] = preventedOffset - offset; 1723 } 1724 1725 if (checkAltAxis) { 1726 var _mainSide = mainAxis === 'x' ? top : left; 1727 1728 var _altSide = mainAxis === 'x' ? bottom : right; 1729 1730 var _offset = popperOffsets[altAxis]; 1731 1732 var _min = _offset + overflow[_mainSide]; 1733 1734 var _max = _offset - overflow[_altSide]; 1735 1736 var _preventedOffset = within(tether ? min(_min, tetherMin) : _min, _offset, tether ? max(_max, tetherMax) : _max); 1737 1738 popperOffsets[altAxis] = _preventedOffset; 1739 data[altAxis] = _preventedOffset - _offset; 1740 } 1741 } 1742 1743 state.modifiersData[name] = data; 1744 } // eslint-disable-next-line import/no-unused-modules 1745 1746 1747 var preventOverflow$1 = { 1748 name: 'preventOverflow', 1749 enabled: true, 1750 phase: 'main', 1751 fn: preventOverflow, 1752 requiresIfExists: ['offset'] 1753 }; 1754 1755 var toPaddingObject = function toPaddingObject(padding, state) { 1756 padding = typeof padding === 'function' ? padding(Object.assign({}, state.rects, { 1757 placement: state.placement 1758 })) : padding; 1759 return mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements)); 1760 }; 1761 1762 function arrow(_ref) { 1763 var _state$modifiersData$; 1764 1765 var state = _ref.state, 1766 name = _ref.name, 1767 options = _ref.options; 1768 var arrowElement = state.elements.arrow; 1769 var popperOffsets = state.modifiersData.popperOffsets; 1770 var basePlacement = getBasePlacement(state.placement); 1771 var axis = getMainAxisFromPlacement(basePlacement); 1772 var isVertical = [left, right].indexOf(basePlacement) >= 0; 1773 var len = isVertical ? 'height' : 'width'; 1774 1775 if (!arrowElement || !popperOffsets) { 1776 return; 1777 } 1778 1779 var paddingObject = toPaddingObject(options.padding, state); 1780 var arrowRect = getLayoutRect(arrowElement); 1781 var minProp = axis === 'y' ? top : left; 1782 var maxProp = axis === 'y' ? bottom : right; 1783 var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len]; 1784 var startDiff = popperOffsets[axis] - state.rects.reference[axis]; 1785 var arrowOffsetParent = getOffsetParent(arrowElement); 1786 var clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0; 1787 var centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the popper if the center point is 1788 // outside of the popper bounds 1789 1790 var min = paddingObject[minProp]; 1791 var max = clientSize - arrowRect[len] - paddingObject[maxPro
vendor: 4,714 bytes, lines 1791-1932
1791p]; 1792 var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference; 1793 var offset = within(min, center, max); // Prevents breaking syntax highlighting... 1794 1795 var axisProp = axis; 1796 state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$); 1797 } 1798 1799 function effect(_ref2) { 1800 var state = _ref2.state, 1801 options = _ref2.options; 1802 var _options$element = options.element, 1803 arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element; 1804 1805 if (arrowElement == null) { 1806 return; 1807 } // CSS selector 1808 1809 1810 if (typeof arrowElement === 'string') { 1811 arrowElement = state.elements.popper.querySelector(arrowElement); 1812 1813 if (!arrowElement) { 1814 return; 1815 } 1816 } 1817 1818 { 1819 if (!isHTMLElement(arrowElement)) { 1820 console.error(['Popper: "arrow" element must be an HTMLElement (not an SVGElement).', 'To use an SVG arrow, wrap it in an HTMLElement that will be used as', 'the arrow.'].join(' ')); 1821 } 1822 } 1823 1824 if (!contains(state.elements.popper, arrowElement)) { 1825 { 1826 console.error(['Popper: "arrow" modifier\'s `element` must be a child of the popper', 'element.'].join(' ')); 1827 } 1828 1829 return; 1830 } 1831 1832 state.elements.arrow = arrowElement; 1833 } // eslint-disable-next-line import/no-unused-modules 1834 1835 1836 var arrow$1 = { 1837 name: 'arrow', 1838 enabled: true, 1839 phase: 'main', 1840 fn: arrow, 1841 effect: effect, 1842 requires: ['popperOffsets'], 1843 requiresIfExists: ['preventOverflow'] 1844 }; 1845 1846 function getSideOffsets(overflow, rect, preventedOffsets) { 1847 if (preventedOffsets === void 0) { 1848 preventedOffsets = { 1849 x: 0, 1850 y: 0 1851 }; 1852 } 1853 1854 return { 1855 top: overflow.top - rect.height - preventedOffsets.y, 1856 right: overflow.right - rect.width + preventedOffsets.x, 1857 bottom: overflow.bottom - rect.height + preventedOffsets.y, 1858 left: overflow.left - rect.width - preventedOffsets.x 1859 }; 1860 } 1861 1862 function isAnySideFullyClipped(overflow) { 1863 return [top, right, bottom, left].some(function (side) { 1864 return overflow[side] >= 0; 1865 }); 1866 } 1867 1868 function hide(_ref) { 1869 var state = _ref.state, 1870 name = _ref.name; 1871 var referenceRect = state.rects.reference; 1872 var popperRect = state.rects.popper; 1873 var preventedOffsets = state.modifiersData.preventOverflow; 1874 var referenceOverflow = detectOverflow(state, { 1875 elementContext: 'reference' 1876 }); 1877 var popperAltOverflow = detectOverflow(state, { 1878 altBoundary: true 1879 }); 1880 var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect); 1881 var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets); 1882 var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets); 1883 var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets); 1884 state.modifiersData[name] = { 1885 referenceClippingOffsets: referenceClippingOffsets, 1886 popperEscapeOffsets: popperEscapeOffsets, 1887 isReferenceHidden: isReferenceHidden, 1888 hasPopperEscaped: hasPopperEscaped 1889 }; 1890 state.attributes.popper = Object.assign({}, state.attributes.popper, { 1891 'data-popper-reference-hidden': isReferenceHidden, 1892 'data-popper-escaped': hasPopperEscaped 1893 }); 1894 } // eslint-disable-next-line import/no-unused-modules 1895 1896 1897 var hide$1 = { 1898 name: 'hide', 1899 enabled: true, 1900 phase: 'main', 1901 requiresIfExists: ['preventOverflow'], 1902 fn: hide 1903 }; 1904 1905 var defaultModifiers$1 = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1]; 1906 var createPopper$1 = /*#__PURE__*/popperGenerator({ 1907 defaultModifiers: defaultModifiers$1 1908 }); // eslint-disable-next-line import/no-unused-modules 1909 1910 var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1]; 1911 var createPopper = /*#__PURE__*/popperGenerator({ 1912 defaultModifiers: defaultModifiers 1913 }); // eslint-disable-next-line import/no-unused-modules 1914 1915 exports.applyStyles = applyStyles$1; 1916 exports.arrow = arrow$1; 1917 exports.computeStyles = computeStyles$1; 1918 exports.createPopper = createPopper; 1919 exports.createPopperLite = createPopper$1; 1920 exports.defaultModifiers = defaultModifiers; 1921 exports.detectOverflow = detectOverflow; 1922 exports.eventListeners = eventListeners; 1923 exports.flip = flip$1; 1924 exports.hide = hide$1; 1925 exports.offset = offset$1; 1926 exports.popperGenerator = popperGenerator; 1927 exports.popperOffsets = popperOffsets$1; 1928 exports.preventOverflow = preventOverflow$1; 1929 1930 Object.defineProperty(exports, '__esModule', { value: true }); 1931 1932})));
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.