bootstrap.bundle.js
4 years ago
bootstrap.bundle.min.js
4 years ago
bootstrap.js
4 years ago
bootstrap.min.js
4 years ago
bootstrap.bundle.js
6813 lines
| 1 | /*! |
| 2 | * Bootstrap v5.1.3 (https://getbootstrap.com/) |
| 3 | * Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) |
| 4 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 5 | */ |
| 6 | (function (global, factory) { |
| 7 | typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : |
| 8 | typeof define === 'function' && define.amd ? define(factory) : |
| 9 | (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.bootstrap = factory()); |
| 10 | })(this, (function () { 'use strict'; |
| 11 | |
| 12 | /** |
| 13 | * -------------------------------------------------------------------------- |
| 14 | * Bootstrap (v5.1.3): util/index.js |
| 15 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 16 | * -------------------------------------------------------------------------- |
| 17 | */ |
| 18 | const MAX_UID = 1000000; |
| 19 | const MILLISECONDS_MULTIPLIER = 1000; |
| 20 | const TRANSITION_END = 'transitionend'; // Shoutout AngusCroll (https://goo.gl/pxwQGp) |
| 21 | |
| 22 | const toType = obj => { |
| 23 | if (obj === null || obj === undefined) { |
| 24 | return `${obj}`; |
| 25 | } |
| 26 | |
| 27 | return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase(); |
| 28 | }; |
| 29 | /** |
| 30 | * -------------------------------------------------------------------------- |
| 31 | * Public Util Api |
| 32 | * -------------------------------------------------------------------------- |
| 33 | */ |
| 34 | |
| 35 | |
| 36 | const getUID = prefix => { |
| 37 | do { |
| 38 | prefix += Math.floor(Math.random() * MAX_UID); |
| 39 | } while (document.getElementById(prefix)); |
| 40 | |
| 41 | return prefix; |
| 42 | }; |
| 43 | |
| 44 | const getSelector = element => { |
| 45 | let selector = element.getAttribute('data-bs-target'); |
| 46 | |
| 47 | if (!selector || selector === '#') { |
| 48 | let hrefAttr = element.getAttribute('href'); // The only valid content that could double as a selector are IDs or classes, |
| 49 | // so everything starting with `#` or `.`. If a "real" URL is used as the selector, |
| 50 | // `document.querySelector` will rightfully complain it is invalid. |
| 51 | // See https://github.com/twbs/bootstrap/issues/32273 |
| 52 | |
| 53 | if (!hrefAttr || !hrefAttr.includes('#') && !hrefAttr.startsWith('.')) { |
| 54 | return null; |
| 55 | } // Just in case some CMS puts out a full URL with the anchor appended |
| 56 | |
| 57 | |
| 58 | if (hrefAttr.includes('#') && !hrefAttr.startsWith('#')) { |
| 59 | hrefAttr = `#${hrefAttr.split('#')[1]}`; |
| 60 | } |
| 61 | |
| 62 | selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : null; |
| 63 | } |
| 64 | |
| 65 | return selector; |
| 66 | }; |
| 67 | |
| 68 | const getSelectorFromElement = element => { |
| 69 | const selector = getSelector(element); |
| 70 | |
| 71 | if (selector) { |
| 72 | return document.querySelector(selector) ? selector : null; |
| 73 | } |
| 74 | |
| 75 | return null; |
| 76 | }; |
| 77 | |
| 78 | const getElementFromSelector = element => { |
| 79 | const selector = getSelector(element); |
| 80 | return selector ? document.querySelector(selector) : null; |
| 81 | }; |
| 82 | |
| 83 | const getTransitionDurationFromElement = element => { |
| 84 | if (!element) { |
| 85 | return 0; |
| 86 | } // Get transition-duration of the element |
| 87 | |
| 88 | |
| 89 | let { |
| 90 | transitionDuration, |
| 91 | transitionDelay |
| 92 | } = window.getComputedStyle(element); |
| 93 | const floatTransitionDuration = Number.parseFloat(transitionDuration); |
| 94 | const floatTransitionDelay = Number.parseFloat(transitionDelay); // Return 0 if element or transition duration is not found |
| 95 | |
| 96 | if (!floatTransitionDuration && !floatTransitionDelay) { |
| 97 | return 0; |
| 98 | } // If multiple durations are defined, take the first |
| 99 | |
| 100 | |
| 101 | transitionDuration = transitionDuration.split(',')[0]; |
| 102 | transitionDelay = transitionDelay.split(',')[0]; |
| 103 | return (Number.parseFloat(transitionDuration) + Number.parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER; |
| 104 | }; |
| 105 | |
| 106 | const triggerTransitionEnd = element => { |
| 107 | element.dispatchEvent(new Event(TRANSITION_END)); |
| 108 | }; |
| 109 | |
| 110 | const isElement$1 = obj => { |
| 111 | if (!obj || typeof obj !== 'object') { |
| 112 | return false; |
| 113 | } |
| 114 | |
| 115 | if (typeof obj.jquery !== 'undefined') { |
| 116 | obj = obj[0]; |
| 117 | } |
| 118 | |
| 119 | return typeof obj.nodeType !== 'undefined'; |
| 120 | }; |
| 121 | |
| 122 | const getElement = obj => { |
| 123 | if (isElement$1(obj)) { |
| 124 | // it's a jQuery object or a node element |
| 125 | return obj.jquery ? obj[0] : obj; |
| 126 | } |
| 127 | |
| 128 | if (typeof obj === 'string' && obj.length > 0) { |
| 129 | return document.querySelector(obj); |
| 130 | } |
| 131 | |
| 132 | return null; |
| 133 | }; |
| 134 | |
| 135 | const typeCheckConfig = (componentName, config, configTypes) => { |
| 136 | Object.keys(configTypes).forEach(property => { |
| 137 | const expectedTypes = configTypes[property]; |
| 138 | const value = config[property]; |
| 139 | const valueType = value && isElement$1(value) ? 'element' : toType(value); |
| 140 | |
| 141 | if (!new RegExp(expectedTypes).test(valueType)) { |
| 142 | throw new TypeError(`${componentName.toUpperCase()}: Option "${property}" provided type "${valueType}" but expected type "${expectedTypes}".`); |
| 143 | } |
| 144 | }); |
| 145 | }; |
| 146 | |
| 147 | const isVisible = element => { |
| 148 | if (!isElement$1(element) || element.getClientRects().length === 0) { |
| 149 | return false; |
| 150 | } |
| 151 | |
| 152 | return getComputedStyle(element).getPropertyValue('visibility') === 'visible'; |
| 153 | }; |
| 154 | |
| 155 | const isDisabled = element => { |
| 156 | if (!element || element.nodeType !== Node.ELEMENT_NODE) { |
| 157 | return true; |
| 158 | } |
| 159 | |
| 160 | if (element.classList.contains('disabled')) { |
| 161 | return true; |
| 162 | } |
| 163 | |
| 164 | if (typeof element.disabled !== 'undefined') { |
| 165 | return element.disabled; |
| 166 | } |
| 167 | |
| 168 | return element.hasAttribute('disabled') && element.getAttribute('disabled') !== 'false'; |
| 169 | }; |
| 170 | |
| 171 | const findShadowRoot = element => { |
| 172 | if (!document.documentElement.attachShadow) { |
| 173 | return null; |
| 174 | } // Can find the shadow root otherwise it'll return the document |
| 175 | |
| 176 | |
| 177 | if (typeof element.getRootNode === 'function') { |
| 178 | const root = element.getRootNode(); |
| 179 | return root instanceof ShadowRoot ? root : null; |
| 180 | } |
| 181 | |
| 182 | if (element instanceof ShadowRoot) { |
| 183 | return element; |
| 184 | } // when we don't find a shadow root |
| 185 | |
| 186 | |
| 187 | if (!element.parentNode) { |
| 188 | return null; |
| 189 | } |
| 190 | |
| 191 | return findShadowRoot(element.parentNode); |
| 192 | }; |
| 193 | |
| 194 | const noop = () => {}; |
| 195 | /** |
| 196 | * Trick to restart an element's animation |
| 197 | * |
| 198 | * @param {HTMLElement} element |
| 199 | * @return void |
| 200 | * |
| 201 | * @see https://www.charistheo.io/blog/2021/02/restart-a-css-animation-with-javascript/#restarting-a-css-animation |
| 202 | */ |
| 203 | |
| 204 | |
| 205 | const reflow = element => { |
| 206 | // eslint-disable-next-line no-unused-expressions |
| 207 | element.offsetHeight; |
| 208 | }; |
| 209 | |
| 210 | const getjQuery = () => { |
| 211 | const { |
| 212 | jQuery |
| 213 | } = window; |
| 214 | |
| 215 | if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) { |
| 216 | return jQuery; |
| 217 | } |
| 218 | |
| 219 | return null; |
| 220 | }; |
| 221 | |
| 222 | const DOMContentLoadedCallbacks = []; |
| 223 | |
| 224 | const onDOMContentLoaded = callback => { |
| 225 | if (document.readyState === 'loading') { |
| 226 | // add listener on the first call when the document is in loading state |
| 227 | if (!DOMContentLoadedCallbacks.length) { |
| 228 | document.addEventListener('DOMContentLoaded', () => { |
| 229 | DOMContentLoadedCallbacks.forEach(callback => callback()); |
| 230 | }); |
| 231 | } |
| 232 | |
| 233 | DOMContentLoadedCallbacks.push(callback); |
| 234 | } else { |
| 235 | callback(); |
| 236 | } |
| 237 | }; |
| 238 | |
| 239 | const isRTL = () => document.documentElement.dir === 'rtl'; |
| 240 | |
| 241 | const defineJQueryPlugin = plugin => { |
| 242 | onDOMContentLoaded(() => { |
| 243 | const $ = getjQuery(); |
| 244 | /* istanbul ignore if */ |
| 245 | |
| 246 | if ($) { |
| 247 | const name = plugin.NAME; |
| 248 | const JQUERY_NO_CONFLICT = $.fn[name]; |
| 249 | $.fn[name] = plugin.jQueryInterface; |
| 250 | $.fn[name].Constructor = plugin; |
| 251 | |
| 252 | $.fn[name].noConflict = () => { |
| 253 | $.fn[name] = JQUERY_NO_CONFLICT; |
| 254 | return plugin.jQueryInterface; |
| 255 | }; |
| 256 | } |
| 257 | }); |
| 258 | }; |
| 259 | |
| 260 | const execute = callback => { |
| 261 | if (typeof callback === 'function') { |
| 262 | callback(); |
| 263 | } |
| 264 | }; |
| 265 | |
| 266 | const executeAfterTransition = (callback, transitionElement, waitForTransition = true) => { |
| 267 | if (!waitForTransition) { |
| 268 | execute(callback); |
| 269 | return; |
| 270 | } |
| 271 | |
| 272 | const durationPadding = 5; |
| 273 | const emulatedDuration = getTransitionDurationFromElement(transitionElement) + durationPadding; |
| 274 | let called = false; |
| 275 | |
| 276 | const handler = ({ |
| 277 | target |
| 278 | }) => { |
| 279 | if (target !== transitionElement) { |
| 280 | return; |
| 281 | } |
| 282 | |
| 283 | called = true; |
| 284 | transitionElement.removeEventListener(TRANSITION_END, handler); |
| 285 | execute(callback); |
| 286 | }; |
| 287 | |
| 288 | transitionElement.addEventListener(TRANSITION_END, handler); |
| 289 | setTimeout(() => { |
| 290 | if (!called) { |
| 291 | triggerTransitionEnd(transitionElement); |
| 292 | } |
| 293 | }, emulatedDuration); |
| 294 | }; |
| 295 | /** |
| 296 | * Return the previous/next element of a list. |
| 297 | * |
| 298 | * @param {array} list The list of elements |
| 299 | * @param activeElement The active element |
| 300 | * @param shouldGetNext Choose to get next or previous element |
| 301 | * @param isCycleAllowed |
| 302 | * @return {Element|elem} The proper element |
| 303 | */ |
| 304 | |
| 305 | |
| 306 | const getNextActiveElement = (list, activeElement, shouldGetNext, isCycleAllowed) => { |
| 307 | let index = list.indexOf(activeElement); // if the element does not exist in the list return an element depending on the direction and if cycle is allowed |
| 308 | |
| 309 | if (index === -1) { |
| 310 | return list[!shouldGetNext && isCycleAllowed ? list.length - 1 : 0]; |
| 311 | } |
| 312 | |
| 313 | const listLength = list.length; |
| 314 | index += shouldGetNext ? 1 : -1; |
| 315 | |
| 316 | if (isCycleAllowed) { |
| 317 | index = (index + listLength) % listLength; |
| 318 | } |
| 319 | |
| 320 | return list[Math.max(0, Math.min(index, listLength - 1))]; |
| 321 | }; |
| 322 | |
| 323 | /** |
| 324 | * -------------------------------------------------------------------------- |
| 325 | * Bootstrap (v5.1.3): dom/event-handler.js |
| 326 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 327 | * -------------------------------------------------------------------------- |
| 328 | */ |
| 329 | /** |
| 330 | * ------------------------------------------------------------------------ |
| 331 | * Constants |
| 332 | * ------------------------------------------------------------------------ |
| 333 | */ |
| 334 | |
| 335 | const namespaceRegex = /[^.]*(?=\..*)\.|.*/; |
| 336 | const stripNameRegex = /\..*/; |
| 337 | const stripUidRegex = /::\d+$/; |
| 338 | const eventRegistry = {}; // Events storage |
| 339 | |
| 340 | let uidEvent = 1; |
| 341 | const customEvents = { |
| 342 | mouseenter: 'mouseover', |
| 343 | mouseleave: 'mouseout' |
| 344 | }; |
| 345 | const customEventsRegex = /^(mouseenter|mouseleave)/i; |
| 346 | const nativeEvents = new Set(['click', 'dblclick', 'mouseup', 'mousedown', 'contextmenu', 'mousewheel', 'DOMMouseScroll', 'mouseover', 'mouseout', 'mousemove', 'selectstart', 'selectend', 'keydown', 'keypress', 'keyup', 'orientationchange', 'touchstart', 'touchmove', 'touchend', 'touchcancel', 'pointerdown', 'pointermove', 'pointerup', 'pointerleave', 'pointercancel', 'gesturestart', 'gesturechange', 'gestureend', 'focus', 'blur', 'change', 'reset', 'select', 'submit', 'focusin', 'focusout', 'load', 'unload', 'beforeunload', 'resize', 'move', 'DOMContentLoaded', 'readystatechange', 'error', 'abort', 'scroll']); |
| 347 | /** |
| 348 | * ------------------------------------------------------------------------ |
| 349 | * Private methods |
| 350 | * ------------------------------------------------------------------------ |
| 351 | */ |
| 352 | |
| 353 | function getUidEvent(element, uid) { |
| 354 | return uid && `${uid}::${uidEvent++}` || element.uidEvent || uidEvent++; |
| 355 | } |
| 356 | |
| 357 | function getEvent(element) { |
| 358 | const uid = getUidEvent(element); |
| 359 | element.uidEvent = uid; |
| 360 | eventRegistry[uid] = eventRegistry[uid] || {}; |
| 361 | return eventRegistry[uid]; |
| 362 | } |
| 363 | |
| 364 | function bootstrapHandler(element, fn) { |
| 365 | return function handler(event) { |
| 366 | event.delegateTarget = element; |
| 367 | |
| 368 | if (handler.oneOff) { |
| 369 | EventHandler.off(element, event.type, fn); |
| 370 | } |
| 371 | |
| 372 | return fn.apply(element, [event]); |
| 373 | }; |
| 374 | } |
| 375 | |
| 376 | function bootstrapDelegationHandler(element, selector, fn) { |
| 377 | return function handler(event) { |
| 378 | const domElements = element.querySelectorAll(selector); |
| 379 | |
| 380 | for (let { |
| 381 | target |
| 382 | } = event; target && target !== this; target = target.parentNode) { |
| 383 | for (let i = domElements.length; i--;) { |
| 384 | if (domElements[i] === target) { |
| 385 | event.delegateTarget = target; |
| 386 | |
| 387 | if (handler.oneOff) { |
| 388 | EventHandler.off(element, event.type, selector, fn); |
| 389 | } |
| 390 | |
| 391 | return fn.apply(target, [event]); |
| 392 | } |
| 393 | } |
| 394 | } // To please ESLint |
| 395 | |
| 396 | |
| 397 | return null; |
| 398 | }; |
| 399 | } |
| 400 | |
| 401 | function findHandler(events, handler, delegationSelector = null) { |
| 402 | const uidEventList = Object.keys(events); |
| 403 | |
| 404 | for (let i = 0, len = uidEventList.length; i < len; i++) { |
| 405 | const event = events[uidEventList[i]]; |
| 406 | |
| 407 | if (event.originalHandler === handler && event.delegationSelector === delegationSelector) { |
| 408 | return event; |
| 409 | } |
| 410 | } |
| 411 | |
| 412 | return null; |
| 413 | } |
| 414 | |
| 415 | function normalizeParams(originalTypeEvent, handler, delegationFn) { |
| 416 | const delegation = typeof handler === 'string'; |
| 417 | const originalHandler = delegation ? delegationFn : handler; |
| 418 | let typeEvent = getTypeEvent(originalTypeEvent); |
| 419 | const isNative = nativeEvents.has(typeEvent); |
| 420 | |
| 421 | if (!isNative) { |
| 422 | typeEvent = originalTypeEvent; |
| 423 | } |
| 424 | |
| 425 | return [delegation, originalHandler, typeEvent]; |
| 426 | } |
| 427 | |
| 428 | function addHandler(element, originalTypeEvent, handler, delegationFn, oneOff) { |
| 429 | if (typeof originalTypeEvent !== 'string' || !element) { |
| 430 | return; |
| 431 | } |
| 432 | |
| 433 | if (!handler) { |
| 434 | handler = delegationFn; |
| 435 | delegationFn = null; |
| 436 | } // in case of mouseenter or mouseleave wrap the handler within a function that checks for its DOM position |
| 437 | // this prevents the handler from being dispatched the same way as mouseover or mouseout does |
| 438 | |
| 439 | |
| 440 | if (customEventsRegex.test(originalTypeEvent)) { |
| 441 | const wrapFn = fn => { |
| 442 | return function (event) { |
| 443 | if (!event.relatedTarget || event.relatedTarget !== event.delegateTarget && !event.delegateTarget.contains(event.relatedTarget)) { |
| 444 | return fn.call(this, event); |
| 445 | } |
| 446 | }; |
| 447 | }; |
| 448 | |
| 449 | if (delegationFn) { |
| 450 | delegationFn = wrapFn(delegationFn); |
| 451 | } else { |
| 452 | handler = wrapFn(handler); |
| 453 | } |
| 454 | } |
| 455 | |
| 456 | const [delegation, originalHandler, typeEvent] = normalizeParams(originalTypeEvent, handler, delegationFn); |
| 457 | const events = getEvent(element); |
| 458 | const handlers = events[typeEvent] || (events[typeEvent] = {}); |
| 459 | const previousFn = findHandler(handlers, originalHandler, delegation ? handler : null); |
| 460 | |
| 461 | if (previousFn) { |
| 462 | previousFn.oneOff = previousFn.oneOff && oneOff; |
| 463 | return; |
| 464 | } |
| 465 | |
| 466 | const uid = getUidEvent(originalHandler, originalTypeEvent.replace(namespaceRegex, '')); |
| 467 | const fn = delegation ? bootstrapDelegationHandler(element, handler, delegationFn) : bootstrapHandler(element, handler); |
| 468 | fn.delegationSelector = delegation ? handler : null; |
| 469 | fn.originalHandler = originalHandler; |
| 470 | fn.oneOff = oneOff; |
| 471 | fn.uidEvent = uid; |
| 472 | handlers[uid] = fn; |
| 473 | element.addEventListener(typeEvent, fn, delegation); |
| 474 | } |
| 475 | |
| 476 | function removeHandler(element, events, typeEvent, handler, delegationSelector) { |
| 477 | const fn = findHandler(events[typeEvent], handler, delegationSelector); |
| 478 | |
| 479 | if (!fn) { |
| 480 | return; |
| 481 | } |
| 482 | |
| 483 | element.removeEventListener(typeEvent, fn, Boolean(delegationSelector)); |
| 484 | delete events[typeEvent][fn.uidEvent]; |
| 485 | } |
| 486 | |
| 487 | function removeNamespacedHandlers(element, events, typeEvent, namespace) { |
| 488 | const storeElementEvent = events[typeEvent] || {}; |
| 489 | Object.keys(storeElementEvent).forEach(handlerKey => { |
| 490 | if (handlerKey.includes(namespace)) { |
| 491 | const event = storeElementEvent[handlerKey]; |
| 492 | removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector); |
| 493 | } |
| 494 | }); |
| 495 | } |
| 496 | |
| 497 | function getTypeEvent(event) { |
| 498 | // allow to get the native events from namespaced events ('click.bs.button' --> 'click') |
| 499 | event = event.replace(stripNameRegex, ''); |
| 500 | return customEvents[event] || event; |
| 501 | } |
| 502 | |
| 503 | const EventHandler = { |
| 504 | on(element, event, handler, delegationFn) { |
| 505 | addHandler(element, event, handler, delegationFn, false); |
| 506 | }, |
| 507 | |
| 508 | one(element, event, handler, delegationFn) { |
| 509 | addHandler(element, event, handler, delegationFn, true); |
| 510 | }, |
| 511 | |
| 512 | off(element, originalTypeEvent, handler, delegationFn) { |
| 513 | if (typeof originalTypeEvent !== 'string' || !element) { |
| 514 | return; |
| 515 | } |
| 516 | |
| 517 | const [delegation, originalHandler, typeEvent] = normalizeParams(originalTypeEvent, handler, delegationFn); |
| 518 | const inNamespace = typeEvent !== originalTypeEvent; |
| 519 | const events = getEvent(element); |
| 520 | const isNamespace = originalTypeEvent.startsWith('.'); |
| 521 | |
| 522 | if (typeof originalHandler !== 'undefined') { |
| 523 | // Simplest case: handler is passed, remove that listener ONLY. |
| 524 | if (!events || !events[typeEvent]) { |
| 525 | return; |
| 526 | } |
| 527 | |
| 528 | removeHandler(element, events, typeEvent, originalHandler, delegation ? handler : null); |
| 529 | return; |
| 530 | } |
| 531 | |
| 532 | if (isNamespace) { |
| 533 | Object.keys(events).forEach(elementEvent => { |
| 534 | removeNamespacedHandlers(element, events, elementEvent, originalTypeEvent.slice(1)); |
| 535 | }); |
| 536 | } |
| 537 | |
| 538 | const storeElementEvent = events[typeEvent] || {}; |
| 539 | Object.keys(storeElementEvent).forEach(keyHandlers => { |
| 540 | const handlerKey = keyHandlers.replace(stripUidRegex, ''); |
| 541 | |
| 542 | if (!inNamespace || originalTypeEvent.includes(handlerKey)) { |
| 543 | const event = storeElementEvent[keyHandlers]; |
| 544 | removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector); |
| 545 | } |
| 546 | }); |
| 547 | }, |
| 548 | |
| 549 | trigger(element, event, args) { |
| 550 | if (typeof event !== 'string' || !element) { |
| 551 | return null; |
| 552 | } |
| 553 | |
| 554 | const $ = getjQuery(); |
| 555 | const typeEvent = getTypeEvent(event); |
| 556 | const inNamespace = event !== typeEvent; |
| 557 | const isNative = nativeEvents.has(typeEvent); |
| 558 | let jQueryEvent; |
| 559 | let bubbles = true; |
| 560 | let nativeDispatch = true; |
| 561 | let defaultPrevented = false; |
| 562 | let evt = null; |
| 563 | |
| 564 | if (inNamespace && $) { |
| 565 | jQueryEvent = $.Event(event, args); |
| 566 | $(element).trigger(jQueryEvent); |
| 567 | bubbles = !jQueryEvent.isPropagationStopped(); |
| 568 | nativeDispatch = !jQueryEvent.isImmediatePropagationStopped(); |
| 569 | defaultPrevented = jQueryEvent.isDefaultPrevented(); |
| 570 | } |
| 571 | |
| 572 | if (isNative) { |
| 573 | evt = document.createEvent('HTMLEvents'); |
| 574 | evt.initEvent(typeEvent, bubbles, true); |
| 575 | } else { |
| 576 | evt = new CustomEvent(event, { |
| 577 | bubbles, |
| 578 | cancelable: true |
| 579 | }); |
| 580 | } // merge custom information in our event |
| 581 | |
| 582 | |
| 583 | if (typeof args !== 'undefined') { |
| 584 | Object.keys(args).forEach(key => { |
| 585 | Object.defineProperty(evt, key, { |
| 586 | get() { |
| 587 | return args[key]; |
| 588 | } |
| 589 | |
| 590 | }); |
| 591 | }); |
| 592 | } |
| 593 | |
| 594 | if (defaultPrevented) { |
| 595 | evt.preventDefault(); |
| 596 | } |
| 597 | |
| 598 | if (nativeDispatch) { |
| 599 | element.dispatchEvent(evt); |
| 600 | } |
| 601 | |
| 602 | if (evt.defaultPrevented && typeof jQueryEvent !== 'undefined') { |
| 603 | jQueryEvent.preventDefault(); |
| 604 | } |
| 605 | |
| 606 | return evt; |
| 607 | } |
| 608 | |
| 609 | }; |
| 610 | |
| 611 | /** |
| 612 | * -------------------------------------------------------------------------- |
| 613 | * Bootstrap (v5.1.3): dom/data.js |
| 614 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 615 | * -------------------------------------------------------------------------- |
| 616 | */ |
| 617 | |
| 618 | /** |
| 619 | * ------------------------------------------------------------------------ |
| 620 | * Constants |
| 621 | * ------------------------------------------------------------------------ |
| 622 | */ |
| 623 | const elementMap = new Map(); |
| 624 | const Data = { |
| 625 | set(element, key, instance) { |
| 626 | if (!elementMap.has(element)) { |
| 627 | elementMap.set(element, new Map()); |
| 628 | } |
| 629 | |
| 630 | const instanceMap = elementMap.get(element); // make it clear we only want one instance per element |
| 631 | // can be removed later when multiple key/instances are fine to be used |
| 632 | |
| 633 | if (!instanceMap.has(key) && instanceMap.size !== 0) { |
| 634 | // eslint-disable-next-line no-console |
| 635 | console.error(`Bootstrap doesn't allow more than one instance per element. Bound instance: ${Array.from(instanceMap.keys())[0]}.`); |
| 636 | return; |
| 637 | } |
| 638 | |
| 639 | instanceMap.set(key, instance); |
| 640 | }, |
| 641 | |
| 642 | get(element, key) { |
| 643 | if (elementMap.has(element)) { |
| 644 | return elementMap.get(element).get(key) || null; |
| 645 | } |
| 646 | |
| 647 | return null; |
| 648 | }, |
| 649 | |
| 650 | remove(element, key) { |
| 651 | if (!elementMap.has(element)) { |
| 652 | return; |
| 653 | } |
| 654 | |
| 655 | const instanceMap = elementMap.get(element); |
| 656 | instanceMap.delete(key); // free up element references if there are no instances left for an element |
| 657 | |
| 658 | if (instanceMap.size === 0) { |
| 659 | elementMap.delete(element); |
| 660 | } |
| 661 | } |
| 662 | |
| 663 | }; |
| 664 | |
| 665 | /** |
| 666 | * -------------------------------------------------------------------------- |
| 667 | * Bootstrap (v5.1.3): base-component.js |
| 668 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 669 | * -------------------------------------------------------------------------- |
| 670 | */ |
| 671 | /** |
| 672 | * ------------------------------------------------------------------------ |
| 673 | * Constants |
| 674 | * ------------------------------------------------------------------------ |
| 675 | */ |
| 676 | |
| 677 | const VERSION = '5.1.3'; |
| 678 | |
| 679 | class BaseComponent { |
| 680 | constructor(element) { |
| 681 | element = getElement(element); |
| 682 | |
| 683 | if (!element) { |
| 684 | return; |
| 685 | } |
| 686 | |
| 687 | this._element = element; |
| 688 | Data.set(this._element, this.constructor.DATA_KEY, this); |
| 689 | } |
| 690 | |
| 691 | dispose() { |
| 692 | Data.remove(this._element, this.constructor.DATA_KEY); |
| 693 | EventHandler.off(this._element, this.constructor.EVENT_KEY); |
| 694 | Object.getOwnPropertyNames(this).forEach(propertyName => { |
| 695 | this[propertyName] = null; |
| 696 | }); |
| 697 | } |
| 698 | |
| 699 | _queueCallback(callback, element, isAnimated = true) { |
| 700 | executeAfterTransition(callback, element, isAnimated); |
| 701 | } |
| 702 | /** Static */ |
| 703 | |
| 704 | |
| 705 | static getInstance(element) { |
| 706 | return Data.get(getElement(element), this.DATA_KEY); |
| 707 | } |
| 708 | |
| 709 | static getOrCreateInstance(element, config = {}) { |
| 710 | return this.getInstance(element) || new this(element, typeof config === 'object' ? config : null); |
| 711 | } |
| 712 | |
| 713 | static get VERSION() { |
| 714 | return VERSION; |
| 715 | } |
| 716 | |
| 717 | static get NAME() { |
| 718 | throw new Error('You have to implement the static method "NAME", for each component!'); |
| 719 | } |
| 720 | |
| 721 | static get DATA_KEY() { |
| 722 | return `bs.${this.NAME}`; |
| 723 | } |
| 724 | |
| 725 | static get EVENT_KEY() { |
| 726 | return `.${this.DATA_KEY}`; |
| 727 | } |
| 728 | |
| 729 | } |
| 730 | |
| 731 | /** |
| 732 | * -------------------------------------------------------------------------- |
| 733 | * Bootstrap (v5.1.3): util/component-functions.js |
| 734 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 735 | * -------------------------------------------------------------------------- |
| 736 | */ |
| 737 | |
| 738 | const enableDismissTrigger = (component, method = 'hide') => { |
| 739 | const clickEvent = `click.dismiss${component.EVENT_KEY}`; |
| 740 | const name = component.NAME; |
| 741 | EventHandler.on(document, clickEvent, `[data-bs-dismiss="${name}"]`, function (event) { |
| 742 | if (['A', 'AREA'].includes(this.tagName)) { |
| 743 | event.preventDefault(); |
| 744 | } |
| 745 | |
| 746 | if (isDisabled(this)) { |
| 747 | return; |
| 748 | } |
| 749 | |
| 750 | const target = getElementFromSelector(this) || this.closest(`.${name}`); |
| 751 | const instance = component.getOrCreateInstance(target); // Method argument is left, for Alert and only, as it doesn't implement the 'hide' method |
| 752 | |
| 753 | instance[method](); |
| 754 | }); |
| 755 | }; |
| 756 | |
| 757 | /** |
| 758 | * -------------------------------------------------------------------------- |
| 759 | * Bootstrap (v5.1.3): alert.js |
| 760 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 761 | * -------------------------------------------------------------------------- |
| 762 | */ |
| 763 | /** |
| 764 | * ------------------------------------------------------------------------ |
| 765 | * Constants |
| 766 | * ------------------------------------------------------------------------ |
| 767 | */ |
| 768 | |
| 769 | const NAME$d = 'alert'; |
| 770 | const DATA_KEY$c = 'bs.alert'; |
| 771 | const EVENT_KEY$c = `.${DATA_KEY$c}`; |
| 772 | const EVENT_CLOSE = `close${EVENT_KEY$c}`; |
| 773 | const EVENT_CLOSED = `closed${EVENT_KEY$c}`; |
| 774 | const CLASS_NAME_FADE$5 = 'fade'; |
| 775 | const CLASS_NAME_SHOW$8 = 'show'; |
| 776 | /** |
| 777 | * ------------------------------------------------------------------------ |
| 778 | * Class Definition |
| 779 | * ------------------------------------------------------------------------ |
| 780 | */ |
| 781 | |
| 782 | class Alert extends BaseComponent { |
| 783 | // Getters |
| 784 | static get NAME() { |
| 785 | return NAME$d; |
| 786 | } // Public |
| 787 | |
| 788 | |
| 789 | close() { |
| 790 | const closeEvent = EventHandler.trigger(this._element, EVENT_CLOSE); |
| 791 | |
| 792 | if (closeEvent.defaultPrevented) { |
| 793 | return; |
| 794 | } |
| 795 | |
| 796 | this._element.classList.remove(CLASS_NAME_SHOW$8); |
| 797 | |
| 798 | const isAnimated = this._element.classList.contains(CLASS_NAME_FADE$5); |
| 799 | |
| 800 | this._queueCallback(() => this._destroyElement(), this._element, isAnimated); |
| 801 | } // Private |
| 802 | |
| 803 | |
| 804 | _destroyElement() { |
| 805 | this._element.remove(); |
| 806 | |
| 807 | EventHandler.trigger(this._element, EVENT_CLOSED); |
| 808 | this.dispose(); |
| 809 | } // Static |
| 810 | |
| 811 | |
| 812 | static jQueryInterface(config) { |
| 813 | return this.each(function () { |
| 814 | const data = Alert.getOrCreateInstance(this); |
| 815 | |
| 816 | if (typeof config !== 'string') { |
| 817 | return; |
| 818 | } |
| 819 | |
| 820 | if (data[config] === undefined || config.startsWith('_') || config === 'constructor') { |
| 821 | throw new TypeError(`No method named "${config}"`); |
| 822 | } |
| 823 | |
| 824 | data[config](this); |
| 825 | }); |
| 826 | } |
| 827 | |
| 828 | } |
| 829 | /** |
| 830 | * ------------------------------------------------------------------------ |
| 831 | * Data Api implementation |
| 832 | * ------------------------------------------------------------------------ |
| 833 | */ |
| 834 | |
| 835 | |
| 836 | enableDismissTrigger(Alert, 'close'); |
| 837 | /** |
| 838 | * ------------------------------------------------------------------------ |
| 839 | * jQuery |
| 840 | * ------------------------------------------------------------------------ |
| 841 | * add .Alert to jQuery only if jQuery is present |
| 842 | */ |
| 843 | |
| 844 | defineJQueryPlugin(Alert); |
| 845 | |
| 846 | /** |
| 847 | * -------------------------------------------------------------------------- |
| 848 | * Bootstrap (v5.1.3): button.js |
| 849 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 850 | * -------------------------------------------------------------------------- |
| 851 | */ |
| 852 | /** |
| 853 | * ------------------------------------------------------------------------ |
| 854 | * Constants |
| 855 | * ------------------------------------------------------------------------ |
| 856 | */ |
| 857 | |
| 858 | const NAME$c = 'button'; |
| 859 | const DATA_KEY$b = 'bs.button'; |
| 860 | const EVENT_KEY$b = `.${DATA_KEY$b}`; |
| 861 | const DATA_API_KEY$7 = '.data-api'; |
| 862 | const CLASS_NAME_ACTIVE$3 = 'active'; |
| 863 | const SELECTOR_DATA_TOGGLE$5 = '[data-bs-toggle="button"]'; |
| 864 | const EVENT_CLICK_DATA_API$6 = `click${EVENT_KEY$b}${DATA_API_KEY$7}`; |
| 865 | /** |
| 866 | * ------------------------------------------------------------------------ |
| 867 | * Class Definition |
| 868 | * ------------------------------------------------------------------------ |
| 869 | */ |
| 870 | |
| 871 | class Button extends BaseComponent { |
| 872 | // Getters |
| 873 | static get NAME() { |
| 874 | return NAME$c; |
| 875 | } // Public |
| 876 | |
| 877 | |
| 878 | toggle() { |
| 879 | // Toggle class and sync the `aria-pressed` attribute with the return value of the `.toggle()` method |
| 880 | this._element.setAttribute('aria-pressed', this._element.classList.toggle(CLASS_NAME_ACTIVE$3)); |
| 881 | } // Static |
| 882 | |
| 883 | |
| 884 | static jQueryInterface(config) { |
| 885 | return this.each(function () { |
| 886 | const data = Button.getOrCreateInstance(this); |
| 887 | |
| 888 | if (config === 'toggle') { |
| 889 | data[config](); |
| 890 | } |
| 891 | }); |
| 892 | } |
| 893 | |
| 894 | } |
| 895 | /** |
| 896 | * ------------------------------------------------------------------------ |
| 897 | * Data Api implementation |
| 898 | * ------------------------------------------------------------------------ |
| 899 | */ |
| 900 | |
| 901 | |
| 902 | EventHandler.on(document, EVENT_CLICK_DATA_API$6, SELECTOR_DATA_TOGGLE$5, event => { |
| 903 | event.preventDefault(); |
| 904 | const button = event.target.closest(SELECTOR_DATA_TOGGLE$5); |
| 905 | const data = Button.getOrCreateInstance(button); |
| 906 | data.toggle(); |
| 907 | }); |
| 908 | /** |
| 909 | * ------------------------------------------------------------------------ |
| 910 | * jQuery |
| 911 | * ------------------------------------------------------------------------ |
| 912 | * add .Button to jQuery only if jQuery is present |
| 913 | */ |
| 914 | |
| 915 | defineJQueryPlugin(Button); |
| 916 | |
| 917 | /** |
| 918 | * -------------------------------------------------------------------------- |
| 919 | * Bootstrap (v5.1.3): dom/manipulator.js |
| 920 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 921 | * -------------------------------------------------------------------------- |
| 922 | */ |
| 923 | function normalizeData(val) { |
| 924 | if (val === 'true') { |
| 925 | return true; |
| 926 | } |
| 927 | |
| 928 | if (val === 'false') { |
| 929 | return false; |
| 930 | } |
| 931 | |
| 932 | if (val === Number(val).toString()) { |
| 933 | return Number(val); |
| 934 | } |
| 935 | |
| 936 | if (val === '' || val === 'null') { |
| 937 | return null; |
| 938 | } |
| 939 | |
| 940 | return val; |
| 941 | } |
| 942 | |
| 943 | function normalizeDataKey(key) { |
| 944 | return key.replace(/[A-Z]/g, chr => `-${chr.toLowerCase()}`); |
| 945 | } |
| 946 | |
| 947 | const Manipulator = { |
| 948 | setDataAttribute(element, key, value) { |
| 949 | element.setAttribute(`data-bs-${normalizeDataKey(key)}`, value); |
| 950 | }, |
| 951 | |
| 952 | removeDataAttribute(element, key) { |
| 953 | element.removeAttribute(`data-bs-${normalizeDataKey(key)}`); |
| 954 | }, |
| 955 | |
| 956 | getDataAttributes(element) { |
| 957 | if (!element) { |
| 958 | return {}; |
| 959 | } |
| 960 | |
| 961 | const attributes = {}; |
| 962 | Object.keys(element.dataset).filter(key => key.startsWith('bs')).forEach(key => { |
| 963 | let pureKey = key.replace(/^bs/, ''); |
| 964 | pureKey = pureKey.charAt(0).toLowerCase() + pureKey.slice(1, pureKey.length); |
| 965 | attributes[pureKey] = normalizeData(element.dataset[key]); |
| 966 | }); |
| 967 | return attributes; |
| 968 | }, |
| 969 | |
| 970 | getDataAttribute(element, key) { |
| 971 | return normalizeData(element.getAttribute(`data-bs-${normalizeDataKey(key)}`)); |
| 972 | }, |
| 973 | |
| 974 | offset(element) { |
| 975 | const rect = element.getBoundingClientRect(); |
| 976 | return { |
| 977 | top: rect.top + window.pageYOffset, |
| 978 | left: rect.left + window.pageXOffset |
| 979 | }; |
| 980 | }, |
| 981 | |
| 982 | position(element) { |
| 983 | return { |
| 984 | top: element.offsetTop, |
| 985 | left: element.offsetLeft |
| 986 | }; |
| 987 | } |
| 988 | |
| 989 | }; |
| 990 | |
| 991 | /** |
| 992 | * -------------------------------------------------------------------------- |
| 993 | * Bootstrap (v5.1.3): dom/selector-engine.js |
| 994 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 995 | * -------------------------------------------------------------------------- |
| 996 | */ |
| 997 | const NODE_TEXT = 3; |
| 998 | const SelectorEngine = { |
| 999 | find(selector, element = document.documentElement) { |
| 1000 | return [].concat(...Element.prototype.querySelectorAll.call(element, selector)); |
| 1001 | }, |
| 1002 | |
| 1003 | findOne(selector, element = document.documentElement) { |
| 1004 | return Element.prototype.querySelector.call(element, selector); |
| 1005 | }, |
| 1006 | |
| 1007 | children(element, selector) { |
| 1008 | return [].concat(...element.children).filter(child => child.matches(selector)); |
| 1009 | }, |
| 1010 | |
| 1011 | parents(element, selector) { |
| 1012 | const parents = []; |
| 1013 | let ancestor = element.parentNode; |
| 1014 | |
| 1015 | while (ancestor && ancestor.nodeType === Node.ELEMENT_NODE && ancestor.nodeType !== NODE_TEXT) { |
| 1016 | if (ancestor.matches(selector)) { |
| 1017 | parents.push(ancestor); |
| 1018 | } |
| 1019 | |
| 1020 | ancestor = ancestor.parentNode; |
| 1021 | } |
| 1022 | |
| 1023 | return parents; |
| 1024 | }, |
| 1025 | |
| 1026 | prev(element, selector) { |
| 1027 | let previous = element.previousElementSibling; |
| 1028 | |
| 1029 | while (previous) { |
| 1030 | if (previous.matches(selector)) { |
| 1031 | return [previous]; |
| 1032 | } |
| 1033 | |
| 1034 | previous = previous.previousElementSibling; |
| 1035 | } |
| 1036 | |
| 1037 | return []; |
| 1038 | }, |
| 1039 | |
| 1040 | next(element, selector) { |
| 1041 | let next = element.nextElementSibling; |
| 1042 | |
| 1043 | while (next) { |
| 1044 | if (next.matches(selector)) { |
| 1045 | return [next]; |
| 1046 | } |
| 1047 | |
| 1048 | next = next.nextElementSibling; |
| 1049 | } |
| 1050 | |
| 1051 | return []; |
| 1052 | }, |
| 1053 | |
| 1054 | focusableChildren(element) { |
| 1055 | const focusables = ['a', 'button', 'input', 'textarea', 'select', 'details', '[tabindex]', '[contenteditable="true"]'].map(selector => `${selector}:not([tabindex^="-"])`).join(', '); |
| 1056 | return this.find(focusables, element).filter(el => !isDisabled(el) && isVisible(el)); |
| 1057 | } |
| 1058 | |
| 1059 | }; |
| 1060 | |
| 1061 | /** |
| 1062 | * -------------------------------------------------------------------------- |
| 1063 | * Bootstrap (v5.1.3): carousel.js |
| 1064 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 1065 | * -------------------------------------------------------------------------- |
| 1066 | */ |
| 1067 | /** |
| 1068 | * ------------------------------------------------------------------------ |
| 1069 | * Constants |
| 1070 | * ------------------------------------------------------------------------ |
| 1071 | */ |
| 1072 | |
| 1073 | const NAME$b = 'carousel'; |
| 1074 | const DATA_KEY$a = 'bs.carousel'; |
| 1075 | const EVENT_KEY$a = `.${DATA_KEY$a}`; |
| 1076 | const DATA_API_KEY$6 = '.data-api'; |
| 1077 | const ARROW_LEFT_KEY = 'ArrowLeft'; |
| 1078 | const ARROW_RIGHT_KEY = 'ArrowRight'; |
| 1079 | const TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch |
| 1080 | |
| 1081 | const SWIPE_THRESHOLD = 40; |
| 1082 | const Default$a = { |
| 1083 | interval: 5000, |
| 1084 | keyboard: true, |
| 1085 | slide: false, |
| 1086 | pause: 'hover', |
| 1087 | wrap: true, |
| 1088 | touch: true |
| 1089 | }; |
| 1090 | const DefaultType$a = { |
| 1091 | interval: '(number|boolean)', |
| 1092 | keyboard: 'boolean', |
| 1093 | slide: '(boolean|string)', |
| 1094 | pause: '(string|boolean)', |
| 1095 | wrap: 'boolean', |
| 1096 | touch: 'boolean' |
| 1097 | }; |
| 1098 | const ORDER_NEXT = 'next'; |
| 1099 | const ORDER_PREV = 'prev'; |
| 1100 | const DIRECTION_LEFT = 'left'; |
| 1101 | const DIRECTION_RIGHT = 'right'; |
| 1102 | const KEY_TO_DIRECTION = { |
| 1103 | [ARROW_LEFT_KEY]: DIRECTION_RIGHT, |
| 1104 | [ARROW_RIGHT_KEY]: DIRECTION_LEFT |
| 1105 | }; |
| 1106 | const EVENT_SLIDE = `slide${EVENT_KEY$a}`; |
| 1107 | const EVENT_SLID = `slid${EVENT_KEY$a}`; |
| 1108 | const EVENT_KEYDOWN = `keydown${EVENT_KEY$a}`; |
| 1109 | const EVENT_MOUSEENTER = `mouseenter${EVENT_KEY$a}`; |
| 1110 | const EVENT_MOUSELEAVE = `mouseleave${EVENT_KEY$a}`; |
| 1111 | const EVENT_TOUCHSTART = `touchstart${EVENT_KEY$a}`; |
| 1112 | const EVENT_TOUCHMOVE = `touchmove${EVENT_KEY$a}`; |
| 1113 | const EVENT_TOUCHEND = `touchend${EVENT_KEY$a}`; |
| 1114 | const EVENT_POINTERDOWN = `pointerdown${EVENT_KEY$a}`; |
| 1115 | const EVENT_POINTERUP = `pointerup${EVENT_KEY$a}`; |
| 1116 | const EVENT_DRAG_START = `dragstart${EVENT_KEY$a}`; |
| 1117 | const EVENT_LOAD_DATA_API$2 = `load${EVENT_KEY$a}${DATA_API_KEY$6}`; |
| 1118 | const EVENT_CLICK_DATA_API$5 = `click${EVENT_KEY$a}${DATA_API_KEY$6}`; |
| 1119 | const CLASS_NAME_CAROUSEL = 'carousel'; |
| 1120 | const CLASS_NAME_ACTIVE$2 = 'active'; |
| 1121 | const CLASS_NAME_SLIDE = 'slide'; |
| 1122 | const CLASS_NAME_END = 'carousel-item-end'; |
| 1123 | const CLASS_NAME_START = 'carousel-item-start'; |
| 1124 | const CLASS_NAME_NEXT = 'carousel-item-next'; |
| 1125 | const CLASS_NAME_PREV = 'carousel-item-prev'; |
| 1126 | const CLASS_NAME_POINTER_EVENT = 'pointer-event'; |
| 1127 | const SELECTOR_ACTIVE$1 = '.active'; |
| 1128 | const SELECTOR_ACTIVE_ITEM = '.active.carousel-item'; |
| 1129 | const SELECTOR_ITEM = '.carousel-item'; |
| 1130 | const SELECTOR_ITEM_IMG = '.carousel-item img'; |
| 1131 | const SELECTOR_NEXT_PREV = '.carousel-item-next, .carousel-item-prev'; |
| 1132 | const SELECTOR_INDICATORS = '.carousel-indicators'; |
| 1133 | const SELECTOR_INDICATOR = '[data-bs-target]'; |
| 1134 | const SELECTOR_DATA_SLIDE = '[data-bs-slide], [data-bs-slide-to]'; |
| 1135 | const SELECTOR_DATA_RIDE = '[data-bs-ride="carousel"]'; |
| 1136 | const POINTER_TYPE_TOUCH = 'touch'; |
| 1137 | const POINTER_TYPE_PEN = 'pen'; |
| 1138 | /** |
| 1139 | * ------------------------------------------------------------------------ |
| 1140 | * Class Definition |
| 1141 | * ------------------------------------------------------------------------ |
| 1142 | */ |
| 1143 | |
| 1144 | class Carousel extends BaseComponent { |
| 1145 | constructor(element, config) { |
| 1146 | super(element); |
| 1147 | this._items = null; |
| 1148 | this._interval = null; |
| 1149 | this._activeElement = null; |
| 1150 | this._isPaused = false; |
| 1151 | this._isSliding = false; |
| 1152 | this.touchTimeout = null; |
| 1153 | this.touchStartX = 0; |
| 1154 | this.touchDeltaX = 0; |
| 1155 | this._config = this._getConfig(config); |
| 1156 | this._indicatorsElement = SelectorEngine.findOne(SELECTOR_INDICATORS, this._element); |
| 1157 | this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0; |
| 1158 | this._pointerEvent = Boolean(window.PointerEvent); |
| 1159 | |
| 1160 | this._addEventListeners(); |
| 1161 | } // Getters |
| 1162 | |
| 1163 | |
| 1164 | static get Default() { |
| 1165 | return Default$a; |
| 1166 | } |
| 1167 | |
| 1168 | static get NAME() { |
| 1169 | return NAME$b; |
| 1170 | } // Public |
| 1171 | |
| 1172 | |
| 1173 | next() { |
| 1174 | this._slide(ORDER_NEXT); |
| 1175 | } |
| 1176 | |
| 1177 | nextWhenVisible() { |
| 1178 | // Don't call next when the page isn't visible |
| 1179 | // or the carousel or its parent isn't visible |
| 1180 | if (!document.hidden && isVisible(this._element)) { |
| 1181 | this.next(); |
| 1182 | } |
| 1183 | } |
| 1184 | |
| 1185 | prev() { |
| 1186 | this._slide(ORDER_PREV); |
| 1187 | } |
| 1188 | |
| 1189 | pause(event) { |
| 1190 | if (!event) { |
| 1191 | this._isPaused = true; |
| 1192 | } |
| 1193 | |
| 1194 | if (SelectorEngine.findOne(SELECTOR_NEXT_PREV, this._element)) { |
| 1195 | triggerTransitionEnd(this._element); |
| 1196 | this.cycle(true); |
| 1197 | } |
| 1198 | |
| 1199 | clearInterval(this._interval); |
| 1200 | this._interval = null; |
| 1201 | } |
| 1202 | |
| 1203 | cycle(event) { |
| 1204 | if (!event) { |
| 1205 | this._isPaused = false; |
| 1206 | } |
| 1207 | |
| 1208 | if (this._interval) { |
| 1209 | clearInterval(this._interval); |
| 1210 | this._interval = null; |
| 1211 | } |
| 1212 | |
| 1213 | if (this._config && this._config.interval && !this._isPaused) { |
| 1214 | this._updateInterval(); |
| 1215 | |
| 1216 | this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval); |
| 1217 | } |
| 1218 | } |
| 1219 | |
| 1220 | to(index) { |
| 1221 | this._activeElement = SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element); |
| 1222 | |
| 1223 | const activeIndex = this._getItemIndex(this._activeElement); |
| 1224 | |
| 1225 | if (index > this._items.length - 1 || index < 0) { |
| 1226 | return; |
| 1227 | } |
| 1228 | |
| 1229 | if (this._isSliding) { |
| 1230 | EventHandler.one(this._element, EVENT_SLID, () => this.to(index)); |
| 1231 | return; |
| 1232 | } |
| 1233 | |
| 1234 | if (activeIndex === index) { |
| 1235 | this.pause(); |
| 1236 | this.cycle(); |
| 1237 | return; |
| 1238 | } |
| 1239 | |
| 1240 | const order = index > activeIndex ? ORDER_NEXT : ORDER_PREV; |
| 1241 | |
| 1242 | this._slide(order, this._items[index]); |
| 1243 | } // Private |
| 1244 | |
| 1245 | |
| 1246 | _getConfig(config) { |
| 1247 | config = { ...Default$a, |
| 1248 | ...Manipulator.getDataAttributes(this._element), |
| 1249 | ...(typeof config === 'object' ? config : {}) |
| 1250 | }; |
| 1251 | typeCheckConfig(NAME$b, config, DefaultType$a); |
| 1252 | return config; |
| 1253 | } |
| 1254 | |
| 1255 | _handleSwipe() { |
| 1256 | const absDeltax = Math.abs(this.touchDeltaX); |
| 1257 | |
| 1258 | if (absDeltax <= SWIPE_THRESHOLD) { |
| 1259 | return; |
| 1260 | } |
| 1261 | |
| 1262 | const direction = absDeltax / this.touchDeltaX; |
| 1263 | this.touchDeltaX = 0; |
| 1264 | |
| 1265 | if (!direction) { |
| 1266 | return; |
| 1267 | } |
| 1268 | |
| 1269 | this._slide(direction > 0 ? DIRECTION_RIGHT : DIRECTION_LEFT); |
| 1270 | } |
| 1271 | |
| 1272 | _addEventListeners() { |
| 1273 | if (this._config.keyboard) { |
| 1274 | EventHandler.on(this._element, EVENT_KEYDOWN, event => this._keydown(event)); |
| 1275 | } |
| 1276 | |
| 1277 | if (this._config.pause === 'hover') { |
| 1278 | EventHandler.on(this._element, EVENT_MOUSEENTER, event => this.pause(event)); |
| 1279 | EventHandler.on(this._element, EVENT_MOUSELEAVE, event => this.cycle(event)); |
| 1280 | } |
| 1281 | |
| 1282 | if (this._config.touch && this._touchSupported) { |
| 1283 | this._addTouchEventListeners(); |
| 1284 | } |
| 1285 | } |
| 1286 | |
| 1287 | _addTouchEventListeners() { |
| 1288 | const hasPointerPenTouch = event => { |
| 1289 | return this._pointerEvent && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH); |
| 1290 | }; |
| 1291 | |
| 1292 | const start = event => { |
| 1293 | if (hasPointerPenTouch(event)) { |
| 1294 | this.touchStartX = event.clientX; |
| 1295 | } else if (!this._pointerEvent) { |
| 1296 | this.touchStartX = event.touches[0].clientX; |
| 1297 | } |
| 1298 | }; |
| 1299 | |
| 1300 | const move = event => { |
| 1301 | // ensure swiping with one touch and not pinching |
| 1302 | this.touchDeltaX = event.touches && event.touches.length > 1 ? 0 : event.touches[0].clientX - this.touchStartX; |
| 1303 | }; |
| 1304 | |
| 1305 | const end = event => { |
| 1306 | if (hasPointerPenTouch(event)) { |
| 1307 | this.touchDeltaX = event.clientX - this.touchStartX; |
| 1308 | } |
| 1309 | |
| 1310 | this._handleSwipe(); |
| 1311 | |
| 1312 | if (this._config.pause === 'hover') { |
| 1313 | // If it's a touch-enabled device, mouseenter/leave are fired as |
| 1314 | // part of the mouse compatibility events on first tap - the carousel |
| 1315 | // would stop cycling until user tapped out of it; |
| 1316 | // here, we listen for touchend, explicitly pause the carousel |
| 1317 | // (as if it's the second time we tap on it, mouseenter compat event |
| 1318 | // is NOT fired) and after a timeout (to allow for mouse compatibility |
| 1319 | // events to fire) we explicitly restart cycling |
| 1320 | this.pause(); |
| 1321 | |
| 1322 | if (this.touchTimeout) { |
| 1323 | clearTimeout(this.touchTimeout); |
| 1324 | } |
| 1325 | |
| 1326 | this.touchTimeout = setTimeout(event => this.cycle(event), TOUCHEVENT_COMPAT_WAIT + this._config.interval); |
| 1327 | } |
| 1328 | }; |
| 1329 | |
| 1330 | SelectorEngine.find(SELECTOR_ITEM_IMG, this._element).forEach(itemImg => { |
| 1331 | EventHandler.on(itemImg, EVENT_DRAG_START, event => event.preventDefault()); |
| 1332 | }); |
| 1333 | |
| 1334 | if (this._pointerEvent) { |
| 1335 | EventHandler.on(this._element, EVENT_POINTERDOWN, event => start(event)); |
| 1336 | EventHandler.on(this._element, EVENT_POINTERUP, event => end(event)); |
| 1337 | |
| 1338 | this._element.classList.add(CLASS_NAME_POINTER_EVENT); |
| 1339 | } else { |
| 1340 | EventHandler.on(this._element, EVENT_TOUCHSTART, event => start(event)); |
| 1341 | EventHandler.on(this._element, EVENT_TOUCHMOVE, event => move(event)); |
| 1342 | EventHandler.on(this._element, EVENT_TOUCHEND, event => end(event)); |
| 1343 | } |
| 1344 | } |
| 1345 | |
| 1346 | _keydown(event) { |
| 1347 | if (/input|textarea/i.test(event.target.tagName)) { |
| 1348 | return; |
| 1349 | } |
| 1350 | |
| 1351 | const direction = KEY_TO_DIRECTION[event.key]; |
| 1352 | |
| 1353 | if (direction) { |
| 1354 | event.preventDefault(); |
| 1355 | |
| 1356 | this._slide(direction); |
| 1357 | } |
| 1358 | } |
| 1359 | |
| 1360 | _getItemIndex(element) { |
| 1361 | this._items = element && element.parentNode ? SelectorEngine.find(SELECTOR_ITEM, element.parentNode) : []; |
| 1362 | return this._items.indexOf(element); |
| 1363 | } |
| 1364 | |
| 1365 | _getItemByOrder(order, activeElement) { |
| 1366 | const isNext = order === ORDER_NEXT; |
| 1367 | return getNextActiveElement(this._items, activeElement, isNext, this._config.wrap); |
| 1368 | } |
| 1369 | |
| 1370 | _triggerSlideEvent(relatedTarget, eventDirectionName) { |
| 1371 | const targetIndex = this._getItemIndex(relatedTarget); |
| 1372 | |
| 1373 | const fromIndex = this._getItemIndex(SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element)); |
| 1374 | |
| 1375 | return EventHandler.trigger(this._element, EVENT_SLIDE, { |
| 1376 | relatedTarget, |
| 1377 | direction: eventDirectionName, |
| 1378 | from: fromIndex, |
| 1379 | to: targetIndex |
| 1380 | }); |
| 1381 | } |
| 1382 | |
| 1383 | _setActiveIndicatorElement(element) { |
| 1384 | if (this._indicatorsElement) { |
| 1385 | const activeIndicator = SelectorEngine.findOne(SELECTOR_ACTIVE$1, this._indicatorsElement); |
| 1386 | activeIndicator.classList.remove(CLASS_NAME_ACTIVE$2); |
| 1387 | activeIndicator.removeAttribute('aria-current'); |
| 1388 | const indicators = SelectorEngine.find(SELECTOR_INDICATOR, this._indicatorsElement); |
| 1389 | |
| 1390 | for (let i = 0; i < indicators.length; i++) { |
| 1391 | if (Number.parseInt(indicators[i].getAttribute('data-bs-slide-to'), 10) === this._getItemIndex(element)) { |
| 1392 | indicators[i].classList.add(CLASS_NAME_ACTIVE$2); |
| 1393 | indicators[i].setAttribute('aria-current', 'true'); |
| 1394 | break; |
| 1395 | } |
| 1396 | } |
| 1397 | } |
| 1398 | } |
| 1399 | |
| 1400 | _updateInterval() { |
| 1401 | const element = this._activeElement || SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element); |
| 1402 | |
| 1403 | if (!element) { |
| 1404 | return; |
| 1405 | } |
| 1406 | |
| 1407 | const elementInterval = Number.parseInt(element.getAttribute('data-bs-interval'), 10); |
| 1408 | |
| 1409 | if (elementInterval) { |
| 1410 | this._config.defaultInterval = this._config.defaultInterval || this._config.interval; |
| 1411 | this._config.interval = elementInterval; |
| 1412 | } else { |
| 1413 | this._config.interval = this._config.defaultInterval || this._config.interval; |
| 1414 | } |
| 1415 | } |
| 1416 | |
| 1417 | _slide(directionOrOrder, element) { |
| 1418 | const order = this._directionToOrder(directionOrOrder); |
| 1419 | |
| 1420 | const activeElement = SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element); |
| 1421 | |
| 1422 | const activeElementIndex = this._getItemIndex(activeElement); |
| 1423 | |
| 1424 | const nextElement = element || this._getItemByOrder(order, activeElement); |
| 1425 | |
| 1426 | const nextElementIndex = this._getItemIndex(nextElement); |
| 1427 | |
| 1428 | const isCycling = Boolean(this._interval); |
| 1429 | const isNext = order === ORDER_NEXT; |
| 1430 | const directionalClassName = isNext ? CLASS_NAME_START : CLASS_NAME_END; |
| 1431 | const orderClassName = isNext ? CLASS_NAME_NEXT : CLASS_NAME_PREV; |
| 1432 | |
| 1433 | const eventDirectionName = this._orderToDirection(order); |
| 1434 | |
| 1435 | if (nextElement && nextElement.classList.contains(CLASS_NAME_ACTIVE$2)) { |
| 1436 | this._isSliding = false; |
| 1437 | return; |
| 1438 | } |
| 1439 | |
| 1440 | if (this._isSliding) { |
| 1441 | return; |
| 1442 | } |
| 1443 | |
| 1444 | const slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName); |
| 1445 | |
| 1446 | if (slideEvent.defaultPrevented) { |
| 1447 | return; |
| 1448 | } |
| 1449 | |
| 1450 | if (!activeElement || !nextElement) { |
| 1451 | // Some weirdness is happening, so we bail |
| 1452 | return; |
| 1453 | } |
| 1454 | |
| 1455 | this._isSliding = true; |
| 1456 | |
| 1457 | if (isCycling) { |
| 1458 | this.pause(); |
| 1459 | } |
| 1460 | |
| 1461 | this._setActiveIndicatorElement(nextElement); |
| 1462 | |
| 1463 | this._activeElement = nextElement; |
| 1464 | |
| 1465 | const triggerSlidEvent = () => { |
| 1466 | EventHandler.trigger(this._element, EVENT_SLID, { |
| 1467 | relatedTarget: nextElement, |
| 1468 | direction: eventDirectionName, |
| 1469 | from: activeElementIndex, |
| 1470 | to: nextElementIndex |
| 1471 | }); |
| 1472 | }; |
| 1473 | |
| 1474 | if (this._element.classList.contains(CLASS_NAME_SLIDE)) { |
| 1475 | nextElement.classList.add(orderClassName); |
| 1476 | reflow(nextElement); |
| 1477 | activeElement.classList.add(directionalClassName); |
| 1478 | nextElement.classList.add(directionalClassName); |
| 1479 | |
| 1480 | const completeCallBack = () => { |
| 1481 | nextElement.classList.remove(directionalClassName, orderClassName); |
| 1482 | nextElement.classList.add(CLASS_NAME_ACTIVE$2); |
| 1483 | activeElement.classList.remove(CLASS_NAME_ACTIVE$2, orderClassName, directionalClassName); |
| 1484 | this._isSliding = false; |
| 1485 | setTimeout(triggerSlidEvent, 0); |
| 1486 | }; |
| 1487 | |
| 1488 | this._queueCallback(completeCallBack, activeElement, true); |
| 1489 | } else { |
| 1490 | activeElement.classList.remove(CLASS_NAME_ACTIVE$2); |
| 1491 | nextElement.classList.add(CLASS_NAME_ACTIVE$2); |
| 1492 | this._isSliding = false; |
| 1493 | triggerSlidEvent(); |
| 1494 | } |
| 1495 | |
| 1496 | if (isCycling) { |
| 1497 | this.cycle(); |
| 1498 | } |
| 1499 | } |
| 1500 | |
| 1501 | _directionToOrder(direction) { |
| 1502 | if (![DIRECTION_RIGHT, DIRECTION_LEFT].includes(direction)) { |
| 1503 | return direction; |
| 1504 | } |
| 1505 | |
| 1506 | if (isRTL()) { |
| 1507 | return direction === DIRECTION_LEFT ? ORDER_PREV : ORDER_NEXT; |
| 1508 | } |
| 1509 | |
| 1510 | return direction === DIRECTION_LEFT ? ORDER_NEXT : ORDER_PREV; |
| 1511 | } |
| 1512 | |
| 1513 | _orderToDirection(order) { |
| 1514 | if (![ORDER_NEXT, ORDER_PREV].includes(order)) { |
| 1515 | return order; |
| 1516 | } |
| 1517 | |
| 1518 | if (isRTL()) { |
| 1519 | return order === ORDER_PREV ? DIRECTION_LEFT : DIRECTION_RIGHT; |
| 1520 | } |
| 1521 | |
| 1522 | return order === ORDER_PREV ? DIRECTION_RIGHT : DIRECTION_LEFT; |
| 1523 | } // Static |
| 1524 | |
| 1525 | |
| 1526 | static carouselInterface(element, config) { |
| 1527 | const data = Carousel.getOrCreateInstance(element, config); |
| 1528 | let { |
| 1529 | _config |
| 1530 | } = data; |
| 1531 | |
| 1532 | if (typeof config === 'object') { |
| 1533 | _config = { ..._config, |
| 1534 | ...config |
| 1535 | }; |
| 1536 | } |
| 1537 | |
| 1538 | const action = typeof config === 'string' ? config : _config.slide; |
| 1539 | |
| 1540 | if (typeof config === 'number') { |
| 1541 | data.to(config); |
| 1542 | } else if (typeof action === 'string') { |
| 1543 | if (typeof data[action] === 'undefined') { |
| 1544 | throw new TypeError(`No method named "${action}"`); |
| 1545 | } |
| 1546 | |
| 1547 | data[action](); |
| 1548 | } else if (_config.interval && _config.ride) { |
| 1549 | data.pause(); |
| 1550 | data.cycle(); |
| 1551 | } |
| 1552 | } |
| 1553 | |
| 1554 | static jQueryInterface(config) { |
| 1555 | return this.each(function () { |
| 1556 | Carousel.carouselInterface(this, config); |
| 1557 | }); |
| 1558 | } |
| 1559 | |
| 1560 | static dataApiClickHandler(event) { |
| 1561 | const target = getElementFromSelector(this); |
| 1562 | |
| 1563 | if (!target || !target.classList.contains(CLASS_NAME_CAROUSEL)) { |
| 1564 | return; |
| 1565 | } |
| 1566 | |
| 1567 | const config = { ...Manipulator.getDataAttributes(target), |
| 1568 | ...Manipulator.getDataAttributes(this) |
| 1569 | }; |
| 1570 | const slideIndex = this.getAttribute('data-bs-slide-to'); |
| 1571 | |
| 1572 | if (slideIndex) { |
| 1573 | config.interval = false; |
| 1574 | } |
| 1575 | |
| 1576 | Carousel.carouselInterface(target, config); |
| 1577 | |
| 1578 | if (slideIndex) { |
| 1579 | Carousel.getInstance(target).to(slideIndex); |
| 1580 | } |
| 1581 | |
| 1582 | event.preventDefault(); |
| 1583 | } |
| 1584 | |
| 1585 | } |
| 1586 | /** |
| 1587 | * ------------------------------------------------------------------------ |
| 1588 | * Data Api implementation |
| 1589 | * ------------------------------------------------------------------------ |
| 1590 | */ |
| 1591 | |
| 1592 | |
| 1593 | EventHandler.on(document, EVENT_CLICK_DATA_API$5, SELECTOR_DATA_SLIDE, Carousel.dataApiClickHandler); |
| 1594 | EventHandler.on(window, EVENT_LOAD_DATA_API$2, () => { |
| 1595 | const carousels = SelectorEngine.find(SELECTOR_DATA_RIDE); |
| 1596 | |
| 1597 | for (let i = 0, len = carousels.length; i < len; i++) { |
| 1598 | Carousel.carouselInterface(carousels[i], Carousel.getInstance(carousels[i])); |
| 1599 | } |
| 1600 | }); |
| 1601 | /** |
| 1602 | * ------------------------------------------------------------------------ |
| 1603 | * jQuery |
| 1604 | * ------------------------------------------------------------------------ |
| 1605 | * add .Carousel to jQuery only if jQuery is present |
| 1606 | */ |
| 1607 | |
| 1608 | defineJQueryPlugin(Carousel); |
| 1609 | |
| 1610 | /** |
| 1611 | * -------------------------------------------------------------------------- |
| 1612 | * Bootstrap (v5.1.3): collapse.js |
| 1613 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 1614 | * -------------------------------------------------------------------------- |
| 1615 | */ |
| 1616 | /** |
| 1617 | * ------------------------------------------------------------------------ |
| 1618 | * Constants |
| 1619 | * ------------------------------------------------------------------------ |
| 1620 | */ |
| 1621 | |
| 1622 | const NAME$a = 'collapse'; |
| 1623 | const DATA_KEY$9 = 'bs.collapse'; |
| 1624 | const EVENT_KEY$9 = `.${DATA_KEY$9}`; |
| 1625 | const DATA_API_KEY$5 = '.data-api'; |
| 1626 | const Default$9 = { |
| 1627 | toggle: true, |
| 1628 | parent: null |
| 1629 | }; |
| 1630 | const DefaultType$9 = { |
| 1631 | toggle: 'boolean', |
| 1632 | parent: '(null|element)' |
| 1633 | }; |
| 1634 | const EVENT_SHOW$5 = `show${EVENT_KEY$9}`; |
| 1635 | const EVENT_SHOWN$5 = `shown${EVENT_KEY$9}`; |
| 1636 | const EVENT_HIDE$5 = `hide${EVENT_KEY$9}`; |
| 1637 | const EVENT_HIDDEN$5 = `hidden${EVENT_KEY$9}`; |
| 1638 | const EVENT_CLICK_DATA_API$4 = `click${EVENT_KEY$9}${DATA_API_KEY$5}`; |
| 1639 | const CLASS_NAME_SHOW$7 = 'show'; |
| 1640 | const CLASS_NAME_COLLAPSE = 'collapse'; |
| 1641 | const CLASS_NAME_COLLAPSING = 'collapsing'; |
| 1642 | const CLASS_NAME_COLLAPSED = 'collapsed'; |
| 1643 | const CLASS_NAME_DEEPER_CHILDREN = `:scope .${CLASS_NAME_COLLAPSE} .${CLASS_NAME_COLLAPSE}`; |
| 1644 | const CLASS_NAME_HORIZONTAL = 'collapse-horizontal'; |
| 1645 | const WIDTH = 'width'; |
| 1646 | const HEIGHT = 'height'; |
| 1647 | const SELECTOR_ACTIVES = '.collapse.show, .collapse.collapsing'; |
| 1648 | const SELECTOR_DATA_TOGGLE$4 = '[data-bs-toggle="collapse"]'; |
| 1649 | /** |
| 1650 | * ------------------------------------------------------------------------ |
| 1651 | * Class Definition |
| 1652 | * ------------------------------------------------------------------------ |
| 1653 | */ |
| 1654 | |
| 1655 | class Collapse extends BaseComponent { |
| 1656 | constructor(element, config) { |
| 1657 | super(element); |
| 1658 | this._isTransitioning = false; |
| 1659 | this._config = this._getConfig(config); |
| 1660 | this._triggerArray = []; |
| 1661 | const toggleList = SelectorEngine.find(SELECTOR_DATA_TOGGLE$4); |
| 1662 | |
| 1663 | for (let i = 0, len = toggleList.length; i < len; i++) { |
| 1664 | const elem = toggleList[i]; |
| 1665 | const selector = getSelectorFromElement(elem); |
| 1666 | const filterElement = SelectorEngine.find(selector).filter(foundElem => foundElem === this._element); |
| 1667 | |
| 1668 | if (selector !== null && filterElement.length) { |
| 1669 | this._selector = selector; |
| 1670 | |
| 1671 | this._triggerArray.push(elem); |
| 1672 | } |
| 1673 | } |
| 1674 | |
| 1675 | this._initializeChildren(); |
| 1676 | |
| 1677 | if (!this._config.parent) { |
| 1678 | this._addAriaAndCollapsedClass(this._triggerArray, this._isShown()); |
| 1679 | } |
| 1680 | |
| 1681 | if (this._config.toggle) { |
| 1682 | this.toggle(); |
| 1683 | } |
| 1684 | } // Getters |
| 1685 | |
| 1686 | |
| 1687 | static get Default() { |
| 1688 | return Default$9; |
| 1689 | } |
| 1690 | |
| 1691 | static get NAME() { |
| 1692 | return NAME$a; |
| 1693 | } // Public |
| 1694 | |
| 1695 | |
| 1696 | toggle() { |
| 1697 | if (this._isShown()) { |
| 1698 | this.hide(); |
| 1699 | } else { |
| 1700 | this.show(); |
| 1701 | } |
| 1702 | } |
| 1703 | |
| 1704 | show() { |
| 1705 | if (this._isTransitioning || this._isShown()) { |
| 1706 | return; |
| 1707 | } |
| 1708 | |
| 1709 | let actives = []; |
| 1710 | let activesData; |
| 1711 | |
| 1712 | if (this._config.parent) { |
| 1713 | const children = SelectorEngine.find(CLASS_NAME_DEEPER_CHILDREN, this._config.parent); |
| 1714 | actives = SelectorEngine.find(SELECTOR_ACTIVES, this._config.parent).filter(elem => !children.includes(elem)); // remove children if greater depth |
| 1715 | } |
| 1716 | |
| 1717 | const container = SelectorEngine.findOne(this._selector); |
| 1718 | |
| 1719 | if (actives.length) { |
| 1720 | const tempActiveData = actives.find(elem => container !== elem); |
| 1721 | activesData = tempActiveData ? Collapse.getInstance(tempActiveData) : null; |
| 1722 | |
| 1723 | if (activesData && activesData._isTransitioning) { |
| 1724 | return; |
| 1725 | } |
| 1726 | } |
| 1727 | |
| 1728 | const startEvent = EventHandler.trigger(this._element, EVENT_SHOW$5); |
| 1729 | |
| 1730 | if (startEvent.defaultPrevented) { |
| 1731 | return; |
| 1732 | } |
| 1733 | |
| 1734 | actives.forEach(elemActive => { |
| 1735 | if (container !== elemActive) { |
| 1736 | Collapse.getOrCreateInstance(elemActive, { |
| 1737 | toggle: false |
| 1738 | }).hide(); |
| 1739 | } |
| 1740 | |
| 1741 | if (!activesData) { |
| 1742 | Data.set(elemActive, DATA_KEY$9, null); |
| 1743 | } |
| 1744 | }); |
| 1745 | |
| 1746 | const dimension = this._getDimension(); |
| 1747 | |
| 1748 | this._element.classList.remove(CLASS_NAME_COLLAPSE); |
| 1749 | |
| 1750 | this._element.classList.add(CLASS_NAME_COLLAPSING); |
| 1751 | |
| 1752 | this._element.style[dimension] = 0; |
| 1753 | |
| 1754 | this._addAriaAndCollapsedClass(this._triggerArray, true); |
| 1755 | |
| 1756 | this._isTransitioning = true; |
| 1757 | |
| 1758 | const complete = () => { |
| 1759 | this._isTransitioning = false; |
| 1760 | |
| 1761 | this._element.classList.remove(CLASS_NAME_COLLAPSING); |
| 1762 | |
| 1763 | this._element.classList.add(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW$7); |
| 1764 | |
| 1765 | this._element.style[dimension] = ''; |
| 1766 | EventHandler.trigger(this._element, EVENT_SHOWN$5); |
| 1767 | }; |
| 1768 | |
| 1769 | const capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1); |
| 1770 | const scrollSize = `scroll${capitalizedDimension}`; |
| 1771 | |
| 1772 | this._queueCallback(complete, this._element, true); |
| 1773 | |
| 1774 | this._element.style[dimension] = `${this._element[scrollSize]}px`; |
| 1775 | } |
| 1776 | |
| 1777 | hide() { |
| 1778 | if (this._isTransitioning || !this._isShown()) { |
| 1779 | return; |
| 1780 | } |
| 1781 | |
| 1782 | const startEvent = EventHandler.trigger(this._element, EVENT_HIDE$5); |
| 1783 | |
| 1784 | if (startEvent.defaultPrevented) { |
| 1785 | return; |
| 1786 | } |
| 1787 | |
| 1788 | const dimension = this._getDimension(); |
| 1789 | |
| 1790 | this._element.style[dimension] = `${this._element.getBoundingClientRect()[dimension]}px`; |
| 1791 | reflow(this._element); |
| 1792 | |
| 1793 | this._element.classList.add(CLASS_NAME_COLLAPSING); |
| 1794 | |
| 1795 | this._element.classList.remove(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW$7); |
| 1796 | |
| 1797 | const triggerArrayLength = this._triggerArray.length; |
| 1798 | |
| 1799 | for (let i = 0; i < triggerArrayLength; i++) { |
| 1800 | const trigger = this._triggerArray[i]; |
| 1801 | const elem = getElementFromSelector(trigger); |
| 1802 | |
| 1803 | if (elem && !this._isShown(elem)) { |
| 1804 | this._addAriaAndCollapsedClass([trigger], false); |
| 1805 | } |
| 1806 | } |
| 1807 | |
| 1808 | this._isTransitioning = true; |
| 1809 | |
| 1810 | const complete = () => { |
| 1811 | this._isTransitioning = false; |
| 1812 | |
| 1813 | this._element.classList.remove(CLASS_NAME_COLLAPSING); |
| 1814 | |
| 1815 | this._element.classList.add(CLASS_NAME_COLLAPSE); |
| 1816 | |
| 1817 | EventHandler.trigger(this._element, EVENT_HIDDEN$5); |
| 1818 | }; |
| 1819 | |
| 1820 | this._element.style[dimension] = ''; |
| 1821 | |
| 1822 | this._queueCallback(complete, this._element, true); |
| 1823 | } |
| 1824 | |
| 1825 | _isShown(element = this._element) { |
| 1826 | return element.classList.contains(CLASS_NAME_SHOW$7); |
| 1827 | } // Private |
| 1828 | |
| 1829 | |
| 1830 | _getConfig(config) { |
| 1831 | config = { ...Default$9, |
| 1832 | ...Manipulator.getDataAttributes(this._element), |
| 1833 | ...config |
| 1834 | }; |
| 1835 | config.toggle = Boolean(config.toggle); // Coerce string values |
| 1836 | |
| 1837 | config.parent = getElement(config.parent); |
| 1838 | typeCheckConfig(NAME$a, config, DefaultType$9); |
| 1839 | return config; |
| 1840 | } |
| 1841 | |
| 1842 | _getDimension() { |
| 1843 | return this._element.classList.contains(CLASS_NAME_HORIZONTAL) ? WIDTH : HEIGHT; |
| 1844 | } |
| 1845 | |
| 1846 | _initializeChildren() { |
| 1847 | if (!this._config.parent) { |
| 1848 | return; |
| 1849 | } |
| 1850 | |
| 1851 | const children = SelectorEngine.find(CLASS_NAME_DEEPER_CHILDREN, this._config.parent); |
| 1852 | SelectorEngine.find(SELECTOR_DATA_TOGGLE$4, this._config.parent).filter(elem => !children.includes(elem)).forEach(element => { |
| 1853 | const selected = getElementFromSelector(element); |
| 1854 | |
| 1855 | if (selected) { |
| 1856 | this._addAriaAndCollapsedClass([element], this._isShown(selected)); |
| 1857 | } |
| 1858 | }); |
| 1859 | } |
| 1860 | |
| 1861 | _addAriaAndCollapsedClass(triggerArray, isOpen) { |
| 1862 | if (!triggerArray.length) { |
| 1863 | return; |
| 1864 | } |
| 1865 | |
| 1866 | triggerArray.forEach(elem => { |
| 1867 | if (isOpen) { |
| 1868 | elem.classList.remove(CLASS_NAME_COLLAPSED); |
| 1869 | } else { |
| 1870 | elem.classList.add(CLASS_NAME_COLLAPSED); |
| 1871 | } |
| 1872 | |
| 1873 | elem.setAttribute('aria-expanded', isOpen); |
| 1874 | }); |
| 1875 | } // Static |
| 1876 | |
| 1877 | |
| 1878 | static jQueryInterface(config) { |
| 1879 | return this.each(function () { |
| 1880 | const _config = {}; |
| 1881 | |
| 1882 | if (typeof config === 'string' && /show|hide/.test(config)) { |
| 1883 | _config.toggle = false; |
| 1884 | } |
| 1885 | |
| 1886 | const data = Collapse.getOrCreateInstance(this, _config); |
| 1887 | |
| 1888 | if (typeof config === 'string') { |
| 1889 | if (typeof data[config] === 'undefined') { |
| 1890 | throw new TypeError(`No method named "${config}"`); |
| 1891 | } |
| 1892 | |
| 1893 | data[config](); |
| 1894 | } |
| 1895 | }); |
| 1896 | } |
| 1897 | |
| 1898 | } |
| 1899 | /** |
| 1900 | * ------------------------------------------------------------------------ |
| 1901 | * Data Api implementation |
| 1902 | * ------------------------------------------------------------------------ |
| 1903 | */ |
| 1904 | |
| 1905 | |
| 1906 | EventHandler.on(document, EVENT_CLICK_DATA_API$4, SELECTOR_DATA_TOGGLE$4, function (event) { |
| 1907 | // preventDefault only for <a> elements (which change the URL) not inside the collapsible element |
| 1908 | if (event.target.tagName === 'A' || event.delegateTarget && event.delegateTarget.tagName === 'A') { |
| 1909 | event.preventDefault(); |
| 1910 | } |
| 1911 | |
| 1912 | const selector = getSelectorFromElement(this); |
| 1913 | const selectorElements = SelectorEngine.find(selector); |
| 1914 | selectorElements.forEach(element => { |
| 1915 | Collapse.getOrCreateInstance(element, { |
| 1916 | toggle: false |
| 1917 | }).toggle(); |
| 1918 | }); |
| 1919 | }); |
| 1920 | /** |
| 1921 | * ------------------------------------------------------------------------ |
| 1922 | * jQuery |
| 1923 | * ------------------------------------------------------------------------ |
| 1924 | * add .Collapse to jQuery only if jQuery is present |
| 1925 | */ |
| 1926 | |
| 1927 | defineJQueryPlugin(Collapse); |
| 1928 | |
| 1929 | var top = 'top'; |
| 1930 | var bottom = 'bottom'; |
| 1931 | var right = 'right'; |
| 1932 | var left = 'left'; |
| 1933 | var auto = 'auto'; |
| 1934 | var basePlacements = [top, bottom, right, left]; |
| 1935 | var start = 'start'; |
| 1936 | var end = 'end'; |
| 1937 | var clippingParents = 'clippingParents'; |
| 1938 | var viewport = 'viewport'; |
| 1939 | var popper = 'popper'; |
| 1940 | var reference = 'reference'; |
| 1941 | var variationPlacements = /*#__PURE__*/basePlacements.reduce(function (acc, placement) { |
| 1942 | return acc.concat([placement + "-" + start, placement + "-" + end]); |
| 1943 | }, []); |
| 1944 | var placements = /*#__PURE__*/[].concat(basePlacements, [auto]).reduce(function (acc, placement) { |
| 1945 | return acc.concat([placement, placement + "-" + start, placement + "-" + end]); |
| 1946 | }, []); // modifiers that need to read the DOM |
| 1947 | |
| 1948 | var beforeRead = 'beforeRead'; |
| 1949 | var read = 'read'; |
| 1950 | var afterRead = 'afterRead'; // pure-logic modifiers |
| 1951 | |
| 1952 | var beforeMain = 'beforeMain'; |
| 1953 | var main = 'main'; |
| 1954 | var afterMain = 'afterMain'; // modifier with the purpose to write to the DOM (or write into a framework state) |
| 1955 | |
| 1956 | var beforeWrite = 'beforeWrite'; |
| 1957 | var write = 'write'; |
| 1958 | var afterWrite = 'afterWrite'; |
| 1959 | var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite]; |
| 1960 | |
| 1961 | function getNodeName(element) { |
| 1962 | return element ? (element.nodeName || '').toLowerCase() : null; |
| 1963 | } |
| 1964 | |
| 1965 | function getWindow(node) { |
| 1966 | if (node == null) { |
| 1967 | return window; |
| 1968 | } |
| 1969 | |
| 1970 | if (node.toString() !== '[object Window]') { |
| 1971 | var ownerDocument = node.ownerDocument; |
| 1972 | return ownerDocument ? ownerDocument.defaultView || window : window; |
| 1973 | } |
| 1974 | |
| 1975 | return node; |
| 1976 | } |
| 1977 | |
| 1978 | function isElement(node) { |
| 1979 | var OwnElement = getWindow(node).Element; |
| 1980 | return node instanceof OwnElement || node instanceof Element; |
| 1981 | } |
| 1982 | |
| 1983 | function isHTMLElement(node) { |
| 1984 | var OwnElement = getWindow(node).HTMLElement; |
| 1985 | return node instanceof OwnElement || node instanceof HTMLElement; |
| 1986 | } |
| 1987 | |
| 1988 | function isShadowRoot(node) { |
| 1989 | // IE 11 has no ShadowRoot |
| 1990 | if (typeof ShadowRoot === 'undefined') { |
| 1991 | return false; |
| 1992 | } |
| 1993 | |
| 1994 | var OwnElement = getWindow(node).ShadowRoot; |
| 1995 | return node instanceof OwnElement || node instanceof ShadowRoot; |
| 1996 | } |
| 1997 | |
| 1998 | // and applies them to the HTMLElements such as popper and arrow |
| 1999 | |
| 2000 | function applyStyles(_ref) { |
| 2001 | var state = _ref.state; |
| 2002 | Object.keys(state.elements).forEach(function (name) { |
| 2003 | var style = state.styles[name] || {}; |
| 2004 | var attributes = state.attributes[name] || {}; |
| 2005 | var element = state.elements[name]; // arrow is optional + virtual elements |
| 2006 | |
| 2007 | if (!isHTMLElement(element) || !getNodeName(element)) { |
| 2008 | return; |
| 2009 | } // Flow doesn't support to extend this property, but it's the most |
| 2010 | // effective way to apply styles to an HTMLElement |
| 2011 | // $FlowFixMe[cannot-write] |
| 2012 | |
| 2013 | |
| 2014 | Object.assign(element.style, style); |
| 2015 | Object.keys(attributes).forEach(function (name) { |
| 2016 | var value = attributes[name]; |
| 2017 | |
| 2018 | if (value === false) { |
| 2019 | element.removeAttribute(name); |
| 2020 | } else { |
| 2021 | element.setAttribute(name, value === true ? '' : value); |
| 2022 | } |
| 2023 | }); |
| 2024 | }); |
| 2025 | } |
| 2026 | |
| 2027 | function effect$2(_ref2) { |
| 2028 | var state = _ref2.state; |
| 2029 | var initialStyles = { |
| 2030 | popper: { |
| 2031 | position: state.options.strategy, |
| 2032 | left: '0', |
| 2033 | top: '0', |
| 2034 | margin: '0' |
| 2035 | }, |
| 2036 | arrow: { |
| 2037 | position: 'absolute' |
| 2038 | }, |
| 2039 | reference: {} |
| 2040 | }; |
| 2041 | Object.assign(state.elements.popper.style, initialStyles.popper); |
| 2042 | state.styles = initialStyles; |
| 2043 | |
| 2044 | if (state.elements.arrow) { |
| 2045 | Object.assign(state.elements.arrow.style, initialStyles.arrow); |
| 2046 | } |
| 2047 | |
| 2048 | return function () { |
| 2049 | Object.keys(state.elements).forEach(function (name) { |
| 2050 | var element = state.elements[name]; |
| 2051 | var attributes = state.attributes[name] || {}; |
| 2052 | var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]); // Set all values to an empty string to unset them |
| 2053 | |
| 2054 | var style = styleProperties.reduce(function (style, property) { |
| 2055 | style[property] = ''; |
| 2056 | return style; |
| 2057 | }, {}); // arrow is optional + virtual elements |
| 2058 | |
| 2059 | if (!isHTMLElement(element) || !getNodeName(element)) { |
| 2060 | return; |
| 2061 | } |
| 2062 | |
| 2063 | Object.assign(element.style, style); |
| 2064 | Object.keys(attributes).forEach(function (attribute) { |
| 2065 | element.removeAttribute(attribute); |
| 2066 | }); |
| 2067 | }); |
| 2068 | }; |
| 2069 | } // eslint-disable-next-line import/no-unused-modules |
| 2070 | |
| 2071 | |
| 2072 | const applyStyles$1 = { |
| 2073 | name: 'applyStyles', |
| 2074 | enabled: true, |
| 2075 | phase: 'write', |
| 2076 | fn: applyStyles, |
| 2077 | effect: effect$2, |
| 2078 | requires: ['computeStyles'] |
| 2079 | }; |
| 2080 | |
| 2081 | function getBasePlacement(placement) { |
| 2082 | return placement.split('-')[0]; |
| 2083 | } |
| 2084 | |
| 2085 | // import { isHTMLElement } from './instanceOf'; |
| 2086 | function getBoundingClientRect(element, // eslint-disable-next-line unused-imports/no-unused-vars |
| 2087 | includeScale) { |
| 2088 | |
| 2089 | var rect = element.getBoundingClientRect(); |
| 2090 | var scaleX = 1; |
| 2091 | var scaleY = 1; // FIXME: |
| 2092 | // `offsetWidth` returns an integer while `getBoundingClientRect` |
| 2093 | // returns a float. This results in `scaleX` or `scaleY` being |
| 2094 | // non-1 when it should be for elements that aren't a full pixel in |
| 2095 | // width or height. |
| 2096 | // if (isHTMLElement(element) && includeScale) { |
| 2097 | // const offsetHeight = element.offsetHeight; |
| 2098 | // const offsetWidth = element.offsetWidth; |
| 2099 | // // Do not attempt to divide by 0, otherwise we get `Infinity` as scale |
| 2100 | // // Fallback to 1 in case both values are `0` |
| 2101 | // if (offsetWidth > 0) { |
| 2102 | // scaleX = rect.width / offsetWidth || 1; |
| 2103 | // } |
| 2104 | // if (offsetHeight > 0) { |
| 2105 | // scaleY = rect.height / offsetHeight || 1; |
| 2106 | // } |
| 2107 | // } |
| 2108 | |
| 2109 | return { |
| 2110 | width: rect.width / scaleX, |
| 2111 | height: rect.height / scaleY, |
| 2112 | top: rect.top / scaleY, |
| 2113 | right: rect.right / scaleX, |
| 2114 | bottom: rect.bottom / scaleY, |
| 2115 | left: rect.left / scaleX, |
| 2116 | x: rect.left / scaleX, |
| 2117 | y: rect.top / scaleY |
| 2118 | }; |
| 2119 | } |
| 2120 | |
| 2121 | // means it doesn't take into account transforms. |
| 2122 | |
| 2123 | function getLayoutRect(element) { |
| 2124 | var clientRect = getBoundingClientRect(element); // Use the clientRect sizes if it's not been transformed. |
| 2125 | // Fixes https://github.com/popperjs/popper-core/issues/1223 |
| 2126 | |
| 2127 | var width = element.offsetWidth; |
| 2128 | var height = element.offsetHeight; |
| 2129 | |
| 2130 | if (Math.abs(clientRect.width - width) <= 1) { |
| 2131 | width = clientRect.width; |
| 2132 | } |
| 2133 | |
| 2134 | if (Math.abs(clientRect.height - height) <= 1) { |
| 2135 | height = clientRect.height; |
| 2136 | } |
| 2137 | |
| 2138 | return { |
| 2139 | x: element.offsetLeft, |
| 2140 | y: element.offsetTop, |
| 2141 | width: width, |
| 2142 | height: height |
| 2143 | }; |
| 2144 | } |
| 2145 | |
| 2146 | function contains(parent, child) { |
| 2147 | var rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method |
| 2148 | |
| 2149 | if (parent.contains(child)) { |
| 2150 | return true; |
| 2151 | } // then fallback to custom implementation with Shadow DOM support |
| 2152 | else if (rootNode && isShadowRoot(rootNode)) { |
| 2153 | var next = child; |
| 2154 | |
| 2155 | do { |
| 2156 | if (next && parent.isSameNode(next)) { |
| 2157 | return true; |
| 2158 | } // $FlowFixMe[prop-missing]: need a better way to handle this... |
| 2159 | |
| 2160 | |
| 2161 | next = next.parentNode || next.host; |
| 2162 | } while (next); |
| 2163 | } // Give up, the result is false |
| 2164 | |
| 2165 | |
| 2166 | return false; |
| 2167 | } |
| 2168 | |
| 2169 | function getComputedStyle$1(element) { |
| 2170 | return getWindow(element).getComputedStyle(element); |
| 2171 | } |
| 2172 | |
| 2173 | function isTableElement(element) { |
| 2174 | return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0; |
| 2175 | } |
| 2176 | |
| 2177 | function getDocumentElement(element) { |
| 2178 | // $FlowFixMe[incompatible-return]: assume body is always available |
| 2179 | return ((isElement(element) ? element.ownerDocument : // $FlowFixMe[prop-missing] |
| 2180 | element.document) || window.document).documentElement; |
| 2181 | } |
| 2182 | |
| 2183 | function getParentNode(element) { |
| 2184 | if (getNodeName(element) === 'html') { |
| 2185 | return element; |
| 2186 | } |
| 2187 | |
| 2188 | return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle |
| 2189 | // $FlowFixMe[incompatible-return] |
| 2190 | // $FlowFixMe[prop-missing] |
| 2191 | element.assignedSlot || // step into the shadow DOM of the parent of a slotted node |
| 2192 | element.parentNode || ( // DOM Element detected |
| 2193 | isShadowRoot(element) ? element.host : null) || // ShadowRoot detected |
| 2194 | // $FlowFixMe[incompatible-call]: HTMLElement is a Node |
| 2195 | getDocumentElement(element) // fallback |
| 2196 | |
| 2197 | ); |
| 2198 | } |
| 2199 | |
| 2200 | function getTrueOffsetParent(element) { |
| 2201 | if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837 |
| 2202 | getComputedStyle$1(element).position === 'fixed') { |
| 2203 | return null; |
| 2204 | } |
| 2205 | |
| 2206 | return element.offsetParent; |
| 2207 | } // `.offsetParent` reports `null` for fixed elements, while absolute elements |
| 2208 | // return the containing block |
| 2209 | |
| 2210 | |
| 2211 | function getContainingBlock(element) { |
| 2212 | var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') !== -1; |
| 2213 | var isIE = navigator.userAgent.indexOf('Trident') !== -1; |
| 2214 | |
| 2215 | if (isIE && isHTMLElement(element)) { |
| 2216 | // In IE 9, 10 and 11 fixed elements containing block is always established by the viewport |
| 2217 | var elementCss = getComputedStyle$1(element); |
| 2218 | |
| 2219 | if (elementCss.position === 'fixed') { |
| 2220 | return null; |
| 2221 | } |
| 2222 | } |
| 2223 | |
| 2224 | var currentNode = getParentNode(element); |
| 2225 | |
| 2226 | while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) { |
| 2227 | var css = getComputedStyle$1(currentNode); // This is non-exhaustive but covers the most common CSS properties that |
| 2228 | // create a containing block. |
| 2229 | // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block |
| 2230 | |
| 2231 | 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') { |
| 2232 | return currentNode; |
| 2233 | } else { |
| 2234 | currentNode = currentNode.parentNode; |
| 2235 | } |
| 2236 | } |
| 2237 | |
| 2238 | return null; |
| 2239 | } // Gets the closest ancestor positioned element. Handles some edge cases, |
| 2240 | // such as table ancestors and cross browser bugs. |
| 2241 | |
| 2242 | |
| 2243 | function getOffsetParent(element) { |
| 2244 | var window = getWindow(element); |
| 2245 | var offsetParent = getTrueOffsetParent(element); |
| 2246 | |
| 2247 | while (offsetParent && isTableElement(offsetParent) && getComputedStyle$1(offsetParent).position === 'static') { |
| 2248 | offsetParent = getTrueOffsetParent(offsetParent); |
| 2249 | } |
| 2250 | |
| 2251 | if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle$1(offsetParent).position === 'static')) { |
| 2252 | return window; |
| 2253 | } |
| 2254 | |
| 2255 | return offsetParent || getContainingBlock(element) || window; |
| 2256 | } |
| 2257 | |
| 2258 | function getMainAxisFromPlacement(placement) { |
| 2259 | return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y'; |
| 2260 | } |
| 2261 | |
| 2262 | var max = Math.max; |
| 2263 | var min = Math.min; |
| 2264 | var round = Math.round; |
| 2265 | |
| 2266 | function within(min$1, value, max$1) { |
| 2267 | return max(min$1, min(value, max$1)); |
| 2268 | } |
| 2269 | |
| 2270 | function getFreshSideObject() { |
| 2271 | return { |
| 2272 | top: 0, |
| 2273 | right: 0, |
| 2274 | bottom: 0, |
| 2275 | left: 0 |
| 2276 | }; |
| 2277 | } |
| 2278 | |
| 2279 | function mergePaddingObject(paddingObject) { |
| 2280 | return Object.assign({}, getFreshSideObject(), paddingObject); |
| 2281 | } |
| 2282 | |
| 2283 | function expandToHashMap(value, keys) { |
| 2284 | return keys.reduce(function (hashMap, key) { |
| 2285 | hashMap[key] = value; |
| 2286 | return hashMap; |
| 2287 | }, {}); |
| 2288 | } |
| 2289 | |
| 2290 | var toPaddingObject = function toPaddingObject(padding, state) { |
| 2291 | padding = typeof padding === 'function' ? padding(Object.assign({}, state.rects, { |
| 2292 | placement: state.placement |
| 2293 | })) : padding; |
| 2294 | return mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements)); |
| 2295 | }; |
| 2296 | |
| 2297 | function arrow(_ref) { |
| 2298 | var _state$modifiersData$; |
| 2299 | |
| 2300 | var state = _ref.state, |
| 2301 | name = _ref.name, |
| 2302 | options = _ref.options; |
| 2303 | var arrowElement = state.elements.arrow; |
| 2304 | var popperOffsets = state.modifiersData.popperOffsets; |
| 2305 | var basePlacement = getBasePlacement(state.placement); |
| 2306 | var axis = getMainAxisFromPlacement(basePlacement); |
| 2307 | var isVertical = [left, right].indexOf(basePlacement) >= 0; |
| 2308 | var len = isVertical ? 'height' : 'width'; |
| 2309 | |
| 2310 | if (!arrowElement || !popperOffsets) { |
| 2311 | return; |
| 2312 | } |
| 2313 | |
| 2314 | var paddingObject = toPaddingObject(options.padding, state); |
| 2315 | var arrowRect = getLayoutRect(arrowElement); |
| 2316 | var minProp = axis === 'y' ? top : left; |
| 2317 | var maxProp = axis === 'y' ? bottom : right; |
| 2318 | var endDiff = state.rects.reference[len] + state.rects.reference[axis] - popperOffsets[axis] - state.rects.popper[len]; |
| 2319 | var startDiff = popperOffsets[axis] - state.rects.reference[axis]; |
| 2320 | var arrowOffsetParent = getOffsetParent(arrowElement); |
| 2321 | var clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0; |
| 2322 | var centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the popper if the center point is |
| 2323 | // outside of the popper bounds |
| 2324 | |
| 2325 | var min = paddingObject[minProp]; |
| 2326 | var max = clientSize - arrowRect[len] - paddingObject[maxProp]; |
| 2327 | var center = clientSize / 2 - arrowRect[len] / 2 + centerToReference; |
| 2328 | var offset = within(min, center, max); // Prevents breaking syntax highlighting... |
| 2329 | |
| 2330 | var axisProp = axis; |
| 2331 | state.modifiersData[name] = (_state$modifiersData$ = {}, _state$modifiersData$[axisProp] = offset, _state$modifiersData$.centerOffset = offset - center, _state$modifiersData$); |
| 2332 | } |
| 2333 | |
| 2334 | function effect$1(_ref2) { |
| 2335 | var state = _ref2.state, |
| 2336 | options = _ref2.options; |
| 2337 | var _options$element = options.element, |
| 2338 | arrowElement = _options$element === void 0 ? '[data-popper-arrow]' : _options$element; |
| 2339 | |
| 2340 | if (arrowElement == null) { |
| 2341 | return; |
| 2342 | } // CSS selector |
| 2343 | |
| 2344 | |
| 2345 | if (typeof arrowElement === 'string') { |
| 2346 | arrowElement = state.elements.popper.querySelector(arrowElement); |
| 2347 | |
| 2348 | if (!arrowElement) { |
| 2349 | return; |
| 2350 | } |
| 2351 | } |
| 2352 | |
| 2353 | if (!contains(state.elements.popper, arrowElement)) { |
| 2354 | |
| 2355 | return; |
| 2356 | } |
| 2357 | |
| 2358 | state.elements.arrow = arrowElement; |
| 2359 | } // eslint-disable-next-line import/no-unused-modules |
| 2360 | |
| 2361 | |
| 2362 | const arrow$1 = { |
| 2363 | name: 'arrow', |
| 2364 | enabled: true, |
| 2365 | phase: 'main', |
| 2366 | fn: arrow, |
| 2367 | effect: effect$1, |
| 2368 | requires: ['popperOffsets'], |
| 2369 | requiresIfExists: ['preventOverflow'] |
| 2370 | }; |
| 2371 | |
| 2372 | function getVariation(placement) { |
| 2373 | return placement.split('-')[1]; |
| 2374 | } |
| 2375 | |
| 2376 | var unsetSides = { |
| 2377 | top: 'auto', |
| 2378 | right: 'auto', |
| 2379 | bottom: 'auto', |
| 2380 | left: 'auto' |
| 2381 | }; // Round the offsets to the nearest suitable subpixel based on the DPR. |
| 2382 | // Zooming can change the DPR, but it seems to report a value that will |
| 2383 | // cleanly divide the values into the appropriate subpixels. |
| 2384 | |
| 2385 | function roundOffsetsByDPR(_ref) { |
| 2386 | var x = _ref.x, |
| 2387 | y = _ref.y; |
| 2388 | var win = window; |
| 2389 | var dpr = win.devicePixelRatio || 1; |
| 2390 | return { |
| 2391 | x: round(round(x * dpr) / dpr) || 0, |
| 2392 | y: round(round(y * dpr) / dpr) || 0 |
| 2393 | }; |
| 2394 | } |
| 2395 | |
| 2396 | function mapToStyles(_ref2) { |
| 2397 | var _Object$assign2; |
| 2398 | |
| 2399 | var popper = _ref2.popper, |
| 2400 | popperRect = _ref2.popperRect, |
| 2401 | placement = _ref2.placement, |
| 2402 | variation = _ref2.variation, |
| 2403 | offsets = _ref2.offsets, |
| 2404 | position = _ref2.position, |
| 2405 | gpuAcceleration = _ref2.gpuAcceleration, |
| 2406 | adaptive = _ref2.adaptive, |
| 2407 | roundOffsets = _ref2.roundOffsets; |
| 2408 | |
| 2409 | var _ref3 = roundOffsets === true ? roundOffsetsByDPR(offsets) : typeof roundOffsets === 'function' ? roundOffsets(offsets) : offsets, |
| 2410 | _ref3$x = _ref3.x, |
| 2411 | x = _ref3$x === void 0 ? 0 : _ref3$x, |
| 2412 | _ref3$y = _ref3.y, |
| 2413 | y = _ref3$y === void 0 ? 0 : _ref3$y; |
| 2414 | |
| 2415 | var hasX = offsets.hasOwnProperty('x'); |
| 2416 | var hasY = offsets.hasOwnProperty('y'); |
| 2417 | var sideX = left; |
| 2418 | var sideY = top; |
| 2419 | var win = window; |
| 2420 | |
| 2421 | if (adaptive) { |
| 2422 | var offsetParent = getOffsetParent(popper); |
| 2423 | var heightProp = 'clientHeight'; |
| 2424 | var widthProp = 'clientWidth'; |
| 2425 | |
| 2426 | if (offsetParent === getWindow(popper)) { |
| 2427 | offsetParent = getDocumentElement(popper); |
| 2428 | |
| 2429 | if (getComputedStyle$1(offsetParent).position !== 'static' && position === 'absolute') { |
| 2430 | heightProp = 'scrollHeight'; |
| 2431 | widthProp = 'scrollWidth'; |
| 2432 | } |
| 2433 | } // $FlowFixMe[incompatible-cast]: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it |
| 2434 | |
| 2435 | |
| 2436 | offsetParent = offsetParent; |
| 2437 | |
| 2438 | if (placement === top || (placement === left || placement === right) && variation === end) { |
| 2439 | sideY = bottom; // $FlowFixMe[prop-missing] |
| 2440 | |
| 2441 | y -= offsetParent[heightProp] - popperRect.height; |
| 2442 | y *= gpuAcceleration ? 1 : -1; |
| 2443 | } |
| 2444 | |
| 2445 | if (placement === left || (placement === top || placement === bottom) && variation === end) { |
| 2446 | sideX = right; // $FlowFixMe[prop-missing] |
| 2447 | |
| 2448 | x -= offsetParent[widthProp] - popperRect.width; |
| 2449 | x *= gpuAcceleration ? 1 : -1; |
| 2450 | } |
| 2451 | } |
| 2452 | |
| 2453 | var commonStyles = Object.assign({ |
| 2454 | position: position |
| 2455 | }, adaptive && unsetSides); |
| 2456 | |
| 2457 | if (gpuAcceleration) { |
| 2458 | var _Object$assign; |
| 2459 | |
| 2460 | 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)); |
| 2461 | } |
| 2462 | |
| 2463 | return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2)); |
| 2464 | } |
| 2465 | |
| 2466 | function computeStyles(_ref4) { |
| 2467 | var state = _ref4.state, |
| 2468 | options = _ref4.options; |
| 2469 | var _options$gpuAccelerat = options.gpuAcceleration, |
| 2470 | gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat, |
| 2471 | _options$adaptive = options.adaptive, |
| 2472 | adaptive = _options$adaptive === void 0 ? true : _options$adaptive, |
| 2473 | _options$roundOffsets = options.roundOffsets, |
| 2474 | roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets; |
| 2475 | |
| 2476 | var commonStyles = { |
| 2477 | placement: getBasePlacement(state.placement), |
| 2478 | variation: getVariation(state.placement), |
| 2479 | popper: state.elements.popper, |
| 2480 | popperRect: state.rects.popper, |
| 2481 | gpuAcceleration: gpuAcceleration |
| 2482 | }; |
| 2483 | |
| 2484 | if (state.modifiersData.popperOffsets != null) { |
| 2485 | state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, { |
| 2486 | offsets: state.modifiersData.popperOffsets, |
| 2487 | position: state.options.strategy, |
| 2488 | adaptive: adaptive, |
| 2489 | roundOffsets: roundOffsets |
| 2490 | }))); |
| 2491 | } |
| 2492 | |
| 2493 | if (state.modifiersData.arrow != null) { |
| 2494 | state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, { |
| 2495 | offsets: state.modifiersData.arrow, |
| 2496 | position: 'absolute', |
| 2497 | adaptive: false, |
| 2498 | roundOffsets: roundOffsets |
| 2499 | }))); |
| 2500 | } |
| 2501 | |
| 2502 | state.attributes.popper = Object.assign({}, state.attributes.popper, { |
| 2503 | 'data-popper-placement': state.placement |
| 2504 | }); |
| 2505 | } // eslint-disable-next-line import/no-unused-modules |
| 2506 | |
| 2507 | |
| 2508 | const computeStyles$1 = { |
| 2509 | name: 'computeStyles', |
| 2510 | enabled: true, |
| 2511 | phase: 'beforeWrite', |
| 2512 | fn: computeStyles, |
| 2513 | data: {} |
| 2514 | }; |
| 2515 | |
| 2516 | var passive = { |
| 2517 | passive: true |
| 2518 | }; |
| 2519 | |
| 2520 | function effect(_ref) { |
| 2521 | var state = _ref.state, |
| 2522 | instance = _ref.instance, |
| 2523 | options = _ref.options; |
| 2524 | var _options$scroll = options.scroll, |
| 2525 | scroll = _options$scroll === void 0 ? true : _options$scroll, |
| 2526 | _options$resize = options.resize, |
| 2527 | resize = _options$resize === void 0 ? true : _options$resize; |
| 2528 | var window = getWindow(state.elements.popper); |
| 2529 | var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper); |
| 2530 | |
| 2531 | if (scroll) { |
| 2532 | scrollParents.forEach(function (scrollParent) { |
| 2533 | scrollParent.addEventListener('scroll', instance.update, passive); |
| 2534 | }); |
| 2535 | } |
| 2536 | |
| 2537 | if (resize) { |
| 2538 | window.addEventListener('resize', instance.update, passive); |
| 2539 | } |
| 2540 | |
| 2541 | return function () { |
| 2542 | if (scroll) { |
| 2543 | scrollParents.forEach(function (scrollParent) { |
| 2544 | scrollParent.removeEventListener('scroll', instance.update, passive); |
| 2545 | }); |
| 2546 | } |
| 2547 | |
| 2548 | if (resize) { |
| 2549 | window.removeEventListener('resize', instance.update, passive); |
| 2550 | } |
| 2551 | }; |
| 2552 | } // eslint-disable-next-line import/no-unused-modules |
| 2553 | |
| 2554 | |
| 2555 | const eventListeners = { |
| 2556 | name: 'eventListeners', |
| 2557 | enabled: true, |
| 2558 | phase: 'write', |
| 2559 | fn: function fn() {}, |
| 2560 | effect: effect, |
| 2561 | data: {} |
| 2562 | }; |
| 2563 | |
| 2564 | var hash$1 = { |
| 2565 | left: 'right', |
| 2566 | right: 'left', |
| 2567 | bottom: 'top', |
| 2568 | top: 'bottom' |
| 2569 | }; |
| 2570 | function getOppositePlacement(placement) { |
| 2571 | return placement.replace(/left|right|bottom|top/g, function (matched) { |
| 2572 | return hash$1[matched]; |
| 2573 | }); |
| 2574 | } |
| 2575 | |
| 2576 | var hash = { |
| 2577 | start: 'end', |
| 2578 | end: 'start' |
| 2579 | }; |
| 2580 | function getOppositeVariationPlacement(placement) { |
| 2581 | return placement.replace(/start|end/g, function (matched) { |
| 2582 | return hash[matched]; |
| 2583 | }); |
| 2584 | } |
| 2585 | |
| 2586 | function getWindowScroll(node) { |
| 2587 | var win = getWindow(node); |
| 2588 | var scrollLeft = win.pageXOffset; |
| 2589 | var scrollTop = win.pageYOffset; |
| 2590 | return { |
| 2591 | scrollLeft: scrollLeft, |
| 2592 | scrollTop: scrollTop |
| 2593 | }; |
| 2594 | } |
| 2595 | |
| 2596 | function getWindowScrollBarX(element) { |
| 2597 | // If <html> has a CSS width greater than the viewport, then this will be |
| 2598 | // incorrect for RTL. |
| 2599 | // Popper 1 is broken in this case and never had a bug report so let's assume |
| 2600 | // it's not an issue. I don't think anyone ever specifies width on <html> |
| 2601 | // anyway. |
| 2602 | // Browsers where the left scrollbar doesn't cause an issue report `0` for |
| 2603 | // this (e.g. Edge 2019, IE11, Safari) |
| 2604 | return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft; |
| 2605 | } |
| 2606 | |
| 2607 | function getViewportRect(element) { |
| 2608 | var win = getWindow(element); |
| 2609 | var html = getDocumentElement(element); |
| 2610 | var visualViewport = win.visualViewport; |
| 2611 | var width = html.clientWidth; |
| 2612 | var height = html.clientHeight; |
| 2613 | var x = 0; |
| 2614 | var y = 0; // NB: This isn't supported on iOS <= 12. If the keyboard is open, the popper |
| 2615 | // can be obscured underneath it. |
| 2616 | // Also, `html.clientHeight` adds the bottom bar height in Safari iOS, even |
| 2617 | // if it isn't open, so if this isn't available, the popper will be detected |
| 2618 | // to overflow the bottom of the screen too early. |
| 2619 | |
| 2620 | if (visualViewport) { |
| 2621 | width = visualViewport.width; |
| 2622 | height = visualViewport.height; // Uses Layout Viewport (like Chrome; Safari does not currently) |
| 2623 | // In Chrome, it returns a value very close to 0 (+/-) but contains rounding |
| 2624 | // errors due to floating point numbers, so we need to check precision. |
| 2625 | // Safari returns a number <= 0, usually < -1 when pinch-zoomed |
| 2626 | // Feature detection fails in mobile emulation mode in Chrome. |
| 2627 | // Math.abs(win.innerWidth / visualViewport.scale - visualViewport.width) < |
| 2628 | // 0.001 |
| 2629 | // Fallback here: "Not Safari" userAgent |
| 2630 | |
| 2631 | if (!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) { |
| 2632 | x = visualViewport.offsetLeft; |
| 2633 | y = visualViewport.offsetTop; |
| 2634 | } |
| 2635 | } |
| 2636 | |
| 2637 | return { |
| 2638 | width: width, |
| 2639 | height: height, |
| 2640 | x: x + getWindowScrollBarX(element), |
| 2641 | y: y |
| 2642 | }; |
| 2643 | } |
| 2644 | |
| 2645 | // of the `<html>` and `<body>` rect bounds if horizontally scrollable |
| 2646 | |
| 2647 | function getDocumentRect(element) { |
| 2648 | var _element$ownerDocumen; |
| 2649 | |
| 2650 | var html = getDocumentElement(element); |
| 2651 | var winScroll = getWindowScroll(element); |
| 2652 | var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body; |
| 2653 | var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0); |
| 2654 | var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0); |
| 2655 | var x = -winScroll.scrollLeft + getWindowScrollBarX(element); |
| 2656 | var y = -winScroll.scrollTop; |
| 2657 | |
| 2658 | if (getComputedStyle$1(body || html).direction === 'rtl') { |
| 2659 | x += max(html.clientWidth, body ? body.clientWidth : 0) - width; |
| 2660 | } |
| 2661 | |
| 2662 | return { |
| 2663 | width: width, |
| 2664 | height: height, |
| 2665 | x: x, |
| 2666 | y: y |
| 2667 | }; |
| 2668 | } |
| 2669 | |
| 2670 | function isScrollParent(element) { |
| 2671 | // Firefox wants us to check `-x` and `-y` variations as well |
| 2672 | var _getComputedStyle = getComputedStyle$1(element), |
| 2673 | overflow = _getComputedStyle.overflow, |
| 2674 | overflowX = _getComputedStyle.overflowX, |
| 2675 | overflowY = _getComputedStyle.overflowY; |
| 2676 | |
| 2677 | return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX); |
| 2678 | } |
| 2679 | |
| 2680 | function getScrollParent(node) { |
| 2681 | if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) { |
| 2682 | // $FlowFixMe[incompatible-return]: assume body is always available |
| 2683 | return node.ownerDocument.body; |
| 2684 | } |
| 2685 | |
| 2686 | if (isHTMLElement(node) && isScrollParent(node)) { |
| 2687 | return node; |
| 2688 | } |
| 2689 | |
| 2690 | return getScrollParent(getParentNode(node)); |
| 2691 | } |
| 2692 | |
| 2693 | /* |
| 2694 | given a DOM element, return the list of all scroll parents, up the list of ancesors |
| 2695 | until we get to the top window object. This list is what we attach scroll listeners |
| 2696 | to, because if any of these parent elements scroll, we'll need to re-calculate the |
| 2697 | reference element's position. |
| 2698 | */ |
| 2699 | |
| 2700 | function listScrollParents(element, list) { |
| 2701 | var _element$ownerDocumen; |
| 2702 | |
| 2703 | if (list === void 0) { |
| 2704 | list = []; |
| 2705 | } |
| 2706 | |
| 2707 | var scrollParent = getScrollParent(element); |
| 2708 | var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body); |
| 2709 | var win = getWindow(scrollParent); |
| 2710 | var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent; |
| 2711 | var updatedList = list.concat(target); |
| 2712 | return isBody ? updatedList : // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here |
| 2713 | updatedList.concat(listScrollParents(getParentNode(target))); |
| 2714 | } |
| 2715 | |
| 2716 | function rectToClientRect(rect) { |
| 2717 | return Object.assign({}, rect, { |
| 2718 | left: rect.x, |
| 2719 | top: rect.y, |
| 2720 | right: rect.x + rect.width, |
| 2721 | bottom: rect.y + rect.height |
| 2722 | }); |
| 2723 | } |
| 2724 | |
| 2725 | function getInnerBoundingClientRect(element) { |
| 2726 | var rect = getBoundingClientRect(element); |
| 2727 | rect.top = rect.top + element.clientTop; |
| 2728 | rect.left = rect.left + element.clientLeft; |
| 2729 | rect.bottom = rect.top + element.clientHeight; |
| 2730 | rect.right = rect.left + element.clientWidth; |
| 2731 | rect.width = element.clientWidth; |
| 2732 | rect.height = element.clientHeight; |
| 2733 | rect.x = rect.left; |
| 2734 | rect.y = rect.top; |
| 2735 | return rect; |
| 2736 | } |
| 2737 | |
| 2738 | function getClientRectFromMixedType(element, clippingParent) { |
| 2739 | return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isHTMLElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element))); |
| 2740 | } // A "clipping parent" is an overflowable container with the characteristic of |
| 2741 | // clipping (or hiding) overflowing elements with a position different from |
| 2742 | // `initial` |
| 2743 | |
| 2744 | |
| 2745 | function getClippingParents(element) { |
| 2746 | var clippingParents = listScrollParents(getParentNode(element)); |
| 2747 | var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle$1(element).position) >= 0; |
| 2748 | var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element; |
| 2749 | |
| 2750 | if (!isElement(clipperElement)) { |
| 2751 | return []; |
| 2752 | } // $FlowFixMe[incompatible-return]: https://github.com/facebook/flow/issues/1414 |
| 2753 | |
| 2754 | |
| 2755 | return clippingParents.filter(function (clippingParent) { |
| 2756 | return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body'; |
| 2757 | }); |
| 2758 | } // Gets the maximum area that the element is visible in due to any number of |
| 2759 | // clipping parents |
| 2760 | |
| 2761 | |
| 2762 | function getClippingRect(element, boundary, rootBoundary) { |
| 2763 | var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary); |
| 2764 | var clippingParents = [].concat(mainClippingParents, [rootBoundary]); |
| 2765 | var firstClippingParent = clippingParents[0]; |
| 2766 | var clippingRect = clippingParents.reduce(function (accRect, clippingParent) { |
| 2767 | var rect = getClientRectFromMixedType(element, clippingParent); |
| 2768 | accRect.top = max(rect.top, accRect.top); |
| 2769 | accRect.right = min(rect.right, accRect.right); |
| 2770 | accRect.bottom = min(rect.bottom, accRect.bottom); |
| 2771 | accRect.left = max(rect.left, accRect.left); |
| 2772 | return accRect; |
| 2773 | }, getClientRectFromMixedType(element, firstClippingParent)); |
| 2774 | clippingRect.width = clippingRect.right - clippingRect.left; |
| 2775 | clippingRect.height = clippingRect.bottom - clippingRect.top; |
| 2776 | clippingRect.x = clippingRect.left; |
| 2777 | clippingRect.y = clippingRect.top; |
| 2778 | return clippingRect; |
| 2779 | } |
| 2780 | |
| 2781 | function computeOffsets(_ref) { |
| 2782 | var reference = _ref.reference, |
| 2783 | element = _ref.element, |
| 2784 | placement = _ref.placement; |
| 2785 | var basePlacement = placement ? getBasePlacement(placement) : null; |
| 2786 | var variation = placement ? getVariation(placement) : null; |
| 2787 | var commonX = reference.x + reference.width / 2 - element.width / 2; |
| 2788 | var commonY = reference.y + reference.height / 2 - element.height / 2; |
| 2789 | var offsets; |
| 2790 | |
| 2791 | switch (basePlacement) { |
| 2792 | case top: |
| 2793 | offsets = { |
| 2794 | x: commonX, |
| 2795 | y: reference.y - element.height |
| 2796 | }; |
| 2797 | break; |
| 2798 | |
| 2799 | case bottom: |
| 2800 | offsets = { |
| 2801 | x: commonX, |
| 2802 | y: reference.y + reference.height |
| 2803 | }; |
| 2804 | break; |
| 2805 | |
| 2806 | case right: |
| 2807 | offsets = { |
| 2808 | x: reference.x + reference.width, |
| 2809 | y: commonY |
| 2810 | }; |
| 2811 | break; |
| 2812 | |
| 2813 | case left: |
| 2814 | offsets = { |
| 2815 | x: reference.x - element.width, |
| 2816 | y: commonY |
| 2817 | }; |
| 2818 | break; |
| 2819 | |
| 2820 | default: |
| 2821 | offsets = { |
| 2822 | x: reference.x, |
| 2823 | y: reference.y |
| 2824 | }; |
| 2825 | } |
| 2826 | |
| 2827 | var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null; |
| 2828 | |
| 2829 | if (mainAxis != null) { |
| 2830 | var len = mainAxis === 'y' ? 'height' : 'width'; |
| 2831 | |
| 2832 | switch (variation) { |
| 2833 | case start: |
| 2834 | offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2); |
| 2835 | break; |
| 2836 | |
| 2837 | case end: |
| 2838 | offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2); |
| 2839 | break; |
| 2840 | } |
| 2841 | } |
| 2842 | |
| 2843 | return offsets; |
| 2844 | } |
| 2845 | |
| 2846 | function detectOverflow(state, options) { |
| 2847 | if (options === void 0) { |
| 2848 | options = {}; |
| 2849 | } |
| 2850 | |
| 2851 | var _options = options, |
| 2852 | _options$placement = _options.placement, |
| 2853 | placement = _options$placement === void 0 ? state.placement : _options$placement, |
| 2854 | _options$boundary = _options.boundary, |
| 2855 | boundary = _options$boundary === void 0 ? clippingParents : _options$boundary, |
| 2856 | _options$rootBoundary = _options.rootBoundary, |
| 2857 | rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary, |
| 2858 | _options$elementConte = _options.elementContext, |
| 2859 | elementContext = _options$elementConte === void 0 ? popper : _options$elementConte, |
| 2860 | _options$altBoundary = _options.altBoundary, |
| 2861 | altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary, |
| 2862 | _options$padding = _options.padding, |
| 2863 | padding = _options$padding === void 0 ? 0 : _options$padding; |
| 2864 | var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements)); |
| 2865 | var altContext = elementContext === popper ? reference : popper; |
| 2866 | var popperRect = state.rects.popper; |
| 2867 | var element = state.elements[altBoundary ? altContext : elementContext]; |
| 2868 | var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary); |
| 2869 | var referenceClientRect = getBoundingClientRect(state.elements.reference); |
| 2870 | var popperOffsets = computeOffsets({ |
| 2871 | reference: referenceClientRect, |
| 2872 | element: popperRect, |
| 2873 | strategy: 'absolute', |
| 2874 | placement: placement |
| 2875 | }); |
| 2876 | var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets)); |
| 2877 | var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect |
| 2878 | // 0 or negative = within the clipping rect |
| 2879 | |
| 2880 | var overflowOffsets = { |
| 2881 | top: clippingClientRect.top - elementClientRect.top + paddingObject.top, |
| 2882 | bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom, |
| 2883 | left: clippingClientRect.left - elementClientRect.left + paddingObject.left, |
| 2884 | right: elementClientRect.right - clippingClientRect.right + paddingObject.right |
| 2885 | }; |
| 2886 | var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element |
| 2887 | |
| 2888 | if (elementContext === popper && offsetData) { |
| 2889 | var offset = offsetData[placement]; |
| 2890 | Object.keys(overflowOffsets).forEach(function (key) { |
| 2891 | var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1; |
| 2892 | var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x'; |
| 2893 | overflowOffsets[key] += offset[axis] * multiply; |
| 2894 | }); |
| 2895 | } |
| 2896 | |
| 2897 | return overflowOffsets; |
| 2898 | } |
| 2899 | |
| 2900 | function computeAutoPlacement(state, options) { |
| 2901 | if (options === void 0) { |
| 2902 | options = {}; |
| 2903 | } |
| 2904 | |
| 2905 | var _options = options, |
| 2906 | placement = _options.placement, |
| 2907 | boundary = _options.boundary, |
| 2908 | rootBoundary = _options.rootBoundary, |
| 2909 | padding = _options.padding, |
| 2910 | flipVariations = _options.flipVariations, |
| 2911 | _options$allowedAutoP = _options.allowedAutoPlacements, |
| 2912 | allowedAutoPlacements = _options$allowedAutoP === void 0 ? placements : _options$allowedAutoP; |
| 2913 | var variation = getVariation(placement); |
| 2914 | var placements$1 = variation ? flipVariations ? variationPlacements : variationPlacements.filter(function (placement) { |
| 2915 | return getVariation(placement) === variation; |
| 2916 | }) : basePlacements; |
| 2917 | var allowedPlacements = placements$1.filter(function (placement) { |
| 2918 | return allowedAutoPlacements.indexOf(placement) >= 0; |
| 2919 | }); |
| 2920 | |
| 2921 | if (allowedPlacements.length === 0) { |
| 2922 | allowedPlacements = placements$1; |
| 2923 | } // $FlowFixMe[incompatible-type]: Flow seems to have problems with two array unions... |
| 2924 | |
| 2925 | |
| 2926 | var overflows = allowedPlacements.reduce(function (acc, placement) { |
| 2927 | acc[placement] = detectOverflow(state, { |
| 2928 | placement: placement, |
| 2929 | boundary: boundary, |
| 2930 | rootBoundary: rootBoundary, |
| 2931 | padding: padding |
| 2932 | })[getBasePlacement(placement)]; |
| 2933 | return acc; |
| 2934 | }, {}); |
| 2935 | return Object.keys(overflows).sort(function (a, b) { |
| 2936 | return overflows[a] - overflows[b]; |
| 2937 | }); |
| 2938 | } |
| 2939 | |
| 2940 | function getExpandedFallbackPlacements(placement) { |
| 2941 | if (getBasePlacement(placement) === auto) { |
| 2942 | return []; |
| 2943 | } |
| 2944 | |
| 2945 | var oppositePlacement = getOppositePlacement(placement); |
| 2946 | return [getOppositeVariationPlacement(placement), oppositePlacement, getOppositeVariationPlacement(oppositePlacement)]; |
| 2947 | } |
| 2948 | |
| 2949 | function flip(_ref) { |
| 2950 | var state = _ref.state, |
| 2951 | options = _ref.options, |
| 2952 | name = _ref.name; |
| 2953 | |
| 2954 | if (state.modifiersData[name]._skip) { |
| 2955 | return; |
| 2956 | } |
| 2957 | |
| 2958 | var _options$mainAxis = options.mainAxis, |
| 2959 | checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis, |
| 2960 | _options$altAxis = options.altAxis, |
| 2961 | checkAltAxis = _options$altAxis === void 0 ? true : _options$altAxis, |
| 2962 | specifiedFallbackPlacements = options.fallbackPlacements, |
| 2963 | padding = options.padding, |
| 2964 | boundary = options.boundary, |
| 2965 | rootBoundary = options.rootBoundary, |
| 2966 | altBoundary = options.altBoundary, |
| 2967 | _options$flipVariatio = options.flipVariations, |
| 2968 | flipVariations = _options$flipVariatio === void 0 ? true : _options$flipVariatio, |
| 2969 | allowedAutoPlacements = options.allowedAutoPlacements; |
| 2970 | var preferredPlacement = state.options.placement; |
| 2971 | var basePlacement = getBasePlacement(preferredPlacement); |
| 2972 | var isBasePlacement = basePlacement === preferredPlacement; |
| 2973 | var fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipVariations ? [getOppositePlacement(preferredPlacement)] : getExpandedFallbackPlacements(preferredPlacement)); |
| 2974 | var placements = [preferredPlacement].concat(fallbackPlacements).reduce(function (acc, placement) { |
| 2975 | return acc.concat(getBasePlacement(placement) === auto ? computeAutoPlacement(state, { |
| 2976 | placement: placement, |
| 2977 | boundary: boundary, |
| 2978 | rootBoundary: rootBoundary, |
| 2979 | padding: padding, |
| 2980 | flipVariations: flipVariations, |
| 2981 | allowedAutoPlacements: allowedAutoPlacements |
| 2982 | }) : placement); |
| 2983 | }, []); |
| 2984 | var referenceRect = state.rects.reference; |
| 2985 | var popperRect = state.rects.popper; |
| 2986 | var checksMap = new Map(); |
| 2987 | var makeFallbackChecks = true; |
| 2988 | var firstFittingPlacement = placements[0]; |
| 2989 | |
| 2990 | for (var i = 0; i < placements.length; i++) { |
| 2991 | var placement = placements[i]; |
| 2992 | |
| 2993 | var _basePlacement = getBasePlacement(placement); |
| 2994 | |
| 2995 | var isStartVariation = getVariation(placement) === start; |
| 2996 | var isVertical = [top, bottom].indexOf(_basePlacement) >= 0; |
| 2997 | var len = isVertical ? 'width' : 'height'; |
| 2998 | var overflow = detectOverflow(state, { |
| 2999 | placement: placement, |
| 3000 | boundary: boundary, |
| 3001 | rootBoundary: rootBoundary, |
| 3002 | altBoundary: altBoundary, |
| 3003 | padding: padding |
| 3004 | }); |
| 3005 | var mainVariationSide = isVertical ? isStartVariation ? right : left : isStartVariation ? bottom : top; |
| 3006 | |
| 3007 | if (referenceRect[len] > popperRect[len]) { |
| 3008 | mainVariationSide = getOppositePlacement(mainVariationSide); |
| 3009 | } |
| 3010 | |
| 3011 | var altVariationSide = getOppositePlacement(mainVariationSide); |
| 3012 | var checks = []; |
| 3013 | |
| 3014 | if (checkMainAxis) { |
| 3015 | checks.push(overflow[_basePlacement] <= 0); |
| 3016 | } |
| 3017 | |
| 3018 | if (checkAltAxis) { |
| 3019 | checks.push(overflow[mainVariationSide] <= 0, overflow[altVariationSide] <= 0); |
| 3020 | } |
| 3021 | |
| 3022 | if (checks.every(function (check) { |
| 3023 | return check; |
| 3024 | })) { |
| 3025 | firstFittingPlacement = placement; |
| 3026 | makeFallbackChecks = false; |
| 3027 | break; |
| 3028 | } |
| 3029 | |
| 3030 | checksMap.set(placement, checks); |
| 3031 | } |
| 3032 | |
| 3033 | if (makeFallbackChecks) { |
| 3034 | // `2` may be desired in some cases – research later |
| 3035 | var numberOfChecks = flipVariations ? 3 : 1; |
| 3036 | |
| 3037 | var _loop = function _loop(_i) { |
| 3038 | var fittingPlacement = placements.find(function (placement) { |
| 3039 | var checks = checksMap.get(placement); |
| 3040 | |
| 3041 | if (checks) { |
| 3042 | return checks.slice(0, _i).every(function (check) { |
| 3043 | return check; |
| 3044 | }); |
| 3045 | } |
| 3046 | }); |
| 3047 | |
| 3048 | if (fittingPlacement) { |
| 3049 | firstFittingPlacement = fittingPlacement; |
| 3050 | return "break"; |
| 3051 | } |
| 3052 | }; |
| 3053 | |
| 3054 | for (var _i = numberOfChecks; _i > 0; _i--) { |
| 3055 | var _ret = _loop(_i); |
| 3056 | |
| 3057 | if (_ret === "break") break; |
| 3058 | } |
| 3059 | } |
| 3060 | |
| 3061 | if (state.placement !== firstFittingPlacement) { |
| 3062 | state.modifiersData[name]._skip = true; |
| 3063 | state.placement = firstFittingPlacement; |
| 3064 | state.reset = true; |
| 3065 | } |
| 3066 | } // eslint-disable-next-line import/no-unused-modules |
| 3067 | |
| 3068 | |
| 3069 | const flip$1 = { |
| 3070 | name: 'flip', |
| 3071 | enabled: true, |
| 3072 | phase: 'main', |
| 3073 | fn: flip, |
| 3074 | requiresIfExists: ['offset'], |
| 3075 | data: { |
| 3076 | _skip: false |
| 3077 | } |
| 3078 | }; |
| 3079 | |
| 3080 | function getSideOffsets(overflow, rect, preventedOffsets) { |
| 3081 | if (preventedOffsets === void 0) { |
| 3082 | preventedOffsets = { |
| 3083 | x: 0, |
| 3084 | y: 0 |
| 3085 | }; |
| 3086 | } |
| 3087 | |
| 3088 | return { |
| 3089 | top: overflow.top - rect.height - preventedOffsets.y, |
| 3090 | right: overflow.right - rect.width + preventedOffsets.x, |
| 3091 | bottom: overflow.bottom - rect.height + preventedOffsets.y, |
| 3092 | left: overflow.left - rect.width - preventedOffsets.x |
| 3093 | }; |
| 3094 | } |
| 3095 | |
| 3096 | function isAnySideFullyClipped(overflow) { |
| 3097 | return [top, right, bottom, left].some(function (side) { |
| 3098 | return overflow[side] >= 0; |
| 3099 | }); |
| 3100 | } |
| 3101 | |
| 3102 | function hide(_ref) { |
| 3103 | var state = _ref.state, |
| 3104 | name = _ref.name; |
| 3105 | var referenceRect = state.rects.reference; |
| 3106 | var popperRect = state.rects.popper; |
| 3107 | var preventedOffsets = state.modifiersData.preventOverflow; |
| 3108 | var referenceOverflow = detectOverflow(state, { |
| 3109 | elementContext: 'reference' |
| 3110 | }); |
| 3111 | var popperAltOverflow = detectOverflow(state, { |
| 3112 | altBoundary: true |
| 3113 | }); |
| 3114 | var referenceClippingOffsets = getSideOffsets(referenceOverflow, referenceRect); |
| 3115 | var popperEscapeOffsets = getSideOffsets(popperAltOverflow, popperRect, preventedOffsets); |
| 3116 | var isReferenceHidden = isAnySideFullyClipped(referenceClippingOffsets); |
| 3117 | var hasPopperEscaped = isAnySideFullyClipped(popperEscapeOffsets); |
| 3118 | state.modifiersData[name] = { |
| 3119 | referenceClippingOffsets: referenceClippingOffsets, |
| 3120 | popperEscapeOffsets: popperEscapeOffsets, |
| 3121 | isReferenceHidden: isReferenceHidden, |
| 3122 | hasPopperEscaped: hasPopperEscaped |
| 3123 | }; |
| 3124 | state.attributes.popper = Object.assign({}, state.attributes.popper, { |
| 3125 | 'data-popper-reference-hidden': isReferenceHidden, |
| 3126 | 'data-popper-escaped': hasPopperEscaped |
| 3127 | }); |
| 3128 | } // eslint-disable-next-line import/no-unused-modules |
| 3129 | |
| 3130 | |
| 3131 | const hide$1 = { |
| 3132 | name: 'hide', |
| 3133 | enabled: true, |
| 3134 | phase: 'main', |
| 3135 | requiresIfExists: ['preventOverflow'], |
| 3136 | fn: hide |
| 3137 | }; |
| 3138 | |
| 3139 | function distanceAndSkiddingToXY(placement, rects, offset) { |
| 3140 | var basePlacement = getBasePlacement(placement); |
| 3141 | var invertDistance = [left, top].indexOf(basePlacement) >= 0 ? -1 : 1; |
| 3142 | |
| 3143 | var _ref = typeof offset === 'function' ? offset(Object.assign({}, rects, { |
| 3144 | placement: placement |
| 3145 | })) : offset, |
| 3146 | skidding = _ref[0], |
| 3147 | distance = _ref[1]; |
| 3148 | |
| 3149 | skidding = skidding || 0; |
| 3150 | distance = (distance || 0) * invertDistance; |
| 3151 | return [left, right].indexOf(basePlacement) >= 0 ? { |
| 3152 | x: distance, |
| 3153 | y: skidding |
| 3154 | } : { |
| 3155 | x: skidding, |
| 3156 | y: distance |
| 3157 | }; |
| 3158 | } |
| 3159 | |
| 3160 | function offset(_ref2) { |
| 3161 | var state = _ref2.state, |
| 3162 | options = _ref2.options, |
| 3163 | name = _ref2.name; |
| 3164 | var _options$offset = options.offset, |
| 3165 | offset = _options$offset === void 0 ? [0, 0] : _options$offset; |
| 3166 | var data = placements.reduce(function (acc, placement) { |
| 3167 | acc[placement] = distanceAndSkiddingToXY(placement, state.rects, offset); |
| 3168 | return acc; |
| 3169 | }, {}); |
| 3170 | var _data$state$placement = data[state.placement], |
| 3171 | x = _data$state$placement.x, |
| 3172 | y = _data$state$placement.y; |
| 3173 | |
| 3174 | if (state.modifiersData.popperOffsets != null) { |
| 3175 | state.modifiersData.popperOffsets.x += x; |
| 3176 | state.modifiersData.popperOffsets.y += y; |
| 3177 | } |
| 3178 | |
| 3179 | state.modifiersData[name] = data; |
| 3180 | } // eslint-disable-next-line import/no-unused-modules |
| 3181 | |
| 3182 | |
| 3183 | const offset$1 = { |
| 3184 | name: 'offset', |
| 3185 | enabled: true, |
| 3186 | phase: 'main', |
| 3187 | requires: ['popperOffsets'], |
| 3188 | fn: offset |
| 3189 | }; |
| 3190 | |
| 3191 | function popperOffsets(_ref) { |
| 3192 | var state = _ref.state, |
| 3193 | name = _ref.name; |
| 3194 | // Offsets are the actual position the popper needs to have to be |
| 3195 | // properly positioned near its reference element |
| 3196 | // This is the most basic placement, and will be adjusted by |
| 3197 | // the modifiers in the next step |
| 3198 | state.modifiersData[name] = computeOffsets({ |
| 3199 | reference: state.rects.reference, |
| 3200 | element: state.rects.popper, |
| 3201 | strategy: 'absolute', |
| 3202 | placement: state.placement |
| 3203 | }); |
| 3204 | } // eslint-disable-next-line import/no-unused-modules |
| 3205 | |
| 3206 | |
| 3207 | const popperOffsets$1 = { |
| 3208 | name: 'popperOffsets', |
| 3209 | enabled: true, |
| 3210 | phase: 'read', |
| 3211 | fn: popperOffsets, |
| 3212 | data: {} |
| 3213 | }; |
| 3214 | |
| 3215 | function getAltAxis(axis) { |
| 3216 | return axis === 'x' ? 'y' : 'x'; |
| 3217 | } |
| 3218 | |
| 3219 | function preventOverflow(_ref) { |
| 3220 | var state = _ref.state, |
| 3221 | options = _ref.options, |
| 3222 | name = _ref.name; |
| 3223 | var _options$mainAxis = options.mainAxis, |
| 3224 | checkMainAxis = _options$mainAxis === void 0 ? true : _options$mainAxis, |
| 3225 | _options$altAxis = options.altAxis, |
| 3226 | checkAltAxis = _options$altAxis === void 0 ? false : _options$altAxis, |
| 3227 | boundary = options.boundary, |
| 3228 | rootBoundary = options.rootBoundary, |
| 3229 | altBoundary = options.altBoundary, |
| 3230 | padding = options.padding, |
| 3231 | _options$tether = options.tether, |
| 3232 | tether = _options$tether === void 0 ? true : _options$tether, |
| 3233 | _options$tetherOffset = options.tetherOffset, |
| 3234 | tetherOffset = _options$tetherOffset === void 0 ? 0 : _options$tetherOffset; |
| 3235 | var overflow = detectOverflow(state, { |
| 3236 | boundary: boundary, |
| 3237 | rootBoundary: rootBoundary, |
| 3238 | padding: padding, |
| 3239 | altBoundary: altBoundary |
| 3240 | }); |
| 3241 | var basePlacement = getBasePlacement(state.placement); |
| 3242 | var variation = getVariation(state.placement); |
| 3243 | var isBasePlacement = !variation; |
| 3244 | var mainAxis = getMainAxisFromPlacement(basePlacement); |
| 3245 | var altAxis = getAltAxis(mainAxis); |
| 3246 | var popperOffsets = state.modifiersData.popperOffsets; |
| 3247 | var referenceRect = state.rects.reference; |
| 3248 | var popperRect = state.rects.popper; |
| 3249 | var tetherOffsetValue = typeof tetherOffset === 'function' ? tetherOffset(Object.assign({}, state.rects, { |
| 3250 | placement: state.placement |
| 3251 | })) : tetherOffset; |
| 3252 | var data = { |
| 3253 | x: 0, |
| 3254 | y: 0 |
| 3255 | }; |
| 3256 | |
| 3257 | if (!popperOffsets) { |
| 3258 | return; |
| 3259 | } |
| 3260 | |
| 3261 | if (checkMainAxis || checkAltAxis) { |
| 3262 | var mainSide = mainAxis === 'y' ? top : left; |
| 3263 | var altSide = mainAxis === 'y' ? bottom : right; |
| 3264 | var len = mainAxis === 'y' ? 'height' : 'width'; |
| 3265 | var offset = popperOffsets[mainAxis]; |
| 3266 | var min$1 = popperOffsets[mainAxis] + overflow[mainSide]; |
| 3267 | var max$1 = popperOffsets[mainAxis] - overflow[altSide]; |
| 3268 | var additive = tether ? -popperRect[len] / 2 : 0; |
| 3269 | var minLen = variation === start ? referenceRect[len] : popperRect[len]; |
| 3270 | var maxLen = variation === start ? -popperRect[len] : -referenceRect[len]; // We need to include the arrow in the calculation so the arrow doesn't go |
| 3271 | // outside the reference bounds |
| 3272 | |
| 3273 | var arrowElement = state.elements.arrow; |
| 3274 | var arrowRect = tether && arrowElement ? getLayoutRect(arrowElement) : { |
| 3275 | width: 0, |
| 3276 | height: 0 |
| 3277 | }; |
| 3278 | var arrowPaddingObject = state.modifiersData['arrow#persistent'] ? state.modifiersData['arrow#persistent'].padding : getFreshSideObject(); |
| 3279 | var arrowPaddingMin = arrowPaddingObject[mainSide]; |
| 3280 | var arrowPaddingMax = arrowPaddingObject[altSide]; // If the reference length is smaller than the arrow length, we don't want |
| 3281 | // to include its full size in the calculation. If the reference is small |
| 3282 | // and near the edge of a boundary, the popper can overflow even if the |
| 3283 | // reference is not overflowing as well (e.g. virtual elements with no |
| 3284 | // width or height) |
| 3285 | |
| 3286 | var arrowLen = within(0, referenceRect[len], arrowRect[len]); |
| 3287 | var minOffset = isBasePlacement ? referenceRect[len] / 2 - additive - arrowLen - arrowPaddingMin - tetherOffsetValue : minLen - arrowLen - arrowPaddingMin - tetherOffsetValue; |
| 3288 | var maxOffset = isBasePlacement ? -referenceRect[len] / 2 + additive + arrowLen + arrowPaddingMax + tetherOffsetValue : maxLen + arrowLen + arrowPaddingMax + tetherOffsetValue; |
| 3289 | var arrowOffsetParent = state.elements.arrow && getOffsetParent(state.elements.arrow); |
| 3290 | var clientOffset = arrowOffsetParent ? mainAxis === 'y' ? arrowOffsetParent.clientTop || 0 : arrowOffsetParent.clientLeft || 0 : 0; |
| 3291 | var offsetModifierValue = state.modifiersData.offset ? state.modifiersData.offset[state.placement][mainAxis] : 0; |
| 3292 | var tetherMin = popperOffsets[mainAxis] + minOffset - offsetModifierValue - clientOffset; |
| 3293 | var tetherMax = popperOffsets[mainAxis] + maxOffset - offsetModifierValue; |
| 3294 | |
| 3295 | if (checkMainAxis) { |
| 3296 | var preventedOffset = within(tether ? min(min$1, tetherMin) : min$1, offset, tether ? max(max$1, tetherMax) : max$1); |
| 3297 | popperOffsets[mainAxis] = preventedOffset; |
| 3298 | data[mainAxis] = preventedOffset - offset; |
| 3299 | } |
| 3300 | |
| 3301 | if (checkAltAxis) { |
| 3302 | var _mainSide = mainAxis === 'x' ? top : left; |
| 3303 | |
| 3304 | var _altSide = mainAxis === 'x' ? bottom : right; |
| 3305 | |
| 3306 | var _offset = popperOffsets[altAxis]; |
| 3307 | |
| 3308 | var _min = _offset + overflow[_mainSide]; |
| 3309 | |
| 3310 | var _max = _offset - overflow[_altSide]; |
| 3311 | |
| 3312 | var _preventedOffset = within(tether ? min(_min, tetherMin) : _min, _offset, tether ? max(_max, tetherMax) : _max); |
| 3313 | |
| 3314 | popperOffsets[altAxis] = _preventedOffset; |
| 3315 | data[altAxis] = _preventedOffset - _offset; |
| 3316 | } |
| 3317 | } |
| 3318 | |
| 3319 | state.modifiersData[name] = data; |
| 3320 | } // eslint-disable-next-line import/no-unused-modules |
| 3321 | |
| 3322 | |
| 3323 | const preventOverflow$1 = { |
| 3324 | name: 'preventOverflow', |
| 3325 | enabled: true, |
| 3326 | phase: 'main', |
| 3327 | fn: preventOverflow, |
| 3328 | requiresIfExists: ['offset'] |
| 3329 | }; |
| 3330 | |
| 3331 | function getHTMLElementScroll(element) { |
| 3332 | return { |
| 3333 | scrollLeft: element.scrollLeft, |
| 3334 | scrollTop: element.scrollTop |
| 3335 | }; |
| 3336 | } |
| 3337 | |
| 3338 | function getNodeScroll(node) { |
| 3339 | if (node === getWindow(node) || !isHTMLElement(node)) { |
| 3340 | return getWindowScroll(node); |
| 3341 | } else { |
| 3342 | return getHTMLElementScroll(node); |
| 3343 | } |
| 3344 | } |
| 3345 | |
| 3346 | function isElementScaled(element) { |
| 3347 | var rect = element.getBoundingClientRect(); |
| 3348 | var scaleX = rect.width / element.offsetWidth || 1; |
| 3349 | var scaleY = rect.height / element.offsetHeight || 1; |
| 3350 | return scaleX !== 1 || scaleY !== 1; |
| 3351 | } // Returns the composite rect of an element relative to its offsetParent. |
| 3352 | // Composite means it takes into account transforms as well as layout. |
| 3353 | |
| 3354 | |
| 3355 | function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) { |
| 3356 | if (isFixed === void 0) { |
| 3357 | isFixed = false; |
| 3358 | } |
| 3359 | |
| 3360 | var isOffsetParentAnElement = isHTMLElement(offsetParent); |
| 3361 | isHTMLElement(offsetParent) && isElementScaled(offsetParent); |
| 3362 | var documentElement = getDocumentElement(offsetParent); |
| 3363 | var rect = getBoundingClientRect(elementOrVirtualElement); |
| 3364 | var scroll = { |
| 3365 | scrollLeft: 0, |
| 3366 | scrollTop: 0 |
| 3367 | }; |
| 3368 | var offsets = { |
| 3369 | x: 0, |
| 3370 | y: 0 |
| 3371 | }; |
| 3372 | |
| 3373 | if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) { |
| 3374 | if (getNodeName(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078 |
| 3375 | isScrollParent(documentElement)) { |
| 3376 | scroll = getNodeScroll(offsetParent); |
| 3377 | } |
| 3378 | |
| 3379 | if (isHTMLElement(offsetParent)) { |
| 3380 | offsets = getBoundingClientRect(offsetParent); |
| 3381 | offsets.x += offsetParent.clientLeft; |
| 3382 | offsets.y += offsetParent.clientTop; |
| 3383 | } else if (documentElement) { |
| 3384 | offsets.x = getWindowScrollBarX(documentElement); |
| 3385 | } |
| 3386 | } |
| 3387 | |
| 3388 | return { |
| 3389 | x: rect.left + scroll.scrollLeft - offsets.x, |
| 3390 | y: rect.top + scroll.scrollTop - offsets.y, |
| 3391 | width: rect.width, |
| 3392 | height: rect.height |
| 3393 | }; |
| 3394 | } |
| 3395 | |
| 3396 | function order(modifiers) { |
| 3397 | var map = new Map(); |
| 3398 | var visited = new Set(); |
| 3399 | var result = []; |
| 3400 | modifiers.forEach(function (modifier) { |
| 3401 | map.set(modifier.name, modifier); |
| 3402 | }); // On visiting object, check for its dependencies and visit them recursively |
| 3403 | |
| 3404 | function sort(modifier) { |
| 3405 | visited.add(modifier.name); |
| 3406 | var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []); |
| 3407 | requires.forEach(function (dep) { |
| 3408 | if (!visited.has(dep)) { |
| 3409 | var depModifier = map.get(dep); |
| 3410 | |
| 3411 | if (depModifier) { |
| 3412 | sort(depModifier); |
| 3413 | } |
| 3414 | } |
| 3415 | }); |
| 3416 | result.push(modifier); |
| 3417 | } |
| 3418 | |
| 3419 | modifiers.forEach(function (modifier) { |
| 3420 | if (!visited.has(modifier.name)) { |
| 3421 | // check for visited object |
| 3422 | sort(modifier); |
| 3423 | } |
| 3424 | }); |
| 3425 | return result; |
| 3426 | } |
| 3427 | |
| 3428 | function orderModifiers(modifiers) { |
| 3429 | // order based on dependencies |
| 3430 | var orderedModifiers = order(modifiers); // order based on phase |
| 3431 | |
| 3432 | return modifierPhases.reduce(function (acc, phase) { |
| 3433 | return acc.concat(orderedModifiers.filter(function (modifier) { |
| 3434 | return modifier.phase === phase; |
| 3435 | })); |
| 3436 | }, []); |
| 3437 | } |
| 3438 | |
| 3439 | function debounce(fn) { |
| 3440 | var pending; |
| 3441 | return function () { |
| 3442 | if (!pending) { |
| 3443 | pending = new Promise(function (resolve) { |
| 3444 | Promise.resolve().then(function () { |
| 3445 | pending = undefined; |
| 3446 | resolve(fn()); |
| 3447 | }); |
| 3448 | }); |
| 3449 | } |
| 3450 | |
| 3451 | return pending; |
| 3452 | }; |
| 3453 | } |
| 3454 | |
| 3455 | function mergeByName(modifiers) { |
| 3456 | var merged = modifiers.reduce(function (merged, current) { |
| 3457 | var existing = merged[current.name]; |
| 3458 | merged[current.name] = existing ? Object.assign({}, existing, current, { |
| 3459 | options: Object.assign({}, existing.options, current.options), |
| 3460 | data: Object.assign({}, existing.data, current.data) |
| 3461 | }) : current; |
| 3462 | return merged; |
| 3463 | }, {}); // IE11 does not support Object.values |
| 3464 | |
| 3465 | return Object.keys(merged).map(function (key) { |
| 3466 | return merged[key]; |
| 3467 | }); |
| 3468 | } |
| 3469 | |
| 3470 | var DEFAULT_OPTIONS = { |
| 3471 | placement: 'bottom', |
| 3472 | modifiers: [], |
| 3473 | strategy: 'absolute' |
| 3474 | }; |
| 3475 | |
| 3476 | function areValidElements() { |
| 3477 | for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { |
| 3478 | args[_key] = arguments[_key]; |
| 3479 | } |
| 3480 | |
| 3481 | return !args.some(function (element) { |
| 3482 | return !(element && typeof element.getBoundingClientRect === 'function'); |
| 3483 | }); |
| 3484 | } |
| 3485 | |
| 3486 | function popperGenerator(generatorOptions) { |
| 3487 | if (generatorOptions === void 0) { |
| 3488 | generatorOptions = {}; |
| 3489 | } |
| 3490 | |
| 3491 | var _generatorOptions = generatorOptions, |
| 3492 | _generatorOptions$def = _generatorOptions.defaultModifiers, |
| 3493 | defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def, |
| 3494 | _generatorOptions$def2 = _generatorOptions.defaultOptions, |
| 3495 | defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2; |
| 3496 | return function createPopper(reference, popper, options) { |
| 3497 | if (options === void 0) { |
| 3498 | options = defaultOptions; |
| 3499 | } |
| 3500 | |
| 3501 | var state = { |
| 3502 | placement: 'bottom', |
| 3503 | orderedModifiers: [], |
| 3504 | options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions), |
| 3505 | modifiersData: {}, |
| 3506 | elements: { |
| 3507 | reference: reference, |
| 3508 | popper: popper |
| 3509 | }, |
| 3510 | attributes: {}, |
| 3511 | styles: {} |
| 3512 | }; |
| 3513 | var effectCleanupFns = []; |
| 3514 | var isDestroyed = false; |
| 3515 | var instance = { |
| 3516 | state: state, |
| 3517 | setOptions: function setOptions(setOptionsAction) { |
| 3518 | var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction; |
| 3519 | cleanupModifierEffects(); |
| 3520 | state.options = Object.assign({}, defaultOptions, state.options, options); |
| 3521 | state.scrollParents = { |
| 3522 | reference: isElement(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [], |
| 3523 | popper: listScrollParents(popper) |
| 3524 | }; // Orders the modifiers based on their dependencies and `phase` |
| 3525 | // properties |
| 3526 | |
| 3527 | var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers))); // Strip out disabled modifiers |
| 3528 | |
| 3529 | state.orderedModifiers = orderedModifiers.filter(function (m) { |
| 3530 | return m.enabled; |
| 3531 | }); // Validate the provided modifiers so that the consumer will get warned |
| 3532 | |
| 3533 | runModifierEffects(); |
| 3534 | return instance.update(); |
| 3535 | }, |
| 3536 | // Sync update – it will always be executed, even if not necessary. This |
| 3537 | // is useful for low frequency updates where sync behavior simplifies the |
| 3538 | // logic. |
| 3539 | // For high frequency updates (e.g. `resize` and `scroll` events), always |
| 3540 | // prefer the async Popper#update method |
| 3541 | forceUpdate: function forceUpdate() { |
| 3542 | if (isDestroyed) { |
| 3543 | return; |
| 3544 | } |
| 3545 | |
| 3546 | var _state$elements = state.elements, |
| 3547 | reference = _state$elements.reference, |
| 3548 | popper = _state$elements.popper; // Don't proceed if `reference` or `popper` are not valid elements |
| 3549 | // anymore |
| 3550 | |
| 3551 | if (!areValidElements(reference, popper)) { |
| 3552 | |
| 3553 | return; |
| 3554 | } // Store the reference and popper rects to be read by modifiers |
| 3555 | |
| 3556 | |
| 3557 | state.rects = { |
| 3558 | reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'), |
| 3559 | popper: getLayoutRect(popper) |
| 3560 | }; // Modifiers have the ability to reset the current update cycle. The |
| 3561 | // most common use case for this is the `flip` modifier changing the |
| 3562 | // placement, which then needs to re-run all the modifiers, because the |
| 3563 | // logic was previously ran for the previous placement and is therefore |
| 3564 | // stale/incorrect |
| 3565 | |
| 3566 | state.reset = false; |
| 3567 | state.placement = state.options.placement; // On each update cycle, the `modifiersData` property for each modifier |
| 3568 | // is filled with the initial data specified by the modifier. This means |
| 3569 | // it doesn't persist and is fresh on each update. |
| 3570 | // To ensure persistent data, use `${name}#persistent` |
| 3571 | |
| 3572 | state.orderedModifiers.forEach(function (modifier) { |
| 3573 | return state.modifiersData[modifier.name] = Object.assign({}, modifier.data); |
| 3574 | }); |
| 3575 | |
| 3576 | for (var index = 0; index < state.orderedModifiers.length; index++) { |
| 3577 | |
| 3578 | if (state.reset === true) { |
| 3579 | state.reset = false; |
| 3580 | index = -1; |
| 3581 | continue; |
| 3582 | } |
| 3583 | |
| 3584 | var _state$orderedModifie = state.orderedModifiers[index], |
| 3585 | fn = _state$orderedModifie.fn, |
| 3586 | _state$orderedModifie2 = _state$orderedModifie.options, |
| 3587 | _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2, |
| 3588 | name = _state$orderedModifie.name; |
| 3589 | |
| 3590 | if (typeof fn === 'function') { |
| 3591 | state = fn({ |
| 3592 | state: state, |
| 3593 | options: _options, |
| 3594 | name: name, |
| 3595 | instance: instance |
| 3596 | }) || state; |
| 3597 | } |
| 3598 | } |
| 3599 | }, |
| 3600 | // Async and optimistically optimized update – it will not be executed if |
| 3601 | // not necessary (debounced to run at most once-per-tick) |
| 3602 | update: debounce(function () { |
| 3603 | return new Promise(function (resolve) { |
| 3604 | instance.forceUpdate(); |
| 3605 | resolve(state); |
| 3606 | }); |
| 3607 | }), |
| 3608 | destroy: function destroy() { |
| 3609 | cleanupModifierEffects(); |
| 3610 | isDestroyed = true; |
| 3611 | } |
| 3612 | }; |
| 3613 | |
| 3614 | if (!areValidElements(reference, popper)) { |
| 3615 | |
| 3616 | return instance; |
| 3617 | } |
| 3618 | |
| 3619 | instance.setOptions(options).then(function (state) { |
| 3620 | if (!isDestroyed && options.onFirstUpdate) { |
| 3621 | options.onFirstUpdate(state); |
| 3622 | } |
| 3623 | }); // Modifiers have the ability to execute arbitrary code before the first |
| 3624 | // update cycle runs. They will be executed in the same order as the update |
| 3625 | // cycle. This is useful when a modifier adds some persistent data that |
| 3626 | // other modifiers need to use, but the modifier is run after the dependent |
| 3627 | // one. |
| 3628 | |
| 3629 | function runModifierEffects() { |
| 3630 | state.orderedModifiers.forEach(function (_ref3) { |
| 3631 | var name = _ref3.name, |
| 3632 | _ref3$options = _ref3.options, |
| 3633 | options = _ref3$options === void 0 ? {} : _ref3$options, |
| 3634 | effect = _ref3.effect; |
| 3635 | |
| 3636 | if (typeof effect === 'function') { |
| 3637 | var cleanupFn = effect({ |
| 3638 | state: state, |
| 3639 | name: name, |
| 3640 | instance: instance, |
| 3641 | options: options |
| 3642 | }); |
| 3643 | |
| 3644 | var noopFn = function noopFn() {}; |
| 3645 | |
| 3646 | effectCleanupFns.push(cleanupFn || noopFn); |
| 3647 | } |
| 3648 | }); |
| 3649 | } |
| 3650 | |
| 3651 | function cleanupModifierEffects() { |
| 3652 | effectCleanupFns.forEach(function (fn) { |
| 3653 | return fn(); |
| 3654 | }); |
| 3655 | effectCleanupFns = []; |
| 3656 | } |
| 3657 | |
| 3658 | return instance; |
| 3659 | }; |
| 3660 | } |
| 3661 | var createPopper$2 = /*#__PURE__*/popperGenerator(); // eslint-disable-next-line import/no-unused-modules |
| 3662 | |
| 3663 | var defaultModifiers$1 = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1]; |
| 3664 | var createPopper$1 = /*#__PURE__*/popperGenerator({ |
| 3665 | defaultModifiers: defaultModifiers$1 |
| 3666 | }); // eslint-disable-next-line import/no-unused-modules |
| 3667 | |
| 3668 | var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1, offset$1, flip$1, preventOverflow$1, arrow$1, hide$1]; |
| 3669 | var createPopper = /*#__PURE__*/popperGenerator({ |
| 3670 | defaultModifiers: defaultModifiers |
| 3671 | }); // eslint-disable-next-line import/no-unused-modules |
| 3672 | |
| 3673 | const Popper = /*#__PURE__*/Object.freeze({ |
| 3674 | __proto__: null, |
| 3675 | popperGenerator, |
| 3676 | detectOverflow, |
| 3677 | createPopperBase: createPopper$2, |
| 3678 | createPopper, |
| 3679 | createPopperLite: createPopper$1, |
| 3680 | top, |
| 3681 | bottom, |
| 3682 | right, |
| 3683 | left, |
| 3684 | auto, |
| 3685 | basePlacements, |
| 3686 | start, |
| 3687 | end, |
| 3688 | clippingParents, |
| 3689 | viewport, |
| 3690 | popper, |
| 3691 | reference, |
| 3692 | variationPlacements, |
| 3693 | placements, |
| 3694 | beforeRead, |
| 3695 | read, |
| 3696 | afterRead, |
| 3697 | beforeMain, |
| 3698 | main, |
| 3699 | afterMain, |
| 3700 | beforeWrite, |
| 3701 | write, |
| 3702 | afterWrite, |
| 3703 | modifierPhases, |
| 3704 | applyStyles: applyStyles$1, |
| 3705 | arrow: arrow$1, |
| 3706 | computeStyles: computeStyles$1, |
| 3707 | eventListeners, |
| 3708 | flip: flip$1, |
| 3709 | hide: hide$1, |
| 3710 | offset: offset$1, |
| 3711 | popperOffsets: popperOffsets$1, |
| 3712 | preventOverflow: preventOverflow$1 |
| 3713 | }); |
| 3714 | |
| 3715 | /** |
| 3716 | * -------------------------------------------------------------------------- |
| 3717 | * Bootstrap (v5.1.3): dropdown.js |
| 3718 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 3719 | * -------------------------------------------------------------------------- |
| 3720 | */ |
| 3721 | /** |
| 3722 | * ------------------------------------------------------------------------ |
| 3723 | * Constants |
| 3724 | * ------------------------------------------------------------------------ |
| 3725 | */ |
| 3726 | |
| 3727 | const NAME$9 = 'dropdown'; |
| 3728 | const DATA_KEY$8 = 'bs.dropdown'; |
| 3729 | const EVENT_KEY$8 = `.${DATA_KEY$8}`; |
| 3730 | const DATA_API_KEY$4 = '.data-api'; |
| 3731 | const ESCAPE_KEY$2 = 'Escape'; |
| 3732 | const SPACE_KEY = 'Space'; |
| 3733 | const TAB_KEY$1 = 'Tab'; |
| 3734 | const ARROW_UP_KEY = 'ArrowUp'; |
| 3735 | const ARROW_DOWN_KEY = 'ArrowDown'; |
| 3736 | const RIGHT_MOUSE_BUTTON = 2; // MouseEvent.button value for the secondary button, usually the right button |
| 3737 | |
| 3738 | const REGEXP_KEYDOWN = new RegExp(`${ARROW_UP_KEY}|${ARROW_DOWN_KEY}|${ESCAPE_KEY$2}`); |
| 3739 | const EVENT_HIDE$4 = `hide${EVENT_KEY$8}`; |
| 3740 | const EVENT_HIDDEN$4 = `hidden${EVENT_KEY$8}`; |
| 3741 | const EVENT_SHOW$4 = `show${EVENT_KEY$8}`; |
| 3742 | const EVENT_SHOWN$4 = `shown${EVENT_KEY$8}`; |
| 3743 | const EVENT_CLICK_DATA_API$3 = `click${EVENT_KEY$8}${DATA_API_KEY$4}`; |
| 3744 | const EVENT_KEYDOWN_DATA_API = `keydown${EVENT_KEY$8}${DATA_API_KEY$4}`; |
| 3745 | const EVENT_KEYUP_DATA_API = `keyup${EVENT_KEY$8}${DATA_API_KEY$4}`; |
| 3746 | const CLASS_NAME_SHOW$6 = 'show'; |
| 3747 | const CLASS_NAME_DROPUP = 'dropup'; |
| 3748 | const CLASS_NAME_DROPEND = 'dropend'; |
| 3749 | const CLASS_NAME_DROPSTART = 'dropstart'; |
| 3750 | const CLASS_NAME_NAVBAR = 'navbar'; |
| 3751 | const SELECTOR_DATA_TOGGLE$3 = '[data-bs-toggle="dropdown"]'; |
| 3752 | const SELECTOR_MENU = '.dropdown-menu'; |
| 3753 | const SELECTOR_NAVBAR_NAV = '.navbar-nav'; |
| 3754 | const SELECTOR_VISIBLE_ITEMS = '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)'; |
| 3755 | const PLACEMENT_TOP = isRTL() ? 'top-end' : 'top-start'; |
| 3756 | const PLACEMENT_TOPEND = isRTL() ? 'top-start' : 'top-end'; |
| 3757 | const PLACEMENT_BOTTOM = isRTL() ? 'bottom-end' : 'bottom-start'; |
| 3758 | const PLACEMENT_BOTTOMEND = isRTL() ? 'bottom-start' : 'bottom-end'; |
| 3759 | const PLACEMENT_RIGHT = isRTL() ? 'left-start' : 'right-start'; |
| 3760 | const PLACEMENT_LEFT = isRTL() ? 'right-start' : 'left-start'; |
| 3761 | const Default$8 = { |
| 3762 | offset: [0, 2], |
| 3763 | boundary: 'clippingParents', |
| 3764 | reference: 'toggle', |
| 3765 | display: 'dynamic', |
| 3766 | popperConfig: null, |
| 3767 | autoClose: true |
| 3768 | }; |
| 3769 | const DefaultType$8 = { |
| 3770 | offset: '(array|string|function)', |
| 3771 | boundary: '(string|element)', |
| 3772 | reference: '(string|element|object)', |
| 3773 | display: 'string', |
| 3774 | popperConfig: '(null|object|function)', |
| 3775 | autoClose: '(boolean|string)' |
| 3776 | }; |
| 3777 | /** |
| 3778 | * ------------------------------------------------------------------------ |
| 3779 | * Class Definition |
| 3780 | * ------------------------------------------------------------------------ |
| 3781 | */ |
| 3782 | |
| 3783 | class Dropdown extends BaseComponent { |
| 3784 | constructor(element, config) { |
| 3785 | super(element); |
| 3786 | this._popper = null; |
| 3787 | this._config = this._getConfig(config); |
| 3788 | this._menu = this._getMenuElement(); |
| 3789 | this._inNavbar = this._detectNavbar(); |
| 3790 | } // Getters |
| 3791 | |
| 3792 | |
| 3793 | static get Default() { |
| 3794 | return Default$8; |
| 3795 | } |
| 3796 | |
| 3797 | static get DefaultType() { |
| 3798 | return DefaultType$8; |
| 3799 | } |
| 3800 | |
| 3801 | static get NAME() { |
| 3802 | return NAME$9; |
| 3803 | } // Public |
| 3804 | |
| 3805 | |
| 3806 | toggle() { |
| 3807 | return this._isShown() ? this.hide() : this.show(); |
| 3808 | } |
| 3809 | |
| 3810 | show() { |
| 3811 | if (isDisabled(this._element) || this._isShown(this._menu)) { |
| 3812 | return; |
| 3813 | } |
| 3814 | |
| 3815 | const relatedTarget = { |
| 3816 | relatedTarget: this._element |
| 3817 | }; |
| 3818 | const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$4, relatedTarget); |
| 3819 | |
| 3820 | if (showEvent.defaultPrevented) { |
| 3821 | return; |
| 3822 | } |
| 3823 | |
| 3824 | const parent = Dropdown.getParentFromElement(this._element); // Totally disable Popper for Dropdowns in Navbar |
| 3825 | |
| 3826 | if (this._inNavbar) { |
| 3827 | Manipulator.setDataAttribute(this._menu, 'popper', 'none'); |
| 3828 | } else { |
| 3829 | this._createPopper(parent); |
| 3830 | } // If this is a touch-enabled device we add extra |
| 3831 | // empty mouseover listeners to the body's immediate children; |
| 3832 | // only needed because of broken event delegation on iOS |
| 3833 | // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html |
| 3834 | |
| 3835 | |
| 3836 | if ('ontouchstart' in document.documentElement && !parent.closest(SELECTOR_NAVBAR_NAV)) { |
| 3837 | [].concat(...document.body.children).forEach(elem => EventHandler.on(elem, 'mouseover', noop)); |
| 3838 | } |
| 3839 | |
| 3840 | this._element.focus(); |
| 3841 | |
| 3842 | this._element.setAttribute('aria-expanded', true); |
| 3843 | |
| 3844 | this._menu.classList.add(CLASS_NAME_SHOW$6); |
| 3845 | |
| 3846 | this._element.classList.add(CLASS_NAME_SHOW$6); |
| 3847 | |
| 3848 | EventHandler.trigger(this._element, EVENT_SHOWN$4, relatedTarget); |
| 3849 | } |
| 3850 | |
| 3851 | hide() { |
| 3852 | if (isDisabled(this._element) || !this._isShown(this._menu)) { |
| 3853 | return; |
| 3854 | } |
| 3855 | |
| 3856 | const relatedTarget = { |
| 3857 | relatedTarget: this._element |
| 3858 | }; |
| 3859 | |
| 3860 | this._completeHide(relatedTarget); |
| 3861 | } |
| 3862 | |
| 3863 | dispose() { |
| 3864 | if (this._popper) { |
| 3865 | this._popper.destroy(); |
| 3866 | } |
| 3867 | |
| 3868 | super.dispose(); |
| 3869 | } |
| 3870 | |
| 3871 | update() { |
| 3872 | this._inNavbar = this._detectNavbar(); |
| 3873 | |
| 3874 | if (this._popper) { |
| 3875 | this._popper.update(); |
| 3876 | } |
| 3877 | } // Private |
| 3878 | |
| 3879 | |
| 3880 | _completeHide(relatedTarget) { |
| 3881 | const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$4, relatedTarget); |
| 3882 | |
| 3883 | if (hideEvent.defaultPrevented) { |
| 3884 | return; |
| 3885 | } // If this is a touch-enabled device we remove the extra |
| 3886 | // empty mouseover listeners we added for iOS support |
| 3887 | |
| 3888 | |
| 3889 | if ('ontouchstart' in document.documentElement) { |
| 3890 | [].concat(...document.body.children).forEach(elem => EventHandler.off(elem, 'mouseover', noop)); |
| 3891 | } |
| 3892 | |
| 3893 | if (this._popper) { |
| 3894 | this._popper.destroy(); |
| 3895 | } |
| 3896 | |
| 3897 | this._menu.classList.remove(CLASS_NAME_SHOW$6); |
| 3898 | |
| 3899 | this._element.classList.remove(CLASS_NAME_SHOW$6); |
| 3900 | |
| 3901 | this._element.setAttribute('aria-expanded', 'false'); |
| 3902 | |
| 3903 | Manipulator.removeDataAttribute(this._menu, 'popper'); |
| 3904 | EventHandler.trigger(this._element, EVENT_HIDDEN$4, relatedTarget); |
| 3905 | } |
| 3906 | |
| 3907 | _getConfig(config) { |
| 3908 | config = { ...this.constructor.Default, |
| 3909 | ...Manipulator.getDataAttributes(this._element), |
| 3910 | ...config |
| 3911 | }; |
| 3912 | typeCheckConfig(NAME$9, config, this.constructor.DefaultType); |
| 3913 | |
| 3914 | if (typeof config.reference === 'object' && !isElement$1(config.reference) && typeof config.reference.getBoundingClientRect !== 'function') { |
| 3915 | // Popper virtual elements require a getBoundingClientRect method |
| 3916 | throw new TypeError(`${NAME$9.toUpperCase()}: Option "reference" provided type "object" without a required "getBoundingClientRect" method.`); |
| 3917 | } |
| 3918 | |
| 3919 | return config; |
| 3920 | } |
| 3921 | |
| 3922 | _createPopper(parent) { |
| 3923 | if (typeof Popper === 'undefined') { |
| 3924 | throw new TypeError('Bootstrap\'s dropdowns require Popper (https://popper.js.org)'); |
| 3925 | } |
| 3926 | |
| 3927 | let referenceElement = this._element; |
| 3928 | |
| 3929 | if (this._config.reference === 'parent') { |
| 3930 | referenceElement = parent; |
| 3931 | } else if (isElement$1(this._config.reference)) { |
| 3932 | referenceElement = getElement(this._config.reference); |
| 3933 | } else if (typeof this._config.reference === 'object') { |
| 3934 | referenceElement = this._config.reference; |
| 3935 | } |
| 3936 | |
| 3937 | const popperConfig = this._getPopperConfig(); |
| 3938 | |
| 3939 | const isDisplayStatic = popperConfig.modifiers.find(modifier => modifier.name === 'applyStyles' && modifier.enabled === false); |
| 3940 | this._popper = createPopper(referenceElement, this._menu, popperConfig); |
| 3941 | |
| 3942 | if (isDisplayStatic) { |
| 3943 | Manipulator.setDataAttribute(this._menu, 'popper', 'static'); |
| 3944 | } |
| 3945 | } |
| 3946 | |
| 3947 | _isShown(element = this._element) { |
| 3948 | return element.classList.contains(CLASS_NAME_SHOW$6); |
| 3949 | } |
| 3950 | |
| 3951 | _getMenuElement() { |
| 3952 | return SelectorEngine.next(this._element, SELECTOR_MENU)[0]; |
| 3953 | } |
| 3954 | |
| 3955 | _getPlacement() { |
| 3956 | const parentDropdown = this._element.parentNode; |
| 3957 | |
| 3958 | if (parentDropdown.classList.contains(CLASS_NAME_DROPEND)) { |
| 3959 | return PLACEMENT_RIGHT; |
| 3960 | } |
| 3961 | |
| 3962 | if (parentDropdown.classList.contains(CLASS_NAME_DROPSTART)) { |
| 3963 | return PLACEMENT_LEFT; |
| 3964 | } // We need to trim the value because custom properties can also include spaces |
| 3965 | |
| 3966 | |
| 3967 | const isEnd = getComputedStyle(this._menu).getPropertyValue('--bs-position').trim() === 'end'; |
| 3968 | |
| 3969 | if (parentDropdown.classList.contains(CLASS_NAME_DROPUP)) { |
| 3970 | return isEnd ? PLACEMENT_TOPEND : PLACEMENT_TOP; |
| 3971 | } |
| 3972 | |
| 3973 | return isEnd ? PLACEMENT_BOTTOMEND : PLACEMENT_BOTTOM; |
| 3974 | } |
| 3975 | |
| 3976 | _detectNavbar() { |
| 3977 | return this._element.closest(`.${CLASS_NAME_NAVBAR}`) !== null; |
| 3978 | } |
| 3979 | |
| 3980 | _getOffset() { |
| 3981 | const { |
| 3982 | offset |
| 3983 | } = this._config; |
| 3984 | |
| 3985 | if (typeof offset === 'string') { |
| 3986 | return offset.split(',').map(val => Number.parseInt(val, 10)); |
| 3987 | } |
| 3988 | |
| 3989 | if (typeof offset === 'function') { |
| 3990 | return popperData => offset(popperData, this._element); |
| 3991 | } |
| 3992 | |
| 3993 | return offset; |
| 3994 | } |
| 3995 | |
| 3996 | _getPopperConfig() { |
| 3997 | const defaultBsPopperConfig = { |
| 3998 | placement: this._getPlacement(), |
| 3999 | modifiers: [{ |
| 4000 | name: 'preventOverflow', |
| 4001 | options: { |
| 4002 | boundary: this._config.boundary |
| 4003 | } |
| 4004 | }, { |
| 4005 | name: 'offset', |
| 4006 | options: { |
| 4007 | offset: this._getOffset() |
| 4008 | } |
| 4009 | }] |
| 4010 | }; // Disable Popper if we have a static display |
| 4011 | |
| 4012 | if (this._config.display === 'static') { |
| 4013 | defaultBsPopperConfig.modifiers = [{ |
| 4014 | name: 'applyStyles', |
| 4015 | enabled: false |
| 4016 | }]; |
| 4017 | } |
| 4018 | |
| 4019 | return { ...defaultBsPopperConfig, |
| 4020 | ...(typeof this._config.popperConfig === 'function' ? this._config.popperConfig(defaultBsPopperConfig) : this._config.popperConfig) |
| 4021 | }; |
| 4022 | } |
| 4023 | |
| 4024 | _selectMenuItem({ |
| 4025 | key, |
| 4026 | target |
| 4027 | }) { |
| 4028 | const items = SelectorEngine.find(SELECTOR_VISIBLE_ITEMS, this._menu).filter(isVisible); |
| 4029 | |
| 4030 | if (!items.length) { |
| 4031 | return; |
| 4032 | } // if target isn't included in items (e.g. when expanding the dropdown) |
| 4033 | // allow cycling to get the last item in case key equals ARROW_UP_KEY |
| 4034 | |
| 4035 | |
| 4036 | getNextActiveElement(items, target, key === ARROW_DOWN_KEY, !items.includes(target)).focus(); |
| 4037 | } // Static |
| 4038 | |
| 4039 | |
| 4040 | static jQueryInterface(config) { |
| 4041 | return this.each(function () { |
| 4042 | const data = Dropdown.getOrCreateInstance(this, config); |
| 4043 | |
| 4044 | if (typeof config !== 'string') { |
| 4045 | return; |
| 4046 | } |
| 4047 | |
| 4048 | if (typeof data[config] === 'undefined') { |
| 4049 | throw new TypeError(`No method named "${config}"`); |
| 4050 | } |
| 4051 | |
| 4052 | data[config](); |
| 4053 | }); |
| 4054 | } |
| 4055 | |
| 4056 | static clearMenus(event) { |
| 4057 | if (event && (event.button === RIGHT_MOUSE_BUTTON || event.type === 'keyup' && event.key !== TAB_KEY$1)) { |
| 4058 | return; |
| 4059 | } |
| 4060 | |
| 4061 | const toggles = SelectorEngine.find(SELECTOR_DATA_TOGGLE$3); |
| 4062 | |
| 4063 | for (let i = 0, len = toggles.length; i < len; i++) { |
| 4064 | const context = Dropdown.getInstance(toggles[i]); |
| 4065 | |
| 4066 | if (!context || context._config.autoClose === false) { |
| 4067 | continue; |
| 4068 | } |
| 4069 | |
| 4070 | if (!context._isShown()) { |
| 4071 | continue; |
| 4072 | } |
| 4073 | |
| 4074 | const relatedTarget = { |
| 4075 | relatedTarget: context._element |
| 4076 | }; |
| 4077 | |
| 4078 | if (event) { |
| 4079 | const composedPath = event.composedPath(); |
| 4080 | const isMenuTarget = composedPath.includes(context._menu); |
| 4081 | |
| 4082 | if (composedPath.includes(context._element) || context._config.autoClose === 'inside' && !isMenuTarget || context._config.autoClose === 'outside' && isMenuTarget) { |
| 4083 | continue; |
| 4084 | } // Tab navigation through the dropdown menu or events from contained inputs shouldn't close the menu |
| 4085 | |
| 4086 | |
| 4087 | if (context._menu.contains(event.target) && (event.type === 'keyup' && event.key === TAB_KEY$1 || /input|select|option|textarea|form/i.test(event.target.tagName))) { |
| 4088 | continue; |
| 4089 | } |
| 4090 | |
| 4091 | if (event.type === 'click') { |
| 4092 | relatedTarget.clickEvent = event; |
| 4093 | } |
| 4094 | } |
| 4095 | |
| 4096 | context._completeHide(relatedTarget); |
| 4097 | } |
| 4098 | } |
| 4099 | |
| 4100 | static getParentFromElement(element) { |
| 4101 | return getElementFromSelector(element) || element.parentNode; |
| 4102 | } |
| 4103 | |
| 4104 | static dataApiKeydownHandler(event) { |
| 4105 | // If not input/textarea: |
| 4106 | // - And not a key in REGEXP_KEYDOWN => not a dropdown command |
| 4107 | // If input/textarea: |
| 4108 | // - If space key => not a dropdown command |
| 4109 | // - If key is other than escape |
| 4110 | // - If key is not up or down => not a dropdown command |
| 4111 | // - If trigger inside the menu => not a dropdown command |
| 4112 | if (/input|textarea/i.test(event.target.tagName) ? event.key === SPACE_KEY || event.key !== ESCAPE_KEY$2 && (event.key !== ARROW_DOWN_KEY && event.key !== ARROW_UP_KEY || event.target.closest(SELECTOR_MENU)) : !REGEXP_KEYDOWN.test(event.key)) { |
| 4113 | return; |
| 4114 | } |
| 4115 | |
| 4116 | const isActive = this.classList.contains(CLASS_NAME_SHOW$6); |
| 4117 | |
| 4118 | if (!isActive && event.key === ESCAPE_KEY$2) { |
| 4119 | return; |
| 4120 | } |
| 4121 | |
| 4122 | event.preventDefault(); |
| 4123 | event.stopPropagation(); |
| 4124 | |
| 4125 | if (isDisabled(this)) { |
| 4126 | return; |
| 4127 | } |
| 4128 | |
| 4129 | const getToggleButton = this.matches(SELECTOR_DATA_TOGGLE$3) ? this : SelectorEngine.prev(this, SELECTOR_DATA_TOGGLE$3)[0]; |
| 4130 | const instance = Dropdown.getOrCreateInstance(getToggleButton); |
| 4131 | |
| 4132 | if (event.key === ESCAPE_KEY$2) { |
| 4133 | instance.hide(); |
| 4134 | return; |
| 4135 | } |
| 4136 | |
| 4137 | if (event.key === ARROW_UP_KEY || event.key === ARROW_DOWN_KEY) { |
| 4138 | if (!isActive) { |
| 4139 | instance.show(); |
| 4140 | } |
| 4141 | |
| 4142 | instance._selectMenuItem(event); |
| 4143 | |
| 4144 | return; |
| 4145 | } |
| 4146 | |
| 4147 | if (!isActive || event.key === SPACE_KEY) { |
| 4148 | Dropdown.clearMenus(); |
| 4149 | } |
| 4150 | } |
| 4151 | |
| 4152 | } |
| 4153 | /** |
| 4154 | * ------------------------------------------------------------------------ |
| 4155 | * Data Api implementation |
| 4156 | * ------------------------------------------------------------------------ |
| 4157 | */ |
| 4158 | |
| 4159 | |
| 4160 | EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_DATA_TOGGLE$3, Dropdown.dataApiKeydownHandler); |
| 4161 | EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_MENU, Dropdown.dataApiKeydownHandler); |
| 4162 | EventHandler.on(document, EVENT_CLICK_DATA_API$3, Dropdown.clearMenus); |
| 4163 | EventHandler.on(document, EVENT_KEYUP_DATA_API, Dropdown.clearMenus); |
| 4164 | EventHandler.on(document, EVENT_CLICK_DATA_API$3, SELECTOR_DATA_TOGGLE$3, function (event) { |
| 4165 | event.preventDefault(); |
| 4166 | Dropdown.getOrCreateInstance(this).toggle(); |
| 4167 | }); |
| 4168 | /** |
| 4169 | * ------------------------------------------------------------------------ |
| 4170 | * jQuery |
| 4171 | * ------------------------------------------------------------------------ |
| 4172 | * add .Dropdown to jQuery only if jQuery is present |
| 4173 | */ |
| 4174 | |
| 4175 | defineJQueryPlugin(Dropdown); |
| 4176 | |
| 4177 | /** |
| 4178 | * -------------------------------------------------------------------------- |
| 4179 | * Bootstrap (v5.1.3): util/scrollBar.js |
| 4180 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 4181 | * -------------------------------------------------------------------------- |
| 4182 | */ |
| 4183 | const SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top'; |
| 4184 | const SELECTOR_STICKY_CONTENT = '.sticky-top'; |
| 4185 | |
| 4186 | class ScrollBarHelper { |
| 4187 | constructor() { |
| 4188 | this._element = document.body; |
| 4189 | } |
| 4190 | |
| 4191 | getWidth() { |
| 4192 | // https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes |
| 4193 | const documentWidth = document.documentElement.clientWidth; |
| 4194 | return Math.abs(window.innerWidth - documentWidth); |
| 4195 | } |
| 4196 | |
| 4197 | hide() { |
| 4198 | const width = this.getWidth(); |
| 4199 | |
| 4200 | this._disableOverFlow(); // give padding to element to balance the hidden scrollbar width |
| 4201 | |
| 4202 | |
| 4203 | this._setElementAttributes(this._element, 'paddingRight', calculatedValue => calculatedValue + width); // trick: We adjust positive paddingRight and negative marginRight to sticky-top elements to keep showing fullwidth |
| 4204 | |
| 4205 | |
| 4206 | this._setElementAttributes(SELECTOR_FIXED_CONTENT, 'paddingRight', calculatedValue => calculatedValue + width); |
| 4207 | |
| 4208 | this._setElementAttributes(SELECTOR_STICKY_CONTENT, 'marginRight', calculatedValue => calculatedValue - width); |
| 4209 | } |
| 4210 | |
| 4211 | _disableOverFlow() { |
| 4212 | this._saveInitialAttribute(this._element, 'overflow'); |
| 4213 | |
| 4214 | this._element.style.overflow = 'hidden'; |
| 4215 | } |
| 4216 | |
| 4217 | _setElementAttributes(selector, styleProp, callback) { |
| 4218 | const scrollbarWidth = this.getWidth(); |
| 4219 | |
| 4220 | const manipulationCallBack = element => { |
| 4221 | if (element !== this._element && window.innerWidth > element.clientWidth + scrollbarWidth) { |
| 4222 | return; |
| 4223 | } |
| 4224 | |
| 4225 | this._saveInitialAttribute(element, styleProp); |
| 4226 | |
| 4227 | const calculatedValue = window.getComputedStyle(element)[styleProp]; |
| 4228 | element.style[styleProp] = `${callback(Number.parseFloat(calculatedValue))}px`; |
| 4229 | }; |
| 4230 | |
| 4231 | this._applyManipulationCallback(selector, manipulationCallBack); |
| 4232 | } |
| 4233 | |
| 4234 | reset() { |
| 4235 | this._resetElementAttributes(this._element, 'overflow'); |
| 4236 | |
| 4237 | this._resetElementAttributes(this._element, 'paddingRight'); |
| 4238 | |
| 4239 | this._resetElementAttributes(SELECTOR_FIXED_CONTENT, 'paddingRight'); |
| 4240 | |
| 4241 | this._resetElementAttributes(SELECTOR_STICKY_CONTENT, 'marginRight'); |
| 4242 | } |
| 4243 | |
| 4244 | _saveInitialAttribute(element, styleProp) { |
| 4245 | const actualValue = element.style[styleProp]; |
| 4246 | |
| 4247 | if (actualValue) { |
| 4248 | Manipulator.setDataAttribute(element, styleProp, actualValue); |
| 4249 | } |
| 4250 | } |
| 4251 | |
| 4252 | _resetElementAttributes(selector, styleProp) { |
| 4253 | const manipulationCallBack = element => { |
| 4254 | const value = Manipulator.getDataAttribute(element, styleProp); |
| 4255 | |
| 4256 | if (typeof value === 'undefined') { |
| 4257 | element.style.removeProperty(styleProp); |
| 4258 | } else { |
| 4259 | Manipulator.removeDataAttribute(element, styleProp); |
| 4260 | element.style[styleProp] = value; |
| 4261 | } |
| 4262 | }; |
| 4263 | |
| 4264 | this._applyManipulationCallback(selector, manipulationCallBack); |
| 4265 | } |
| 4266 | |
| 4267 | _applyManipulationCallback(selector, callBack) { |
| 4268 | if (isElement$1(selector)) { |
| 4269 | callBack(selector); |
| 4270 | } else { |
| 4271 | SelectorEngine.find(selector, this._element).forEach(callBack); |
| 4272 | } |
| 4273 | } |
| 4274 | |
| 4275 | isOverflowing() { |
| 4276 | return this.getWidth() > 0; |
| 4277 | } |
| 4278 | |
| 4279 | } |
| 4280 | |
| 4281 | /** |
| 4282 | * -------------------------------------------------------------------------- |
| 4283 | * Bootstrap (v5.1.3): util/backdrop.js |
| 4284 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 4285 | * -------------------------------------------------------------------------- |
| 4286 | */ |
| 4287 | const Default$7 = { |
| 4288 | className: 'modal-backdrop', |
| 4289 | isVisible: true, |
| 4290 | // if false, we use the backdrop helper without adding any element to the dom |
| 4291 | isAnimated: false, |
| 4292 | rootElement: 'body', |
| 4293 | // give the choice to place backdrop under different elements |
| 4294 | clickCallback: null |
| 4295 | }; |
| 4296 | const DefaultType$7 = { |
| 4297 | className: 'string', |
| 4298 | isVisible: 'boolean', |
| 4299 | isAnimated: 'boolean', |
| 4300 | rootElement: '(element|string)', |
| 4301 | clickCallback: '(function|null)' |
| 4302 | }; |
| 4303 | const NAME$8 = 'backdrop'; |
| 4304 | const CLASS_NAME_FADE$4 = 'fade'; |
| 4305 | const CLASS_NAME_SHOW$5 = 'show'; |
| 4306 | const EVENT_MOUSEDOWN = `mousedown.bs.${NAME$8}`; |
| 4307 | |
| 4308 | class Backdrop { |
| 4309 | constructor(config) { |
| 4310 | this._config = this._getConfig(config); |
| 4311 | this._isAppended = false; |
| 4312 | this._element = null; |
| 4313 | } |
| 4314 | |
| 4315 | show(callback) { |
| 4316 | if (!this._config.isVisible) { |
| 4317 | execute(callback); |
| 4318 | return; |
| 4319 | } |
| 4320 | |
| 4321 | this._append(); |
| 4322 | |
| 4323 | if (this._config.isAnimated) { |
| 4324 | reflow(this._getElement()); |
| 4325 | } |
| 4326 | |
| 4327 | this._getElement().classList.add(CLASS_NAME_SHOW$5); |
| 4328 | |
| 4329 | this._emulateAnimation(() => { |
| 4330 | execute(callback); |
| 4331 | }); |
| 4332 | } |
| 4333 | |
| 4334 | hide(callback) { |
| 4335 | if (!this._config.isVisible) { |
| 4336 | execute(callback); |
| 4337 | return; |
| 4338 | } |
| 4339 | |
| 4340 | this._getElement().classList.remove(CLASS_NAME_SHOW$5); |
| 4341 | |
| 4342 | this._emulateAnimation(() => { |
| 4343 | this.dispose(); |
| 4344 | execute(callback); |
| 4345 | }); |
| 4346 | } // Private |
| 4347 | |
| 4348 | |
| 4349 | _getElement() { |
| 4350 | if (!this._element) { |
| 4351 | const backdrop = document.createElement('div'); |
| 4352 | backdrop.className = this._config.className; |
| 4353 | |
| 4354 | if (this._config.isAnimated) { |
| 4355 | backdrop.classList.add(CLASS_NAME_FADE$4); |
| 4356 | } |
| 4357 | |
| 4358 | this._element = backdrop; |
| 4359 | } |
| 4360 | |
| 4361 | return this._element; |
| 4362 | } |
| 4363 | |
| 4364 | _getConfig(config) { |
| 4365 | config = { ...Default$7, |
| 4366 | ...(typeof config === 'object' ? config : {}) |
| 4367 | }; // use getElement() with the default "body" to get a fresh Element on each instantiation |
| 4368 | |
| 4369 | config.rootElement = getElement(config.rootElement); |
| 4370 | typeCheckConfig(NAME$8, config, DefaultType$7); |
| 4371 | return config; |
| 4372 | } |
| 4373 | |
| 4374 | _append() { |
| 4375 | if (this._isAppended) { |
| 4376 | return; |
| 4377 | } |
| 4378 | |
| 4379 | this._config.rootElement.append(this._getElement()); |
| 4380 | |
| 4381 | EventHandler.on(this._getElement(), EVENT_MOUSEDOWN, () => { |
| 4382 | execute(this._config.clickCallback); |
| 4383 | }); |
| 4384 | this._isAppended = true; |
| 4385 | } |
| 4386 | |
| 4387 | dispose() { |
| 4388 | if (!this._isAppended) { |
| 4389 | return; |
| 4390 | } |
| 4391 | |
| 4392 | EventHandler.off(this._element, EVENT_MOUSEDOWN); |
| 4393 | |
| 4394 | this._element.remove(); |
| 4395 | |
| 4396 | this._isAppended = false; |
| 4397 | } |
| 4398 | |
| 4399 | _emulateAnimation(callback) { |
| 4400 | executeAfterTransition(callback, this._getElement(), this._config.isAnimated); |
| 4401 | } |
| 4402 | |
| 4403 | } |
| 4404 | |
| 4405 | /** |
| 4406 | * -------------------------------------------------------------------------- |
| 4407 | * Bootstrap (v5.1.3): util/focustrap.js |
| 4408 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 4409 | * -------------------------------------------------------------------------- |
| 4410 | */ |
| 4411 | const Default$6 = { |
| 4412 | trapElement: null, |
| 4413 | // The element to trap focus inside of |
| 4414 | autofocus: true |
| 4415 | }; |
| 4416 | const DefaultType$6 = { |
| 4417 | trapElement: 'element', |
| 4418 | autofocus: 'boolean' |
| 4419 | }; |
| 4420 | const NAME$7 = 'focustrap'; |
| 4421 | const DATA_KEY$7 = 'bs.focustrap'; |
| 4422 | const EVENT_KEY$7 = `.${DATA_KEY$7}`; |
| 4423 | const EVENT_FOCUSIN$1 = `focusin${EVENT_KEY$7}`; |
| 4424 | const EVENT_KEYDOWN_TAB = `keydown.tab${EVENT_KEY$7}`; |
| 4425 | const TAB_KEY = 'Tab'; |
| 4426 | const TAB_NAV_FORWARD = 'forward'; |
| 4427 | const TAB_NAV_BACKWARD = 'backward'; |
| 4428 | |
| 4429 | class FocusTrap { |
| 4430 | constructor(config) { |
| 4431 | this._config = this._getConfig(config); |
| 4432 | this._isActive = false; |
| 4433 | this._lastTabNavDirection = null; |
| 4434 | } |
| 4435 | |
| 4436 | activate() { |
| 4437 | const { |
| 4438 | trapElement, |
| 4439 | autofocus |
| 4440 | } = this._config; |
| 4441 | |
| 4442 | if (this._isActive) { |
| 4443 | return; |
| 4444 | } |
| 4445 | |
| 4446 | if (autofocus) { |
| 4447 | trapElement.focus(); |
| 4448 | } |
| 4449 | |
| 4450 | EventHandler.off(document, EVENT_KEY$7); // guard against infinite focus loop |
| 4451 | |
| 4452 | EventHandler.on(document, EVENT_FOCUSIN$1, event => this._handleFocusin(event)); |
| 4453 | EventHandler.on(document, EVENT_KEYDOWN_TAB, event => this._handleKeydown(event)); |
| 4454 | this._isActive = true; |
| 4455 | } |
| 4456 | |
| 4457 | deactivate() { |
| 4458 | if (!this._isActive) { |
| 4459 | return; |
| 4460 | } |
| 4461 | |
| 4462 | this._isActive = false; |
| 4463 | EventHandler.off(document, EVENT_KEY$7); |
| 4464 | } // Private |
| 4465 | |
| 4466 | |
| 4467 | _handleFocusin(event) { |
| 4468 | const { |
| 4469 | target |
| 4470 | } = event; |
| 4471 | const { |
| 4472 | trapElement |
| 4473 | } = this._config; |
| 4474 | |
| 4475 | if (target === document || target === trapElement || trapElement.contains(target)) { |
| 4476 | return; |
| 4477 | } |
| 4478 | |
| 4479 | const elements = SelectorEngine.focusableChildren(trapElement); |
| 4480 | |
| 4481 | if (elements.length === 0) { |
| 4482 | trapElement.focus(); |
| 4483 | } else if (this._lastTabNavDirection === TAB_NAV_BACKWARD) { |
| 4484 | elements[elements.length - 1].focus(); |
| 4485 | } else { |
| 4486 | elements[0].focus(); |
| 4487 | } |
| 4488 | } |
| 4489 | |
| 4490 | _handleKeydown(event) { |
| 4491 | if (event.key !== TAB_KEY) { |
| 4492 | return; |
| 4493 | } |
| 4494 | |
| 4495 | this._lastTabNavDirection = event.shiftKey ? TAB_NAV_BACKWARD : TAB_NAV_FORWARD; |
| 4496 | } |
| 4497 | |
| 4498 | _getConfig(config) { |
| 4499 | config = { ...Default$6, |
| 4500 | ...(typeof config === 'object' ? config : {}) |
| 4501 | }; |
| 4502 | typeCheckConfig(NAME$7, config, DefaultType$6); |
| 4503 | return config; |
| 4504 | } |
| 4505 | |
| 4506 | } |
| 4507 | |
| 4508 | /** |
| 4509 | * -------------------------------------------------------------------------- |
| 4510 | * Bootstrap (v5.1.3): modal.js |
| 4511 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 4512 | * -------------------------------------------------------------------------- |
| 4513 | */ |
| 4514 | /** |
| 4515 | * ------------------------------------------------------------------------ |
| 4516 | * Constants |
| 4517 | * ------------------------------------------------------------------------ |
| 4518 | */ |
| 4519 | |
| 4520 | const NAME$6 = 'modal'; |
| 4521 | const DATA_KEY$6 = 'bs.modal'; |
| 4522 | const EVENT_KEY$6 = `.${DATA_KEY$6}`; |
| 4523 | const DATA_API_KEY$3 = '.data-api'; |
| 4524 | const ESCAPE_KEY$1 = 'Escape'; |
| 4525 | const Default$5 = { |
| 4526 | backdrop: true, |
| 4527 | keyboard: true, |
| 4528 | focus: true |
| 4529 | }; |
| 4530 | const DefaultType$5 = { |
| 4531 | backdrop: '(boolean|string)', |
| 4532 | keyboard: 'boolean', |
| 4533 | focus: 'boolean' |
| 4534 | }; |
| 4535 | const EVENT_HIDE$3 = `hide${EVENT_KEY$6}`; |
| 4536 | const EVENT_HIDE_PREVENTED = `hidePrevented${EVENT_KEY$6}`; |
| 4537 | const EVENT_HIDDEN$3 = `hidden${EVENT_KEY$6}`; |
| 4538 | const EVENT_SHOW$3 = `show${EVENT_KEY$6}`; |
| 4539 | const EVENT_SHOWN$3 = `shown${EVENT_KEY$6}`; |
| 4540 | const EVENT_RESIZE = `resize${EVENT_KEY$6}`; |
| 4541 | const EVENT_CLICK_DISMISS = `click.dismiss${EVENT_KEY$6}`; |
| 4542 | const EVENT_KEYDOWN_DISMISS$1 = `keydown.dismiss${EVENT_KEY$6}`; |
| 4543 | const EVENT_MOUSEUP_DISMISS = `mouseup.dismiss${EVENT_KEY$6}`; |
| 4544 | const EVENT_MOUSEDOWN_DISMISS = `mousedown.dismiss${EVENT_KEY$6}`; |
| 4545 | const EVENT_CLICK_DATA_API$2 = `click${EVENT_KEY$6}${DATA_API_KEY$3}`; |
| 4546 | const CLASS_NAME_OPEN = 'modal-open'; |
| 4547 | const CLASS_NAME_FADE$3 = 'fade'; |
| 4548 | const CLASS_NAME_SHOW$4 = 'show'; |
| 4549 | const CLASS_NAME_STATIC = 'modal-static'; |
| 4550 | const OPEN_SELECTOR$1 = '.modal.show'; |
| 4551 | const SELECTOR_DIALOG = '.modal-dialog'; |
| 4552 | const SELECTOR_MODAL_BODY = '.modal-body'; |
| 4553 | const SELECTOR_DATA_TOGGLE$2 = '[data-bs-toggle="modal"]'; |
| 4554 | /** |
| 4555 | * ------------------------------------------------------------------------ |
| 4556 | * Class Definition |
| 4557 | * ------------------------------------------------------------------------ |
| 4558 | */ |
| 4559 | |
| 4560 | class Modal extends BaseComponent { |
| 4561 | constructor(element, config) { |
| 4562 | super(element); |
| 4563 | this._config = this._getConfig(config); |
| 4564 | this._dialog = SelectorEngine.findOne(SELECTOR_DIALOG, this._element); |
| 4565 | this._backdrop = this._initializeBackDrop(); |
| 4566 | this._focustrap = this._initializeFocusTrap(); |
| 4567 | this._isShown = false; |
| 4568 | this._ignoreBackdropClick = false; |
| 4569 | this._isTransitioning = false; |
| 4570 | this._scrollBar = new ScrollBarHelper(); |
| 4571 | } // Getters |
| 4572 | |
| 4573 | |
| 4574 | static get Default() { |
| 4575 | return Default$5; |
| 4576 | } |
| 4577 | |
| 4578 | static get NAME() { |
| 4579 | return NAME$6; |
| 4580 | } // Public |
| 4581 | |
| 4582 | |
| 4583 | toggle(relatedTarget) { |
| 4584 | return this._isShown ? this.hide() : this.show(relatedTarget); |
| 4585 | } |
| 4586 | |
| 4587 | show(relatedTarget) { |
| 4588 | if (this._isShown || this._isTransitioning) { |
| 4589 | return; |
| 4590 | } |
| 4591 | |
| 4592 | const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$3, { |
| 4593 | relatedTarget |
| 4594 | }); |
| 4595 | |
| 4596 | if (showEvent.defaultPrevented) { |
| 4597 | return; |
| 4598 | } |
| 4599 | |
| 4600 | this._isShown = true; |
| 4601 | |
| 4602 | if (this._isAnimated()) { |
| 4603 | this._isTransitioning = true; |
| 4604 | } |
| 4605 | |
| 4606 | this._scrollBar.hide(); |
| 4607 | |
| 4608 | document.body.classList.add(CLASS_NAME_OPEN); |
| 4609 | |
| 4610 | this._adjustDialog(); |
| 4611 | |
| 4612 | this._setEscapeEvent(); |
| 4613 | |
| 4614 | this._setResizeEvent(); |
| 4615 | |
| 4616 | EventHandler.on(this._dialog, EVENT_MOUSEDOWN_DISMISS, () => { |
| 4617 | EventHandler.one(this._element, EVENT_MOUSEUP_DISMISS, event => { |
| 4618 | if (event.target === this._element) { |
| 4619 | this._ignoreBackdropClick = true; |
| 4620 | } |
| 4621 | }); |
| 4622 | }); |
| 4623 | |
| 4624 | this._showBackdrop(() => this._showElement(relatedTarget)); |
| 4625 | } |
| 4626 | |
| 4627 | hide() { |
| 4628 | if (!this._isShown || this._isTransitioning) { |
| 4629 | return; |
| 4630 | } |
| 4631 | |
| 4632 | const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$3); |
| 4633 | |
| 4634 | if (hideEvent.defaultPrevented) { |
| 4635 | return; |
| 4636 | } |
| 4637 | |
| 4638 | this._isShown = false; |
| 4639 | |
| 4640 | const isAnimated = this._isAnimated(); |
| 4641 | |
| 4642 | if (isAnimated) { |
| 4643 | this._isTransitioning = true; |
| 4644 | } |
| 4645 | |
| 4646 | this._setEscapeEvent(); |
| 4647 | |
| 4648 | this._setResizeEvent(); |
| 4649 | |
| 4650 | this._focustrap.deactivate(); |
| 4651 | |
| 4652 | this._element.classList.remove(CLASS_NAME_SHOW$4); |
| 4653 | |
| 4654 | EventHandler.off(this._element, EVENT_CLICK_DISMISS); |
| 4655 | EventHandler.off(this._dialog, EVENT_MOUSEDOWN_DISMISS); |
| 4656 | |
| 4657 | this._queueCallback(() => this._hideModal(), this._element, isAnimated); |
| 4658 | } |
| 4659 | |
| 4660 | dispose() { |
| 4661 | [window, this._dialog].forEach(htmlElement => EventHandler.off(htmlElement, EVENT_KEY$6)); |
| 4662 | |
| 4663 | this._backdrop.dispose(); |
| 4664 | |
| 4665 | this._focustrap.deactivate(); |
| 4666 | |
| 4667 | super.dispose(); |
| 4668 | } |
| 4669 | |
| 4670 | handleUpdate() { |
| 4671 | this._adjustDialog(); |
| 4672 | } // Private |
| 4673 | |
| 4674 | |
| 4675 | _initializeBackDrop() { |
| 4676 | return new Backdrop({ |
| 4677 | isVisible: Boolean(this._config.backdrop), |
| 4678 | // 'static' option will be translated to true, and booleans will keep their value |
| 4679 | isAnimated: this._isAnimated() |
| 4680 | }); |
| 4681 | } |
| 4682 | |
| 4683 | _initializeFocusTrap() { |
| 4684 | return new FocusTrap({ |
| 4685 | trapElement: this._element |
| 4686 | }); |
| 4687 | } |
| 4688 | |
| 4689 | _getConfig(config) { |
| 4690 | config = { ...Default$5, |
| 4691 | ...Manipulator.getDataAttributes(this._element), |
| 4692 | ...(typeof config === 'object' ? config : {}) |
| 4693 | }; |
| 4694 | typeCheckConfig(NAME$6, config, DefaultType$5); |
| 4695 | return config; |
| 4696 | } |
| 4697 | |
| 4698 | _showElement(relatedTarget) { |
| 4699 | const isAnimated = this._isAnimated(); |
| 4700 | |
| 4701 | const modalBody = SelectorEngine.findOne(SELECTOR_MODAL_BODY, this._dialog); |
| 4702 | |
| 4703 | if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) { |
| 4704 | // Don't move modal's DOM position |
| 4705 | document.body.append(this._element); |
| 4706 | } |
| 4707 | |
| 4708 | this._element.style.display = 'block'; |
| 4709 | |
| 4710 | this._element.removeAttribute('aria-hidden'); |
| 4711 | |
| 4712 | this._element.setAttribute('aria-modal', true); |
| 4713 | |
| 4714 | this._element.setAttribute('role', 'dialog'); |
| 4715 | |
| 4716 | this._element.scrollTop = 0; |
| 4717 | |
| 4718 | if (modalBody) { |
| 4719 | modalBody.scrollTop = 0; |
| 4720 | } |
| 4721 | |
| 4722 | if (isAnimated) { |
| 4723 | reflow(this._element); |
| 4724 | } |
| 4725 | |
| 4726 | this._element.classList.add(CLASS_NAME_SHOW$4); |
| 4727 | |
| 4728 | const transitionComplete = () => { |
| 4729 | if (this._config.focus) { |
| 4730 | this._focustrap.activate(); |
| 4731 | } |
| 4732 | |
| 4733 | this._isTransitioning = false; |
| 4734 | EventHandler.trigger(this._element, EVENT_SHOWN$3, { |
| 4735 | relatedTarget |
| 4736 | }); |
| 4737 | }; |
| 4738 | |
| 4739 | this._queueCallback(transitionComplete, this._dialog, isAnimated); |
| 4740 | } |
| 4741 | |
| 4742 | _setEscapeEvent() { |
| 4743 | if (this._isShown) { |
| 4744 | EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS$1, event => { |
| 4745 | if (this._config.keyboard && event.key === ESCAPE_KEY$1) { |
| 4746 | event.preventDefault(); |
| 4747 | this.hide(); |
| 4748 | } else if (!this._config.keyboard && event.key === ESCAPE_KEY$1) { |
| 4749 | this._triggerBackdropTransition(); |
| 4750 | } |
| 4751 | }); |
| 4752 | } else { |
| 4753 | EventHandler.off(this._element, EVENT_KEYDOWN_DISMISS$1); |
| 4754 | } |
| 4755 | } |
| 4756 | |
| 4757 | _setResizeEvent() { |
| 4758 | if (this._isShown) { |
| 4759 | EventHandler.on(window, EVENT_RESIZE, () => this._adjustDialog()); |
| 4760 | } else { |
| 4761 | EventHandler.off(window, EVENT_RESIZE); |
| 4762 | } |
| 4763 | } |
| 4764 | |
| 4765 | _hideModal() { |
| 4766 | this._element.style.display = 'none'; |
| 4767 | |
| 4768 | this._element.setAttribute('aria-hidden', true); |
| 4769 | |
| 4770 | this._element.removeAttribute('aria-modal'); |
| 4771 | |
| 4772 | this._element.removeAttribute('role'); |
| 4773 | |
| 4774 | this._isTransitioning = false; |
| 4775 | |
| 4776 | this._backdrop.hide(() => { |
| 4777 | document.body.classList.remove(CLASS_NAME_OPEN); |
| 4778 | |
| 4779 | this._resetAdjustments(); |
| 4780 | |
| 4781 | this._scrollBar.reset(); |
| 4782 | |
| 4783 | EventHandler.trigger(this._element, EVENT_HIDDEN$3); |
| 4784 | }); |
| 4785 | } |
| 4786 | |
| 4787 | _showBackdrop(callback) { |
| 4788 | EventHandler.on(this._element, EVENT_CLICK_DISMISS, event => { |
| 4789 | if (this._ignoreBackdropClick) { |
| 4790 | this._ignoreBackdropClick = false; |
| 4791 | return; |
| 4792 | } |
| 4793 | |
| 4794 | if (event.target !== event.currentTarget) { |
| 4795 | return; |
| 4796 | } |
| 4797 | |
| 4798 | if (this._config.backdrop === true) { |
| 4799 | this.hide(); |
| 4800 | } else if (this._config.backdrop === 'static') { |
| 4801 | this._triggerBackdropTransition(); |
| 4802 | } |
| 4803 | }); |
| 4804 | |
| 4805 | this._backdrop.show(callback); |
| 4806 | } |
| 4807 | |
| 4808 | _isAnimated() { |
| 4809 | return this._element.classList.contains(CLASS_NAME_FADE$3); |
| 4810 | } |
| 4811 | |
| 4812 | _triggerBackdropTransition() { |
| 4813 | const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED); |
| 4814 | |
| 4815 | if (hideEvent.defaultPrevented) { |
| 4816 | return; |
| 4817 | } |
| 4818 | |
| 4819 | const { |
| 4820 | classList, |
| 4821 | scrollHeight, |
| 4822 | style |
| 4823 | } = this._element; |
| 4824 | const isModalOverflowing = scrollHeight > document.documentElement.clientHeight; // return if the following background transition hasn't yet completed |
| 4825 | |
| 4826 | if (!isModalOverflowing && style.overflowY === 'hidden' || classList.contains(CLASS_NAME_STATIC)) { |
| 4827 | return; |
| 4828 | } |
| 4829 | |
| 4830 | if (!isModalOverflowing) { |
| 4831 | style.overflowY = 'hidden'; |
| 4832 | } |
| 4833 | |
| 4834 | classList.add(CLASS_NAME_STATIC); |
| 4835 | |
| 4836 | this._queueCallback(() => { |
| 4837 | classList.remove(CLASS_NAME_STATIC); |
| 4838 | |
| 4839 | if (!isModalOverflowing) { |
| 4840 | this._queueCallback(() => { |
| 4841 | style.overflowY = ''; |
| 4842 | }, this._dialog); |
| 4843 | } |
| 4844 | }, this._dialog); |
| 4845 | |
| 4846 | this._element.focus(); |
| 4847 | } // ---------------------------------------------------------------------- |
| 4848 | // the following methods are used to handle overflowing modals |
| 4849 | // ---------------------------------------------------------------------- |
| 4850 | |
| 4851 | |
| 4852 | _adjustDialog() { |
| 4853 | const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight; |
| 4854 | |
| 4855 | const scrollbarWidth = this._scrollBar.getWidth(); |
| 4856 | |
| 4857 | const isBodyOverflowing = scrollbarWidth > 0; |
| 4858 | |
| 4859 | if (!isBodyOverflowing && isModalOverflowing && !isRTL() || isBodyOverflowing && !isModalOverflowing && isRTL()) { |
| 4860 | this._element.style.paddingLeft = `${scrollbarWidth}px`; |
| 4861 | } |
| 4862 | |
| 4863 | if (isBodyOverflowing && !isModalOverflowing && !isRTL() || !isBodyOverflowing && isModalOverflowing && isRTL()) { |
| 4864 | this._element.style.paddingRight = `${scrollbarWidth}px`; |
| 4865 | } |
| 4866 | } |
| 4867 | |
| 4868 | _resetAdjustments() { |
| 4869 | this._element.style.paddingLeft = ''; |
| 4870 | this._element.style.paddingRight = ''; |
| 4871 | } // Static |
| 4872 | |
| 4873 | |
| 4874 | static jQueryInterface(config, relatedTarget) { |
| 4875 | return this.each(function () { |
| 4876 | const data = Modal.getOrCreateInstance(this, config); |
| 4877 | |
| 4878 | if (typeof config !== 'string') { |
| 4879 | return; |
| 4880 | } |
| 4881 | |
| 4882 | if (typeof data[config] === 'undefined') { |
| 4883 | throw new TypeError(`No method named "${config}"`); |
| 4884 | } |
| 4885 | |
| 4886 | data[config](relatedTarget); |
| 4887 | }); |
| 4888 | } |
| 4889 | |
| 4890 | } |
| 4891 | /** |
| 4892 | * ------------------------------------------------------------------------ |
| 4893 | * Data Api implementation |
| 4894 | * ------------------------------------------------------------------------ |
| 4895 | */ |
| 4896 | |
| 4897 | |
| 4898 | EventHandler.on(document, EVENT_CLICK_DATA_API$2, SELECTOR_DATA_TOGGLE$2, function (event) { |
| 4899 | const target = getElementFromSelector(this); |
| 4900 | |
| 4901 | if (['A', 'AREA'].includes(this.tagName)) { |
| 4902 | event.preventDefault(); |
| 4903 | } |
| 4904 | |
| 4905 | EventHandler.one(target, EVENT_SHOW$3, showEvent => { |
| 4906 | if (showEvent.defaultPrevented) { |
| 4907 | // only register focus restorer if modal will actually get shown |
| 4908 | return; |
| 4909 | } |
| 4910 | |
| 4911 | EventHandler.one(target, EVENT_HIDDEN$3, () => { |
| 4912 | if (isVisible(this)) { |
| 4913 | this.focus(); |
| 4914 | } |
| 4915 | }); |
| 4916 | }); // avoid conflict when clicking moddal toggler while another one is open |
| 4917 | |
| 4918 | const allReadyOpen = SelectorEngine.findOne(OPEN_SELECTOR$1); |
| 4919 | |
| 4920 | if (allReadyOpen) { |
| 4921 | Modal.getInstance(allReadyOpen).hide(); |
| 4922 | } |
| 4923 | |
| 4924 | const data = Modal.getOrCreateInstance(target); |
| 4925 | data.toggle(this); |
| 4926 | }); |
| 4927 | enableDismissTrigger(Modal); |
| 4928 | /** |
| 4929 | * ------------------------------------------------------------------------ |
| 4930 | * jQuery |
| 4931 | * ------------------------------------------------------------------------ |
| 4932 | * add .Modal to jQuery only if jQuery is present |
| 4933 | */ |
| 4934 | |
| 4935 | defineJQueryPlugin(Modal); |
| 4936 | |
| 4937 | /** |
| 4938 | * -------------------------------------------------------------------------- |
| 4939 | * Bootstrap (v5.1.3): offcanvas.js |
| 4940 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 4941 | * -------------------------------------------------------------------------- |
| 4942 | */ |
| 4943 | /** |
| 4944 | * ------------------------------------------------------------------------ |
| 4945 | * Constants |
| 4946 | * ------------------------------------------------------------------------ |
| 4947 | */ |
| 4948 | |
| 4949 | const NAME$5 = 'offcanvas'; |
| 4950 | const DATA_KEY$5 = 'bs.offcanvas'; |
| 4951 | const EVENT_KEY$5 = `.${DATA_KEY$5}`; |
| 4952 | const DATA_API_KEY$2 = '.data-api'; |
| 4953 | const EVENT_LOAD_DATA_API$1 = `load${EVENT_KEY$5}${DATA_API_KEY$2}`; |
| 4954 | const ESCAPE_KEY = 'Escape'; |
| 4955 | const Default$4 = { |
| 4956 | backdrop: true, |
| 4957 | keyboard: true, |
| 4958 | scroll: false |
| 4959 | }; |
| 4960 | const DefaultType$4 = { |
| 4961 | backdrop: 'boolean', |
| 4962 | keyboard: 'boolean', |
| 4963 | scroll: 'boolean' |
| 4964 | }; |
| 4965 | const CLASS_NAME_SHOW$3 = 'show'; |
| 4966 | const CLASS_NAME_BACKDROP = 'offcanvas-backdrop'; |
| 4967 | const OPEN_SELECTOR = '.offcanvas.show'; |
| 4968 | const EVENT_SHOW$2 = `show${EVENT_KEY$5}`; |
| 4969 | const EVENT_SHOWN$2 = `shown${EVENT_KEY$5}`; |
| 4970 | const EVENT_HIDE$2 = `hide${EVENT_KEY$5}`; |
| 4971 | const EVENT_HIDDEN$2 = `hidden${EVENT_KEY$5}`; |
| 4972 | const EVENT_CLICK_DATA_API$1 = `click${EVENT_KEY$5}${DATA_API_KEY$2}`; |
| 4973 | const EVENT_KEYDOWN_DISMISS = `keydown.dismiss${EVENT_KEY$5}`; |
| 4974 | const SELECTOR_DATA_TOGGLE$1 = '[data-bs-toggle="offcanvas"]'; |
| 4975 | /** |
| 4976 | * ------------------------------------------------------------------------ |
| 4977 | * Class Definition |
| 4978 | * ------------------------------------------------------------------------ |
| 4979 | */ |
| 4980 | |
| 4981 | class Offcanvas extends BaseComponent { |
| 4982 | constructor(element, config) { |
| 4983 | super(element); |
| 4984 | this._config = this._getConfig(config); |
| 4985 | this._isShown = false; |
| 4986 | this._backdrop = this._initializeBackDrop(); |
| 4987 | this._focustrap = this._initializeFocusTrap(); |
| 4988 | |
| 4989 | this._addEventListeners(); |
| 4990 | } // Getters |
| 4991 | |
| 4992 | |
| 4993 | static get NAME() { |
| 4994 | return NAME$5; |
| 4995 | } |
| 4996 | |
| 4997 | static get Default() { |
| 4998 | return Default$4; |
| 4999 | } // Public |
| 5000 | |
| 5001 | |
| 5002 | toggle(relatedTarget) { |
| 5003 | return this._isShown ? this.hide() : this.show(relatedTarget); |
| 5004 | } |
| 5005 | |
| 5006 | show(relatedTarget) { |
| 5007 | if (this._isShown) { |
| 5008 | return; |
| 5009 | } |
| 5010 | |
| 5011 | const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$2, { |
| 5012 | relatedTarget |
| 5013 | }); |
| 5014 | |
| 5015 | if (showEvent.defaultPrevented) { |
| 5016 | return; |
| 5017 | } |
| 5018 | |
| 5019 | this._isShown = true; |
| 5020 | this._element.style.visibility = 'visible'; |
| 5021 | |
| 5022 | this._backdrop.show(); |
| 5023 | |
| 5024 | if (!this._config.scroll) { |
| 5025 | new ScrollBarHelper().hide(); |
| 5026 | } |
| 5027 | |
| 5028 | this._element.removeAttribute('aria-hidden'); |
| 5029 | |
| 5030 | this._element.setAttribute('aria-modal', true); |
| 5031 | |
| 5032 | this._element.setAttribute('role', 'dialog'); |
| 5033 | |
| 5034 | this._element.classList.add(CLASS_NAME_SHOW$3); |
| 5035 | |
| 5036 | const completeCallBack = () => { |
| 5037 | if (!this._config.scroll) { |
| 5038 | this._focustrap.activate(); |
| 5039 | } |
| 5040 | |
| 5041 | EventHandler.trigger(this._element, EVENT_SHOWN$2, { |
| 5042 | relatedTarget |
| 5043 | }); |
| 5044 | }; |
| 5045 | |
| 5046 | this._queueCallback(completeCallBack, this._element, true); |
| 5047 | } |
| 5048 | |
| 5049 | hide() { |
| 5050 | if (!this._isShown) { |
| 5051 | return; |
| 5052 | } |
| 5053 | |
| 5054 | const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$2); |
| 5055 | |
| 5056 | if (hideEvent.defaultPrevented) { |
| 5057 | return; |
| 5058 | } |
| 5059 | |
| 5060 | this._focustrap.deactivate(); |
| 5061 | |
| 5062 | this._element.blur(); |
| 5063 | |
| 5064 | this._isShown = false; |
| 5065 | |
| 5066 | this._element.classList.remove(CLASS_NAME_SHOW$3); |
| 5067 | |
| 5068 | this._backdrop.hide(); |
| 5069 | |
| 5070 | const completeCallback = () => { |
| 5071 | this._element.setAttribute('aria-hidden', true); |
| 5072 | |
| 5073 | this._element.removeAttribute('aria-modal'); |
| 5074 | |
| 5075 | this._element.removeAttribute('role'); |
| 5076 | |
| 5077 | this._element.style.visibility = 'hidden'; |
| 5078 | |
| 5079 | if (!this._config.scroll) { |
| 5080 | new ScrollBarHelper().reset(); |
| 5081 | } |
| 5082 | |
| 5083 | EventHandler.trigger(this._element, EVENT_HIDDEN$2); |
| 5084 | }; |
| 5085 | |
| 5086 | this._queueCallback(completeCallback, this._element, true); |
| 5087 | } |
| 5088 | |
| 5089 | dispose() { |
| 5090 | this._backdrop.dispose(); |
| 5091 | |
| 5092 | this._focustrap.deactivate(); |
| 5093 | |
| 5094 | super.dispose(); |
| 5095 | } // Private |
| 5096 | |
| 5097 | |
| 5098 | _getConfig(config) { |
| 5099 | config = { ...Default$4, |
| 5100 | ...Manipulator.getDataAttributes(this._element), |
| 5101 | ...(typeof config === 'object' ? config : {}) |
| 5102 | }; |
| 5103 | typeCheckConfig(NAME$5, config, DefaultType$4); |
| 5104 | return config; |
| 5105 | } |
| 5106 | |
| 5107 | _initializeBackDrop() { |
| 5108 | return new Backdrop({ |
| 5109 | className: CLASS_NAME_BACKDROP, |
| 5110 | isVisible: this._config.backdrop, |
| 5111 | isAnimated: true, |
| 5112 | rootElement: this._element.parentNode, |
| 5113 | clickCallback: () => this.hide() |
| 5114 | }); |
| 5115 | } |
| 5116 | |
| 5117 | _initializeFocusTrap() { |
| 5118 | return new FocusTrap({ |
| 5119 | trapElement: this._element |
| 5120 | }); |
| 5121 | } |
| 5122 | |
| 5123 | _addEventListeners() { |
| 5124 | EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS, event => { |
| 5125 | if (this._config.keyboard && event.key === ESCAPE_KEY) { |
| 5126 | this.hide(); |
| 5127 | } |
| 5128 | }); |
| 5129 | } // Static |
| 5130 | |
| 5131 | |
| 5132 | static jQueryInterface(config) { |
| 5133 | return this.each(function () { |
| 5134 | const data = Offcanvas.getOrCreateInstance(this, config); |
| 5135 | |
| 5136 | if (typeof config !== 'string') { |
| 5137 | return; |
| 5138 | } |
| 5139 | |
| 5140 | if (data[config] === undefined || config.startsWith('_') || config === 'constructor') { |
| 5141 | throw new TypeError(`No method named "${config}"`); |
| 5142 | } |
| 5143 | |
| 5144 | data[config](this); |
| 5145 | }); |
| 5146 | } |
| 5147 | |
| 5148 | } |
| 5149 | /** |
| 5150 | * ------------------------------------------------------------------------ |
| 5151 | * Data Api implementation |
| 5152 | * ------------------------------------------------------------------------ |
| 5153 | */ |
| 5154 | |
| 5155 | |
| 5156 | EventHandler.on(document, EVENT_CLICK_DATA_API$1, SELECTOR_DATA_TOGGLE$1, function (event) { |
| 5157 | const target = getElementFromSelector(this); |
| 5158 | |
| 5159 | if (['A', 'AREA'].includes(this.tagName)) { |
| 5160 | event.preventDefault(); |
| 5161 | } |
| 5162 | |
| 5163 | if (isDisabled(this)) { |
| 5164 | return; |
| 5165 | } |
| 5166 | |
| 5167 | EventHandler.one(target, EVENT_HIDDEN$2, () => { |
| 5168 | // focus on trigger when it is closed |
| 5169 | if (isVisible(this)) { |
| 5170 | this.focus(); |
| 5171 | } |
| 5172 | }); // avoid conflict when clicking a toggler of an offcanvas, while another is open |
| 5173 | |
| 5174 | const allReadyOpen = SelectorEngine.findOne(OPEN_SELECTOR); |
| 5175 | |
| 5176 | if (allReadyOpen && allReadyOpen !== target) { |
| 5177 | Offcanvas.getInstance(allReadyOpen).hide(); |
| 5178 | } |
| 5179 | |
| 5180 | const data = Offcanvas.getOrCreateInstance(target); |
| 5181 | data.toggle(this); |
| 5182 | }); |
| 5183 | EventHandler.on(window, EVENT_LOAD_DATA_API$1, () => SelectorEngine.find(OPEN_SELECTOR).forEach(el => Offcanvas.getOrCreateInstance(el).show())); |
| 5184 | enableDismissTrigger(Offcanvas); |
| 5185 | /** |
| 5186 | * ------------------------------------------------------------------------ |
| 5187 | * jQuery |
| 5188 | * ------------------------------------------------------------------------ |
| 5189 | */ |
| 5190 | |
| 5191 | defineJQueryPlugin(Offcanvas); |
| 5192 | |
| 5193 | /** |
| 5194 | * -------------------------------------------------------------------------- |
| 5195 | * Bootstrap (v5.1.3): util/sanitizer.js |
| 5196 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 5197 | * -------------------------------------------------------------------------- |
| 5198 | */ |
| 5199 | const uriAttributes = new Set(['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href']); |
| 5200 | const ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i; |
| 5201 | /** |
| 5202 | * A pattern that recognizes a commonly useful subset of URLs that are safe. |
| 5203 | * |
| 5204 | * Shoutout to Angular https://github.com/angular/angular/blob/12.2.x/packages/core/src/sanitization/url_sanitizer.ts |
| 5205 | */ |
| 5206 | |
| 5207 | const SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file|sms):|[^#&/:?]*(?:[#/?]|$))/i; |
| 5208 | /** |
| 5209 | * A pattern that matches safe data URLs. Only matches image, video and audio types. |
| 5210 | * |
| 5211 | * Shoutout to Angular https://github.com/angular/angular/blob/12.2.x/packages/core/src/sanitization/url_sanitizer.ts |
| 5212 | */ |
| 5213 | |
| 5214 | const DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[\d+/a-z]+=*$/i; |
| 5215 | |
| 5216 | const allowedAttribute = (attribute, allowedAttributeList) => { |
| 5217 | const attributeName = attribute.nodeName.toLowerCase(); |
| 5218 | |
| 5219 | if (allowedAttributeList.includes(attributeName)) { |
| 5220 | if (uriAttributes.has(attributeName)) { |
| 5221 | return Boolean(SAFE_URL_PATTERN.test(attribute.nodeValue) || DATA_URL_PATTERN.test(attribute.nodeValue)); |
| 5222 | } |
| 5223 | |
| 5224 | return true; |
| 5225 | } |
| 5226 | |
| 5227 | const regExp = allowedAttributeList.filter(attributeRegex => attributeRegex instanceof RegExp); // Check if a regular expression validates the attribute. |
| 5228 | |
| 5229 | for (let i = 0, len = regExp.length; i < len; i++) { |
| 5230 | if (regExp[i].test(attributeName)) { |
| 5231 | return true; |
| 5232 | } |
| 5233 | } |
| 5234 | |
| 5235 | return false; |
| 5236 | }; |
| 5237 | |
| 5238 | const DefaultAllowlist = { |
| 5239 | // Global attributes allowed on any supplied element below. |
| 5240 | '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN], |
| 5241 | a: ['target', 'href', 'title', 'rel'], |
| 5242 | area: [], |
| 5243 | b: [], |
| 5244 | br: [], |
| 5245 | col: [], |
| 5246 | code: [], |
| 5247 | div: [], |
| 5248 | em: [], |
| 5249 | hr: [], |
| 5250 | h1: [], |
| 5251 | h2: [], |
| 5252 | h3: [], |
| 5253 | h4: [], |
| 5254 | h5: [], |
| 5255 | h6: [], |
| 5256 | i: [], |
| 5257 | img: ['src', 'srcset', 'alt', 'title', 'width', 'height'], |
| 5258 | li: [], |
| 5259 | ol: [], |
| 5260 | p: [], |
| 5261 | pre: [], |
| 5262 | s: [], |
| 5263 | small: [], |
| 5264 | span: [], |
| 5265 | sub: [], |
| 5266 | sup: [], |
| 5267 | strong: [], |
| 5268 | u: [], |
| 5269 | ul: [] |
| 5270 | }; |
| 5271 | function sanitizeHtml(unsafeHtml, allowList, sanitizeFn) { |
| 5272 | if (!unsafeHtml.length) { |
| 5273 | return unsafeHtml; |
| 5274 | } |
| 5275 | |
| 5276 | if (sanitizeFn && typeof sanitizeFn === 'function') { |
| 5277 | return sanitizeFn(unsafeHtml); |
| 5278 | } |
| 5279 | |
| 5280 | const domParser = new window.DOMParser(); |
| 5281 | const createdDocument = domParser.parseFromString(unsafeHtml, 'text/html'); |
| 5282 | const elements = [].concat(...createdDocument.body.querySelectorAll('*')); |
| 5283 | |
| 5284 | for (let i = 0, len = elements.length; i < len; i++) { |
| 5285 | const element = elements[i]; |
| 5286 | const elementName = element.nodeName.toLowerCase(); |
| 5287 | |
| 5288 | if (!Object.keys(allowList).includes(elementName)) { |
| 5289 | element.remove(); |
| 5290 | continue; |
| 5291 | } |
| 5292 | |
| 5293 | const attributeList = [].concat(...element.attributes); |
| 5294 | const allowedAttributes = [].concat(allowList['*'] || [], allowList[elementName] || []); |
| 5295 | attributeList.forEach(attribute => { |
| 5296 | if (!allowedAttribute(attribute, allowedAttributes)) { |
| 5297 | element.removeAttribute(attribute.nodeName); |
| 5298 | } |
| 5299 | }); |
| 5300 | } |
| 5301 | |
| 5302 | return createdDocument.body.innerHTML; |
| 5303 | } |
| 5304 | |
| 5305 | /** |
| 5306 | * -------------------------------------------------------------------------- |
| 5307 | * Bootstrap (v5.1.3): tooltip.js |
| 5308 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 5309 | * -------------------------------------------------------------------------- |
| 5310 | */ |
| 5311 | /** |
| 5312 | * ------------------------------------------------------------------------ |
| 5313 | * Constants |
| 5314 | * ------------------------------------------------------------------------ |
| 5315 | */ |
| 5316 | |
| 5317 | const NAME$4 = 'tooltip'; |
| 5318 | const DATA_KEY$4 = 'bs.tooltip'; |
| 5319 | const EVENT_KEY$4 = `.${DATA_KEY$4}`; |
| 5320 | const CLASS_PREFIX$1 = 'bs-tooltip'; |
| 5321 | const DISALLOWED_ATTRIBUTES = new Set(['sanitize', 'allowList', 'sanitizeFn']); |
| 5322 | const DefaultType$3 = { |
| 5323 | animation: 'boolean', |
| 5324 | template: 'string', |
| 5325 | title: '(string|element|function)', |
| 5326 | trigger: 'string', |
| 5327 | delay: '(number|object)', |
| 5328 | html: 'boolean', |
| 5329 | selector: '(string|boolean)', |
| 5330 | placement: '(string|function)', |
| 5331 | offset: '(array|string|function)', |
| 5332 | container: '(string|element|boolean)', |
| 5333 | fallbackPlacements: 'array', |
| 5334 | boundary: '(string|element)', |
| 5335 | customClass: '(string|function)', |
| 5336 | sanitize: 'boolean', |
| 5337 | sanitizeFn: '(null|function)', |
| 5338 | allowList: 'object', |
| 5339 | popperConfig: '(null|object|function)' |
| 5340 | }; |
| 5341 | const AttachmentMap = { |
| 5342 | AUTO: 'auto', |
| 5343 | TOP: 'top', |
| 5344 | RIGHT: isRTL() ? 'left' : 'right', |
| 5345 | BOTTOM: 'bottom', |
| 5346 | LEFT: isRTL() ? 'right' : 'left' |
| 5347 | }; |
| 5348 | const Default$3 = { |
| 5349 | animation: true, |
| 5350 | template: '<div class="tooltip" role="tooltip">' + '<div class="tooltip-arrow"></div>' + '<div class="tooltip-inner"></div>' + '</div>', |
| 5351 | trigger: 'hover focus', |
| 5352 | title: '', |
| 5353 | delay: 0, |
| 5354 | html: false, |
| 5355 | selector: false, |
| 5356 | placement: 'top', |
| 5357 | offset: [0, 0], |
| 5358 | container: false, |
| 5359 | fallbackPlacements: ['top', 'right', 'bottom', 'left'], |
| 5360 | boundary: 'clippingParents', |
| 5361 | customClass: '', |
| 5362 | sanitize: true, |
| 5363 | sanitizeFn: null, |
| 5364 | allowList: DefaultAllowlist, |
| 5365 | popperConfig: null |
| 5366 | }; |
| 5367 | const Event$2 = { |
| 5368 | HIDE: `hide${EVENT_KEY$4}`, |
| 5369 | HIDDEN: `hidden${EVENT_KEY$4}`, |
| 5370 | SHOW: `show${EVENT_KEY$4}`, |
| 5371 | SHOWN: `shown${EVENT_KEY$4}`, |
| 5372 | INSERTED: `inserted${EVENT_KEY$4}`, |
| 5373 | CLICK: `click${EVENT_KEY$4}`, |
| 5374 | FOCUSIN: `focusin${EVENT_KEY$4}`, |
| 5375 | FOCUSOUT: `focusout${EVENT_KEY$4}`, |
| 5376 | MOUSEENTER: `mouseenter${EVENT_KEY$4}`, |
| 5377 | MOUSELEAVE: `mouseleave${EVENT_KEY$4}` |
| 5378 | }; |
| 5379 | const CLASS_NAME_FADE$2 = 'fade'; |
| 5380 | const CLASS_NAME_MODAL = 'modal'; |
| 5381 | const CLASS_NAME_SHOW$2 = 'show'; |
| 5382 | const HOVER_STATE_SHOW = 'show'; |
| 5383 | const HOVER_STATE_OUT = 'out'; |
| 5384 | const SELECTOR_TOOLTIP_INNER = '.tooltip-inner'; |
| 5385 | const SELECTOR_MODAL = `.${CLASS_NAME_MODAL}`; |
| 5386 | const EVENT_MODAL_HIDE = 'hide.bs.modal'; |
| 5387 | const TRIGGER_HOVER = 'hover'; |
| 5388 | const TRIGGER_FOCUS = 'focus'; |
| 5389 | const TRIGGER_CLICK = 'click'; |
| 5390 | const TRIGGER_MANUAL = 'manual'; |
| 5391 | /** |
| 5392 | * ------------------------------------------------------------------------ |
| 5393 | * Class Definition |
| 5394 | * ------------------------------------------------------------------------ |
| 5395 | */ |
| 5396 | |
| 5397 | class Tooltip extends BaseComponent { |
| 5398 | constructor(element, config) { |
| 5399 | if (typeof Popper === 'undefined') { |
| 5400 | throw new TypeError('Bootstrap\'s tooltips require Popper (https://popper.js.org)'); |
| 5401 | } |
| 5402 | |
| 5403 | super(element); // private |
| 5404 | |
| 5405 | this._isEnabled = true; |
| 5406 | this._timeout = 0; |
| 5407 | this._hoverState = ''; |
| 5408 | this._activeTrigger = {}; |
| 5409 | this._popper = null; // Protected |
| 5410 | |
| 5411 | this._config = this._getConfig(config); |
| 5412 | this.tip = null; |
| 5413 | |
| 5414 | this._setListeners(); |
| 5415 | } // Getters |
| 5416 | |
| 5417 | |
| 5418 | static get Default() { |
| 5419 | return Default$3; |
| 5420 | } |
| 5421 | |
| 5422 | static get NAME() { |
| 5423 | return NAME$4; |
| 5424 | } |
| 5425 | |
| 5426 | static get Event() { |
| 5427 | return Event$2; |
| 5428 | } |
| 5429 | |
| 5430 | static get DefaultType() { |
| 5431 | return DefaultType$3; |
| 5432 | } // Public |
| 5433 | |
| 5434 | |
| 5435 | enable() { |
| 5436 | this._isEnabled = true; |
| 5437 | } |
| 5438 | |
| 5439 | disable() { |
| 5440 | this._isEnabled = false; |
| 5441 | } |
| 5442 | |
| 5443 | toggleEnabled() { |
| 5444 | this._isEnabled = !this._isEnabled; |
| 5445 | } |
| 5446 | |
| 5447 | toggle(event) { |
| 5448 | if (!this._isEnabled) { |
| 5449 | return; |
| 5450 | } |
| 5451 | |
| 5452 | if (event) { |
| 5453 | const context = this._initializeOnDelegatedTarget(event); |
| 5454 | |
| 5455 | context._activeTrigger.click = !context._activeTrigger.click; |
| 5456 | |
| 5457 | if (context._isWithActiveTrigger()) { |
| 5458 | context._enter(null, context); |
| 5459 | } else { |
| 5460 | context._leave(null, context); |
| 5461 | } |
| 5462 | } else { |
| 5463 | if (this.getTipElement().classList.contains(CLASS_NAME_SHOW$2)) { |
| 5464 | this._leave(null, this); |
| 5465 | |
| 5466 | return; |
| 5467 | } |
| 5468 | |
| 5469 | this._enter(null, this); |
| 5470 | } |
| 5471 | } |
| 5472 | |
| 5473 | dispose() { |
| 5474 | clearTimeout(this._timeout); |
| 5475 | EventHandler.off(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler); |
| 5476 | |
| 5477 | if (this.tip) { |
| 5478 | this.tip.remove(); |
| 5479 | } |
| 5480 | |
| 5481 | this._disposePopper(); |
| 5482 | |
| 5483 | super.dispose(); |
| 5484 | } |
| 5485 | |
| 5486 | show() { |
| 5487 | if (this._element.style.display === 'none') { |
| 5488 | throw new Error('Please use show on visible elements'); |
| 5489 | } |
| 5490 | |
| 5491 | if (!(this.isWithContent() && this._isEnabled)) { |
| 5492 | return; |
| 5493 | } |
| 5494 | |
| 5495 | const showEvent = EventHandler.trigger(this._element, this.constructor.Event.SHOW); |
| 5496 | const shadowRoot = findShadowRoot(this._element); |
| 5497 | const isInTheDom = shadowRoot === null ? this._element.ownerDocument.documentElement.contains(this._element) : shadowRoot.contains(this._element); |
| 5498 | |
| 5499 | if (showEvent.defaultPrevented || !isInTheDom) { |
| 5500 | return; |
| 5501 | } // A trick to recreate a tooltip in case a new title is given by using the NOT documented `data-bs-original-title` |
| 5502 | // This will be removed later in favor of a `setContent` method |
| 5503 | |
| 5504 | |
| 5505 | if (this.constructor.NAME === 'tooltip' && this.tip && this.getTitle() !== this.tip.querySelector(SELECTOR_TOOLTIP_INNER).innerHTML) { |
| 5506 | this._disposePopper(); |
| 5507 | |
| 5508 | this.tip.remove(); |
| 5509 | this.tip = null; |
| 5510 | } |
| 5511 | |
| 5512 | const tip = this.getTipElement(); |
| 5513 | const tipId = getUID(this.constructor.NAME); |
| 5514 | tip.setAttribute('id', tipId); |
| 5515 | |
| 5516 | this._element.setAttribute('aria-describedby', tipId); |
| 5517 | |
| 5518 | if (this._config.animation) { |
| 5519 | tip.classList.add(CLASS_NAME_FADE$2); |
| 5520 | } |
| 5521 | |
| 5522 | const placement = typeof this._config.placement === 'function' ? this._config.placement.call(this, tip, this._element) : this._config.placement; |
| 5523 | |
| 5524 | const attachment = this._getAttachment(placement); |
| 5525 | |
| 5526 | this._addAttachmentClass(attachment); |
| 5527 | |
| 5528 | const { |
| 5529 | container |
| 5530 | } = this._config; |
| 5531 | Data.set(tip, this.constructor.DATA_KEY, this); |
| 5532 | |
| 5533 | if (!this._element.ownerDocument.documentElement.contains(this.tip)) { |
| 5534 | container.append(tip); |
| 5535 | EventHandler.trigger(this._element, this.constructor.Event.INSERTED); |
| 5536 | } |
| 5537 | |
| 5538 | if (this._popper) { |
| 5539 | this._popper.update(); |
| 5540 | } else { |
| 5541 | this._popper = createPopper(this._element, tip, this._getPopperConfig(attachment)); |
| 5542 | } |
| 5543 | |
| 5544 | tip.classList.add(CLASS_NAME_SHOW$2); |
| 5545 | |
| 5546 | const customClass = this._resolvePossibleFunction(this._config.customClass); |
| 5547 | |
| 5548 | if (customClass) { |
| 5549 | tip.classList.add(...customClass.split(' ')); |
| 5550 | } // If this is a touch-enabled device we add extra |
| 5551 | // empty mouseover listeners to the body's immediate children; |
| 5552 | // only needed because of broken event delegation on iOS |
| 5553 | // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html |
| 5554 | |
| 5555 | |
| 5556 | if ('ontouchstart' in document.documentElement) { |
| 5557 | [].concat(...document.body.children).forEach(element => { |
| 5558 | EventHandler.on(element, 'mouseover', noop); |
| 5559 | }); |
| 5560 | } |
| 5561 | |
| 5562 | const complete = () => { |
| 5563 | const prevHoverState = this._hoverState; |
| 5564 | this._hoverState = null; |
| 5565 | EventHandler.trigger(this._element, this.constructor.Event.SHOWN); |
| 5566 | |
| 5567 | if (prevHoverState === HOVER_STATE_OUT) { |
| 5568 | this._leave(null, this); |
| 5569 | } |
| 5570 | }; |
| 5571 | |
| 5572 | const isAnimated = this.tip.classList.contains(CLASS_NAME_FADE$2); |
| 5573 | |
| 5574 | this._queueCallback(complete, this.tip, isAnimated); |
| 5575 | } |
| 5576 | |
| 5577 | hide() { |
| 5578 | if (!this._popper) { |
| 5579 | return; |
| 5580 | } |
| 5581 | |
| 5582 | const tip = this.getTipElement(); |
| 5583 | |
| 5584 | const complete = () => { |
| 5585 | if (this._isWithActiveTrigger()) { |
| 5586 | return; |
| 5587 | } |
| 5588 | |
| 5589 | if (this._hoverState !== HOVER_STATE_SHOW) { |
| 5590 | tip.remove(); |
| 5591 | } |
| 5592 | |
| 5593 | this._cleanTipClass(); |
| 5594 | |
| 5595 | this._element.removeAttribute('aria-describedby'); |
| 5596 | |
| 5597 | EventHandler.trigger(this._element, this.constructor.Event.HIDDEN); |
| 5598 | |
| 5599 | this._disposePopper(); |
| 5600 | }; |
| 5601 | |
| 5602 | const hideEvent = EventHandler.trigger(this._element, this.constructor.Event.HIDE); |
| 5603 | |
| 5604 | if (hideEvent.defaultPrevented) { |
| 5605 | return; |
| 5606 | } |
| 5607 | |
| 5608 | tip.classList.remove(CLASS_NAME_SHOW$2); // If this is a touch-enabled device we remove the extra |
| 5609 | // empty mouseover listeners we added for iOS support |
| 5610 | |
| 5611 | if ('ontouchstart' in document.documentElement) { |
| 5612 | [].concat(...document.body.children).forEach(element => EventHandler.off(element, 'mouseover', noop)); |
| 5613 | } |
| 5614 | |
| 5615 | this._activeTrigger[TRIGGER_CLICK] = false; |
| 5616 | this._activeTrigger[TRIGGER_FOCUS] = false; |
| 5617 | this._activeTrigger[TRIGGER_HOVER] = false; |
| 5618 | const isAnimated = this.tip.classList.contains(CLASS_NAME_FADE$2); |
| 5619 | |
| 5620 | this._queueCallback(complete, this.tip, isAnimated); |
| 5621 | |
| 5622 | this._hoverState = ''; |
| 5623 | } |
| 5624 | |
| 5625 | update() { |
| 5626 | if (this._popper !== null) { |
| 5627 | this._popper.update(); |
| 5628 | } |
| 5629 | } // Protected |
| 5630 | |
| 5631 | |
| 5632 | isWithContent() { |
| 5633 | return Boolean(this.getTitle()); |
| 5634 | } |
| 5635 | |
| 5636 | getTipElement() { |
| 5637 | if (this.tip) { |
| 5638 | return this.tip; |
| 5639 | } |
| 5640 | |
| 5641 | const element = document.createElement('div'); |
| 5642 | element.innerHTML = this._config.template; |
| 5643 | const tip = element.children[0]; |
| 5644 | this.setContent(tip); |
| 5645 | tip.classList.remove(CLASS_NAME_FADE$2, CLASS_NAME_SHOW$2); |
| 5646 | this.tip = tip; |
| 5647 | return this.tip; |
| 5648 | } |
| 5649 | |
| 5650 | setContent(tip) { |
| 5651 | this._sanitizeAndSetContent(tip, this.getTitle(), SELECTOR_TOOLTIP_INNER); |
| 5652 | } |
| 5653 | |
| 5654 | _sanitizeAndSetContent(template, content, selector) { |
| 5655 | const templateElement = SelectorEngine.findOne(selector, template); |
| 5656 | |
| 5657 | if (!content && templateElement) { |
| 5658 | templateElement.remove(); |
| 5659 | return; |
| 5660 | } // we use append for html objects to maintain js events |
| 5661 | |
| 5662 | |
| 5663 | this.setElementContent(templateElement, content); |
| 5664 | } |
| 5665 | |
| 5666 | setElementContent(element, content) { |
| 5667 | if (element === null) { |
| 5668 | return; |
| 5669 | } |
| 5670 | |
| 5671 | if (isElement$1(content)) { |
| 5672 | content = getElement(content); // content is a DOM node or a jQuery |
| 5673 | |
| 5674 | if (this._config.html) { |
| 5675 | if (content.parentNode !== element) { |
| 5676 | element.innerHTML = ''; |
| 5677 | element.append(content); |
| 5678 | } |
| 5679 | } else { |
| 5680 | element.textContent = content.textContent; |
| 5681 | } |
| 5682 | |
| 5683 | return; |
| 5684 | } |
| 5685 | |
| 5686 | if (this._config.html) { |
| 5687 | if (this._config.sanitize) { |
| 5688 | content = sanitizeHtml(content, this._config.allowList, this._config.sanitizeFn); |
| 5689 | } |
| 5690 | |
| 5691 | element.innerHTML = content; |
| 5692 | } else { |
| 5693 | element.textContent = content; |
| 5694 | } |
| 5695 | } |
| 5696 | |
| 5697 | getTitle() { |
| 5698 | const title = this._element.getAttribute('data-bs-original-title') || this._config.title; |
| 5699 | |
| 5700 | return this._resolvePossibleFunction(title); |
| 5701 | } |
| 5702 | |
| 5703 | updateAttachment(attachment) { |
| 5704 | if (attachment === 'right') { |
| 5705 | return 'end'; |
| 5706 | } |
| 5707 | |
| 5708 | if (attachment === 'left') { |
| 5709 | return 'start'; |
| 5710 | } |
| 5711 | |
| 5712 | return attachment; |
| 5713 | } // Private |
| 5714 | |
| 5715 | |
| 5716 | _initializeOnDelegatedTarget(event, context) { |
| 5717 | return context || this.constructor.getOrCreateInstance(event.delegateTarget, this._getDelegateConfig()); |
| 5718 | } |
| 5719 | |
| 5720 | _getOffset() { |
| 5721 | const { |
| 5722 | offset |
| 5723 | } = this._config; |
| 5724 | |
| 5725 | if (typeof offset === 'string') { |
| 5726 | return offset.split(',').map(val => Number.parseInt(val, 10)); |
| 5727 | } |
| 5728 | |
| 5729 | if (typeof offset === 'function') { |
| 5730 | return popperData => offset(popperData, this._element); |
| 5731 | } |
| 5732 | |
| 5733 | return offset; |
| 5734 | } |
| 5735 | |
| 5736 | _resolvePossibleFunction(content) { |
| 5737 | return typeof content === 'function' ? content.call(this._element) : content; |
| 5738 | } |
| 5739 | |
| 5740 | _getPopperConfig(attachment) { |
| 5741 | const defaultBsPopperConfig = { |
| 5742 | placement: attachment, |
| 5743 | modifiers: [{ |
| 5744 | name: 'flip', |
| 5745 | options: { |
| 5746 | fallbackPlacements: this._config.fallbackPlacements |
| 5747 | } |
| 5748 | }, { |
| 5749 | name: 'offset', |
| 5750 | options: { |
| 5751 | offset: this._getOffset() |
| 5752 | } |
| 5753 | }, { |
| 5754 | name: 'preventOverflow', |
| 5755 | options: { |
| 5756 | boundary: this._config.boundary |
| 5757 | } |
| 5758 | }, { |
| 5759 | name: 'arrow', |
| 5760 | options: { |
| 5761 | element: `.${this.constructor.NAME}-arrow` |
| 5762 | } |
| 5763 | }, { |
| 5764 | name: 'onChange', |
| 5765 | enabled: true, |
| 5766 | phase: 'afterWrite', |
| 5767 | fn: data => this._handlePopperPlacementChange(data) |
| 5768 | }], |
| 5769 | onFirstUpdate: data => { |
| 5770 | if (data.options.placement !== data.placement) { |
| 5771 | this._handlePopperPlacementChange(data); |
| 5772 | } |
| 5773 | } |
| 5774 | }; |
| 5775 | return { ...defaultBsPopperConfig, |
| 5776 | ...(typeof this._config.popperConfig === 'function' ? this._config.popperConfig(defaultBsPopperConfig) : this._config.popperConfig) |
| 5777 | }; |
| 5778 | } |
| 5779 | |
| 5780 | _addAttachmentClass(attachment) { |
| 5781 | this.getTipElement().classList.add(`${this._getBasicClassPrefix()}-${this.updateAttachment(attachment)}`); |
| 5782 | } |
| 5783 | |
| 5784 | _getAttachment(placement) { |
| 5785 | return AttachmentMap[placement.toUpperCase()]; |
| 5786 | } |
| 5787 | |
| 5788 | _setListeners() { |
| 5789 | const triggers = this._config.trigger.split(' '); |
| 5790 | |
| 5791 | triggers.forEach(trigger => { |
| 5792 | if (trigger === 'click') { |
| 5793 | EventHandler.on(this._element, this.constructor.Event.CLICK, this._config.selector, event => this.toggle(event)); |
| 5794 | } else if (trigger !== TRIGGER_MANUAL) { |
| 5795 | const eventIn = trigger === TRIGGER_HOVER ? this.constructor.Event.MOUSEENTER : this.constructor.Event.FOCUSIN; |
| 5796 | const eventOut = trigger === TRIGGER_HOVER ? this.constructor.Event.MOUSELEAVE : this.constructor.Event.FOCUSOUT; |
| 5797 | EventHandler.on(this._element, eventIn, this._config.selector, event => this._enter(event)); |
| 5798 | EventHandler.on(this._element, eventOut, this._config.selector, event => this._leave(event)); |
| 5799 | } |
| 5800 | }); |
| 5801 | |
| 5802 | this._hideModalHandler = () => { |
| 5803 | if (this._element) { |
| 5804 | this.hide(); |
| 5805 | } |
| 5806 | }; |
| 5807 | |
| 5808 | EventHandler.on(this._element.closest(SELECTOR_MODAL), EVENT_MODAL_HIDE, this._hideModalHandler); |
| 5809 | |
| 5810 | if (this._config.selector) { |
| 5811 | this._config = { ...this._config, |
| 5812 | trigger: 'manual', |
| 5813 | selector: '' |
| 5814 | }; |
| 5815 | } else { |
| 5816 | this._fixTitle(); |
| 5817 | } |
| 5818 | } |
| 5819 | |
| 5820 | _fixTitle() { |
| 5821 | const title = this._element.getAttribute('title'); |
| 5822 | |
| 5823 | const originalTitleType = typeof this._element.getAttribute('data-bs-original-title'); |
| 5824 | |
| 5825 | if (title || originalTitleType !== 'string') { |
| 5826 | this._element.setAttribute('data-bs-original-title', title || ''); |
| 5827 | |
| 5828 | if (title && !this._element.getAttribute('aria-label') && !this._element.textContent) { |
| 5829 | this._element.setAttribute('aria-label', title); |
| 5830 | } |
| 5831 | |
| 5832 | this._element.setAttribute('title', ''); |
| 5833 | } |
| 5834 | } |
| 5835 | |
| 5836 | _enter(event, context) { |
| 5837 | context = this._initializeOnDelegatedTarget(event, context); |
| 5838 | |
| 5839 | if (event) { |
| 5840 | context._activeTrigger[event.type === 'focusin' ? TRIGGER_FOCUS : TRIGGER_HOVER] = true; |
| 5841 | } |
| 5842 | |
| 5843 | if (context.getTipElement().classList.contains(CLASS_NAME_SHOW$2) || context._hoverState === HOVER_STATE_SHOW) { |
| 5844 | context._hoverState = HOVER_STATE_SHOW; |
| 5845 | return; |
| 5846 | } |
| 5847 | |
| 5848 | clearTimeout(context._timeout); |
| 5849 | context._hoverState = HOVER_STATE_SHOW; |
| 5850 | |
| 5851 | if (!context._config.delay || !context._config.delay.show) { |
| 5852 | context.show(); |
| 5853 | return; |
| 5854 | } |
| 5855 | |
| 5856 | context._timeout = setTimeout(() => { |
| 5857 | if (context._hoverState === HOVER_STATE_SHOW) { |
| 5858 | context.show(); |
| 5859 | } |
| 5860 | }, context._config.delay.show); |
| 5861 | } |
| 5862 | |
| 5863 | _leave(event, context) { |
| 5864 | context = this._initializeOnDelegatedTarget(event, context); |
| 5865 | |
| 5866 | if (event) { |
| 5867 | context._activeTrigger[event.type === 'focusout' ? TRIGGER_FOCUS : TRIGGER_HOVER] = context._element.contains(event.relatedTarget); |
| 5868 | } |
| 5869 | |
| 5870 | if (context._isWithActiveTrigger()) { |
| 5871 | return; |
| 5872 | } |
| 5873 | |
| 5874 | clearTimeout(context._timeout); |
| 5875 | context._hoverState = HOVER_STATE_OUT; |
| 5876 | |
| 5877 | if (!context._config.delay || !context._config.delay.hide) { |
| 5878 | context.hide(); |
| 5879 | return; |
| 5880 | } |
| 5881 | |
| 5882 | context._timeout = setTimeout(() => { |
| 5883 | if (context._hoverState === HOVER_STATE_OUT) { |
| 5884 | context.hide(); |
| 5885 | } |
| 5886 | }, context._config.delay.hide); |
| 5887 | } |
| 5888 | |
| 5889 | _isWithActiveTrigger() { |
| 5890 | for (const trigger in this._activeTrigger) { |
| 5891 | if (this._activeTrigger[trigger]) { |
| 5892 | return true; |
| 5893 | } |
| 5894 | } |
| 5895 | |
| 5896 | return false; |
| 5897 | } |
| 5898 | |
| 5899 | _getConfig(config) { |
| 5900 | const dataAttributes = Manipulator.getDataAttributes(this._element); |
| 5901 | Object.keys(dataAttributes).forEach(dataAttr => { |
| 5902 | if (DISALLOWED_ATTRIBUTES.has(dataAttr)) { |
| 5903 | delete dataAttributes[dataAttr]; |
| 5904 | } |
| 5905 | }); |
| 5906 | config = { ...this.constructor.Default, |
| 5907 | ...dataAttributes, |
| 5908 | ...(typeof config === 'object' && config ? config : {}) |
| 5909 | }; |
| 5910 | config.container = config.container === false ? document.body : getElement(config.container); |
| 5911 | |
| 5912 | if (typeof config.delay === 'number') { |
| 5913 | config.delay = { |
| 5914 | show: config.delay, |
| 5915 | hide: config.delay |
| 5916 | }; |
| 5917 | } |
| 5918 | |
| 5919 | if (typeof config.title === 'number') { |
| 5920 | config.title = config.title.toString(); |
| 5921 | } |
| 5922 | |
| 5923 | if (typeof config.content === 'number') { |
| 5924 | config.content = config.content.toString(); |
| 5925 | } |
| 5926 | |
| 5927 | typeCheckConfig(NAME$4, config, this.constructor.DefaultType); |
| 5928 | |
| 5929 | if (config.sanitize) { |
| 5930 | config.template = sanitizeHtml(config.template, config.allowList, config.sanitizeFn); |
| 5931 | } |
| 5932 | |
| 5933 | return config; |
| 5934 | } |
| 5935 | |
| 5936 | _getDelegateConfig() { |
| 5937 | const config = {}; |
| 5938 | |
| 5939 | for (const key in this._config) { |
| 5940 | if (this.constructor.Default[key] !== this._config[key]) { |
| 5941 | config[key] = this._config[key]; |
| 5942 | } |
| 5943 | } // In the future can be replaced with: |
| 5944 | // const keysWithDifferentValues = Object.entries(this._config).filter(entry => this.constructor.Default[entry[0]] !== this._config[entry[0]]) |
| 5945 | // `Object.fromEntries(keysWithDifferentValues)` |
| 5946 | |
| 5947 | |
| 5948 | return config; |
| 5949 | } |
| 5950 | |
| 5951 | _cleanTipClass() { |
| 5952 | const tip = this.getTipElement(); |
| 5953 | const basicClassPrefixRegex = new RegExp(`(^|\\s)${this._getBasicClassPrefix()}\\S+`, 'g'); |
| 5954 | const tabClass = tip.getAttribute('class').match(basicClassPrefixRegex); |
| 5955 | |
| 5956 | if (tabClass !== null && tabClass.length > 0) { |
| 5957 | tabClass.map(token => token.trim()).forEach(tClass => tip.classList.remove(tClass)); |
| 5958 | } |
| 5959 | } |
| 5960 | |
| 5961 | _getBasicClassPrefix() { |
| 5962 | return CLASS_PREFIX$1; |
| 5963 | } |
| 5964 | |
| 5965 | _handlePopperPlacementChange(popperData) { |
| 5966 | const { |
| 5967 | state |
| 5968 | } = popperData; |
| 5969 | |
| 5970 | if (!state) { |
| 5971 | return; |
| 5972 | } |
| 5973 | |
| 5974 | this.tip = state.elements.popper; |
| 5975 | |
| 5976 | this._cleanTipClass(); |
| 5977 | |
| 5978 | this._addAttachmentClass(this._getAttachment(state.placement)); |
| 5979 | } |
| 5980 | |
| 5981 | _disposePopper() { |
| 5982 | if (this._popper) { |
| 5983 | this._popper.destroy(); |
| 5984 | |
| 5985 | this._popper = null; |
| 5986 | } |
| 5987 | } // Static |
| 5988 | |
| 5989 | |
| 5990 | static jQueryInterface(config) { |
| 5991 | return this.each(function () { |
| 5992 | const data = Tooltip.getOrCreateInstance(this, config); |
| 5993 | |
| 5994 | if (typeof config === 'string') { |
| 5995 | if (typeof data[config] === 'undefined') { |
| 5996 | throw new TypeError(`No method named "${config}"`); |
| 5997 | } |
| 5998 | |
| 5999 | data[config](); |
| 6000 | } |
| 6001 | }); |
| 6002 | } |
| 6003 | |
| 6004 | } |
| 6005 | /** |
| 6006 | * ------------------------------------------------------------------------ |
| 6007 | * jQuery |
| 6008 | * ------------------------------------------------------------------------ |
| 6009 | * add .Tooltip to jQuery only if jQuery is present |
| 6010 | */ |
| 6011 | |
| 6012 | |
| 6013 | defineJQueryPlugin(Tooltip); |
| 6014 | |
| 6015 | /** |
| 6016 | * -------------------------------------------------------------------------- |
| 6017 | * Bootstrap (v5.1.3): popover.js |
| 6018 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 6019 | * -------------------------------------------------------------------------- |
| 6020 | */ |
| 6021 | /** |
| 6022 | * ------------------------------------------------------------------------ |
| 6023 | * Constants |
| 6024 | * ------------------------------------------------------------------------ |
| 6025 | */ |
| 6026 | |
| 6027 | const NAME$3 = 'popover'; |
| 6028 | const DATA_KEY$3 = 'bs.popover'; |
| 6029 | const EVENT_KEY$3 = `.${DATA_KEY$3}`; |
| 6030 | const CLASS_PREFIX = 'bs-popover'; |
| 6031 | const Default$2 = { ...Tooltip.Default, |
| 6032 | placement: 'right', |
| 6033 | offset: [0, 8], |
| 6034 | trigger: 'click', |
| 6035 | content: '', |
| 6036 | template: '<div class="popover" role="tooltip">' + '<div class="popover-arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div>' + '</div>' |
| 6037 | }; |
| 6038 | const DefaultType$2 = { ...Tooltip.DefaultType, |
| 6039 | content: '(string|element|function)' |
| 6040 | }; |
| 6041 | const Event$1 = { |
| 6042 | HIDE: `hide${EVENT_KEY$3}`, |
| 6043 | HIDDEN: `hidden${EVENT_KEY$3}`, |
| 6044 | SHOW: `show${EVENT_KEY$3}`, |
| 6045 | SHOWN: `shown${EVENT_KEY$3}`, |
| 6046 | INSERTED: `inserted${EVENT_KEY$3}`, |
| 6047 | CLICK: `click${EVENT_KEY$3}`, |
| 6048 | FOCUSIN: `focusin${EVENT_KEY$3}`, |
| 6049 | FOCUSOUT: `focusout${EVENT_KEY$3}`, |
| 6050 | MOUSEENTER: `mouseenter${EVENT_KEY$3}`, |
| 6051 | MOUSELEAVE: `mouseleave${EVENT_KEY$3}` |
| 6052 | }; |
| 6053 | const SELECTOR_TITLE = '.popover-header'; |
| 6054 | const SELECTOR_CONTENT = '.popover-body'; |
| 6055 | /** |
| 6056 | * ------------------------------------------------------------------------ |
| 6057 | * Class Definition |
| 6058 | * ------------------------------------------------------------------------ |
| 6059 | */ |
| 6060 | |
| 6061 | class Popover extends Tooltip { |
| 6062 | // Getters |
| 6063 | static get Default() { |
| 6064 | return Default$2; |
| 6065 | } |
| 6066 | |
| 6067 | static get NAME() { |
| 6068 | return NAME$3; |
| 6069 | } |
| 6070 | |
| 6071 | static get Event() { |
| 6072 | return Event$1; |
| 6073 | } |
| 6074 | |
| 6075 | static get DefaultType() { |
| 6076 | return DefaultType$2; |
| 6077 | } // Overrides |
| 6078 | |
| 6079 | |
| 6080 | isWithContent() { |
| 6081 | return this.getTitle() || this._getContent(); |
| 6082 | } |
| 6083 | |
| 6084 | setContent(tip) { |
| 6085 | this._sanitizeAndSetContent(tip, this.getTitle(), SELECTOR_TITLE); |
| 6086 | |
| 6087 | this._sanitizeAndSetContent(tip, this._getContent(), SELECTOR_CONTENT); |
| 6088 | } // Private |
| 6089 | |
| 6090 | |
| 6091 | _getContent() { |
| 6092 | return this._resolvePossibleFunction(this._config.content); |
| 6093 | } |
| 6094 | |
| 6095 | _getBasicClassPrefix() { |
| 6096 | return CLASS_PREFIX; |
| 6097 | } // Static |
| 6098 | |
| 6099 | |
| 6100 | static jQueryInterface(config) { |
| 6101 | return this.each(function () { |
| 6102 | const data = Popover.getOrCreateInstance(this, config); |
| 6103 | |
| 6104 | if (typeof config === 'string') { |
| 6105 | if (typeof data[config] === 'undefined') { |
| 6106 | throw new TypeError(`No method named "${config}"`); |
| 6107 | } |
| 6108 | |
| 6109 | data[config](); |
| 6110 | } |
| 6111 | }); |
| 6112 | } |
| 6113 | |
| 6114 | } |
| 6115 | /** |
| 6116 | * ------------------------------------------------------------------------ |
| 6117 | * jQuery |
| 6118 | * ------------------------------------------------------------------------ |
| 6119 | * add .Popover to jQuery only if jQuery is present |
| 6120 | */ |
| 6121 | |
| 6122 | |
| 6123 | defineJQueryPlugin(Popover); |
| 6124 | |
| 6125 | /** |
| 6126 | * -------------------------------------------------------------------------- |
| 6127 | * Bootstrap (v5.1.3): scrollspy.js |
| 6128 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 6129 | * -------------------------------------------------------------------------- |
| 6130 | */ |
| 6131 | /** |
| 6132 | * ------------------------------------------------------------------------ |
| 6133 | * Constants |
| 6134 | * ------------------------------------------------------------------------ |
| 6135 | */ |
| 6136 | |
| 6137 | const NAME$2 = 'scrollspy'; |
| 6138 | const DATA_KEY$2 = 'bs.scrollspy'; |
| 6139 | const EVENT_KEY$2 = `.${DATA_KEY$2}`; |
| 6140 | const DATA_API_KEY$1 = '.data-api'; |
| 6141 | const Default$1 = { |
| 6142 | offset: 10, |
| 6143 | method: 'auto', |
| 6144 | target: '' |
| 6145 | }; |
| 6146 | const DefaultType$1 = { |
| 6147 | offset: 'number', |
| 6148 | method: 'string', |
| 6149 | target: '(string|element)' |
| 6150 | }; |
| 6151 | const EVENT_ACTIVATE = `activate${EVENT_KEY$2}`; |
| 6152 | const EVENT_SCROLL = `scroll${EVENT_KEY$2}`; |
| 6153 | const EVENT_LOAD_DATA_API = `load${EVENT_KEY$2}${DATA_API_KEY$1}`; |
| 6154 | const CLASS_NAME_DROPDOWN_ITEM = 'dropdown-item'; |
| 6155 | const CLASS_NAME_ACTIVE$1 = 'active'; |
| 6156 | const SELECTOR_DATA_SPY = '[data-bs-spy="scroll"]'; |
| 6157 | const SELECTOR_NAV_LIST_GROUP$1 = '.nav, .list-group'; |
| 6158 | const SELECTOR_NAV_LINKS = '.nav-link'; |
| 6159 | const SELECTOR_NAV_ITEMS = '.nav-item'; |
| 6160 | const SELECTOR_LIST_ITEMS = '.list-group-item'; |
| 6161 | const SELECTOR_LINK_ITEMS = `${SELECTOR_NAV_LINKS}, ${SELECTOR_LIST_ITEMS}, .${CLASS_NAME_DROPDOWN_ITEM}`; |
| 6162 | const SELECTOR_DROPDOWN$1 = '.dropdown'; |
| 6163 | const SELECTOR_DROPDOWN_TOGGLE$1 = '.dropdown-toggle'; |
| 6164 | const METHOD_OFFSET = 'offset'; |
| 6165 | const METHOD_POSITION = 'position'; |
| 6166 | /** |
| 6167 | * ------------------------------------------------------------------------ |
| 6168 | * Class Definition |
| 6169 | * ------------------------------------------------------------------------ |
| 6170 | */ |
| 6171 | |
| 6172 | class ScrollSpy extends BaseComponent { |
| 6173 | constructor(element, config) { |
| 6174 | super(element); |
| 6175 | this._scrollElement = this._element.tagName === 'BODY' ? window : this._element; |
| 6176 | this._config = this._getConfig(config); |
| 6177 | this._offsets = []; |
| 6178 | this._targets = []; |
| 6179 | this._activeTarget = null; |
| 6180 | this._scrollHeight = 0; |
| 6181 | EventHandler.on(this._scrollElement, EVENT_SCROLL, () => this._process()); |
| 6182 | this.refresh(); |
| 6183 | |
| 6184 | this._process(); |
| 6185 | } // Getters |
| 6186 | |
| 6187 | |
| 6188 | static get Default() { |
| 6189 | return Default$1; |
| 6190 | } |
| 6191 | |
| 6192 | static get NAME() { |
| 6193 | return NAME$2; |
| 6194 | } // Public |
| 6195 | |
| 6196 | |
| 6197 | refresh() { |
| 6198 | const autoMethod = this._scrollElement === this._scrollElement.window ? METHOD_OFFSET : METHOD_POSITION; |
| 6199 | const offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method; |
| 6200 | const offsetBase = offsetMethod === METHOD_POSITION ? this._getScrollTop() : 0; |
| 6201 | this._offsets = []; |
| 6202 | this._targets = []; |
| 6203 | this._scrollHeight = this._getScrollHeight(); |
| 6204 | const targets = SelectorEngine.find(SELECTOR_LINK_ITEMS, this._config.target); |
| 6205 | targets.map(element => { |
| 6206 | const targetSelector = getSelectorFromElement(element); |
| 6207 | const target = targetSelector ? SelectorEngine.findOne(targetSelector) : null; |
| 6208 | |
| 6209 | if (target) { |
| 6210 | const targetBCR = target.getBoundingClientRect(); |
| 6211 | |
| 6212 | if (targetBCR.width || targetBCR.height) { |
| 6213 | return [Manipulator[offsetMethod](target).top + offsetBase, targetSelector]; |
| 6214 | } |
| 6215 | } |
| 6216 | |
| 6217 | return null; |
| 6218 | }).filter(item => item).sort((a, b) => a[0] - b[0]).forEach(item => { |
| 6219 | this._offsets.push(item[0]); |
| 6220 | |
| 6221 | this._targets.push(item[1]); |
| 6222 | }); |
| 6223 | } |
| 6224 | |
| 6225 | dispose() { |
| 6226 | EventHandler.off(this._scrollElement, EVENT_KEY$2); |
| 6227 | super.dispose(); |
| 6228 | } // Private |
| 6229 | |
| 6230 | |
| 6231 | _getConfig(config) { |
| 6232 | config = { ...Default$1, |
| 6233 | ...Manipulator.getDataAttributes(this._element), |
| 6234 | ...(typeof config === 'object' && config ? config : {}) |
| 6235 | }; |
| 6236 | config.target = getElement(config.target) || document.documentElement; |
| 6237 | typeCheckConfig(NAME$2, config, DefaultType$1); |
| 6238 | return config; |
| 6239 | } |
| 6240 | |
| 6241 | _getScrollTop() { |
| 6242 | return this._scrollElement === window ? this._scrollElement.pageYOffset : this._scrollElement.scrollTop; |
| 6243 | } |
| 6244 | |
| 6245 | _getScrollHeight() { |
| 6246 | return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight); |
| 6247 | } |
| 6248 | |
| 6249 | _getOffsetHeight() { |
| 6250 | return this._scrollElement === window ? window.innerHeight : this._scrollElement.getBoundingClientRect().height; |
| 6251 | } |
| 6252 | |
| 6253 | _process() { |
| 6254 | const scrollTop = this._getScrollTop() + this._config.offset; |
| 6255 | |
| 6256 | const scrollHeight = this._getScrollHeight(); |
| 6257 | |
| 6258 | const maxScroll = this._config.offset + scrollHeight - this._getOffsetHeight(); |
| 6259 | |
| 6260 | if (this._scrollHeight !== scrollHeight) { |
| 6261 | this.refresh(); |
| 6262 | } |
| 6263 | |
| 6264 | if (scrollTop >= maxScroll) { |
| 6265 | const target = this._targets[this._targets.length - 1]; |
| 6266 | |
| 6267 | if (this._activeTarget !== target) { |
| 6268 | this._activate(target); |
| 6269 | } |
| 6270 | |
| 6271 | return; |
| 6272 | } |
| 6273 | |
| 6274 | if (this._activeTarget && scrollTop < this._offsets[0] && this._offsets[0] > 0) { |
| 6275 | this._activeTarget = null; |
| 6276 | |
| 6277 | this._clear(); |
| 6278 | |
| 6279 | return; |
| 6280 | } |
| 6281 | |
| 6282 | for (let i = this._offsets.length; i--;) { |
| 6283 | const isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (typeof this._offsets[i + 1] === 'undefined' || scrollTop < this._offsets[i + 1]); |
| 6284 | |
| 6285 | if (isActiveTarget) { |
| 6286 | this._activate(this._targets[i]); |
| 6287 | } |
| 6288 | } |
| 6289 | } |
| 6290 | |
| 6291 | _activate(target) { |
| 6292 | this._activeTarget = target; |
| 6293 | |
| 6294 | this._clear(); |
| 6295 | |
| 6296 | const queries = SELECTOR_LINK_ITEMS.split(',').map(selector => `${selector}[data-bs-target="${target}"],${selector}[href="${target}"]`); |
| 6297 | const link = SelectorEngine.findOne(queries.join(','), this._config.target); |
| 6298 | link.classList.add(CLASS_NAME_ACTIVE$1); |
| 6299 | |
| 6300 | if (link.classList.contains(CLASS_NAME_DROPDOWN_ITEM)) { |
| 6301 | SelectorEngine.findOne(SELECTOR_DROPDOWN_TOGGLE$1, link.closest(SELECTOR_DROPDOWN$1)).classList.add(CLASS_NAME_ACTIVE$1); |
| 6302 | } else { |
| 6303 | SelectorEngine.parents(link, SELECTOR_NAV_LIST_GROUP$1).forEach(listGroup => { |
| 6304 | // Set triggered links parents as active |
| 6305 | // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor |
| 6306 | SelectorEngine.prev(listGroup, `${SELECTOR_NAV_LINKS}, ${SELECTOR_LIST_ITEMS}`).forEach(item => item.classList.add(CLASS_NAME_ACTIVE$1)); // Handle special case when .nav-link is inside .nav-item |
| 6307 | |
| 6308 | SelectorEngine.prev(listGroup, SELECTOR_NAV_ITEMS).forEach(navItem => { |
| 6309 | SelectorEngine.children(navItem, SELECTOR_NAV_LINKS).forEach(item => item.classList.add(CLASS_NAME_ACTIVE$1)); |
| 6310 | }); |
| 6311 | }); |
| 6312 | } |
| 6313 | |
| 6314 | EventHandler.trigger(this._scrollElement, EVENT_ACTIVATE, { |
| 6315 | relatedTarget: target |
| 6316 | }); |
| 6317 | } |
| 6318 | |
| 6319 | _clear() { |
| 6320 | SelectorEngine.find(SELECTOR_LINK_ITEMS, this._config.target).filter(node => node.classList.contains(CLASS_NAME_ACTIVE$1)).forEach(node => node.classList.remove(CLASS_NAME_ACTIVE$1)); |
| 6321 | } // Static |
| 6322 | |
| 6323 | |
| 6324 | static jQueryInterface(config) { |
| 6325 | return this.each(function () { |
| 6326 | const data = ScrollSpy.getOrCreateInstance(this, config); |
| 6327 | |
| 6328 | if (typeof config !== 'string') { |
| 6329 | return; |
| 6330 | } |
| 6331 | |
| 6332 | if (typeof data[config] === 'undefined') { |
| 6333 | throw new TypeError(`No method named "${config}"`); |
| 6334 | } |
| 6335 | |
| 6336 | data[config](); |
| 6337 | }); |
| 6338 | } |
| 6339 | |
| 6340 | } |
| 6341 | /** |
| 6342 | * ------------------------------------------------------------------------ |
| 6343 | * Data Api implementation |
| 6344 | * ------------------------------------------------------------------------ |
| 6345 | */ |
| 6346 | |
| 6347 | |
| 6348 | EventHandler.on(window, EVENT_LOAD_DATA_API, () => { |
| 6349 | SelectorEngine.find(SELECTOR_DATA_SPY).forEach(spy => new ScrollSpy(spy)); |
| 6350 | }); |
| 6351 | /** |
| 6352 | * ------------------------------------------------------------------------ |
| 6353 | * jQuery |
| 6354 | * ------------------------------------------------------------------------ |
| 6355 | * add .ScrollSpy to jQuery only if jQuery is present |
| 6356 | */ |
| 6357 | |
| 6358 | defineJQueryPlugin(ScrollSpy); |
| 6359 | |
| 6360 | /** |
| 6361 | * -------------------------------------------------------------------------- |
| 6362 | * Bootstrap (v5.1.3): tab.js |
| 6363 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 6364 | * -------------------------------------------------------------------------- |
| 6365 | */ |
| 6366 | /** |
| 6367 | * ------------------------------------------------------------------------ |
| 6368 | * Constants |
| 6369 | * ------------------------------------------------------------------------ |
| 6370 | */ |
| 6371 | |
| 6372 | const NAME$1 = 'tab'; |
| 6373 | const DATA_KEY$1 = 'bs.tab'; |
| 6374 | const EVENT_KEY$1 = `.${DATA_KEY$1}`; |
| 6375 | const DATA_API_KEY = '.data-api'; |
| 6376 | const EVENT_HIDE$1 = `hide${EVENT_KEY$1}`; |
| 6377 | const EVENT_HIDDEN$1 = `hidden${EVENT_KEY$1}`; |
| 6378 | const EVENT_SHOW$1 = `show${EVENT_KEY$1}`; |
| 6379 | const EVENT_SHOWN$1 = `shown${EVENT_KEY$1}`; |
| 6380 | const EVENT_CLICK_DATA_API = `click${EVENT_KEY$1}${DATA_API_KEY}`; |
| 6381 | const CLASS_NAME_DROPDOWN_MENU = 'dropdown-menu'; |
| 6382 | const CLASS_NAME_ACTIVE = 'active'; |
| 6383 | const CLASS_NAME_FADE$1 = 'fade'; |
| 6384 | const CLASS_NAME_SHOW$1 = 'show'; |
| 6385 | const SELECTOR_DROPDOWN = '.dropdown'; |
| 6386 | const SELECTOR_NAV_LIST_GROUP = '.nav, .list-group'; |
| 6387 | const SELECTOR_ACTIVE = '.active'; |
| 6388 | const SELECTOR_ACTIVE_UL = ':scope > li > .active'; |
| 6389 | const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="tab"], [data-bs-toggle="pill"], [data-bs-toggle="list"]'; |
| 6390 | const SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle'; |
| 6391 | const SELECTOR_DROPDOWN_ACTIVE_CHILD = ':scope > .dropdown-menu .active'; |
| 6392 | /** |
| 6393 | * ------------------------------------------------------------------------ |
| 6394 | * Class Definition |
| 6395 | * ------------------------------------------------------------------------ |
| 6396 | */ |
| 6397 | |
| 6398 | class Tab extends BaseComponent { |
| 6399 | // Getters |
| 6400 | static get NAME() { |
| 6401 | return NAME$1; |
| 6402 | } // Public |
| 6403 | |
| 6404 | |
| 6405 | show() { |
| 6406 | if (this._element.parentNode && this._element.parentNode.nodeType === Node.ELEMENT_NODE && this._element.classList.contains(CLASS_NAME_ACTIVE)) { |
| 6407 | return; |
| 6408 | } |
| 6409 | |
| 6410 | let previous; |
| 6411 | const target = getElementFromSelector(this._element); |
| 6412 | |
| 6413 | const listElement = this._element.closest(SELECTOR_NAV_LIST_GROUP); |
| 6414 | |
| 6415 | if (listElement) { |
| 6416 | const itemSelector = listElement.nodeName === 'UL' || listElement.nodeName === 'OL' ? SELECTOR_ACTIVE_UL : SELECTOR_ACTIVE; |
| 6417 | previous = SelectorEngine.find(itemSelector, listElement); |
| 6418 | previous = previous[previous.length - 1]; |
| 6419 | } |
| 6420 | |
| 6421 | const hideEvent = previous ? EventHandler.trigger(previous, EVENT_HIDE$1, { |
| 6422 | relatedTarget: this._element |
| 6423 | }) : null; |
| 6424 | const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$1, { |
| 6425 | relatedTarget: previous |
| 6426 | }); |
| 6427 | |
| 6428 | if (showEvent.defaultPrevented || hideEvent !== null && hideEvent.defaultPrevented) { |
| 6429 | return; |
| 6430 | } |
| 6431 | |
| 6432 | this._activate(this._element, listElement); |
| 6433 | |
| 6434 | const complete = () => { |
| 6435 | EventHandler.trigger(previous, EVENT_HIDDEN$1, { |
| 6436 | relatedTarget: this._element |
| 6437 | }); |
| 6438 | EventHandler.trigger(this._element, EVENT_SHOWN$1, { |
| 6439 | relatedTarget: previous |
| 6440 | }); |
| 6441 | }; |
| 6442 | |
| 6443 | if (target) { |
| 6444 | this._activate(target, target.parentNode, complete); |
| 6445 | } else { |
| 6446 | complete(); |
| 6447 | } |
| 6448 | } // Private |
| 6449 | |
| 6450 | |
| 6451 | _activate(element, container, callback) { |
| 6452 | const activeElements = container && (container.nodeName === 'UL' || container.nodeName === 'OL') ? SelectorEngine.find(SELECTOR_ACTIVE_UL, container) : SelectorEngine.children(container, SELECTOR_ACTIVE); |
| 6453 | const active = activeElements[0]; |
| 6454 | const isTransitioning = callback && active && active.classList.contains(CLASS_NAME_FADE$1); |
| 6455 | |
| 6456 | const complete = () => this._transitionComplete(element, active, callback); |
| 6457 | |
| 6458 | if (active && isTransitioning) { |
| 6459 | active.classList.remove(CLASS_NAME_SHOW$1); |
| 6460 | |
| 6461 | this._queueCallback(complete, element, true); |
| 6462 | } else { |
| 6463 | complete(); |
| 6464 | } |
| 6465 | } |
| 6466 | |
| 6467 | _transitionComplete(element, active, callback) { |
| 6468 | if (active) { |
| 6469 | active.classList.remove(CLASS_NAME_ACTIVE); |
| 6470 | const dropdownChild = SelectorEngine.findOne(SELECTOR_DROPDOWN_ACTIVE_CHILD, active.parentNode); |
| 6471 | |
| 6472 | if (dropdownChild) { |
| 6473 | dropdownChild.classList.remove(CLASS_NAME_ACTIVE); |
| 6474 | } |
| 6475 | |
| 6476 | if (active.getAttribute('role') === 'tab') { |
| 6477 | active.setAttribute('aria-selected', false); |
| 6478 | } |
| 6479 | } |
| 6480 | |
| 6481 | element.classList.add(CLASS_NAME_ACTIVE); |
| 6482 | |
| 6483 | if (element.getAttribute('role') === 'tab') { |
| 6484 | element.setAttribute('aria-selected', true); |
| 6485 | } |
| 6486 | |
| 6487 | reflow(element); |
| 6488 | |
| 6489 | if (element.classList.contains(CLASS_NAME_FADE$1)) { |
| 6490 | element.classList.add(CLASS_NAME_SHOW$1); |
| 6491 | } |
| 6492 | |
| 6493 | let parent = element.parentNode; |
| 6494 | |
| 6495 | if (parent && parent.nodeName === 'LI') { |
| 6496 | parent = parent.parentNode; |
| 6497 | } |
| 6498 | |
| 6499 | if (parent && parent.classList.contains(CLASS_NAME_DROPDOWN_MENU)) { |
| 6500 | const dropdownElement = element.closest(SELECTOR_DROPDOWN); |
| 6501 | |
| 6502 | if (dropdownElement) { |
| 6503 | SelectorEngine.find(SELECTOR_DROPDOWN_TOGGLE, dropdownElement).forEach(dropdown => dropdown.classList.add(CLASS_NAME_ACTIVE)); |
| 6504 | } |
| 6505 | |
| 6506 | element.setAttribute('aria-expanded', true); |
| 6507 | } |
| 6508 | |
| 6509 | if (callback) { |
| 6510 | callback(); |
| 6511 | } |
| 6512 | } // Static |
| 6513 | |
| 6514 | |
| 6515 | static jQueryInterface(config) { |
| 6516 | return this.each(function () { |
| 6517 | const data = Tab.getOrCreateInstance(this); |
| 6518 | |
| 6519 | if (typeof config === 'string') { |
| 6520 | if (typeof data[config] === 'undefined') { |
| 6521 | throw new TypeError(`No method named "${config}"`); |
| 6522 | } |
| 6523 | |
| 6524 | data[config](); |
| 6525 | } |
| 6526 | }); |
| 6527 | } |
| 6528 | |
| 6529 | } |
| 6530 | /** |
| 6531 | * ------------------------------------------------------------------------ |
| 6532 | * Data Api implementation |
| 6533 | * ------------------------------------------------------------------------ |
| 6534 | */ |
| 6535 | |
| 6536 | |
| 6537 | EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) { |
| 6538 | if (['A', 'AREA'].includes(this.tagName)) { |
| 6539 | event.preventDefault(); |
| 6540 | } |
| 6541 | |
| 6542 | if (isDisabled(this)) { |
| 6543 | return; |
| 6544 | } |
| 6545 | |
| 6546 | const data = Tab.getOrCreateInstance(this); |
| 6547 | data.show(); |
| 6548 | }); |
| 6549 | /** |
| 6550 | * ------------------------------------------------------------------------ |
| 6551 | * jQuery |
| 6552 | * ------------------------------------------------------------------------ |
| 6553 | * add .Tab to jQuery only if jQuery is present |
| 6554 | */ |
| 6555 | |
| 6556 | defineJQueryPlugin(Tab); |
| 6557 | |
| 6558 | /** |
| 6559 | * -------------------------------------------------------------------------- |
| 6560 | * Bootstrap (v5.1.3): toast.js |
| 6561 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 6562 | * -------------------------------------------------------------------------- |
| 6563 | */ |
| 6564 | /** |
| 6565 | * ------------------------------------------------------------------------ |
| 6566 | * Constants |
| 6567 | * ------------------------------------------------------------------------ |
| 6568 | */ |
| 6569 | |
| 6570 | const NAME = 'toast'; |
| 6571 | const DATA_KEY = 'bs.toast'; |
| 6572 | const EVENT_KEY = `.${DATA_KEY}`; |
| 6573 | const EVENT_MOUSEOVER = `mouseover${EVENT_KEY}`; |
| 6574 | const EVENT_MOUSEOUT = `mouseout${EVENT_KEY}`; |
| 6575 | const EVENT_FOCUSIN = `focusin${EVENT_KEY}`; |
| 6576 | const EVENT_FOCUSOUT = `focusout${EVENT_KEY}`; |
| 6577 | const EVENT_HIDE = `hide${EVENT_KEY}`; |
| 6578 | const EVENT_HIDDEN = `hidden${EVENT_KEY}`; |
| 6579 | const EVENT_SHOW = `show${EVENT_KEY}`; |
| 6580 | const EVENT_SHOWN = `shown${EVENT_KEY}`; |
| 6581 | const CLASS_NAME_FADE = 'fade'; |
| 6582 | const CLASS_NAME_HIDE = 'hide'; // @deprecated - kept here only for backwards compatibility |
| 6583 | |
| 6584 | const CLASS_NAME_SHOW = 'show'; |
| 6585 | const CLASS_NAME_SHOWING = 'showing'; |
| 6586 | const DefaultType = { |
| 6587 | animation: 'boolean', |
| 6588 | autohide: 'boolean', |
| 6589 | delay: 'number' |
| 6590 | }; |
| 6591 | const Default = { |
| 6592 | animation: true, |
| 6593 | autohide: true, |
| 6594 | delay: 5000 |
| 6595 | }; |
| 6596 | /** |
| 6597 | * ------------------------------------------------------------------------ |
| 6598 | * Class Definition |
| 6599 | * ------------------------------------------------------------------------ |
| 6600 | */ |
| 6601 | |
| 6602 | class Toast extends BaseComponent { |
| 6603 | constructor(element, config) { |
| 6604 | super(element); |
| 6605 | this._config = this._getConfig(config); |
| 6606 | this._timeout = null; |
| 6607 | this._hasMouseInteraction = false; |
| 6608 | this._hasKeyboardInteraction = false; |
| 6609 | |
| 6610 | this._setListeners(); |
| 6611 | } // Getters |
| 6612 | |
| 6613 | |
| 6614 | static get DefaultType() { |
| 6615 | return DefaultType; |
| 6616 | } |
| 6617 | |
| 6618 | static get Default() { |
| 6619 | return Default; |
| 6620 | } |
| 6621 | |
| 6622 | static get NAME() { |
| 6623 | return NAME; |
| 6624 | } // Public |
| 6625 | |
| 6626 | |
| 6627 | show() { |
| 6628 | const showEvent = EventHandler.trigger(this._element, EVENT_SHOW); |
| 6629 | |
| 6630 | if (showEvent.defaultPrevented) { |
| 6631 | return; |
| 6632 | } |
| 6633 | |
| 6634 | this._clearTimeout(); |
| 6635 | |
| 6636 | if (this._config.animation) { |
| 6637 | this._element.classList.add(CLASS_NAME_FADE); |
| 6638 | } |
| 6639 | |
| 6640 | const complete = () => { |
| 6641 | this._element.classList.remove(CLASS_NAME_SHOWING); |
| 6642 | |
| 6643 | EventHandler.trigger(this._element, EVENT_SHOWN); |
| 6644 | |
| 6645 | this._maybeScheduleHide(); |
| 6646 | }; |
| 6647 | |
| 6648 | this._element.classList.remove(CLASS_NAME_HIDE); // @deprecated |
| 6649 | |
| 6650 | |
| 6651 | reflow(this._element); |
| 6652 | |
| 6653 | this._element.classList.add(CLASS_NAME_SHOW); |
| 6654 | |
| 6655 | this._element.classList.add(CLASS_NAME_SHOWING); |
| 6656 | |
| 6657 | this._queueCallback(complete, this._element, this._config.animation); |
| 6658 | } |
| 6659 | |
| 6660 | hide() { |
| 6661 | if (!this._element.classList.contains(CLASS_NAME_SHOW)) { |
| 6662 | return; |
| 6663 | } |
| 6664 | |
| 6665 | const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE); |
| 6666 | |
| 6667 | if (hideEvent.defaultPrevented) { |
| 6668 | return; |
| 6669 | } |
| 6670 | |
| 6671 | const complete = () => { |
| 6672 | this._element.classList.add(CLASS_NAME_HIDE); // @deprecated |
| 6673 | |
| 6674 | |
| 6675 | this._element.classList.remove(CLASS_NAME_SHOWING); |
| 6676 | |
| 6677 | this._element.classList.remove(CLASS_NAME_SHOW); |
| 6678 | |
| 6679 | EventHandler.trigger(this._element, EVENT_HIDDEN); |
| 6680 | }; |
| 6681 | |
| 6682 | this._element.classList.add(CLASS_NAME_SHOWING); |
| 6683 | |
| 6684 | this._queueCallback(complete, this._element, this._config.animation); |
| 6685 | } |
| 6686 | |
| 6687 | dispose() { |
| 6688 | this._clearTimeout(); |
| 6689 | |
| 6690 | if (this._element.classList.contains(CLASS_NAME_SHOW)) { |
| 6691 | this._element.classList.remove(CLASS_NAME_SHOW); |
| 6692 | } |
| 6693 | |
| 6694 | super.dispose(); |
| 6695 | } // Private |
| 6696 | |
| 6697 | |
| 6698 | _getConfig(config) { |
| 6699 | config = { ...Default, |
| 6700 | ...Manipulator.getDataAttributes(this._element), |
| 6701 | ...(typeof config === 'object' && config ? config : {}) |
| 6702 | }; |
| 6703 | typeCheckConfig(NAME, config, this.constructor.DefaultType); |
| 6704 | return config; |
| 6705 | } |
| 6706 | |
| 6707 | _maybeScheduleHide() { |
| 6708 | if (!this._config.autohide) { |
| 6709 | return; |
| 6710 | } |
| 6711 | |
| 6712 | if (this._hasMouseInteraction || this._hasKeyboardInteraction) { |
| 6713 | return; |
| 6714 | } |
| 6715 | |
| 6716 | this._timeout = setTimeout(() => { |
| 6717 | this.hide(); |
| 6718 | }, this._config.delay); |
| 6719 | } |
| 6720 | |
| 6721 | _onInteraction(event, isInteracting) { |
| 6722 | switch (event.type) { |
| 6723 | case 'mouseover': |
| 6724 | case 'mouseout': |
| 6725 | this._hasMouseInteraction = isInteracting; |
| 6726 | break; |
| 6727 | |
| 6728 | case 'focusin': |
| 6729 | case 'focusout': |
| 6730 | this._hasKeyboardInteraction = isInteracting; |
| 6731 | break; |
| 6732 | } |
| 6733 | |
| 6734 | if (isInteracting) { |
| 6735 | this._clearTimeout(); |
| 6736 | |
| 6737 | return; |
| 6738 | } |
| 6739 | |
| 6740 | const nextElement = event.relatedTarget; |
| 6741 | |
| 6742 | if (this._element === nextElement || this._element.contains(nextElement)) { |
| 6743 | return; |
| 6744 | } |
| 6745 | |
| 6746 | this._maybeScheduleHide(); |
| 6747 | } |
| 6748 | |
| 6749 | _setListeners() { |
| 6750 | EventHandler.on(this._element, EVENT_MOUSEOVER, event => this._onInteraction(event, true)); |
| 6751 | EventHandler.on(this._element, EVENT_MOUSEOUT, event => this._onInteraction(event, false)); |
| 6752 | EventHandler.on(this._element, EVENT_FOCUSIN, event => this._onInteraction(event, true)); |
| 6753 | EventHandler.on(this._element, EVENT_FOCUSOUT, event => this._onInteraction(event, false)); |
| 6754 | } |
| 6755 | |
| 6756 | _clearTimeout() { |
| 6757 | clearTimeout(this._timeout); |
| 6758 | this._timeout = null; |
| 6759 | } // Static |
| 6760 | |
| 6761 | |
| 6762 | static jQueryInterface(config) { |
| 6763 | return this.each(function () { |
| 6764 | const data = Toast.getOrCreateInstance(this, config); |
| 6765 | |
| 6766 | if (typeof config === 'string') { |
| 6767 | if (typeof data[config] === 'undefined') { |
| 6768 | throw new TypeError(`No method named "${config}"`); |
| 6769 | } |
| 6770 | |
| 6771 | data[config](this); |
| 6772 | } |
| 6773 | }); |
| 6774 | } |
| 6775 | |
| 6776 | } |
| 6777 | |
| 6778 | enableDismissTrigger(Toast); |
| 6779 | /** |
| 6780 | * ------------------------------------------------------------------------ |
| 6781 | * jQuery |
| 6782 | * ------------------------------------------------------------------------ |
| 6783 | * add .Toast to jQuery only if jQuery is present |
| 6784 | */ |
| 6785 | |
| 6786 | defineJQueryPlugin(Toast); |
| 6787 | |
| 6788 | /** |
| 6789 | * -------------------------------------------------------------------------- |
| 6790 | * Bootstrap (v5.1.3): index.umd.js |
| 6791 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 6792 | * -------------------------------------------------------------------------- |
| 6793 | */ |
| 6794 | const index_umd = { |
| 6795 | Alert, |
| 6796 | Button, |
| 6797 | Carousel, |
| 6798 | Collapse, |
| 6799 | Dropdown, |
| 6800 | Modal, |
| 6801 | Offcanvas, |
| 6802 | Popover, |
| 6803 | ScrollSpy, |
| 6804 | Tab, |
| 6805 | Toast, |
| 6806 | Tooltip |
| 6807 | }; |
| 6808 | |
| 6809 | return index_umd; |
| 6810 | |
| 6811 | })); |
| 6812 | //# sourceMappingURL=bootstrap.bundle.js.map |
| 6813 |