| 1 |
/*! |
| 2 |
* Bootstrap v5.0.2 (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(require('@popperjs/core')) : |
| 8 |
typeof define === 'function' && define.amd ? define(['@popperjs/core'], factory) : |
| 9 |
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.bootstrap = factory(global.Popper)); |
| 10 |
}(this, (function (Popper) { 'use strict'; |
| 11 |
|
| 12 |
function _interopNamespace(e) { |
| 13 |
if (e && e.__esModule) return e; |
| 14 |
var n = Object.create(null); |
| 15 |
if (e) { |
| 16 |
Object.keys(e).forEach(function (k) { |
| 17 |
if (k !== 'default') { |
| 18 |
var d = Object.getOwnPropertyDescriptor(e, k); |
| 19 |
Object.defineProperty(n, k, d.get ? d : { |
| 20 |
enumerable: true, |
| 21 |
get: function () { |
| 22 |
return e[k]; |
| 23 |
} |
| 24 |
}); |
| 25 |
} |
| 26 |
}); |
| 27 |
} |
| 28 |
n['default'] = e; |
| 29 |
return Object.freeze(n); |
| 30 |
} |
| 31 |
|
| 32 |
var Popper__namespace = /*#__PURE__*/_interopNamespace(Popper); |
| 33 |
|
| 34 |
/** |
| 35 |
* -------------------------------------------------------------------------- |
| 36 |
* Bootstrap (v5.0.2): dom/selector-engine.js |
| 37 |
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 38 |
* -------------------------------------------------------------------------- |
| 39 |
*/ |
| 40 |
|
| 41 |
/** |
| 42 |
* ------------------------------------------------------------------------ |
| 43 |
* Constants |
| 44 |
* ------------------------------------------------------------------------ |
| 45 |
*/ |
| 46 |
const NODE_TEXT = 3; |
| 47 |
const SelectorEngine = { |
| 48 |
find(selector, element = document.documentElement) { |
| 49 |
return [].concat(...Element.prototype.querySelectorAll.call(element, selector)); |
| 50 |
}, |
| 51 |
|
| 52 |
findOne(selector, element = document.documentElement) { |
| 53 |
return Element.prototype.querySelector.call(element, selector); |
| 54 |
}, |
| 55 |
|
| 56 |
children(element, selector) { |
| 57 |
return [].concat(...element.children).filter(child => child.matches(selector)); |
| 58 |
}, |
| 59 |
|
| 60 |
parents(element, selector) { |
| 61 |
const parents = []; |
| 62 |
let ancestor = element.parentNode; |
| 63 |
|
| 64 |
while (ancestor && ancestor.nodeType === Node.ELEMENT_NODE && ancestor.nodeType !== NODE_TEXT) { |
| 65 |
if (ancestor.matches(selector)) { |
| 66 |
parents.push(ancestor); |
| 67 |
} |
| 68 |
|
| 69 |
ancestor = ancestor.parentNode; |
| 70 |
} |
| 71 |
|
| 72 |
return parents; |
| 73 |
}, |
| 74 |
|
| 75 |
prev(element, selector) { |
| 76 |
let previous = element.previousElementSibling; |
| 77 |
|
| 78 |
while (previous) { |
| 79 |
if (previous.matches(selector)) { |
| 80 |
return [previous]; |
| 81 |
} |
| 82 |
|
| 83 |
previous = previous.previousElementSibling; |
| 84 |
} |
| 85 |
|
| 86 |
return []; |
| 87 |
}, |
| 88 |
|
| 89 |
next(element, selector) { |
| 90 |
let next = element.nextElementSibling; |
| 91 |
|
| 92 |
while (next) { |
| 93 |
if (next.matches(selector)) { |
| 94 |
return [next]; |
| 95 |
} |
| 96 |
|
| 97 |
next = next.nextElementSibling; |
| 98 |
} |
| 99 |
|
| 100 |
return []; |
| 101 |
} |
| 102 |
|
| 103 |
}; |
| 104 |
|
| 105 |
/** |
| 106 |
* -------------------------------------------------------------------------- |
| 107 |
* Bootstrap (v5.0.2): util/index.js |
| 108 |
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 109 |
* -------------------------------------------------------------------------- |
| 110 |
*/ |
| 111 |
|
| 112 |
const MAX_UID = 1000000; |
| 113 |
const MILLISECONDS_MULTIPLIER = 1000; |
| 114 |
const TRANSITION_END = 'transitionend'; // Shoutout AngusCroll (https://goo.gl/pxwQGp) |
| 115 |
|
| 116 |
const toType = obj => { |
| 117 |
if (obj === null || obj === undefined) { |
| 118 |
return `${obj}`; |
| 119 |
} |
| 120 |
|
| 121 |
return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase(); |
| 122 |
}; |
| 123 |
/** |
| 124 |
* -------------------------------------------------------------------------- |
| 125 |
* Public Util Api |
| 126 |
* -------------------------------------------------------------------------- |
| 127 |
*/ |
| 128 |
|
| 129 |
|
| 130 |
const getUID = prefix => { |
| 131 |
do { |
| 132 |
prefix += Math.floor(Math.random() * MAX_UID); |
| 133 |
} while (document.getElementById(prefix)); |
| 134 |
|
| 135 |
return prefix; |
| 136 |
}; |
| 137 |
|
| 138 |
const getSelector = element => { |
| 139 |
let selector = element.getAttribute('data-bs-target'); |
| 140 |
|
| 141 |
if (!selector || selector === '#') { |
| 142 |
let hrefAttr = element.getAttribute('href'); // The only valid content that could double as a selector are IDs or classes, |
| 143 |
// so everything starting with `#` or `.`. If a "real" URL is used as the selector, |
| 144 |
// `document.querySelector` will rightfully complain it is invalid. |
| 145 |
// See https://github.com/twbs/bootstrap/issues/32273 |
| 146 |
|
| 147 |
if (!hrefAttr || !hrefAttr.includes('#') && !hrefAttr.startsWith('.')) { |
| 148 |
return null; |
| 149 |
} // Just in case some CMS puts out a full URL with the anchor appended |
| 150 |
|
| 151 |
|
| 152 |
if (hrefAttr.includes('#') && !hrefAttr.startsWith('#')) { |
| 153 |
hrefAttr = `#${hrefAttr.split('#')[1]}`; |
| 154 |
} |
| 155 |
|
| 156 |
selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : null; |
| 157 |
} |
| 158 |
|
| 159 |
return selector; |
| 160 |
}; |
| 161 |
|
| 162 |
const getSelectorFromElement = element => { |
| 163 |
const selector = getSelector(element); |
| 164 |
|
| 165 |
if (selector) { |
| 166 |
return document.querySelector(selector) ? selector : null; |
| 167 |
} |
| 168 |
|
| 169 |
return null; |
| 170 |
}; |
| 171 |
|
| 172 |
const getElementFromSelector = element => { |
| 173 |
const selector = getSelector(element); |
| 174 |
return selector ? document.querySelector(selector) : null; |
| 175 |
}; |
| 176 |
|
| 177 |
const getTransitionDurationFromElement = element => { |
| 178 |
if (!element) { |
| 179 |
return 0; |
| 180 |
} // Get transition-duration of the element |
| 181 |
|
| 182 |
|
| 183 |
let { |
| 184 |
transitionDuration, |
| 185 |
transitionDelay |
| 186 |
} = window.getComputedStyle(element); |
| 187 |
const floatTransitionDuration = Number.parseFloat(transitionDuration); |
| 188 |
const floatTransitionDelay = Number.parseFloat(transitionDelay); // Return 0 if element or transition duration is not found |
| 189 |
|
| 190 |
if (!floatTransitionDuration && !floatTransitionDelay) { |
| 191 |
return 0; |
| 192 |
} // If multiple durations are defined, take the first |
| 193 |
|
| 194 |
|
| 195 |
transitionDuration = transitionDuration.split(',')[0]; |
| 196 |
transitionDelay = transitionDelay.split(',')[0]; |
| 197 |
return (Number.parseFloat(transitionDuration) + Number.parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER; |
| 198 |
}; |
| 199 |
|
| 200 |
const triggerTransitionEnd = element => { |
| 201 |
element.dispatchEvent(new Event(TRANSITION_END)); |
| 202 |
}; |
| 203 |
|
| 204 |
const isElement = obj => { |
| 205 |
if (!obj || typeof obj !== 'object') { |
| 206 |
return false; |
| 207 |
} |
| 208 |
|
| 209 |
if (typeof obj.jquery !== 'undefined') { |
| 210 |
obj = obj[0]; |
| 211 |
} |
| 212 |
|
| 213 |
return typeof obj.nodeType !== 'undefined'; |
| 214 |
}; |
| 215 |
|
| 216 |
const getElement = obj => { |
| 217 |
if (isElement(obj)) { |
| 218 |
// it's a jQuery object or a node element |
| 219 |
return obj.jquery ? obj[0] : obj; |
| 220 |
} |
| 221 |
|
| 222 |
if (typeof obj === 'string' && obj.length > 0) { |
| 223 |
return SelectorEngine.findOne(obj); |
| 224 |
} |
| 225 |
|
| 226 |
return null; |
| 227 |
}; |
| 228 |
|
| 229 |
const typeCheckConfig = (componentName, config, configTypes) => { |
| 230 |
Object.keys(configTypes).forEach(property => { |
| 231 |
const expectedTypes = configTypes[property]; |
| 232 |
const value = config[property]; |
| 233 |
const valueType = value && isElement(value) ? 'element' : toType(value); |
| 234 |
|
| 235 |
if (!new RegExp(expectedTypes).test(valueType)) { |
| 236 |
throw new TypeError(`${componentName.toUpperCase()}: Option "${property}" provided type "${valueType}" but expected type "${expectedTypes}".`); |
| 237 |
} |
| 238 |
}); |
| 239 |
}; |
| 240 |
|
| 241 |
const isVisible = element => { |
| 242 |
if (!isElement(element) || element.getClientRects().length === 0) { |
| 243 |
return false; |
| 244 |
} |
| 245 |
|
| 246 |
return getComputedStyle(element).getPropertyValue('visibility') === 'visible'; |
| 247 |
}; |
| 248 |
|
| 249 |
const isDisabled = element => { |
| 250 |
if (!element || element.nodeType !== Node.ELEMENT_NODE) { |
| 251 |
return true; |
| 252 |
} |
| 253 |
|
| 254 |
if (element.classList.contains('disabled')) { |
| 255 |
return true; |
| 256 |
} |
| 257 |
|
| 258 |
if (typeof element.disabled !== 'undefined') { |
| 259 |
return element.disabled; |
| 260 |
} |
| 261 |
|
| 262 |
return element.hasAttribute('disabled') && element.getAttribute('disabled') !== 'false'; |
| 263 |
}; |
| 264 |
|
| 265 |
const findShadowRoot = element => { |
| 266 |
if (!document.documentElement.attachShadow) { |
| 267 |
return null; |
| 268 |
} // Can find the shadow root otherwise it'll return the document |
| 269 |
|
| 270 |
|
| 271 |
if (typeof element.getRootNode === 'function') { |
| 272 |
const root = element.getRootNode(); |
| 273 |
return root instanceof ShadowRoot ? root : null; |
| 274 |
} |
| 275 |
|
| 276 |
if (element instanceof ShadowRoot) { |
| 277 |
return element; |
| 278 |
} // when we don't find a shadow root |
| 279 |
|
| 280 |
|
| 281 |
if (!element.parentNode) { |
| 282 |
return null; |
| 283 |
} |
| 284 |
|
| 285 |
return findShadowRoot(element.parentNode); |
| 286 |
}; |
| 287 |
|
| 288 |
const noop = () => {}; |
| 289 |
|
| 290 |
const reflow = element => element.offsetHeight; |
| 291 |
|
| 292 |
const getjQuery = () => { |
| 293 |
const { |
| 294 |
jQuery |
| 295 |
} = window; |
| 296 |
|
| 297 |
if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) { |
| 298 |
return jQuery; |
| 299 |
} |
| 300 |
|
| 301 |
return null; |
| 302 |
}; |
| 303 |
|
| 304 |
const DOMContentLoadedCallbacks = []; |
| 305 |
|
| 306 |
const onDOMContentLoaded = callback => { |
| 307 |
if (document.readyState === 'loading') { |
| 308 |
// add listener on the first call when the document is in loading state |
| 309 |
if (!DOMContentLoadedCallbacks.length) { |
| 310 |
document.addEventListener('DOMContentLoaded', () => { |
| 311 |
DOMContentLoadedCallbacks.forEach(callback => callback()); |
| 312 |
}); |
| 313 |
} |
| 314 |
|
| 315 |
DOMContentLoadedCallbacks.push(callback); |
| 316 |
} else { |
| 317 |
callback(); |
| 318 |
} |
| 319 |
}; |
| 320 |
|
| 321 |
const isRTL = () => document.documentElement.dir === 'rtl'; |
| 322 |
|
| 323 |
const defineJQueryPlugin = plugin => { |
| 324 |
onDOMContentLoaded(() => { |
| 325 |
const $ = getjQuery(); |
| 326 |
/* istanbul ignore if */ |
| 327 |
|
| 328 |
if ($) { |
| 329 |
const name = plugin.NAME; |
| 330 |
const JQUERY_NO_CONFLICT = $.fn[name]; |
| 331 |
$.fn[name] = plugin.jQueryInterface; |
| 332 |
$.fn[name].Constructor = plugin; |
| 333 |
|
| 334 |
$.fn[name].noConflict = () => { |
| 335 |
$.fn[name] = JQUERY_NO_CONFLICT; |
| 336 |
return plugin.jQueryInterface; |
| 337 |
}; |
| 338 |
} |
| 339 |
}); |
| 340 |
}; |
| 341 |
|
| 342 |
const execute = callback => { |
| 343 |
if (typeof callback === 'function') { |
| 344 |
callback(); |
| 345 |
} |
| 346 |
}; |
| 347 |
|
| 348 |
const executeAfterTransition = (callback, transitionElement, waitForTransition = true) => { |
| 349 |
if (!waitForTransition) { |
| 350 |
execute(callback); |
| 351 |
return; |
| 352 |
} |
| 353 |
|
| 354 |
const durationPadding = 5; |
| 355 |
const emulatedDuration = getTransitionDurationFromElement(transitionElement) + durationPadding; |
| 356 |
let called = false; |
| 357 |
|
| 358 |
const handler = ({ |
| 359 |
target |
| 360 |
}) => { |
| 361 |
if (target !== transitionElement) { |
| 362 |
return; |
| 363 |
} |
| 364 |
|
| 365 |
called = true; |
| 366 |
transitionElement.removeEventListener(TRANSITION_END, handler); |
| 367 |
execute(callback); |
| 368 |
}; |
| 369 |
|
| 370 |
transitionElement.addEventListener(TRANSITION_END, handler); |
| 371 |
setTimeout(() => { |
| 372 |
if (!called) { |
| 373 |
triggerTransitionEnd(transitionElement); |
| 374 |
} |
| 375 |
}, emulatedDuration); |
| 376 |
}; |
| 377 |
/** |
| 378 |
* Return the previous/next element of a list. |
| 379 |
* |
| 380 |
* @param {array} list The list of elements |
| 381 |
* @param activeElement The active element |
| 382 |
* @param shouldGetNext Choose to get next or previous element |
| 383 |
* @param isCycleAllowed |
| 384 |
* @return {Element|elem} The proper element |
| 385 |
*/ |
| 386 |
|
| 387 |
|
| 388 |
const getNextActiveElement = (list, activeElement, shouldGetNext, isCycleAllowed) => { |
| 389 |
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 |
| 390 |
|
| 391 |
if (index === -1) { |
| 392 |
return list[!shouldGetNext && isCycleAllowed ? list.length - 1 : 0]; |
| 393 |
} |
| 394 |
|
| 395 |
const listLength = list.length; |
| 396 |
index += shouldGetNext ? 1 : -1; |
| 397 |
|
| 398 |
if (isCycleAllowed) { |
| 399 |
index = (index + listLength) % listLength; |
| 400 |
} |
| 401 |
|
| 402 |
return list[Math.max(0, Math.min(index, listLength - 1))]; |
| 403 |
}; |
| 404 |
|
| 405 |
/** |
| 406 |
* -------------------------------------------------------------------------- |
| 407 |
* Bootstrap (v5.0.2): dom/event-handler.js |
| 408 |
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 409 |
* -------------------------------------------------------------------------- |
| 410 |
*/ |
| 411 |
/** |
| 412 |
* ------------------------------------------------------------------------ |
| 413 |
* Constants |
| 414 |
* ------------------------------------------------------------------------ |
| 415 |
*/ |
| 416 |
|
| 417 |
const namespaceRegex = /[^.]*(?=\..*)\.|.*/; |
| 418 |
const stripNameRegex = /\..*/; |
| 419 |
const stripUidRegex = /::\d+$/; |
| 420 |
const eventRegistry = {}; // Events storage |
| 421 |
|
| 422 |
let uidEvent = 1; |
| 423 |
const customEvents = { |
| 424 |
mouseenter: 'mouseover', |
| 425 |
mouseleave: 'mouseout' |
| 426 |
}; |
| 427 |
const customEventsRegex = /^(mouseenter|mouseleave)/i; |
| 428 |
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']); |
| 429 |
/** |
| 430 |
* ------------------------------------------------------------------------ |
| 431 |
* Private methods |
| 432 |
* ------------------------------------------------------------------------ |
| 433 |
*/ |
| 434 |
|
| 435 |
function getUidEvent(element, uid) { |
| 436 |
return uid && `${uid}::${uidEvent++}` || element.uidEvent || uidEvent++; |
| 437 |
} |
| 438 |
|
| 439 |
function getEvent(element) { |
| 440 |
const uid = getUidEvent(element); |
| 441 |
element.uidEvent = uid; |
| 442 |
eventRegistry[uid] = eventRegistry[uid] || {}; |
| 443 |
return eventRegistry[uid]; |
| 444 |
} |
| 445 |
|
| 446 |
function bootstrapHandler(element, fn) { |
| 447 |
return function handler(event) { |
| 448 |
event.delegateTarget = element; |
| 449 |
|
| 450 |
if (handler.oneOff) { |
| 451 |
EventHandler.off(element, event.type, fn); |
| 452 |
} |
| 453 |
|
| 454 |
return fn.apply(element, [event]); |
| 455 |
}; |
| 456 |
} |
| 457 |
|
| 458 |
function bootstrapDelegationHandler(element, selector, fn) { |
| 459 |
return function handler(event) { |
| 460 |
const domElements = element.querySelectorAll(selector); |
| 461 |
|
| 462 |
for (let { |
| 463 |
target |
| 464 |
} = event; target && target !== this; target = target.parentNode) { |
| 465 |
for (let i = domElements.length; i--;) { |
| 466 |
if (domElements[i] === target) { |
| 467 |
event.delegateTarget = target; |
| 468 |
|
| 469 |
if (handler.oneOff) { |
| 470 |
// eslint-disable-next-line unicorn/consistent-destructuring |
| 471 |
EventHandler.off(element, event.type, selector, fn); |
| 472 |
} |
| 473 |
|
| 474 |
return fn.apply(target, [event]); |
| 475 |
} |
| 476 |
} |
| 477 |
} // To please ESLint |
| 478 |
|
| 479 |
|
| 480 |
return null; |
| 481 |
}; |
| 482 |
} |
| 483 |
|
| 484 |
function findHandler(events, handler, delegationSelector = null) { |
| 485 |
const uidEventList = Object.keys(events); |
| 486 |
|
| 487 |
for (let i = 0, len = uidEventList.length; i < len; i++) { |
| 488 |
const event = events[uidEventList[i]]; |
| 489 |
|
| 490 |
if (event.originalHandler === handler && event.delegationSelector === delegationSelector) { |
| 491 |
return event; |
| 492 |
} |
| 493 |
} |
| 494 |
|
| 495 |
return null; |
| 496 |
} |
| 497 |
|
| 498 |
function normalizeParams(originalTypeEvent, handler, delegationFn) { |
| 499 |
const delegation = typeof handler === 'string'; |
| 500 |
const originalHandler = delegation ? delegationFn : handler; |
| 501 |
let typeEvent = getTypeEvent(originalTypeEvent); |
| 502 |
const isNative = nativeEvents.has(typeEvent); |
| 503 |
|
| 504 |
if (!isNative) { |
| 505 |
typeEvent = originalTypeEvent; |
| 506 |
} |
| 507 |
|
| 508 |
return [delegation, originalHandler, typeEvent]; |
| 509 |
} |
| 510 |
|
| 511 |
function addHandler(element, originalTypeEvent, handler, delegationFn, oneOff) { |
| 512 |
if (typeof originalTypeEvent !== 'string' || !element) { |
| 513 |
return; |
| 514 |
} |
| 515 |
|
| 516 |
if (!handler) { |
| 517 |
handler = delegationFn; |
| 518 |
delegationFn = null; |
| 519 |
} // in case of mouseenter or mouseleave wrap the handler within a function that checks for its DOM position |
| 520 |
// this prevents the handler from being dispatched the same way as mouseover or mouseout does |
| 521 |
|
| 522 |
|
| 523 |
if (customEventsRegex.test(originalTypeEvent)) { |
| 524 |
const wrapFn = fn => { |
| 525 |
return function (event) { |
| 526 |
if (!event.relatedTarget || event.relatedTarget !== event.delegateTarget && !event.delegateTarget.contains(event.relatedTarget)) { |
| 527 |
return fn.call(this, event); |
| 528 |
} |
| 529 |
}; |
| 530 |
}; |
| 531 |
|
| 532 |
if (delegationFn) { |
| 533 |
delegationFn = wrapFn(delegationFn); |
| 534 |
} else { |
| 535 |
handler = wrapFn(handler); |
| 536 |
} |
| 537 |
} |
| 538 |
|
| 539 |
const [delegation, originalHandler, typeEvent] = normalizeParams(originalTypeEvent, handler, delegationFn); |
| 540 |
const events = getEvent(element); |
| 541 |
const handlers = events[typeEvent] || (events[typeEvent] = {}); |
| 542 |
const previousFn = findHandler(handlers, originalHandler, delegation ? handler : null); |
| 543 |
|
| 544 |
if (previousFn) { |
| 545 |
previousFn.oneOff = previousFn.oneOff && oneOff; |
| 546 |
return; |
| 547 |
} |
| 548 |
|
| 549 |
const uid = getUidEvent(originalHandler, originalTypeEvent.replace(namespaceRegex, '')); |
| 550 |
const fn = delegation ? bootstrapDelegationHandler(element, handler, delegationFn) : bootstrapHandler(element, handler); |
| 551 |
fn.delegationSelector = delegation ? handler : null; |
| 552 |
fn.originalHandler = originalHandler; |
| 553 |
fn.oneOff = oneOff; |
| 554 |
fn.uidEvent = uid; |
| 555 |
handlers[uid] = fn; |
| 556 |
element.addEventListener(typeEvent, fn, delegation); |
| 557 |
} |
| 558 |
|
| 559 |
function removeHandler(element, events, typeEvent, handler, delegationSelector) { |
| 560 |
const fn = findHandler(events[typeEvent], handler, delegationSelector); |
| 561 |
|
| 562 |
if (!fn) { |
| 563 |
return; |
| 564 |
} |
| 565 |
|
| 566 |
element.removeEventListener(typeEvent, fn, Boolean(delegationSelector)); |
| 567 |
delete events[typeEvent][fn.uidEvent]; |
| 568 |
} |
| 569 |
|
| 570 |
function removeNamespacedHandlers(element, events, typeEvent, namespace) { |
| 571 |
const storeElementEvent = events[typeEvent] || {}; |
| 572 |
Object.keys(storeElementEvent).forEach(handlerKey => { |
| 573 |
if (handlerKey.includes(namespace)) { |
| 574 |
const event = storeElementEvent[handlerKey]; |
| 575 |
removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector); |
| 576 |
} |
| 577 |
}); |
| 578 |
} |
| 579 |
|
| 580 |
function getTypeEvent(event) { |
| 581 |
// allow to get the native events from namespaced events ('click.bs.button' --> 'click') |
| 582 |
event = event.replace(stripNameRegex, ''); |
| 583 |
return customEvents[event] || event; |
| 584 |
} |
| 585 |
|
| 586 |
const EventHandler = { |
| 587 |
on(element, event, handler, delegationFn) { |
| 588 |
addHandler(element, event, handler, delegationFn, false); |
| 589 |
}, |
| 590 |
|
| 591 |
one(element, event, handler, delegationFn) { |
| 592 |
addHandler(element, event, handler, delegationFn, true); |
| 593 |
}, |
| 594 |
|
| 595 |
off(element, originalTypeEvent, handler, delegationFn) { |
| 596 |
if (typeof originalTypeEvent !== 'string' || !element) { |
| 597 |
return; |
| 598 |
} |
| 599 |
|
| 600 |
const [delegation, originalHandler, typeEvent] = normalizeParams(originalTypeEvent, handler, delegationFn); |
| 601 |
const inNamespace = typeEvent !== originalTypeEvent; |
| 602 |
const events = getEvent(element); |
| 603 |
const isNamespace = originalTypeEvent.startsWith('.'); |
| 604 |
|
| 605 |
if (typeof originalHandler !== 'undefined') { |
| 606 |
// Simplest case: handler is passed, remove that listener ONLY. |
| 607 |
if (!events || !events[typeEvent]) { |
| 608 |
return; |
| 609 |
} |
| 610 |
|
| 611 |
removeHandler(element, events, typeEvent, originalHandler, delegation ? handler : null); |
| 612 |
return; |
| 613 |
} |
| 614 |
|
| 615 |
if (isNamespace) { |
| 616 |
Object.keys(events).forEach(elementEvent => { |
| 617 |
removeNamespacedHandlers(element, events, elementEvent, originalTypeEvent.slice(1)); |
| 618 |
}); |
| 619 |
} |
| 620 |
|
| 621 |
const storeElementEvent = events[typeEvent] || {}; |
| 622 |
Object.keys(storeElementEvent).forEach(keyHandlers => { |
| 623 |
const handlerKey = keyHandlers.replace(stripUidRegex, ''); |
| 624 |
|
| 625 |
if (!inNamespace || originalTypeEvent.includes(handlerKey)) { |
| 626 |
const event = storeElementEvent[keyHandlers]; |
| 627 |
removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector); |
| 628 |
} |
| 629 |
}); |
| 630 |
}, |
| 631 |
|
| 632 |
trigger(element, event, args) { |
| 633 |
if (typeof event !== 'string' || !element) { |
| 634 |
return null; |
| 635 |
} |
| 636 |
|
| 637 |
const $ = getjQuery(); |
| 638 |
const typeEvent = getTypeEvent(event); |
| 639 |
const inNamespace = event !== typeEvent; |
| 640 |
const isNative = nativeEvents.has(typeEvent); |
| 641 |
let jQueryEvent; |
| 642 |
let bubbles = true; |
| 643 |
let nativeDispatch = true; |
| 644 |
let defaultPrevented = false; |
| 645 |
let evt = null; |
| 646 |
|
| 647 |
if (inNamespace && $) { |
| 648 |
jQueryEvent = $.Event(event, args); |
| 649 |
$(element).trigger(jQueryEvent); |
| 650 |
bubbles = !jQueryEvent.isPropagationStopped(); |
| 651 |
nativeDispatch = !jQueryEvent.isImmediatePropagationStopped(); |
| 652 |
defaultPrevented = jQueryEvent.isDefaultPrevented(); |
| 653 |
} |
| 654 |
|
| 655 |
if (isNative) { |
| 656 |
evt = document.createEvent('HTMLEvents'); |
| 657 |
evt.initEvent(typeEvent, bubbles, true); |
| 658 |
} else { |
| 659 |
evt = new CustomEvent(event, { |
| 660 |
bubbles, |
| 661 |
cancelable: true |
| 662 |
}); |
| 663 |
} // merge custom information in our event |
| 664 |
|
| 665 |
|
| 666 |
if (typeof args !== 'undefined') { |
| 667 |
Object.keys(args).forEach(key => { |
| 668 |
Object.defineProperty(evt, key, { |
| 669 |
get() { |
| 670 |
return args[key]; |
| 671 |
} |
| 672 |
|
| 673 |
}); |
| 674 |
}); |
| 675 |
} |
| 676 |
|
| 677 |
if (defaultPrevented) { |
| 678 |
evt.preventDefault(); |
| 679 |
} |
| 680 |
|
| 681 |
if (nativeDispatch) { |
| 682 |
element.dispatchEvent(evt); |
| 683 |
} |
| 684 |
|
| 685 |
if (evt.defaultPrevented && typeof jQueryEvent !== 'undefined') { |
| 686 |
jQueryEvent.preventDefault(); |
| 687 |
} |
| 688 |
|
| 689 |
return evt; |
| 690 |
} |
| 691 |
|
| 692 |
}; |
| 693 |
|
| 694 |
/** |
| 695 |
* -------------------------------------------------------------------------- |
| 696 |
* Bootstrap (v5.0.2): dom/data.js |
| 697 |
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 698 |
* -------------------------------------------------------------------------- |
| 699 |
*/ |
| 700 |
|
| 701 |
/** |
| 702 |
* ------------------------------------------------------------------------ |
| 703 |
* Constants |
| 704 |
* ------------------------------------------------------------------------ |
| 705 |
*/ |
| 706 |
const elementMap = new Map(); |
| 707 |
var Data = { |
| 708 |
set(element, key, instance) { |
| 709 |
if (!elementMap.has(element)) { |
| 710 |
elementMap.set(element, new Map()); |
| 711 |
} |
| 712 |
|
| 713 |
const instanceMap = elementMap.get(element); // make it clear we only want one instance per element |
| 714 |
// can be removed later when multiple key/instances are fine to be used |
| 715 |
|
| 716 |
if (!instanceMap.has(key) && instanceMap.size !== 0) { |
| 717 |
// eslint-disable-next-line no-console |
| 718 |
console.error(`Bootstrap doesn't allow more than one instance per element. Bound instance: ${Array.from(instanceMap.keys())[0]}.`); |
| 719 |
return; |
| 720 |
} |
| 721 |
|
| 722 |
instanceMap.set(key, instance); |
| 723 |
}, |
| 724 |
|
| 725 |
get(element, key) { |
| 726 |
if (elementMap.has(element)) { |
| 727 |
return elementMap.get(element).get(key) || null; |
| 728 |
} |
| 729 |
|
| 730 |
return null; |
| 731 |
}, |
| 732 |
|
| 733 |
remove(element, key) { |
| 734 |
if (!elementMap.has(element)) { |
| 735 |
return; |
| 736 |
} |
| 737 |
|
| 738 |
const instanceMap = elementMap.get(element); |
| 739 |
instanceMap.delete(key); // free up element references if there are no instances left for an element |
| 740 |
|
| 741 |
if (instanceMap.size === 0) { |
| 742 |
elementMap.delete(element); |
| 743 |
} |
| 744 |
} |
| 745 |
|
| 746 |
}; |
| 747 |
|
| 748 |
/** |
| 749 |
* -------------------------------------------------------------------------- |
| 750 |
* Bootstrap (v5.0.2): base-component.js |
| 751 |
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 752 |
* -------------------------------------------------------------------------- |
| 753 |
*/ |
| 754 |
/** |
| 755 |
* ------------------------------------------------------------------------ |
| 756 |
* Constants |
| 757 |
* ------------------------------------------------------------------------ |
| 758 |
*/ |
| 759 |
|
| 760 |
const VERSION = '5.0.2'; |
| 761 |
|
| 762 |
class BaseComponent { |
| 763 |
constructor(element) { |
| 764 |
element = getElement(element); |
| 765 |
|
| 766 |
if (!element) { |
| 767 |
return; |
| 768 |
} |
| 769 |
|
| 770 |
this._element = element; |
| 771 |
Data.set(this._element, this.constructor.DATA_KEY, this); |
| 772 |
} |
| 773 |
|
| 774 |
dispose() { |
| 775 |
Data.remove(this._element, this.constructor.DATA_KEY); |
| 776 |
EventHandler.off(this._element, this.constructor.EVENT_KEY); |
| 777 |
Object.getOwnPropertyNames(this).forEach(propertyName => { |
| 778 |
this[propertyName] = null; |
| 779 |
}); |
| 780 |
} |
| 781 |
|
| 782 |
_queueCallback(callback, element, isAnimated = true) { |
| 783 |
executeAfterTransition(callback, element, isAnimated); |
| 784 |
} |
| 785 |
/** Static */ |
| 786 |
|
| 787 |
|
| 788 |
static getInstance(element) { |
| 789 |
return Data.get(element, this.DATA_KEY); |
| 790 |
} |
| 791 |
|
| 792 |
static getOrCreateInstance(element, config = {}) { |
| 793 |
return this.getInstance(element) || new this(element, typeof config === 'object' ? config : null); |
| 794 |
} |
| 795 |
|
| 796 |
static get VERSION() { |
| 797 |
return VERSION; |
| 798 |
} |
| 799 |
|
| 800 |
static get NAME() { |
| 801 |
throw new Error('You have to implement the static method "NAME", for each component!'); |
| 802 |
} |
| 803 |
|
| 804 |
static get DATA_KEY() { |
| 805 |
return `bs.${this.NAME}`; |
| 806 |
} |
| 807 |
|
| 808 |
static get EVENT_KEY() { |
| 809 |
return `.${this.DATA_KEY}`; |
| 810 |
} |
| 811 |
|
| 812 |
} |
| 813 |
|
| 814 |
/** |
| 815 |
* -------------------------------------------------------------------------- |
| 816 |
* Bootstrap (v5.0.2): alert.js |
| 817 |
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 818 |
* -------------------------------------------------------------------------- |
| 819 |
*/ |
| 820 |
/** |
| 821 |
* ------------------------------------------------------------------------ |
| 822 |
* Constants |
| 823 |
* ------------------------------------------------------------------------ |
| 824 |
*/ |
| 825 |
|
| 826 |
const NAME$c = 'alert'; |
| 827 |
const DATA_KEY$b = 'bs.alert'; |
| 828 |
const EVENT_KEY$b = `.${DATA_KEY$b}`; |
| 829 |
const DATA_API_KEY$8 = '.data-api'; |
| 830 |
const SELECTOR_DISMISS = '[data-bs-dismiss="alert"]'; |
| 831 |
const EVENT_CLOSE = `close${EVENT_KEY$b}`; |
| 832 |
const EVENT_CLOSED = `closed${EVENT_KEY$b}`; |
| 833 |
const EVENT_CLICK_DATA_API$7 = `click${EVENT_KEY$b}${DATA_API_KEY$8}`; |
| 834 |
const CLASS_NAME_ALERT = 'alert'; |
| 835 |
const CLASS_NAME_FADE$6 = 'fade'; |
| 836 |
const CLASS_NAME_SHOW$9 = 'show'; |
| 837 |
/** |
| 838 |
* ------------------------------------------------------------------------ |
| 839 |
* Class Definition |
| 840 |
* ------------------------------------------------------------------------ |
| 841 |
*/ |
| 842 |
|
| 843 |
class Alert extends BaseComponent { |
| 844 |
// Getters |
| 845 |
static get NAME() { |
| 846 |
return NAME$c; |
| 847 |
} // Public |
| 848 |
|
| 849 |
|
| 850 |
close(element) { |
| 851 |
const rootElement = element ? this._getRootElement(element) : this._element; |
| 852 |
|
| 853 |
const customEvent = this._triggerCloseEvent(rootElement); |
| 854 |
|
| 855 |
if (customEvent === null || customEvent.defaultPrevented) { |
| 856 |
return; |
| 857 |
} |
| 858 |
|
| 859 |
this._removeElement(rootElement); |
| 860 |
} // Private |
| 861 |
|
| 862 |
|
| 863 |
_getRootElement(element) { |
| 864 |
return getElementFromSelector(element) || element.closest(`.${CLASS_NAME_ALERT}`); |
| 865 |
} |
| 866 |
|
| 867 |
_triggerCloseEvent(element) { |
| 868 |
return EventHandler.trigger(element, EVENT_CLOSE); |
| 869 |
} |
| 870 |
|
| 871 |
_removeElement(element) { |
| 872 |
element.classList.remove(CLASS_NAME_SHOW$9); |
| 873 |
const isAnimated = element.classList.contains(CLASS_NAME_FADE$6); |
| 874 |
|
| 875 |
this._queueCallback(() => this._destroyElement(element), element, isAnimated); |
| 876 |
} |
| 877 |
|
| 878 |
_destroyElement(element) { |
| 879 |
element.remove(); |
| 880 |
EventHandler.trigger(element, EVENT_CLOSED); |
| 881 |
} // Static |
| 882 |
|
| 883 |
|
| 884 |
static jQueryInterface(config) { |
| 885 |
return this.each(function () { |
| 886 |
const data = Alert.getOrCreateInstance(this); |
| 887 |
|
| 888 |
if (config === 'close') { |
| 889 |
data[config](this); |
| 890 |
} |
| 891 |
}); |
| 892 |
} |
| 893 |
|
| 894 |
static handleDismiss(alertInstance) { |
| 895 |
return function (event) { |
| 896 |
if (event) { |
| 897 |
event.preventDefault(); |
| 898 |
} |
| 899 |
|
| 900 |
alertInstance.close(this); |
| 901 |
}; |
| 902 |
} |
| 903 |
|
| 904 |
} |
| 905 |
/** |
| 906 |
* ------------------------------------------------------------------------ |
| 907 |
* Data Api implementation |
| 908 |
* ------------------------------------------------------------------------ |
| 909 |
*/ |
| 910 |
|
| 911 |
|
| 912 |
EventHandler.on(document, EVENT_CLICK_DATA_API$7, SELECTOR_DISMISS, Alert.handleDismiss(new Alert())); |
| 913 |
/** |
| 914 |
* ------------------------------------------------------------------------ |
| 915 |
* jQuery |
| 916 |
* ------------------------------------------------------------------------ |
| 917 |
* add .Alert to jQuery only if jQuery is present |
| 918 |
*/ |
| 919 |
|
| 920 |
defineJQueryPlugin(Alert); |
| 921 |
|
| 922 |
/** |
| 923 |
* -------------------------------------------------------------------------- |
| 924 |
* Bootstrap (v5.0.2): button.js |
| 925 |
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 926 |
* -------------------------------------------------------------------------- |
| 927 |
*/ |
| 928 |
/** |
| 929 |
* ------------------------------------------------------------------------ |
| 930 |
* Constants |
| 931 |
* ------------------------------------------------------------------------ |
| 932 |
*/ |
| 933 |
|
| 934 |
const NAME$b = 'button'; |
| 935 |
const DATA_KEY$a = 'bs.button'; |
| 936 |
const EVENT_KEY$a = `.${DATA_KEY$a}`; |
| 937 |
const DATA_API_KEY$7 = '.data-api'; |
| 938 |
const CLASS_NAME_ACTIVE$3 = 'active'; |
| 939 |
const SELECTOR_DATA_TOGGLE$5 = '[data-bs-toggle="button"]'; |
| 940 |
const EVENT_CLICK_DATA_API$6 = `click${EVENT_KEY$a}${DATA_API_KEY$7}`; |
| 941 |
/** |
| 942 |
* ------------------------------------------------------------------------ |
| 943 |
* Class Definition |
| 944 |
* ------------------------------------------------------------------------ |
| 945 |
*/ |
| 946 |
|
| 947 |
class Button extends BaseComponent { |
| 948 |
// Getters |
| 949 |
static get NAME() { |
| 950 |
return NAME$b; |
| 951 |
} // Public |
| 952 |
|
| 953 |
|
| 954 |
toggle() { |
| 955 |
// Toggle class and sync the `aria-pressed` attribute with the return value of the `.toggle()` method |
| 956 |
this._element.setAttribute('aria-pressed', this._element.classList.toggle(CLASS_NAME_ACTIVE$3)); |
| 957 |
} // Static |
| 958 |
|
| 959 |
|
| 960 |
static jQueryInterface(config) { |
| 961 |
return this.each(function () { |
| 962 |
const data = Button.getOrCreateInstance(this); |
| 963 |
|
| 964 |
if (config === 'toggle') { |
| 965 |
data[config](); |
| 966 |
} |
| 967 |
}); |
| 968 |
} |
| 969 |
|
| 970 |
} |
| 971 |
/** |
| 972 |
* ------------------------------------------------------------------------ |
| 973 |
* Data Api implementation |
| 974 |
* ------------------------------------------------------------------------ |
| 975 |
*/ |
| 976 |
|
| 977 |
|
| 978 |
EventHandler.on(document, EVENT_CLICK_DATA_API$6, SELECTOR_DATA_TOGGLE$5, event => { |
| 979 |
event.preventDefault(); |
| 980 |
const button = event.target.closest(SELECTOR_DATA_TOGGLE$5); |
| 981 |
const data = Button.getOrCreateInstance(button); |
| 982 |
data.toggle(); |
| 983 |
}); |
| 984 |
/** |
| 985 |
* ------------------------------------------------------------------------ |
| 986 |
* jQuery |
| 987 |
* ------------------------------------------------------------------------ |
| 988 |
* add .Button to jQuery only if jQuery is present |
| 989 |
*/ |
| 990 |
|
| 991 |
defineJQueryPlugin(Button); |
| 992 |
|
| 993 |
/** |
| 994 |
* -------------------------------------------------------------------------- |
| 995 |
* Bootstrap (v5.0.2): dom/manipulator.js |
| 996 |
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 997 |
* -------------------------------------------------------------------------- |
| 998 |
*/ |
| 999 |
function normalizeData(val) { |
| 1000 |
if (val === 'true') { |
| 1001 |
return true; |
| 1002 |
} |
| 1003 |
|
| 1004 |
if (val === 'false') { |
| 1005 |
return false; |
| 1006 |
} |
| 1007 |
|
| 1008 |
if (val === Number(val).toString()) { |
| 1009 |
return Number(val); |
| 1010 |
} |
| 1011 |
|
| 1012 |
if (val === '' || val === 'null') { |
| 1013 |
return null; |
| 1014 |
} |
| 1015 |
|
| 1016 |
return val; |
| 1017 |
} |
| 1018 |
|
| 1019 |
function normalizeDataKey(key) { |
| 1020 |
return key.replace(/[A-Z]/g, chr => `-${chr.toLowerCase()}`); |
| 1021 |
} |
| 1022 |
|
| 1023 |
const Manipulator = { |
| 1024 |
setDataAttribute(element, key, value) { |
| 1025 |
element.setAttribute(`data-bs-${normalizeDataKey(key)}`, value); |
| 1026 |
}, |
| 1027 |
|
| 1028 |
removeDataAttribute(element, key) { |
| 1029 |
element.removeAttribute(`data-bs-${normalizeDataKey(key)}`); |
| 1030 |
}, |
| 1031 |
|
| 1032 |
getDataAttributes(element) { |
| 1033 |
if (!element) { |
| 1034 |
return {}; |
| 1035 |
} |
| 1036 |
|
| 1037 |
const attributes = {}; |
| 1038 |
Object.keys(element.dataset).filter(key => key.startsWith('bs')).forEach(key => { |
| 1039 |
let pureKey = key.replace(/^bs/, ''); |
| 1040 |
pureKey = pureKey.charAt(0).toLowerCase() + pureKey.slice(1, pureKey.length); |
| 1041 |
attributes[pureKey] = normalizeData(element.dataset[key]); |
| 1042 |
}); |
| 1043 |
return attributes; |
| 1044 |
}, |
| 1045 |
|
| 1046 |
getDataAttribute(element, key) { |
| 1047 |
return normalizeData(element.getAttribute(`data-bs-${normalizeDataKey(key)}`)); |
| 1048 |
}, |
| 1049 |
|
| 1050 |
offset(element) { |
| 1051 |
const rect = element.getBoundingClientRect(); |
| 1052 |
return { |
| 1053 |
top: rect.top + document.body.scrollTop, |
| 1054 |
left: rect.left + document.body.scrollLeft |
| 1055 |
}; |
| 1056 |
}, |
| 1057 |
|
| 1058 |
position(element) { |
| 1059 |
return { |
| 1060 |
top: element.offsetTop, |
| 1061 |
left: element.offsetLeft |
| 1062 |
}; |
| 1063 |
} |
| 1064 |
|
| 1065 |
}; |
| 1066 |
|
| 1067 |
/** |
| 1068 |
* -------------------------------------------------------------------------- |
| 1069 |
* Bootstrap (v5.0.2): carousel.js |
| 1070 |
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 1071 |
* -------------------------------------------------------------------------- |
| 1072 |
*/ |
| 1073 |
/** |
| 1074 |
* ------------------------------------------------------------------------ |
| 1075 |
* Constants |
| 1076 |
* ------------------------------------------------------------------------ |
| 1077 |
*/ |
| 1078 |
|
| 1079 |
const NAME$a = 'carousel'; |
| 1080 |
const DATA_KEY$9 = 'bs.carousel'; |
| 1081 |
const EVENT_KEY$9 = `.${DATA_KEY$9}`; |
| 1082 |
const DATA_API_KEY$6 = '.data-api'; |
| 1083 |
const ARROW_LEFT_KEY = 'ArrowLeft'; |
| 1084 |
const ARROW_RIGHT_KEY = 'ArrowRight'; |
| 1085 |
const TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch |
| 1086 |
|
| 1087 |
const SWIPE_THRESHOLD = 40; |
| 1088 |
const Default$9 = { |
| 1089 |
interval: 5000, |
| 1090 |
keyboard: true, |
| 1091 |
slide: false, |
| 1092 |
pause: 'hover', |
| 1093 |
wrap: true, |
| 1094 |
touch: true |
| 1095 |
}; |
| 1096 |
const DefaultType$9 = { |
| 1097 |
interval: '(number|boolean)', |
| 1098 |
keyboard: 'boolean', |
| 1099 |
slide: '(boolean|string)', |
| 1100 |
pause: '(string|boolean)', |
| 1101 |
wrap: 'boolean', |
| 1102 |
touch: 'boolean' |
| 1103 |
}; |
| 1104 |
const ORDER_NEXT = 'next'; |
| 1105 |
const ORDER_PREV = 'prev'; |
| 1106 |
const DIRECTION_LEFT = 'left'; |
| 1107 |
const DIRECTION_RIGHT = 'right'; |
| 1108 |
const KEY_TO_DIRECTION = { |
| 1109 |
[ARROW_LEFT_KEY]: DIRECTION_RIGHT, |
| 1110 |
[ARROW_RIGHT_KEY]: DIRECTION_LEFT |
| 1111 |
}; |
| 1112 |
const EVENT_SLIDE = `slide${EVENT_KEY$9}`; |
| 1113 |
const EVENT_SLID = `slid${EVENT_KEY$9}`; |
| 1114 |
const EVENT_KEYDOWN = `keydown${EVENT_KEY$9}`; |
| 1115 |
const EVENT_MOUSEENTER = `mouseenter${EVENT_KEY$9}`; |
| 1116 |
const EVENT_MOUSELEAVE = `mouseleave${EVENT_KEY$9}`; |
| 1117 |
const EVENT_TOUCHSTART = `touchstart${EVENT_KEY$9}`; |
| 1118 |
const EVENT_TOUCHMOVE = `touchmove${EVENT_KEY$9}`; |
| 1119 |
const EVENT_TOUCHEND = `touchend${EVENT_KEY$9}`; |
| 1120 |
const EVENT_POINTERDOWN = `pointerdown${EVENT_KEY$9}`; |
| 1121 |
const EVENT_POINTERUP = `pointerup${EVENT_KEY$9}`; |
| 1122 |
const EVENT_DRAG_START = `dragstart${EVENT_KEY$9}`; |
| 1123 |
const EVENT_LOAD_DATA_API$2 = `load${EVENT_KEY$9}${DATA_API_KEY$6}`; |
| 1124 |
const EVENT_CLICK_DATA_API$5 = `click${EVENT_KEY$9}${DATA_API_KEY$6}`; |
| 1125 |
const CLASS_NAME_CAROUSEL = 'carousel'; |
| 1126 |
const CLASS_NAME_ACTIVE$2 = 'active'; |
| 1127 |
const CLASS_NAME_SLIDE = 'slide'; |
| 1128 |
const CLASS_NAME_END = 'carousel-item-end'; |
| 1129 |
const CLASS_NAME_START = 'carousel-item-start'; |
| 1130 |
const CLASS_NAME_NEXT = 'carousel-item-next'; |
| 1131 |
const CLASS_NAME_PREV = 'carousel-item-prev'; |
| 1132 |
const CLASS_NAME_POINTER_EVENT = 'pointer-event'; |
| 1133 |
const SELECTOR_ACTIVE$1 = '.active'; |
| 1134 |
const SELECTOR_ACTIVE_ITEM = '.active.carousel-item'; |
| 1135 |
const SELECTOR_ITEM = '.carousel-item'; |
| 1136 |
const SELECTOR_ITEM_IMG = '.carousel-item img'; |
| 1137 |
const SELECTOR_NEXT_PREV = '.carousel-item-next, .carousel-item-prev'; |
| 1138 |
const SELECTOR_INDICATORS = '.carousel-indicators'; |
| 1139 |
const SELECTOR_INDICATOR = '[data-bs-target]'; |
| 1140 |
const SELECTOR_DATA_SLIDE = '[data-bs-slide], [data-bs-slide-to]'; |
| 1141 |
const SELECTOR_DATA_RIDE = '[data-bs-ride="carousel"]'; |
| 1142 |
const POINTER_TYPE_TOUCH = 'touch'; |
| 1143 |
const POINTER_TYPE_PEN = 'pen'; |
| 1144 |
/** |
| 1145 |
* ------------------------------------------------------------------------ |
| 1146 |
* Class Definition |
| 1147 |
* ------------------------------------------------------------------------ |
| 1148 |
*/ |
| 1149 |
|
| 1150 |
class Carousel extends BaseComponent { |
| 1151 |
constructor(element, config) { |
| 1152 |
super(element); |
| 1153 |
this._items = null; |
| 1154 |
this._interval = null; |
| 1155 |
this._activeElement = null; |
| 1156 |
this._isPaused = false; |
| 1157 |
this._isSliding = false; |
| 1158 |
this.touchTimeout = null; |
| 1159 |
this.touchStartX = 0; |
| 1160 |
this.touchDeltaX = 0; |
| 1161 |
this._config = this._getConfig(config); |
| 1162 |
this._indicatorsElement = SelectorEngine.findOne(SELECTOR_INDICATORS, this._element); |
| 1163 |
this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0; |
| 1164 |
this._pointerEvent = Boolean(window.PointerEvent); |
| 1165 |
|
| 1166 |
this._addEventListeners(); |
| 1167 |
} // Getters |
| 1168 |
|
| 1169 |
|
| 1170 |
static get Default() { |
| 1171 |
return Default$9; |
| 1172 |
} |
| 1173 |
|
| 1174 |
static get NAME() { |
| 1175 |
return NAME$a; |
| 1176 |
} // Public |
| 1177 |
|
| 1178 |
|
| 1179 |
next() { |
| 1180 |
this._slide(ORDER_NEXT); |
| 1181 |
} |
| 1182 |
|
| 1183 |
nextWhenVisible() { |
| 1184 |
// Don't call next when the page isn't visible |
| 1185 |
// or the carousel or its parent isn't visible |
| 1186 |
if (!document.hidden && isVisible(this._element)) { |
| 1187 |
this.next(); |
| 1188 |
} |
| 1189 |
} |
| 1190 |
|
| 1191 |
prev() { |
| 1192 |
this._slide(ORDER_PREV); |
| 1193 |
} |
| 1194 |
|
| 1195 |
pause(event) { |
| 1196 |
if (!event) { |
| 1197 |
this._isPaused = true; |
| 1198 |
} |
| 1199 |
|
| 1200 |
if (SelectorEngine.findOne(SELECTOR_NEXT_PREV, this._element)) { |
| 1201 |
triggerTransitionEnd(this._element); |
| 1202 |
this.cycle(true); |
| 1203 |
} |
| 1204 |
|
| 1205 |
clearInterval(this._interval); |
| 1206 |
this._interval = null; |
| 1207 |
} |
| 1208 |
|
| 1209 |
cycle(event) { |
| 1210 |
if (!event) { |
| 1211 |
this._isPaused = false; |
| 1212 |
} |
| 1213 |
|
| 1214 |
if (this._interval) { |
| 1215 |
clearInterval(this._interval); |
| 1216 |
this._interval = null; |
| 1217 |
} |
| 1218 |
|
| 1219 |
if (this._config && this._config.interval && !this._isPaused) { |
| 1220 |
this._updateInterval(); |
| 1221 |
|
| 1222 |
this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval); |
| 1223 |
} |
| 1224 |
} |
| 1225 |
|
| 1226 |
to(index) { |
| 1227 |
this._activeElement = SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element); |
| 1228 |
|
| 1229 |
const activeIndex = this._getItemIndex(this._activeElement); |
| 1230 |
|
| 1231 |
if (index > this._items.length - 1 || index < 0) { |
| 1232 |
return; |
| 1233 |
} |
| 1234 |
|
| 1235 |
if (this._isSliding) { |
| 1236 |
EventHandler.one(this._element, EVENT_SLID, () => this.to(index)); |
| 1237 |
return; |
| 1238 |
} |
| 1239 |
|
| 1240 |
if (activeIndex === index) { |
| 1241 |
this.pause(); |
| 1242 |
this.cycle(); |
| 1243 |
return; |
| 1244 |
} |
| 1245 |
|
| 1246 |
const order = index > activeIndex ? ORDER_NEXT : ORDER_PREV; |
| 1247 |
|
| 1248 |
this._slide(order, this._items[index]); |
| 1249 |
} // Private |
| 1250 |
|
| 1251 |
|
| 1252 |
_getConfig(config) { |
| 1253 |
config = { ...Default$9, |
| 1254 |
...Manipulator.getDataAttributes(this._element), |
| 1255 |
...(typeof config === 'object' ? config : {}) |
| 1256 |
}; |
| 1257 |
typeCheckConfig(NAME$a, config, DefaultType$9); |
| 1258 |
return config; |
| 1259 |
} |
| 1260 |
|
| 1261 |
_handleSwipe() { |
| 1262 |
const absDeltax = Math.abs(this.touchDeltaX); |
| 1263 |
|
| 1264 |
if (absDeltax <= SWIPE_THRESHOLD) { |
| 1265 |
return; |
| 1266 |
} |
| 1267 |
|
| 1268 |
const direction = absDeltax / this.touchDeltaX; |
| 1269 |
this.touchDeltaX = 0; |
| 1270 |
|
| 1271 |
if (!direction) { |
| 1272 |
return; |
| 1273 |
} |
| 1274 |
|
| 1275 |
this._slide(direction > 0 ? DIRECTION_RIGHT : DIRECTION_LEFT); |
| 1276 |
} |
| 1277 |
|
| 1278 |
_addEventListeners() { |
| 1279 |
if (this._config.keyboard) { |
| 1280 |
EventHandler.on(this._element, EVENT_KEYDOWN, event => this._keydown(event)); |
| 1281 |
} |
| 1282 |
|
| 1283 |
if (this._config.pause === 'hover') { |
| 1284 |
EventHandler.on(this._element, EVENT_MOUSEENTER, event => this.pause(event)); |
| 1285 |
EventHandler.on(this._element, EVENT_MOUSELEAVE, event => this.cycle(event)); |
| 1286 |
} |
| 1287 |
|
| 1288 |
if (this._config.touch && this._touchSupported) { |
| 1289 |
this._addTouchEventListeners(); |
| 1290 |
} |
| 1291 |
} |
| 1292 |
|
| 1293 |
_addTouchEventListeners() { |
| 1294 |
const start = event => { |
| 1295 |
if (this._pointerEvent && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH)) { |
| 1296 |
this.touchStartX = event.clientX; |
| 1297 |
} else if (!this._pointerEvent) { |
| 1298 |
this.touchStartX = event.touches[0].clientX; |
| 1299 |
} |
| 1300 |
}; |
| 1301 |
|
| 1302 |
const move = event => { |
| 1303 |
// ensure swiping with one touch and not pinching |
| 1304 |
this.touchDeltaX = event.touches && event.touches.length > 1 ? 0 : event.touches[0].clientX - this.touchStartX; |
| 1305 |
}; |
| 1306 |
|
| 1307 |
const end = event => { |
| 1308 |
if (this._pointerEvent && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH)) { |
| 1309 |
this.touchDeltaX = event.clientX - this.touchStartX; |
| 1310 |
} |
| 1311 |
|
| 1312 |
this._handleSwipe(); |
| 1313 |
|
| 1314 |
if (this._config.pause === 'hover') { |
| 1315 |
// If it's a touch-enabled device, mouseenter/leave are fired as |
| 1316 |
// part of the mouse compatibility events on first tap - the carousel |
| 1317 |
// would stop cycling until user tapped out of it; |
| 1318 |
// here, we listen for touchend, explicitly pause the carousel |
| 1319 |
// (as if it's the second time we tap on it, mouseenter compat event |
| 1320 |
// is NOT fired) and after a timeout (to allow for mouse compatibility |
| 1321 |
// events to fire) we explicitly restart cycling |
| 1322 |
this.pause(); |
| 1323 |
|
| 1324 |
if (this.touchTimeout) { |
| 1325 |
clearTimeout(this.touchTimeout); |
| 1326 |
} |
| 1327 |
|
| 1328 |
this.touchTimeout = setTimeout(event => this.cycle(event), TOUCHEVENT_COMPAT_WAIT + this._config.interval); |
| 1329 |
} |
| 1330 |
}; |
| 1331 |
|
| 1332 |
SelectorEngine.find(SELECTOR_ITEM_IMG, this._element).forEach(itemImg => { |
| 1333 |
EventHandler.on(itemImg, EVENT_DRAG_START, e => e.preventDefault()); |
| 1334 |
}); |
| 1335 |
|
| 1336 |
if (this._pointerEvent) { |
| 1337 |
EventHandler.on(this._element, EVENT_POINTERDOWN, event => start(event)); |
| 1338 |
EventHandler.on(this._element, EVENT_POINTERUP, event => end(event)); |
| 1339 |
|
| 1340 |
this._element.classList.add(CLASS_NAME_POINTER_EVENT); |
| 1341 |
} else { |
| 1342 |
EventHandler.on(this._element, EVENT_TOUCHSTART, event => start(event)); |
| 1343 |
EventHandler.on(this._element, EVENT_TOUCHMOVE, event => move(event)); |
| 1344 |
EventHandler.on(this._element, EVENT_TOUCHEND, event => end(event)); |
| 1345 |
} |
| 1346 |
} |
| 1347 |
|
| 1348 |
_keydown(event) { |
| 1349 |
if (/input|textarea/i.test(event.target.tagName)) { |
| 1350 |
return; |
| 1351 |
} |
| 1352 |
|
| 1353 |
const direction = KEY_TO_DIRECTION[event.key]; |
| 1354 |
|
| 1355 |
if (direction) { |
| 1356 |
event.preventDefault(); |
| 1357 |
|
| 1358 |
this._slide(direction); |
| 1359 |
} |
| 1360 |
} |
| 1361 |
|
| 1362 |
_getItemIndex(element) { |
| 1363 |
this._items = element && element.parentNode ? SelectorEngine.find(SELECTOR_ITEM, element.parentNode) : []; |
| 1364 |
return this._items.indexOf(element); |
| 1365 |
} |
| 1366 |
|
| 1367 |
_getItemByOrder(order, activeElement) { |
| 1368 |
const isNext = order === ORDER_NEXT; |
| 1369 |
return getNextActiveElement(this._items, activeElement, isNext, this._config.wrap); |
| 1370 |
} |
| 1371 |
|
| 1372 |
_triggerSlideEvent(relatedTarget, eventDirectionName) { |
| 1373 |
const targetIndex = this._getItemIndex(relatedTarget); |
| 1374 |
|
| 1375 |
const fromIndex = this._getItemIndex(SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element)); |
| 1376 |
|
| 1377 |
return EventHandler.trigger(this._element, EVENT_SLIDE, { |
| 1378 |
relatedTarget, |
| 1379 |
direction: eventDirectionName, |
| 1380 |
from: fromIndex, |
| 1381 |
to: targetIndex |
| 1382 |
}); |
| 1383 |
} |
| 1384 |
|
| 1385 |
_setActiveIndicatorElement(element) { |
| 1386 |
if (this._indicatorsElement) { |
| 1387 |
const activeIndicator = SelectorEngine.findOne(SELECTOR_ACTIVE$1, this._indicatorsElement); |
| 1388 |
activeIndicator.classList.remove(CLASS_NAME_ACTIVE$2); |
| 1389 |
activeIndicator.removeAttribute('aria-current'); |
| 1390 |
const indicators = SelectorEngine.find(SELECTOR_INDICATOR, this._indicatorsElement); |
| 1391 |
|
| 1392 |
for (let i = 0; i < indicators.length; i++) { |
| 1393 |
if (Number.parseInt(indicators[i].getAttribute('data-bs-slide-to'), 10) === this._getItemIndex(element)) { |
| 1394 |
indicators[i].classList.add(CLASS_NAME_ACTIVE$2); |
| 1395 |
indicators[i].setAttribute('aria-current', 'true'); |
| 1396 |
break; |
| 1397 |
} |
| 1398 |
} |
| 1399 |
} |
| 1400 |
} |
| 1401 |
|
| 1402 |
_updateInterval() { |
| 1403 |
const element = this._activeElement || SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element); |
| 1404 |
|
| 1405 |
if (!element) { |
| 1406 |
return; |
| 1407 |
} |
| 1408 |
|
| 1409 |
const elementInterval = Number.parseInt(element.getAttribute('data-bs-interval'), 10); |
| 1410 |
|
| 1411 |
if (elementInterval) { |
| 1412 |
this._config.defaultInterval = this._config.defaultInterval || this._config.interval; |
| 1413 |
this._config.interval = elementInterval; |
| 1414 |
} else { |
| 1415 |
this._config.interval = this._config.defaultInterval || this._config.interval; |
| 1416 |
} |
| 1417 |
} |
| 1418 |
|
| 1419 |
_slide(directionOrOrder, element) { |
| 1420 |
const order = this._directionToOrder(directionOrOrder); |
| 1421 |
|
| 1422 |
const activeElement = SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element); |
| 1423 |
|
| 1424 |
const activeElementIndex = this._getItemIndex(activeElement); |
| 1425 |
|
| 1426 |
const nextElement = element || this._getItemByOrder(order, activeElement); |
| 1427 |
|
| 1428 |
const nextElementIndex = this._getItemIndex(nextElement); |
| 1429 |
|
| 1430 |
const isCycling = Boolean(this._interval); |
| 1431 |
const isNext = order === ORDER_NEXT; |
| 1432 |
const directionalClassName = isNext ? CLASS_NAME_START : CLASS_NAME_END; |
| 1433 |
const orderClassName = isNext ? CLASS_NAME_NEXT : CLASS_NAME_PREV; |
| 1434 |
|
| 1435 |
const eventDirectionName = this._orderToDirection(order); |
| 1436 |
|
| 1437 |
if (nextElement && nextElement.classList.contains(CLASS_NAME_ACTIVE$2)) { |
| 1438 |
this._isSliding = false; |
| 1439 |
return; |
| 1440 |
} |
| 1441 |
|
| 1442 |
if (this._isSliding) { |
| 1443 |
return; |
| 1444 |
} |
| 1445 |
|
| 1446 |
const slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName); |
| 1447 |
|
| 1448 |
if (slideEvent.defaultPrevented) { |
| 1449 |
return; |
| 1450 |
} |
| 1451 |
|
| 1452 |
if (!activeElement || !nextElement) { |
| 1453 |
// Some weirdness is happening, so we bail |
| 1454 |
return; |
| 1455 |
} |
| 1456 |
|
| 1457 |
this._isSliding = true; |
| 1458 |
|
| 1459 |
if (isCycling) { |
| 1460 |
this.pause(); |
| 1461 |
} |
| 1462 |
|
| 1463 |
this._setActiveIndicatorElement(nextElement); |
| 1464 |
|
| 1465 |
this._activeElement = nextElement; |
| 1466 |
|
| 1467 |
const triggerSlidEvent = () => { |
| 1468 |
EventHandler.trigger(this._element, EVENT_SLID, { |
| 1469 |
relatedTarget: nextElement, |
| 1470 |
direction: eventDirectionName, |
| 1471 |
from: activeElementIndex, |
| 1472 |
to: nextElementIndex |
| 1473 |
}); |
| 1474 |
}; |
| 1475 |
|
| 1476 |
if (this._element.classList.contains(CLASS_NAME_SLIDE)) { |
| 1477 |
nextElement.classList.add(orderClassName); |
| 1478 |
reflow(nextElement); |
| 1479 |
activeElement.classList.add(directionalClassName); |
| 1480 |
nextElement.classList.add(directionalClassName); |
| 1481 |
|
| 1482 |
const completeCallBack = () => { |
| 1483 |
nextElement.classList.remove(directionalClassName, orderClassName); |
| 1484 |
nextElement.classList.add(CLASS_NAME_ACTIVE$2); |
| 1485 |
activeElement.classList.remove(CLASS_NAME_ACTIVE$2, orderClassName, directionalClassName); |
| 1486 |
this._isSliding = false; |
| 1487 |
setTimeout(triggerSlidEvent, 0); |
| 1488 |
}; |
| 1489 |
|
| 1490 |
this._queueCallback(completeCallBack, activeElement, true); |
| 1491 |
} else { |
| 1492 |
activeElement.classList.remove(CLASS_NAME_ACTIVE$2); |
| 1493 |
nextElement.classList.add(CLASS_NAME_ACTIVE$2); |
| 1494 |
this._isSliding = false; |
| 1495 |
triggerSlidEvent(); |
| 1496 |
} |
| 1497 |
|
| 1498 |
if (isCycling) { |
| 1499 |
this.cycle(); |
| 1500 |
} |
| 1501 |
} |
| 1502 |
|
| 1503 |
_directionToOrder(direction) { |
| 1504 |
if (![DIRECTION_RIGHT, DIRECTION_LEFT].includes(direction)) { |
| 1505 |
return direction; |
| 1506 |
} |
| 1507 |
|
| 1508 |
if (isRTL()) { |
| 1509 |
return direction === DIRECTION_LEFT ? ORDER_PREV : ORDER_NEXT; |
| 1510 |
} |
| 1511 |
|
| 1512 |
return direction === DIRECTION_LEFT ? ORDER_NEXT : ORDER_PREV; |
| 1513 |
} |
| 1514 |
|
| 1515 |
_orderToDirection(order) { |
| 1516 |
if (![ORDER_NEXT, ORDER_PREV].includes(order)) { |
| 1517 |
return order; |
| 1518 |
} |
| 1519 |
|
| 1520 |
if (isRTL()) { |
| 1521 |
return order === ORDER_PREV ? DIRECTION_LEFT : DIRECTION_RIGHT; |
| 1522 |
} |
| 1523 |
|
| 1524 |
return order === ORDER_PREV ? DIRECTION_RIGHT : DIRECTION_LEFT; |
| 1525 |
} // Static |
| 1526 |
|
| 1527 |
|
| 1528 |
static carouselInterface(element, config) { |
| 1529 |
const data = Carousel.getOrCreateInstance(element, config); |
| 1530 |
let { |
| 1531 |
_config |
| 1532 |
} = data; |
| 1533 |
|
| 1534 |
if (typeof config === 'object') { |
| 1535 |
_config = { ..._config, |
| 1536 |
...config |
| 1537 |
}; |
| 1538 |
} |
| 1539 |
|
| 1540 |
const action = typeof config === 'string' ? config : _config.slide; |
| 1541 |
|
| 1542 |
if (typeof config === 'number') { |
| 1543 |
data.to(config); |
| 1544 |
} else if (typeof action === 'string') { |
| 1545 |
if (typeof data[action] === 'undefined') { |
| 1546 |
throw new TypeError(`No method named "${action}"`); |
| 1547 |
} |
| 1548 |
|
| 1549 |
data[action](); |
| 1550 |
} else if (_config.interval && _config.ride) { |
| 1551 |
data.pause(); |
| 1552 |
data.cycle(); |
| 1553 |
} |
| 1554 |
} |
| 1555 |
|
| 1556 |
static jQueryInterface(config) { |
| 1557 |
return this.each(function () { |
| 1558 |
Carousel.carouselInterface(this, config); |
| 1559 |
}); |
| 1560 |
} |
| 1561 |
|
| 1562 |
static dataApiClickHandler(event) { |
| 1563 |
const target = getElementFromSelector(this); |
| 1564 |
|
| 1565 |
if (!target || !target.classList.contains(CLASS_NAME_CAROUSEL)) { |
| 1566 |
return; |
| 1567 |
} |
| 1568 |
|
| 1569 |
const config = { ...Manipulator.getDataAttributes(target), |
| 1570 |
...Manipulator.getDataAttributes(this) |
| 1571 |
}; |
| 1572 |
const slideIndex = this.getAttribute('data-bs-slide-to'); |
| 1573 |
|
| 1574 |
if (slideIndex) { |
| 1575 |
config.interval = false; |
| 1576 |
} |
| 1577 |
|
| 1578 |
Carousel.carouselInterface(target, config); |
| 1579 |
|
| 1580 |
if (slideIndex) { |
| 1581 |
Carousel.getInstance(target).to(slideIndex); |
| 1582 |
} |
| 1583 |
|
| 1584 |
event.preventDefault(); |
| 1585 |
} |
| 1586 |
|
| 1587 |
} |
| 1588 |
/** |
| 1589 |
* ------------------------------------------------------------------------ |
| 1590 |
* Data Api implementation |
| 1591 |
* ------------------------------------------------------------------------ |
| 1592 |
*/ |
| 1593 |
|
| 1594 |
|
| 1595 |
EventHandler.on(document, EVENT_CLICK_DATA_API$5, SELECTOR_DATA_SLIDE, Carousel.dataApiClickHandler); |
| 1596 |
EventHandler.on(window, EVENT_LOAD_DATA_API$2, () => { |
| 1597 |
const carousels = SelectorEngine.find(SELECTOR_DATA_RIDE); |
| 1598 |
|
| 1599 |
for (let i = 0, len = carousels.length; i < len; i++) { |
| 1600 |
Carousel.carouselInterface(carousels[i], Carousel.getInstance(carousels[i])); |
| 1601 |
} |
| 1602 |
}); |
| 1603 |
/** |
| 1604 |
* ------------------------------------------------------------------------ |
| 1605 |
* jQuery |
| 1606 |
* ------------------------------------------------------------------------ |
| 1607 |
* add .Carousel to jQuery only if jQuery is present |
| 1608 |
*/ |
| 1609 |
|
| 1610 |
defineJQueryPlugin(Carousel); |
| 1611 |
|
| 1612 |
/** |
| 1613 |
* -------------------------------------------------------------------------- |
| 1614 |
* Bootstrap (v5.0.2): collapse.js |
| 1615 |
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 1616 |
* -------------------------------------------------------------------------- |
| 1617 |
*/ |
| 1618 |
/** |
| 1619 |
* ------------------------------------------------------------------------ |
| 1620 |
* Constants |
| 1621 |
* ------------------------------------------------------------------------ |
| 1622 |
*/ |
| 1623 |
|
| 1624 |
const NAME$9 = 'collapse'; |
| 1625 |
const DATA_KEY$8 = 'bs.collapse'; |
| 1626 |
const EVENT_KEY$8 = `.${DATA_KEY$8}`; |
| 1627 |
const DATA_API_KEY$5 = '.data-api'; |
| 1628 |
const Default$8 = { |
| 1629 |
toggle: true, |
| 1630 |
parent: '' |
| 1631 |
}; |
| 1632 |
const DefaultType$8 = { |
| 1633 |
toggle: 'boolean', |
| 1634 |
parent: '(string|element)' |
| 1635 |
}; |
| 1636 |
const EVENT_SHOW$5 = `show${EVENT_KEY$8}`; |
| 1637 |
const EVENT_SHOWN$5 = `shown${EVENT_KEY$8}`; |
| 1638 |
const EVENT_HIDE$5 = `hide${EVENT_KEY$8}`; |
| 1639 |
const EVENT_HIDDEN$5 = `hidden${EVENT_KEY$8}`; |
| 1640 |
const EVENT_CLICK_DATA_API$4 = `click${EVENT_KEY$8}${DATA_API_KEY$5}`; |
| 1641 |
const CLASS_NAME_SHOW$8 = 'show'; |
| 1642 |
const CLASS_NAME_COLLAPSE = 'collapse'; |
| 1643 |
const CLASS_NAME_COLLAPSING = 'collapsing'; |
| 1644 |
const CLASS_NAME_COLLAPSED = 'collapsed'; |
| 1645 |
const WIDTH = 'width'; |
| 1646 |
const HEIGHT = 'height'; |
| 1647 |
const SELECTOR_ACTIVES = '.show, .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 = SelectorEngine.find(`${SELECTOR_DATA_TOGGLE$4}[href="#${this._element.id}"],` + `${SELECTOR_DATA_TOGGLE$4}[data-bs-target="#${this._element.id}"]`); |
| 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._parent = this._config.parent ? this._getParent() : null; |
| 1676 |
|
| 1677 |
if (!this._config.parent) { |
| 1678 |
this._addAriaAndCollapsedClass(this._element, this._triggerArray); |
| 1679 |
} |
| 1680 |
|
| 1681 |
if (this._config.toggle) { |
| 1682 |
this.toggle(); |
| 1683 |
} |
| 1684 |
} // Getters |
| 1685 |
|
| 1686 |
|
| 1687 |
static get Default() { |
| 1688 |
return Default$8; |
| 1689 |
} |
| 1690 |
|
| 1691 |
static get NAME() { |
| 1692 |
return NAME$9; |
| 1693 |
} // Public |
| 1694 |
|
| 1695 |
|
| 1696 |
toggle() { |
| 1697 |
if (this._element.classList.contains(CLASS_NAME_SHOW$8)) { |
| 1698 |
this.hide(); |
| 1699 |
} else { |
| 1700 |
this.show(); |
| 1701 |
} |
| 1702 |
} |
| 1703 |
|
| 1704 |
show() { |
| 1705 |
if (this._isTransitioning || this._element.classList.contains(CLASS_NAME_SHOW$8)) { |
| 1706 |
return; |
| 1707 |
} |
| 1708 |
|
| 1709 |
let actives; |
| 1710 |
let activesData; |
| 1711 |
|
| 1712 |
if (this._parent) { |
| 1713 |
actives = SelectorEngine.find(SELECTOR_ACTIVES, this._parent).filter(elem => { |
| 1714 |
if (typeof this._config.parent === 'string') { |
| 1715 |
return elem.getAttribute('data-bs-parent') === this._config.parent; |
| 1716 |
} |
| 1717 |
|
| 1718 |
return elem.classList.contains(CLASS_NAME_COLLAPSE); |
| 1719 |
}); |
| 1720 |
|
| 1721 |
if (actives.length === 0) { |
| 1722 |
actives = null; |
| 1723 |
} |
| 1724 |
} |
| 1725 |
|
| 1726 |
const container = SelectorEngine.findOne(this._selector); |
| 1727 |
|
| 1728 |
if (actives) { |
| 1729 |
const tempActiveData = actives.find(elem => container !== elem); |
| 1730 |
activesData = tempActiveData ? Collapse.getInstance(tempActiveData) : null; |
| 1731 |
|
| 1732 |
if (activesData && activesData._isTransitioning) { |
| 1733 |
return; |
| 1734 |
} |
| 1735 |
} |
| 1736 |
|
| 1737 |
const startEvent = EventHandler.trigger(this._element, EVENT_SHOW$5); |
| 1738 |
|
| 1739 |
if (startEvent.defaultPrevented) { |
| 1740 |
return; |
| 1741 |
} |
| 1742 |
|
| 1743 |
if (actives) { |
| 1744 |
actives.forEach(elemActive => { |
| 1745 |
if (container !== elemActive) { |
| 1746 |
Collapse.collapseInterface(elemActive, 'hide'); |
| 1747 |
} |
| 1748 |
|
| 1749 |
if (!activesData) { |
| 1750 |
Data.set(elemActive, DATA_KEY$8, null); |
| 1751 |
} |
| 1752 |
}); |
| 1753 |
} |
| 1754 |
|
| 1755 |
const dimension = this._getDimension(); |
| 1756 |
|
| 1757 |
this._element.classList.remove(CLASS_NAME_COLLAPSE); |
| 1758 |
|
| 1759 |
this._element.classList.add(CLASS_NAME_COLLAPSING); |
| 1760 |
|
| 1761 |
this._element.style[dimension] = 0; |
| 1762 |
|
| 1763 |
if (this._triggerArray.length) { |
| 1764 |
this._triggerArray.forEach(element => { |
| 1765 |
element.classList.remove(CLASS_NAME_COLLAPSED); |
| 1766 |
element.setAttribute('aria-expanded', true); |
| 1767 |
}); |
| 1768 |
} |
| 1769 |
|
| 1770 |
this.setTransitioning(true); |
| 1771 |
|
| 1772 |
const complete = () => { |
| 1773 |
this._element.classList.remove(CLASS_NAME_COLLAPSING); |
| 1774 |
|
| 1775 |
this._element.classList.add(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW$8); |
| 1776 |
|
| 1777 |
this._element.style[dimension] = ''; |
| 1778 |
this.setTransitioning(false); |
| 1779 |
EventHandler.trigger(this._element, EVENT_SHOWN$5); |
| 1780 |
}; |
| 1781 |
|
| 1782 |
const capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1); |
| 1783 |
const scrollSize = `scroll${capitalizedDimension}`; |
| 1784 |
|
| 1785 |
this._queueCallback(complete, this._element, true); |
| 1786 |
|
| 1787 |
this._element.style[dimension] = `${this._element[scrollSize]}px`; |
| 1788 |
} |
| 1789 |
|
| 1790 |
hide() { |
| 1791 |
if (this._isTransitioning || !this._element.classList.contains(CLASS_NAME_SHOW$8)) { |
| 1792 |
return; |
| 1793 |
} |
| 1794 |
|
| 1795 |
const startEvent = EventHandler.trigger(this._element, EVENT_HIDE$5); |
| 1796 |
|
| 1797 |
if (startEvent.defaultPrevented) { |
| 1798 |
return; |
| 1799 |
} |
| 1800 |
|
| 1801 |
const dimension = this._getDimension(); |
| 1802 |
|
| 1803 |
this._element.style[dimension] = `${this._element.getBoundingClientRect()[dimension]}px`; |
| 1804 |
reflow(this._element); |
| 1805 |
|
| 1806 |
this._element.classList.add(CLASS_NAME_COLLAPSING); |
| 1807 |
|
| 1808 |
this._element.classList.remove(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW$8); |
| 1809 |
|
| 1810 |
const triggerArrayLength = this._triggerArray.length; |
| 1811 |
|
| 1812 |
if (triggerArrayLength > 0) { |
| 1813 |
for (let i = 0; i < triggerArrayLength; i++) { |
| 1814 |
const trigger = this._triggerArray[i]; |
| 1815 |
const elem = getElementFromSelector(trigger); |
| 1816 |
|
| 1817 |
if (elem && !elem.classList.contains(CLASS_NAME_SHOW$8)) { |
| 1818 |
trigger.classList.add(CLASS_NAME_COLLAPSED); |
| 1819 |
trigger.setAttribute('aria-expanded', false); |
| 1820 |
} |
| 1821 |
} |
| 1822 |
} |
| 1823 |
|
| 1824 |
this.setTransitioning(true); |
| 1825 |
|
| 1826 |
const complete = () => { |
| 1827 |
this.setTransitioning(false); |
| 1828 |
|
| 1829 |
this._element.classList.remove(CLASS_NAME_COLLAPSING); |
| 1830 |
|
| 1831 |
this._element.classList.add(CLASS_NAME_COLLAPSE); |
| 1832 |
|
| 1833 |
EventHandler.trigger(this._element, EVENT_HIDDEN$5); |
| 1834 |
}; |
| 1835 |
|
| 1836 |
this._element.style[dimension] = ''; |
| 1837 |
|
| 1838 |
this._queueCallback(complete, this._element, true); |
| 1839 |
} |
| 1840 |
|
| 1841 |
setTransitioning(isTransitioning) { |
| 1842 |
this._isTransitioning = isTransitioning; |
| 1843 |
} // Private |
| 1844 |
|
| 1845 |
|
| 1846 |
_getConfig(config) { |
| 1847 |
config = { ...Default$8, |
| 1848 |
...config |
| 1849 |
}; |
| 1850 |
config.toggle = Boolean(config.toggle); // Coerce string values |
| 1851 |
|
| 1852 |
typeCheckConfig(NAME$9, config, DefaultType$8); |
| 1853 |
return config; |
| 1854 |
} |
| 1855 |
|
| 1856 |
_getDimension() { |
| 1857 |
return this._element.classList.contains(WIDTH) ? WIDTH : HEIGHT; |
| 1858 |
} |
| 1859 |
|
| 1860 |
_getParent() { |
| 1861 |
let { |
| 1862 |
parent |
| 1863 |
} = this._config; |
| 1864 |
parent = getElement(parent); |
| 1865 |
const selector = `${SELECTOR_DATA_TOGGLE$4}[data-bs-parent="${parent}"]`; |
| 1866 |
SelectorEngine.find(selector, parent).forEach(element => { |
| 1867 |
const selected = getElementFromSelector(element); |
| 1868 |
|
| 1869 |
this._addAriaAndCollapsedClass(selected, [element]); |
| 1870 |
}); |
| 1871 |
return parent; |
| 1872 |
} |
| 1873 |
|
| 1874 |
_addAriaAndCollapsedClass(element, triggerArray) { |
| 1875 |
if (!element || !triggerArray.length) { |
| 1876 |
return; |
| 1877 |
} |
| 1878 |
|
| 1879 |
const isOpen = element.classList.contains(CLASS_NAME_SHOW$8); |
| 1880 |
triggerArray.forEach(elem => { |
| 1881 |
if (isOpen) { |
| 1882 |
elem.classList.remove(CLASS_NAME_COLLAPSED); |
| 1883 |
} else { |
| 1884 |
elem.classList.add(CLASS_NAME_COLLAPSED); |
| 1885 |
} |
| 1886 |
|
| 1887 |
elem.setAttribute('aria-expanded', isOpen); |
| 1888 |
}); |
| 1889 |
} // Static |
| 1890 |
|
| 1891 |
|
| 1892 |
static collapseInterface(element, config) { |
| 1893 |
let data = Collapse.getInstance(element); |
| 1894 |
const _config = { ...Default$8, |
| 1895 |
...Manipulator.getDataAttributes(element), |
| 1896 |
...(typeof config === 'object' && config ? config : {}) |
| 1897 |
}; |
| 1898 |
|
| 1899 |
if (!data && _config.toggle && typeof config === 'string' && /show|hide/.test(config)) { |
| 1900 |
_config.toggle = false; |
| 1901 |
} |
| 1902 |
|
| 1903 |
if (!data) { |
| 1904 |
data = new Collapse(element, _config); |
| 1905 |
} |
| 1906 |
|
| 1907 |
if (typeof config === 'string') { |
| 1908 |
if (typeof data[config] === 'undefined') { |
| 1909 |
throw new TypeError(`No method named "${config}"`); |
| 1910 |
} |
| 1911 |
|
| 1912 |
data[config](); |
| 1913 |
} |
| 1914 |
} |
| 1915 |
|
| 1916 |
static jQueryInterface(config) { |
| 1917 |
return this.each(function () { |
| 1918 |
Collapse.collapseInterface(this, config); |
| 1919 |
}); |
| 1920 |
} |
| 1921 |
|
| 1922 |
} |
| 1923 |
/** |
| 1924 |
* ------------------------------------------------------------------------ |
| 1925 |
* Data Api implementation |
| 1926 |
* ------------------------------------------------------------------------ |
| 1927 |
*/ |
| 1928 |
|
| 1929 |
|
| 1930 |
EventHandler.on(document, EVENT_CLICK_DATA_API$4, SELECTOR_DATA_TOGGLE$4, function (event) { |
| 1931 |
// preventDefault only for <a> elements (which change the URL) not inside the collapsible element |
| 1932 |
if (event.target.tagName === 'A' || event.delegateTarget && event.delegateTarget.tagName === 'A') { |
| 1933 |
event.preventDefault(); |
| 1934 |
} |
| 1935 |
|
| 1936 |
const triggerData = Manipulator.getDataAttributes(this); |
| 1937 |
const selector = getSelectorFromElement(this); |
| 1938 |
const selectorElements = SelectorEngine.find(selector); |
| 1939 |
selectorElements.forEach(element => { |
| 1940 |
const data = Collapse.getInstance(element); |
| 1941 |
let config; |
| 1942 |
|
| 1943 |
if (data) { |
| 1944 |
// update parent attribute |
| 1945 |
if (data._parent === null && typeof triggerData.parent === 'string') { |
| 1946 |
data._config.parent = triggerData.parent; |
| 1947 |
data._parent = data._getParent(); |
| 1948 |
} |
| 1949 |
|
| 1950 |
config = 'toggle'; |
| 1951 |
} else { |
| 1952 |
config = triggerData; |
| 1953 |
} |
| 1954 |
|
| 1955 |
Collapse.collapseInterface(element, config); |
| 1956 |
}); |
| 1957 |
}); |
| 1958 |
/** |
| 1959 |
* ------------------------------------------------------------------------ |
| 1960 |
* jQuery |
| 1961 |
* ------------------------------------------------------------------------ |
| 1962 |
* add .Collapse to jQuery only if jQuery is present |
| 1963 |
*/ |
| 1964 |
|
| 1965 |
defineJQueryPlugin(Collapse); |
| 1966 |
|
| 1967 |
/** |
| 1968 |
* -------------------------------------------------------------------------- |
| 1969 |
* Bootstrap (v5.0.2): dropdown.js |
| 1970 |
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 1971 |
* -------------------------------------------------------------------------- |
| 1972 |
*/ |
| 1973 |
/** |
| 1974 |
* ------------------------------------------------------------------------ |
| 1975 |
* Constants |
| 1976 |
* ------------------------------------------------------------------------ |
| 1977 |
*/ |
| 1978 |
|
| 1979 |
const NAME$8 = 'dropdown'; |
| 1980 |
const DATA_KEY$7 = 'bs.dropdown'; |
| 1981 |
const EVENT_KEY$7 = `.${DATA_KEY$7}`; |
| 1982 |
const DATA_API_KEY$4 = '.data-api'; |
| 1983 |
const ESCAPE_KEY$2 = 'Escape'; |
| 1984 |
const SPACE_KEY = 'Space'; |
| 1985 |
const TAB_KEY = 'Tab'; |
| 1986 |
const ARROW_UP_KEY = 'ArrowUp'; |
| 1987 |
const ARROW_DOWN_KEY = 'ArrowDown'; |
| 1988 |
const RIGHT_MOUSE_BUTTON = 2; // MouseEvent.button value for the secondary button, usually the right button |
| 1989 |
|
| 1990 |
const REGEXP_KEYDOWN = new RegExp(`${ARROW_UP_KEY}|${ARROW_DOWN_KEY}|${ESCAPE_KEY$2}`); |
| 1991 |
const EVENT_HIDE$4 = `hide${EVENT_KEY$7}`; |
| 1992 |
const EVENT_HIDDEN$4 = `hidden${EVENT_KEY$7}`; |
| 1993 |
const EVENT_SHOW$4 = `show${EVENT_KEY$7}`; |
| 1994 |
const EVENT_SHOWN$4 = `shown${EVENT_KEY$7}`; |
| 1995 |
const EVENT_CLICK = `click${EVENT_KEY$7}`; |
| 1996 |
const EVENT_CLICK_DATA_API$3 = `click${EVENT_KEY$7}${DATA_API_KEY$4}`; |
| 1997 |
const EVENT_KEYDOWN_DATA_API = `keydown${EVENT_KEY$7}${DATA_API_KEY$4}`; |
| 1998 |
const EVENT_KEYUP_DATA_API = `keyup${EVENT_KEY$7}${DATA_API_KEY$4}`; |
| 1999 |
const CLASS_NAME_SHOW$7 = 'show'; |
| 2000 |
const CLASS_NAME_DROPUP = 'dropup'; |
| 2001 |
const CLASS_NAME_DROPEND = 'dropend'; |
| 2002 |
const CLASS_NAME_DROPSTART = 'dropstart'; |
| 2003 |
const CLASS_NAME_NAVBAR = 'navbar'; |
| 2004 |
const SELECTOR_DATA_TOGGLE$3 = '[data-bs-toggle="dropdown"]'; |
| 2005 |
const SELECTOR_MENU = '.dropdown-menu'; |
| 2006 |
const SELECTOR_NAVBAR_NAV = '.navbar-nav'; |
| 2007 |
const SELECTOR_VISIBLE_ITEMS = '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)'; |
| 2008 |
const PLACEMENT_TOP = isRTL() ? 'top-end' : 'top-start'; |
| 2009 |
const PLACEMENT_TOPEND = isRTL() ? 'top-start' : 'top-end'; |
| 2010 |
const PLACEMENT_BOTTOM = isRTL() ? 'bottom-end' : 'bottom-start'; |
| 2011 |
const PLACEMENT_BOTTOMEND = isRTL() ? 'bottom-start' : 'bottom-end'; |
| 2012 |
const PLACEMENT_RIGHT = isRTL() ? 'left-start' : 'right-start'; |
| 2013 |
const PLACEMENT_LEFT = isRTL() ? 'right-start' : 'left-start'; |
| 2014 |
const Default$7 = { |
| 2015 |
offset: [0, 2], |
| 2016 |
boundary: 'clippingParents', |
| 2017 |
reference: 'toggle', |
| 2018 |
display: 'dynamic', |
| 2019 |
popperConfig: null, |
| 2020 |
autoClose: true |
| 2021 |
}; |
| 2022 |
const DefaultType$7 = { |
| 2023 |
offset: '(array|string|function)', |
| 2024 |
boundary: '(string|element)', |
| 2025 |
reference: '(string|element|object)', |
| 2026 |
display: 'string', |
| 2027 |
popperConfig: '(null|object|function)', |
| 2028 |
autoClose: '(boolean|string)' |
| 2029 |
}; |
| 2030 |
/** |
| 2031 |
* ------------------------------------------------------------------------ |
| 2032 |
* Class Definition |
| 2033 |
* ------------------------------------------------------------------------ |
| 2034 |
*/ |
| 2035 |
|
| 2036 |
class Dropdown extends BaseComponent { |
| 2037 |
constructor(element, config) { |
| 2038 |
super(element); |
| 2039 |
this._popper = null; |
| 2040 |
this._config = this._getConfig(config); |
| 2041 |
this._menu = this._getMenuElement(); |
| 2042 |
this._inNavbar = this._detectNavbar(); |
| 2043 |
|
| 2044 |
this._addEventListeners(); |
| 2045 |
} // Getters |
| 2046 |
|
| 2047 |
|
| 2048 |
static get Default() { |
| 2049 |
return Default$7; |
| 2050 |
} |
| 2051 |
|
| 2052 |
static get DefaultType() { |
| 2053 |
return DefaultType$7; |
| 2054 |
} |
| 2055 |
|
| 2056 |
static get NAME() { |
| 2057 |
return NAME$8; |
| 2058 |
} // Public |
| 2059 |
|
| 2060 |
|
| 2061 |
toggle() { |
| 2062 |
if (isDisabled(this._element)) { |
| 2063 |
return; |
| 2064 |
} |
| 2065 |
|
| 2066 |
const isActive = this._element.classList.contains(CLASS_NAME_SHOW$7); |
| 2067 |
|
| 2068 |
if (isActive) { |
| 2069 |
this.hide(); |
| 2070 |
return; |
| 2071 |
} |
| 2072 |
|
| 2073 |
this.show(); |
| 2074 |
} |
| 2075 |
|
| 2076 |
show() { |
| 2077 |
if (isDisabled(this._element) || this._menu.classList.contains(CLASS_NAME_SHOW$7)) { |
| 2078 |
return; |
| 2079 |
} |
| 2080 |
|
| 2081 |
const parent = Dropdown.getParentFromElement(this._element); |
| 2082 |
const relatedTarget = { |
| 2083 |
relatedTarget: this._element |
| 2084 |
}; |
| 2085 |
const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$4, relatedTarget); |
| 2086 |
|
| 2087 |
if (showEvent.defaultPrevented) { |
| 2088 |
return; |
| 2089 |
} // Totally disable Popper for Dropdowns in Navbar |
| 2090 |
|
| 2091 |
|
| 2092 |
if (this._inNavbar) { |
| 2093 |
Manipulator.setDataAttribute(this._menu, 'popper', 'none'); |
| 2094 |
} else { |
| 2095 |
if (typeof Popper__namespace === 'undefined') { |
| 2096 |
throw new TypeError('Bootstrap\'s dropdowns require Popper (https://popper.js.org)'); |
| 2097 |
} |
| 2098 |
|
| 2099 |
let referenceElement = this._element; |
| 2100 |
|
| 2101 |
if (this._config.reference === 'parent') { |
| 2102 |
referenceElement = parent; |
| 2103 |
} else if (isElement(this._config.reference)) { |
| 2104 |
referenceElement = getElement(this._config.reference); |
| 2105 |
} else if (typeof this._config.reference === 'object') { |
| 2106 |
referenceElement = this._config.reference; |
| 2107 |
} |
| 2108 |
|
| 2109 |
const popperConfig = this._getPopperConfig(); |
| 2110 |
|
| 2111 |
const isDisplayStatic = popperConfig.modifiers.find(modifier => modifier.name === 'applyStyles' && modifier.enabled === false); |
| 2112 |
this._popper = Popper__namespace.createPopper(referenceElement, this._menu, popperConfig); |
| 2113 |
|
| 2114 |
if (isDisplayStatic) { |
| 2115 |
Manipulator.setDataAttribute(this._menu, 'popper', 'static'); |
| 2116 |
} |
| 2117 |
} // If this is a touch-enabled device we add extra |
| 2118 |
// empty mouseover listeners to the body's immediate children; |
| 2119 |
// only needed because of broken event delegation on iOS |
| 2120 |
// https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html |
| 2121 |
|
| 2122 |
|
| 2123 |
if ('ontouchstart' in document.documentElement && !parent.closest(SELECTOR_NAVBAR_NAV)) { |
| 2124 |
[].concat(...document.body.children).forEach(elem => EventHandler.on(elem, 'mouseover', noop)); |
| 2125 |
} |
| 2126 |
|
| 2127 |
this._element.focus(); |
| 2128 |
|
| 2129 |
this._element.setAttribute('aria-expanded', true); |
| 2130 |
|
| 2131 |
this._menu.classList.toggle(CLASS_NAME_SHOW$7); |
| 2132 |
|
| 2133 |
this._element.classList.toggle(CLASS_NAME_SHOW$7); |
| 2134 |
|
| 2135 |
EventHandler.trigger(this._element, EVENT_SHOWN$4, relatedTarget); |
| 2136 |
} |
| 2137 |
|
| 2138 |
hide() { |
| 2139 |
if (isDisabled(this._element) || !this._menu.classList.contains(CLASS_NAME_SHOW$7)) { |
| 2140 |
return; |
| 2141 |
} |
| 2142 |
|
| 2143 |
const relatedTarget = { |
| 2144 |
relatedTarget: this._element |
| 2145 |
}; |
| 2146 |
|
| 2147 |
this._completeHide(relatedTarget); |
| 2148 |
} |
| 2149 |
|
| 2150 |
dispose() { |
| 2151 |
if (this._popper) { |
| 2152 |
this._popper.destroy(); |
| 2153 |
} |
| 2154 |
|
| 2155 |
super.dispose(); |
| 2156 |
} |
| 2157 |
|
| 2158 |
update() { |
| 2159 |
this._inNavbar = this._detectNavbar(); |
| 2160 |
|
| 2161 |
if (this._popper) { |
| 2162 |
this._popper.update(); |
| 2163 |
} |
| 2164 |
} // Private |
| 2165 |
|
| 2166 |
|
| 2167 |
_addEventListeners() { |
| 2168 |
EventHandler.on(this._element, EVENT_CLICK, event => { |
| 2169 |
event.preventDefault(); |
| 2170 |
this.toggle(); |
| 2171 |
}); |
| 2172 |
} |
| 2173 |
|
| 2174 |
_completeHide(relatedTarget) { |
| 2175 |
const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$4, relatedTarget); |
| 2176 |
|
| 2177 |
if (hideEvent.defaultPrevented) { |
| 2178 |
return; |
| 2179 |
} // If this is a touch-enabled device we remove the extra |
| 2180 |
// empty mouseover listeners we added for iOS support |
| 2181 |
|
| 2182 |
|
| 2183 |
if ('ontouchstart' in document.documentElement) { |
| 2184 |
[].concat(...document.body.children).forEach(elem => EventHandler.off(elem, 'mouseover', noop)); |
| 2185 |
} |
| 2186 |
|
| 2187 |
if (this._popper) { |
| 2188 |
this._popper.destroy(); |
| 2189 |
} |
| 2190 |
|
| 2191 |
this._menu.classList.remove(CLASS_NAME_SHOW$7); |
| 2192 |
|
| 2193 |
this._element.classList.remove(CLASS_NAME_SHOW$7); |
| 2194 |
|
| 2195 |
this._element.setAttribute('aria-expanded', 'false'); |
| 2196 |
|
| 2197 |
Manipulator.removeDataAttribute(this._menu, 'popper'); |
| 2198 |
EventHandler.trigger(this._element, EVENT_HIDDEN$4, relatedTarget); |
| 2199 |
} |
| 2200 |
|
| 2201 |
_getConfig(config) { |
| 2202 |
config = { ...this.constructor.Default, |
| 2203 |
...Manipulator.getDataAttributes(this._element), |
| 2204 |
...config |
| 2205 |
}; |
| 2206 |
typeCheckConfig(NAME$8, config, this.constructor.DefaultType); |
| 2207 |
|
| 2208 |
if (typeof config.reference === 'object' && !isElement(config.reference) && typeof config.reference.getBoundingClientRect !== 'function') { |
| 2209 |
// Popper virtual elements require a getBoundingClientRect method |
| 2210 |
throw new TypeError(`${NAME$8.toUpperCase()}: Option "reference" provided type "object" without a required "getBoundingClientRect" method.`); |
| 2211 |
} |
| 2212 |
|
| 2213 |
return config; |
| 2214 |
} |
| 2215 |
|
| 2216 |
_getMenuElement() { |
| 2217 |
return SelectorEngine.next(this._element, SELECTOR_MENU)[0]; |
| 2218 |
} |
| 2219 |
|
| 2220 |
_getPlacement() { |
| 2221 |
const parentDropdown = this._element.parentNode; |
| 2222 |
|
| 2223 |
if (parentDropdown.classList.contains(CLASS_NAME_DROPEND)) { |
| 2224 |
return PLACEMENT_RIGHT; |
| 2225 |
} |
| 2226 |
|
| 2227 |
if (parentDropdown.classList.contains(CLASS_NAME_DROPSTART)) { |
| 2228 |
return PLACEMENT_LEFT; |
| 2229 |
} // We need to trim the value because custom properties can also include spaces |
| 2230 |
|
| 2231 |
|
| 2232 |
const isEnd = getComputedStyle(this._menu).getPropertyValue('--bs-position').trim() === 'end'; |
| 2233 |
|
| 2234 |
if (parentDropdown.classList.contains(CLASS_NAME_DROPUP)) { |
| 2235 |
return isEnd ? PLACEMENT_TOPEND : PLACEMENT_TOP; |
| 2236 |
} |
| 2237 |
|
| 2238 |
return isEnd ? PLACEMENT_BOTTOMEND : PLACEMENT_BOTTOM; |
| 2239 |
} |
| 2240 |
|
| 2241 |
_detectNavbar() { |
| 2242 |
return this._element.closest(`.${CLASS_NAME_NAVBAR}`) !== null; |
| 2243 |
} |
| 2244 |
|
| 2245 |
_getOffset() { |
| 2246 |
const { |
| 2247 |
offset |
| 2248 |
} = this._config; |
| 2249 |
|
| 2250 |
if (typeof offset === 'string') { |
| 2251 |
return offset.split(',').map(val => Number.parseInt(val, 10)); |
| 2252 |
} |
| 2253 |
|
| 2254 |
if (typeof offset === 'function') { |
| 2255 |
return popperData => offset(popperData, this._element); |
| 2256 |
} |
| 2257 |
|
| 2258 |
return offset; |
| 2259 |
} |
| 2260 |
|
| 2261 |
_getPopperConfig() { |
| 2262 |
const defaultBsPopperConfig = { |
| 2263 |
placement: this._getPlacement(), |
| 2264 |
modifiers: [{ |
| 2265 |
name: 'preventOverflow', |
| 2266 |
options: { |
| 2267 |
boundary: this._config.boundary |
| 2268 |
} |
| 2269 |
}, { |
| 2270 |
name: 'offset', |
| 2271 |
options: { |
| 2272 |
offset: this._getOffset() |
| 2273 |
} |
| 2274 |
}] |
| 2275 |
}; // Disable Popper if we have a static display |
| 2276 |
|
| 2277 |
if (this._config.display === 'static') { |
| 2278 |
defaultBsPopperConfig.modifiers = [{ |
| 2279 |
name: 'applyStyles', |
| 2280 |
enabled: false |
| 2281 |
}]; |
| 2282 |
} |
| 2283 |
|
| 2284 |
return { ...defaultBsPopperConfig, |
| 2285 |
...(typeof this._config.popperConfig === 'function' ? this._config.popperConfig(defaultBsPopperConfig) : this._config.popperConfig) |
| 2286 |
}; |
| 2287 |
} |
| 2288 |
|
| 2289 |
_selectMenuItem({ |
| 2290 |
key, |
| 2291 |
target |
| 2292 |
}) { |
| 2293 |
const items = SelectorEngine.find(SELECTOR_VISIBLE_ITEMS, this._menu).filter(isVisible); |
| 2294 |
|
| 2295 |
if (!items.length) { |
| 2296 |
return; |
| 2297 |
} // if target isn't included in items (e.g. when expanding the dropdown) |
| 2298 |
// allow cycling to get the last item in case key equals ARROW_UP_KEY |
| 2299 |
|
| 2300 |
|
| 2301 |
getNextActiveElement(items, target, key === ARROW_DOWN_KEY, !items.includes(target)).focus(); |
| 2302 |
} // Static |
| 2303 |
|
| 2304 |
|
| 2305 |
static dropdownInterface(element, config) { |
| 2306 |
const data = Dropdown.getOrCreateInstance(element, config); |
| 2307 |
|
| 2308 |
if (typeof config === 'string') { |
| 2309 |
if (typeof data[config] === 'undefined') { |
| 2310 |
throw new TypeError(`No method named "${config}"`); |
| 2311 |
} |
| 2312 |
|
| 2313 |
data[config](); |
| 2314 |
} |
| 2315 |
} |
| 2316 |
|
| 2317 |
static jQueryInterface(config) { |
| 2318 |
return this.each(function () { |
| 2319 |
Dropdown.dropdownInterface(this, config); |
| 2320 |
}); |
| 2321 |
} |
| 2322 |
|
| 2323 |
static clearMenus(event) { |
| 2324 |
if (event && (event.button === RIGHT_MOUSE_BUTTON || event.type === 'keyup' && event.key !== TAB_KEY)) { |
| 2325 |
return; |
| 2326 |
} |
| 2327 |
|
| 2328 |
const toggles = SelectorEngine.find(SELECTOR_DATA_TOGGLE$3); |
| 2329 |
|
| 2330 |
for (let i = 0, len = toggles.length; i < len; i++) { |
| 2331 |
const context = Dropdown.getInstance(toggles[i]); |
| 2332 |
|
| 2333 |
if (!context || context._config.autoClose === false) { |
| 2334 |
continue; |
| 2335 |
} |
| 2336 |
|
| 2337 |
if (!context._element.classList.contains(CLASS_NAME_SHOW$7)) { |
| 2338 |
continue; |
| 2339 |
} |
| 2340 |
|
| 2341 |
const relatedTarget = { |
| 2342 |
relatedTarget: context._element |
| 2343 |
}; |
| 2344 |
|
| 2345 |
if (event) { |
| 2346 |
const composedPath = event.composedPath(); |
| 2347 |
const isMenuTarget = composedPath.includes(context._menu); |
| 2348 |
|
| 2349 |
if (composedPath.includes(context._element) || context._config.autoClose === 'inside' && !isMenuTarget || context._config.autoClose === 'outside' && isMenuTarget) { |
| 2350 |
continue; |
| 2351 |
} // Tab navigation through the dropdown menu or events from contained inputs shouldn't close the menu |
| 2352 |
|
| 2353 |
|
| 2354 |
if (context._menu.contains(event.target) && (event.type === 'keyup' && event.key === TAB_KEY || /input|select|option|textarea|form/i.test(event.target.tagName))) { |
| 2355 |
continue; |
| 2356 |
} |
| 2357 |
|
| 2358 |
if (event.type === 'click') { |
| 2359 |
relatedTarget.clickEvent = event; |
| 2360 |
} |
| 2361 |
} |
| 2362 |
|
| 2363 |
context._completeHide(relatedTarget); |
| 2364 |
} |
| 2365 |
} |
| 2366 |
|
| 2367 |
static getParentFromElement(element) { |
| 2368 |
return getElementFromSelector(element) || element.parentNode; |
| 2369 |
} |
| 2370 |
|
| 2371 |
static dataApiKeydownHandler(event) { |
| 2372 |
// If not input/textarea: |
| 2373 |
// - And not a key in REGEXP_KEYDOWN => not a dropdown command |
| 2374 |
// If input/textarea: |
| 2375 |
// - If space key => not a dropdown command |
| 2376 |
// - If key is other than escape |
| 2377 |
// - If key is not up or down => not a dropdown command |
| 2378 |
// - If trigger inside the menu => not a dropdown command |
| 2379 |
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)) { |
| 2380 |
return; |
| 2381 |
} |
| 2382 |
|
| 2383 |
const isActive = this.classList.contains(CLASS_NAME_SHOW$7); |
| 2384 |
|
| 2385 |
if (!isActive && event.key === ESCAPE_KEY$2) { |
| 2386 |
return; |
| 2387 |
} |
| 2388 |
|
| 2389 |
event.preventDefault(); |
| 2390 |
event.stopPropagation(); |
| 2391 |
|
| 2392 |
if (isDisabled(this)) { |
| 2393 |
return; |
| 2394 |
} |
| 2395 |
|
| 2396 |
const getToggleButton = () => this.matches(SELECTOR_DATA_TOGGLE$3) ? this : SelectorEngine.prev(this, SELECTOR_DATA_TOGGLE$3)[0]; |
| 2397 |
|
| 2398 |
if (event.key === ESCAPE_KEY$2) { |
| 2399 |
getToggleButton().focus(); |
| 2400 |
Dropdown.clearMenus(); |
| 2401 |
return; |
| 2402 |
} |
| 2403 |
|
| 2404 |
if (event.key === ARROW_UP_KEY || event.key === ARROW_DOWN_KEY) { |
| 2405 |
if (!isActive) { |
| 2406 |
getToggleButton().click(); |
| 2407 |
} |
| 2408 |
|
| 2409 |
Dropdown.getInstance(getToggleButton())._selectMenuItem(event); |
| 2410 |
|
| 2411 |
return; |
| 2412 |
} |
| 2413 |
|
| 2414 |
if (!isActive || event.key === SPACE_KEY) { |
| 2415 |
Dropdown.clearMenus(); |
| 2416 |
} |
| 2417 |
} |
| 2418 |
|
| 2419 |
} |
| 2420 |
/** |
| 2421 |
* ------------------------------------------------------------------------ |
| 2422 |
* Data Api implementation |
| 2423 |
* ------------------------------------------------------------------------ |
| 2424 |
*/ |
| 2425 |
|
| 2426 |
|
| 2427 |
EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_DATA_TOGGLE$3, Dropdown.dataApiKeydownHandler); |
| 2428 |
EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_MENU, Dropdown.dataApiKeydownHandler); |
| 2429 |
EventHandler.on(document, EVENT_CLICK_DATA_API$3, Dropdown.clearMenus); |
| 2430 |
EventHandler.on(document, EVENT_KEYUP_DATA_API, Dropdown.clearMenus); |
| 2431 |
EventHandler.on(document, EVENT_CLICK_DATA_API$3, SELECTOR_DATA_TOGGLE$3, function (event) { |
| 2432 |
event.preventDefault(); |
| 2433 |
Dropdown.dropdownInterface(this); |
| 2434 |
}); |
| 2435 |
/** |
| 2436 |
* ------------------------------------------------------------------------ |
| 2437 |
* jQuery |
| 2438 |
* ------------------------------------------------------------------------ |
| 2439 |
* add .Dropdown to jQuery only if jQuery is present |
| 2440 |
*/ |
| 2441 |
|
| 2442 |
defineJQueryPlugin(Dropdown); |
| 2443 |
|
| 2444 |
/** |
| 2445 |
* -------------------------------------------------------------------------- |
| 2446 |
* Bootstrap (v5.0.2): util/scrollBar.js |
| 2447 |
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 2448 |
* -------------------------------------------------------------------------- |
| 2449 |
*/ |
| 2450 |
const SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top'; |
| 2451 |
const SELECTOR_STICKY_CONTENT = '.sticky-top'; |
| 2452 |
|
| 2453 |
class ScrollBarHelper { |
| 2454 |
constructor() { |
| 2455 |
this._element = document.body; |
| 2456 |
} |
| 2457 |
|
| 2458 |
getWidth() { |
| 2459 |
// https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes |
| 2460 |
const documentWidth = document.documentElement.clientWidth; |
| 2461 |
return Math.abs(window.innerWidth - documentWidth); |
| 2462 |
} |
| 2463 |
|
| 2464 |
hide() { |
| 2465 |
const width = this.getWidth(); |
| 2466 |
|
| 2467 |
this._disableOverFlow(); // give padding to element to balance the hidden scrollbar width |
| 2468 |
|
| 2469 |
|
| 2470 |
this._setElementAttributes(this._element, 'paddingRight', calculatedValue => calculatedValue + width); // trick: We adjust positive paddingRight and negative marginRight to sticky-top elements to keep showing fullwidth |
| 2471 |
|
| 2472 |
|
| 2473 |
this._setElementAttributes(SELECTOR_FIXED_CONTENT, 'paddingRight', calculatedValue => calculatedValue + width); |
| 2474 |
|
| 2475 |
this._setElementAttributes(SELECTOR_STICKY_CONTENT, 'marginRight', calculatedValue => calculatedValue - width); |
| 2476 |
} |
| 2477 |
|
| 2478 |
_disableOverFlow() { |
| 2479 |
this._saveInitialAttribute(this._element, 'overflow'); |
| 2480 |
|
| 2481 |
this._element.style.overflow = 'hidden'; |
| 2482 |
} |
| 2483 |
|
| 2484 |
_setElementAttributes(selector, styleProp, callback) { |
| 2485 |
const scrollbarWidth = this.getWidth(); |
| 2486 |
|
| 2487 |
const manipulationCallBack = element => { |
| 2488 |
if (element !== this._element && window.innerWidth > element.clientWidth + scrollbarWidth) { |
| 2489 |
return; |
| 2490 |
} |
| 2491 |
|
| 2492 |
this._saveInitialAttribute(element, styleProp); |
| 2493 |
|
| 2494 |
const calculatedValue = window.getComputedStyle(element)[styleProp]; |
| 2495 |
element.style[styleProp] = `${callback(Number.parseFloat(calculatedValue))}px`; |
| 2496 |
}; |
| 2497 |
|
| 2498 |
this._applyManipulationCallback(selector, manipulationCallBack); |
| 2499 |
} |
| 2500 |
|
| 2501 |
reset() { |
| 2502 |
this._resetElementAttributes(this._element, 'overflow'); |
| 2503 |
|
| 2504 |
this._resetElementAttributes(this._element, 'paddingRight'); |
| 2505 |
|
| 2506 |
this._resetElementAttributes(SELECTOR_FIXED_CONTENT, 'paddingRight'); |
| 2507 |
|
| 2508 |
this._resetElementAttributes(SELECTOR_STICKY_CONTENT, 'marginRight'); |
| 2509 |
} |
| 2510 |
|
| 2511 |
_saveInitialAttribute(element, styleProp) { |
| 2512 |
const actualValue = element.style[styleProp]; |
| 2513 |
|
| 2514 |
if (actualValue) { |
| 2515 |
Manipulator.setDataAttribute(element, styleProp, actualValue); |
| 2516 |
} |
| 2517 |
} |
| 2518 |
|
| 2519 |
_resetElementAttributes(selector, styleProp) { |
| 2520 |
const manipulationCallBack = element => { |
| 2521 |
const value = Manipulator.getDataAttribute(element, styleProp); |
| 2522 |
|
| 2523 |
if (typeof value === 'undefined') { |
| 2524 |
element.style.removeProperty(styleProp); |
| 2525 |
} else { |
| 2526 |
Manipulator.removeDataAttribute(element, styleProp); |
| 2527 |
element.style[styleProp] = value; |
| 2528 |
} |
| 2529 |
}; |
| 2530 |
|
| 2531 |
this._applyManipulationCallback(selector, manipulationCallBack); |
| 2532 |
} |
| 2533 |
|
| 2534 |
_applyManipulationCallback(selector, callBack) { |
| 2535 |
if (isElement(selector)) { |
| 2536 |
callBack(selector); |
| 2537 |
} else { |
| 2538 |
SelectorEngine.find(selector, this._element).forEach(callBack); |
| 2539 |
} |
| 2540 |
} |
| 2541 |
|
| 2542 |
isOverflowing() { |
| 2543 |
return this.getWidth() > 0; |
| 2544 |
} |
| 2545 |
|
| 2546 |
} |
| 2547 |
|
| 2548 |
/** |
| 2549 |
* -------------------------------------------------------------------------- |
| 2550 |
* Bootstrap (v5.0.2): util/backdrop.js |
| 2551 |
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) |
| 2552 |
* -------------------------------------------------------------------------- |
| 2553 |
*/ |
| 2554 |
const Default$6 = { |
| 2555 |
isVisible: true, |
| 2556 |
// if false, we use the backdrop helper without adding any element to the dom |
| 2557 |
isAnimated: false, |
| 2558 |
rootElement: 'body', |
| 2559 |
// give the choice to place backdrop under different elements |
| 2560 |
clickCallback: null |
| 2561 |
}; |
| 2562 |
const DefaultType$6 = { |
| 2563 |
isVisible: 'boolean', |
| 2564 |
isAnimated: 'boolean', |
| 2565 |
rootElement: '(element|string)', |
| 2566 |
clickCallback: '(function|null)' |
| 2567 |
}; |
| 2568 |
const NAME$7 = 'backdrop'; |
| 2569 |
const CLASS_NAME_BACKDROP = 'modal-backdrop'; |
| 2570 |
const CLASS_NAME_FADE$5 = 'fade'; |
| 2571 |
const CLASS_NAME_SHOW$6 = 'show'; |
| 2572 |
const EVENT_MOUSEDOWN = `mousedown.bs.${NAME$7}`; |
| 2573 |
|
| 2574 |
class Backdrop { |
| 2575 |
constructor(config) { |
| 2576 |
this._config = this._getConfig(config); |
| 2577 |
this._isAppended = false; |
| 2578 |
this._element = null; |
| 2579 |
} |
| 2580 |
|
| 2581 |
show(callback) { |
| 2582 |
if (!this._config.isVisible) { |
| 2583 |
execute(callback); |
| 2584 |
return; |
| 2585 |
} |
| 2586 |
|
| 2587 |
this._append(); |
| 2588 |
|
| 2589 |
if (this._config.isAnimated) { |
| 2590 |
reflow(this._getElement()); |
| 2591 |
} |
| 2592 |
|
| 2593 |
this._getElement().classList.add(CLASS_NAME_SHOW$6); |
| 2594 |
|
| 2595 |
this._emulateAnimation(() => { |
| 2596 |
execute(callback); |
| 2597 |
}); |
| 2598 |
} |
| 2599 |
|
| 2600 |
hide(callback) { |
| 2601 |
if (!this._config.isVisible) { |
| 2602 |
execute(callback); |
| 2603 |
return; |
| 2604 |
} |
| 2605 |
|
| 2606 |
this._getElement().classList.remove(CLASS_NAME_SHOW$6); |
| 2607 |
|
| 2608 |
this._emulateAnimation(() => { |
| 2609 |
this.dispose(); |
| 2610 |
execute(callback); |
| 2611 |
}); |
| 2612 |
} // Private |
| 2613 |
|
| 2614 |
|
| 2615 |
_getElement() { |
| 2616 |
if (!this._element) { |
| 2617 |
const backdrop = document.createElement('div'); |
| 2618 |
backdrop.className = CLASS_NAME_BACKDROP; |
| 2619 |
|
| 2620 |
if (this._config.isAnimated) { |
| 2621 |
backdrop.classList.add(CLASS_NAME_FADE$5); |
| 2622 |
} |
| 2623 |
|
| 2624 |
this._element = backdrop; |
| 2625 |
} |
| 2626 |
|
| 2627 |
return this._element; |
| 2628 |
} |
| 2629 |
|
| 2630 |
_getConfig(config) { |
| 2631 |
config = { ...Default$6, |
| 2632 |
...(typeof config === 'object' ? config : {}) |
| 2633 |
}; // use getElement() with the default "body" to get a fresh Element on each instantiation |
| 2634 |
|
| 2635 |
config.rootElement = getElement(config.rootElement); |
| 2636 |
typeCheckConfig(NAME$7, config, DefaultType$6); |
| 2637 |
return config; |
| 2638 |
} |
| 2639 |
|
| 2640 |
_append() { |
| 2641 |
if (this._isAppended) { |
| 2642 |
return; |
| 2643 |
} |
| 2644 |
|
| 2645 |
this._config.rootElement.appendChild(this._getElement()); |
| 2646 |
|
| 2647 |
EventHandler.on(this._getElement(), EVENT_MOUSEDOWN, () => { |
| 2648 |
execute(this._config.clickCallback); |
| 2649 |
}); |
| 2650 |
this._isAppended = true; |
| 2651 |
} |
| 2652 |
|
| 2653 |
dispose() { |
| 2654 |
if (!this._isAppended) { |
| 2655 |
return; |
| 2656 |
} |
| 2657 |
|
| 2658 |
EventHandler.off(this._element, EVENT_MOUSEDOWN); |
| 2659 |
|
| 2660 |
this._element.remove(); |
| 2661 |
|
| 2662 |
this._isAppended = false; |
| 2663 |
} |
| 2664 |
|
| 2665 |
_emulateAnimation(callback) { |
| 2666 |
executeAfterTransition(callback, this._getElement(), this._config.isAnimated); |
| 2667 |
} |
| 2668 |
|
| 2669 |
} |
| 2670 |
|
| 2671 |
/** |
| 2672 |
* -------------------------------------------------------------------------- |
| 2673 |
* Bootstrap (v5.0.2): modal.js |
| 2674 |
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 2675 |
* -------------------------------------------------------------------------- |
| 2676 |
*/ |
| 2677 |
/** |
| 2678 |
* ------------------------------------------------------------------------ |
| 2679 |
* Constants |
| 2680 |
* ------------------------------------------------------------------------ |
| 2681 |
*/ |
| 2682 |
|
| 2683 |
const NAME$6 = 'modal'; |
| 2684 |
const DATA_KEY$6 = 'bs.modal'; |
| 2685 |
const EVENT_KEY$6 = `.${DATA_KEY$6}`; |
| 2686 |
const DATA_API_KEY$3 = '.data-api'; |
| 2687 |
const ESCAPE_KEY$1 = 'Escape'; |
| 2688 |
const Default$5 = { |
| 2689 |
backdrop: true, |
| 2690 |
keyboard: true, |
| 2691 |
focus: true |
| 2692 |
}; |
| 2693 |
const DefaultType$5 = { |
| 2694 |
backdrop: '(boolean|string)', |
| 2695 |
keyboard: 'boolean', |
| 2696 |
focus: 'boolean' |
| 2697 |
}; |
| 2698 |
const EVENT_HIDE$3 = `hide${EVENT_KEY$6}`; |
| 2699 |
const EVENT_HIDE_PREVENTED = `hidePrevented${EVENT_KEY$6}`; |
| 2700 |
const EVENT_HIDDEN$3 = `hidden${EVENT_KEY$6}`; |
| 2701 |
const EVENT_SHOW$3 = `show${EVENT_KEY$6}`; |
| 2702 |
const EVENT_SHOWN$3 = `shown${EVENT_KEY$6}`; |
| 2703 |
const EVENT_FOCUSIN$2 = `focusin${EVENT_KEY$6}`; |
| 2704 |
const EVENT_RESIZE = `resize${EVENT_KEY$6}`; |
| 2705 |
const EVENT_CLICK_DISMISS$2 = `click.dismiss${EVENT_KEY$6}`; |
| 2706 |
const EVENT_KEYDOWN_DISMISS$1 = `keydown.dismiss${EVENT_KEY$6}`; |
| 2707 |
const EVENT_MOUSEUP_DISMISS = `mouseup.dismiss${EVENT_KEY$6}`; |
| 2708 |
const EVENT_MOUSEDOWN_DISMISS = `mousedown.dismiss${EVENT_KEY$6}`; |
| 2709 |
const EVENT_CLICK_DATA_API$2 = `click${EVENT_KEY$6}${DATA_API_KEY$3}`; |
| 2710 |
const CLASS_NAME_OPEN = 'modal-open'; |
| 2711 |
const CLASS_NAME_FADE$4 = 'fade'; |
| 2712 |
const CLASS_NAME_SHOW$5 = 'show'; |
| 2713 |
const CLASS_NAME_STATIC = 'modal-static'; |
| 2714 |
const SELECTOR_DIALOG = '.modal-dialog'; |
| 2715 |
const SELECTOR_MODAL_BODY = '.modal-body'; |
| 2716 |
const SELECTOR_DATA_TOGGLE$2 = '[data-bs-toggle="modal"]'; |
| 2717 |
const SELECTOR_DATA_DISMISS$2 = '[data-bs-dismiss="modal"]'; |
| 2718 |
/** |
| 2719 |
* ------------------------------------------------------------------------ |
| 2720 |
* Class Definition |
| 2721 |
* ------------------------------------------------------------------------ |
| 2722 |
*/ |
| 2723 |
|
| 2724 |
class Modal extends BaseComponent { |
| 2725 |
constructor(element, config) { |
| 2726 |
super(element); |
| 2727 |
this._config = this._getConfig(config); |
| 2728 |
this._dialog = SelectorEngine.findOne(SELECTOR_DIALOG, this._element); |
| 2729 |
this._backdrop = this._initializeBackDrop(); |
| 2730 |
this._isShown = false; |
| 2731 |
this._ignoreBackdropClick = false; |
| 2732 |
this._isTransitioning = false; |
| 2733 |
this._scrollBar = new ScrollBarHelper(); |
| 2734 |
} // Getters |
| 2735 |
|
| 2736 |
|
| 2737 |
static get Default() { |
| 2738 |
return Default$5; |
| 2739 |
} |
| 2740 |
|
| 2741 |
static get NAME() { |
| 2742 |
return NAME$6; |
| 2743 |
} // Public |
| 2744 |
|
| 2745 |
|
| 2746 |
toggle(relatedTarget) { |
| 2747 |
return this._isShown ? this.hide() : this.show(relatedTarget); |
| 2748 |
} |
| 2749 |
|
| 2750 |
show(relatedTarget) { |
| 2751 |
if (this._isShown || this._isTransitioning) { |
| 2752 |
return; |
| 2753 |
} |
| 2754 |
|
| 2755 |
const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$3, { |
| 2756 |
relatedTarget |
| 2757 |
}); |
| 2758 |
|
| 2759 |
if (showEvent.defaultPrevented) { |
| 2760 |
return; |
| 2761 |
} |
| 2762 |
|
| 2763 |
this._isShown = true; |
| 2764 |
|
| 2765 |
if (this._isAnimated()) { |
| 2766 |
this._isTransitioning = true; |
| 2767 |
} |
| 2768 |
|
| 2769 |
this._scrollBar.hide(); |
| 2770 |
|
| 2771 |
document.body.classList.add(CLASS_NAME_OPEN); |
| 2772 |
|
| 2773 |
this._adjustDialog(); |
| 2774 |
|
| 2775 |
this._setEscapeEvent(); |
| 2776 |
|
| 2777 |
this._setResizeEvent(); |
| 2778 |
|
| 2779 |
EventHandler.on(this._element, EVENT_CLICK_DISMISS$2, SELECTOR_DATA_DISMISS$2, event => this.hide(event)); |
| 2780 |
EventHandler.on(this._dialog, EVENT_MOUSEDOWN_DISMISS, () => { |
| 2781 |
EventHandler.one(this._element, EVENT_MOUSEUP_DISMISS, event => { |
| 2782 |
if (event.target === this._element) { |
| 2783 |
this._ignoreBackdropClick = true; |
| 2784 |
} |
| 2785 |
}); |
| 2786 |
}); |
| 2787 |
|
| 2788 |
this._showBackdrop(() => this._showElement(relatedTarget)); |
| 2789 |
} |
| 2790 |
|
| 2791 |
hide(event) { |
| 2792 |
if (event && ['A', 'AREA'].includes(event.target.tagName)) { |
| 2793 |
event.preventDefault(); |
| 2794 |
} |
| 2795 |
|
| 2796 |
if (!this._isShown || this._isTransitioning) { |
| 2797 |
return; |
| 2798 |
} |
| 2799 |
|
| 2800 |
const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$3); |
| 2801 |
|
| 2802 |
if (hideEvent.defaultPrevented) { |
| 2803 |
return; |
| 2804 |
} |
| 2805 |
|
| 2806 |
this._isShown = false; |
| 2807 |
|
| 2808 |
const isAnimated = this._isAnimated(); |
| 2809 |
|
| 2810 |
if (isAnimated) { |
| 2811 |
this._isTransitioning = true; |
| 2812 |
} |
| 2813 |
|
| 2814 |
this._setEscapeEvent(); |
| 2815 |
|
| 2816 |
this._setResizeEvent(); |
| 2817 |
|
| 2818 |
EventHandler.off(document, EVENT_FOCUSIN$2); |
| 2819 |
|
| 2820 |
this._element.classList.remove(CLASS_NAME_SHOW$5); |
| 2821 |
|
| 2822 |
EventHandler.off(this._element, EVENT_CLICK_DISMISS$2); |
| 2823 |
EventHandler.off(this._dialog, EVENT_MOUSEDOWN_DISMISS); |
| 2824 |
|
| 2825 |
this._queueCallback(() => this._hideModal(), this._element, isAnimated); |
| 2826 |
} |
| 2827 |
|
| 2828 |
dispose() { |
| 2829 |
[window, this._dialog].forEach(htmlElement => EventHandler.off(htmlElement, EVENT_KEY$6)); |
| 2830 |
|
| 2831 |
this._backdrop.dispose(); |
| 2832 |
|
| 2833 |
super.dispose(); |
| 2834 |
/** |
| 2835 |
* `document` has 2 events `EVENT_FOCUSIN` and `EVENT_CLICK_DATA_API` |
| 2836 |
* Do not move `document` in `htmlElements` array |
| 2837 |
* It will remove `EVENT_CLICK_DATA_API` event that should remain |
| 2838 |
*/ |
| 2839 |
|
| 2840 |
EventHandler.off(document, EVENT_FOCUSIN$2); |
| 2841 |
} |
| 2842 |
|
| 2843 |
handleUpdate() { |
| 2844 |
this._adjustDialog(); |
| 2845 |
} // Private |
| 2846 |
|
| 2847 |
|
| 2848 |
_initializeBackDrop() { |
| 2849 |
return new Backdrop({ |
| 2850 |
isVisible: Boolean(this._config.backdrop), |
| 2851 |
// 'static' option will be translated to true, and booleans will keep their value |
| 2852 |
isAnimated: this._isAnimated() |
| 2853 |
}); |
| 2854 |
} |
| 2855 |
|
| 2856 |
_getConfig(config) { |
| 2857 |
config = { ...Default$5, |
| 2858 |
...Manipulator.getDataAttributes(this._element), |
| 2859 |
...(typeof config === 'object' ? config : {}) |
| 2860 |
}; |
| 2861 |
typeCheckConfig(NAME$6, config, DefaultType$5); |
| 2862 |
return config; |
| 2863 |
} |
| 2864 |
|
| 2865 |
_showElement(relatedTarget) { |
| 2866 |
const isAnimated = this._isAnimated(); |
| 2867 |
|
| 2868 |
const modalBody = SelectorEngine.findOne(SELECTOR_MODAL_BODY, this._dialog); |
| 2869 |
|
| 2870 |
if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) { |
| 2871 |
// Don't move modal's DOM position |
| 2872 |
document.body.appendChild(this._element); |
| 2873 |
} |
| 2874 |
|
| 2875 |
this._element.style.display = 'block'; |
| 2876 |
|
| 2877 |
this._element.removeAttribute('aria-hidden'); |
| 2878 |
|
| 2879 |
this._element.setAttribute('aria-modal', true); |
| 2880 |
|
| 2881 |
this._element.setAttribute('role', 'dialog'); |
| 2882 |
|
| 2883 |
this._element.scrollTop = 0; |
| 2884 |
|
| 2885 |
if (modalBody) { |
| 2886 |
modalBody.scrollTop = 0; |
| 2887 |
} |
| 2888 |
|
| 2889 |
if (isAnimated) { |
| 2890 |
reflow(this._element); |
| 2891 |
} |
| 2892 |
|
| 2893 |
this._element.classList.add(CLASS_NAME_SHOW$5); |
| 2894 |
|
| 2895 |
if (this._config.focus) { |
| 2896 |
this._enforceFocus(); |
| 2897 |
} |
| 2898 |
|
| 2899 |
const transitionComplete = () => { |
| 2900 |
if (this._config.focus) { |
| 2901 |
this._element.focus(); |
| 2902 |
} |
| 2903 |
|
| 2904 |
this._isTransitioning = false; |
| 2905 |
EventHandler.trigger(this._element, EVENT_SHOWN$3, { |
| 2906 |
relatedTarget |
| 2907 |
}); |
| 2908 |
}; |
| 2909 |
|
| 2910 |
this._queueCallback(transitionComplete, this._dialog, isAnimated); |
| 2911 |
} |
| 2912 |
|
| 2913 |
_enforceFocus() { |
| 2914 |
EventHandler.off(document, EVENT_FOCUSIN$2); // guard against infinite focus loop |
| 2915 |
|
| 2916 |
EventHandler.on(document, EVENT_FOCUSIN$2, event => { |
| 2917 |
if (document !== event.target && this._element !== event.target && !this._element.contains(event.target)) { |
| 2918 |
this._element.focus(); |
| 2919 |
} |
| 2920 |
}); |
| 2921 |
} |
| 2922 |
|
| 2923 |
_setEscapeEvent() { |
| 2924 |
if (this._isShown) { |
| 2925 |
EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS$1, event => { |
| 2926 |
if (this._config.keyboard && event.key === ESCAPE_KEY$1) { |
| 2927 |
event.preventDefault(); |
| 2928 |
this.hide(); |
| 2929 |
} else if (!this._config.keyboard && event.key === ESCAPE_KEY$1) { |
| 2930 |
this._triggerBackdropTransition(); |
| 2931 |
} |
| 2932 |
}); |
| 2933 |
} else { |
| 2934 |
EventHandler.off(this._element, EVENT_KEYDOWN_DISMISS$1); |
| 2935 |
} |
| 2936 |
} |
| 2937 |
|
| 2938 |
_setResizeEvent() { |
| 2939 |
if (this._isShown) { |
| 2940 |
EventHandler.on(window, EVENT_RESIZE, () => this._adjustDialog()); |
| 2941 |
} else { |
| 2942 |
EventHandler.off(window, EVENT_RESIZE); |
| 2943 |
} |
| 2944 |
} |
| 2945 |
|
| 2946 |
_hideModal() { |
| 2947 |
this._element.style.display = 'none'; |
| 2948 |
|
| 2949 |
this._element.setAttribute('aria-hidden', true); |
| 2950 |
|
| 2951 |
this._element.removeAttribute('aria-modal'); |
| 2952 |
|
| 2953 |
this._element.removeAttribute('role'); |
| 2954 |
|
| 2955 |
this._isTransitioning = false; |
| 2956 |
|
| 2957 |
this._backdrop.hide(() => { |
| 2958 |
document.body.classList.remove(CLASS_NAME_OPEN); |
| 2959 |
|
| 2960 |
this._resetAdjustments(); |
| 2961 |
|
| 2962 |
this._scrollBar.reset(); |
| 2963 |
|
| 2964 |
EventHandler.trigger(this._element, EVENT_HIDDEN$3); |
| 2965 |
}); |
| 2966 |
} |
| 2967 |
|
| 2968 |
_showBackdrop(callback) { |
| 2969 |
EventHandler.on(this._element, EVENT_CLICK_DISMISS$2, event => { |
| 2970 |
if (this._ignoreBackdropClick) { |
| 2971 |
this._ignoreBackdropClick = false; |
| 2972 |
return; |
| 2973 |
} |
| 2974 |
|
| 2975 |
if (event.target !== event.currentTarget) { |
| 2976 |
return; |
| 2977 |
} |
| 2978 |
|
| 2979 |
if (this._config.backdrop === true) { |
| 2980 |
this.hide(); |
| 2981 |
} else if (this._config.backdrop === 'static') { |
| 2982 |
this._triggerBackdropTransition(); |
| 2983 |
} |
| 2984 |
}); |
| 2985 |
|
| 2986 |
this._backdrop.show(callback); |
| 2987 |
} |
| 2988 |
|
| 2989 |
_isAnimated() { |
| 2990 |
return this._element.classList.contains(CLASS_NAME_FADE$4); |
| 2991 |
} |
| 2992 |
|
| 2993 |
_triggerBackdropTransition() { |
| 2994 |
const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED); |
| 2995 |
|
| 2996 |
if (hideEvent.defaultPrevented) { |
| 2997 |
return; |
| 2998 |
} |
| 2999 |
|
| 3000 |
const { |
| 3001 |
classList, |
| 3002 |
scrollHeight, |
| 3003 |
style |
| 3004 |
} = this._element; |
| 3005 |
const isModalOverflowing = scrollHeight > document.documentElement.clientHeight; // return if the following background transition hasn't yet completed |
| 3006 |
|
| 3007 |
if (!isModalOverflowing && style.overflowY === 'hidden' || classList.contains(CLASS_NAME_STATIC)) { |
| 3008 |
return; |
| 3009 |
} |
| 3010 |
|
| 3011 |
if (!isModalOverflowing) { |
| 3012 |
style.overflowY = 'hidden'; |
| 3013 |
} |
| 3014 |
|
| 3015 |
classList.add(CLASS_NAME_STATIC); |
| 3016 |
|
| 3017 |
this._queueCallback(() => { |
| 3018 |
classList.remove(CLASS_NAME_STATIC); |
| 3019 |
|
| 3020 |
if (!isModalOverflowing) { |
| 3021 |
this._queueCallback(() => { |
| 3022 |
style.overflowY = ''; |
| 3023 |
}, this._dialog); |
| 3024 |
} |
| 3025 |
}, this._dialog); |
| 3026 |
|
| 3027 |
this._element.focus(); |
| 3028 |
} // ---------------------------------------------------------------------- |
| 3029 |
// the following methods are used to handle overflowing modals |
| 3030 |
// ---------------------------------------------------------------------- |
| 3031 |
|
| 3032 |
|
| 3033 |
_adjustDialog() { |
| 3034 |
const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight; |
| 3035 |
|
| 3036 |
const scrollbarWidth = this._scrollBar.getWidth(); |
| 3037 |
|
| 3038 |
const isBodyOverflowing = scrollbarWidth > 0; |
| 3039 |
|
| 3040 |
if (!isBodyOverflowing && isModalOverflowing && !isRTL() || isBodyOverflowing && !isModalOverflowing && isRTL()) { |
| 3041 |
this._element.style.paddingLeft = `${scrollbarWidth}px`; |
| 3042 |
} |
| 3043 |
|
| 3044 |
if (isBodyOverflowing && !isModalOverflowing && !isRTL() || !isBodyOverflowing && isModalOverflowing && isRTL()) { |
| 3045 |
this._element.style.paddingRight = `${scrollbarWidth}px`; |
| 3046 |
} |
| 3047 |
} |
| 3048 |
|
| 3049 |
_resetAdjustments() { |
| 3050 |
this._element.style.paddingLeft = ''; |
| 3051 |
this._element.style.paddingRight = ''; |
| 3052 |
} // Static |
| 3053 |
|
| 3054 |
|
| 3055 |
static jQueryInterface(config, relatedTarget) { |
| 3056 |
return this.each(function () { |
| 3057 |
const data = Modal.getOrCreateInstance(this, config); |
| 3058 |
|
| 3059 |
if (typeof config !== 'string') { |
| 3060 |
return; |
| 3061 |
} |
| 3062 |
|
| 3063 |
if (typeof data[config] === 'undefined') { |
| 3064 |
throw new TypeError(`No method named "${config}"`); |
| 3065 |
} |
| 3066 |
|
| 3067 |
data[config](relatedTarget); |
| 3068 |
}); |
| 3069 |
} |
| 3070 |
|
| 3071 |
} |
| 3072 |
/** |
| 3073 |
* ------------------------------------------------------------------------ |
| 3074 |
* Data Api implementation |
| 3075 |
* ------------------------------------------------------------------------ |
| 3076 |
*/ |
| 3077 |
|
| 3078 |
|
| 3079 |
EventHandler.on(document, EVENT_CLICK_DATA_API$2, SELECTOR_DATA_TOGGLE$2, function (event) { |
| 3080 |
const target = getElementFromSelector(this); |
| 3081 |
|
| 3082 |
if (['A', 'AREA'].includes(this.tagName)) { |
| 3083 |
event.preventDefault(); |
| 3084 |
} |
| 3085 |
|
| 3086 |
EventHandler.one(target, EVENT_SHOW$3, showEvent => { |
| 3087 |
if (showEvent.defaultPrevented) { |
| 3088 |
// only register focus restorer if modal will actually get shown |
| 3089 |
return; |
| 3090 |
} |
| 3091 |
|
| 3092 |
EventHandler.one(target, EVENT_HIDDEN$3, () => { |
| 3093 |
if (isVisible(this)) { |
| 3094 |
this.focus(); |
| 3095 |
} |
| 3096 |
}); |
| 3097 |
}); |
| 3098 |
const data = Modal.getOrCreateInstance(target); |
| 3099 |
data.toggle(this); |
| 3100 |
}); |
| 3101 |
/** |
| 3102 |
* ------------------------------------------------------------------------ |
| 3103 |
* jQuery |
| 3104 |
* ------------------------------------------------------------------------ |
| 3105 |
* add .Modal to jQuery only if jQuery is present |
| 3106 |
*/ |
| 3107 |
|
| 3108 |
defineJQueryPlugin(Modal); |
| 3109 |
|
| 3110 |
/** |
| 3111 |
* -------------------------------------------------------------------------- |
| 3112 |
* Bootstrap (v5.0.2): offcanvas.js |
| 3113 |
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) |
| 3114 |
* -------------------------------------------------------------------------- |
| 3115 |
*/ |
| 3116 |
/** |
| 3117 |
* ------------------------------------------------------------------------ |
| 3118 |
* Constants |
| 3119 |
* ------------------------------------------------------------------------ |
| 3120 |
*/ |
| 3121 |
|
| 3122 |
const NAME$5 = 'offcanvas'; |
| 3123 |
const DATA_KEY$5 = 'bs.offcanvas'; |
| 3124 |
const EVENT_KEY$5 = `.${DATA_KEY$5}`; |
| 3125 |
const DATA_API_KEY$2 = '.data-api'; |
| 3126 |
const EVENT_LOAD_DATA_API$1 = `load${EVENT_KEY$5}${DATA_API_KEY$2}`; |
| 3127 |
const ESCAPE_KEY = 'Escape'; |
| 3128 |
const Default$4 = { |
| 3129 |
backdrop: true, |
| 3130 |
keyboard: true, |
| 3131 |
scroll: false |
| 3132 |
}; |
| 3133 |
const DefaultType$4 = { |
| 3134 |
backdrop: 'boolean', |
| 3135 |
keyboard: 'boolean', |
| 3136 |
scroll: 'boolean' |
| 3137 |
}; |
| 3138 |
const CLASS_NAME_SHOW$4 = 'show'; |
| 3139 |
const OPEN_SELECTOR = '.offcanvas.show'; |
| 3140 |
const EVENT_SHOW$2 = `show${EVENT_KEY$5}`; |
| 3141 |
const EVENT_SHOWN$2 = `shown${EVENT_KEY$5}`; |
| 3142 |
const EVENT_HIDE$2 = `hide${EVENT_KEY$5}`; |
| 3143 |
const EVENT_HIDDEN$2 = `hidden${EVENT_KEY$5}`; |
| 3144 |
const EVENT_FOCUSIN$1 = `focusin${EVENT_KEY$5}`; |
| 3145 |
const EVENT_CLICK_DATA_API$1 = `click${EVENT_KEY$5}${DATA_API_KEY$2}`; |
| 3146 |
const EVENT_CLICK_DISMISS$1 = `click.dismiss${EVENT_KEY$5}`; |
| 3147 |
const EVENT_KEYDOWN_DISMISS = `keydown.dismiss${EVENT_KEY$5}`; |
| 3148 |
const SELECTOR_DATA_DISMISS$1 = '[data-bs-dismiss="offcanvas"]'; |
| 3149 |
const SELECTOR_DATA_TOGGLE$1 = '[data-bs-toggle="offcanvas"]'; |
| 3150 |
/** |
| 3151 |
* ------------------------------------------------------------------------ |
| 3152 |
* Class Definition |
| 3153 |
* ------------------------------------------------------------------------ |
| 3154 |
*/ |
| 3155 |
|
| 3156 |
class Offcanvas extends BaseComponent { |
| 3157 |
constructor(element, config) { |
| 3158 |
super(element); |
| 3159 |
this._config = this._getConfig(config); |
| 3160 |
this._isShown = false; |
| 3161 |
this._backdrop = this._initializeBackDrop(); |
| 3162 |
|
| 3163 |
this._addEventListeners(); |
| 3164 |
} // Getters |
| 3165 |
|
| 3166 |
|
| 3167 |
static get NAME() { |
| 3168 |
return NAME$5; |
| 3169 |
} |
| 3170 |
|
| 3171 |
static get Default() { |
| 3172 |
return Default$4; |
| 3173 |
} // Public |
| 3174 |
|
| 3175 |
|
| 3176 |
toggle(relatedTarget) { |
| 3177 |
return this._isShown ? this.hide() : this.show(relatedTarget); |
| 3178 |
} |
| 3179 |
|
| 3180 |
show(relatedTarget) { |
| 3181 |
if (this._isShown) { |
| 3182 |
return; |
| 3183 |
} |
| 3184 |
|
| 3185 |
const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$2, { |
| 3186 |
relatedTarget |
| 3187 |
}); |
| 3188 |
|
| 3189 |
if (showEvent.defaultPrevented) { |
| 3190 |
return; |
| 3191 |
} |
| 3192 |
|
| 3193 |
this._isShown = true; |
| 3194 |
this._element.style.visibility = 'visible'; |
| 3195 |
|
| 3196 |
this._backdrop.show(); |
| 3197 |
|
| 3198 |
if (!this._config.scroll) { |
| 3199 |
new ScrollBarHelper().hide(); |
| 3200 |
|
| 3201 |
this._enforceFocusOnElement(this._element); |
| 3202 |
} |
| 3203 |
|
| 3204 |
this._element.removeAttribute('aria-hidden'); |
| 3205 |
|
| 3206 |
this._element.setAttribute('aria-modal', true); |
| 3207 |
|
| 3208 |
this._element.setAttribute('role', 'dialog'); |
| 3209 |
|
| 3210 |
this._element.classList.add(CLASS_NAME_SHOW$4); |
| 3211 |
|
| 3212 |
const completeCallBack = () => { |
| 3213 |
EventHandler.trigger(this._element, EVENT_SHOWN$2, { |
| 3214 |
relatedTarget |
| 3215 |
}); |
| 3216 |
}; |
| 3217 |
|
| 3218 |
this._queueCallback(completeCallBack, this._element, true); |
| 3219 |
} |
| 3220 |
|
| 3221 |
hide() { |
| 3222 |
if (!this._isShown) { |
| 3223 |
return; |
| 3224 |
} |
| 3225 |
|
| 3226 |
const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$2); |
| 3227 |
|
| 3228 |
if (hideEvent.defaultPrevented) { |
| 3229 |
return; |
| 3230 |
} |
| 3231 |
|
| 3232 |
EventHandler.off(document, EVENT_FOCUSIN$1); |
| 3233 |
|
| 3234 |
this._element.blur(); |
| 3235 |
|
| 3236 |
this._isShown = false; |
| 3237 |
|
| 3238 |
this._element.classList.remove(CLASS_NAME_SHOW$4); |
| 3239 |
|
| 3240 |
this._backdrop.hide(); |
| 3241 |
|
| 3242 |
const completeCallback = () => { |
| 3243 |
this._element.setAttribute('aria-hidden', true); |
| 3244 |
|
| 3245 |
this._element.removeAttribute('aria-modal'); |
| 3246 |
|
| 3247 |
this._element.removeAttribute('role'); |
| 3248 |
|
| 3249 |
this._element.style.visibility = 'hidden'; |
| 3250 |
|
| 3251 |
if (!this._config.scroll) { |
| 3252 |
new ScrollBarHelper().reset(); |
| 3253 |
} |
| 3254 |
|
| 3255 |
EventHandler.trigger(this._element, EVENT_HIDDEN$2); |
| 3256 |
}; |
| 3257 |
|
| 3258 |
this._queueCallback(completeCallback, this._element, true); |
| 3259 |
} |
| 3260 |
|
| 3261 |
dispose() { |
| 3262 |
this._backdrop.dispose(); |
| 3263 |
|
| 3264 |
super.dispose(); |
| 3265 |
EventHandler.off(document, EVENT_FOCUSIN$1); |
| 3266 |
} // Private |
| 3267 |
|
| 3268 |
|
| 3269 |
_getConfig(config) { |
| 3270 |
config = { ...Default$4, |
| 3271 |
...Manipulator.getDataAttributes(this._element), |
| 3272 |
...(typeof config === 'object' ? config : {}) |
| 3273 |
}; |
| 3274 |
typeCheckConfig(NAME$5, config, DefaultType$4); |
| 3275 |
return config; |
| 3276 |
} |
| 3277 |
|
| 3278 |
_initializeBackDrop() { |
| 3279 |
return new Backdrop({ |
| 3280 |
isVisible: this._config.backdrop, |
| 3281 |
isAnimated: true, |
| 3282 |
rootElement: this._element.parentNode, |
| 3283 |
clickCallback: () => this.hide() |
| 3284 |
}); |
| 3285 |
} |
| 3286 |
|
| 3287 |
_enforceFocusOnElement(element) { |
| 3288 |
EventHandler.off(document, EVENT_FOCUSIN$1); // guard against infinite focus loop |
| 3289 |
|
| 3290 |
EventHandler.on(document, EVENT_FOCUSIN$1, event => { |
| 3291 |
if (document !== event.target && element !== event.target && !element.contains(event.target)) { |
| 3292 |
element.focus(); |
| 3293 |
} |
| 3294 |
}); |
| 3295 |
element.focus(); |
| 3296 |
} |
| 3297 |
|
| 3298 |
_addEventListeners() { |
| 3299 |
EventHandler.on(this._element, EVENT_CLICK_DISMISS$1, SELECTOR_DATA_DISMISS$1, () => this.hide()); |
| 3300 |
EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS, event => { |
| 3301 |
if (this._config.keyboard && event.key === ESCAPE_KEY) { |
| 3302 |
this.hide(); |
| 3303 |
} |
| 3304 |
}); |
| 3305 |
} // Static |
| 3306 |
|
| 3307 |
|
| 3308 |
static jQueryInterface(config) { |
| 3309 |
return this.each(function () { |
| 3310 |
const data = Offcanvas.getOrCreateInstance(this, config); |
| 3311 |
|
| 3312 |
if (typeof config !== 'string') { |
| 3313 |
return; |
| 3314 |
} |
| 3315 |
|
| 3316 |
if (data[config] === undefined || config.startsWith('_') || config === 'constructor') { |
| 3317 |
throw new TypeError(`No method named "${config}"`); |
| 3318 |
} |
| 3319 |
|
| 3320 |
data[config](this); |
| 3321 |
}); |
| 3322 |
} |
| 3323 |
|
| 3324 |
} |
| 3325 |
/** |
| 3326 |
* ------------------------------------------------------------------------ |
| 3327 |
* Data Api implementation |
| 3328 |
* ------------------------------------------------------------------------ |
| 3329 |
*/ |
| 3330 |
|
| 3331 |
|
| 3332 |
EventHandler.on(document, EVENT_CLICK_DATA_API$1, SELECTOR_DATA_TOGGLE$1, function (event) { |
| 3333 |
const target = getElementFromSelector(this); |
| 3334 |
|
| 3335 |
if (['A', 'AREA'].includes(this.tagName)) { |
| 3336 |
event.preventDefault(); |
| 3337 |
} |
| 3338 |
|
| 3339 |
if (isDisabled(this)) { |
| 3340 |
return; |
| 3341 |
} |
| 3342 |
|
| 3343 |
EventHandler.one(target, EVENT_HIDDEN$2, () => { |
| 3344 |
// focus on trigger when it is closed |
| 3345 |
if (isVisible(this)) { |
| 3346 |
this.focus(); |
| 3347 |
} |
| 3348 |
}); // avoid conflict when clicking a toggler of an offcanvas, while another is open |
| 3349 |
|
| 3350 |
const allReadyOpen = SelectorEngine.findOne(OPEN_SELECTOR); |
| 3351 |
|
| 3352 |
if (allReadyOpen && allReadyOpen !== target) { |
| 3353 |
Offcanvas.getInstance(allReadyOpen).hide(); |
| 3354 |
} |
| 3355 |
|
| 3356 |
const data = Offcanvas.getOrCreateInstance(target); |
| 3357 |
data.toggle(this); |
| 3358 |
}); |
| 3359 |
EventHandler.on(window, EVENT_LOAD_DATA_API$1, () => SelectorEngine.find(OPEN_SELECTOR).forEach(el => Offcanvas.getOrCreateInstance(el).show())); |
| 3360 |
/** |
| 3361 |
* ------------------------------------------------------------------------ |
| 3362 |
* jQuery |
| 3363 |
* ------------------------------------------------------------------------ |
| 3364 |
*/ |
| 3365 |
|
| 3366 |
defineJQueryPlugin(Offcanvas); |
| 3367 |
|
| 3368 |
/** |
| 3369 |
* -------------------------------------------------------------------------- |
| 3370 |
* Bootstrap (v5.0.2): util/sanitizer.js |
| 3371 |
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 3372 |
* -------------------------------------------------------------------------- |
| 3373 |
*/ |
| 3374 |
const uriAttrs = new Set(['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href']); |
| 3375 |
const ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i; |
| 3376 |
/** |
| 3377 |
* A pattern that recognizes a commonly useful subset of URLs that are safe. |
| 3378 |
* |
| 3379 |
* Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts |
| 3380 |
*/ |
| 3381 |
|
| 3382 |
const SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^#&/:?]*(?:[#/?]|$))/i; |
| 3383 |
/** |
| 3384 |
* A pattern that matches safe data URLs. Only matches image, video and audio types. |
| 3385 |
* |
| 3386 |
* Shoutout to Angular 7 https://github.com/angular/angular/blob/7.2.4/packages/core/src/sanitization/url_sanitizer.ts |
| 3387 |
*/ |
| 3388 |
|
| 3389 |
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; |
| 3390 |
|
| 3391 |
const allowedAttribute = (attr, allowedAttributeList) => { |
| 3392 |
const attrName = attr.nodeName.toLowerCase(); |
| 3393 |
|
| 3394 |
if (allowedAttributeList.includes(attrName)) { |
| 3395 |
if (uriAttrs.has(attrName)) { |
| 3396 |
return Boolean(SAFE_URL_PATTERN.test(attr.nodeValue) || DATA_URL_PATTERN.test(attr.nodeValue)); |
| 3397 |
} |
| 3398 |
|
| 3399 |
return true; |
| 3400 |
} |
| 3401 |
|
| 3402 |
const regExp = allowedAttributeList.filter(attrRegex => attrRegex instanceof RegExp); // Check if a regular expression validates the attribute. |
| 3403 |
|
| 3404 |
for (let i = 0, len = regExp.length; i < len; i++) { |
| 3405 |
if (regExp[i].test(attrName)) { |
| 3406 |
return true; |
| 3407 |
} |
| 3408 |
} |
| 3409 |
|
| 3410 |
return false; |
| 3411 |
}; |
| 3412 |
|
| 3413 |
const DefaultAllowlist = { |
| 3414 |
// Global attributes allowed on any supplied element below. |
| 3415 |
'*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN], |
| 3416 |
a: ['target', 'href', 'title', 'rel'], |
| 3417 |
area: [], |
| 3418 |
b: [], |
| 3419 |
br: [], |
| 3420 |
col: [], |
| 3421 |
code: [], |
| 3422 |
div: [], |
| 3423 |
em: [], |
| 3424 |
hr: [], |
| 3425 |
h1: [], |
| 3426 |
h2: [], |
| 3427 |
h3: [], |
| 3428 |
h4: [], |
| 3429 |
h5: [], |
| 3430 |
h6: [], |
| 3431 |
i: [], |
| 3432 |
img: ['src', 'srcset', 'alt', 'title', 'width', 'height'], |
| 3433 |
li: [], |
| 3434 |
ol: [], |
| 3435 |
p: [], |
| 3436 |
pre: [], |
| 3437 |
s: [], |
| 3438 |
small: [], |
| 3439 |
span: [], |
| 3440 |
sub: [], |
| 3441 |
sup: [], |
| 3442 |
strong: [], |
| 3443 |
u: [], |
| 3444 |
ul: [] |
| 3445 |
}; |
| 3446 |
function sanitizeHtml(unsafeHtml, allowList, sanitizeFn) { |
| 3447 |
if (!unsafeHtml.length) { |
| 3448 |
return unsafeHtml; |
| 3449 |
} |
| 3450 |
|
| 3451 |
if (sanitizeFn && typeof sanitizeFn === 'function') { |
| 3452 |
return sanitizeFn(unsafeHtml); |
| 3453 |
} |
| 3454 |
|
| 3455 |
const domParser = new window.DOMParser(); |
| 3456 |
const createdDocument = domParser.parseFromString(unsafeHtml, 'text/html'); |
| 3457 |
const allowlistKeys = Object.keys(allowList); |
| 3458 |
const elements = [].concat(...createdDocument.body.querySelectorAll('*')); |
| 3459 |
|
| 3460 |
for (let i = 0, len = elements.length; i < len; i++) { |
| 3461 |
const el = elements[i]; |
| 3462 |
const elName = el.nodeName.toLowerCase(); |
| 3463 |
|
| 3464 |
if (!allowlistKeys.includes(elName)) { |
| 3465 |
el.remove(); |
| 3466 |
continue; |
| 3467 |
} |
| 3468 |
|
| 3469 |
const attributeList = [].concat(...el.attributes); |
| 3470 |
const allowedAttributes = [].concat(allowList['*'] || [], allowList[elName] || []); |
| 3471 |
attributeList.forEach(attr => { |
| 3472 |
if (!allowedAttribute(attr, allowedAttributes)) { |
| 3473 |
el.removeAttribute(attr.nodeName); |
| 3474 |
} |
| 3475 |
}); |
| 3476 |
} |
| 3477 |
|
| 3478 |
return createdDocument.body.innerHTML; |
| 3479 |
} |
| 3480 |
|
| 3481 |
/** |
| 3482 |
* -------------------------------------------------------------------------- |
| 3483 |
* Bootstrap (v5.0.2): tooltip.js |
| 3484 |
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 3485 |
* -------------------------------------------------------------------------- |
| 3486 |
*/ |
| 3487 |
/** |
| 3488 |
* ------------------------------------------------------------------------ |
| 3489 |
* Constants |
| 3490 |
* ------------------------------------------------------------------------ |
| 3491 |
*/ |
| 3492 |
|
| 3493 |
const NAME$4 = 'tooltip'; |
| 3494 |
const DATA_KEY$4 = 'bs.tooltip'; |
| 3495 |
const EVENT_KEY$4 = `.${DATA_KEY$4}`; |
| 3496 |
const CLASS_PREFIX$1 = 'bs-tooltip'; |
| 3497 |
const BSCLS_PREFIX_REGEX$1 = new RegExp(`(^|\\s)${CLASS_PREFIX$1}\\S+`, 'g'); |
| 3498 |
const DISALLOWED_ATTRIBUTES = new Set(['sanitize', 'allowList', 'sanitizeFn']); |
| 3499 |
const DefaultType$3 = { |
| 3500 |
animation: 'boolean', |
| 3501 |
template: 'string', |
| 3502 |
title: '(string|element|function)', |
| 3503 |
trigger: 'string', |
| 3504 |
delay: '(number|object)', |
| 3505 |
html: 'boolean', |
| 3506 |
selector: '(string|boolean)', |
| 3507 |
placement: '(string|function)', |
| 3508 |
offset: '(array|string|function)', |
| 3509 |
container: '(string|element|boolean)', |
| 3510 |
fallbackPlacements: 'array', |
| 3511 |
boundary: '(string|element)', |
| 3512 |
customClass: '(string|function)', |
| 3513 |
sanitize: 'boolean', |
| 3514 |
sanitizeFn: '(null|function)', |
| 3515 |
allowList: 'object', |
| 3516 |
popperConfig: '(null|object|function)' |
| 3517 |
}; |
| 3518 |
const AttachmentMap = { |
| 3519 |
AUTO: 'auto', |
| 3520 |
TOP: 'top', |
| 3521 |
RIGHT: isRTL() ? 'left' : 'right', |
| 3522 |
BOTTOM: 'bottom', |
| 3523 |
LEFT: isRTL() ? 'right' : 'left' |
| 3524 |
}; |
| 3525 |
const Default$3 = { |
| 3526 |
animation: true, |
| 3527 |
template: '<div class="tooltip" role="tooltip">' + '<div class="tooltip-arrow"></div>' + '<div class="tooltip-inner"></div>' + '</div>', |
| 3528 |
trigger: 'hover focus', |
| 3529 |
title: '', |
| 3530 |
delay: 0, |
| 3531 |
html: false, |
| 3532 |
selector: false, |
| 3533 |
placement: 'top', |
| 3534 |
offset: [0, 0], |
| 3535 |
container: false, |
| 3536 |
fallbackPlacements: ['top', 'right', 'bottom', 'left'], |
| 3537 |
boundary: 'clippingParents', |
| 3538 |
customClass: '', |
| 3539 |
sanitize: true, |
| 3540 |
sanitizeFn: null, |
| 3541 |
allowList: DefaultAllowlist, |
| 3542 |
popperConfig: null |
| 3543 |
}; |
| 3544 |
const Event$2 = { |
| 3545 |
HIDE: `hide${EVENT_KEY$4}`, |
| 3546 |
HIDDEN: `hidden${EVENT_KEY$4}`, |
| 3547 |
SHOW: `show${EVENT_KEY$4}`, |
| 3548 |
SHOWN: `shown${EVENT_KEY$4}`, |
| 3549 |
INSERTED: `inserted${EVENT_KEY$4}`, |
| 3550 |
CLICK: `click${EVENT_KEY$4}`, |
| 3551 |
FOCUSIN: `focusin${EVENT_KEY$4}`, |
| 3552 |
FOCUSOUT: `focusout${EVENT_KEY$4}`, |
| 3553 |
MOUSEENTER: `mouseenter${EVENT_KEY$4}`, |
| 3554 |
MOUSELEAVE: `mouseleave${EVENT_KEY$4}` |
| 3555 |
}; |
| 3556 |
const CLASS_NAME_FADE$3 = 'fade'; |
| 3557 |
const CLASS_NAME_MODAL = 'modal'; |
| 3558 |
const CLASS_NAME_SHOW$3 = 'show'; |
| 3559 |
const HOVER_STATE_SHOW = 'show'; |
| 3560 |
const HOVER_STATE_OUT = 'out'; |
| 3561 |
const SELECTOR_TOOLTIP_INNER = '.tooltip-inner'; |
| 3562 |
const TRIGGER_HOVER = 'hover'; |
| 3563 |
const TRIGGER_FOCUS = 'focus'; |
| 3564 |
const TRIGGER_CLICK = 'click'; |
| 3565 |
const TRIGGER_MANUAL = 'manual'; |
| 3566 |
/** |
| 3567 |
* ------------------------------------------------------------------------ |
| 3568 |
* Class Definition |
| 3569 |
* ------------------------------------------------------------------------ |
| 3570 |
*/ |
| 3571 |
|
| 3572 |
class Tooltip extends BaseComponent { |
| 3573 |
constructor(element, config) { |
| 3574 |
if (typeof Popper__namespace === 'undefined') { |
| 3575 |
throw new TypeError('Bootstrap\'s tooltips require Popper (https://popper.js.org)'); |
| 3576 |
} |
| 3577 |
|
| 3578 |
super(element); // private |
| 3579 |
|
| 3580 |
this._isEnabled = true; |
| 3581 |
this._timeout = 0; |
| 3582 |
this._hoverState = ''; |
| 3583 |
this._activeTrigger = {}; |
| 3584 |
this._popper = null; // Protected |
| 3585 |
|
| 3586 |
this._config = this._getConfig(config); |
| 3587 |
this.tip = null; |
| 3588 |
|
| 3589 |
this._setListeners(); |
| 3590 |
} // Getters |
| 3591 |
|
| 3592 |
|
| 3593 |
static get Default() { |
| 3594 |
return Default$3; |
| 3595 |
} |
| 3596 |
|
| 3597 |
static get NAME() { |
| 3598 |
return NAME$4; |
| 3599 |
} |
| 3600 |
|
| 3601 |
static get Event() { |
| 3602 |
return Event$2; |
| 3603 |
} |
| 3604 |
|
| 3605 |
static get DefaultType() { |
| 3606 |
return DefaultType$3; |
| 3607 |
} // Public |
| 3608 |
|
| 3609 |
|
| 3610 |
enable() { |
| 3611 |
this._isEnabled = true; |
| 3612 |
} |
| 3613 |
|
| 3614 |
disable() { |
| 3615 |
this._isEnabled = false; |
| 3616 |
} |
| 3617 |
|
| 3618 |
toggleEnabled() { |
| 3619 |
this._isEnabled = !this._isEnabled; |
| 3620 |
} |
| 3621 |
|
| 3622 |
toggle(event) { |
| 3623 |
if (!this._isEnabled) { |
| 3624 |
return; |
| 3625 |
} |
| 3626 |
|
| 3627 |
if (event) { |
| 3628 |
const context = this._initializeOnDelegatedTarget(event); |
| 3629 |
|
| 3630 |
context._activeTrigger.click = !context._activeTrigger.click; |
| 3631 |
|
| 3632 |
if (context._isWithActiveTrigger()) { |
| 3633 |
context._enter(null, context); |
| 3634 |
} else { |
| 3635 |
context._leave(null, context); |
| 3636 |
} |
| 3637 |
} else { |
| 3638 |
if (this.getTipElement().classList.contains(CLASS_NAME_SHOW$3)) { |
| 3639 |
this._leave(null, this); |
| 3640 |
|
| 3641 |
return; |
| 3642 |
} |
| 3643 |
|
| 3644 |
this._enter(null, this); |
| 3645 |
} |
| 3646 |
} |
| 3647 |
|
| 3648 |
dispose() { |
| 3649 |
clearTimeout(this._timeout); |
| 3650 |
EventHandler.off(this._element.closest(`.${CLASS_NAME_MODAL}`), 'hide.bs.modal', this._hideModalHandler); |
| 3651 |
|
| 3652 |
if (this.tip) { |
| 3653 |
this.tip.remove(); |
| 3654 |
} |
| 3655 |
|
| 3656 |
if (this._popper) { |
| 3657 |
this._popper.destroy(); |
| 3658 |
} |
| 3659 |
|
| 3660 |
super.dispose(); |
| 3661 |
} |
| 3662 |
|
| 3663 |
show() { |
| 3664 |
if (this._element.style.display === 'none') { |
| 3665 |
throw new Error('Please use show on visible elements'); |
| 3666 |
} |
| 3667 |
|
| 3668 |
if (!(this.isWithContent() && this._isEnabled)) { |
| 3669 |
return; |
| 3670 |
} |
| 3671 |
|
| 3672 |
const showEvent = EventHandler.trigger(this._element, this.constructor.Event.SHOW); |
| 3673 |
const shadowRoot = findShadowRoot(this._element); |
| 3674 |
const isInTheDom = shadowRoot === null ? this._element.ownerDocument.documentElement.contains(this._element) : shadowRoot.contains(this._element); |
| 3675 |
|
| 3676 |
if (showEvent.defaultPrevented || !isInTheDom) { |
| 3677 |
return; |
| 3678 |
} |
| 3679 |
|
| 3680 |
const tip = this.getTipElement(); |
| 3681 |
const tipId = getUID(this.constructor.NAME); |
| 3682 |
tip.setAttribute('id', tipId); |
| 3683 |
|
| 3684 |
this._element.setAttribute('aria-describedby', tipId); |
| 3685 |
|
| 3686 |
this.setContent(); |
| 3687 |
|
| 3688 |
if (this._config.animation) { |
| 3689 |
tip.classList.add(CLASS_NAME_FADE$3); |
| 3690 |
} |
| 3691 |
|
| 3692 |
const placement = typeof this._config.placement === 'function' ? this._config.placement.call(this, tip, this._element) : this._config.placement; |
| 3693 |
|
| 3694 |
const attachment = this._getAttachment(placement); |
| 3695 |
|
| 3696 |
this._addAttachmentClass(attachment); |
| 3697 |
|
| 3698 |
const { |
| 3699 |
container |
| 3700 |
} = this._config; |
| 3701 |
Data.set(tip, this.constructor.DATA_KEY, this); |
| 3702 |
|
| 3703 |
if (!this._element.ownerDocument.documentElement.contains(this.tip)) { |
| 3704 |
container.appendChild(tip); |
| 3705 |
EventHandler.trigger(this._element, this.constructor.Event.INSERTED); |
| 3706 |
} |
| 3707 |
|
| 3708 |
if (this._popper) { |
| 3709 |
this._popper.update(); |
| 3710 |
} else { |
| 3711 |
this._popper = Popper__namespace.createPopper(this._element, tip, this._getPopperConfig(attachment)); |
| 3712 |
} |
| 3713 |
|
| 3714 |
tip.classList.add(CLASS_NAME_SHOW$3); |
| 3715 |
const customClass = typeof this._config.customClass === 'function' ? this._config.customClass() : this._config.customClass; |
| 3716 |
|
| 3717 |
if (customClass) { |
| 3718 |
tip.classList.add(...customClass.split(' ')); |
| 3719 |
} // If this is a touch-enabled device we add extra |
| 3720 |
// empty mouseover listeners to the body's immediate children; |
| 3721 |
// only needed because of broken event delegation on iOS |
| 3722 |
// https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html |
| 3723 |
|
| 3724 |
|
| 3725 |
if ('ontouchstart' in document.documentElement) { |
| 3726 |
[].concat(...document.body.children).forEach(element => { |
| 3727 |
EventHandler.on(element, 'mouseover', noop); |
| 3728 |
}); |
| 3729 |
} |
| 3730 |
|
| 3731 |
const complete = () => { |
| 3732 |
const prevHoverState = this._hoverState; |
| 3733 |
this._hoverState = null; |
| 3734 |
EventHandler.trigger(this._element, this.constructor.Event.SHOWN); |
| 3735 |
|
| 3736 |
if (prevHoverState === HOVER_STATE_OUT) { |
| 3737 |
this._leave(null, this); |
| 3738 |
} |
| 3739 |
}; |
| 3740 |
|
| 3741 |
const isAnimated = this.tip.classList.contains(CLASS_NAME_FADE$3); |
| 3742 |
|
| 3743 |
this._queueCallback(complete, this.tip, isAnimated); |
| 3744 |
} |
| 3745 |
|
| 3746 |
hide() { |
| 3747 |
if (!this._popper) { |
| 3748 |
return; |
| 3749 |
} |
| 3750 |
|
| 3751 |
const tip = this.getTipElement(); |
| 3752 |
|
| 3753 |
const complete = () => { |
| 3754 |
if (this._isWithActiveTrigger()) { |
| 3755 |
return; |
| 3756 |
} |
| 3757 |
|
| 3758 |
if (this._hoverState !== HOVER_STATE_SHOW) { |
| 3759 |
tip.remove(); |
| 3760 |
} |
| 3761 |
|
| 3762 |
this._cleanTipClass(); |
| 3763 |
|
| 3764 |
this._element.removeAttribute('aria-describedby'); |
| 3765 |
|
| 3766 |
EventHandler.trigger(this._element, this.constructor.Event.HIDDEN); |
| 3767 |
|
| 3768 |
if (this._popper) { |
| 3769 |
this._popper.destroy(); |
| 3770 |
|
| 3771 |
this._popper = null; |
| 3772 |
} |
| 3773 |
}; |
| 3774 |
|
| 3775 |
const hideEvent = EventHandler.trigger(this._element, this.constructor.Event.HIDE); |
| 3776 |
|
| 3777 |
if (hideEvent.defaultPrevented) { |
| 3778 |
return; |
| 3779 |
} |
| 3780 |
|
| 3781 |
tip.classList.remove(CLASS_NAME_SHOW$3); // If this is a touch-enabled device we remove the extra |
| 3782 |
// empty mouseover listeners we added for iOS support |
| 3783 |
|
| 3784 |
if ('ontouchstart' in document.documentElement) { |
| 3785 |
[].concat(...document.body.children).forEach(element => EventHandler.off(element, 'mouseover', noop)); |
| 3786 |
} |
| 3787 |
|
| 3788 |
this._activeTrigger[TRIGGER_CLICK] = false; |
| 3789 |
this._activeTrigger[TRIGGER_FOCUS] = false; |
| 3790 |
this._activeTrigger[TRIGGER_HOVER] = false; |
| 3791 |
const isAnimated = this.tip.classList.contains(CLASS_NAME_FADE$3); |
| 3792 |
|
| 3793 |
this._queueCallback(complete, this.tip, isAnimated); |
| 3794 |
|
| 3795 |
this._hoverState = ''; |
| 3796 |
} |
| 3797 |
|
| 3798 |
update() { |
| 3799 |
if (this._popper !== null) { |
| 3800 |
this._popper.update(); |
| 3801 |
} |
| 3802 |
} // Protected |
| 3803 |
|
| 3804 |
|
| 3805 |
isWithContent() { |
| 3806 |
return Boolean(this.getTitle()); |
| 3807 |
} |
| 3808 |
|
| 3809 |
getTipElement() { |
| 3810 |
if (this.tip) { |
| 3811 |
return this.tip; |
| 3812 |
} |
| 3813 |
|
| 3814 |
const element = document.createElement('div'); |
| 3815 |
element.innerHTML = this._config.template; |
| 3816 |
this.tip = element.children[0]; |
| 3817 |
return this.tip; |
| 3818 |
} |
| 3819 |
|
| 3820 |
setContent() { |
| 3821 |
const tip = this.getTipElement(); |
| 3822 |
this.setElementContent(SelectorEngine.findOne(SELECTOR_TOOLTIP_INNER, tip), this.getTitle()); |
| 3823 |
tip.classList.remove(CLASS_NAME_FADE$3, CLASS_NAME_SHOW$3); |
| 3824 |
} |
| 3825 |
|
| 3826 |
setElementContent(element, content) { |
| 3827 |
if (element === null) { |
| 3828 |
return; |
| 3829 |
} |
| 3830 |
|
| 3831 |
if (isElement(content)) { |
| 3832 |
content = getElement(content); // content is a DOM node or a jQuery |
| 3833 |
|
| 3834 |
if (this._config.html) { |
| 3835 |
if (content.parentNode !== element) { |
| 3836 |
element.innerHTML = ''; |
| 3837 |
element.appendChild(content); |
| 3838 |
} |
| 3839 |
} else { |
| 3840 |
element.textContent = content.textContent; |
| 3841 |
} |
| 3842 |
|
| 3843 |
return; |
| 3844 |
} |
| 3845 |
|
| 3846 |
if (this._config.html) { |
| 3847 |
if (this._config.sanitize) { |
| 3848 |
content = sanitizeHtml(content, this._config.allowList, this._config.sanitizeFn); |
| 3849 |
} |
| 3850 |
|
| 3851 |
element.innerHTML = content; |
| 3852 |
} else { |
| 3853 |
element.textContent = content; |
| 3854 |
} |
| 3855 |
} |
| 3856 |
|
| 3857 |
getTitle() { |
| 3858 |
let title = this._element.getAttribute('data-bs-original-title'); |
| 3859 |
|
| 3860 |
if (!title) { |
| 3861 |
title = typeof this._config.title === 'function' ? this._config.title.call(this._element) : this._config.title; |
| 3862 |
} |
| 3863 |
|
| 3864 |
return title; |
| 3865 |
} |
| 3866 |
|
| 3867 |
updateAttachment(attachment) { |
| 3868 |
if (attachment === 'right') { |
| 3869 |
return 'end'; |
| 3870 |
} |
| 3871 |
|
| 3872 |
if (attachment === 'left') { |
| 3873 |
return 'start'; |
| 3874 |
} |
| 3875 |
|
| 3876 |
return attachment; |
| 3877 |
} // Private |
| 3878 |
|
| 3879 |
|
| 3880 |
_initializeOnDelegatedTarget(event, context) { |
| 3881 |
const dataKey = this.constructor.DATA_KEY; |
| 3882 |
context = context || Data.get(event.delegateTarget, dataKey); |
| 3883 |
|
| 3884 |
if (!context) { |
| 3885 |
context = new this.constructor(event.delegateTarget, this._getDelegateConfig()); |
| 3886 |
Data.set(event.delegateTarget, dataKey, context); |
| 3887 |
} |
| 3888 |
|
| 3889 |
return context; |
| 3890 |
} |
| 3891 |
|
| 3892 |
_getOffset() { |
| 3893 |
const { |
| 3894 |
offset |
| 3895 |
} = this._config; |
| 3896 |
|
| 3897 |
if (typeof offset === 'string') { |
| 3898 |
return offset.split(',').map(val => Number.parseInt(val, 10)); |
| 3899 |
} |
| 3900 |
|
| 3901 |
if (typeof offset === 'function') { |
| 3902 |
return popperData => offset(popperData, this._element); |
| 3903 |
} |
| 3904 |
|
| 3905 |
return offset; |
| 3906 |
} |
| 3907 |
|
| 3908 |
_getPopperConfig(attachment) { |
| 3909 |
const defaultBsPopperConfig = { |
| 3910 |
placement: attachment, |
| 3911 |
modifiers: [{ |
| 3912 |
name: 'flip', |
| 3913 |
options: { |
| 3914 |
fallbackPlacements: this._config.fallbackPlacements |
| 3915 |
} |
| 3916 |
}, { |
| 3917 |
name: 'offset', |
| 3918 |
options: { |
| 3919 |
offset: this._getOffset() |
| 3920 |
} |
| 3921 |
}, { |
| 3922 |
name: 'preventOverflow', |
| 3923 |
options: { |
| 3924 |
boundary: this._config.boundary |
| 3925 |
} |
| 3926 |
}, { |
| 3927 |
name: 'arrow', |
| 3928 |
options: { |
| 3929 |
element: `.${this.constructor.NAME}-arrow` |
| 3930 |
} |
| 3931 |
}, { |
| 3932 |
name: 'onChange', |
| 3933 |
enabled: true, |
| 3934 |
phase: 'afterWrite', |
| 3935 |
fn: data => this._handlePopperPlacementChange(data) |
| 3936 |
}], |
| 3937 |
onFirstUpdate: data => { |
| 3938 |
if (data.options.placement !== data.placement) { |
| 3939 |
this._handlePopperPlacementChange(data); |
| 3940 |
} |
| 3941 |
} |
| 3942 |
}; |
| 3943 |
return { ...defaultBsPopperConfig, |
| 3944 |
...(typeof this._config.popperConfig === 'function' ? this._config.popperConfig(defaultBsPopperConfig) : this._config.popperConfig) |
| 3945 |
}; |
| 3946 |
} |
| 3947 |
|
| 3948 |
_addAttachmentClass(attachment) { |
| 3949 |
this.getTipElement().classList.add(`${CLASS_PREFIX$1}-${this.updateAttachment(attachment)}`); |
| 3950 |
} |
| 3951 |
|
| 3952 |
_getAttachment(placement) { |
| 3953 |
return AttachmentMap[placement.toUpperCase()]; |
| 3954 |
} |
| 3955 |
|
| 3956 |
_setListeners() { |
| 3957 |
const triggers = this._config.trigger.split(' '); |
| 3958 |
|
| 3959 |
triggers.forEach(trigger => { |
| 3960 |
if (trigger === 'click') { |
| 3961 |
EventHandler.on(this._element, this.constructor.Event.CLICK, this._config.selector, event => this.toggle(event)); |
| 3962 |
} else if (trigger !== TRIGGER_MANUAL) { |
| 3963 |
const eventIn = trigger === TRIGGER_HOVER ? this.constructor.Event.MOUSEENTER : this.constructor.Event.FOCUSIN; |
| 3964 |
const eventOut = trigger === TRIGGER_HOVER ? this.constructor.Event.MOUSELEAVE : this.constructor.Event.FOCUSOUT; |
| 3965 |
EventHandler.on(this._element, eventIn, this._config.selector, event => this._enter(event)); |
| 3966 |
EventHandler.on(this._element, eventOut, this._config.selector, event => this._leave(event)); |
| 3967 |
} |
| 3968 |
}); |
| 3969 |
|
| 3970 |
this._hideModalHandler = () => { |
| 3971 |
if (this._element) { |
| 3972 |
this.hide(); |
| 3973 |
} |
| 3974 |
}; |
| 3975 |
|
| 3976 |
EventHandler.on(this._element.closest(`.${CLASS_NAME_MODAL}`), 'hide.bs.modal', this._hideModalHandler); |
| 3977 |
|
| 3978 |
if (this._config.selector) { |
| 3979 |
this._config = { ...this._config, |
| 3980 |
trigger: 'manual', |
| 3981 |
selector: '' |
| 3982 |
}; |
| 3983 |
} else { |
| 3984 |
this._fixTitle(); |
| 3985 |
} |
| 3986 |
} |
| 3987 |
|
| 3988 |
_fixTitle() { |
| 3989 |
const title = this._element.getAttribute('title'); |
| 3990 |
|
| 3991 |
const originalTitleType = typeof this._element.getAttribute('data-bs-original-title'); |
| 3992 |
|
| 3993 |
if (title || originalTitleType !== 'string') { |
| 3994 |
this._element.setAttribute('data-bs-original-title', title || ''); |
| 3995 |
|
| 3996 |
if (title && !this._element.getAttribute('aria-label') && !this._element.textContent) { |
| 3997 |
this._element.setAttribute('aria-label', title); |
| 3998 |
} |
| 3999 |
|
| 4000 |
this._element.setAttribute('title', ''); |
| 4001 |
} |
| 4002 |
} |
| 4003 |
|
| 4004 |
_enter(event, context) { |
| 4005 |
context = this._initializeOnDelegatedTarget(event, context); |
| 4006 |
|
| 4007 |
if (event) { |
| 4008 |
context._activeTrigger[event.type === 'focusin' ? TRIGGER_FOCUS : TRIGGER_HOVER] = true; |
| 4009 |
} |
| 4010 |
|
| 4011 |
if (context.getTipElement().classList.contains(CLASS_NAME_SHOW$3) || context._hoverState === HOVER_STATE_SHOW) { |
| 4012 |
context._hoverState = HOVER_STATE_SHOW; |
| 4013 |
return; |
| 4014 |
} |
| 4015 |
|
| 4016 |
clearTimeout(context._timeout); |
| 4017 |
context._hoverState = HOVER_STATE_SHOW; |
| 4018 |
|
| 4019 |
if (!context._config.delay || !context._config.delay.show) { |
| 4020 |
context.show(); |
| 4021 |
return; |
| 4022 |
} |
| 4023 |
|
| 4024 |
context._timeout = setTimeout(() => { |
| 4025 |
if (context._hoverState === HOVER_STATE_SHOW) { |
| 4026 |
context.show(); |
| 4027 |
} |
| 4028 |
}, context._config.delay.show); |
| 4029 |
} |
| 4030 |
|
| 4031 |
_leave(event, context) { |
| 4032 |
context = this._initializeOnDelegatedTarget(event, context); |
| 4033 |
|
| 4034 |
if (event) { |
| 4035 |
context._activeTrigger[event.type === 'focusout' ? TRIGGER_FOCUS : TRIGGER_HOVER] = context._element.contains(event.relatedTarget); |
| 4036 |
} |
| 4037 |
|
| 4038 |
if (context._isWithActiveTrigger()) { |
| 4039 |
return; |
| 4040 |
} |
| 4041 |
|
| 4042 |
clearTimeout(context._timeout); |
| 4043 |
context._hoverState = HOVER_STATE_OUT; |
| 4044 |
|
| 4045 |
if (!context._config.delay || !context._config.delay.hide) { |
| 4046 |
context.hide(); |
| 4047 |
return; |
| 4048 |
} |
| 4049 |
|
| 4050 |
context._timeout = setTimeout(() => { |
| 4051 |
if (context._hoverState === HOVER_STATE_OUT) { |
| 4052 |
context.hide(); |
| 4053 |
} |
| 4054 |
}, context._config.delay.hide); |
| 4055 |
} |
| 4056 |
|
| 4057 |
_isWithActiveTrigger() { |
| 4058 |
for (const trigger in this._activeTrigger) { |
| 4059 |
if (this._activeTrigger[trigger]) { |
| 4060 |
return true; |
| 4061 |
} |
| 4062 |
} |
| 4063 |
|
| 4064 |
return false; |
| 4065 |
} |
| 4066 |
|
| 4067 |
_getConfig(config) { |
| 4068 |
const dataAttributes = Manipulator.getDataAttributes(this._element); |
| 4069 |
Object.keys(dataAttributes).forEach(dataAttr => { |
| 4070 |
if (DISALLOWED_ATTRIBUTES.has(dataAttr)) { |
| 4071 |
delete dataAttributes[dataAttr]; |
| 4072 |
} |
| 4073 |
}); |
| 4074 |
config = { ...this.constructor.Default, |
| 4075 |
...dataAttributes, |
| 4076 |
...(typeof config === 'object' && config ? config : {}) |
| 4077 |
}; |
| 4078 |
config.container = config.container === false ? document.body : getElement(config.container); |
| 4079 |
|
| 4080 |
if (typeof config.delay === 'number') { |
| 4081 |
config.delay = { |
| 4082 |
show: config.delay, |
| 4083 |
hide: config.delay |
| 4084 |
}; |
| 4085 |
} |
| 4086 |
|
| 4087 |
if (typeof config.title === 'number') { |
| 4088 |
config.title = config.title.toString(); |
| 4089 |
} |
| 4090 |
|
| 4091 |
if (typeof config.content === 'number') { |
| 4092 |
config.content = config.content.toString(); |
| 4093 |
} |
| 4094 |
|
| 4095 |
typeCheckConfig(NAME$4, config, this.constructor.DefaultType); |
| 4096 |
|
| 4097 |
if (config.sanitize) { |
| 4098 |
config.template = sanitizeHtml(config.template, config.allowList, config.sanitizeFn); |
| 4099 |
} |
| 4100 |
|
| 4101 |
return config; |
| 4102 |
} |
| 4103 |
|
| 4104 |
_getDelegateConfig() { |
| 4105 |
const config = {}; |
| 4106 |
|
| 4107 |
if (this._config) { |
| 4108 |
for (const key in this._config) { |
| 4109 |
if (this.constructor.Default[key] !== this._config[key]) { |
| 4110 |
config[key] = this._config[key]; |
| 4111 |
} |
| 4112 |
} |
| 4113 |
} |
| 4114 |
|
| 4115 |
return config; |
| 4116 |
} |
| 4117 |
|
| 4118 |
_cleanTipClass() { |
| 4119 |
const tip = this.getTipElement(); |
| 4120 |
const tabClass = tip.getAttribute('class').match(BSCLS_PREFIX_REGEX$1); |
| 4121 |
|
| 4122 |
if (tabClass !== null && tabClass.length > 0) { |
| 4123 |
tabClass.map(token => token.trim()).forEach(tClass => tip.classList.remove(tClass)); |
| 4124 |
} |
| 4125 |
} |
| 4126 |
|
| 4127 |
_handlePopperPlacementChange(popperData) { |
| 4128 |
const { |
| 4129 |
state |
| 4130 |
} = popperData; |
| 4131 |
|
| 4132 |
if (!state) { |
| 4133 |
return; |
| 4134 |
} |
| 4135 |
|
| 4136 |
this.tip = state.elements.popper; |
| 4137 |
|
| 4138 |
this._cleanTipClass(); |
| 4139 |
|
| 4140 |
this._addAttachmentClass(this._getAttachment(state.placement)); |
| 4141 |
} // Static |
| 4142 |
|
| 4143 |
|
| 4144 |
static jQueryInterface(config) { |
| 4145 |
return this.each(function () { |
| 4146 |
const data = Tooltip.getOrCreateInstance(this, config); |
| 4147 |
|
| 4148 |
if (typeof config === 'string') { |
| 4149 |
if (typeof data[config] === 'undefined') { |
| 4150 |
throw new TypeError(`No method named "${config}"`); |
| 4151 |
} |
| 4152 |
|
| 4153 |
data[config](); |
| 4154 |
} |
| 4155 |
}); |
| 4156 |
} |
| 4157 |
|
| 4158 |
} |
| 4159 |
/** |
| 4160 |
* ------------------------------------------------------------------------ |
| 4161 |
* jQuery |
| 4162 |
* ------------------------------------------------------------------------ |
| 4163 |
* add .Tooltip to jQuery only if jQuery is present |
| 4164 |
*/ |
| 4165 |
|
| 4166 |
|
| 4167 |
defineJQueryPlugin(Tooltip); |
| 4168 |
|
| 4169 |
/** |
| 4170 |
* -------------------------------------------------------------------------- |
| 4171 |
* Bootstrap (v5.0.2): popover.js |
| 4172 |
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 4173 |
* -------------------------------------------------------------------------- |
| 4174 |
*/ |
| 4175 |
/** |
| 4176 |
* ------------------------------------------------------------------------ |
| 4177 |
* Constants |
| 4178 |
* ------------------------------------------------------------------------ |
| 4179 |
*/ |
| 4180 |
|
| 4181 |
const NAME$3 = 'popover'; |
| 4182 |
const DATA_KEY$3 = 'bs.popover'; |
| 4183 |
const EVENT_KEY$3 = `.${DATA_KEY$3}`; |
| 4184 |
const CLASS_PREFIX = 'bs-popover'; |
| 4185 |
const BSCLS_PREFIX_REGEX = new RegExp(`(^|\\s)${CLASS_PREFIX}\\S+`, 'g'); |
| 4186 |
const Default$2 = { ...Tooltip.Default, |
| 4187 |
placement: 'right', |
| 4188 |
offset: [0, 8], |
| 4189 |
trigger: 'click', |
| 4190 |
content: '', |
| 4191 |
template: '<div class="popover" role="tooltip">' + '<div class="popover-arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div>' + '</div>' |
| 4192 |
}; |
| 4193 |
const DefaultType$2 = { ...Tooltip.DefaultType, |
| 4194 |
content: '(string|element|function)' |
| 4195 |
}; |
| 4196 |
const Event$1 = { |
| 4197 |
HIDE: `hide${EVENT_KEY$3}`, |
| 4198 |
HIDDEN: `hidden${EVENT_KEY$3}`, |
| 4199 |
SHOW: `show${EVENT_KEY$3}`, |
| 4200 |
SHOWN: `shown${EVENT_KEY$3}`, |
| 4201 |
INSERTED: `inserted${EVENT_KEY$3}`, |
| 4202 |
CLICK: `click${EVENT_KEY$3}`, |
| 4203 |
FOCUSIN: `focusin${EVENT_KEY$3}`, |
| 4204 |
FOCUSOUT: `focusout${EVENT_KEY$3}`, |
| 4205 |
MOUSEENTER: `mouseenter${EVENT_KEY$3}`, |
| 4206 |
MOUSELEAVE: `mouseleave${EVENT_KEY$3}` |
| 4207 |
}; |
| 4208 |
const CLASS_NAME_FADE$2 = 'fade'; |
| 4209 |
const CLASS_NAME_SHOW$2 = 'show'; |
| 4210 |
const SELECTOR_TITLE = '.popover-header'; |
| 4211 |
const SELECTOR_CONTENT = '.popover-body'; |
| 4212 |
/** |
| 4213 |
* ------------------------------------------------------------------------ |
| 4214 |
* Class Definition |
| 4215 |
* ------------------------------------------------------------------------ |
| 4216 |
*/ |
| 4217 |
|
| 4218 |
class Popover extends Tooltip { |
| 4219 |
// Getters |
| 4220 |
static get Default() { |
| 4221 |
return Default$2; |
| 4222 |
} |
| 4223 |
|
| 4224 |
static get NAME() { |
| 4225 |
return NAME$3; |
| 4226 |
} |
| 4227 |
|
| 4228 |
static get Event() { |
| 4229 |
return Event$1; |
| 4230 |
} |
| 4231 |
|
| 4232 |
static get DefaultType() { |
| 4233 |
return DefaultType$2; |
| 4234 |
} // Overrides |
| 4235 |
|
| 4236 |
|
| 4237 |
isWithContent() { |
| 4238 |
return this.getTitle() || this._getContent(); |
| 4239 |
} |
| 4240 |
|
| 4241 |
getTipElement() { |
| 4242 |
if (this.tip) { |
| 4243 |
return this.tip; |
| 4244 |
} |
| 4245 |
|
| 4246 |
this.tip = super.getTipElement(); |
| 4247 |
|
| 4248 |
if (!this.getTitle()) { |
| 4249 |
SelectorEngine.findOne(SELECTOR_TITLE, this.tip).remove(); |
| 4250 |
} |
| 4251 |
|
| 4252 |
if (!this._getContent()) { |
| 4253 |
SelectorEngine.findOne(SELECTOR_CONTENT, this.tip).remove(); |
| 4254 |
} |
| 4255 |
|
| 4256 |
return this.tip; |
| 4257 |
} |
| 4258 |
|
| 4259 |
setContent() { |
| 4260 |
const tip = this.getTipElement(); // we use append for html objects to maintain js events |
| 4261 |
|
| 4262 |
this.setElementContent(SelectorEngine.findOne(SELECTOR_TITLE, tip), this.getTitle()); |
| 4263 |
|
| 4264 |
let content = this._getContent(); |
| 4265 |
|
| 4266 |
if (typeof content === 'function') { |
| 4267 |
content = content.call(this._element); |
| 4268 |
} |
| 4269 |
|
| 4270 |
this.setElementContent(SelectorEngine.findOne(SELECTOR_CONTENT, tip), content); |
| 4271 |
tip.classList.remove(CLASS_NAME_FADE$2, CLASS_NAME_SHOW$2); |
| 4272 |
} // Private |
| 4273 |
|
| 4274 |
|
| 4275 |
_addAttachmentClass(attachment) { |
| 4276 |
this.getTipElement().classList.add(`${CLASS_PREFIX}-${this.updateAttachment(attachment)}`); |
| 4277 |
} |
| 4278 |
|
| 4279 |
_getContent() { |
| 4280 |
return this._element.getAttribute('data-bs-content') || this._config.content; |
| 4281 |
} |
| 4282 |
|
| 4283 |
_cleanTipClass() { |
| 4284 |
const tip = this.getTipElement(); |
| 4285 |
const tabClass = tip.getAttribute('class').match(BSCLS_PREFIX_REGEX); |
| 4286 |
|
| 4287 |
if (tabClass !== null && tabClass.length > 0) { |
| 4288 |
tabClass.map(token => token.trim()).forEach(tClass => tip.classList.remove(tClass)); |
| 4289 |
} |
| 4290 |
} // Static |
| 4291 |
|
| 4292 |
|
| 4293 |
static jQueryInterface(config) { |
| 4294 |
return this.each(function () { |
| 4295 |
const data = Popover.getOrCreateInstance(this, config); |
| 4296 |
|
| 4297 |
if (typeof config === 'string') { |
| 4298 |
if (typeof data[config] === 'undefined') { |
| 4299 |
throw new TypeError(`No method named "${config}"`); |
| 4300 |
} |
| 4301 |
|
| 4302 |
data[config](); |
| 4303 |
} |
| 4304 |
}); |
| 4305 |
} |
| 4306 |
|
| 4307 |
} |
| 4308 |
/** |
| 4309 |
* ------------------------------------------------------------------------ |
| 4310 |
* jQuery |
| 4311 |
* ------------------------------------------------------------------------ |
| 4312 |
* add .Popover to jQuery only if jQuery is present |
| 4313 |
*/ |
| 4314 |
|
| 4315 |
|
| 4316 |
defineJQueryPlugin(Popover); |
| 4317 |
|
| 4318 |
/** |
| 4319 |
* -------------------------------------------------------------------------- |
| 4320 |
* Bootstrap (v5.0.2): scrollspy.js |
| 4321 |
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 4322 |
* -------------------------------------------------------------------------- |
| 4323 |
*/ |
| 4324 |
/** |
| 4325 |
* ------------------------------------------------------------------------ |
| 4326 |
* Constants |
| 4327 |
* ------------------------------------------------------------------------ |
| 4328 |
*/ |
| 4329 |
|
| 4330 |
const NAME$2 = 'scrollspy'; |
| 4331 |
const DATA_KEY$2 = 'bs.scrollspy'; |
| 4332 |
const EVENT_KEY$2 = `.${DATA_KEY$2}`; |
| 4333 |
const DATA_API_KEY$1 = '.data-api'; |
| 4334 |
const Default$1 = { |
| 4335 |
offset: 10, |
| 4336 |
method: 'auto', |
| 4337 |
target: '' |
| 4338 |
}; |
| 4339 |
const DefaultType$1 = { |
| 4340 |
offset: 'number', |
| 4341 |
method: 'string', |
| 4342 |
target: '(string|element)' |
| 4343 |
}; |
| 4344 |
const EVENT_ACTIVATE = `activate${EVENT_KEY$2}`; |
| 4345 |
const EVENT_SCROLL = `scroll${EVENT_KEY$2}`; |
| 4346 |
const EVENT_LOAD_DATA_API = `load${EVENT_KEY$2}${DATA_API_KEY$1}`; |
| 4347 |
const CLASS_NAME_DROPDOWN_ITEM = 'dropdown-item'; |
| 4348 |
const CLASS_NAME_ACTIVE$1 = 'active'; |
| 4349 |
const SELECTOR_DATA_SPY = '[data-bs-spy="scroll"]'; |
| 4350 |
const SELECTOR_NAV_LIST_GROUP$1 = '.nav, .list-group'; |
| 4351 |
const SELECTOR_NAV_LINKS = '.nav-link'; |
| 4352 |
const SELECTOR_NAV_ITEMS = '.nav-item'; |
| 4353 |
const SELECTOR_LIST_ITEMS = '.list-group-item'; |
| 4354 |
const SELECTOR_DROPDOWN$1 = '.dropdown'; |
| 4355 |
const SELECTOR_DROPDOWN_TOGGLE$1 = '.dropdown-toggle'; |
| 4356 |
const METHOD_OFFSET = 'offset'; |
| 4357 |
const METHOD_POSITION = 'position'; |
| 4358 |
/** |
| 4359 |
* ------------------------------------------------------------------------ |
| 4360 |
* Class Definition |
| 4361 |
* ------------------------------------------------------------------------ |
| 4362 |
*/ |
| 4363 |
|
| 4364 |
class ScrollSpy extends BaseComponent { |
| 4365 |
constructor(element, config) { |
| 4366 |
super(element); |
| 4367 |
this._scrollElement = this._element.tagName === 'BODY' ? window : this._element; |
| 4368 |
this._config = this._getConfig(config); |
| 4369 |
this._selector = `${this._config.target} ${SELECTOR_NAV_LINKS}, ${this._config.target} ${SELECTOR_LIST_ITEMS}, ${this._config.target} .${CLASS_NAME_DROPDOWN_ITEM}`; |
| 4370 |
this._offsets = []; |
| 4371 |
this._targets = []; |
| 4372 |
this._activeTarget = null; |
| 4373 |
this._scrollHeight = 0; |
| 4374 |
EventHandler.on(this._scrollElement, EVENT_SCROLL, () => this._process()); |
| 4375 |
this.refresh(); |
| 4376 |
|
| 4377 |
this._process(); |
| 4378 |
} // Getters |
| 4379 |
|
| 4380 |
|
| 4381 |
static get Default() { |
| 4382 |
return Default$1; |
| 4383 |
} |
| 4384 |
|
| 4385 |
static get NAME() { |
| 4386 |
return NAME$2; |
| 4387 |
} // Public |
| 4388 |
|
| 4389 |
|
| 4390 |
refresh() { |
| 4391 |
const autoMethod = this._scrollElement === this._scrollElement.window ? METHOD_OFFSET : METHOD_POSITION; |
| 4392 |
const offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method; |
| 4393 |
const offsetBase = offsetMethod === METHOD_POSITION ? this._getScrollTop() : 0; |
| 4394 |
this._offsets = []; |
| 4395 |
this._targets = []; |
| 4396 |
this._scrollHeight = this._getScrollHeight(); |
| 4397 |
const targets = SelectorEngine.find(this._selector); |
| 4398 |
targets.map(element => { |
| 4399 |
const targetSelector = getSelectorFromElement(element); |
| 4400 |
const target = targetSelector ? SelectorEngine.findOne(targetSelector) : null; |
| 4401 |
|
| 4402 |
if (target) { |
| 4403 |
const targetBCR = target.getBoundingClientRect(); |
| 4404 |
|
| 4405 |
if (targetBCR.width || targetBCR.height) { |
| 4406 |
return [Manipulator[offsetMethod](target).top + offsetBase, targetSelector]; |
| 4407 |
} |
| 4408 |
} |
| 4409 |
|
| 4410 |
return null; |
| 4411 |
}).filter(item => item).sort((a, b) => a[0] - b[0]).forEach(item => { |
| 4412 |
this._offsets.push(item[0]); |
| 4413 |
|
| 4414 |
this._targets.push(item[1]); |
| 4415 |
}); |
| 4416 |
} |
| 4417 |
|
| 4418 |
dispose() { |
| 4419 |
EventHandler.off(this._scrollElement, EVENT_KEY$2); |
| 4420 |
super.dispose(); |
| 4421 |
} // Private |
| 4422 |
|
| 4423 |
|
| 4424 |
_getConfig(config) { |
| 4425 |
config = { ...Default$1, |
| 4426 |
...Manipulator.getDataAttributes(this._element), |
| 4427 |
...(typeof config === 'object' && config ? config : {}) |
| 4428 |
}; |
| 4429 |
|
| 4430 |
if (typeof config.target !== 'string' && isElement(config.target)) { |
| 4431 |
let { |
| 4432 |
id |
| 4433 |
} = config.target; |
| 4434 |
|
| 4435 |
if (!id) { |
| 4436 |
id = getUID(NAME$2); |
| 4437 |
config.target.id = id; |
| 4438 |
} |
| 4439 |
|
| 4440 |
config.target = `#${id}`; |
| 4441 |
} |
| 4442 |
|
| 4443 |
typeCheckConfig(NAME$2, config, DefaultType$1); |
| 4444 |
return config; |
| 4445 |
} |
| 4446 |
|
| 4447 |
_getScrollTop() { |
| 4448 |
return this._scrollElement === window ? this._scrollElement.pageYOffset : this._scrollElement.scrollTop; |
| 4449 |
} |
| 4450 |
|
| 4451 |
_getScrollHeight() { |
| 4452 |
return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight); |
| 4453 |
} |
| 4454 |
|
| 4455 |
_getOffsetHeight() { |
| 4456 |
return this._scrollElement === window ? window.innerHeight : this._scrollElement.getBoundingClientRect().height; |
| 4457 |
} |
| 4458 |
|
| 4459 |
_process() { |
| 4460 |
const scrollTop = this._getScrollTop() + this._config.offset; |
| 4461 |
|
| 4462 |
const scrollHeight = this._getScrollHeight(); |
| 4463 |
|
| 4464 |
const maxScroll = this._config.offset + scrollHeight - this._getOffsetHeight(); |
| 4465 |
|
| 4466 |
if (this._scrollHeight !== scrollHeight) { |
| 4467 |
this.refresh(); |
| 4468 |
} |
| 4469 |
|
| 4470 |
if (scrollTop >= maxScroll) { |
| 4471 |
const target = this._targets[this._targets.length - 1]; |
| 4472 |
|
| 4473 |
if (this._activeTarget !== target) { |
| 4474 |
this._activate(target); |
| 4475 |
} |
| 4476 |
|
| 4477 |
return; |
| 4478 |
} |
| 4479 |
|
| 4480 |
if (this._activeTarget && scrollTop < this._offsets[0] && this._offsets[0] > 0) { |
| 4481 |
this._activeTarget = null; |
| 4482 |
|
| 4483 |
this._clear(); |
| 4484 |
|
| 4485 |
return; |
| 4486 |
} |
| 4487 |
|
| 4488 |
for (let i = this._offsets.length; i--;) { |
| 4489 |
const isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (typeof this._offsets[i + 1] === 'undefined' || scrollTop < this._offsets[i + 1]); |
| 4490 |
|
| 4491 |
if (isActiveTarget) { |
| 4492 |
this._activate(this._targets[i]); |
| 4493 |
} |
| 4494 |
} |
| 4495 |
} |
| 4496 |
|
| 4497 |
_activate(target) { |
| 4498 |
this._activeTarget = target; |
| 4499 |
|
| 4500 |
this._clear(); |
| 4501 |
|
| 4502 |
const queries = this._selector.split(',').map(selector => `${selector}[data-bs-target="${target}"],${selector}[href="${target}"]`); |
| 4503 |
|
| 4504 |
const link = SelectorEngine.findOne(queries.join(',')); |
| 4505 |
|
| 4506 |
if (link.classList.contains(CLASS_NAME_DROPDOWN_ITEM)) { |
| 4507 |
SelectorEngine.findOne(SELECTOR_DROPDOWN_TOGGLE$1, link.closest(SELECTOR_DROPDOWN$1)).classList.add(CLASS_NAME_ACTIVE$1); |
| 4508 |
link.classList.add(CLASS_NAME_ACTIVE$1); |
| 4509 |
} else { |
| 4510 |
// Set triggered link as active |
| 4511 |
link.classList.add(CLASS_NAME_ACTIVE$1); |
| 4512 |
SelectorEngine.parents(link, SELECTOR_NAV_LIST_GROUP$1).forEach(listGroup => { |
| 4513 |
// Set triggered links parents as active |
| 4514 |
// With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor |
| 4515 |
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 |
| 4516 |
|
| 4517 |
SelectorEngine.prev(listGroup, SELECTOR_NAV_ITEMS).forEach(navItem => { |
| 4518 |
SelectorEngine.children(navItem, SELECTOR_NAV_LINKS).forEach(item => item.classList.add(CLASS_NAME_ACTIVE$1)); |
| 4519 |
}); |
| 4520 |
}); |
| 4521 |
} |
| 4522 |
|
| 4523 |
EventHandler.trigger(this._scrollElement, EVENT_ACTIVATE, { |
| 4524 |
relatedTarget: target |
| 4525 |
}); |
| 4526 |
} |
| 4527 |
|
| 4528 |
_clear() { |
| 4529 |
SelectorEngine.find(this._selector).filter(node => node.classList.contains(CLASS_NAME_ACTIVE$1)).forEach(node => node.classList.remove(CLASS_NAME_ACTIVE$1)); |
| 4530 |
} // Static |
| 4531 |
|
| 4532 |
|
| 4533 |
static jQueryInterface(config) { |
| 4534 |
return this.each(function () { |
| 4535 |
const data = ScrollSpy.getOrCreateInstance(this, config); |
| 4536 |
|
| 4537 |
if (typeof config !== 'string') { |
| 4538 |
return; |
| 4539 |
} |
| 4540 |
|
| 4541 |
if (typeof data[config] === 'undefined') { |
| 4542 |
throw new TypeError(`No method named "${config}"`); |
| 4543 |
} |
| 4544 |
|
| 4545 |
data[config](); |
| 4546 |
}); |
| 4547 |
} |
| 4548 |
|
| 4549 |
} |
| 4550 |
/** |
| 4551 |
* ------------------------------------------------------------------------ |
| 4552 |
* Data Api implementation |
| 4553 |
* ------------------------------------------------------------------------ |
| 4554 |
*/ |
| 4555 |
|
| 4556 |
|
| 4557 |
EventHandler.on(window, EVENT_LOAD_DATA_API, () => { |
| 4558 |
SelectorEngine.find(SELECTOR_DATA_SPY).forEach(spy => new ScrollSpy(spy)); |
| 4559 |
}); |
| 4560 |
/** |
| 4561 |
* ------------------------------------------------------------------------ |
| 4562 |
* jQuery |
| 4563 |
* ------------------------------------------------------------------------ |
| 4564 |
* add .ScrollSpy to jQuery only if jQuery is present |
| 4565 |
*/ |
| 4566 |
|
| 4567 |
defineJQueryPlugin(ScrollSpy); |
| 4568 |
|
| 4569 |
/** |
| 4570 |
* -------------------------------------------------------------------------- |
| 4571 |
* Bootstrap (v5.0.2): tab.js |
| 4572 |
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 4573 |
* -------------------------------------------------------------------------- |
| 4574 |
*/ |
| 4575 |
/** |
| 4576 |
* ------------------------------------------------------------------------ |
| 4577 |
* Constants |
| 4578 |
* ------------------------------------------------------------------------ |
| 4579 |
*/ |
| 4580 |
|
| 4581 |
const NAME$1 = 'tab'; |
| 4582 |
const DATA_KEY$1 = 'bs.tab'; |
| 4583 |
const EVENT_KEY$1 = `.${DATA_KEY$1}`; |
| 4584 |
const DATA_API_KEY = '.data-api'; |
| 4585 |
const EVENT_HIDE$1 = `hide${EVENT_KEY$1}`; |
| 4586 |
const EVENT_HIDDEN$1 = `hidden${EVENT_KEY$1}`; |
| 4587 |
const EVENT_SHOW$1 = `show${EVENT_KEY$1}`; |
| 4588 |
const EVENT_SHOWN$1 = `shown${EVENT_KEY$1}`; |
| 4589 |
const EVENT_CLICK_DATA_API = `click${EVENT_KEY$1}${DATA_API_KEY}`; |
| 4590 |
const CLASS_NAME_DROPDOWN_MENU = 'dropdown-menu'; |
| 4591 |
const CLASS_NAME_ACTIVE = 'active'; |
| 4592 |
const CLASS_NAME_FADE$1 = 'fade'; |
| 4593 |
const CLASS_NAME_SHOW$1 = 'show'; |
| 4594 |
const SELECTOR_DROPDOWN = '.dropdown'; |
| 4595 |
const SELECTOR_NAV_LIST_GROUP = '.nav, .list-group'; |
| 4596 |
const SELECTOR_ACTIVE = '.active'; |
| 4597 |
const SELECTOR_ACTIVE_UL = ':scope > li > .active'; |
| 4598 |
const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="tab"], [data-bs-toggle="pill"], [data-bs-toggle="list"]'; |
| 4599 |
const SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle'; |
| 4600 |
const SELECTOR_DROPDOWN_ACTIVE_CHILD = ':scope > .dropdown-menu .active'; |
| 4601 |
/** |
| 4602 |
* ------------------------------------------------------------------------ |
| 4603 |
* Class Definition |
| 4604 |
* ------------------------------------------------------------------------ |
| 4605 |
*/ |
| 4606 |
|
| 4607 |
class Tab extends BaseComponent { |
| 4608 |
// Getters |
| 4609 |
static get NAME() { |
| 4610 |
return NAME$1; |
| 4611 |
} // Public |
| 4612 |
|
| 4613 |
|
| 4614 |
show() { |
| 4615 |
if (this._element.parentNode && this._element.parentNode.nodeType === Node.ELEMENT_NODE && this._element.classList.contains(CLASS_NAME_ACTIVE)) { |
| 4616 |
return; |
| 4617 |
} |
| 4618 |
|
| 4619 |
let previous; |
| 4620 |
const target = getElementFromSelector(this._element); |
| 4621 |
|
| 4622 |
const listElement = this._element.closest(SELECTOR_NAV_LIST_GROUP); |
| 4623 |
|
| 4624 |
if (listElement) { |
| 4625 |
const itemSelector = listElement.nodeName === 'UL' || listElement.nodeName === 'OL' ? SELECTOR_ACTIVE_UL : SELECTOR_ACTIVE; |
| 4626 |
previous = SelectorEngine.find(itemSelector, listElement); |
| 4627 |
previous = previous[previous.length - 1]; |
| 4628 |
} |
| 4629 |
|
| 4630 |
const hideEvent = previous ? EventHandler.trigger(previous, EVENT_HIDE$1, { |
| 4631 |
relatedTarget: this._element |
| 4632 |
}) : null; |
| 4633 |
const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$1, { |
| 4634 |
relatedTarget: previous |
| 4635 |
}); |
| 4636 |
|
| 4637 |
if (showEvent.defaultPrevented || hideEvent !== null && hideEvent.defaultPrevented) { |
| 4638 |
return; |
| 4639 |
} |
| 4640 |
|
| 4641 |
this._activate(this._element, listElement); |
| 4642 |
|
| 4643 |
const complete = () => { |
| 4644 |
EventHandler.trigger(previous, EVENT_HIDDEN$1, { |
| 4645 |
relatedTarget: this._element |
| 4646 |
}); |
| 4647 |
EventHandler.trigger(this._element, EVENT_SHOWN$1, { |
| 4648 |
relatedTarget: previous |
| 4649 |
}); |
| 4650 |
}; |
| 4651 |
|
| 4652 |
if (target) { |
| 4653 |
this._activate(target, target.parentNode, complete); |
| 4654 |
} else { |
| 4655 |
complete(); |
| 4656 |
} |
| 4657 |
} // Private |
| 4658 |
|
| 4659 |
|
| 4660 |
_activate(element, container, callback) { |
| 4661 |
const activeElements = container && (container.nodeName === 'UL' || container.nodeName === 'OL') ? SelectorEngine.find(SELECTOR_ACTIVE_UL, container) : SelectorEngine.children(container, SELECTOR_ACTIVE); |
| 4662 |
const active = activeElements[0]; |
| 4663 |
const isTransitioning = callback && active && active.classList.contains(CLASS_NAME_FADE$1); |
| 4664 |
|
| 4665 |
const complete = () => this._transitionComplete(element, active, callback); |
| 4666 |
|
| 4667 |
if (active && isTransitioning) { |
| 4668 |
active.classList.remove(CLASS_NAME_SHOW$1); |
| 4669 |
|
| 4670 |
this._queueCallback(complete, element, true); |
| 4671 |
} else { |
| 4672 |
complete(); |
| 4673 |
} |
| 4674 |
} |
| 4675 |
|
| 4676 |
_transitionComplete(element, active, callback) { |
| 4677 |
if (active) { |
| 4678 |
active.classList.remove(CLASS_NAME_ACTIVE); |
| 4679 |
const dropdownChild = SelectorEngine.findOne(SELECTOR_DROPDOWN_ACTIVE_CHILD, active.parentNode); |
| 4680 |
|
| 4681 |
if (dropdownChild) { |
| 4682 |
dropdownChild.classList.remove(CLASS_NAME_ACTIVE); |
| 4683 |
} |
| 4684 |
|
| 4685 |
if (active.getAttribute('role') === 'tab') { |
| 4686 |
active.setAttribute('aria-selected', false); |
| 4687 |
} |
| 4688 |
} |
| 4689 |
|
| 4690 |
element.classList.add(CLASS_NAME_ACTIVE); |
| 4691 |
|
| 4692 |
if (element.getAttribute('role') === 'tab') { |
| 4693 |
element.setAttribute('aria-selected', true); |
| 4694 |
} |
| 4695 |
|
| 4696 |
reflow(element); |
| 4697 |
|
| 4698 |
if (element.classList.contains(CLASS_NAME_FADE$1)) { |
| 4699 |
element.classList.add(CLASS_NAME_SHOW$1); |
| 4700 |
} |
| 4701 |
|
| 4702 |
let parent = element.parentNode; |
| 4703 |
|
| 4704 |
if (parent && parent.nodeName === 'LI') { |
| 4705 |
parent = parent.parentNode; |
| 4706 |
} |
| 4707 |
|
| 4708 |
if (parent && parent.classList.contains(CLASS_NAME_DROPDOWN_MENU)) { |
| 4709 |
const dropdownElement = element.closest(SELECTOR_DROPDOWN); |
| 4710 |
|
| 4711 |
if (dropdownElement) { |
| 4712 |
SelectorEngine.find(SELECTOR_DROPDOWN_TOGGLE, dropdownElement).forEach(dropdown => dropdown.classList.add(CLASS_NAME_ACTIVE)); |
| 4713 |
} |
| 4714 |
|
| 4715 |
element.setAttribute('aria-expanded', true); |
| 4716 |
} |
| 4717 |
|
| 4718 |
if (callback) { |
| 4719 |
callback(); |
| 4720 |
} |
| 4721 |
} // Static |
| 4722 |
|
| 4723 |
|
| 4724 |
static jQueryInterface(config) { |
| 4725 |
return this.each(function () { |
| 4726 |
const data = Tab.getOrCreateInstance(this); |
| 4727 |
|
| 4728 |
if (typeof config === 'string') { |
| 4729 |
if (typeof data[config] === 'undefined') { |
| 4730 |
throw new TypeError(`No method named "${config}"`); |
| 4731 |
} |
| 4732 |
|
| 4733 |
data[config](); |
| 4734 |
} |
| 4735 |
}); |
| 4736 |
} |
| 4737 |
|
| 4738 |
} |
| 4739 |
/** |
| 4740 |
* ------------------------------------------------------------------------ |
| 4741 |
* Data Api implementation |
| 4742 |
* ------------------------------------------------------------------------ |
| 4743 |
*/ |
| 4744 |
|
| 4745 |
|
| 4746 |
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) { |
| 4747 |
if (['A', 'AREA'].includes(this.tagName)) { |
| 4748 |
event.preventDefault(); |
| 4749 |
} |
| 4750 |
|
| 4751 |
if (isDisabled(this)) { |
| 4752 |
return; |
| 4753 |
} |
| 4754 |
|
| 4755 |
const data = Tab.getOrCreateInstance(this); |
| 4756 |
data.show(); |
| 4757 |
}); |
| 4758 |
/** |
| 4759 |
* ------------------------------------------------------------------------ |
| 4760 |
* jQuery |
| 4761 |
* ------------------------------------------------------------------------ |
| 4762 |
* add .Tab to jQuery only if jQuery is present |
| 4763 |
*/ |
| 4764 |
|
| 4765 |
defineJQueryPlugin(Tab); |
| 4766 |
|
| 4767 |
/** |
| 4768 |
* -------------------------------------------------------------------------- |
| 4769 |
* Bootstrap (v5.0.2): toast.js |
| 4770 |
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 4771 |
* -------------------------------------------------------------------------- |
| 4772 |
*/ |
| 4773 |
/** |
| 4774 |
* ------------------------------------------------------------------------ |
| 4775 |
* Constants |
| 4776 |
* ------------------------------------------------------------------------ |
| 4777 |
*/ |
| 4778 |
|
| 4779 |
const NAME = 'toast'; |
| 4780 |
const DATA_KEY = 'bs.toast'; |
| 4781 |
const EVENT_KEY = `.${DATA_KEY}`; |
| 4782 |
const EVENT_CLICK_DISMISS = `click.dismiss${EVENT_KEY}`; |
| 4783 |
const EVENT_MOUSEOVER = `mouseover${EVENT_KEY}`; |
| 4784 |
const EVENT_MOUSEOUT = `mouseout${EVENT_KEY}`; |
| 4785 |
const EVENT_FOCUSIN = `focusin${EVENT_KEY}`; |
| 4786 |
const EVENT_FOCUSOUT = `focusout${EVENT_KEY}`; |
| 4787 |
const EVENT_HIDE = `hide${EVENT_KEY}`; |
| 4788 |
const EVENT_HIDDEN = `hidden${EVENT_KEY}`; |
| 4789 |
const EVENT_SHOW = `show${EVENT_KEY}`; |
| 4790 |
const EVENT_SHOWN = `shown${EVENT_KEY}`; |
| 4791 |
const CLASS_NAME_FADE = 'fade'; |
| 4792 |
const CLASS_NAME_HIDE = 'hide'; |
| 4793 |
const CLASS_NAME_SHOW = 'show'; |
| 4794 |
const CLASS_NAME_SHOWING = 'showing'; |
| 4795 |
const DefaultType = { |
| 4796 |
animation: 'boolean', |
| 4797 |
autohide: 'boolean', |
| 4798 |
delay: 'number' |
| 4799 |
}; |
| 4800 |
const Default = { |
| 4801 |
animation: true, |
| 4802 |
autohide: true, |
| 4803 |
delay: 5000 |
| 4804 |
}; |
| 4805 |
const SELECTOR_DATA_DISMISS = '[data-bs-dismiss="toast"]'; |
| 4806 |
/** |
| 4807 |
* ------------------------------------------------------------------------ |
| 4808 |
* Class Definition |
| 4809 |
* ------------------------------------------------------------------------ |
| 4810 |
*/ |
| 4811 |
|
| 4812 |
class Toast extends BaseComponent { |
| 4813 |
constructor(element, config) { |
| 4814 |
super(element); |
| 4815 |
this._config = this._getConfig(config); |
| 4816 |
this._timeout = null; |
| 4817 |
this._hasMouseInteraction = false; |
| 4818 |
this._hasKeyboardInteraction = false; |
| 4819 |
|
| 4820 |
this._setListeners(); |
| 4821 |
} // Getters |
| 4822 |
|
| 4823 |
|
| 4824 |
static get DefaultType() { |
| 4825 |
return DefaultType; |
| 4826 |
} |
| 4827 |
|
| 4828 |
static get Default() { |
| 4829 |
return Default; |
| 4830 |
} |
| 4831 |
|
| 4832 |
static get NAME() { |
| 4833 |
return NAME; |
| 4834 |
} // Public |
| 4835 |
|
| 4836 |
|
| 4837 |
show() { |
| 4838 |
const showEvent = EventHandler.trigger(this._element, EVENT_SHOW); |
| 4839 |
|
| 4840 |
if (showEvent.defaultPrevented) { |
| 4841 |
return; |
| 4842 |
} |
| 4843 |
|
| 4844 |
this._clearTimeout(); |
| 4845 |
|
| 4846 |
if (this._config.animation) { |
| 4847 |
this._element.classList.add(CLASS_NAME_FADE); |
| 4848 |
} |
| 4849 |
|
| 4850 |
const complete = () => { |
| 4851 |
this._element.classList.remove(CLASS_NAME_SHOWING); |
| 4852 |
|
| 4853 |
this._element.classList.add(CLASS_NAME_SHOW); |
| 4854 |
|
| 4855 |
EventHandler.trigger(this._element, EVENT_SHOWN); |
| 4856 |
|
| 4857 |
this._maybeScheduleHide(); |
| 4858 |
}; |
| 4859 |
|
| 4860 |
this._element.classList.remove(CLASS_NAME_HIDE); |
| 4861 |
|
| 4862 |
reflow(this._element); |
| 4863 |
|
| 4864 |
this._element.classList.add(CLASS_NAME_SHOWING); |
| 4865 |
|
| 4866 |
this._queueCallback(complete, this._element, this._config.animation); |
| 4867 |
} |
| 4868 |
|
| 4869 |
hide() { |
| 4870 |
if (!this._element.classList.contains(CLASS_NAME_SHOW)) { |
| 4871 |
return; |
| 4872 |
} |
| 4873 |
|
| 4874 |
const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE); |
| 4875 |
|
| 4876 |
if (hideEvent.defaultPrevented) { |
| 4877 |
return; |
| 4878 |
} |
| 4879 |
|
| 4880 |
const complete = () => { |
| 4881 |
this._element.classList.add(CLASS_NAME_HIDE); |
| 4882 |
|
| 4883 |
EventHandler.trigger(this._element, EVENT_HIDDEN); |
| 4884 |
}; |
| 4885 |
|
| 4886 |
this._element.classList.remove(CLASS_NAME_SHOW); |
| 4887 |
|
| 4888 |
this._queueCallback(complete, this._element, this._config.animation); |
| 4889 |
} |
| 4890 |
|
| 4891 |
dispose() { |
| 4892 |
this._clearTimeout(); |
| 4893 |
|
| 4894 |
if (this._element.classList.contains(CLASS_NAME_SHOW)) { |
| 4895 |
this._element.classList.remove(CLASS_NAME_SHOW); |
| 4896 |
} |
| 4897 |
|
| 4898 |
super.dispose(); |
| 4899 |
} // Private |
| 4900 |
|
| 4901 |
|
| 4902 |
_getConfig(config) { |
| 4903 |
config = { ...Default, |
| 4904 |
...Manipulator.getDataAttributes(this._element), |
| 4905 |
...(typeof config === 'object' && config ? config : {}) |
| 4906 |
}; |
| 4907 |
typeCheckConfig(NAME, config, this.constructor.DefaultType); |
| 4908 |
return config; |
| 4909 |
} |
| 4910 |
|
| 4911 |
_maybeScheduleHide() { |
| 4912 |
if (!this._config.autohide) { |
| 4913 |
return; |
| 4914 |
} |
| 4915 |
|
| 4916 |
if (this._hasMouseInteraction || this._hasKeyboardInteraction) { |
| 4917 |
return; |
| 4918 |
} |
| 4919 |
|
| 4920 |
this._timeout = setTimeout(() => { |
| 4921 |
this.hide(); |
| 4922 |
}, this._config.delay); |
| 4923 |
} |
| 4924 |
|
| 4925 |
_onInteraction(event, isInteracting) { |
| 4926 |
switch (event.type) { |
| 4927 |
case 'mouseover': |
| 4928 |
case 'mouseout': |
| 4929 |
this._hasMouseInteraction = isInteracting; |
| 4930 |
break; |
| 4931 |
|
| 4932 |
case 'focusin': |
| 4933 |
case 'focusout': |
| 4934 |
this._hasKeyboardInteraction = isInteracting; |
| 4935 |
break; |
| 4936 |
} |
| 4937 |
|
| 4938 |
if (isInteracting) { |
| 4939 |
this._clearTimeout(); |
| 4940 |
|
| 4941 |
return; |
| 4942 |
} |
| 4943 |
|
| 4944 |
const nextElement = event.relatedTarget; |
| 4945 |
|
| 4946 |
if (this._element === nextElement || this._element.contains(nextElement)) { |
| 4947 |
return; |
| 4948 |
} |
| 4949 |
|
| 4950 |
this._maybeScheduleHide(); |
| 4951 |
} |
| 4952 |
|
| 4953 |
_setListeners() { |
| 4954 |
EventHandler.on(this._element, EVENT_CLICK_DISMISS, SELECTOR_DATA_DISMISS, () => this.hide()); |
| 4955 |
EventHandler.on(this._element, EVENT_MOUSEOVER, event => this._onInteraction(event, true)); |
| 4956 |
EventHandler.on(this._element, EVENT_MOUSEOUT, event => this._onInteraction(event, false)); |
| 4957 |
EventHandler.on(this._element, EVENT_FOCUSIN, event => this._onInteraction(event, true)); |
| 4958 |
EventHandler.on(this._element, EVENT_FOCUSOUT, event => this._onInteraction(event, false)); |
| 4959 |
} |
| 4960 |
|
| 4961 |
_clearTimeout() { |
| 4962 |
clearTimeout(this._timeout); |
| 4963 |
this._timeout = null; |
| 4964 |
} // Static |
| 4965 |
|
| 4966 |
|
| 4967 |
static jQueryInterface(config) { |
| 4968 |
return this.each(function () { |
| 4969 |
const data = Toast.getOrCreateInstance(this, config); |
| 4970 |
|
| 4971 |
if (typeof config === 'string') { |
| 4972 |
if (typeof data[config] === 'undefined') { |
| 4973 |
throw new TypeError(`No method named "${config}"`); |
| 4974 |
} |
| 4975 |
|
| 4976 |
data[config](this); |
| 4977 |
} |
| 4978 |
}); |
| 4979 |
} |
| 4980 |
|
| 4981 |
} |
| 4982 |
/** |
| 4983 |
* ------------------------------------------------------------------------ |
| 4984 |
* jQuery |
| 4985 |
* ------------------------------------------------------------------------ |
| 4986 |
* add .Toast to jQuery only if jQuery is present |
| 4987 |
*/ |
| 4988 |
|
| 4989 |
|
| 4990 |
defineJQueryPlugin(Toast); |
| 4991 |
|
| 4992 |
/** |
| 4993 |
* -------------------------------------------------------------------------- |
| 4994 |
* Bootstrap (v5.0.2): index.umd.js |
| 4995 |
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) |
| 4996 |
* -------------------------------------------------------------------------- |
| 4997 |
*/ |
| 4998 |
var index_umd = { |
| 4999 |
Alert, |
| 5000 |
Button, |
| 5001 |
Carousel, |
| 5002 |
Collapse, |
| 5003 |
Dropdown, |
| 5004 |
Modal, |
| 5005 |
Offcanvas, |
| 5006 |
Popover, |
| 5007 |
ScrollSpy, |
| 5008 |
Tab, |
| 5009 |
Toast, |
| 5010 |
Tooltip |
| 5011 |
}; |
| 5012 |
|
| 5013 |
return index_umd; |
| 5014 |
|
| 5015 |
}))); |
| 5016 |
//# sourceMappingURL=bootstrap.js.map |
| 5017 |
|