bootstrap 5.0.1 → 5.1.2
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.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/assets/javascripts/bootstrap/alert.js +89 -58
- data/assets/javascripts/bootstrap/base-component.js +53 -39
- data/assets/javascripts/bootstrap/button.js +31 -25
- data/assets/javascripts/bootstrap/carousel.js +126 -89
- data/assets/javascripts/bootstrap/collapse.js +125 -133
- data/assets/javascripts/bootstrap/dom/data.js +5 -5
- data/assets/javascripts/bootstrap/dom/event-handler.js +11 -5
- data/assets/javascripts/bootstrap/dom/manipulator.js +6 -6
- data/assets/javascripts/bootstrap/dom/selector-engine.js +49 -7
- data/assets/javascripts/bootstrap/dropdown.js +147 -140
- data/assets/javascripts/bootstrap/modal.js +397 -180
- data/assets/javascripts/bootstrap/offcanvas.js +333 -138
- data/assets/javascripts/bootstrap/popover.js +36 -54
- data/assets/javascripts/bootstrap/scrollspy.js +58 -68
- data/assets/javascripts/bootstrap/tab.js +53 -26
- data/assets/javascripts/bootstrap/toast.js +138 -41
- data/assets/javascripts/bootstrap/tooltip.js +137 -120
- data/assets/javascripts/bootstrap-sprockets.js +8 -8
- data/assets/javascripts/bootstrap.js +937 -886
- data/assets/javascripts/bootstrap.min.js +2 -2
- data/assets/stylesheets/_bootstrap-grid.scss +3 -1
- data/assets/stylesheets/_bootstrap-reboot.scss +2 -4
- data/assets/stylesheets/_bootstrap.scss +2 -1
- data/assets/stylesheets/bootstrap/_buttons.scss +1 -0
- data/assets/stylesheets/bootstrap/_card.scss +7 -6
- data/assets/stylesheets/bootstrap/_carousel.scss +2 -2
- data/assets/stylesheets/bootstrap/_dropdown.scss +4 -4
- data/assets/stylesheets/bootstrap/_functions.scss +100 -3
- data/assets/stylesheets/bootstrap/_grid.scss +11 -0
- data/assets/stylesheets/bootstrap/_helpers.scss +2 -0
- data/assets/stylesheets/bootstrap/_images.scss +1 -1
- data/assets/stylesheets/bootstrap/_mixins.scss +1 -0
- data/assets/stylesheets/bootstrap/_modal.scss +5 -15
- data/assets/stylesheets/bootstrap/_navbar.scss +30 -1
- data/assets/stylesheets/bootstrap/_offcanvas.scss +8 -2
- data/assets/stylesheets/bootstrap/_placeholders.scss +51 -0
- data/assets/stylesheets/bootstrap/_popover.scss +10 -10
- data/assets/stylesheets/bootstrap/_reboot.scss +12 -8
- data/assets/stylesheets/bootstrap/_root.scss +40 -2
- data/assets/stylesheets/bootstrap/_tables.scss +9 -5
- data/assets/stylesheets/bootstrap/_toasts.scss +3 -3
- data/assets/stylesheets/bootstrap/_tooltip.scss +4 -4
- data/assets/stylesheets/bootstrap/_transitions.scss +6 -0
- data/assets/stylesheets/bootstrap/_utilities.scss +44 -8
- data/assets/stylesheets/bootstrap/_variables.scss +206 -29
- data/assets/stylesheets/bootstrap/bootstrap-utilities.scss +1 -1
- data/assets/stylesheets/bootstrap/forms/_floating-labels.scss +3 -1
- data/assets/stylesheets/bootstrap/forms/_form-check.scss +1 -1
- data/assets/stylesheets/bootstrap/forms/_form-control.scss +1 -1
- data/assets/stylesheets/bootstrap/forms/_form-range.scss +1 -1
- data/assets/stylesheets/bootstrap/forms/_form-select.scss +5 -0
- data/assets/stylesheets/bootstrap/helpers/_stacks.scss +15 -0
- data/assets/stylesheets/bootstrap/helpers/_vr.scss +8 -0
- data/assets/stylesheets/bootstrap/mixins/_backdrop.scss +14 -0
- data/assets/stylesheets/bootstrap/mixins/_buttons.scss +1 -1
- data/assets/stylesheets/bootstrap/mixins/_grid.scss +35 -9
- data/assets/stylesheets/bootstrap/mixins/_utilities.scss +27 -6
- data/assets/stylesheets/bootstrap/mixins/_visually-hidden.scss +1 -1
- data/assets/stylesheets/bootstrap/vendor/_rfs.scss +55 -13
- data/bootstrap.gemspec +3 -3
- data/lib/bootstrap/version.rb +2 -2
- data/tasks/updater/js.rb +6 -2
- metadata +12 -8
@@ -1,5 +1,5 @@
|
|
1
1
|
/*!
|
2
|
-
* Bootstrap selector-engine.js v5.
|
2
|
+
* Bootstrap selector-engine.js v5.1.2 (https://getbootstrap.com/)
|
3
3
|
* Copyright 2011-2021 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
|
*/
|
@@ -7,19 +7,56 @@
|
|
7
7
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
8
8
|
typeof define === 'function' && define.amd ? define(factory) :
|
9
9
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.SelectorEngine = factory());
|
10
|
-
}(this, (function () { 'use strict';
|
10
|
+
})(this, (function () { 'use strict';
|
11
11
|
|
12
12
|
/**
|
13
13
|
* --------------------------------------------------------------------------
|
14
|
-
* Bootstrap (v5.
|
14
|
+
* Bootstrap (v5.1.2): util/index.js
|
15
15
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
16
16
|
* --------------------------------------------------------------------------
|
17
17
|
*/
|
18
18
|
|
19
|
+
const isElement = obj => {
|
20
|
+
if (!obj || typeof obj !== 'object') {
|
21
|
+
return false;
|
22
|
+
}
|
23
|
+
|
24
|
+
if (typeof obj.jquery !== 'undefined') {
|
25
|
+
obj = obj[0];
|
26
|
+
}
|
27
|
+
|
28
|
+
return typeof obj.nodeType !== 'undefined';
|
29
|
+
};
|
30
|
+
|
31
|
+
const isVisible = element => {
|
32
|
+
if (!isElement(element) || element.getClientRects().length === 0) {
|
33
|
+
return false;
|
34
|
+
}
|
35
|
+
|
36
|
+
return getComputedStyle(element).getPropertyValue('visibility') === 'visible';
|
37
|
+
};
|
38
|
+
|
39
|
+
const isDisabled = element => {
|
40
|
+
if (!element || element.nodeType !== Node.ELEMENT_NODE) {
|
41
|
+
return true;
|
42
|
+
}
|
43
|
+
|
44
|
+
if (element.classList.contains('disabled')) {
|
45
|
+
return true;
|
46
|
+
}
|
47
|
+
|
48
|
+
if (typeof element.disabled !== 'undefined') {
|
49
|
+
return element.disabled;
|
50
|
+
}
|
51
|
+
|
52
|
+
return element.hasAttribute('disabled') && element.getAttribute('disabled') !== 'false';
|
53
|
+
};
|
54
|
+
|
19
55
|
/**
|
20
|
-
*
|
21
|
-
*
|
22
|
-
*
|
56
|
+
* --------------------------------------------------------------------------
|
57
|
+
* Bootstrap (v5.1.2): dom/selector-engine.js
|
58
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
59
|
+
* --------------------------------------------------------------------------
|
23
60
|
*/
|
24
61
|
const NODE_TEXT = 3;
|
25
62
|
const SelectorEngine = {
|
@@ -76,10 +113,15 @@
|
|
76
113
|
}
|
77
114
|
|
78
115
|
return [];
|
116
|
+
},
|
117
|
+
|
118
|
+
focusableChildren(element) {
|
119
|
+
const focusables = ['a', 'button', 'input', 'textarea', 'select', 'details', '[tabindex]', '[contenteditable="true"]'].map(selector => `${selector}:not([tabindex^="-"])`).join(', ');
|
120
|
+
return this.find(focusables, element).filter(el => !isDisabled(el) && isVisible(el));
|
79
121
|
}
|
80
122
|
|
81
123
|
};
|
82
124
|
|
83
125
|
return SelectorEngine;
|
84
126
|
|
85
|
-
}))
|
127
|
+
}));
|
@@ -1,42 +1,46 @@
|
|
1
1
|
/*!
|
2
|
-
* Bootstrap dropdown.js v5.
|
2
|
+
* Bootstrap dropdown.js v5.1.2 (https://getbootstrap.com/)
|
3
3
|
* Copyright 2011-2021 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('./dom/
|
8
|
-
typeof define === 'function' && define.amd ? define(['@popperjs/core', './dom/
|
9
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Dropdown = factory(global.Popper, global.
|
10
|
-
}(this, (function (Popper,
|
7
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@popperjs/core'), require('./dom/event-handler.js'), require('./dom/manipulator.js'), require('./dom/selector-engine.js'), require('./base-component.js')) :
|
8
|
+
typeof define === 'function' && define.amd ? define(['@popperjs/core', './dom/event-handler', './dom/manipulator', './dom/selector-engine', './base-component'], factory) :
|
9
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Dropdown = factory(global.Popper, global.EventHandler, global.Manipulator, global.SelectorEngine, global.Base));
|
10
|
+
})(this, (function (Popper, EventHandler, Manipulator, SelectorEngine, BaseComponent) { 'use strict';
|
11
11
|
|
12
|
-
|
12
|
+
const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e };
|
13
13
|
|
14
14
|
function _interopNamespace(e) {
|
15
15
|
if (e && e.__esModule) return e;
|
16
|
-
|
16
|
+
const n = Object.create(null);
|
17
17
|
if (e) {
|
18
|
-
|
18
|
+
for (const k in e) {
|
19
19
|
if (k !== 'default') {
|
20
|
-
|
20
|
+
const d = Object.getOwnPropertyDescriptor(e, k);
|
21
21
|
Object.defineProperty(n, k, d.get ? d : {
|
22
22
|
enumerable: true,
|
23
|
-
get:
|
24
|
-
return e[k];
|
25
|
-
}
|
23
|
+
get: () => e[k]
|
26
24
|
});
|
27
25
|
}
|
28
|
-
}
|
26
|
+
}
|
29
27
|
}
|
30
|
-
n
|
28
|
+
n.default = e;
|
31
29
|
return Object.freeze(n);
|
32
30
|
}
|
33
31
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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);
|
37
|
+
|
38
|
+
/**
|
39
|
+
* --------------------------------------------------------------------------
|
40
|
+
* Bootstrap (v5.1.2): util/index.js
|
41
|
+
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
42
|
+
* --------------------------------------------------------------------------
|
43
|
+
*/
|
40
44
|
|
41
45
|
const toType = obj => {
|
42
46
|
if (obj === null || obj === undefined) {
|
@@ -94,7 +98,7 @@
|
|
94
98
|
}
|
95
99
|
|
96
100
|
if (typeof obj === 'string' && obj.length > 0) {
|
97
|
-
return
|
101
|
+
return document.querySelector(obj);
|
98
102
|
}
|
99
103
|
|
100
104
|
return null;
|
@@ -113,17 +117,11 @@
|
|
113
117
|
};
|
114
118
|
|
115
119
|
const isVisible = element => {
|
116
|
-
if (!element) {
|
120
|
+
if (!isElement(element) || element.getClientRects().length === 0) {
|
117
121
|
return false;
|
118
122
|
}
|
119
123
|
|
120
|
-
|
121
|
-
const elementStyle = getComputedStyle(element);
|
122
|
-
const parentNodeStyle = getComputedStyle(element.parentNode);
|
123
|
-
return elementStyle.display !== 'none' && parentNodeStyle.display !== 'none' && elementStyle.visibility !== 'hidden';
|
124
|
-
}
|
125
|
-
|
126
|
-
return false;
|
124
|
+
return getComputedStyle(element).getPropertyValue('visibility') === 'visible';
|
127
125
|
};
|
128
126
|
|
129
127
|
const isDisabled = element => {
|
@@ -156,9 +154,18 @@
|
|
156
154
|
return null;
|
157
155
|
};
|
158
156
|
|
157
|
+
const DOMContentLoadedCallbacks = [];
|
158
|
+
|
159
159
|
const onDOMContentLoaded = callback => {
|
160
160
|
if (document.readyState === 'loading') {
|
161
|
-
document
|
161
|
+
// add listener on the first call when the document is in loading state
|
162
|
+
if (!DOMContentLoadedCallbacks.length) {
|
163
|
+
document.addEventListener('DOMContentLoaded', () => {
|
164
|
+
DOMContentLoadedCallbacks.forEach(callback => callback());
|
165
|
+
});
|
166
|
+
}
|
167
|
+
|
168
|
+
DOMContentLoadedCallbacks.push(callback);
|
162
169
|
} else {
|
163
170
|
callback();
|
164
171
|
}
|
@@ -184,10 +191,37 @@
|
|
184
191
|
}
|
185
192
|
});
|
186
193
|
};
|
194
|
+
/**
|
195
|
+
* Return the previous/next element of a list.
|
196
|
+
*
|
197
|
+
* @param {array} list The list of elements
|
198
|
+
* @param activeElement The active element
|
199
|
+
* @param shouldGetNext Choose to get next or previous element
|
200
|
+
* @param isCycleAllowed
|
201
|
+
* @return {Element|elem} The proper element
|
202
|
+
*/
|
203
|
+
|
204
|
+
|
205
|
+
const getNextActiveElement = (list, activeElement, shouldGetNext, isCycleAllowed) => {
|
206
|
+
let index = list.indexOf(activeElement); // if the element does not exist in the list return an element depending on the direction and if cycle is allowed
|
207
|
+
|
208
|
+
if (index === -1) {
|
209
|
+
return list[!shouldGetNext && isCycleAllowed ? list.length - 1 : 0];
|
210
|
+
}
|
211
|
+
|
212
|
+
const listLength = list.length;
|
213
|
+
index += shouldGetNext ? 1 : -1;
|
214
|
+
|
215
|
+
if (isCycleAllowed) {
|
216
|
+
index = (index + listLength) % listLength;
|
217
|
+
}
|
218
|
+
|
219
|
+
return list[Math.max(0, Math.min(index, listLength - 1))];
|
220
|
+
};
|
187
221
|
|
188
222
|
/**
|
189
223
|
* --------------------------------------------------------------------------
|
190
|
-
* Bootstrap (v5.
|
224
|
+
* Bootstrap (v5.1.2): dropdown.js
|
191
225
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
192
226
|
* --------------------------------------------------------------------------
|
193
227
|
*/
|
@@ -213,7 +247,6 @@
|
|
213
247
|
const EVENT_HIDDEN = `hidden${EVENT_KEY}`;
|
214
248
|
const EVENT_SHOW = `show${EVENT_KEY}`;
|
215
249
|
const EVENT_SHOWN = `shown${EVENT_KEY}`;
|
216
|
-
const EVENT_CLICK = `click${EVENT_KEY}`;
|
217
250
|
const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`;
|
218
251
|
const EVENT_KEYDOWN_DATA_API = `keydown${EVENT_KEY}${DATA_API_KEY}`;
|
219
252
|
const EVENT_KEYUP_DATA_API = `keyup${EVENT_KEY}${DATA_API_KEY}`;
|
@@ -254,15 +287,13 @@
|
|
254
287
|
* ------------------------------------------------------------------------
|
255
288
|
*/
|
256
289
|
|
257
|
-
class Dropdown extends BaseComponent__default
|
290
|
+
class Dropdown extends BaseComponent__default.default {
|
258
291
|
constructor(element, config) {
|
259
292
|
super(element);
|
260
293
|
this._popper = null;
|
261
294
|
this._config = this._getConfig(config);
|
262
295
|
this._menu = this._getMenuElement();
|
263
296
|
this._inNavbar = this._detectNavbar();
|
264
|
-
|
265
|
-
this._addEventListeners();
|
266
297
|
} // Getters
|
267
298
|
|
268
299
|
|
@@ -280,61 +311,29 @@
|
|
280
311
|
|
281
312
|
|
282
313
|
toggle() {
|
283
|
-
|
284
|
-
return;
|
285
|
-
}
|
286
|
-
|
287
|
-
const isActive = this._element.classList.contains(CLASS_NAME_SHOW);
|
288
|
-
|
289
|
-
if (isActive) {
|
290
|
-
this.hide();
|
291
|
-
return;
|
292
|
-
}
|
293
|
-
|
294
|
-
this.show();
|
314
|
+
return this._isShown() ? this.hide() : this.show();
|
295
315
|
}
|
296
316
|
|
297
317
|
show() {
|
298
|
-
if (isDisabled(this._element) || this._menu
|
318
|
+
if (isDisabled(this._element) || this._isShown(this._menu)) {
|
299
319
|
return;
|
300
320
|
}
|
301
321
|
|
302
|
-
const parent = Dropdown.getParentFromElement(this._element);
|
303
322
|
const relatedTarget = {
|
304
323
|
relatedTarget: this._element
|
305
324
|
};
|
306
|
-
const showEvent = EventHandler__default
|
325
|
+
const showEvent = EventHandler__default.default.trigger(this._element, EVENT_SHOW, relatedTarget);
|
307
326
|
|
308
327
|
if (showEvent.defaultPrevented) {
|
309
328
|
return;
|
310
|
-
}
|
329
|
+
}
|
311
330
|
|
331
|
+
const parent = Dropdown.getParentFromElement(this._element); // Totally disable Popper for Dropdowns in Navbar
|
312
332
|
|
313
333
|
if (this._inNavbar) {
|
314
|
-
Manipulator__default
|
334
|
+
Manipulator__default.default.setDataAttribute(this._menu, 'popper', 'none');
|
315
335
|
} else {
|
316
|
-
|
317
|
-
throw new TypeError('Bootstrap\'s dropdowns require Popper (https://popper.js.org)');
|
318
|
-
}
|
319
|
-
|
320
|
-
let referenceElement = this._element;
|
321
|
-
|
322
|
-
if (this._config.reference === 'parent') {
|
323
|
-
referenceElement = parent;
|
324
|
-
} else if (isElement(this._config.reference)) {
|
325
|
-
referenceElement = getElement(this._config.reference);
|
326
|
-
} else if (typeof this._config.reference === 'object') {
|
327
|
-
referenceElement = this._config.reference;
|
328
|
-
}
|
329
|
-
|
330
|
-
const popperConfig = this._getPopperConfig();
|
331
|
-
|
332
|
-
const isDisplayStatic = popperConfig.modifiers.find(modifier => modifier.name === 'applyStyles' && modifier.enabled === false);
|
333
|
-
this._popper = Popper__namespace.createPopper(referenceElement, this._menu, popperConfig);
|
334
|
-
|
335
|
-
if (isDisplayStatic) {
|
336
|
-
Manipulator__default['default'].setDataAttribute(this._menu, 'popper', 'static');
|
337
|
-
}
|
336
|
+
this._createPopper(parent);
|
338
337
|
} // If this is a touch-enabled device we add extra
|
339
338
|
// empty mouseover listeners to the body's immediate children;
|
340
339
|
// only needed because of broken event delegation on iOS
|
@@ -342,22 +341,22 @@
|
|
342
341
|
|
343
342
|
|
344
343
|
if ('ontouchstart' in document.documentElement && !parent.closest(SELECTOR_NAVBAR_NAV)) {
|
345
|
-
[].concat(...document.body.children).forEach(elem => EventHandler__default
|
344
|
+
[].concat(...document.body.children).forEach(elem => EventHandler__default.default.on(elem, 'mouseover', noop));
|
346
345
|
}
|
347
346
|
|
348
347
|
this._element.focus();
|
349
348
|
|
350
349
|
this._element.setAttribute('aria-expanded', true);
|
351
350
|
|
352
|
-
this._menu.classList.
|
351
|
+
this._menu.classList.add(CLASS_NAME_SHOW);
|
353
352
|
|
354
|
-
this._element.classList.
|
353
|
+
this._element.classList.add(CLASS_NAME_SHOW);
|
355
354
|
|
356
|
-
EventHandler__default
|
355
|
+
EventHandler__default.default.trigger(this._element, EVENT_SHOWN, relatedTarget);
|
357
356
|
}
|
358
357
|
|
359
358
|
hide() {
|
360
|
-
if (isDisabled(this._element) || !this._menu
|
359
|
+
if (isDisabled(this._element) || !this._isShown(this._menu)) {
|
361
360
|
return;
|
362
361
|
}
|
363
362
|
|
@@ -385,15 +384,8 @@
|
|
385
384
|
} // Private
|
386
385
|
|
387
386
|
|
388
|
-
_addEventListeners() {
|
389
|
-
EventHandler__default['default'].on(this._element, EVENT_CLICK, event => {
|
390
|
-
event.preventDefault();
|
391
|
-
this.toggle();
|
392
|
-
});
|
393
|
-
}
|
394
|
-
|
395
387
|
_completeHide(relatedTarget) {
|
396
|
-
const hideEvent = EventHandler__default
|
388
|
+
const hideEvent = EventHandler__default.default.trigger(this._element, EVENT_HIDE, relatedTarget);
|
397
389
|
|
398
390
|
if (hideEvent.defaultPrevented) {
|
399
391
|
return;
|
@@ -402,7 +394,7 @@
|
|
402
394
|
|
403
395
|
|
404
396
|
if ('ontouchstart' in document.documentElement) {
|
405
|
-
[].concat(...document.body.children).forEach(elem => EventHandler__default
|
397
|
+
[].concat(...document.body.children).forEach(elem => EventHandler__default.default.off(elem, 'mouseover', noop));
|
406
398
|
}
|
407
399
|
|
408
400
|
if (this._popper) {
|
@@ -415,13 +407,13 @@
|
|
415
407
|
|
416
408
|
this._element.setAttribute('aria-expanded', 'false');
|
417
409
|
|
418
|
-
Manipulator__default
|
419
|
-
EventHandler__default
|
410
|
+
Manipulator__default.default.removeDataAttribute(this._menu, 'popper');
|
411
|
+
EventHandler__default.default.trigger(this._element, EVENT_HIDDEN, relatedTarget);
|
420
412
|
}
|
421
413
|
|
422
414
|
_getConfig(config) {
|
423
415
|
config = { ...this.constructor.Default,
|
424
|
-
...Manipulator__default
|
416
|
+
...Manipulator__default.default.getDataAttributes(this._element),
|
425
417
|
...config
|
426
418
|
};
|
427
419
|
typeCheckConfig(NAME, config, this.constructor.DefaultType);
|
@@ -434,8 +426,37 @@
|
|
434
426
|
return config;
|
435
427
|
}
|
436
428
|
|
429
|
+
_createPopper(parent) {
|
430
|
+
if (typeof Popper__namespace === 'undefined') {
|
431
|
+
throw new TypeError('Bootstrap\'s dropdowns require Popper (https://popper.js.org)');
|
432
|
+
}
|
433
|
+
|
434
|
+
let referenceElement = this._element;
|
435
|
+
|
436
|
+
if (this._config.reference === 'parent') {
|
437
|
+
referenceElement = parent;
|
438
|
+
} else if (isElement(this._config.reference)) {
|
439
|
+
referenceElement = getElement(this._config.reference);
|
440
|
+
} else if (typeof this._config.reference === 'object') {
|
441
|
+
referenceElement = this._config.reference;
|
442
|
+
}
|
443
|
+
|
444
|
+
const popperConfig = this._getPopperConfig();
|
445
|
+
|
446
|
+
const isDisplayStatic = popperConfig.modifiers.find(modifier => modifier.name === 'applyStyles' && modifier.enabled === false);
|
447
|
+
this._popper = Popper__namespace.createPopper(referenceElement, this._menu, popperConfig);
|
448
|
+
|
449
|
+
if (isDisplayStatic) {
|
450
|
+
Manipulator__default.default.setDataAttribute(this._menu, 'popper', 'static');
|
451
|
+
}
|
452
|
+
}
|
453
|
+
|
454
|
+
_isShown(element = this._element) {
|
455
|
+
return element.classList.contains(CLASS_NAME_SHOW);
|
456
|
+
}
|
457
|
+
|
437
458
|
_getMenuElement() {
|
438
|
-
return SelectorEngine__default
|
459
|
+
return SelectorEngine__default.default.next(this._element, SELECTOR_MENU)[0];
|
439
460
|
}
|
440
461
|
|
441
462
|
_getPlacement() {
|
@@ -507,51 +528,35 @@
|
|
507
528
|
};
|
508
529
|
}
|
509
530
|
|
510
|
-
_selectMenuItem(
|
511
|
-
|
531
|
+
_selectMenuItem({
|
532
|
+
key,
|
533
|
+
target
|
534
|
+
}) {
|
535
|
+
const items = SelectorEngine__default.default.find(SELECTOR_VISIBLE_ITEMS, this._menu).filter(isVisible);
|
512
536
|
|
513
537
|
if (!items.length) {
|
514
538
|
return;
|
515
|
-
}
|
516
|
-
|
517
|
-
let index = items.indexOf(event.target); // Up
|
539
|
+
} // if target isn't included in items (e.g. when expanding the dropdown)
|
540
|
+
// allow cycling to get the last item in case key equals ARROW_UP_KEY
|
518
541
|
|
519
|
-
if (event.key === ARROW_UP_KEY && index > 0) {
|
520
|
-
index--;
|
521
|
-
} // Down
|
522
542
|
|
523
|
-
|
524
|
-
if (event.key === ARROW_DOWN_KEY && index < items.length - 1) {
|
525
|
-
index++;
|
526
|
-
} // index is -1 if the first keydown is an ArrowUp
|
527
|
-
|
528
|
-
|
529
|
-
index = index === -1 ? 0 : index;
|
530
|
-
items[index].focus();
|
543
|
+
getNextActiveElement(items, target, key === ARROW_DOWN_KEY, !items.includes(target)).focus();
|
531
544
|
} // Static
|
532
545
|
|
533
546
|
|
534
|
-
static
|
535
|
-
|
536
|
-
|
537
|
-
const _config = typeof config === 'object' ? config : null;
|
547
|
+
static jQueryInterface(config) {
|
548
|
+
return this.each(function () {
|
549
|
+
const data = Dropdown.getOrCreateInstance(this, config);
|
538
550
|
|
539
|
-
|
540
|
-
|
541
|
-
|
551
|
+
if (typeof config !== 'string') {
|
552
|
+
return;
|
553
|
+
}
|
542
554
|
|
543
|
-
if (typeof config === 'string') {
|
544
555
|
if (typeof data[config] === 'undefined') {
|
545
556
|
throw new TypeError(`No method named "${config}"`);
|
546
557
|
}
|
547
558
|
|
548
559
|
data[config]();
|
549
|
-
}
|
550
|
-
}
|
551
|
-
|
552
|
-
static jQueryInterface(config) {
|
553
|
-
return this.each(function () {
|
554
|
-
Dropdown.dropdownInterface(this, config);
|
555
560
|
});
|
556
561
|
}
|
557
562
|
|
@@ -560,16 +565,16 @@
|
|
560
565
|
return;
|
561
566
|
}
|
562
567
|
|
563
|
-
const toggles = SelectorEngine__default
|
568
|
+
const toggles = SelectorEngine__default.default.find(SELECTOR_DATA_TOGGLE);
|
564
569
|
|
565
570
|
for (let i = 0, len = toggles.length; i < len; i++) {
|
566
|
-
const context =
|
571
|
+
const context = Dropdown.getInstance(toggles[i]);
|
567
572
|
|
568
573
|
if (!context || context._config.autoClose === false) {
|
569
574
|
continue;
|
570
575
|
}
|
571
576
|
|
572
|
-
if (!context.
|
577
|
+
if (!context._isShown()) {
|
573
578
|
continue;
|
574
579
|
}
|
575
580
|
|
@@ -628,25 +633,27 @@
|
|
628
633
|
return;
|
629
634
|
}
|
630
635
|
|
631
|
-
const getToggleButton =
|
636
|
+
const getToggleButton = this.matches(SELECTOR_DATA_TOGGLE) ? this : SelectorEngine__default.default.prev(this, SELECTOR_DATA_TOGGLE)[0];
|
637
|
+
const instance = Dropdown.getOrCreateInstance(getToggleButton);
|
632
638
|
|
633
639
|
if (event.key === ESCAPE_KEY) {
|
634
|
-
|
635
|
-
Dropdown.clearMenus();
|
640
|
+
instance.hide();
|
636
641
|
return;
|
637
642
|
}
|
638
643
|
|
639
|
-
if (
|
640
|
-
|
644
|
+
if (event.key === ARROW_UP_KEY || event.key === ARROW_DOWN_KEY) {
|
645
|
+
if (!isActive) {
|
646
|
+
instance.show();
|
647
|
+
}
|
648
|
+
|
649
|
+
instance._selectMenuItem(event);
|
650
|
+
|
641
651
|
return;
|
642
652
|
}
|
643
653
|
|
644
654
|
if (!isActive || event.key === SPACE_KEY) {
|
645
655
|
Dropdown.clearMenus();
|
646
|
-
return;
|
647
656
|
}
|
648
|
-
|
649
|
-
Dropdown.getInstance(getToggleButton())._selectMenuItem(event);
|
650
657
|
}
|
651
658
|
|
652
659
|
}
|
@@ -657,13 +664,13 @@
|
|
657
664
|
*/
|
658
665
|
|
659
666
|
|
660
|
-
EventHandler__default
|
661
|
-
EventHandler__default
|
662
|
-
EventHandler__default
|
663
|
-
EventHandler__default
|
664
|
-
EventHandler__default
|
667
|
+
EventHandler__default.default.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_DATA_TOGGLE, Dropdown.dataApiKeydownHandler);
|
668
|
+
EventHandler__default.default.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_MENU, Dropdown.dataApiKeydownHandler);
|
669
|
+
EventHandler__default.default.on(document, EVENT_CLICK_DATA_API, Dropdown.clearMenus);
|
670
|
+
EventHandler__default.default.on(document, EVENT_KEYUP_DATA_API, Dropdown.clearMenus);
|
671
|
+
EventHandler__default.default.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
|
665
672
|
event.preventDefault();
|
666
|
-
Dropdown.
|
673
|
+
Dropdown.getOrCreateInstance(this).toggle();
|
667
674
|
});
|
668
675
|
/**
|
669
676
|
* ------------------------------------------------------------------------
|
@@ -676,4 +683,4 @@
|
|
676
683
|
|
677
684
|
return Dropdown;
|
678
685
|
|
679
|
-
}))
|
686
|
+
}));
|