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