bootstrap 4.3.0 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 +173 -137
  6. data/assets/javascripts/bootstrap/base-component.js +182 -0
  7. data/assets/javascripts/bootstrap/button.js +102 -143
  8. data/assets/javascripts/bootstrap/carousel.js +481 -410
  9. data/assets/javascripts/bootstrap/collapse.js +340 -274
  10. data/assets/javascripts/bootstrap/dom/data.js +68 -0
  11. data/assets/javascripts/bootstrap/dom/event-handler.js +322 -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 +494 -400
  15. data/assets/javascripts/bootstrap/modal.js +834 -450
  16. data/assets/javascripts/bootstrap/offcanvas.js +866 -0
  17. data/assets/javascripts/bootstrap/popover.js +122 -199
  18. data/assets/javascripts/bootstrap/scrollspy.js +257 -241
  19. data/assets/javascripts/bootstrap/tab.js +219 -155
  20. data/assets/javascripts/bootstrap/toast.js +330 -190
  21. data/assets/javascripts/bootstrap/tooltip.js +710 -472
  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 +3547 -2809
  26. data/assets/javascripts/bootstrap.min.js +4 -4
  27. data/assets/stylesheets/_bootstrap-grid.scss +54 -18
  28. data/assets/stylesheets/_bootstrap-reboot.scss +7 -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 +237 -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 +42 -8
  58. data/assets/stylesheets/bootstrap/_spinners.scss +21 -7
  59. data/assets/stylesheets/bootstrap/_tables.scss +80 -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 +993 -487
  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 +70 -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 +131 -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 +274 -132
  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
@@ -1,282 +1,422 @@
1
1
  /*!
2
- * Bootstrap toast.js v4.3.0 (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 toast.js v5.1.0 (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.Toast = 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);
7
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/event-handler.js'), require('./dom/manipulator.js'), require('./base-component.js')) :
8
+ typeof define === 'function' && define.amd ? define(['./dom/event-handler', './dom/manipulator', './base-component'], factory) :
9
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Toast = factory(global.EventHandler, global.Manipulator, global.Base));
10
+ }(this, (function (EventHandler, Manipulator, BaseComponent) { 'use strict';
11
+
12
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
+
14
+ var EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler);
15
+ var Manipulator__default = /*#__PURE__*/_interopDefaultLegacy(Manipulator);
16
+ var BaseComponent__default = /*#__PURE__*/_interopDefaultLegacy(BaseComponent);
17
+
18
+ /**
19
+ * --------------------------------------------------------------------------
20
+ * Bootstrap (v5.1.0): util/index.js
21
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
22
+ * --------------------------------------------------------------------------
23
+ */
24
+
25
+ const toType = obj => {
26
+ if (obj === null || obj === undefined) {
27
+ return `${obj}`;
22
28
  }
23
- }
24
29
 
25
- function _createClass(Constructor, protoProps, staticProps) {
26
- if (protoProps) _defineProperties(Constructor.prototype, protoProps);
27
- if (staticProps) _defineProperties(Constructor, staticProps);
28
- return Constructor;
29
- }
30
+ return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase();
31
+ };
30
32
 
31
- function _defineProperty(obj, key, value) {
32
- if (key in obj) {
33
- Object.defineProperty(obj, key, {
34
- value: value,
35
- enumerable: true,
36
- configurable: true,
37
- writable: true
38
- });
39
- } else {
40
- obj[key] = value;
33
+ const getSelector = element => {
34
+ let selector = element.getAttribute('data-bs-target');
35
+
36
+ if (!selector || selector === '#') {
37
+ let hrefAttr = element.getAttribute('href'); // The only valid content that could double as a selector are IDs or classes,
38
+ // so everything starting with `#` or `.`. If a "real" URL is used as the selector,
39
+ // `document.querySelector` will rightfully complain it is invalid.
40
+ // See https://github.com/twbs/bootstrap/issues/32273
41
+
42
+ if (!hrefAttr || !hrefAttr.includes('#') && !hrefAttr.startsWith('.')) {
43
+ return null;
44
+ } // Just in case some CMS puts out a full URL with the anchor appended
45
+
46
+
47
+ if (hrefAttr.includes('#') && !hrefAttr.startsWith('#')) {
48
+ hrefAttr = `#${hrefAttr.split('#')[1]}`;
49
+ }
50
+
51
+ selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : null;
41
52
  }
42
53
 
43
- return obj;
44
- }
54
+ return selector;
55
+ };
56
+
57
+ const getElementFromSelector = element => {
58
+ const selector = getSelector(element);
59
+ return selector ? document.querySelector(selector) : null;
60
+ };
61
+
62
+ const isElement = obj => {
63
+ if (!obj || typeof obj !== 'object') {
64
+ return false;
65
+ }
66
+
67
+ if (typeof obj.jquery !== 'undefined') {
68
+ obj = obj[0];
69
+ }
70
+
71
+ return typeof obj.nodeType !== 'undefined';
72
+ };
45
73
 
46
- function _objectSpread(target) {
47
- for (var i = 1; i < arguments.length; i++) {
48
- var source = arguments[i] != null ? arguments[i] : {};
49
- var ownKeys = Object.keys(source);
74
+ const typeCheckConfig = (componentName, config, configTypes) => {
75
+ Object.keys(configTypes).forEach(property => {
76
+ const expectedTypes = configTypes[property];
77
+ const value = config[property];
78
+ const valueType = value && isElement(value) ? 'element' : toType(value);
50
79
 
51
- if (typeof Object.getOwnPropertySymbols === 'function') {
52
- ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) {
53
- return Object.getOwnPropertyDescriptor(source, sym).enumerable;
54
- }));
80
+ if (!new RegExp(expectedTypes).test(valueType)) {
81
+ throw new TypeError(`${componentName.toUpperCase()}: Option "${property}" provided type "${valueType}" but expected type "${expectedTypes}".`);
55
82
  }
83
+ });
84
+ };
56
85
 
57
- ownKeys.forEach(function (key) {
58
- _defineProperty(target, key, source[key]);
59
- });
86
+ const isDisabled = element => {
87
+ if (!element || element.nodeType !== Node.ELEMENT_NODE) {
88
+ return true;
60
89
  }
61
90
 
62
- return target;
63
- }
91
+ if (element.classList.contains('disabled')) {
92
+ return true;
93
+ }
64
94
 
95
+ if (typeof element.disabled !== 'undefined') {
96
+ return element.disabled;
97
+ }
98
+
99
+ return element.hasAttribute('disabled') && element.getAttribute('disabled') !== 'false';
100
+ };
101
+ /**
102
+ * Trick to restart an element's animation
103
+ *
104
+ * @param {HTMLElement} element
105
+ * @return void
106
+ *
107
+ * @see https://www.charistheo.io/blog/2021/02/restart-a-css-animation-with-javascript/#restarting-a-css-animation
108
+ */
109
+
110
+
111
+ const reflow = element => {
112
+ // eslint-disable-next-line no-unused-expressions
113
+ element.offsetHeight;
114
+ };
115
+
116
+ const getjQuery = () => {
117
+ const {
118
+ jQuery
119
+ } = window;
120
+
121
+ if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) {
122
+ return jQuery;
123
+ }
124
+
125
+ return null;
126
+ };
127
+
128
+ const DOMContentLoadedCallbacks = [];
129
+
130
+ const onDOMContentLoaded = callback => {
131
+ if (document.readyState === 'loading') {
132
+ // add listener on the first call when the document is in loading state
133
+ if (!DOMContentLoadedCallbacks.length) {
134
+ document.addEventListener('DOMContentLoaded', () => {
135
+ DOMContentLoadedCallbacks.forEach(callback => callback());
136
+ });
137
+ }
138
+
139
+ DOMContentLoadedCallbacks.push(callback);
140
+ } else {
141
+ callback();
142
+ }
143
+ };
144
+
145
+ const defineJQueryPlugin = plugin => {
146
+ onDOMContentLoaded(() => {
147
+ const $ = getjQuery();
148
+ /* istanbul ignore if */
149
+
150
+ if ($) {
151
+ const name = plugin.NAME;
152
+ const JQUERY_NO_CONFLICT = $.fn[name];
153
+ $.fn[name] = plugin.jQueryInterface;
154
+ $.fn[name].Constructor = plugin;
155
+
156
+ $.fn[name].noConflict = () => {
157
+ $.fn[name] = JQUERY_NO_CONFLICT;
158
+ return plugin.jQueryInterface;
159
+ };
160
+ }
161
+ });
162
+ };
163
+
164
+ /**
165
+ * --------------------------------------------------------------------------
166
+ * Bootstrap (v5.1.0): util/component-functions.js
167
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
168
+ * --------------------------------------------------------------------------
169
+ */
170
+
171
+ const enableDismissTrigger = (component, method = 'hide') => {
172
+ const clickEvent = `click.dismiss${component.EVENT_KEY}`;
173
+ const name = component.NAME;
174
+ EventHandler__default['default'].on(document, clickEvent, `[data-bs-dismiss="${name}"]`, function (event) {
175
+ if (['A', 'AREA'].includes(this.tagName)) {
176
+ event.preventDefault();
177
+ }
178
+
179
+ if (isDisabled(this)) {
180
+ return;
181
+ }
182
+
183
+ const target = getElementFromSelector(this) || this.closest(`.${name}`);
184
+ const instance = component.getOrCreateInstance(target); // Method argument is left, for Alert and only, as it doesn't implement the 'hide' method
185
+
186
+ instance[method]();
187
+ });
188
+ };
189
+
190
+ /**
191
+ * --------------------------------------------------------------------------
192
+ * Bootstrap (v5.1.0): toast.js
193
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
194
+ * --------------------------------------------------------------------------
195
+ */
65
196
  /**
66
197
  * ------------------------------------------------------------------------
67
198
  * Constants
68
199
  * ------------------------------------------------------------------------
69
200
  */
70
201
 
71
- var NAME = 'toast';
72
- var VERSION = '4.3.0';
73
- var DATA_KEY = 'bs.toast';
74
- var EVENT_KEY = "." + DATA_KEY;
75
- var JQUERY_NO_CONFLICT = $.fn[NAME];
76
- var Event = {
77
- CLICK_DISMISS: "click.dismiss" + EVENT_KEY,
78
- HIDE: "hide" + EVENT_KEY,
79
- HIDDEN: "hidden" + EVENT_KEY,
80
- SHOW: "show" + EVENT_KEY,
81
- SHOWN: "shown" + EVENT_KEY
82
- };
83
- var ClassName = {
84
- FADE: 'fade',
85
- HIDE: 'hide',
86
- SHOW: 'show',
87
- SHOWING: 'showing'
88
- };
89
- var DefaultType = {
202
+ const NAME = 'toast';
203
+ const DATA_KEY = 'bs.toast';
204
+ const EVENT_KEY = `.${DATA_KEY}`;
205
+ const EVENT_MOUSEOVER = `mouseover${EVENT_KEY}`;
206
+ const EVENT_MOUSEOUT = `mouseout${EVENT_KEY}`;
207
+ const EVENT_FOCUSIN = `focusin${EVENT_KEY}`;
208
+ const EVENT_FOCUSOUT = `focusout${EVENT_KEY}`;
209
+ const EVENT_HIDE = `hide${EVENT_KEY}`;
210
+ const EVENT_HIDDEN = `hidden${EVENT_KEY}`;
211
+ const EVENT_SHOW = `show${EVENT_KEY}`;
212
+ const EVENT_SHOWN = `shown${EVENT_KEY}`;
213
+ const CLASS_NAME_FADE = 'fade';
214
+ const CLASS_NAME_HIDE = 'hide'; // @deprecated - kept here only for backwards compatibility
215
+
216
+ const CLASS_NAME_SHOW = 'show';
217
+ const CLASS_NAME_SHOWING = 'showing';
218
+ const DefaultType = {
90
219
  animation: 'boolean',
91
220
  autohide: 'boolean',
92
221
  delay: 'number'
93
222
  };
94
- var Default = {
223
+ const Default = {
95
224
  animation: true,
96
225
  autohide: true,
97
- delay: 500
98
- };
99
- var Selector = {
100
- DATA_DISMISS: '[data-dismiss="toast"]'
101
- /**
102
- * ------------------------------------------------------------------------
103
- * Class Definition
104
- * ------------------------------------------------------------------------
105
- */
106
-
226
+ delay: 5000
107
227
  };
228
+ /**
229
+ * ------------------------------------------------------------------------
230
+ * Class Definition
231
+ * ------------------------------------------------------------------------
232
+ */
108
233
 
109
- var Toast =
110
- /*#__PURE__*/
111
- function () {
112
- function Toast(element, config) {
113
- this._element = element;
234
+ class Toast extends BaseComponent__default['default'] {
235
+ constructor(element, config) {
236
+ super(element);
114
237
  this._config = this._getConfig(config);
115
238
  this._timeout = null;
239
+ this._hasMouseInteraction = false;
240
+ this._hasKeyboardInteraction = false;
116
241
 
117
242
  this._setListeners();
118
243
  } // Getters
119
244
 
120
245
 
121
- var _proto = Toast.prototype;
246
+ static get DefaultType() {
247
+ return DefaultType;
248
+ }
249
+
250
+ static get Default() {
251
+ return Default;
252
+ }
253
+
254
+ static get NAME() {
255
+ return NAME;
256
+ } // Public
122
257
 
123
- // Public
124
- _proto.show = function show() {
125
- var _this = this;
126
258
 
127
- $(this._element).trigger(Event.SHOW);
259
+ show() {
260
+ const showEvent = EventHandler__default['default'].trigger(this._element, EVENT_SHOW);
128
261
 
129
- if (this._config.animation) {
130
- this._element.classList.add(ClassName.FADE);
262
+ if (showEvent.defaultPrevented) {
263
+ return;
131
264
  }
132
265
 
133
- var complete = function complete() {
134
- _this._element.classList.remove(ClassName.SHOWING);
266
+ this._clearTimeout();
135
267
 
136
- _this._element.classList.add(ClassName.SHOW);
268
+ if (this._config.animation) {
269
+ this._element.classList.add(CLASS_NAME_FADE);
270
+ }
137
271
 
138
- $(_this._element).trigger(Event.SHOWN);
272
+ const complete = () => {
273
+ this._element.classList.remove(CLASS_NAME_SHOWING);
139
274
 
140
- if (_this._config.autohide) {
141
- _this.hide();
142
- }
275
+ EventHandler__default['default'].trigger(this._element, EVENT_SHOWN);
276
+
277
+ this._maybeScheduleHide();
143
278
  };
144
279
 
145
- this._element.classList.remove(ClassName.HIDE);
280
+ this._element.classList.remove(CLASS_NAME_HIDE); // @deprecated
146
281
 
147
- this._element.classList.add(ClassName.SHOWING);
148
282
 
149
- if (this._config.animation) {
150
- var transitionDuration = Util.getTransitionDurationFromElement(this._element);
151
- $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
152
- } else {
153
- complete();
154
- }
155
- };
283
+ reflow(this._element);
284
+
285
+ this._element.classList.add(CLASS_NAME_SHOW);
156
286
 
157
- _proto.hide = function hide(withoutTimeout) {
158
- var _this2 = this;
287
+ this._element.classList.add(CLASS_NAME_SHOWING);
159
288
 
160
- if (!this._element.classList.contains(ClassName.SHOW)) {
289
+ this._queueCallback(complete, this._element, this._config.animation);
290
+ }
291
+
292
+ hide() {
293
+ if (!this._element.classList.contains(CLASS_NAME_SHOW)) {
161
294
  return;
162
295
  }
163
296
 
164
- $(this._element).trigger(Event.HIDE);
297
+ const hideEvent = EventHandler__default['default'].trigger(this._element, EVENT_HIDE);
165
298
 
166
- if (withoutTimeout) {
167
- this._close();
168
- } else {
169
- this._timeout = setTimeout(function () {
170
- _this2._close();
171
- }, this._config.delay);
299
+ if (hideEvent.defaultPrevented) {
300
+ return;
172
301
  }
173
- };
174
302
 
175
- _proto.dispose = function dispose() {
176
- clearTimeout(this._timeout);
177
- this._timeout = null;
303
+ const complete = () => {
304
+ this._element.classList.add(CLASS_NAME_HIDE); // @deprecated
305
+
306
+
307
+ this._element.classList.remove(CLASS_NAME_SHOWING);
178
308
 
179
- if (this._element.classList.contains(ClassName.SHOW)) {
180
- this._element.classList.remove(ClassName.SHOW);
309
+ this._element.classList.remove(CLASS_NAME_SHOW);
310
+
311
+ EventHandler__default['default'].trigger(this._element, EVENT_HIDDEN);
312
+ };
313
+
314
+ this._element.classList.add(CLASS_NAME_SHOWING);
315
+
316
+ this._queueCallback(complete, this._element, this._config.animation);
317
+ }
318
+
319
+ dispose() {
320
+ this._clearTimeout();
321
+
322
+ if (this._element.classList.contains(CLASS_NAME_SHOW)) {
323
+ this._element.classList.remove(CLASS_NAME_SHOW);
181
324
  }
182
325
 
183
- $(this._element).off(Event.CLICK_DISMISS);
184
- $.removeData(this._element, DATA_KEY);
185
- this._element = null;
186
- this._config = null;
326
+ super.dispose();
187
327
  } // Private
188
- ;
189
328
 
190
- _proto._getConfig = function _getConfig(config) {
191
- config = _objectSpread({}, Default, $(this._element).data(), typeof config === 'object' && config ? config : {});
192
- Util.typeCheckConfig(NAME, config, this.constructor.DefaultType);
329
+
330
+ _getConfig(config) {
331
+ config = { ...Default,
332
+ ...Manipulator__default['default'].getDataAttributes(this._element),
333
+ ...(typeof config === 'object' && config ? config : {})
334
+ };
335
+ typeCheckConfig(NAME, config, this.constructor.DefaultType);
193
336
  return config;
194
- };
337
+ }
195
338
 
196
- _proto._setListeners = function _setListeners() {
197
- var _this3 = this;
339
+ _maybeScheduleHide() {
340
+ if (!this._config.autohide) {
341
+ return;
342
+ }
198
343
 
199
- $(this._element).on(Event.CLICK_DISMISS, Selector.DATA_DISMISS, function () {
200
- return _this3.hide(true);
201
- });
202
- };
344
+ if (this._hasMouseInteraction || this._hasKeyboardInteraction) {
345
+ return;
346
+ }
203
347
 
204
- _proto._close = function _close() {
205
- var _this4 = this;
348
+ this._timeout = setTimeout(() => {
349
+ this.hide();
350
+ }, this._config.delay);
351
+ }
206
352
 
207
- var complete = function complete() {
208
- _this4._element.classList.add(ClassName.HIDE);
353
+ _onInteraction(event, isInteracting) {
354
+ switch (event.type) {
355
+ case 'mouseover':
356
+ case 'mouseout':
357
+ this._hasMouseInteraction = isInteracting;
358
+ break;
359
+
360
+ case 'focusin':
361
+ case 'focusout':
362
+ this._hasKeyboardInteraction = isInteracting;
363
+ break;
364
+ }
209
365
 
210
- $(_this4._element).trigger(Event.HIDDEN);
211
- };
366
+ if (isInteracting) {
367
+ this._clearTimeout();
212
368
 
213
- this._element.classList.remove(ClassName.SHOW);
369
+ return;
370
+ }
214
371
 
215
- if (this._config.animation) {
216
- var transitionDuration = Util.getTransitionDurationFromElement(this._element);
217
- $(this._element).one(Util.TRANSITION_END, complete).emulateTransitionEnd(transitionDuration);
218
- } else {
219
- complete();
372
+ const nextElement = event.relatedTarget;
373
+
374
+ if (this._element === nextElement || this._element.contains(nextElement)) {
375
+ return;
220
376
  }
221
- } // Static
222
- ;
223
377
 
224
- Toast._jQueryInterface = function _jQueryInterface(config) {
225
- return this.each(function () {
226
- var $element = $(this);
227
- var data = $element.data(DATA_KEY);
378
+ this._maybeScheduleHide();
379
+ }
228
380
 
229
- var _config = typeof config === 'object' && config;
381
+ _setListeners() {
382
+ EventHandler__default['default'].on(this._element, EVENT_MOUSEOVER, event => this._onInteraction(event, true));
383
+ EventHandler__default['default'].on(this._element, EVENT_MOUSEOUT, event => this._onInteraction(event, false));
384
+ EventHandler__default['default'].on(this._element, EVENT_FOCUSIN, event => this._onInteraction(event, true));
385
+ EventHandler__default['default'].on(this._element, EVENT_FOCUSOUT, event => this._onInteraction(event, false));
386
+ }
230
387
 
231
- if (!data) {
232
- data = new Toast(this, _config);
233
- $element.data(DATA_KEY, data);
234
- }
388
+ _clearTimeout() {
389
+ clearTimeout(this._timeout);
390
+ this._timeout = null;
391
+ } // Static
392
+
393
+
394
+ static jQueryInterface(config) {
395
+ return this.each(function () {
396
+ const data = Toast.getOrCreateInstance(this, config);
235
397
 
236
398
  if (typeof config === 'string') {
237
399
  if (typeof data[config] === 'undefined') {
238
- throw new TypeError("No method named \"" + config + "\"");
400
+ throw new TypeError(`No method named "${config}"`);
239
401
  }
240
402
 
241
403
  data[config](this);
242
404
  }
243
405
  });
244
- };
406
+ }
245
407
 
246
- _createClass(Toast, null, [{
247
- key: "VERSION",
248
- get: function get() {
249
- return VERSION;
250
- }
251
- }, {
252
- key: "DefaultType",
253
- get: function get() {
254
- return DefaultType;
255
- }
256
- }, {
257
- key: "Default",
258
- get: function get() {
259
- return Default;
260
- }
261
- }]);
408
+ }
262
409
 
263
- return Toast;
264
- }();
410
+ enableDismissTrigger(Toast);
265
411
  /**
266
412
  * ------------------------------------------------------------------------
267
413
  * jQuery
268
414
  * ------------------------------------------------------------------------
415
+ * add .Toast to jQuery only if jQuery is present
269
416
  */
270
417
 
271
-
272
- $.fn[NAME] = Toast._jQueryInterface;
273
- $.fn[NAME].Constructor = Toast;
274
-
275
- $.fn[NAME].noConflict = function () {
276
- $.fn[NAME] = JQUERY_NO_CONFLICT;
277
- return Toast._jQueryInterface;
278
- };
418
+ defineJQueryPlugin(Toast);
279
419
 
280
420
  return Toast;
281
421
 
282
- }));
422
+ })));