bootstrap.esm.js 143 KB
Newer Older
XhmikosR's avatar
Dist.  
XhmikosR committed
1
/*!
2
  * Bootstrap v5.0.0-alpha1 (https://getbootstrap.com/)
XhmikosR's avatar
XhmikosR committed
3
  * Copyright 2011-2020 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
XhmikosR's avatar
Dist.  
XhmikosR committed
4
5
6
7
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
  */
import Popper from 'popper.js';

XhmikosR's avatar
XhmikosR committed
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
function _defineProperties(target, props) {
  for (var i = 0; i < props.length; i++) {
    var descriptor = props[i];
    descriptor.enumerable = descriptor.enumerable || false;
    descriptor.configurable = true;
    if ("value" in descriptor) descriptor.writable = true;
    Object.defineProperty(target, descriptor.key, descriptor);
  }
}

function _createClass(Constructor, protoProps, staticProps) {
  if (protoProps) _defineProperties(Constructor.prototype, protoProps);
  if (staticProps) _defineProperties(Constructor, staticProps);
  return Constructor;
}

function _defineProperty(obj, key, value) {
  if (key in obj) {
    Object.defineProperty(obj, key, {
      value: value,
      enumerable: true,
      configurable: true,
      writable: true
    });
  } else {
    obj[key] = value;
  }

  return obj;
}

39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
function ownKeys(object, enumerableOnly) {
  var keys = Object.keys(object);

  if (Object.getOwnPropertySymbols) {
    var symbols = Object.getOwnPropertySymbols(object);
    if (enumerableOnly) symbols = symbols.filter(function (sym) {
      return Object.getOwnPropertyDescriptor(object, sym).enumerable;
    });
    keys.push.apply(keys, symbols);
  }

  return keys;
}

function _objectSpread2(target) {
XhmikosR's avatar
XhmikosR committed
54
55
56
  for (var i = 1; i < arguments.length; i++) {
    var source = arguments[i] != null ? arguments[i] : {};

57
    if (i % 2) {
XhmikosR's avatar
XhmikosR committed
58
      ownKeys(Object(source), true).forEach(function (key) {
59
60
61
62
63
        _defineProperty(target, key, source[key]);
      });
    } else if (Object.getOwnPropertyDescriptors) {
      Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
    } else {
XhmikosR's avatar
XhmikosR committed
64
      ownKeys(Object(source)).forEach(function (key) {
65
66
        Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
      });
XhmikosR's avatar
XhmikosR committed
67
68
69
70
71
72
73
74
75
76
77
78
    }
  }

  return target;
}

function _inheritsLoose(subClass, superClass) {
  subClass.prototype = Object.create(superClass.prototype);
  subClass.prototype.constructor = subClass;
  subClass.__proto__ = superClass;
}

XhmikosR's avatar
Dist.  
XhmikosR committed
79
80
/**
 * --------------------------------------------------------------------------
81
 * Bootstrap (v5.0.0-alpha1): util/index.js
XhmikosR's avatar
Dist.  
XhmikosR committed
82
83
84
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 * --------------------------------------------------------------------------
 */
XhmikosR's avatar
XhmikosR committed
85
86
var MAX_UID = 1000000;
var MILLISECONDS_MULTIPLIER = 1000;
XhmikosR's avatar
XhmikosR committed
87
var TRANSITION_END = 'transitionend'; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
XhmikosR's avatar
XhmikosR committed
88
89

var toType = function toType(obj) {
XhmikosR's avatar
XhmikosR committed
90
91
92
93
  if (obj === null || obj === undefined) {
    return "" + obj;
  }

XhmikosR's avatar
XhmikosR committed
94
95
  return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
};
XhmikosR's avatar
Dist.  
XhmikosR committed
96
97
98
99
100
101
102
/**
 * --------------------------------------------------------------------------
 * Public Util Api
 * --------------------------------------------------------------------------
 */


XhmikosR's avatar
XhmikosR committed
103
var getUID = function getUID(prefix) {
XhmikosR's avatar
Dist.  
XhmikosR committed
104
  do {
Mark Otto's avatar
Mark Otto committed
105
    prefix += Math.floor(Math.random() * MAX_UID);
XhmikosR's avatar
Dist.  
XhmikosR committed
106
107
108
109
110
  } while (document.getElementById(prefix));

  return prefix;
};

XhmikosR's avatar
XhmikosR committed
111
var getSelector = function getSelector(element) {
XhmikosR's avatar
XhmikosR committed
112
  var selector = element.getAttribute('data-target');
XhmikosR's avatar
Dist.  
XhmikosR committed
113
114

  if (!selector || selector === '#') {
XhmikosR's avatar
XhmikosR committed
115
    var hrefAttr = element.getAttribute('href');
XhmikosR's avatar
XhmikosR committed
116
    selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : null;
XhmikosR's avatar
Dist.  
XhmikosR committed
117
118
  }

XhmikosR's avatar
XhmikosR committed
119
120
121
122
123
124
125
  return selector;
};

var getSelectorFromElement = function getSelectorFromElement(element) {
  var selector = getSelector(element);

  if (selector) {
XhmikosR's avatar
Dist.  
XhmikosR committed
126
127
    return document.querySelector(selector) ? selector : null;
  }
XhmikosR's avatar
XhmikosR committed
128
129
130
131
132
133
134

  return null;
};

var getElementFromSelector = function getElementFromSelector(element) {
  var selector = getSelector(element);
  return selector ? document.querySelector(selector) : null;
XhmikosR's avatar
Dist.  
XhmikosR committed
135
136
};

XhmikosR's avatar
XhmikosR committed
137
var getTransitionDurationFromElement = function getTransitionDurationFromElement(element) {
XhmikosR's avatar
Dist.  
XhmikosR committed
138
139
140
141
142
  if (!element) {
    return 0;
  } // Get transition-duration of the element


XhmikosR's avatar
XhmikosR committed
143
  var _window$getComputedSt = window.getComputedStyle(element),
XhmikosR's avatar
Dist.  
XhmikosR committed
144
145
146
      transitionDuration = _window$getComputedSt.transitionDuration,
      transitionDelay = _window$getComputedSt.transitionDelay;

XhmikosR's avatar
XhmikosR committed
147
148
  var floatTransitionDuration = parseFloat(transitionDuration);
  var floatTransitionDelay = parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
XhmikosR's avatar
Dist.  
XhmikosR committed
149
150
151
152
153
154
155
156
157
158
159

  if (!floatTransitionDuration && !floatTransitionDelay) {
    return 0;
  } // If multiple durations are defined, take the first


  transitionDuration = transitionDuration.split(',')[0];
  transitionDelay = transitionDelay.split(',')[0];
  return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
};

XhmikosR's avatar
XhmikosR committed
160
var triggerTransitionEnd = function triggerTransitionEnd(element) {
XhmikosR's avatar
XhmikosR committed
161
  element.dispatchEvent(new Event(TRANSITION_END));
XhmikosR's avatar
Dist.  
XhmikosR committed
162
163
};

XhmikosR's avatar
XhmikosR committed
164
165
166
var isElement = function isElement(obj) {
  return (obj[0] || obj).nodeType;
};
XhmikosR's avatar
Dist.  
XhmikosR committed
167

XhmikosR's avatar
XhmikosR committed
168
169
170
171
var emulateTransitionEnd = function emulateTransitionEnd(element, duration) {
  var called = false;
  var durationPadding = 5;
  var emulatedDuration = duration + durationPadding;
XhmikosR's avatar
Dist.  
XhmikosR committed
172
173
174
175
176
177
178

  function listener() {
    called = true;
    element.removeEventListener(TRANSITION_END, listener);
  }

  element.addEventListener(TRANSITION_END, listener);
XhmikosR's avatar
XhmikosR committed
179
  setTimeout(function () {
XhmikosR's avatar
Dist.  
XhmikosR committed
180
181
182
183
184
185
    if (!called) {
      triggerTransitionEnd(element);
    }
  }, emulatedDuration);
};

XhmikosR's avatar
XhmikosR committed
186
187
188
189
190
var typeCheckConfig = function typeCheckConfig(componentName, config, configTypes) {
  Object.keys(configTypes).forEach(function (property) {
    var expectedTypes = configTypes[property];
    var value = config[property];
    var valueType = value && isElement(value) ? 'element' : toType(value);
XhmikosR's avatar
Dist.  
XhmikosR committed
191
192

    if (!new RegExp(expectedTypes).test(valueType)) {
XhmikosR's avatar
XhmikosR committed
193
      throw new Error(componentName.toUpperCase() + ": " + ("Option \"" + property + "\" provided type \"" + valueType + "\" ") + ("but expected type \"" + expectedTypes + "\"."));
XhmikosR's avatar
Dist.  
XhmikosR committed
194
195
196
197
    }
  });
};

XhmikosR's avatar
XhmikosR committed
198
var isVisible = function isVisible(element) {
XhmikosR's avatar
Dist.  
XhmikosR committed
199
200
201
202
203
  if (!element) {
    return false;
  }

  if (element.style && element.parentNode && element.parentNode.style) {
XhmikosR's avatar
XhmikosR committed
204
205
206
    var elementStyle = getComputedStyle(element);
    var parentNodeStyle = getComputedStyle(element.parentNode);
    return elementStyle.display !== 'none' && parentNodeStyle.display !== 'none' && elementStyle.visibility !== 'hidden';
XhmikosR's avatar
Dist.  
XhmikosR committed
207
208
209
210
211
  }

  return false;
};

XhmikosR's avatar
XhmikosR committed
212
var findShadowRoot = function findShadowRoot(element) {
XhmikosR's avatar
Dist.  
XhmikosR committed
213
214
215
216
217
218
  if (!document.documentElement.attachShadow) {
    return null;
  } // Can find the shadow root otherwise it'll return the document


  if (typeof element.getRootNode === 'function') {
XhmikosR's avatar
XhmikosR committed
219
    var root = element.getRootNode();
XhmikosR's avatar
Dist.  
XhmikosR committed
220
221
222
223
224
225
226
227
228
229
230
231
232
    return root instanceof ShadowRoot ? root : null;
  }

  if (element instanceof ShadowRoot) {
    return element;
  } // when we don't find a shadow root


  if (!element.parentNode) {
    return null;
  }

  return findShadowRoot(element.parentNode);
XhmikosR's avatar
XhmikosR committed
233
};
XhmikosR's avatar
Dist.  
XhmikosR committed
234

XhmikosR's avatar
XhmikosR committed
235
236
237
var noop = function noop() {
  return function () {};
};
XhmikosR's avatar
Dist.  
XhmikosR committed
238

XhmikosR's avatar
XhmikosR committed
239
240
241
var reflow = function reflow(element) {
  return element.offsetHeight;
};
XhmikosR's avatar
Dist.  
XhmikosR committed
242

XhmikosR's avatar
XhmikosR committed
243
244
245
246
247
248
249
250
251
252
253
var getjQuery = function getjQuery() {
  var _window = window,
      jQuery = _window.jQuery;

  if (jQuery && !document.body.hasAttribute('data-no-jquery')) {
    return jQuery;
  }

  return null;
};

XhmikosR's avatar
Dist.  
XhmikosR committed
254
255
/**
 * --------------------------------------------------------------------------
256
 * Bootstrap (v5.0.0-alpha1): dom/data.js
XhmikosR's avatar
Dist.  
XhmikosR committed
257
258
259
260
261
262
263
264
265
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 * --------------------------------------------------------------------------
 */

/**
 * ------------------------------------------------------------------------
 * Constants
 * ------------------------------------------------------------------------
 */
XhmikosR's avatar
XhmikosR committed
266
267
268
var mapData = function () {
  var storeData = {};
  var id = 1;
XhmikosR's avatar
Dist.  
XhmikosR committed
269
  return {
XhmikosR's avatar
XhmikosR committed
270
    set: function set(element, key, data) {
XhmikosR's avatar
Dist.  
XhmikosR committed
271
272
      if (typeof element.key === 'undefined') {
        element.key = {
XhmikosR's avatar
XhmikosR committed
273
274
          key: key,
          id: id
XhmikosR's avatar
Dist.  
XhmikosR committed
275
276
277
278
279
280
        };
        id++;
      }

      storeData[element.key.id] = data;
    },
XhmikosR's avatar
XhmikosR committed
281
    get: function get(element, key) {
XhmikosR's avatar
Dist.  
XhmikosR committed
282
283
284
285
      if (!element || typeof element.key === 'undefined') {
        return null;
      }

XhmikosR's avatar
XhmikosR committed
286
      var keyProperties = element.key;
XhmikosR's avatar
Dist.  
XhmikosR committed
287
288
289
290
291
292
293

      if (keyProperties.key === key) {
        return storeData[keyProperties.id];
      }

      return null;
    },
XhmikosR's avatar
XhmikosR committed
294
    delete: function _delete(element, key) {
XhmikosR's avatar
Dist.  
XhmikosR committed
295
296
297
298
      if (typeof element.key === 'undefined') {
        return;
      }

XhmikosR's avatar
XhmikosR committed
299
      var keyProperties = element.key;
XhmikosR's avatar
Dist.  
XhmikosR committed
300
301
302
303
304
305
306

      if (keyProperties.key === key) {
        delete storeData[keyProperties.id];
        delete element.key;
      }
    }
  };
XhmikosR's avatar
XhmikosR committed
307
}();
XhmikosR's avatar
Dist.  
XhmikosR committed
308

XhmikosR's avatar
XhmikosR committed
309
310
var Data = {
  setData: function setData(instance, key, data) {
XhmikosR's avatar
Dist.  
XhmikosR committed
311
312
    mapData.set(instance, key, data);
  },
XhmikosR's avatar
XhmikosR committed
313
  getData: function getData(instance, key) {
XhmikosR's avatar
Dist.  
XhmikosR committed
314
315
    return mapData.get(instance, key);
  },
XhmikosR's avatar
XhmikosR committed
316
  removeData: function removeData(instance, key) {
XhmikosR's avatar
Dist.  
XhmikosR committed
317
318
    mapData.delete(instance, key);
  }
XhmikosR's avatar
XhmikosR committed
319
};
XhmikosR's avatar
Dist.  
XhmikosR committed
320

XhmikosR's avatar
XhmikosR committed
321
322
/* istanbul ignore file */
var find = Element.prototype.querySelectorAll;
XhmikosR's avatar
XhmikosR committed
323
var findOne = Element.prototype.querySelector; // MSEdge resets defaultPrevented flag upon dispatchEvent call if at least one listener is attached
XhmikosR's avatar
Dist.  
XhmikosR committed
324

XhmikosR's avatar
XhmikosR committed
325
var defaultPreventedPreservedOnDispatch = function () {
XhmikosR's avatar
XhmikosR committed
326
  var e = new CustomEvent('Bootstrap', {
XhmikosR's avatar
XhmikosR committed
327
328
329
330
331
332
333
334
335
336
    cancelable: true
  });
  var element = document.createElement('div');
  element.addEventListener('Bootstrap', function () {
    return null;
  });
  e.preventDefault();
  element.dispatchEvent(e);
  return e.defaultPrevented;
}();
XhmikosR's avatar
Dist.  
XhmikosR committed
337

XhmikosR's avatar
XhmikosR committed
338
var scopeSelectorRegex = /:scope\b/;
XhmikosR's avatar
Dist.  
XhmikosR committed
339

XhmikosR's avatar
XhmikosR committed
340
341
var supportScopeQuery = function () {
  var element = document.createElement('div');
XhmikosR's avatar
Dist.  
XhmikosR committed
342

XhmikosR's avatar
XhmikosR committed
343
344
  try {
    element.querySelectorAll(':scope *');
XhmikosR's avatar
XhmikosR committed
345
  } catch (_) {
XhmikosR's avatar
XhmikosR committed
346
347
    return false;
  }
XhmikosR's avatar
Dist.  
XhmikosR committed
348

XhmikosR's avatar
XhmikosR committed
349
350
351
352
353
354
355
356
357
358
  return true;
}();

if (!supportScopeQuery) {
  find = function find(selector) {
    if (!scopeSelectorRegex.test(selector)) {
      return this.querySelectorAll(selector);
    }

    var hasId = Boolean(this.id);
XhmikosR's avatar
Dist.  
XhmikosR committed
359

XhmikosR's avatar
XhmikosR committed
360
361
362
363
364
    if (!hasId) {
      this.id = getUID('scope');
    }

    var nodeList = null;
XhmikosR's avatar
Dist.  
XhmikosR committed
365

XhmikosR's avatar
XhmikosR committed
366
367
368
369
370
371
    try {
      selector = selector.replace(scopeSelectorRegex, "#" + this.id);
      nodeList = this.querySelectorAll(selector);
    } finally {
      if (!hasId) {
        this.removeAttribute('id');
XhmikosR's avatar
Dist.  
XhmikosR committed
372
      }
XhmikosR's avatar
XhmikosR committed
373
    }
XhmikosR's avatar
Dist.  
XhmikosR committed
374

XhmikosR's avatar
XhmikosR committed
375
376
    return nodeList;
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
377

XhmikosR's avatar
XhmikosR committed
378
379
380
381
382
383
384
385
386
387
388
389
  findOne = function findOne(selector) {
    if (!scopeSelectorRegex.test(selector)) {
      return this.querySelector(selector);
    }

    var matches = find.call(this, selector);

    if (typeof matches[0] !== 'undefined') {
      return matches[0];
    }

    return null;
XhmikosR's avatar
Dist.  
XhmikosR committed
390
  };
XhmikosR's avatar
XhmikosR committed
391
}
XhmikosR's avatar
Dist.  
XhmikosR committed
392
393
394

/**
 * --------------------------------------------------------------------------
395
 * Bootstrap (v5.0.0-alpha1): dom/event-handler.js
XhmikosR's avatar
Dist.  
XhmikosR committed
396
397
398
399
400
401
402
403
404
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 * --------------------------------------------------------------------------
 */
/**
 * ------------------------------------------------------------------------
 * Constants
 * ------------------------------------------------------------------------
 */

XhmikosR's avatar
XhmikosR committed
405
var $ = getjQuery();
XhmikosR's avatar
XhmikosR committed
406
407
408
409
var namespaceRegex = /[^.]*(?=\..*)\.|.*/;
var stripNameRegex = /\..*/;
var stripUidRegex = /::\d+$/;
var eventRegistry = {}; // Events storage
XhmikosR's avatar
Dist.  
XhmikosR committed
410

XhmikosR's avatar
XhmikosR committed
411
412
var uidEvent = 1;
var customEvents = {
XhmikosR's avatar
Dist.  
XhmikosR committed
413
414
415
  mouseenter: 'mouseover',
  mouseleave: 'mouseout'
};
XhmikosR's avatar
XhmikosR committed
416
var nativeEvents = ['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'];
XhmikosR's avatar
Dist.  
XhmikosR committed
417
418
419
420
421
422
423
/**
 * ------------------------------------------------------------------------
 * Private methods
 * ------------------------------------------------------------------------
 */

function getUidEvent(element, uid) {
XhmikosR's avatar
XhmikosR committed
424
  return uid && uid + "::" + uidEvent++ || element.uidEvent || uidEvent++;
XhmikosR's avatar
Dist.  
XhmikosR committed
425
426
427
}

function getEvent(element) {
XhmikosR's avatar
XhmikosR committed
428
  var uid = getUidEvent(element);
XhmikosR's avatar
Dist.  
XhmikosR committed
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
  element.uidEvent = uid;
  eventRegistry[uid] = eventRegistry[uid] || {};
  return eventRegistry[uid];
}

function bootstrapHandler(element, fn) {
  return function handler(event) {
    if (handler.oneOff) {
      EventHandler.off(element, event.type, fn);
    }

    return fn.apply(element, [event]);
  };
}

function bootstrapDelegationHandler(element, selector, fn) {
  return function handler(event) {
XhmikosR's avatar
XhmikosR committed
446
    var domElements = element.querySelectorAll(selector);
XhmikosR's avatar
Dist.  
XhmikosR committed
447

XhmikosR's avatar
XhmikosR committed
448
449
    for (var target = event.target; target && target !== this; target = target.parentNode) {
      for (var i = domElements.length; i--;) {
XhmikosR's avatar
Dist.  
XhmikosR committed
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
        if (domElements[i] === target) {
          if (handler.oneOff) {
            EventHandler.off(element, event.type, fn);
          }

          return fn.apply(target, [event]);
        }
      }
    } // To please ESLint


    return null;
  };
}

function findHandler(events, handler, delegationSelector) {
  if (delegationSelector === void 0) {
    delegationSelector = null;
  }

Mark Otto's avatar
dist v5    
Mark Otto committed
470
471
472
473
  var uidEventList = Object.keys(events);

  for (var i = 0, len = uidEventList.length; i < len; i++) {
    var event = events[uidEventList[i]];
XhmikosR's avatar
Dist.  
XhmikosR committed
474
475

    if (event.originalHandler === handler && event.delegationSelector === delegationSelector) {
Mark Otto's avatar
dist v5    
Mark Otto committed
476
      return event;
XhmikosR's avatar
Dist.  
XhmikosR committed
477
478
479
480
481
482
483
    }
  }

  return null;
}

function normalizeParams(originalTypeEvent, handler, delegationFn) {
XhmikosR's avatar
XhmikosR committed
484
485
  var delegation = typeof handler === 'string';
  var originalHandler = delegation ? delegationFn : handler; // allow to get the native events from namespaced events ('click.bs.button' --> 'click')
XhmikosR's avatar
Dist.  
XhmikosR committed
486

XhmikosR's avatar
XhmikosR committed
487
488
  var typeEvent = originalTypeEvent.replace(stripNameRegex, '');
  var custom = customEvents[typeEvent];
XhmikosR's avatar
Dist.  
XhmikosR committed
489
490
491
492
493

  if (custom) {
    typeEvent = custom;
  }

XhmikosR's avatar
XhmikosR committed
494
  var isNative = nativeEvents.indexOf(typeEvent) > -1;
XhmikosR's avatar
Dist.  
XhmikosR committed
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512

  if (!isNative) {
    typeEvent = originalTypeEvent;
  }

  return [delegation, originalHandler, typeEvent];
}

function addHandler(element, originalTypeEvent, handler, delegationFn, oneOff) {
  if (typeof originalTypeEvent !== 'string' || !element) {
    return;
  }

  if (!handler) {
    handler = delegationFn;
    delegationFn = null;
  }

XhmikosR's avatar
XhmikosR committed
513
514
515
516
  var _normalizeParams = normalizeParams(originalTypeEvent, handler, delegationFn),
      delegation = _normalizeParams[0],
      originalHandler = _normalizeParams[1],
      typeEvent = _normalizeParams[2];
XhmikosR's avatar
Dist.  
XhmikosR committed
517

XhmikosR's avatar
XhmikosR committed
518
519
520
  var events = getEvent(element);
  var handlers = events[typeEvent] || (events[typeEvent] = {});
  var previousFn = findHandler(handlers, originalHandler, delegation ? handler : null);
XhmikosR's avatar
Dist.  
XhmikosR committed
521
522
523
524
525
526

  if (previousFn) {
    previousFn.oneOff = previousFn.oneOff && oneOff;
    return;
  }

XhmikosR's avatar
XhmikosR committed
527
528
  var uid = getUidEvent(originalHandler, originalTypeEvent.replace(namespaceRegex, ''));
  var fn = delegation ? bootstrapDelegationHandler(element, handler, delegationFn) : bootstrapHandler(element, handler);
XhmikosR's avatar
Dist.  
XhmikosR committed
529
530
531
532
533
534
535
536
537
  fn.delegationSelector = delegation ? handler : null;
  fn.originalHandler = originalHandler;
  fn.oneOff = oneOff;
  fn.uidEvent = uid;
  handlers[uid] = fn;
  element.addEventListener(typeEvent, fn, delegation);
}

function removeHandler(element, events, typeEvent, handler, delegationSelector) {
XhmikosR's avatar
XhmikosR committed
538
  var fn = findHandler(events[typeEvent], handler, delegationSelector);
XhmikosR's avatar
Dist.  
XhmikosR committed
539

Mark Otto's avatar
dist v5    
Mark Otto committed
540
  if (!fn) {
XhmikosR's avatar
Dist.  
XhmikosR committed
541
542
543
544
545
546
547
548
    return;
  }

  element.removeEventListener(typeEvent, fn, Boolean(delegationSelector));
  delete events[typeEvent][fn.uidEvent];
}

function removeNamespacedHandlers(element, events, typeEvent, namespace) {
XhmikosR's avatar
XhmikosR committed
549
550
  var storeElementEvent = events[typeEvent] || {};
  Object.keys(storeElementEvent).forEach(function (handlerKey) {
XhmikosR's avatar
Dist.  
XhmikosR committed
551
    if (handlerKey.indexOf(namespace) > -1) {
XhmikosR's avatar
XhmikosR committed
552
      var event = storeElementEvent[handlerKey];
XhmikosR's avatar
Dist.  
XhmikosR committed
553
554
555
556
557
      removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector);
    }
  });
}

XhmikosR's avatar
XhmikosR committed
558
559
var EventHandler = {
  on: function on(element, event, handler, delegationFn) {
XhmikosR's avatar
Dist.  
XhmikosR committed
560
561
    addHandler(element, event, handler, delegationFn, false);
  },
XhmikosR's avatar
XhmikosR committed
562
  one: function one(element, event, handler, delegationFn) {
XhmikosR's avatar
Dist.  
XhmikosR committed
563
564
    addHandler(element, event, handler, delegationFn, true);
  },
XhmikosR's avatar
XhmikosR committed
565
  off: function off(element, originalTypeEvent, handler, delegationFn) {
XhmikosR's avatar
Dist.  
XhmikosR committed
566
567
568
569
    if (typeof originalTypeEvent !== 'string' || !element) {
      return;
    }

XhmikosR's avatar
XhmikosR committed
570
571
572
573
    var _normalizeParams2 = normalizeParams(originalTypeEvent, handler, delegationFn),
        delegation = _normalizeParams2[0],
        originalHandler = _normalizeParams2[1],
        typeEvent = _normalizeParams2[2];
XhmikosR's avatar
Dist.  
XhmikosR committed
574

XhmikosR's avatar
XhmikosR committed
575
576
577
    var inNamespace = typeEvent !== originalTypeEvent;
    var events = getEvent(element);
    var isNamespace = originalTypeEvent.charAt(0) === '.';
XhmikosR's avatar
Dist.  
XhmikosR committed
578
579
580
581
582
583
584
585
586
587
588
589

    if (typeof originalHandler !== 'undefined') {
      // Simplest case: handler is passed, remove that listener ONLY.
      if (!events || !events[typeEvent]) {
        return;
      }

      removeHandler(element, events, typeEvent, originalHandler, delegation ? handler : null);
      return;
    }

    if (isNamespace) {
XhmikosR's avatar
XhmikosR committed
590
      Object.keys(events).forEach(function (elementEvent) {
XhmikosR's avatar
XhmikosR committed
591
        removeNamespacedHandlers(element, events, elementEvent, originalTypeEvent.slice(1));
XhmikosR's avatar
Dist.  
XhmikosR committed
592
593
594
      });
    }

XhmikosR's avatar
XhmikosR committed
595
596
597
    var storeElementEvent = events[typeEvent] || {};
    Object.keys(storeElementEvent).forEach(function (keyHandlers) {
      var handlerKey = keyHandlers.replace(stripUidRegex, '');
XhmikosR's avatar
Dist.  
XhmikosR committed
598
599

      if (!inNamespace || originalTypeEvent.indexOf(handlerKey) > -1) {
XhmikosR's avatar
XhmikosR committed
600
        var event = storeElementEvent[keyHandlers];
XhmikosR's avatar
Dist.  
XhmikosR committed
601
602
603
604
        removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector);
      }
    });
  },
XhmikosR's avatar
XhmikosR committed
605
  trigger: function trigger(element, event, args) {
XhmikosR's avatar
Dist.  
XhmikosR committed
606
607
608
609
    if (typeof event !== 'string' || !element) {
      return null;
    }

XhmikosR's avatar
XhmikosR committed
610
611
612
613
614
615
616
617
    var typeEvent = event.replace(stripNameRegex, '');
    var inNamespace = event !== typeEvent;
    var isNative = nativeEvents.indexOf(typeEvent) > -1;
    var jQueryEvent;
    var bubbles = true;
    var nativeDispatch = true;
    var defaultPrevented = false;
    var evt = null;
XhmikosR's avatar
Dist.  
XhmikosR committed
618

XhmikosR's avatar
XhmikosR committed
619
620
621
    if (inNamespace && $) {
      jQueryEvent = $.Event(event, args);
      $(element).trigger(jQueryEvent);
XhmikosR's avatar
Dist.  
XhmikosR committed
622
623
624
625
626
627
628
629
630
      bubbles = !jQueryEvent.isPropagationStopped();
      nativeDispatch = !jQueryEvent.isImmediatePropagationStopped();
      defaultPrevented = jQueryEvent.isDefaultPrevented();
    }

    if (isNative) {
      evt = document.createEvent('HTMLEvents');
      evt.initEvent(typeEvent, bubbles, true);
    } else {
XhmikosR's avatar
XhmikosR committed
631
      evt = new CustomEvent(event, {
XhmikosR's avatar
XhmikosR committed
632
        bubbles: bubbles,
XhmikosR's avatar
Dist.  
XhmikosR committed
633
634
635
636
637
638
        cancelable: true
      });
    } // merge custom informations in our event


    if (typeof args !== 'undefined') {
XhmikosR's avatar
XhmikosR committed
639
      Object.keys(args).forEach(function (key) {
XhmikosR's avatar
Dist.  
XhmikosR committed
640
        Object.defineProperty(evt, key, {
XhmikosR's avatar
XhmikosR committed
641
          get: function get() {
XhmikosR's avatar
Dist.  
XhmikosR committed
642
643
644
645
646
647
648
649
650
            return args[key];
          }
        });
      });
    }

    if (defaultPrevented) {
      evt.preventDefault();

XhmikosR's avatar
XhmikosR committed
651
      if (!defaultPreventedPreservedOnDispatch) {
XhmikosR's avatar
Dist.  
XhmikosR committed
652
        Object.defineProperty(evt, 'defaultPrevented', {
XhmikosR's avatar
XhmikosR committed
653
654
655
          get: function get() {
            return true;
          }
XhmikosR's avatar
Dist.  
XhmikosR committed
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
        });
      }
    }

    if (nativeDispatch) {
      element.dispatchEvent(evt);
    }

    if (evt.defaultPrevented && typeof jQueryEvent !== 'undefined') {
      jQueryEvent.preventDefault();
    }

    return evt;
  }
};

/**
 * ------------------------------------------------------------------------
 * Constants
 * ------------------------------------------------------------------------
 */

XhmikosR's avatar
XhmikosR committed
678
var NAME = 'alert';
679
var VERSION = '5.0.0-alpha1';
XhmikosR's avatar
XhmikosR committed
680
681
682
var DATA_KEY = 'bs.alert';
var EVENT_KEY = "." + DATA_KEY;
var DATA_API_KEY = '.data-api';
XhmikosR's avatar
XhmikosR committed
683
684
685
686
687
688
689
var SELECTOR_DISMISS = '[data-dismiss="alert"]';
var EVENT_CLOSE = "close" + EVENT_KEY;
var EVENT_CLOSED = "closed" + EVENT_KEY;
var EVENT_CLICK_DATA_API = "click" + EVENT_KEY + DATA_API_KEY;
var CLASSNAME_ALERT = 'alert';
var CLASSNAME_FADE = 'fade';
var CLASSNAME_SHOW = 'show';
XhmikosR's avatar
XhmikosR committed
690
691
692
693
694
/**
 * ------------------------------------------------------------------------
 * Class Definition
 * ------------------------------------------------------------------------
 */
XhmikosR's avatar
Dist.  
XhmikosR committed
695

XhmikosR's avatar
XhmikosR committed
696
var Alert = /*#__PURE__*/function () {
XhmikosR's avatar
XhmikosR committed
697
  function Alert(element) {
XhmikosR's avatar
Dist.  
XhmikosR committed
698
699
700
701
702
703
704
705
    this._element = element;

    if (this._element) {
      Data.setData(element, DATA_KEY, this);
    }
  } // Getters


XhmikosR's avatar
XhmikosR committed
706
  var _proto = Alert.prototype;
XhmikosR's avatar
Dist.  
XhmikosR committed
707

XhmikosR's avatar
XhmikosR committed
708
709
710
  // Public
  _proto.close = function close(element) {
    var rootElement = this._element;
XhmikosR's avatar
Dist.  
XhmikosR committed
711
712
713
714
715

    if (element) {
      rootElement = this._getRootElement(element);
    }

XhmikosR's avatar
XhmikosR committed
716
    var customEvent = this._triggerCloseEvent(rootElement);
XhmikosR's avatar
Dist.  
XhmikosR committed
717
718
719
720
721
722

    if (customEvent === null || customEvent.defaultPrevented) {
      return;
    }

    this._removeElement(rootElement);
XhmikosR's avatar
XhmikosR committed
723
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
724

XhmikosR's avatar
XhmikosR committed
725
  _proto.dispose = function dispose() {
XhmikosR's avatar
Dist.  
XhmikosR committed
726
727
728
    Data.removeData(this._element, DATA_KEY);
    this._element = null;
  } // Private
XhmikosR's avatar
XhmikosR committed
729
  ;
XhmikosR's avatar
Dist.  
XhmikosR committed
730

XhmikosR's avatar
XhmikosR committed
731
  _proto._getRootElement = function _getRootElement(element) {
XhmikosR's avatar
XhmikosR committed
732
    return getElementFromSelector(element) || element.closest("." + CLASSNAME_ALERT);
XhmikosR's avatar
XhmikosR committed
733
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
734

XhmikosR's avatar
XhmikosR committed
735
  _proto._triggerCloseEvent = function _triggerCloseEvent(element) {
XhmikosR's avatar
XhmikosR committed
736
    return EventHandler.trigger(element, EVENT_CLOSE);
XhmikosR's avatar
XhmikosR committed
737
738
739
740
  };

  _proto._removeElement = function _removeElement(element) {
    var _this = this;
XhmikosR's avatar
Dist.  
XhmikosR committed
741

XhmikosR's avatar
XhmikosR committed
742
    element.classList.remove(CLASSNAME_SHOW);
XhmikosR's avatar
Dist.  
XhmikosR committed
743

XhmikosR's avatar
XhmikosR committed
744
    if (!element.classList.contains(CLASSNAME_FADE)) {
XhmikosR's avatar
Dist.  
XhmikosR committed
745
746
747
748
749
      this._destroyElement(element);

      return;
    }

XhmikosR's avatar
XhmikosR committed
750
    var transitionDuration = getTransitionDurationFromElement(element);
751
752
    EventHandler.one(element, TRANSITION_END, function () {
      return _this._destroyElement(element);
XhmikosR's avatar
XhmikosR committed
753
    });
XhmikosR's avatar
Dist.  
XhmikosR committed
754
    emulateTransitionEnd(element, transitionDuration);
XhmikosR's avatar
XhmikosR committed
755
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
756

XhmikosR's avatar
XhmikosR committed
757
  _proto._destroyElement = function _destroyElement(element) {
XhmikosR's avatar
Dist.  
XhmikosR committed
758
759
760
761
    if (element.parentNode) {
      element.parentNode.removeChild(element);
    }

XhmikosR's avatar
XhmikosR committed
762
    EventHandler.trigger(element, EVENT_CLOSED);
XhmikosR's avatar
Dist.  
XhmikosR committed
763
  } // Static
XhmikosR's avatar
XhmikosR committed
764
  ;
XhmikosR's avatar
Dist.  
XhmikosR committed
765

XhmikosR's avatar
XhmikosR committed
766
  Alert.jQueryInterface = function jQueryInterface(config) {
XhmikosR's avatar
Dist.  
XhmikosR committed
767
    return this.each(function () {
XhmikosR's avatar
XhmikosR committed
768
      var data = Data.getData(this, DATA_KEY);
XhmikosR's avatar
Dist.  
XhmikosR committed
769
770
771
772
773
774
775
776
777

      if (!data) {
        data = new Alert(this);
      }

      if (config === 'close') {
        data[config](this);
      }
    });
XhmikosR's avatar
XhmikosR committed
778
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
779

XhmikosR's avatar
XhmikosR committed
780
  Alert.handleDismiss = function handleDismiss(alertInstance) {
XhmikosR's avatar
Dist.  
XhmikosR committed
781
782
783
784
785
786
787
    return function (event) {
      if (event) {
        event.preventDefault();
      }

      alertInstance.close(this);
    };
XhmikosR's avatar
XhmikosR committed
788
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
789

XhmikosR's avatar
XhmikosR committed
790
  Alert.getInstance = function getInstance(element) {
XhmikosR's avatar
Dist.  
XhmikosR committed
791
    return Data.getData(element, DATA_KEY);
XhmikosR's avatar
XhmikosR committed
792
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
793

XhmikosR's avatar
XhmikosR committed
794
795
796
797
798
799
800
801
802
  _createClass(Alert, null, [{
    key: "VERSION",
    get: function get() {
      return VERSION;
    }
  }]);

  return Alert;
}();
XhmikosR's avatar
Dist.  
XhmikosR committed
803
804
805
806
807
808
809
/**
 * ------------------------------------------------------------------------
 * Data Api implementation
 * ------------------------------------------------------------------------
 */


XhmikosR's avatar
XhmikosR committed
810
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DISMISS, Alert.handleDismiss(new Alert()));
XhmikosR's avatar
XhmikosR committed
811
var $$1 = getjQuery();
XhmikosR's avatar
Dist.  
XhmikosR committed
812
813
814
815
816
817
818
/**
 * ------------------------------------------------------------------------
 * jQuery
 * ------------------------------------------------------------------------
 * add .alert to jQuery only if jQuery is present
 */

819
820
/* istanbul ignore if */

XhmikosR's avatar
XhmikosR committed
821
822
823
824
if ($$1) {
  var JQUERY_NO_CONFLICT = $$1.fn[NAME];
  $$1.fn[NAME] = Alert.jQueryInterface;
  $$1.fn[NAME].Constructor = Alert;
XhmikosR's avatar
Dist.  
XhmikosR committed
825

XhmikosR's avatar
XhmikosR committed
826
827
828
  $$1.fn[NAME].noConflict = function () {
    $$1.fn[NAME] = JQUERY_NO_CONFLICT;
    return Alert.jQueryInterface;
XhmikosR's avatar
Dist.  
XhmikosR committed
829
830
831
  };
}

XhmikosR's avatar
XhmikosR committed
832
833
/**
 * --------------------------------------------------------------------------
834
 * Bootstrap (v5.0.0-alpha1): dom/selector-engine.js
XhmikosR's avatar
XhmikosR committed
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
 * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
 * --------------------------------------------------------------------------
 */
/**
 * ------------------------------------------------------------------------
 * Constants
 * ------------------------------------------------------------------------
 */

var NODE_TEXT = 3;
var SelectorEngine = {
  matches: function matches(element, selector) {
    return element.matches(selector);
  },
  find: function find$1(selector, element) {
    var _ref;

    if (element === void 0) {
      element = document.documentElement;
    }

    return (_ref = []).concat.apply(_ref, find.call(element, selector));
  },
  findOne: function findOne$1(selector, element) {
    if (element === void 0) {
      element = document.documentElement;
    }

    return findOne.call(element, selector);
  },
  children: function children(element, selector) {
    var _ref2;

    var children = (_ref2 = []).concat.apply(_ref2, element.children);

    return children.filter(function (child) {
      return child.matches(selector);
    });
  },
  parents: function parents(element, selector) {
    var parents = [];
    var ancestor = element.parentNode;

    while (ancestor && ancestor.nodeType === Node.ELEMENT_NODE && ancestor.nodeType !== NODE_TEXT) {
      if (this.matches(ancestor, selector)) {
        parents.push(ancestor);
      }

      ancestor = ancestor.parentNode;
    }

    return parents;
  },
  prev: function prev(element, selector) {
    var previous = element.previousElementSibling;

    while (previous) {
      if (previous.matches(selector)) {
        return [previous];
      }

      previous = previous.previousElementSibling;
    }

    return [];
  },
  next: function next(element, selector) {
    var next = element.nextElementSibling;

    while (next) {
      if (this.matches(next, selector)) {
        return [next];
      }

      next = next.nextElementSibling;
    }

    return [];
  }
};

XhmikosR's avatar
Dist.  
XhmikosR committed
916
917
918
919
920
921
/**
 * ------------------------------------------------------------------------
 * Constants
 * ------------------------------------------------------------------------
 */

XhmikosR's avatar
XhmikosR committed
922
var NAME$1 = 'button';
923
var VERSION$1 = '5.0.0-alpha1';
XhmikosR's avatar
XhmikosR committed
924
925
926
var DATA_KEY$1 = 'bs.button';
var EVENT_KEY$1 = "." + DATA_KEY$1;
var DATA_API_KEY$1 = '.data-api';
XhmikosR's avatar
XhmikosR committed
927
928
929
930
931
932
933
934
935
936
937
var CLASS_NAME_ACTIVE = 'active';
var CLASS_NAME_DISABLED = 'disabled';
var CLASS_NAME_FOCUS = 'focus';
var SELECTOR_DATA_TOGGLE_CARROT = '[data-toggle^="button"]';
var SELECTOR_DATA_TOGGLE = '[data-toggle="buttons"]';
var SELECTOR_INPUT = 'input:not([type="hidden"])';
var SELECTOR_ACTIVE = '.active';
var SELECTOR_BUTTON = '.btn';
var EVENT_CLICK_DATA_API$1 = "click" + EVENT_KEY$1 + DATA_API_KEY$1;
var EVENT_FOCUS_DATA_API = "focus" + EVENT_KEY$1 + DATA_API_KEY$1;
var EVENT_BLUR_DATA_API = "blur" + EVENT_KEY$1 + DATA_API_KEY$1;
XhmikosR's avatar
XhmikosR committed
938
939
940
941
942
/**
 * ------------------------------------------------------------------------
 * Class Definition
 * ------------------------------------------------------------------------
 */
XhmikosR's avatar
Dist.  
XhmikosR committed
943

XhmikosR's avatar
XhmikosR committed
944
var Button = /*#__PURE__*/function () {
XhmikosR's avatar
XhmikosR committed
945
  function Button(element) {
XhmikosR's avatar
Dist.  
XhmikosR committed
946
947
948
949
950
    this._element = element;
    Data.setData(element, DATA_KEY$1, this);
  } // Getters


XhmikosR's avatar
XhmikosR committed
951
  var _proto = Button.prototype;
XhmikosR's avatar
Dist.  
XhmikosR committed
952

XhmikosR's avatar
XhmikosR committed
953
954
955
956
  // Public
  _proto.toggle = function toggle() {
    var triggerChangeEvent = true;
    var addAriaPressed = true;
XhmikosR's avatar
XhmikosR committed
957
958

    var rootElement = this._element.closest(SELECTOR_DATA_TOGGLE);
XhmikosR's avatar
Dist.  
XhmikosR committed
959
960

    if (rootElement) {
XhmikosR's avatar
XhmikosR committed
961
      var input = SelectorEngine.findOne(SELECTOR_INPUT, this._element);
XhmikosR's avatar
Dist.  
XhmikosR committed
962

XhmikosR's avatar
XhmikosR committed
963
      if (input && input.type === 'radio') {
XhmikosR's avatar
XhmikosR committed
964
        if (input.checked && this._element.classList.contains(CLASS_NAME_ACTIVE)) {
XhmikosR's avatar
XhmikosR committed
965
966
          triggerChangeEvent = false;
        } else {
XhmikosR's avatar
XhmikosR committed
967
          var activeElement = SelectorEngine.findOne(SELECTOR_ACTIVE, rootElement);
XhmikosR's avatar
Dist.  
XhmikosR committed
968

XhmikosR's avatar
XhmikosR committed
969
          if (activeElement) {
XhmikosR's avatar
XhmikosR committed
970
            activeElement.classList.remove(CLASS_NAME_ACTIVE);
XhmikosR's avatar
Dist.  
XhmikosR committed
971
972
973
974
          }
        }

        if (triggerChangeEvent) {
XhmikosR's avatar
XhmikosR committed
975
          if (input.hasAttribute('disabled') || rootElement.hasAttribute('disabled') || input.classList.contains(CLASS_NAME_DISABLED) || rootElement.classList.contains(CLASS_NAME_DISABLED)) {
XhmikosR's avatar
Dist.  
XhmikosR committed
976
977
978
            return;
          }

XhmikosR's avatar
XhmikosR committed
979
          input.checked = !this._element.classList.contains(CLASS_NAME_ACTIVE);
XhmikosR's avatar
Dist.  
XhmikosR committed
980
981
982
983
984
985
986
987
988
          EventHandler.trigger(input, 'change');
        }

        input.focus();
        addAriaPressed = false;
      }
    }

    if (addAriaPressed) {
XhmikosR's avatar
XhmikosR committed
989
      this._element.setAttribute('aria-pressed', !this._element.classList.contains(CLASS_NAME_ACTIVE));
XhmikosR's avatar
Dist.  
XhmikosR committed
990
991
992
    }

    if (triggerChangeEvent) {
XhmikosR's avatar
XhmikosR committed
993
      this._element.classList.toggle(CLASS_NAME_ACTIVE);
XhmikosR's avatar
Dist.  
XhmikosR committed
994
    }
XhmikosR's avatar
XhmikosR committed
995
  };
XhmikosR's avatar
Dist.  
XhmikosR committed
996

XhmikosR's avatar
XhmikosR committed
997
  _proto.dispose = function dispose() {
XhmikosR's avatar
Dist.  
XhmikosR committed
998
999
1000
    Data.removeData(this._element, DATA_KEY$1);
    this._element = null;
  } // Static
For faster browsing, not all history is shown. View entire blame