bootstrap 5.2.0 → 5.3.0

Sign up to get free protection for your applications and to get access to all the features.
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,18 +1,15 @@
1
1
  /*!
2
- * Bootstrap dropdown.js v5.2.0 (https://getbootstrap.com/)
3
- * Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
2
+ * Bootstrap dropdown.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('@popperjs/core'), require('./util/index'), require('./dom/event-handler'), require('./dom/manipulator'), require('./dom/selector-engine'), require('./base-component')) :
8
- typeof define === 'function' && define.amd ? define(['@popperjs/core', './util/index', './dom/event-handler', './dom/manipulator', './dom/selector-engine', './base-component'], factory) :
9
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Dropdown = factory(global["@popperjs/core"], global.Index, global.EventHandler, global.Manipulator, global.SelectorEngine, global.BaseComponent));
10
- })(this, (function (Popper, index, EventHandler, Manipulator, SelectorEngine, BaseComponent) { 'use strict';
7
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@popperjs/core'), require('./base-component.js'), require('./dom/event-handler.js'), require('./dom/manipulator.js'), require('./dom/selector-engine.js'), require('./util/index.js')) :
8
+ typeof define === 'function' && define.amd ? define(['@popperjs/core', './base-component', './dom/event-handler', './dom/manipulator', './dom/selector-engine', './util/index'], factory) :
9
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Dropdown = factory(global["@popperjs/core"], global.BaseComponent, global.EventHandler, global.Manipulator, global.SelectorEngine, global.Index));
10
+ })(this, (function (Popper, BaseComponent, EventHandler, Manipulator, SelectorEngine, index_js) { 'use strict';
11
11
 
12
- const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e };
13
-
14
- function _interopNamespace(e) {
15
- if (e && e.__esModule) return e;
12
+ function _interopNamespaceDefault(e) {
16
13
  const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
17
14
  if (e) {
18
15
  for (const k in e) {
@@ -29,18 +26,16 @@
29
26
  return Object.freeze(n);
30
27
  }
31
28
 
32
- const Popper__namespace = /*#__PURE__*/_interopNamespace(Popper);
33
- const EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler);
34
- const Manipulator__default = /*#__PURE__*/_interopDefaultLegacy(Manipulator);
35
- const SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine);
36
- const BaseComponent__default = /*#__PURE__*/_interopDefaultLegacy(BaseComponent);
29
+ const Popper__namespace = /*#__PURE__*/_interopNamespaceDefault(Popper);
37
30
 
38
31
  /**
39
32
  * --------------------------------------------------------------------------
40
- * Bootstrap (v5.2.0): dropdown.js
33
+ * Bootstrap dropdown.js
41
34
  * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
42
35
  * --------------------------------------------------------------------------
43
36
  */
37
+
38
+
44
39
  /**
45
40
  * Constants
46
41
  */
@@ -74,12 +69,12 @@
74
69
  const SELECTOR_NAVBAR = '.navbar';
75
70
  const SELECTOR_NAVBAR_NAV = '.navbar-nav';
76
71
  const SELECTOR_VISIBLE_ITEMS = '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)';
77
- const PLACEMENT_TOP = index.isRTL() ? 'top-end' : 'top-start';
78
- const PLACEMENT_TOPEND = index.isRTL() ? 'top-start' : 'top-end';
79
- const PLACEMENT_BOTTOM = index.isRTL() ? 'bottom-end' : 'bottom-start';
80
- const PLACEMENT_BOTTOMEND = index.isRTL() ? 'bottom-start' : 'bottom-end';
81
- const PLACEMENT_RIGHT = index.isRTL() ? 'left-start' : 'right-start';
82
- const PLACEMENT_LEFT = index.isRTL() ? 'right-start' : 'left-start';
72
+ const PLACEMENT_TOP = index_js.isRTL() ? 'top-end' : 'top-start';
73
+ const PLACEMENT_TOPEND = index_js.isRTL() ? 'top-start' : 'top-end';
74
+ const PLACEMENT_BOTTOM = index_js.isRTL() ? 'bottom-end' : 'bottom-start';
75
+ const PLACEMENT_BOTTOMEND = index_js.isRTL() ? 'bottom-start' : 'bottom-end';
76
+ const PLACEMENT_RIGHT = index_js.isRTL() ? 'left-start' : 'right-start';
77
+ const PLACEMENT_LEFT = index_js.isRTL() ? 'right-start' : 'left-start';
83
78
  const PLACEMENT_TOPCENTER = 'top';
84
79
  const PLACEMENT_BOTTOMCENTER = 'bottom';
85
80
  const Default = {
@@ -98,217 +93,172 @@
98
93
  popperConfig: '(null|object|function)',
99
94
  reference: '(string|element|object)'
100
95
  };
96
+
101
97
  /**
102
98
  * Class definition
103
99
  */
104
100
 
105
- class Dropdown extends BaseComponent__default.default {
101
+ class Dropdown extends BaseComponent {
106
102
  constructor(element, config) {
107
103
  super(element, config);
108
104
  this._popper = null;
109
105
  this._parent = this._element.parentNode; // dropdown wrapper
110
-
111
- this._menu = SelectorEngine__default.default.findOne(SELECTOR_MENU, this._parent);
106
+ // TODO: v6 revert #37011 & change markup https://getbootstrap.com/docs/5.3/forms/input-group/
107
+ this._menu = SelectorEngine.next(this._element, SELECTOR_MENU)[0] || SelectorEngine.prev(this._element, SELECTOR_MENU)[0] || SelectorEngine.findOne(SELECTOR_MENU, this._parent);
112
108
  this._inNavbar = this._detectNavbar();
113
- } // Getters
114
-
109
+ }
115
110
 
111
+ // Getters
116
112
  static get Default() {
117
113
  return Default;
118
114
  }
119
-
120
115
  static get DefaultType() {
121
116
  return DefaultType;
122
117
  }
123
-
124
118
  static get NAME() {
125
119
  return NAME;
126
- } // Public
127
-
120
+ }
128
121
 
122
+ // Public
129
123
  toggle() {
130
124
  return this._isShown() ? this.hide() : this.show();
131
125
  }
132
-
133
126
  show() {
134
- if (index.isDisabled(this._element) || this._isShown()) {
127
+ if (index_js.isDisabled(this._element) || this._isShown()) {
135
128
  return;
136
129
  }
137
-
138
130
  const relatedTarget = {
139
131
  relatedTarget: this._element
140
132
  };
141
- const showEvent = EventHandler__default.default.trigger(this._element, EVENT_SHOW, relatedTarget);
142
-
133
+ const showEvent = EventHandler.trigger(this._element, EVENT_SHOW, relatedTarget);
143
134
  if (showEvent.defaultPrevented) {
144
135
  return;
145
136
  }
137
+ this._createPopper();
146
138
 
147
- this._createPopper(); // If this is a touch-enabled device we add extra
139
+ // If this is a touch-enabled device we add extra
148
140
  // empty mouseover listeners to the body's immediate children;
149
141
  // only needed because of broken event delegation on iOS
150
142
  // https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
151
-
152
-
153
143
  if ('ontouchstart' in document.documentElement && !this._parent.closest(SELECTOR_NAVBAR_NAV)) {
154
144
  for (const element of [].concat(...document.body.children)) {
155
- EventHandler__default.default.on(element, 'mouseover', index.noop);
145
+ EventHandler.on(element, 'mouseover', index_js.noop);
156
146
  }
157
147
  }
158
-
159
148
  this._element.focus();
160
-
161
149
  this._element.setAttribute('aria-expanded', true);
162
-
163
150
  this._menu.classList.add(CLASS_NAME_SHOW);
164
-
165
151
  this._element.classList.add(CLASS_NAME_SHOW);
166
-
167
- EventHandler__default.default.trigger(this._element, EVENT_SHOWN, relatedTarget);
152
+ EventHandler.trigger(this._element, EVENT_SHOWN, relatedTarget);
168
153
  }
169
-
170
154
  hide() {
171
- if (index.isDisabled(this._element) || !this._isShown()) {
155
+ if (index_js.isDisabled(this._element) || !this._isShown()) {
172
156
  return;
173
157
  }
174
-
175
158
  const relatedTarget = {
176
159
  relatedTarget: this._element
177
160
  };
178
-
179
161
  this._completeHide(relatedTarget);
180
162
  }
181
-
182
163
  dispose() {
183
164
  if (this._popper) {
184
165
  this._popper.destroy();
185
166
  }
186
-
187
167
  super.dispose();
188
168
  }
189
-
190
169
  update() {
191
170
  this._inNavbar = this._detectNavbar();
192
-
193
171
  if (this._popper) {
194
172
  this._popper.update();
195
173
  }
196
- } // Private
197
-
174
+ }
198
175
 
176
+ // Private
199
177
  _completeHide(relatedTarget) {
200
- const hideEvent = EventHandler__default.default.trigger(this._element, EVENT_HIDE, relatedTarget);
201
-
178
+ const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE, relatedTarget);
202
179
  if (hideEvent.defaultPrevented) {
203
180
  return;
204
- } // If this is a touch-enabled device we remove the extra
205
- // empty mouseover listeners we added for iOS support
206
-
181
+ }
207
182
 
183
+ // If this is a touch-enabled device we remove the extra
184
+ // empty mouseover listeners we added for iOS support
208
185
  if ('ontouchstart' in document.documentElement) {
209
186
  for (const element of [].concat(...document.body.children)) {
210
- EventHandler__default.default.off(element, 'mouseover', index.noop);
187
+ EventHandler.off(element, 'mouseover', index_js.noop);
211
188
  }
212
189
  }
213
-
214
190
  if (this._popper) {
215
191
  this._popper.destroy();
216
192
  }
217
-
218
193
  this._menu.classList.remove(CLASS_NAME_SHOW);
219
-
220
194
  this._element.classList.remove(CLASS_NAME_SHOW);
221
-
222
195
  this._element.setAttribute('aria-expanded', 'false');
223
-
224
- Manipulator__default.default.removeDataAttribute(this._menu, 'popper');
225
- EventHandler__default.default.trigger(this._element, EVENT_HIDDEN, relatedTarget);
196
+ Manipulator.removeDataAttribute(this._menu, 'popper');
197
+ EventHandler.trigger(this._element, EVENT_HIDDEN, relatedTarget);
226
198
  }
227
-
228
199
  _getConfig(config) {
229
200
  config = super._getConfig(config);
230
-
231
- if (typeof config.reference === 'object' && !index.isElement(config.reference) && typeof config.reference.getBoundingClientRect !== 'function') {
201
+ if (typeof config.reference === 'object' && !index_js.isElement(config.reference) && typeof config.reference.getBoundingClientRect !== 'function') {
232
202
  // Popper virtual elements require a getBoundingClientRect method
233
203
  throw new TypeError(`${NAME.toUpperCase()}: Option "reference" provided type "object" without a required "getBoundingClientRect" method.`);
234
204
  }
235
-
236
205
  return config;
237
206
  }
238
-
239
207
  _createPopper() {
240
208
  if (typeof Popper__namespace === 'undefined') {
241
209
  throw new TypeError('Bootstrap\'s dropdowns require Popper (https://popper.js.org)');
242
210
  }
243
-
244
211
  let referenceElement = this._element;
245
-
246
212
  if (this._config.reference === 'parent') {
247
213
  referenceElement = this._parent;
248
- } else if (index.isElement(this._config.reference)) {
249
- referenceElement = index.getElement(this._config.reference);
214
+ } else if (index_js.isElement(this._config.reference)) {
215
+ referenceElement = index_js.getElement(this._config.reference);
250
216
  } else if (typeof this._config.reference === 'object') {
251
217
  referenceElement = this._config.reference;
252
218
  }
253
-
254
219
  const popperConfig = this._getPopperConfig();
255
-
256
220
  this._popper = Popper__namespace.createPopper(referenceElement, this._menu, popperConfig);
257
221
  }
258
-
259
222
  _isShown() {
260
223
  return this._menu.classList.contains(CLASS_NAME_SHOW);
261
224
  }
262
-
263
225
  _getPlacement() {
264
226
  const parentDropdown = this._parent;
265
-
266
227
  if (parentDropdown.classList.contains(CLASS_NAME_DROPEND)) {
267
228
  return PLACEMENT_RIGHT;
268
229
  }
269
-
270
230
  if (parentDropdown.classList.contains(CLASS_NAME_DROPSTART)) {
271
231
  return PLACEMENT_LEFT;
272
232
  }
273
-
274
233
  if (parentDropdown.classList.contains(CLASS_NAME_DROPUP_CENTER)) {
275
234
  return PLACEMENT_TOPCENTER;
276
235
  }
277
-
278
236
  if (parentDropdown.classList.contains(CLASS_NAME_DROPDOWN_CENTER)) {
279
237
  return PLACEMENT_BOTTOMCENTER;
280
- } // We need to trim the value because custom properties can also include spaces
281
-
238
+ }
282
239
 
240
+ // We need to trim the value because custom properties can also include spaces
283
241
  const isEnd = getComputedStyle(this._menu).getPropertyValue('--bs-position').trim() === 'end';
284
-
285
242
  if (parentDropdown.classList.contains(CLASS_NAME_DROPUP)) {
286
243
  return isEnd ? PLACEMENT_TOPEND : PLACEMENT_TOP;
287
244
  }
288
-
289
245
  return isEnd ? PLACEMENT_BOTTOMEND : PLACEMENT_BOTTOM;
290
246
  }
291
-
292
247
  _detectNavbar() {
293
248
  return this._element.closest(SELECTOR_NAVBAR) !== null;
294
249
  }
295
-
296
250
  _getOffset() {
297
251
  const {
298
252
  offset
299
253
  } = this._config;
300
-
301
254
  if (typeof offset === 'string') {
302
255
  return offset.split(',').map(value => Number.parseInt(value, 10));
303
256
  }
304
-
305
257
  if (typeof offset === 'function') {
306
258
  return popperData => offset(popperData, this._element);
307
259
  }
308
-
309
260
  return offset;
310
261
  }
311
-
312
262
  _getPopperConfig() {
313
263
  const defaultBsPopperConfig = {
314
264
  placement: this._getPlacement(),
@@ -323,120 +273,101 @@
323
273
  offset: this._getOffset()
324
274
  }
325
275
  }]
326
- }; // Disable Popper if we have a static display or Dropdown is in Navbar
276
+ };
327
277
 
278
+ // Disable Popper if we have a static display or Dropdown is in Navbar
328
279
  if (this._inNavbar || this._config.display === 'static') {
329
- Manipulator__default.default.setDataAttribute(this._menu, 'popper', 'static'); // todo:v6 remove
330
-
280
+ Manipulator.setDataAttribute(this._menu, 'popper', 'static'); // TODO: v6 remove
331
281
  defaultBsPopperConfig.modifiers = [{
332
282
  name: 'applyStyles',
333
283
  enabled: false
334
284
  }];
335
285
  }
336
-
337
- return { ...defaultBsPopperConfig,
338
- ...(typeof this._config.popperConfig === 'function' ? this._config.popperConfig(defaultBsPopperConfig) : this._config.popperConfig)
286
+ return {
287
+ ...defaultBsPopperConfig,
288
+ ...index_js.execute(this._config.popperConfig, [defaultBsPopperConfig])
339
289
  };
340
290
  }
341
-
342
291
  _selectMenuItem({
343
292
  key,
344
293
  target
345
294
  }) {
346
- const items = SelectorEngine__default.default.find(SELECTOR_VISIBLE_ITEMS, this._menu).filter(element => index.isVisible(element));
347
-
295
+ const items = SelectorEngine.find(SELECTOR_VISIBLE_ITEMS, this._menu).filter(element => index_js.isVisible(element));
348
296
  if (!items.length) {
349
297
  return;
350
- } // if target isn't included in items (e.g. when expanding the dropdown)
351
- // allow cycling to get the last item in case key equals ARROW_UP_KEY
352
-
353
-
354
- index.getNextActiveElement(items, target, key === ARROW_DOWN_KEY, !items.includes(target)).focus();
355
- } // Static
298
+ }
356
299
 
300
+ // if target isn't included in items (e.g. when expanding the dropdown)
301
+ // allow cycling to get the last item in case key equals ARROW_UP_KEY
302
+ index_js.getNextActiveElement(items, target, key === ARROW_DOWN_KEY, !items.includes(target)).focus();
303
+ }
357
304
 
305
+ // Static
358
306
  static jQueryInterface(config) {
359
307
  return this.each(function () {
360
308
  const data = Dropdown.getOrCreateInstance(this, config);
361
-
362
309
  if (typeof config !== 'string') {
363
310
  return;
364
311
  }
365
-
366
312
  if (typeof data[config] === 'undefined') {
367
313
  throw new TypeError(`No method named "${config}"`);
368
314
  }
369
-
370
315
  data[config]();
371
316
  });
372
317
  }
373
-
374
318
  static clearMenus(event) {
375
319
  if (event.button === RIGHT_MOUSE_BUTTON || event.type === 'keyup' && event.key !== TAB_KEY) {
376
320
  return;
377
321
  }
378
-
379
- const openToggles = SelectorEngine__default.default.find(SELECTOR_DATA_TOGGLE_SHOWN);
380
-
322
+ const openToggles = SelectorEngine.find(SELECTOR_DATA_TOGGLE_SHOWN);
381
323
  for (const toggle of openToggles) {
382
324
  const context = Dropdown.getInstance(toggle);
383
-
384
325
  if (!context || context._config.autoClose === false) {
385
326
  continue;
386
327
  }
387
-
388
328
  const composedPath = event.composedPath();
389
329
  const isMenuTarget = composedPath.includes(context._menu);
390
-
391
330
  if (composedPath.includes(context._element) || context._config.autoClose === 'inside' && !isMenuTarget || context._config.autoClose === 'outside' && isMenuTarget) {
392
331
  continue;
393
- } // Tab navigation through the dropdown menu or events from contained inputs shouldn't close the menu
394
-
332
+ }
395
333
 
334
+ // Tab navigation through the dropdown menu or events from contained inputs shouldn't close the menu
396
335
  if (context._menu.contains(event.target) && (event.type === 'keyup' && event.key === TAB_KEY || /input|select|option|textarea|form/i.test(event.target.tagName))) {
397
336
  continue;
398
337
  }
399
-
400
338
  const relatedTarget = {
401
339
  relatedTarget: context._element
402
340
  };
403
-
404
341
  if (event.type === 'click') {
405
342
  relatedTarget.clickEvent = event;
406
343
  }
407
-
408
344
  context._completeHide(relatedTarget);
409
345
  }
410
346
  }
411
-
412
347
  static dataApiKeydownHandler(event) {
413
348
  // If not an UP | DOWN | ESCAPE key => not a dropdown command
414
349
  // If input/textarea && if key is other than ESCAPE => not a dropdown command
350
+
415
351
  const isInput = /input|textarea/i.test(event.target.tagName);
416
352
  const isEscapeEvent = event.key === ESCAPE_KEY;
417
353
  const isUpOrDownEvent = [ARROW_UP_KEY, ARROW_DOWN_KEY].includes(event.key);
418
-
419
354
  if (!isUpOrDownEvent && !isEscapeEvent) {
420
355
  return;
421
356
  }
422
-
423
357
  if (isInput && !isEscapeEvent) {
424
358
  return;
425
359
  }
426
-
427
360
  event.preventDefault();
428
- const getToggleButton = SelectorEngine__default.default.findOne(SELECTOR_DATA_TOGGLE, event.delegateTarget.parentNode);
429
- const instance = Dropdown.getOrCreateInstance(getToggleButton);
430
361
 
362
+ // TODO: v6 revert #37011 & change markup https://getbootstrap.com/docs/5.3/forms/input-group/
363
+ const getToggleButton = this.matches(SELECTOR_DATA_TOGGLE) ? this : SelectorEngine.prev(this, SELECTOR_DATA_TOGGLE)[0] || SelectorEngine.next(this, SELECTOR_DATA_TOGGLE)[0] || SelectorEngine.findOne(SELECTOR_DATA_TOGGLE, event.delegateTarget.parentNode);
364
+ const instance = Dropdown.getOrCreateInstance(getToggleButton);
431
365
  if (isUpOrDownEvent) {
432
366
  event.stopPropagation();
433
367
  instance.show();
434
-
435
368
  instance._selectMenuItem(event);
436
-
437
369
  return;
438
370
  }
439
-
440
371
  if (instance._isShown()) {
441
372
  // else is escape and we check if it is shown
442
373
  event.stopPropagation();
@@ -444,26 +375,26 @@
444
375
  getToggleButton.focus();
445
376
  }
446
377
  }
447
-
448
378
  }
379
+
449
380
  /**
450
381
  * Data API implementation
451
382
  */
452
383
 
453
-
454
- EventHandler__default.default.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_DATA_TOGGLE, Dropdown.dataApiKeydownHandler);
455
- EventHandler__default.default.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_MENU, Dropdown.dataApiKeydownHandler);
456
- EventHandler__default.default.on(document, EVENT_CLICK_DATA_API, Dropdown.clearMenus);
457
- EventHandler__default.default.on(document, EVENT_KEYUP_DATA_API, Dropdown.clearMenus);
458
- EventHandler__default.default.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
384
+ EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_DATA_TOGGLE, Dropdown.dataApiKeydownHandler);
385
+ EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_MENU, Dropdown.dataApiKeydownHandler);
386
+ EventHandler.on(document, EVENT_CLICK_DATA_API, Dropdown.clearMenus);
387
+ EventHandler.on(document, EVENT_KEYUP_DATA_API, Dropdown.clearMenus);
388
+ EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
459
389
  event.preventDefault();
460
390
  Dropdown.getOrCreateInstance(this).toggle();
461
391
  });
392
+
462
393
  /**
463
394
  * jQuery
464
395
  */
465
396
 
466
- index.defineJQueryPlugin(Dropdown);
397
+ index_js.defineJQueryPlugin(Dropdown);
467
398
 
468
399
  return Dropdown;
469
400