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