bootstrap 5.2.0 → 5.3.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 (95) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +55 -0
  3. data/README.md +25 -5
  4. data/assets/javascripts/bootstrap/alert.js +22 -32
  5. data/assets/javascripts/bootstrap/base-component.js +22 -38
  6. data/assets/javascripts/bootstrap/button.js +19 -22
  7. data/assets/javascripts/bootstrap/carousel.js +52 -135
  8. data/assets/javascripts/bootstrap/collapse.js +40 -102
  9. data/assets/javascripts/bootstrap/dom/data.js +8 -12
  10. data/assets/javascripts/bootstrap/dom/event-handler.js +19 -66
  11. data/assets/javascripts/bootstrap/dom/manipulator.js +4 -17
  12. data/assets/javascripts/bootstrap/dom/selector-engine.js +42 -24
  13. data/assets/javascripts/bootstrap/dropdown.js +74 -143
  14. data/assets/javascripts/bootstrap/modal.js +66 -143
  15. data/assets/javascripts/bootstrap/offcanvas.js +50 -102
  16. data/assets/javascripts/bootstrap/popover.js +23 -29
  17. data/assets/javascripts/bootstrap/scrollspy.js +64 -97
  18. data/assets/javascripts/bootstrap/tab.js +55 -112
  19. data/assets/javascripts/bootstrap/toast.js +39 -77
  20. data/assets/javascripts/bootstrap/tooltip.js +99 -216
  21. data/assets/javascripts/bootstrap/util/backdrop.js +28 -54
  22. data/assets/javascripts/bootstrap/util/component-functions.js +13 -18
  23. data/assets/javascripts/bootstrap/util/config.js +15 -27
  24. data/assets/javascripts/bootstrap/util/focustrap.js +20 -36
  25. data/assets/javascripts/bootstrap/util/index.js +42 -111
  26. data/assets/javascripts/bootstrap/util/sanitizer.js +30 -42
  27. data/assets/javascripts/bootstrap/util/scrollbar.js +24 -50
  28. data/assets/javascripts/bootstrap/util/swipe.js +27 -48
  29. data/assets/javascripts/bootstrap/util/template-factory.js +25 -52
  30. data/assets/javascripts/bootstrap-sprockets.js +12 -12
  31. data/assets/javascripts/bootstrap.js +764 -1529
  32. data/assets/javascripts/bootstrap.min.js +3 -3
  33. data/assets/stylesheets/_bootstrap-grid.scss +1 -3
  34. data/assets/stylesheets/_bootstrap-reboot.scss +1 -0
  35. data/assets/stylesheets/_bootstrap.scss +1 -0
  36. data/assets/stylesheets/bootstrap/_accordion.scss +16 -4
  37. data/assets/stylesheets/bootstrap/_alert.scss +8 -11
  38. data/assets/stylesheets/bootstrap/_button-group.scss +3 -3
  39. data/assets/stylesheets/bootstrap/_buttons.scss +31 -10
  40. data/assets/stylesheets/bootstrap/_card.scss +5 -0
  41. data/assets/stylesheets/bootstrap/_carousel.scss +20 -5
  42. data/assets/stylesheets/bootstrap/_close.scss +32 -9
  43. data/assets/stylesheets/bootstrap/_dropdown.scss +3 -1
  44. data/assets/stylesheets/bootstrap/_functions.scss +3 -3
  45. data/assets/stylesheets/bootstrap/_grid.scss +6 -0
  46. data/assets/stylesheets/bootstrap/_helpers.scss +2 -0
  47. data/assets/stylesheets/bootstrap/_list-group.scss +18 -12
  48. data/assets/stylesheets/bootstrap/_maps.scss +120 -0
  49. data/assets/stylesheets/bootstrap/_mixins.scss +1 -2
  50. data/assets/stylesheets/bootstrap/_modal.scss +1 -1
  51. data/assets/stylesheets/bootstrap/_nav.scss +42 -5
  52. data/assets/stylesheets/bootstrap/_navbar.scss +17 -4
  53. data/assets/stylesheets/bootstrap/_offcanvas.scss +9 -6
  54. data/assets/stylesheets/bootstrap/_pagination.scss +1 -1
  55. data/assets/stylesheets/bootstrap/_popover.scss +5 -5
  56. data/assets/stylesheets/bootstrap/_progress.scss +10 -1
  57. data/assets/stylesheets/bootstrap/_reboot.scss +3 -3
  58. data/assets/stylesheets/bootstrap/_root.scss +121 -10
  59. data/assets/stylesheets/bootstrap/_tables.scss +18 -11
  60. data/assets/stylesheets/bootstrap/_toasts.scss +5 -2
  61. data/assets/stylesheets/bootstrap/_tooltip.scss +4 -5
  62. data/assets/stylesheets/bootstrap/_utilities.scss +172 -13
  63. data/assets/stylesheets/bootstrap/_variables-dark.scss +85 -0
  64. data/assets/stylesheets/bootstrap/_variables.scss +272 -162
  65. data/assets/stylesheets/bootstrap/bootstrap-utilities.scss +4 -0
  66. data/assets/stylesheets/bootstrap/forms/_floating-labels.scss +23 -3
  67. data/assets/stylesheets/bootstrap/forms/_form-check.scss +24 -11
  68. data/assets/stylesheets/bootstrap/forms/_form-control.scss +23 -3
  69. data/assets/stylesheets/bootstrap/forms/_form-select.scss +11 -2
  70. data/assets/stylesheets/bootstrap/forms/_input-group.scss +7 -4
  71. data/assets/stylesheets/bootstrap/helpers/_color-bg.scss +0 -2
  72. data/assets/stylesheets/bootstrap/helpers/_colored-links.scss +20 -2
  73. data/assets/stylesheets/bootstrap/helpers/_focus-ring.scss +5 -0
  74. data/assets/stylesheets/bootstrap/helpers/_icon-link.scss +25 -0
  75. data/assets/stylesheets/bootstrap/mixins/_alert.scss +4 -1
  76. data/assets/stylesheets/bootstrap/mixins/_banner.scss +3 -5
  77. data/assets/stylesheets/bootstrap/mixins/_caret.scss +30 -25
  78. data/assets/stylesheets/bootstrap/mixins/_color-mode.scss +21 -0
  79. data/assets/stylesheets/bootstrap/mixins/_forms.scss +18 -17
  80. data/assets/stylesheets/bootstrap/mixins/_list-group.scss +2 -0
  81. data/assets/stylesheets/bootstrap/mixins/_table-variants.scss +2 -2
  82. data/assets/stylesheets/bootstrap/mixins/_utilities.scss +2 -2
  83. data/assets/stylesheets/bootstrap/mixins/_visually-hidden.scss +5 -1
  84. data/assets/stylesheets/bootstrap/vendor/_rfs.scss +23 -29
  85. data/bootstrap.gemspec +1 -1
  86. data/lib/bootstrap/version.rb +2 -2
  87. data/tasks/updater/js.rb +2 -2
  88. data/tasks/updater/network.rb +2 -2
  89. data/tasks/updater/scss.rb +1 -1
  90. data/tasks/updater.rb +2 -2
  91. data/test/gemfiles/rails_5_2.gemfile +8 -0
  92. data/test/gemfiles/rails_7_0.gemfile +7 -0
  93. data/test/test_helper.rb +3 -2
  94. metadata +17 -9
  95. data/.travis.yml +0 -32
@@ -1,26 +1,22 @@
1
1
  /*!
2
- * Bootstrap tab.js v5.2.0 (https://getbootstrap.com/)
3
- * Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
2
+ * Bootstrap tab.js v5.3.0 (https://getbootstrap.com/)
3
+ * Copyright 2011-2023 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
4
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('./util/index'), require('./dom/event-handler'), require('./dom/selector-engine'), require('./base-component')) :
8
- typeof define === 'function' && define.amd ? define(['./util/index', './dom/event-handler', './dom/selector-engine', './base-component'], factory) :
9
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Tab = factory(global.Index, global.EventHandler, global.SelectorEngine, global.BaseComponent));
10
- })(this, (function (index, EventHandler, SelectorEngine, BaseComponent) { 'use strict';
11
-
12
- const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e };
13
-
14
- const EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler);
15
- const SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine);
16
- const BaseComponent__default = /*#__PURE__*/_interopDefaultLegacy(BaseComponent);
7
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./base-component.js'), require('./dom/event-handler.js'), require('./dom/selector-engine.js'), require('./util/index.js')) :
8
+ typeof define === 'function' && define.amd ? define(['./base-component', './dom/event-handler', './dom/selector-engine', './util/index'], factory) :
9
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Tab = factory(global.BaseComponent, global.EventHandler, global.SelectorEngine, global.Index));
10
+ })(this, (function (BaseComponent, EventHandler, SelectorEngine, index_js) { 'use strict';
17
11
 
18
12
  /**
19
13
  * --------------------------------------------------------------------------
20
- * Bootstrap (v5.2.0): tab.js
14
+ * Bootstrap tab.js
21
15
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
22
16
  * --------------------------------------------------------------------------
23
17
  */
18
+
19
+
24
20
  /**
25
21
  * Constants
26
22
  */
@@ -45,280 +41,227 @@
45
41
  const CLASS_DROPDOWN = 'dropdown';
46
42
  const SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle';
47
43
  const SELECTOR_DROPDOWN_MENU = '.dropdown-menu';
48
- const SELECTOR_DROPDOWN_ITEM = '.dropdown-item';
49
44
  const NOT_SELECTOR_DROPDOWN_TOGGLE = ':not(.dropdown-toggle)';
50
45
  const SELECTOR_TAB_PANEL = '.list-group, .nav, [role="tablist"]';
51
46
  const SELECTOR_OUTER = '.nav-item, .list-group-item';
52
47
  const SELECTOR_INNER = `.nav-link${NOT_SELECTOR_DROPDOWN_TOGGLE}, .list-group-item${NOT_SELECTOR_DROPDOWN_TOGGLE}, [role="tab"]${NOT_SELECTOR_DROPDOWN_TOGGLE}`;
53
- const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="tab"], [data-bs-toggle="pill"], [data-bs-toggle="list"]'; // todo:v6: could be only `tab`
54
-
48
+ const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="tab"], [data-bs-toggle="pill"], [data-bs-toggle="list"]'; // TODO: could only be `tab` in v6
55
49
  const SELECTOR_INNER_ELEM = `${SELECTOR_INNER}, ${SELECTOR_DATA_TOGGLE}`;
56
50
  const SELECTOR_DATA_TOGGLE_ACTIVE = `.${CLASS_NAME_ACTIVE}[data-bs-toggle="tab"], .${CLASS_NAME_ACTIVE}[data-bs-toggle="pill"], .${CLASS_NAME_ACTIVE}[data-bs-toggle="list"]`;
51
+
57
52
  /**
58
53
  * Class definition
59
54
  */
60
55
 
61
- class Tab extends BaseComponent__default.default {
56
+ class Tab extends BaseComponent {
62
57
  constructor(element) {
63
58
  super(element);
64
59
  this._parent = this._element.closest(SELECTOR_TAB_PANEL);
65
-
66
60
  if (!this._parent) {
67
- return; // todo: should Throw exception on v6
61
+ return;
62
+ // TODO: should throw exception in v6
68
63
  // throw new TypeError(`${element.outerHTML} has not a valid parent ${SELECTOR_INNER_ELEM}`)
69
- } // Set up initial aria attributes
70
-
64
+ }
71
65
 
66
+ // Set up initial aria attributes
72
67
  this._setInitialAttributes(this._parent, this._getChildren());
68
+ EventHandler.on(this._element, EVENT_KEYDOWN, event => this._keydown(event));
69
+ }
73
70
 
74
- EventHandler__default.default.on(this._element, EVENT_KEYDOWN, event => this._keydown(event));
75
- } // Getters
76
-
77
-
71
+ // Getters
78
72
  static get NAME() {
79
73
  return NAME;
80
- } // Public
81
-
74
+ }
82
75
 
76
+ // Public
83
77
  show() {
84
78
  // Shows this elem and deactivate the active sibling if exists
85
79
  const innerElem = this._element;
86
-
87
80
  if (this._elemIsActive(innerElem)) {
88
81
  return;
89
- } // Search for active tab on same parent to deactivate it
90
-
82
+ }
91
83
 
84
+ // Search for active tab on same parent to deactivate it
92
85
  const active = this._getActiveElem();
93
-
94
- const hideEvent = active ? EventHandler__default.default.trigger(active, EVENT_HIDE, {
86
+ const hideEvent = active ? EventHandler.trigger(active, EVENT_HIDE, {
95
87
  relatedTarget: innerElem
96
88
  }) : null;
97
- const showEvent = EventHandler__default.default.trigger(innerElem, EVENT_SHOW, {
89
+ const showEvent = EventHandler.trigger(innerElem, EVENT_SHOW, {
98
90
  relatedTarget: active
99
91
  });
100
-
101
92
  if (showEvent.defaultPrevented || hideEvent && hideEvent.defaultPrevented) {
102
93
  return;
103
94
  }
104
-
105
95
  this._deactivate(active, innerElem);
106
-
107
96
  this._activate(innerElem, active);
108
- } // Private
109
-
97
+ }
110
98
 
99
+ // Private
111
100
  _activate(element, relatedElem) {
112
101
  if (!element) {
113
102
  return;
114
103
  }
115
-
116
104
  element.classList.add(CLASS_NAME_ACTIVE);
117
-
118
- this._activate(index.getElementFromSelector(element)); // Search and activate/show the proper section
119
-
105
+ this._activate(SelectorEngine.getElementFromSelector(element)); // Search and activate/show the proper section
120
106
 
121
107
  const complete = () => {
122
108
  if (element.getAttribute('role') !== 'tab') {
123
109
  element.classList.add(CLASS_NAME_SHOW);
124
110
  return;
125
111
  }
126
-
127
- element.focus();
128
112
  element.removeAttribute('tabindex');
129
113
  element.setAttribute('aria-selected', true);
130
-
131
114
  this._toggleDropDown(element, true);
132
-
133
- EventHandler__default.default.trigger(element, EVENT_SHOWN, {
115
+ EventHandler.trigger(element, EVENT_SHOWN, {
134
116
  relatedTarget: relatedElem
135
117
  });
136
118
  };
137
-
138
119
  this._queueCallback(complete, element, element.classList.contains(CLASS_NAME_FADE));
139
120
  }
140
-
141
121
  _deactivate(element, relatedElem) {
142
122
  if (!element) {
143
123
  return;
144
124
  }
145
-
146
125
  element.classList.remove(CLASS_NAME_ACTIVE);
147
126
  element.blur();
148
-
149
- this._deactivate(index.getElementFromSelector(element)); // Search and deactivate the shown section too
150
-
127
+ this._deactivate(SelectorEngine.getElementFromSelector(element)); // Search and deactivate the shown section too
151
128
 
152
129
  const complete = () => {
153
130
  if (element.getAttribute('role') !== 'tab') {
154
131
  element.classList.remove(CLASS_NAME_SHOW);
155
132
  return;
156
133
  }
157
-
158
134
  element.setAttribute('aria-selected', false);
159
135
  element.setAttribute('tabindex', '-1');
160
-
161
136
  this._toggleDropDown(element, false);
162
-
163
- EventHandler__default.default.trigger(element, EVENT_HIDDEN, {
137
+ EventHandler.trigger(element, EVENT_HIDDEN, {
164
138
  relatedTarget: relatedElem
165
139
  });
166
140
  };
167
-
168
141
  this._queueCallback(complete, element, element.classList.contains(CLASS_NAME_FADE));
169
142
  }
170
-
171
143
  _keydown(event) {
172
144
  if (![ARROW_LEFT_KEY, ARROW_RIGHT_KEY, ARROW_UP_KEY, ARROW_DOWN_KEY].includes(event.key)) {
173
145
  return;
174
146
  }
175
-
176
147
  event.stopPropagation(); // stopPropagation/preventDefault both added to support up/down keys without scrolling the page
177
-
178
148
  event.preventDefault();
179
149
  const isNext = [ARROW_RIGHT_KEY, ARROW_DOWN_KEY].includes(event.key);
180
- const nextActiveElement = index.getNextActiveElement(this._getChildren().filter(element => !index.isDisabled(element)), event.target, isNext, true);
181
-
150
+ const nextActiveElement = index_js.getNextActiveElement(this._getChildren().filter(element => !index_js.isDisabled(element)), event.target, isNext, true);
182
151
  if (nextActiveElement) {
152
+ nextActiveElement.focus({
153
+ preventScroll: true
154
+ });
183
155
  Tab.getOrCreateInstance(nextActiveElement).show();
184
156
  }
185
157
  }
186
-
187
158
  _getChildren() {
188
159
  // collection of inner elements
189
- return SelectorEngine__default.default.find(SELECTOR_INNER_ELEM, this._parent);
160
+ return SelectorEngine.find(SELECTOR_INNER_ELEM, this._parent);
190
161
  }
191
-
192
162
  _getActiveElem() {
193
163
  return this._getChildren().find(child => this._elemIsActive(child)) || null;
194
164
  }
195
-
196
165
  _setInitialAttributes(parent, children) {
197
166
  this._setAttributeIfNotExists(parent, 'role', 'tablist');
198
-
199
167
  for (const child of children) {
200
168
  this._setInitialAttributesOnChild(child);
201
169
  }
202
170
  }
203
-
204
171
  _setInitialAttributesOnChild(child) {
205
172
  child = this._getInnerElement(child);
206
-
207
173
  const isActive = this._elemIsActive(child);
208
-
209
174
  const outerElem = this._getOuterElement(child);
210
-
211
175
  child.setAttribute('aria-selected', isActive);
212
-
213
176
  if (outerElem !== child) {
214
177
  this._setAttributeIfNotExists(outerElem, 'role', 'presentation');
215
178
  }
216
-
217
179
  if (!isActive) {
218
180
  child.setAttribute('tabindex', '-1');
219
181
  }
182
+ this._setAttributeIfNotExists(child, 'role', 'tab');
220
183
 
221
- this._setAttributeIfNotExists(child, 'role', 'tab'); // set attributes to the related panel too
222
-
223
-
184
+ // set attributes to the related panel too
224
185
  this._setInitialAttributesOnTargetPanel(child);
225
186
  }
226
-
227
187
  _setInitialAttributesOnTargetPanel(child) {
228
- const target = index.getElementFromSelector(child);
229
-
188
+ const target = SelectorEngine.getElementFromSelector(child);
230
189
  if (!target) {
231
190
  return;
232
191
  }
233
-
234
192
  this._setAttributeIfNotExists(target, 'role', 'tabpanel');
235
-
236
193
  if (child.id) {
237
- this._setAttributeIfNotExists(target, 'aria-labelledby', `#${child.id}`);
194
+ this._setAttributeIfNotExists(target, 'aria-labelledby', `${child.id}`);
238
195
  }
239
196
  }
240
-
241
197
  _toggleDropDown(element, open) {
242
198
  const outerElem = this._getOuterElement(element);
243
-
244
199
  if (!outerElem.classList.contains(CLASS_DROPDOWN)) {
245
200
  return;
246
201
  }
247
-
248
202
  const toggle = (selector, className) => {
249
- const element = SelectorEngine__default.default.findOne(selector, outerElem);
250
-
203
+ const element = SelectorEngine.findOne(selector, outerElem);
251
204
  if (element) {
252
205
  element.classList.toggle(className, open);
253
206
  }
254
207
  };
255
-
256
208
  toggle(SELECTOR_DROPDOWN_TOGGLE, CLASS_NAME_ACTIVE);
257
209
  toggle(SELECTOR_DROPDOWN_MENU, CLASS_NAME_SHOW);
258
- toggle(SELECTOR_DROPDOWN_ITEM, CLASS_NAME_ACTIVE);
259
210
  outerElem.setAttribute('aria-expanded', open);
260
211
  }
261
-
262
212
  _setAttributeIfNotExists(element, attribute, value) {
263
213
  if (!element.hasAttribute(attribute)) {
264
214
  element.setAttribute(attribute, value);
265
215
  }
266
216
  }
267
-
268
217
  _elemIsActive(elem) {
269
218
  return elem.classList.contains(CLASS_NAME_ACTIVE);
270
- } // Try to get the inner element (usually the .nav-link)
271
-
219
+ }
272
220
 
221
+ // Try to get the inner element (usually the .nav-link)
273
222
  _getInnerElement(elem) {
274
- return elem.matches(SELECTOR_INNER_ELEM) ? elem : SelectorEngine__default.default.findOne(SELECTOR_INNER_ELEM, elem);
275
- } // Try to get the outer element (usually the .nav-item)
276
-
223
+ return elem.matches(SELECTOR_INNER_ELEM) ? elem : SelectorEngine.findOne(SELECTOR_INNER_ELEM, elem);
224
+ }
277
225
 
226
+ // Try to get the outer element (usually the .nav-item)
278
227
  _getOuterElement(elem) {
279
228
  return elem.closest(SELECTOR_OUTER) || elem;
280
- } // Static
281
-
229
+ }
282
230
 
231
+ // Static
283
232
  static jQueryInterface(config) {
284
233
  return this.each(function () {
285
234
  const data = Tab.getOrCreateInstance(this);
286
-
287
235
  if (typeof config !== 'string') {
288
236
  return;
289
237
  }
290
-
291
238
  if (data[config] === undefined || config.startsWith('_') || config === 'constructor') {
292
239
  throw new TypeError(`No method named "${config}"`);
293
240
  }
294
-
295
241
  data[config]();
296
242
  });
297
243
  }
298
-
299
244
  }
245
+
300
246
  /**
301
247
  * Data API implementation
302
248
  */
303
249
 
304
-
305
- EventHandler__default.default.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
250
+ EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
306
251
  if (['A', 'AREA'].includes(this.tagName)) {
307
252
  event.preventDefault();
308
253
  }
309
-
310
- if (index.isDisabled(this)) {
254
+ if (index_js.isDisabled(this)) {
311
255
  return;
312
256
  }
313
-
314
257
  Tab.getOrCreateInstance(this).show();
315
258
  });
259
+
316
260
  /**
317
261
  * Initialize on focus
318
262
  */
319
-
320
- EventHandler__default.default.on(window, EVENT_LOAD_DATA_API, () => {
321
- for (const element of SelectorEngine__default.default.find(SELECTOR_DATA_TOGGLE_ACTIVE)) {
263
+ EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
264
+ for (const element of SelectorEngine.find(SELECTOR_DATA_TOGGLE_ACTIVE)) {
322
265
  Tab.getOrCreateInstance(element);
323
266
  }
324
267
  });
@@ -326,7 +269,7 @@
326
269
  * jQuery
327
270
  */
328
271
 
329
- index.defineJQueryPlugin(Tab);
272
+ index_js.defineJQueryPlugin(Tab);
330
273
 
331
274
  return Tab;
332
275
 
@@ -1,25 +1,22 @@
1
1
  /*!
2
- * Bootstrap toast.js v5.2.0 (https://getbootstrap.com/)
3
- * Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
2
+ * Bootstrap toast.js v5.3.0 (https://getbootstrap.com/)
3
+ * Copyright 2011-2023 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
4
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('./util/index'), require('./dom/event-handler'), require('./base-component'), require('./util/component-functions')) :
8
- typeof define === 'function' && define.amd ? define(['./util/index', './dom/event-handler', './base-component', './util/component-functions'], factory) :
9
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Toast = factory(global.Index, global.EventHandler, global.BaseComponent, global.ComponentFunctions));
10
- })(this, (function (index, EventHandler, BaseComponent, componentFunctions) { 'use strict';
11
-
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);
7
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./base-component.js'), require('./dom/event-handler.js'), require('./util/component-functions.js'), require('./util/index.js')) :
8
+ typeof define === 'function' && define.amd ? define(['./base-component', './dom/event-handler', './util/component-functions', './util/index'], factory) :
9
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Toast = factory(global.BaseComponent, global.EventHandler, global.ComponentFunctions, global.Index));
10
+ })(this, (function (BaseComponent, EventHandler, componentFunctions_js, index_js) { 'use strict';
16
11
 
17
12
  /**
18
13
  * --------------------------------------------------------------------------
19
- * Bootstrap (v5.2.0): toast.js
14
+ * Bootstrap toast.js
20
15
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
21
16
  * --------------------------------------------------------------------------
22
17
  */
18
+
19
+
23
20
  /**
24
21
  * Constants
25
22
  */
@@ -37,7 +34,6 @@
37
34
  const EVENT_SHOWN = `shown${EVENT_KEY}`;
38
35
  const CLASS_NAME_FADE = 'fade';
39
36
  const CLASS_NAME_HIDE = 'hide'; // @deprecated - kept here only for backwards compatibility
40
-
41
37
  const CLASS_NAME_SHOW = 'show';
42
38
  const CLASS_NAME_SHOWING = 'showing';
43
39
  const DefaultType = {
@@ -50,186 +46,152 @@
50
46
  autohide: true,
51
47
  delay: 5000
52
48
  };
49
+
53
50
  /**
54
51
  * Class definition
55
52
  */
56
53
 
57
- class Toast extends BaseComponent__default.default {
54
+ class Toast extends BaseComponent {
58
55
  constructor(element, config) {
59
56
  super(element, config);
60
57
  this._timeout = null;
61
58
  this._hasMouseInteraction = false;
62
59
  this._hasKeyboardInteraction = false;
63
-
64
60
  this._setListeners();
65
- } // Getters
66
-
61
+ }
67
62
 
63
+ // Getters
68
64
  static get Default() {
69
65
  return Default;
70
66
  }
71
-
72
67
  static get DefaultType() {
73
68
  return DefaultType;
74
69
  }
75
-
76
70
  static get NAME() {
77
71
  return NAME;
78
- } // Public
79
-
72
+ }
80
73
 
74
+ // Public
81
75
  show() {
82
- const showEvent = EventHandler__default.default.trigger(this._element, EVENT_SHOW);
83
-
76
+ const showEvent = EventHandler.trigger(this._element, EVENT_SHOW);
84
77
  if (showEvent.defaultPrevented) {
85
78
  return;
86
79
  }
87
-
88
80
  this._clearTimeout();
89
-
90
81
  if (this._config.animation) {
91
82
  this._element.classList.add(CLASS_NAME_FADE);
92
83
  }
93
-
94
84
  const complete = () => {
95
85
  this._element.classList.remove(CLASS_NAME_SHOWING);
96
-
97
- EventHandler__default.default.trigger(this._element, EVENT_SHOWN);
98
-
86
+ EventHandler.trigger(this._element, EVENT_SHOWN);
99
87
  this._maybeScheduleHide();
100
88
  };
101
-
102
89
  this._element.classList.remove(CLASS_NAME_HIDE); // @deprecated
103
-
104
-
105
- index.reflow(this._element);
106
-
90
+ index_js.reflow(this._element);
107
91
  this._element.classList.add(CLASS_NAME_SHOW, CLASS_NAME_SHOWING);
108
-
109
92
  this._queueCallback(complete, this._element, this._config.animation);
110
93
  }
111
-
112
94
  hide() {
113
95
  if (!this.isShown()) {
114
96
  return;
115
97
  }
116
-
117
- const hideEvent = EventHandler__default.default.trigger(this._element, EVENT_HIDE);
118
-
98
+ const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE);
119
99
  if (hideEvent.defaultPrevented) {
120
100
  return;
121
101
  }
122
-
123
102
  const complete = () => {
124
103
  this._element.classList.add(CLASS_NAME_HIDE); // @deprecated
125
-
126
-
127
104
  this._element.classList.remove(CLASS_NAME_SHOWING, CLASS_NAME_SHOW);
128
-
129
- EventHandler__default.default.trigger(this._element, EVENT_HIDDEN);
105
+ EventHandler.trigger(this._element, EVENT_HIDDEN);
130
106
  };
131
-
132
107
  this._element.classList.add(CLASS_NAME_SHOWING);
133
-
134
108
  this._queueCallback(complete, this._element, this._config.animation);
135
109
  }
136
-
137
110
  dispose() {
138
111
  this._clearTimeout();
139
-
140
112
  if (this.isShown()) {
141
113
  this._element.classList.remove(CLASS_NAME_SHOW);
142
114
  }
143
-
144
115
  super.dispose();
145
116
  }
146
-
147
117
  isShown() {
148
118
  return this._element.classList.contains(CLASS_NAME_SHOW);
149
- } // Private
119
+ }
150
120
 
121
+ // Private
151
122
 
152
123
  _maybeScheduleHide() {
153
124
  if (!this._config.autohide) {
154
125
  return;
155
126
  }
156
-
157
127
  if (this._hasMouseInteraction || this._hasKeyboardInteraction) {
158
128
  return;
159
129
  }
160
-
161
130
  this._timeout = setTimeout(() => {
162
131
  this.hide();
163
132
  }, this._config.delay);
164
133
  }
165
-
166
134
  _onInteraction(event, isInteracting) {
167
135
  switch (event.type) {
168
136
  case 'mouseover':
169
137
  case 'mouseout':
170
- this._hasMouseInteraction = isInteracting;
171
- break;
172
-
138
+ {
139
+ this._hasMouseInteraction = isInteracting;
140
+ break;
141
+ }
173
142
  case 'focusin':
174
143
  case 'focusout':
175
- this._hasKeyboardInteraction = isInteracting;
176
- break;
144
+ {
145
+ this._hasKeyboardInteraction = isInteracting;
146
+ break;
147
+ }
177
148
  }
178
-
179
149
  if (isInteracting) {
180
150
  this._clearTimeout();
181
-
182
151
  return;
183
152
  }
184
-
185
153
  const nextElement = event.relatedTarget;
186
-
187
154
  if (this._element === nextElement || this._element.contains(nextElement)) {
188
155
  return;
189
156
  }
190
-
191
157
  this._maybeScheduleHide();
192
158
  }
193
-
194
159
  _setListeners() {
195
- EventHandler__default.default.on(this._element, EVENT_MOUSEOVER, event => this._onInteraction(event, true));
196
- EventHandler__default.default.on(this._element, EVENT_MOUSEOUT, event => this._onInteraction(event, false));
197
- EventHandler__default.default.on(this._element, EVENT_FOCUSIN, event => this._onInteraction(event, true));
198
- EventHandler__default.default.on(this._element, EVENT_FOCUSOUT, event => this._onInteraction(event, false));
160
+ EventHandler.on(this._element, EVENT_MOUSEOVER, event => this._onInteraction(event, true));
161
+ EventHandler.on(this._element, EVENT_MOUSEOUT, event => this._onInteraction(event, false));
162
+ EventHandler.on(this._element, EVENT_FOCUSIN, event => this._onInteraction(event, true));
163
+ EventHandler.on(this._element, EVENT_FOCUSOUT, event => this._onInteraction(event, false));
199
164
  }
200
-
201
165
  _clearTimeout() {
202
166
  clearTimeout(this._timeout);
203
167
  this._timeout = null;
204
- } // Static
205
-
168
+ }
206
169
 
170
+ // Static
207
171
  static jQueryInterface(config) {
208
172
  return this.each(function () {
209
173
  const data = Toast.getOrCreateInstance(this, config);
210
-
211
174
  if (typeof config === 'string') {
212
175
  if (typeof data[config] === 'undefined') {
213
176
  throw new TypeError(`No method named "${config}"`);
214
177
  }
215
-
216
178
  data[config](this);
217
179
  }
218
180
  });
219
181
  }
220
-
221
182
  }
183
+
222
184
  /**
223
185
  * Data API implementation
224
186
  */
225
187
 
188
+ componentFunctions_js.enableDismissTrigger(Toast);
226
189
 
227
- componentFunctions.enableDismissTrigger(Toast);
228
190
  /**
229
191
  * jQuery
230
192
  */
231
193
 
232
- index.defineJQueryPlugin(Toast);
194
+ index_js.defineJQueryPlugin(Toast);
233
195
 
234
196
  return Toast;
235
197