forked from kisaacs/GardenMockups
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.js
4951 lines (3956 loc) · 152 KB
/
bootstrap.js
1
2
3
4
5
6
7
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
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
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*!
* Bootstrap v5.0.0-beta2 (https://getbootstrap.com/)
* Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@popperjs/core')) :
typeof define === 'function' && define.amd ? define(['@popperjs/core'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.bootstrap = factory(global.Popper));
}(this, (function (Popper) { 'use strict';
function _interopNamespace(e) {
if (e && e.__esModule) return e;
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () {
return e[k];
}
});
}
});
}
n['default'] = e;
return Object.freeze(n);
}
var Popper__namespace = /*#__PURE__*/_interopNamespace(Popper);
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 _extends() {
_extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
return _extends.apply(this, arguments);
}
function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
_setPrototypeOf(subClass, superClass);
}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
o.__proto__ = p;
return o;
};
return _setPrototypeOf(o, p);
}
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta2): util/index.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
var MAX_UID = 1000000;
var MILLISECONDS_MULTIPLIER = 1000;
var TRANSITION_END = 'transitionend'; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
var toType = function toType(obj) {
if (obj === null || obj === undefined) {
return "" + obj;
}
return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
};
/**
* --------------------------------------------------------------------------
* Public Util Api
* --------------------------------------------------------------------------
*/
var getUID = function getUID(prefix) {
do {
prefix += Math.floor(Math.random() * MAX_UID);
} while (document.getElementById(prefix));
return prefix;
};
var getSelector = function getSelector(element) {
var selector = element.getAttribute('data-bs-target');
if (!selector || selector === '#') {
var hrefAttr = element.getAttribute('href'); // The only valid content that could double as a selector are IDs or classes,
// so everything starting with `#` or `.`. If a "real" URL is used as the selector,
// `document.querySelector` will rightfully complain it is invalid.
// See https://github.com/twbs/bootstrap/issues/32273
if (!hrefAttr || !hrefAttr.includes('#') && !hrefAttr.startsWith('.')) {
return null;
} // Just in case some CMS puts out a full URL with the anchor appended
if (hrefAttr.includes('#') && !hrefAttr.startsWith('#')) {
hrefAttr = '#' + hrefAttr.split('#')[1];
}
selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : null;
}
return selector;
};
var getSelectorFromElement = function getSelectorFromElement(element) {
var selector = getSelector(element);
if (selector) {
return document.querySelector(selector) ? selector : null;
}
return null;
};
var getElementFromSelector = function getElementFromSelector(element) {
var selector = getSelector(element);
return selector ? document.querySelector(selector) : null;
};
var getTransitionDurationFromElement = function getTransitionDurationFromElement(element) {
if (!element) {
return 0;
} // Get transition-duration of the element
var _window$getComputedSt = window.getComputedStyle(element),
transitionDuration = _window$getComputedSt.transitionDuration,
transitionDelay = _window$getComputedSt.transitionDelay;
var floatTransitionDuration = Number.parseFloat(transitionDuration);
var floatTransitionDelay = Number.parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
if (!floatTransitionDuration && !floatTransitionDelay) {
return 0;
} // If multiple durations are defined, take the first
transitionDuration = transitionDuration.split(',')[0];
transitionDelay = transitionDelay.split(',')[0];
return (Number.parseFloat(transitionDuration) + Number.parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
};
var triggerTransitionEnd = function triggerTransitionEnd(element) {
element.dispatchEvent(new Event(TRANSITION_END));
};
var isElement = function isElement(obj) {
return (obj[0] || obj).nodeType;
};
var emulateTransitionEnd = function emulateTransitionEnd(element, duration) {
var called = false;
var durationPadding = 5;
var emulatedDuration = duration + durationPadding;
function listener() {
called = true;
element.removeEventListener(TRANSITION_END, listener);
}
element.addEventListener(TRANSITION_END, listener);
setTimeout(function () {
if (!called) {
triggerTransitionEnd(element);
}
}, emulatedDuration);
};
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);
if (!new RegExp(expectedTypes).test(valueType)) {
throw new TypeError(componentName.toUpperCase() + ": " + ("Option \"" + property + "\" provided type \"" + valueType + "\" ") + ("but expected type \"" + expectedTypes + "\"."));
}
});
};
var isVisible = function isVisible(element) {
if (!element) {
return false;
}
if (element.style && element.parentNode && element.parentNode.style) {
var elementStyle = getComputedStyle(element);
var parentNodeStyle = getComputedStyle(element.parentNode);
return elementStyle.display !== 'none' && parentNodeStyle.display !== 'none' && elementStyle.visibility !== 'hidden';
}
return false;
};
var findShadowRoot = function findShadowRoot(element) {
if (!document.documentElement.attachShadow) {
return null;
} // Can find the shadow root otherwise it'll return the document
if (typeof element.getRootNode === 'function') {
var root = element.getRootNode();
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);
};
var noop = function noop() {
return function () {};
};
var reflow = function reflow(element) {
return element.offsetHeight;
};
var getjQuery = function getjQuery() {
var _window = window,
jQuery = _window.jQuery;
if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) {
return jQuery;
}
return null;
};
var onDOMContentLoaded = function onDOMContentLoaded(callback) {
if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', callback);
} else {
callback();
}
};
var isRTL = document.documentElement.dir === 'rtl';
var defineJQueryPlugin = function defineJQueryPlugin(name, plugin) {
onDOMContentLoaded(function () {
var $ = getjQuery();
/* istanbul ignore if */
if ($) {
var JQUERY_NO_CONFLICT = $.fn[name];
$.fn[name] = plugin.jQueryInterface;
$.fn[name].Constructor = plugin;
$.fn[name].noConflict = function () {
$.fn[name] = JQUERY_NO_CONFLICT;
return plugin.jQueryInterface;
};
}
});
};
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta2): dom/data.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
var mapData = function () {
var storeData = {};
var id = 1;
return {
set: function set(element, key, data) {
if (typeof element.bsKey === 'undefined') {
element.bsKey = {
key: key,
id: id
};
id++;
}
storeData[element.bsKey.id] = data;
},
get: function get(element, key) {
if (!element || typeof element.bsKey === 'undefined') {
return null;
}
var keyProperties = element.bsKey;
if (keyProperties.key === key) {
return storeData[keyProperties.id];
}
return null;
},
delete: function _delete(element, key) {
if (typeof element.bsKey === 'undefined') {
return;
}
var keyProperties = element.bsKey;
if (keyProperties.key === key) {
delete storeData[keyProperties.id];
delete element.bsKey;
}
}
};
}();
var Data = {
setData: function setData(instance, key, data) {
mapData.set(instance, key, data);
},
getData: function getData(instance, key) {
return mapData.get(instance, key);
},
removeData: function removeData(instance, key) {
mapData.delete(instance, key);
}
};
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta2): dom/event-handler.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
var namespaceRegex = /[^.]*(?=\..*)\.|.*/;
var stripNameRegex = /\..*/;
var stripUidRegex = /::\d+$/;
var eventRegistry = {}; // Events storage
var uidEvent = 1;
var customEvents = {
mouseenter: 'mouseover',
mouseleave: 'mouseout'
};
var 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']);
/**
* ------------------------------------------------------------------------
* Private methods
* ------------------------------------------------------------------------
*/
function getUidEvent(element, uid) {
return uid && uid + "::" + uidEvent++ || element.uidEvent || uidEvent++;
}
function getEvent(element) {
var uid = getUidEvent(element);
element.uidEvent = uid;
eventRegistry[uid] = eventRegistry[uid] || {};
return eventRegistry[uid];
}
function bootstrapHandler(element, fn) {
return function handler(event) {
event.delegateTarget = element;
if (handler.oneOff) {
EventHandler.off(element, event.type, fn);
}
return fn.apply(element, [event]);
};
}
function bootstrapDelegationHandler(element, selector, fn) {
return function handler(event) {
var domElements = element.querySelectorAll(selector);
for (var target = event.target; target && target !== this; target = target.parentNode) {
for (var i = domElements.length; i--;) {
if (domElements[i] === target) {
event.delegateTarget = target;
if (handler.oneOff) {
// eslint-disable-next-line unicorn/consistent-destructuring
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;
}
var uidEventList = Object.keys(events);
for (var i = 0, len = uidEventList.length; i < len; i++) {
var event = events[uidEventList[i]];
if (event.originalHandler === handler && event.delegationSelector === delegationSelector) {
return event;
}
}
return null;
}
function normalizeParams(originalTypeEvent, handler, delegationFn) {
var delegation = typeof handler === 'string';
var originalHandler = delegation ? delegationFn : handler; // allow to get the native events from namespaced events ('click.bs.button' --> 'click')
var typeEvent = originalTypeEvent.replace(stripNameRegex, '');
var custom = customEvents[typeEvent];
if (custom) {
typeEvent = custom;
}
var isNative = nativeEvents.has(typeEvent);
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;
}
var _normalizeParams = normalizeParams(originalTypeEvent, handler, delegationFn),
delegation = _normalizeParams[0],
originalHandler = _normalizeParams[1],
typeEvent = _normalizeParams[2];
var events = getEvent(element);
var handlers = events[typeEvent] || (events[typeEvent] = {});
var previousFn = findHandler(handlers, originalHandler, delegation ? handler : null);
if (previousFn) {
previousFn.oneOff = previousFn.oneOff && oneOff;
return;
}
var uid = getUidEvent(originalHandler, originalTypeEvent.replace(namespaceRegex, ''));
var fn = delegation ? bootstrapDelegationHandler(element, handler, delegationFn) : bootstrapHandler(element, handler);
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) {
var fn = findHandler(events[typeEvent], handler, delegationSelector);
if (!fn) {
return;
}
element.removeEventListener(typeEvent, fn, Boolean(delegationSelector));
delete events[typeEvent][fn.uidEvent];
}
function removeNamespacedHandlers(element, events, typeEvent, namespace) {
var storeElementEvent = events[typeEvent] || {};
Object.keys(storeElementEvent).forEach(function (handlerKey) {
if (handlerKey.includes(namespace)) {
var event = storeElementEvent[handlerKey];
removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector);
}
});
}
var EventHandler = {
on: function on(element, event, handler, delegationFn) {
addHandler(element, event, handler, delegationFn, false);
},
one: function one(element, event, handler, delegationFn) {
addHandler(element, event, handler, delegationFn, true);
},
off: function off(element, originalTypeEvent, handler, delegationFn) {
if (typeof originalTypeEvent !== 'string' || !element) {
return;
}
var _normalizeParams2 = normalizeParams(originalTypeEvent, handler, delegationFn),
delegation = _normalizeParams2[0],
originalHandler = _normalizeParams2[1],
typeEvent = _normalizeParams2[2];
var inNamespace = typeEvent !== originalTypeEvent;
var events = getEvent(element);
var isNamespace = originalTypeEvent.startsWith('.');
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) {
Object.keys(events).forEach(function (elementEvent) {
removeNamespacedHandlers(element, events, elementEvent, originalTypeEvent.slice(1));
});
}
var storeElementEvent = events[typeEvent] || {};
Object.keys(storeElementEvent).forEach(function (keyHandlers) {
var handlerKey = keyHandlers.replace(stripUidRegex, '');
if (!inNamespace || originalTypeEvent.includes(handlerKey)) {
var event = storeElementEvent[keyHandlers];
removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector);
}
});
},
trigger: function trigger(element, event, args) {
if (typeof event !== 'string' || !element) {
return null;
}
var $ = getjQuery();
var typeEvent = event.replace(stripNameRegex, '');
var inNamespace = event !== typeEvent;
var isNative = nativeEvents.has(typeEvent);
var jQueryEvent;
var bubbles = true;
var nativeDispatch = true;
var defaultPrevented = false;
var evt = null;
if (inNamespace && $) {
jQueryEvent = $.Event(event, args);
$(element).trigger(jQueryEvent);
bubbles = !jQueryEvent.isPropagationStopped();
nativeDispatch = !jQueryEvent.isImmediatePropagationStopped();
defaultPrevented = jQueryEvent.isDefaultPrevented();
}
if (isNative) {
evt = document.createEvent('HTMLEvents');
evt.initEvent(typeEvent, bubbles, true);
} else {
evt = new CustomEvent(event, {
bubbles: bubbles,
cancelable: true
});
} // merge custom information in our event
if (typeof args !== 'undefined') {
Object.keys(args).forEach(function (key) {
Object.defineProperty(evt, key, {
get: function get() {
return args[key];
}
});
});
}
if (defaultPrevented) {
evt.preventDefault();
}
if (nativeDispatch) {
element.dispatchEvent(evt);
}
if (evt.defaultPrevented && typeof jQueryEvent !== 'undefined') {
jQueryEvent.preventDefault();
}
return evt;
}
};
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
var VERSION = '5.0.0-beta2';
var BaseComponent = /*#__PURE__*/function () {
function BaseComponent(element) {
if (!element) {
return;
}
this._element = element;
Data.setData(element, this.constructor.DATA_KEY, this);
}
var _proto = BaseComponent.prototype;
_proto.dispose = function dispose() {
Data.removeData(this._element, this.constructor.DATA_KEY);
this._element = null;
}
/** Static */
;
BaseComponent.getInstance = function getInstance(element) {
return Data.getData(element, this.DATA_KEY);
};
_createClass(BaseComponent, null, [{
key: "VERSION",
get: function get() {
return VERSION;
}
}]);
return BaseComponent;
}();
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
var NAME = 'alert';
var DATA_KEY = 'bs.alert';
var EVENT_KEY = "." + DATA_KEY;
var DATA_API_KEY = '.data-api';
var SELECTOR_DISMISS = '[data-bs-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 CLASS_NAME_ALERT = 'alert';
var CLASS_NAME_FADE = 'fade';
var CLASS_NAME_SHOW = 'show';
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
var Alert = /*#__PURE__*/function (_BaseComponent) {
_inheritsLoose(Alert, _BaseComponent);
function Alert() {
return _BaseComponent.apply(this, arguments) || this;
}
var _proto = Alert.prototype;
// Public
_proto.close = function close(element) {
var rootElement = element ? this._getRootElement(element) : this._element;
var customEvent = this._triggerCloseEvent(rootElement);
if (customEvent === null || customEvent.defaultPrevented) {
return;
}
this._removeElement(rootElement);
} // Private
;
_proto._getRootElement = function _getRootElement(element) {
return getElementFromSelector(element) || element.closest("." + CLASS_NAME_ALERT);
};
_proto._triggerCloseEvent = function _triggerCloseEvent(element) {
return EventHandler.trigger(element, EVENT_CLOSE);
};
_proto._removeElement = function _removeElement(element) {
var _this = this;
element.classList.remove(CLASS_NAME_SHOW);
if (!element.classList.contains(CLASS_NAME_FADE)) {
this._destroyElement(element);
return;
}
var transitionDuration = getTransitionDurationFromElement(element);
EventHandler.one(element, 'transitionend', function () {
return _this._destroyElement(element);
});
emulateTransitionEnd(element, transitionDuration);
};
_proto._destroyElement = function _destroyElement(element) {
if (element.parentNode) {
element.parentNode.removeChild(element);
}
EventHandler.trigger(element, EVENT_CLOSED);
} // Static
;
Alert.jQueryInterface = function jQueryInterface(config) {
return this.each(function () {
var data = Data.getData(this, DATA_KEY);
if (!data) {
data = new Alert(this);
}
if (config === 'close') {
data[config](this);
}
});
};
Alert.handleDismiss = function handleDismiss(alertInstance) {
return function (event) {
if (event) {
event.preventDefault();
}
alertInstance.close(this);
};
};
_createClass(Alert, null, [{
key: "DATA_KEY",
get: // Getters
function get() {
return DATA_KEY;
}
}]);
return Alert;
}(BaseComponent);
/**
* ------------------------------------------------------------------------
* Data Api implementation
* ------------------------------------------------------------------------
*/
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DISMISS, Alert.handleDismiss(new Alert()));
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .Alert to jQuery only if jQuery is present
*/
defineJQueryPlugin(NAME, Alert);
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
var NAME$1 = 'button';
var DATA_KEY$1 = 'bs.button';
var EVENT_KEY$1 = "." + DATA_KEY$1;
var DATA_API_KEY$1 = '.data-api';
var CLASS_NAME_ACTIVE = 'active';
var SELECTOR_DATA_TOGGLE = '[data-bs-toggle="button"]';
var EVENT_CLICK_DATA_API$1 = "click" + EVENT_KEY$1 + DATA_API_KEY$1;
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
var Button = /*#__PURE__*/function (_BaseComponent) {
_inheritsLoose(Button, _BaseComponent);
function Button() {
return _BaseComponent.apply(this, arguments) || this;
}
var _proto = Button.prototype;
// Public
_proto.toggle = function toggle() {
// Toggle class and sync the `aria-pressed` attribute with the return value of the `.toggle()` method
this._element.setAttribute('aria-pressed', this._element.classList.toggle(CLASS_NAME_ACTIVE));
} // Static
;
Button.jQueryInterface = function jQueryInterface(config) {
return this.each(function () {
var data = Data.getData(this, DATA_KEY$1);
if (!data) {
data = new Button(this);
}
if (config === 'toggle') {
data[config]();
}
});
};
_createClass(Button, null, [{
key: "DATA_KEY",
get: // Getters
function get() {
return DATA_KEY$1;
}
}]);
return Button;
}(BaseComponent);
/**
* ------------------------------------------------------------------------
* Data Api implementation
* ------------------------------------------------------------------------
*/
EventHandler.on(document, EVENT_CLICK_DATA_API$1, SELECTOR_DATA_TOGGLE, function (event) {
event.preventDefault();
var button = event.target.closest(SELECTOR_DATA_TOGGLE);
var data = Data.getData(button, DATA_KEY$1);
if (!data) {
data = new Button(button);
}
data.toggle();
});
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
* add .Button to jQuery only if jQuery is present
*/
defineJQueryPlugin(NAME$1, Button);
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta2): dom/manipulator.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
function normalizeData(val) {
if (val === 'true') {
return true;
}
if (val === 'false') {
return false;
}
if (val === Number(val).toString()) {
return Number(val);
}
if (val === '' || val === 'null') {
return null;
}
return val;
}
function normalizeDataKey(key) {
return key.replace(/[A-Z]/g, function (chr) {
return "-" + chr.toLowerCase();
});
}
var Manipulator = {
setDataAttribute: function setDataAttribute(element, key, value) {
element.setAttribute("data-bs-" + normalizeDataKey(key), value);
},
removeDataAttribute: function removeDataAttribute(element, key) {
element.removeAttribute("data-bs-" + normalizeDataKey(key));
},
getDataAttributes: function getDataAttributes(element) {
if (!element) {
return {};
}
var attributes = {};
Object.keys(element.dataset).filter(function (key) {
return key.startsWith('bs');
}).forEach(function (key) {
var pureKey = key.replace(/^bs/, '');
pureKey = pureKey.charAt(0).toLowerCase() + pureKey.slice(1, pureKey.length);
attributes[pureKey] = normalizeData(element.dataset[key]);
});
return attributes;
},
getDataAttribute: function getDataAttribute(element, key) {
return normalizeData(element.getAttribute("data-bs-" + normalizeDataKey(key)));
},
offset: function offset(element) {
var rect = element.getBoundingClientRect();
return {
top: rect.top + document.body.scrollTop,
left: rect.left + document.body.scrollLeft
};
},
position: function position(element) {
return {
top: element.offsetTop,
left: element.offsetLeft
};
}
};
/**
* --------------------------------------------------------------------------
* Bootstrap (v5.0.0-beta2): dom/selector-engine.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
var NODE_TEXT = 3;
var SelectorEngine = {
find: function find(selector, element) {
var _ref;
if (element === void 0) {
element = document.documentElement;
}
return (_ref = []).concat.apply(_ref, Element.prototype.querySelectorAll.call(element, selector));
},
findOne: function findOne(selector, element) {
if (element === void 0) {
element = document.documentElement;
}