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