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