1 | /*!
|
---|
2 | * Bootstrap index.js v5.3.3 (https://getbootstrap.com/)
|
---|
3 | * Copyright 2011-2024 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' ? factory(exports) :
|
---|
8 | typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
---|
9 | (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Index = {}));
|
---|
10 | })(this, (function (exports) { 'use strict';
|
---|
11 |
|
---|
12 | /**
|
---|
13 | * --------------------------------------------------------------------------
|
---|
14 | * Bootstrap util/index.js
|
---|
15 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
---|
16 | * --------------------------------------------------------------------------
|
---|
17 | */
|
---|
18 |
|
---|
19 | const MAX_UID = 1000000;
|
---|
20 | const MILLISECONDS_MULTIPLIER = 1000;
|
---|
21 | const TRANSITION_END = 'transitionend';
|
---|
22 |
|
---|
23 | /**
|
---|
24 | * Properly escape IDs selectors to handle weird IDs
|
---|
25 | * @param {string} selector
|
---|
26 | * @returns {string}
|
---|
27 | */
|
---|
28 | const parseSelector = selector => {
|
---|
29 | if (selector && window.CSS && window.CSS.escape) {
|
---|
30 | // document.querySelector needs escaping to handle IDs (html5+) containing for instance /
|
---|
31 | selector = selector.replace(/#([^\s"#']+)/g, (match, id) => `#${CSS.escape(id)}`);
|
---|
32 | }
|
---|
33 | return selector;
|
---|
34 | };
|
---|
35 |
|
---|
36 | // Shout-out Angus Croll (https://goo.gl/pxwQGp)
|
---|
37 | const toType = object => {
|
---|
38 | if (object === null || object === undefined) {
|
---|
39 | return `${object}`;
|
---|
40 | }
|
---|
41 | return Object.prototype.toString.call(object).match(/\s([a-z]+)/i)[1].toLowerCase();
|
---|
42 | };
|
---|
43 |
|
---|
44 | /**
|
---|
45 | * Public Util API
|
---|
46 | */
|
---|
47 |
|
---|
48 | const getUID = prefix => {
|
---|
49 | do {
|
---|
50 | prefix += Math.floor(Math.random() * MAX_UID);
|
---|
51 | } while (document.getElementById(prefix));
|
---|
52 | return prefix;
|
---|
53 | };
|
---|
54 | const getTransitionDurationFromElement = element => {
|
---|
55 | if (!element) {
|
---|
56 | return 0;
|
---|
57 | }
|
---|
58 |
|
---|
59 | // Get transition-duration of the element
|
---|
60 | let {
|
---|
61 | transitionDuration,
|
---|
62 | transitionDelay
|
---|
63 | } = window.getComputedStyle(element);
|
---|
64 | const floatTransitionDuration = Number.parseFloat(transitionDuration);
|
---|
65 | const floatTransitionDelay = Number.parseFloat(transitionDelay);
|
---|
66 |
|
---|
67 | // Return 0 if element or transition duration is not found
|
---|
68 | if (!floatTransitionDuration && !floatTransitionDelay) {
|
---|
69 | return 0;
|
---|
70 | }
|
---|
71 |
|
---|
72 | // If multiple durations are defined, take the first
|
---|
73 | transitionDuration = transitionDuration.split(',')[0];
|
---|
74 | transitionDelay = transitionDelay.split(',')[0];
|
---|
75 | return (Number.parseFloat(transitionDuration) + Number.parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
|
---|
76 | };
|
---|
77 | const triggerTransitionEnd = element => {
|
---|
78 | element.dispatchEvent(new Event(TRANSITION_END));
|
---|
79 | };
|
---|
80 | const isElement = object => {
|
---|
81 | if (!object || typeof object !== 'object') {
|
---|
82 | return false;
|
---|
83 | }
|
---|
84 | if (typeof object.jquery !== 'undefined') {
|
---|
85 | object = object[0];
|
---|
86 | }
|
---|
87 | return typeof object.nodeType !== 'undefined';
|
---|
88 | };
|
---|
89 | const getElement = object => {
|
---|
90 | // it's a jQuery object or a node element
|
---|
91 | if (isElement(object)) {
|
---|
92 | return object.jquery ? object[0] : object;
|
---|
93 | }
|
---|
94 | if (typeof object === 'string' && object.length > 0) {
|
---|
95 | return document.querySelector(parseSelector(object));
|
---|
96 | }
|
---|
97 | return null;
|
---|
98 | };
|
---|
99 | const isVisible = element => {
|
---|
100 | if (!isElement(element) || element.getClientRects().length === 0) {
|
---|
101 | return false;
|
---|
102 | }
|
---|
103 | const elementIsVisible = getComputedStyle(element).getPropertyValue('visibility') === 'visible';
|
---|
104 | // Handle `details` element as its content may falsie appear visible when it is closed
|
---|
105 | const closedDetails = element.closest('details:not([open])');
|
---|
106 | if (!closedDetails) {
|
---|
107 | return elementIsVisible;
|
---|
108 | }
|
---|
109 | if (closedDetails !== element) {
|
---|
110 | const summary = element.closest('summary');
|
---|
111 | if (summary && summary.parentNode !== closedDetails) {
|
---|
112 | return false;
|
---|
113 | }
|
---|
114 | if (summary === null) {
|
---|
115 | return false;
|
---|
116 | }
|
---|
117 | }
|
---|
118 | return elementIsVisible;
|
---|
119 | };
|
---|
120 | const isDisabled = element => {
|
---|
121 | if (!element || element.nodeType !== Node.ELEMENT_NODE) {
|
---|
122 | return true;
|
---|
123 | }
|
---|
124 | if (element.classList.contains('disabled')) {
|
---|
125 | return true;
|
---|
126 | }
|
---|
127 | if (typeof element.disabled !== 'undefined') {
|
---|
128 | return element.disabled;
|
---|
129 | }
|
---|
130 | return element.hasAttribute('disabled') && element.getAttribute('disabled') !== 'false';
|
---|
131 | };
|
---|
132 | const findShadowRoot = element => {
|
---|
133 | if (!document.documentElement.attachShadow) {
|
---|
134 | return null;
|
---|
135 | }
|
---|
136 |
|
---|
137 | // Can find the shadow root otherwise it'll return the document
|
---|
138 | if (typeof element.getRootNode === 'function') {
|
---|
139 | const root = element.getRootNode();
|
---|
140 | return root instanceof ShadowRoot ? root : null;
|
---|
141 | }
|
---|
142 | if (element instanceof ShadowRoot) {
|
---|
143 | return element;
|
---|
144 | }
|
---|
145 |
|
---|
146 | // when we don't find a shadow root
|
---|
147 | if (!element.parentNode) {
|
---|
148 | return null;
|
---|
149 | }
|
---|
150 | return findShadowRoot(element.parentNode);
|
---|
151 | };
|
---|
152 | const noop = () => {};
|
---|
153 |
|
---|
154 | /**
|
---|
155 | * Trick to restart an element's animation
|
---|
156 | *
|
---|
157 | * @param {HTMLElement} element
|
---|
158 | * @return void
|
---|
159 | *
|
---|
160 | * @see https://www.charistheo.io/blog/2021/02/restart-a-css-animation-with-javascript/#restarting-a-css-animation
|
---|
161 | */
|
---|
162 | const reflow = element => {
|
---|
163 | element.offsetHeight; // eslint-disable-line no-unused-expressions
|
---|
164 | };
|
---|
165 | const getjQuery = () => {
|
---|
166 | if (window.jQuery && !document.body.hasAttribute('data-bs-no-jquery')) {
|
---|
167 | return window.jQuery;
|
---|
168 | }
|
---|
169 | return null;
|
---|
170 | };
|
---|
171 | const DOMContentLoadedCallbacks = [];
|
---|
172 | const onDOMContentLoaded = callback => {
|
---|
173 | if (document.readyState === 'loading') {
|
---|
174 | // add listener on the first call when the document is in loading state
|
---|
175 | if (!DOMContentLoadedCallbacks.length) {
|
---|
176 | document.addEventListener('DOMContentLoaded', () => {
|
---|
177 | for (const callback of DOMContentLoadedCallbacks) {
|
---|
178 | callback();
|
---|
179 | }
|
---|
180 | });
|
---|
181 | }
|
---|
182 | DOMContentLoadedCallbacks.push(callback);
|
---|
183 | } else {
|
---|
184 | callback();
|
---|
185 | }
|
---|
186 | };
|
---|
187 | const isRTL = () => document.documentElement.dir === 'rtl';
|
---|
188 | const defineJQueryPlugin = plugin => {
|
---|
189 | onDOMContentLoaded(() => {
|
---|
190 | const $ = getjQuery();
|
---|
191 | /* istanbul ignore if */
|
---|
192 | if ($) {
|
---|
193 | const name = plugin.NAME;
|
---|
194 | const JQUERY_NO_CONFLICT = $.fn[name];
|
---|
195 | $.fn[name] = plugin.jQueryInterface;
|
---|
196 | $.fn[name].Constructor = plugin;
|
---|
197 | $.fn[name].noConflict = () => {
|
---|
198 | $.fn[name] = JQUERY_NO_CONFLICT;
|
---|
199 | return plugin.jQueryInterface;
|
---|
200 | };
|
---|
201 | }
|
---|
202 | });
|
---|
203 | };
|
---|
204 | const execute = (possibleCallback, args = [], defaultValue = possibleCallback) => {
|
---|
205 | return typeof possibleCallback === 'function' ? possibleCallback(...args) : defaultValue;
|
---|
206 | };
|
---|
207 | const executeAfterTransition = (callback, transitionElement, waitForTransition = true) => {
|
---|
208 | if (!waitForTransition) {
|
---|
209 | execute(callback);
|
---|
210 | return;
|
---|
211 | }
|
---|
212 | const durationPadding = 5;
|
---|
213 | const emulatedDuration = getTransitionDurationFromElement(transitionElement) + durationPadding;
|
---|
214 | let called = false;
|
---|
215 | const handler = ({
|
---|
216 | target
|
---|
217 | }) => {
|
---|
218 | if (target !== transitionElement) {
|
---|
219 | return;
|
---|
220 | }
|
---|
221 | called = true;
|
---|
222 | transitionElement.removeEventListener(TRANSITION_END, handler);
|
---|
223 | execute(callback);
|
---|
224 | };
|
---|
225 | transitionElement.addEventListener(TRANSITION_END, handler);
|
---|
226 | setTimeout(() => {
|
---|
227 | if (!called) {
|
---|
228 | triggerTransitionEnd(transitionElement);
|
---|
229 | }
|
---|
230 | }, emulatedDuration);
|
---|
231 | };
|
---|
232 |
|
---|
233 | /**
|
---|
234 | * Return the previous/next element of a list.
|
---|
235 | *
|
---|
236 | * @param {array} list The list of elements
|
---|
237 | * @param activeElement The active element
|
---|
238 | * @param shouldGetNext Choose to get next or previous element
|
---|
239 | * @param isCycleAllowed
|
---|
240 | * @return {Element|elem} The proper element
|
---|
241 | */
|
---|
242 | const getNextActiveElement = (list, activeElement, shouldGetNext, isCycleAllowed) => {
|
---|
243 | const listLength = list.length;
|
---|
244 | let index = list.indexOf(activeElement);
|
---|
245 |
|
---|
246 | // if the element does not exist in the list return an element
|
---|
247 | // depending on the direction and if cycle is allowed
|
---|
248 | if (index === -1) {
|
---|
249 | return !shouldGetNext && isCycleAllowed ? list[listLength - 1] : list[0];
|
---|
250 | }
|
---|
251 | index += shouldGetNext ? 1 : -1;
|
---|
252 | if (isCycleAllowed) {
|
---|
253 | index = (index + listLength) % listLength;
|
---|
254 | }
|
---|
255 | return list[Math.max(0, Math.min(index, listLength - 1))];
|
---|
256 | };
|
---|
257 |
|
---|
258 | exports.defineJQueryPlugin = defineJQueryPlugin;
|
---|
259 | exports.execute = execute;
|
---|
260 | exports.executeAfterTransition = executeAfterTransition;
|
---|
261 | exports.findShadowRoot = findShadowRoot;
|
---|
262 | exports.getElement = getElement;
|
---|
263 | exports.getNextActiveElement = getNextActiveElement;
|
---|
264 | exports.getTransitionDurationFromElement = getTransitionDurationFromElement;
|
---|
265 | exports.getUID = getUID;
|
---|
266 | exports.getjQuery = getjQuery;
|
---|
267 | exports.isDisabled = isDisabled;
|
---|
268 | exports.isElement = isElement;
|
---|
269 | exports.isRTL = isRTL;
|
---|
270 | exports.isVisible = isVisible;
|
---|
271 | exports.noop = noop;
|
---|
272 | exports.onDOMContentLoaded = onDOMContentLoaded;
|
---|
273 | exports.parseSelector = parseSelector;
|
---|
274 | exports.reflow = reflow;
|
---|
275 | exports.toType = toType;
|
---|
276 | exports.triggerTransitionEnd = triggerTransitionEnd;
|
---|
277 |
|
---|
278 | Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
---|
279 |
|
---|
280 | }));
|
---|
281 | //# sourceMappingURL=index.js.map
|
---|