bootstrap 4.3.1 → 5.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (158) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +17 -2
  3. data/CHANGELOG.md +2 -14
  4. data/README.md +7 -4
  5. data/assets/javascripts/bootstrap/alert.js +172 -136
  6. data/assets/javascripts/bootstrap/base-component.js +182 -0
  7. data/assets/javascripts/bootstrap/button.js +101 -142
  8. data/assets/javascripts/bootstrap/carousel.js +483 -408
  9. data/assets/javascripts/bootstrap/collapse.js +340 -273
  10. data/assets/javascripts/bootstrap/dom/data.js +68 -0
  11. data/assets/javascripts/bootstrap/dom/event-handler.js +321 -0
  12. data/assets/javascripts/bootstrap/dom/manipulator.js +88 -0
  13. data/assets/javascripts/bootstrap/dom/selector-engine.js +127 -0
  14. data/assets/javascripts/bootstrap/dropdown.js +491 -399
  15. data/assets/javascripts/bootstrap/modal.js +841 -449
  16. data/assets/javascripts/bootstrap/offcanvas.js +866 -0
  17. data/assets/javascripts/bootstrap/popover.js +121 -198
  18. data/assets/javascripts/bootstrap/scrollspy.js +256 -240
  19. data/assets/javascripts/bootstrap/tab.js +218 -154
  20. data/assets/javascripts/bootstrap/toast.js +329 -189
  21. data/assets/javascripts/bootstrap/tooltip.js +651 -552
  22. data/assets/javascripts/bootstrap-global-this-define.js +6 -0
  23. data/assets/javascripts/bootstrap-global-this-undefine.js +2 -0
  24. data/assets/javascripts/bootstrap-sprockets.js +8 -1
  25. data/assets/javascripts/bootstrap.js +3503 -2892
  26. data/assets/javascripts/bootstrap.min.js +4 -4
  27. data/assets/stylesheets/_bootstrap-grid.scss +56 -18
  28. data/assets/stylesheets/_bootstrap-reboot.scss +5 -4
  29. data/assets/stylesheets/_bootstrap.scss +20 -11
  30. data/assets/stylesheets/bootstrap/_accordion.scss +118 -0
  31. data/assets/stylesheets/bootstrap/_alert.scss +15 -9
  32. data/assets/stylesheets/bootstrap/_badge.scss +2 -27
  33. data/assets/stylesheets/bootstrap/_breadcrumb.scss +5 -18
  34. data/assets/stylesheets/bootstrap/_button-group.scss +21 -45
  35. data/assets/stylesheets/bootstrap/_buttons.scss +28 -54
  36. data/assets/stylesheets/bootstrap/_card.scss +52 -125
  37. data/assets/stylesheets/bootstrap/_carousel.scss +70 -38
  38. data/assets/stylesheets/bootstrap/_close.scss +30 -31
  39. data/assets/stylesheets/bootstrap/_containers.scss +41 -0
  40. data/assets/stylesheets/bootstrap/_dropdown.scss +88 -39
  41. data/assets/stylesheets/bootstrap/_forms.scss +9 -330
  42. data/assets/stylesheets/bootstrap/_functions.scss +243 -27
  43. data/assets/stylesheets/bootstrap/_grid.scss +14 -33
  44. data/assets/stylesheets/bootstrap/_helpers.scss +9 -0
  45. data/assets/stylesheets/bootstrap/_images.scss +3 -3
  46. data/assets/stylesheets/bootstrap/_list-group.scss +61 -36
  47. data/assets/stylesheets/bootstrap/_mixins.scss +12 -16
  48. data/assets/stylesheets/bootstrap/_modal.scss +64 -84
  49. data/assets/stylesheets/bootstrap/_nav.scss +29 -10
  50. data/assets/stylesheets/bootstrap/_navbar.scss +93 -52
  51. data/assets/stylesheets/bootstrap/_offcanvas.scss +83 -0
  52. data/assets/stylesheets/bootstrap/_pagination.scss +13 -22
  53. data/assets/stylesheets/bootstrap/_placeholders.scss +51 -0
  54. data/assets/stylesheets/bootstrap/_popover.scss +29 -42
  55. data/assets/stylesheets/bootstrap/_progress.scss +10 -5
  56. data/assets/stylesheets/bootstrap/_reboot.scss +350 -208
  57. data/assets/stylesheets/bootstrap/_root.scss +43 -8
  58. data/assets/stylesheets/bootstrap/_spinners.scss +21 -7
  59. data/assets/stylesheets/bootstrap/_tables.scss +84 -114
  60. data/assets/stylesheets/bootstrap/_toasts.scss +21 -14
  61. data/assets/stylesheets/bootstrap/_tooltip.scss +21 -21
  62. data/assets/stylesheets/bootstrap/_transitions.scss +8 -1
  63. data/assets/stylesheets/bootstrap/_type.scss +40 -61
  64. data/assets/stylesheets/bootstrap/_utilities.scss +630 -17
  65. data/assets/stylesheets/bootstrap/_variables.scss +1007 -489
  66. data/assets/stylesheets/bootstrap/bootstrap-utilities.scss +18 -0
  67. data/assets/stylesheets/bootstrap/forms/_floating-labels.scss +63 -0
  68. data/assets/stylesheets/bootstrap/forms/_form-check.scss +152 -0
  69. data/assets/stylesheets/bootstrap/forms/_form-control.scss +219 -0
  70. data/assets/stylesheets/bootstrap/forms/_form-range.scss +91 -0
  71. data/assets/stylesheets/bootstrap/forms/_form-select.scss +72 -0
  72. data/assets/stylesheets/bootstrap/forms/_form-text.scss +11 -0
  73. data/assets/stylesheets/bootstrap/forms/_input-group.scss +121 -0
  74. data/assets/stylesheets/bootstrap/forms/_labels.scss +36 -0
  75. data/assets/stylesheets/bootstrap/forms/_validation.scss +12 -0
  76. data/assets/stylesheets/bootstrap/{utilities → helpers}/_clearfix.scss +0 -0
  77. data/assets/stylesheets/bootstrap/helpers/_colored-links.scss +12 -0
  78. data/assets/stylesheets/bootstrap/helpers/_position.scss +30 -0
  79. data/assets/stylesheets/bootstrap/helpers/_ratio.scss +26 -0
  80. data/assets/stylesheets/bootstrap/helpers/_stacks.scss +15 -0
  81. data/assets/stylesheets/bootstrap/helpers/_stretched-link.scss +15 -0
  82. data/assets/stylesheets/bootstrap/helpers/_text-truncation.scss +7 -0
  83. data/assets/stylesheets/bootstrap/helpers/_visually-hidden.scss +8 -0
  84. data/assets/stylesheets/bootstrap/helpers/_vr.scss +8 -0
  85. data/assets/stylesheets/bootstrap/mixins/_alert.scss +3 -5
  86. data/assets/stylesheets/bootstrap/mixins/_backdrop.scss +14 -0
  87. data/assets/stylesheets/bootstrap/mixins/_border-radius.scss +37 -22
  88. data/assets/stylesheets/bootstrap/mixins/_box-shadow.scss +7 -9
  89. data/assets/stylesheets/bootstrap/mixins/_breakpoints.scss +14 -10
  90. data/assets/stylesheets/bootstrap/mixins/_buttons.scss +77 -51
  91. data/assets/stylesheets/bootstrap/mixins/_caret.scss +10 -8
  92. data/assets/stylesheets/bootstrap/mixins/_clearfix.scss +2 -0
  93. data/assets/stylesheets/bootstrap/mixins/_color-scheme.scss +7 -0
  94. data/assets/stylesheets/bootstrap/mixins/_container.scss +9 -0
  95. data/assets/stylesheets/bootstrap/mixins/_forms.scss +67 -115
  96. data/assets/stylesheets/bootstrap/mixins/_gradients.scss +13 -11
  97. data/assets/stylesheets/bootstrap/mixins/_grid.scss +132 -32
  98. data/assets/stylesheets/bootstrap/mixins/_image.scss +0 -20
  99. data/assets/stylesheets/bootstrap/mixins/_list-group.scss +5 -2
  100. data/assets/stylesheets/bootstrap/mixins/_pagination.scss +17 -8
  101. data/assets/stylesheets/bootstrap/mixins/_reset-text.scss +1 -1
  102. data/assets/stylesheets/bootstrap/mixins/_table-variants.scss +21 -0
  103. data/assets/stylesheets/bootstrap/mixins/_transition.scss +18 -8
  104. data/assets/stylesheets/bootstrap/mixins/_utilities.scss +89 -0
  105. data/assets/stylesheets/bootstrap/mixins/_visually-hidden.scss +29 -0
  106. data/assets/stylesheets/bootstrap/utilities/_api.scss +47 -0
  107. data/assets/stylesheets/bootstrap/vendor/_rfs.scss +278 -128
  108. data/bootstrap.gemspec +4 -6
  109. data/lib/bootstrap/version.rb +2 -2
  110. data/tasks/updater/js.rb +25 -6
  111. data/tasks/updater/network.rb +8 -2
  112. data/test/dummy_rails/app/assets/config/manifest.js +3 -0
  113. data/test/dummy_rails/app/assets/javascripts/application.js +4 -3
  114. data/test/dummy_rails/app/assets/stylesheets/.browserslistrc +1 -0
  115. data/test/dummy_rails/app/views/layouts/application.html.erb +3 -1
  116. data/test/dummy_rails/app/views/pages/root.html +89 -0
  117. data/test/dummy_rails/config/application.rb +0 -3
  118. data/test/gemfiles/rails_6_0.gemfile +7 -0
  119. data/test/gemfiles/rails_6_1.gemfile +7 -0
  120. data/test/support/dummy_rails_integration.rb +3 -1
  121. data/test/test_helper.rb +18 -13
  122. metadata +61 -79
  123. data/assets/javascripts/bootstrap/util.js +0 -171
  124. data/assets/stylesheets/bootstrap/_code.scss +0 -48
  125. data/assets/stylesheets/bootstrap/_custom-forms.scss +0 -507
  126. data/assets/stylesheets/bootstrap/_input-group.scss +0 -193
  127. data/assets/stylesheets/bootstrap/_jumbotron.scss +0 -17
  128. data/assets/stylesheets/bootstrap/_media.scss +0 -8
  129. data/assets/stylesheets/bootstrap/_print.scss +0 -141
  130. data/assets/stylesheets/bootstrap/mixins/_background-variant.scss +0 -21
  131. data/assets/stylesheets/bootstrap/mixins/_badge.scss +0 -17
  132. data/assets/stylesheets/bootstrap/mixins/_float.scss +0 -14
  133. data/assets/stylesheets/bootstrap/mixins/_grid-framework.scss +0 -66
  134. data/assets/stylesheets/bootstrap/mixins/_hover.scss +0 -37
  135. data/assets/stylesheets/bootstrap/mixins/_nav-divider.scss +0 -10
  136. data/assets/stylesheets/bootstrap/mixins/_screen-reader.scss +0 -33
  137. data/assets/stylesheets/bootstrap/mixins/_size.scss +0 -7
  138. data/assets/stylesheets/bootstrap/mixins/_table-row.scss +0 -39
  139. data/assets/stylesheets/bootstrap/mixins/_text-emphasis.scss +0 -16
  140. data/assets/stylesheets/bootstrap/mixins/_text-hide.scss +0 -11
  141. data/assets/stylesheets/bootstrap/mixins/_visibility.scss +0 -8
  142. data/assets/stylesheets/bootstrap/utilities/_align.scss +0 -8
  143. data/assets/stylesheets/bootstrap/utilities/_background.scss +0 -19
  144. data/assets/stylesheets/bootstrap/utilities/_borders.scss +0 -75
  145. data/assets/stylesheets/bootstrap/utilities/_display.scss +0 -26
  146. data/assets/stylesheets/bootstrap/utilities/_embed.scss +0 -39
  147. data/assets/stylesheets/bootstrap/utilities/_flex.scss +0 -51
  148. data/assets/stylesheets/bootstrap/utilities/_float.scss +0 -11
  149. data/assets/stylesheets/bootstrap/utilities/_overflow.scss +0 -5
  150. data/assets/stylesheets/bootstrap/utilities/_position.scss +0 -32
  151. data/assets/stylesheets/bootstrap/utilities/_screenreaders.scss +0 -11
  152. data/assets/stylesheets/bootstrap/utilities/_shadows.scss +0 -6
  153. data/assets/stylesheets/bootstrap/utilities/_sizing.scss +0 -20
  154. data/assets/stylesheets/bootstrap/utilities/_spacing.scss +0 -73
  155. data/assets/stylesheets/bootstrap/utilities/_stretched-link.scss +0 -19
  156. data/assets/stylesheets/bootstrap/utilities/_text.scss +0 -72
  157. data/assets/stylesheets/bootstrap/utilities/_visibility.scss +0 -13
  158. data/test/dummy_rails/app/views/pages/root.html.slim +0 -58
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0e32995c543ae2e6e2053b60ca3bf7f852b89c60ce26827c4b3efc87a482d2eb
4
- data.tar.gz: bec41cdf3c4c03ed3945fa20f744aa5d2a2ebd301389809548d6c08ce08a866d
3
+ metadata.gz: 666b108731be39c8122df9a54b7b2a1715f02b92e03caa941c132b3e7ec352ca
4
+ data.tar.gz: 57086f0d9bb88ba6a0abf74a5f0006b6eed21168d37009c2159e8ab9b68385f4
5
5
  SHA512:
6
- metadata.gz: 8531bfb77cf50de537a66b36c08ef2f90953c9c80d0177c70f07ea14662b219380e904f27a5aed3c55c41b835efe3e20fbebe670f74495dad7efa107afeb1fea
7
- data.tar.gz: c3a0f8311bf6e76ee646fb92cd7432bd2c482e354ed7aa58b5edad824901fc1da6cc92c631553e0c48de2b7d9ba64797fd369af124fe51ae6e88681afecfeb08
6
+ metadata.gz: 6171d65c922c486d41a0cb7f4e781e389b2cf0d9e00cf7c350fcdf6ab59b814e8daa7449a9a97d7462e6945f766261466cbf750f0aedc07301f366d2f7731eaf
7
+ data.tar.gz: b65871d048cecf29a714362f75348bc167ba158e50197908cde71ff197d834c0d84eb9ead9be4f7c87c22f49da0c164a6aa997843b2bc5998f6b12effc762db7
data/.travis.yml CHANGED
@@ -1,11 +1,26 @@
1
1
  language: ruby
2
- sudo: false
2
+ dist: focal
3
+ addons:
4
+ apt:
5
+ packages:
6
+ - chromium-browser
3
7
  rvm:
4
- - 2.3.8
8
+ - 2.5
9
+ - 2.6
10
+ - 2.7
11
+
5
12
  gemfile:
6
13
  - test/gemfiles/rails_4_2.gemfile
7
14
  - test/gemfiles/rails_5_0.gemfile
8
15
  - test/gemfiles/rails_5_1.gemfile
16
+ - test/gemfiles/rails_6_0.gemfile
17
+ - test/gemfiles/rails_6_1.gemfile
18
+
19
+ jobs:
20
+ exclude:
21
+ rvm: 2.7
22
+ gemfile: test/gemfiles/rails_4_2.gemfile
23
+
9
24
  cache: bundler
10
25
  bundler_args: --path ../../vendor/bundle --without debug
11
26
  notifications:
data/CHANGELOG.md CHANGED
@@ -6,21 +6,9 @@ The changelog only includes changes specific to the RubyGem.
6
6
  The Bootstrap framework changes can be found in [the Releases section of twbs/bootstrap](https://github.com/twbs/bootstrap/releases).
7
7
  Release announcement posts on [the official Bootstrap blog](http://blog.getbootstrap.com) contain summaries of the most noteworthy changes made in each release of Bootstrap.
8
8
 
9
- # 4.1.1
9
+ # 4.2.1
10
10
 
11
- No gem-specific changes.
12
-
13
- # 4.1.0
14
-
15
- No gem-specific changes.
16
-
17
- # 4.0.0
18
-
19
- No gem-specific changes.
20
-
21
- # 4.0.0.beta3
22
-
23
- No gem-specific changes.
11
+ * Bootstrap rubygem now depends on SassC instead of Sass.
24
12
 
25
13
  # 4.0.0.beta2.1
26
14
 
data/README.md CHANGED
@@ -1,9 +1,12 @@
1
1
  # Bootstrap Ruby Gem [![Build Status](https://travis-ci.org/twbs/bootstrap-rubygem.svg?branch=master)](https://travis-ci.org/twbs/bootstrap-rubygem) [![Gem](https://img.shields.io/gem/v/bootstrap.svg)](https://rubygems.org/gems/bootstrap)
2
2
 
3
- [Bootstrap 4][bootstrap-home] ruby gem for Ruby on Rails (Sprockets) and Hanami (formerly Lotus).
3
+ [Bootstrap 5][bootstrap-home] ruby gem for Ruby on Rails (*Sprockets*) and Hanami (formerly Lotus).
4
4
 
5
5
  For Sass versions of Bootstrap 3 and 2 see [bootstrap-sass](https://github.com/twbs/bootstrap-sass) instead.
6
6
 
7
+ **Ruby on Rails 6 Note:**:
8
+ With the release of Rails 6 there have been some minor changes made to the default configuration for The Asset Pipeline. In specific, by default _Sprockets no longer processes JavaScript_ and instead Webpack is set as the default. The `twbs/bootstrap-rubygem` is for use with Sprockets not Webpack.
9
+
7
10
  ## Installation
8
11
 
9
12
  Please see the appropriate guide for your environment of choice:
@@ -17,7 +20,7 @@ Please see the appropriate guide for your environment of choice:
17
20
  Add `bootstrap` to your Gemfile:
18
21
 
19
22
  ```ruby
20
- gem 'bootstrap', '~> 4.3.1'
23
+ gem 'bootstrap', '~> 5.1.3'
21
24
  ```
22
25
 
23
26
  Ensure that `sprockets-rails` is at least v2.3.2.
@@ -44,8 +47,8 @@ Then, remove all the `*= require` and `*= require_tree` statements from the Sass
44
47
 
45
48
  Do not use `*= require` in Sass or your other stylesheets will not be able to access the Bootstrap mixins and variables.
46
49
 
47
- Bootstrap JavaScript depends on jQuery.
48
- If you're using Rails 5.1+, add the `jquery-rails` gem to your Gemfile:
50
+ Bootstrap JavaScript can optionally use jQuery.
51
+ If you're using Rails 5.1+, you can add the `jquery-rails` gem to your Gemfile:
49
52
 
50
53
  ```ruby
51
54
  gem 'jquery-rails'
@@ -1,176 +1,217 @@
1
1
  /*!
2
- * Bootstrap alert.js v4.3.1 (https://getbootstrap.com/)
3
- * Copyright 2011-2019 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
4
- * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
2
+ * Bootstrap alert.js 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
5
  */
6
6
  (function (global, factory) {
7
- typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('jquery'), require('./util.js')) :
8
- typeof define === 'function' && define.amd ? define(['jquery', './util.js'], factory) :
9
- (global = global || self, global.Alert = factory(global.jQuery, global.Util));
10
- }(this, function ($, Util) { 'use strict';
11
-
12
- $ = $ && $.hasOwnProperty('default') ? $['default'] : $;
13
- Util = Util && Util.hasOwnProperty('default') ? Util['default'] : Util;
14
-
15
- function _defineProperties(target, props) {
16
- for (var i = 0; i < props.length; i++) {
17
- var descriptor = props[i];
18
- descriptor.enumerable = descriptor.enumerable || false;
19
- descriptor.configurable = true;
20
- if ("value" in descriptor) descriptor.writable = true;
21
- Object.defineProperty(target, descriptor.key, descriptor);
22
- }
23
- }
7
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/event-handler.js'), require('./base-component.js')) :
8
+ typeof define === 'function' && define.amd ? define(['./dom/event-handler', './base-component'], factory) :
9
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Alert = factory(global.EventHandler, global.Base));
10
+ })(this, (function (EventHandler, BaseComponent) { 'use strict';
24
11
 
25
- function _createClass(Constructor, protoProps, staticProps) {
26
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
27
- if (staticProps) _defineProperties(Constructor, staticProps);
28
- return Constructor;
29
- }
12
+ const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e };
13
+
14
+ const EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler);
15
+ const BaseComponent__default = /*#__PURE__*/_interopDefaultLegacy(BaseComponent);
30
16
 
31
17
  /**
32
- * ------------------------------------------------------------------------
33
- * Constants
34
- * ------------------------------------------------------------------------
18
+ * --------------------------------------------------------------------------
19
+ * Bootstrap (v5.1.3): util/index.js
20
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
21
+ * --------------------------------------------------------------------------
35
22
  */
36
23
 
37
- var NAME = 'alert';
38
- var VERSION = '4.3.1';
39
- var DATA_KEY = 'bs.alert';
40
- var EVENT_KEY = "." + DATA_KEY;
41
- var DATA_API_KEY = '.data-api';
42
- var JQUERY_NO_CONFLICT = $.fn[NAME];
43
- var Selector = {
44
- DISMISS: '[data-dismiss="alert"]'
45
- };
46
- var Event = {
47
- CLOSE: "close" + EVENT_KEY,
48
- CLOSED: "closed" + EVENT_KEY,
49
- CLICK_DATA_API: "click" + EVENT_KEY + DATA_API_KEY
24
+ const getSelector = element => {
25
+ let selector = element.getAttribute('data-bs-target');
26
+
27
+ if (!selector || selector === '#') {
28
+ let hrefAttr = element.getAttribute('href'); // The only valid content that could double as a selector are IDs or classes,
29
+ // so everything starting with `#` or `.`. If a "real" URL is used as the selector,
30
+ // `document.querySelector` will rightfully complain it is invalid.
31
+ // See https://github.com/twbs/bootstrap/issues/32273
32
+
33
+ if (!hrefAttr || !hrefAttr.includes('#') && !hrefAttr.startsWith('.')) {
34
+ return null;
35
+ } // Just in case some CMS puts out a full URL with the anchor appended
36
+
37
+
38
+ if (hrefAttr.includes('#') && !hrefAttr.startsWith('#')) {
39
+ hrefAttr = `#${hrefAttr.split('#')[1]}`;
40
+ }
41
+
42
+ selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : null;
43
+ }
44
+
45
+ return selector;
50
46
  };
51
- var ClassName = {
52
- ALERT: 'alert',
53
- FADE: 'fade',
54
- SHOW: 'show'
55
- /**
56
- * ------------------------------------------------------------------------
57
- * Class Definition
58
- * ------------------------------------------------------------------------
59
- */
60
47
 
48
+ const getElementFromSelector = element => {
49
+ const selector = getSelector(element);
50
+ return selector ? document.querySelector(selector) : null;
61
51
  };
62
52
 
63
- var Alert =
64
- /*#__PURE__*/
65
- function () {
66
- function Alert(element) {
67
- this._element = element;
68
- } // Getters
53
+ const isDisabled = element => {
54
+ if (!element || element.nodeType !== Node.ELEMENT_NODE) {
55
+ return true;
56
+ }
69
57
 
58
+ if (element.classList.contains('disabled')) {
59
+ return true;
60
+ }
70
61
 
71
- var _proto = Alert.prototype;
62
+ if (typeof element.disabled !== 'undefined') {
63
+ return element.disabled;
64
+ }
72
65
 
73
- // Public
74
- _proto.close = function close(element) {
75
- var rootElement = this._element;
66
+ return element.hasAttribute('disabled') && element.getAttribute('disabled') !== 'false';
67
+ };
76
68
 
77
- if (element) {
78
- rootElement = this._getRootElement(element);
79
- }
69
+ const getjQuery = () => {
70
+ const {
71
+ jQuery
72
+ } = window;
80
73
 
81
- var customEvent = this._triggerCloseEvent(rootElement);
74
+ if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) {
75
+ return jQuery;
76
+ }
82
77
 
83
- if (customEvent.isDefaultPrevented()) {
84
- return;
78
+ return null;
79
+ };
80
+
81
+ const DOMContentLoadedCallbacks = [];
82
+
83
+ const onDOMContentLoaded = callback => {
84
+ if (document.readyState === 'loading') {
85
+ // add listener on the first call when the document is in loading state
86
+ if (!DOMContentLoadedCallbacks.length) {
87
+ document.addEventListener('DOMContentLoaded', () => {
88
+ DOMContentLoadedCallbacks.forEach(callback => callback());
89
+ });
85
90
  }
86
91
 
87
- this._removeElement(rootElement);
88
- };
92
+ DOMContentLoadedCallbacks.push(callback);
93
+ } else {
94
+ callback();
95
+ }
96
+ };
89
97
 
90
- _proto.dispose = function dispose() {
91
- $.removeData(this._element, DATA_KEY);
92
- this._element = null;
93
- } // Private
94
- ;
98
+ const defineJQueryPlugin = plugin => {
99
+ onDOMContentLoaded(() => {
100
+ const $ = getjQuery();
101
+ /* istanbul ignore if */
102
+
103
+ if ($) {
104
+ const name = plugin.NAME;
105
+ const JQUERY_NO_CONFLICT = $.fn[name];
106
+ $.fn[name] = plugin.jQueryInterface;
107
+ $.fn[name].Constructor = plugin;
108
+
109
+ $.fn[name].noConflict = () => {
110
+ $.fn[name] = JQUERY_NO_CONFLICT;
111
+ return plugin.jQueryInterface;
112
+ };
113
+ }
114
+ });
115
+ };
95
116
 
96
- _proto._getRootElement = function _getRootElement(element) {
97
- var selector = Util.getSelectorFromElement(element);
98
- var parent = false;
117
+ /**
118
+ * --------------------------------------------------------------------------
119
+ * Bootstrap (v5.1.3): util/component-functions.js
120
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
121
+ * --------------------------------------------------------------------------
122
+ */
99
123
 
100
- if (selector) {
101
- parent = document.querySelector(selector);
124
+ const enableDismissTrigger = (component, method = 'hide') => {
125
+ const clickEvent = `click.dismiss${component.EVENT_KEY}`;
126
+ const name = component.NAME;
127
+ EventHandler__default.default.on(document, clickEvent, `[data-bs-dismiss="${name}"]`, function (event) {
128
+ if (['A', 'AREA'].includes(this.tagName)) {
129
+ event.preventDefault();
102
130
  }
103
131
 
104
- if (!parent) {
105
- parent = $(element).closest("." + ClassName.ALERT)[0];
132
+ if (isDisabled(this)) {
133
+ return;
106
134
  }
107
135
 
108
- return parent;
109
- };
136
+ const target = getElementFromSelector(this) || this.closest(`.${name}`);
137
+ const instance = component.getOrCreateInstance(target); // Method argument is left, for Alert and only, as it doesn't implement the 'hide' method
138
+
139
+ instance[method]();
140
+ });
141
+ };
142
+
143
+ /**
144
+ * --------------------------------------------------------------------------
145
+ * Bootstrap (v5.1.3): alert.js
146
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
147
+ * --------------------------------------------------------------------------
148
+ */
149
+ /**
150
+ * ------------------------------------------------------------------------
151
+ * Constants
152
+ * ------------------------------------------------------------------------
153
+ */
110
154
 
111
- _proto._triggerCloseEvent = function _triggerCloseEvent(element) {
112
- var closeEvent = $.Event(Event.CLOSE);
113
- $(element).trigger(closeEvent);
114
- return closeEvent;
115
- };
155
+ const NAME = 'alert';
156
+ const DATA_KEY = 'bs.alert';
157
+ const EVENT_KEY = `.${DATA_KEY}`;
158
+ const EVENT_CLOSE = `close${EVENT_KEY}`;
159
+ const EVENT_CLOSED = `closed${EVENT_KEY}`;
160
+ const CLASS_NAME_FADE = 'fade';
161
+ const CLASS_NAME_SHOW = 'show';
162
+ /**
163
+ * ------------------------------------------------------------------------
164
+ * Class Definition
165
+ * ------------------------------------------------------------------------
166
+ */
116
167
 
117
- _proto._removeElement = function _removeElement(element) {
118
- var _this = this;
168
+ class Alert extends BaseComponent__default.default {
169
+ // Getters
170
+ static get NAME() {
171
+ return NAME;
172
+ } // Public
119
173
 
120
- $(element).removeClass(ClassName.SHOW);
121
174
 
122
- if (!$(element).hasClass(ClassName.FADE)) {
123
- this._destroyElement(element);
175
+ close() {
176
+ const closeEvent = EventHandler__default.default.trigger(this._element, EVENT_CLOSE);
124
177
 
178
+ if (closeEvent.defaultPrevented) {
125
179
  return;
126
180
  }
127
181
 
128
- var transitionDuration = Util.getTransitionDurationFromElement(element);
129
- $(element).one(Util.TRANSITION_END, function (event) {
130
- return _this._destroyElement(element, event);
131
- }).emulateTransitionEnd(transitionDuration);
132
- };
182
+ this._element.classList.remove(CLASS_NAME_SHOW);
133
183
 
134
- _proto._destroyElement = function _destroyElement(element) {
135
- $(element).detach().trigger(Event.CLOSED).remove();
184
+ const isAnimated = this._element.classList.contains(CLASS_NAME_FADE);
185
+
186
+ this._queueCallback(() => this._destroyElement(), this._element, isAnimated);
187
+ } // Private
188
+
189
+
190
+ _destroyElement() {
191
+ this._element.remove();
192
+
193
+ EventHandler__default.default.trigger(this._element, EVENT_CLOSED);
194
+ this.dispose();
136
195
  } // Static
137
- ;
138
196
 
139
- Alert._jQueryInterface = function _jQueryInterface(config) {
140
- return this.each(function () {
141
- var $element = $(this);
142
- var data = $element.data(DATA_KEY);
143
197
 
144
- if (!data) {
145
- data = new Alert(this);
146
- $element.data(DATA_KEY, data);
147
- }
198
+ static jQueryInterface(config) {
199
+ return this.each(function () {
200
+ const data = Alert.getOrCreateInstance(this);
148
201
 
149
- if (config === 'close') {
150
- data[config](this);
202
+ if (typeof config !== 'string') {
203
+ return;
151
204
  }
152
- });
153
- };
154
205
 
155
- Alert._handleDismiss = function _handleDismiss(alertInstance) {
156
- return function (event) {
157
- if (event) {
158
- event.preventDefault();
206
+ if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
207
+ throw new TypeError(`No method named "${config}"`);
159
208
  }
160
209
 
161
- alertInstance.close(this);
162
- };
163
- };
164
-
165
- _createClass(Alert, null, [{
166
- key: "VERSION",
167
- get: function get() {
168
- return VERSION;
169
- }
170
- }]);
210
+ data[config](this);
211
+ });
212
+ }
171
213
 
172
- return Alert;
173
- }();
214
+ }
174
215
  /**
175
216
  * ------------------------------------------------------------------------
176
217
  * Data Api implementation
@@ -178,20 +219,15 @@
178
219
  */
179
220
 
180
221
 
181
- $(document).on(Event.CLICK_DATA_API, Selector.DISMISS, Alert._handleDismiss(new Alert()));
222
+ enableDismissTrigger(Alert, 'close');
182
223
  /**
183
224
  * ------------------------------------------------------------------------
184
225
  * jQuery
185
226
  * ------------------------------------------------------------------------
227
+ * add .Alert to jQuery only if jQuery is present
186
228
  */
187
229
 
188
- $.fn[NAME] = Alert._jQueryInterface;
189
- $.fn[NAME].Constructor = Alert;
190
-
191
- $.fn[NAME].noConflict = function () {
192
- $.fn[NAME] = JQUERY_NO_CONFLICT;
193
- return Alert._jQueryInterface;
194
- };
230
+ defineJQueryPlugin(Alert);
195
231
 
196
232
  return Alert;
197
233
 
@@ -0,0 +1,182 @@
1
+ /*!
2
+ * Bootstrap base-component.js 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('./dom/data.js'), require('./dom/event-handler.js')) :
8
+ typeof define === 'function' && define.amd ? define(['./dom/data', './dom/event-handler'], factory) :
9
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Base = factory(global.Data, global.EventHandler));
10
+ })(this, (function (Data, EventHandler) { 'use strict';
11
+
12
+ const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e };
13
+
14
+ const Data__default = /*#__PURE__*/_interopDefaultLegacy(Data);
15
+ const EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler);
16
+
17
+ /**
18
+ * --------------------------------------------------------------------------
19
+ * Bootstrap (v5.1.3): util/index.js
20
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
21
+ * --------------------------------------------------------------------------
22
+ */
23
+ const MILLISECONDS_MULTIPLIER = 1000;
24
+ const TRANSITION_END = 'transitionend'; // Shoutout AngusCroll (https://goo.gl/pxwQGp)
25
+
26
+ const getTransitionDurationFromElement = element => {
27
+ if (!element) {
28
+ return 0;
29
+ } // Get transition-duration of the element
30
+
31
+
32
+ let {
33
+ transitionDuration,
34
+ transitionDelay
35
+ } = window.getComputedStyle(element);
36
+ const floatTransitionDuration = Number.parseFloat(transitionDuration);
37
+ const floatTransitionDelay = Number.parseFloat(transitionDelay); // Return 0 if element or transition duration is not found
38
+
39
+ if (!floatTransitionDuration && !floatTransitionDelay) {
40
+ return 0;
41
+ } // If multiple durations are defined, take the first
42
+
43
+
44
+ transitionDuration = transitionDuration.split(',')[0];
45
+ transitionDelay = transitionDelay.split(',')[0];
46
+ return (Number.parseFloat(transitionDuration) + Number.parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER;
47
+ };
48
+
49
+ const triggerTransitionEnd = element => {
50
+ element.dispatchEvent(new Event(TRANSITION_END));
51
+ };
52
+
53
+ const isElement = obj => {
54
+ if (!obj || typeof obj !== 'object') {
55
+ return false;
56
+ }
57
+
58
+ if (typeof obj.jquery !== 'undefined') {
59
+ obj = obj[0];
60
+ }
61
+
62
+ return typeof obj.nodeType !== 'undefined';
63
+ };
64
+
65
+ const getElement = obj => {
66
+ if (isElement(obj)) {
67
+ // it's a jQuery object or a node element
68
+ return obj.jquery ? obj[0] : obj;
69
+ }
70
+
71
+ if (typeof obj === 'string' && obj.length > 0) {
72
+ return document.querySelector(obj);
73
+ }
74
+
75
+ return null;
76
+ };
77
+
78
+ const execute = callback => {
79
+ if (typeof callback === 'function') {
80
+ callback();
81
+ }
82
+ };
83
+
84
+ const executeAfterTransition = (callback, transitionElement, waitForTransition = true) => {
85
+ if (!waitForTransition) {
86
+ execute(callback);
87
+ return;
88
+ }
89
+
90
+ const durationPadding = 5;
91
+ const emulatedDuration = getTransitionDurationFromElement(transitionElement) + durationPadding;
92
+ let called = false;
93
+
94
+ const handler = ({
95
+ target
96
+ }) => {
97
+ if (target !== transitionElement) {
98
+ return;
99
+ }
100
+
101
+ called = true;
102
+ transitionElement.removeEventListener(TRANSITION_END, handler);
103
+ execute(callback);
104
+ };
105
+
106
+ transitionElement.addEventListener(TRANSITION_END, handler);
107
+ setTimeout(() => {
108
+ if (!called) {
109
+ triggerTransitionEnd(transitionElement);
110
+ }
111
+ }, emulatedDuration);
112
+ };
113
+
114
+ /**
115
+ * --------------------------------------------------------------------------
116
+ * Bootstrap (v5.1.3): base-component.js
117
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
118
+ * --------------------------------------------------------------------------
119
+ */
120
+ /**
121
+ * ------------------------------------------------------------------------
122
+ * Constants
123
+ * ------------------------------------------------------------------------
124
+ */
125
+
126
+ const VERSION = '5.1.3';
127
+
128
+ class BaseComponent {
129
+ constructor(element) {
130
+ element = getElement(element);
131
+
132
+ if (!element) {
133
+ return;
134
+ }
135
+
136
+ this._element = element;
137
+ Data__default.default.set(this._element, this.constructor.DATA_KEY, this);
138
+ }
139
+
140
+ dispose() {
141
+ Data__default.default.remove(this._element, this.constructor.DATA_KEY);
142
+ EventHandler__default.default.off(this._element, this.constructor.EVENT_KEY);
143
+ Object.getOwnPropertyNames(this).forEach(propertyName => {
144
+ this[propertyName] = null;
145
+ });
146
+ }
147
+
148
+ _queueCallback(callback, element, isAnimated = true) {
149
+ executeAfterTransition(callback, element, isAnimated);
150
+ }
151
+ /** Static */
152
+
153
+
154
+ static getInstance(element) {
155
+ return Data__default.default.get(getElement(element), this.DATA_KEY);
156
+ }
157
+
158
+ static getOrCreateInstance(element, config = {}) {
159
+ return this.getInstance(element) || new this(element, typeof config === 'object' ? config : null);
160
+ }
161
+
162
+ static get VERSION() {
163
+ return VERSION;
164
+ }
165
+
166
+ static get NAME() {
167
+ throw new Error('You have to implement the static method "NAME", for each component!');
168
+ }
169
+
170
+ static get DATA_KEY() {
171
+ return `bs.${this.NAME}`;
172
+ }
173
+
174
+ static get EVENT_KEY() {
175
+ return `.${this.DATA_KEY}`;
176
+ }
177
+
178
+ }
179
+
180
+ return BaseComponent;
181
+
182
+ }));