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