bootstrap 5.2.0 → 5.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +55 -0
- data/README.md +25 -5
- data/assets/javascripts/bootstrap/alert.js +22 -32
- data/assets/javascripts/bootstrap/base-component.js +22 -38
- data/assets/javascripts/bootstrap/button.js +19 -22
- data/assets/javascripts/bootstrap/carousel.js +52 -135
- data/assets/javascripts/bootstrap/collapse.js +40 -102
- data/assets/javascripts/bootstrap/dom/data.js +8 -12
- data/assets/javascripts/bootstrap/dom/event-handler.js +19 -66
- data/assets/javascripts/bootstrap/dom/manipulator.js +4 -17
- data/assets/javascripts/bootstrap/dom/selector-engine.js +42 -24
- data/assets/javascripts/bootstrap/dropdown.js +74 -143
- data/assets/javascripts/bootstrap/modal.js +66 -143
- data/assets/javascripts/bootstrap/offcanvas.js +50 -102
- data/assets/javascripts/bootstrap/popover.js +23 -29
- data/assets/javascripts/bootstrap/scrollspy.js +64 -97
- data/assets/javascripts/bootstrap/tab.js +55 -112
- data/assets/javascripts/bootstrap/toast.js +39 -77
- data/assets/javascripts/bootstrap/tooltip.js +99 -216
- data/assets/javascripts/bootstrap/util/backdrop.js +28 -54
- data/assets/javascripts/bootstrap/util/component-functions.js +13 -18
- data/assets/javascripts/bootstrap/util/config.js +15 -27
- data/assets/javascripts/bootstrap/util/focustrap.js +20 -36
- data/assets/javascripts/bootstrap/util/index.js +42 -111
- data/assets/javascripts/bootstrap/util/sanitizer.js +30 -42
- data/assets/javascripts/bootstrap/util/scrollbar.js +24 -50
- data/assets/javascripts/bootstrap/util/swipe.js +27 -48
- data/assets/javascripts/bootstrap/util/template-factory.js +25 -52
- data/assets/javascripts/bootstrap-sprockets.js +12 -12
- data/assets/javascripts/bootstrap.js +764 -1529
- data/assets/javascripts/bootstrap.min.js +3 -3
- data/assets/stylesheets/_bootstrap-grid.scss +1 -3
- data/assets/stylesheets/_bootstrap-reboot.scss +1 -0
- data/assets/stylesheets/_bootstrap.scss +1 -0
- data/assets/stylesheets/bootstrap/_accordion.scss +16 -4
- data/assets/stylesheets/bootstrap/_alert.scss +8 -11
- data/assets/stylesheets/bootstrap/_button-group.scss +3 -3
- data/assets/stylesheets/bootstrap/_buttons.scss +31 -10
- data/assets/stylesheets/bootstrap/_card.scss +5 -0
- data/assets/stylesheets/bootstrap/_carousel.scss +20 -5
- data/assets/stylesheets/bootstrap/_close.scss +32 -9
- data/assets/stylesheets/bootstrap/_dropdown.scss +3 -1
- data/assets/stylesheets/bootstrap/_functions.scss +3 -3
- data/assets/stylesheets/bootstrap/_grid.scss +6 -0
- data/assets/stylesheets/bootstrap/_helpers.scss +2 -0
- data/assets/stylesheets/bootstrap/_list-group.scss +18 -12
- data/assets/stylesheets/bootstrap/_maps.scss +120 -0
- data/assets/stylesheets/bootstrap/_mixins.scss +1 -2
- data/assets/stylesheets/bootstrap/_modal.scss +1 -1
- data/assets/stylesheets/bootstrap/_nav.scss +42 -5
- data/assets/stylesheets/bootstrap/_navbar.scss +17 -4
- data/assets/stylesheets/bootstrap/_offcanvas.scss +9 -6
- data/assets/stylesheets/bootstrap/_pagination.scss +1 -1
- data/assets/stylesheets/bootstrap/_popover.scss +5 -5
- data/assets/stylesheets/bootstrap/_progress.scss +10 -1
- data/assets/stylesheets/bootstrap/_reboot.scss +3 -3
- data/assets/stylesheets/bootstrap/_root.scss +121 -10
- data/assets/stylesheets/bootstrap/_tables.scss +18 -11
- data/assets/stylesheets/bootstrap/_toasts.scss +5 -2
- data/assets/stylesheets/bootstrap/_tooltip.scss +4 -5
- data/assets/stylesheets/bootstrap/_utilities.scss +172 -13
- data/assets/stylesheets/bootstrap/_variables-dark.scss +85 -0
- data/assets/stylesheets/bootstrap/_variables.scss +272 -162
- data/assets/stylesheets/bootstrap/bootstrap-utilities.scss +4 -0
- data/assets/stylesheets/bootstrap/forms/_floating-labels.scss +23 -3
- data/assets/stylesheets/bootstrap/forms/_form-check.scss +24 -11
- data/assets/stylesheets/bootstrap/forms/_form-control.scss +23 -3
- data/assets/stylesheets/bootstrap/forms/_form-select.scss +11 -2
- data/assets/stylesheets/bootstrap/forms/_input-group.scss +7 -4
- data/assets/stylesheets/bootstrap/helpers/_color-bg.scss +0 -2
- data/assets/stylesheets/bootstrap/helpers/_colored-links.scss +20 -2
- data/assets/stylesheets/bootstrap/helpers/_focus-ring.scss +5 -0
- data/assets/stylesheets/bootstrap/helpers/_icon-link.scss +25 -0
- data/assets/stylesheets/bootstrap/mixins/_alert.scss +4 -1
- data/assets/stylesheets/bootstrap/mixins/_banner.scss +3 -5
- data/assets/stylesheets/bootstrap/mixins/_caret.scss +30 -25
- data/assets/stylesheets/bootstrap/mixins/_color-mode.scss +21 -0
- data/assets/stylesheets/bootstrap/mixins/_forms.scss +18 -17
- data/assets/stylesheets/bootstrap/mixins/_list-group.scss +2 -0
- data/assets/stylesheets/bootstrap/mixins/_table-variants.scss +2 -2
- data/assets/stylesheets/bootstrap/mixins/_utilities.scss +2 -2
- data/assets/stylesheets/bootstrap/mixins/_visually-hidden.scss +5 -1
- data/assets/stylesheets/bootstrap/vendor/_rfs.scss +23 -29
- data/bootstrap.gemspec +1 -1
- data/lib/bootstrap/version.rb +2 -2
- data/tasks/updater/js.rb +2 -2
- data/tasks/updater/network.rb +2 -2
- data/tasks/updater/scss.rb +1 -1
- data/tasks/updater.rb +2 -2
- data/test/gemfiles/rails_5_2.gemfile +8 -0
- data/test/gemfiles/rails_7_0.gemfile +7 -0
- data/test/test_helper.rb +3 -2
- metadata +17 -9
- data/.travis.yml +0 -32
@@ -1,18 +1,15 @@
|
|
1
1
|
/*!
|
2
|
-
* Bootstrap dropdown.js v5.
|
3
|
-
* Copyright 2011-
|
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('./
|
8
|
-
typeof define === 'function' && define.amd ? define(['@popperjs/core', './
|
9
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Dropdown = factory(global["@popperjs/core"], global.
|
10
|
-
})(this, (function (Popper,
|
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
|
-
|
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__*/
|
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
|
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 =
|
78
|
-
const PLACEMENT_TOPEND =
|
79
|
-
const PLACEMENT_BOTTOM =
|
80
|
-
const PLACEMENT_BOTTOMEND =
|
81
|
-
const PLACEMENT_RIGHT =
|
82
|
-
const PLACEMENT_LEFT =
|
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
|
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 =
|
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
|
-
}
|
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
|
-
}
|
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 (
|
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 =
|
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
|
-
|
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
|
-
|
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 (
|
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
|
-
}
|
197
|
-
|
174
|
+
}
|
198
175
|
|
176
|
+
// Private
|
199
177
|
_completeHide(relatedTarget) {
|
200
|
-
const hideEvent =
|
201
|
-
|
178
|
+
const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE, relatedTarget);
|
202
179
|
if (hideEvent.defaultPrevented) {
|
203
180
|
return;
|
204
|
-
}
|
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
|
-
|
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
|
-
|
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 (
|
249
|
-
referenceElement =
|
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
|
-
}
|
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
|
-
};
|
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
|
-
|
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
|
-
|
338
|
-
...(
|
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 =
|
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
|
-
}
|
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
|
-
}
|
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
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
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
|
-
|
397
|
+
index_js.defineJQueryPlugin(Dropdown);
|
467
398
|
|
468
399
|
return Dropdown;
|
469
400
|
|