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