2018-11-13 07:41:12 +01:00
|
|
|
/*!
|
2022-07-19 17:43:58 +02:00
|
|
|
* Bootstrap dropdown.js v5.2.0 (https://getbootstrap.com/)
|
2022-05-13 08:07:23 +02:00
|
|
|
* Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
2020-06-16 20:50:01 +02:00
|
|
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
2018-11-13 07:41:12 +01:00
|
|
|
*/
|
2018-07-24 02:51:14 +02:00
|
|
|
(function (global, factory) {
|
2022-05-13 08:07:23 +02:00
|
|
|
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')) :
|
|
|
|
typeof define === 'function' && define.amd ? define(['@popperjs/core', './util/index', './dom/event-handler', './dom/manipulator', './dom/selector-engine', './base-component'], factory) :
|
|
|
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Dropdown = factory(global["@popperjs/core"], global.Index, global.EventHandler, global.Manipulator, global.SelectorEngine, global.BaseComponent));
|
|
|
|
})(this, (function (Popper, index, EventHandler, Manipulator, SelectorEngine, BaseComponent) { 'use strict';
|
2019-03-01 17:31:34 +01:00
|
|
|
|
2021-10-05 17:50:18 +02:00
|
|
|
const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e };
|
2020-09-14 17:12:06 +02:00
|
|
|
|
2020-12-07 16:50:24 +01:00
|
|
|
function _interopNamespace(e) {
|
|
|
|
if (e && e.__esModule) return e;
|
2022-05-13 08:07:23 +02:00
|
|
|
const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } });
|
2020-12-07 16:50:24 +01:00
|
|
|
if (e) {
|
2021-10-05 17:50:18 +02:00
|
|
|
for (const k in e) {
|
2020-12-07 16:50:24 +01:00
|
|
|
if (k !== 'default') {
|
2021-10-05 17:50:18 +02:00
|
|
|
const d = Object.getOwnPropertyDescriptor(e, k);
|
2020-12-07 16:50:24 +01:00
|
|
|
Object.defineProperty(n, k, d.get ? d : {
|
|
|
|
enumerable: true,
|
2021-10-05 17:50:18 +02:00
|
|
|
get: () => e[k]
|
2020-12-07 16:50:24 +01:00
|
|
|
});
|
|
|
|
}
|
2021-10-05 17:50:18 +02:00
|
|
|
}
|
2020-12-07 16:50:24 +01:00
|
|
|
}
|
2021-10-05 17:50:18 +02:00
|
|
|
n.default = e;
|
2020-12-07 16:50:24 +01:00
|
|
|
return Object.freeze(n);
|
|
|
|
}
|
|
|
|
|
2021-10-05 17:50:18 +02:00
|
|
|
const Popper__namespace = /*#__PURE__*/_interopNamespace(Popper);
|
|
|
|
const EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler);
|
|
|
|
const Manipulator__default = /*#__PURE__*/_interopDefaultLegacy(Manipulator);
|
|
|
|
const SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine);
|
|
|
|
const BaseComponent__default = /*#__PURE__*/_interopDefaultLegacy(BaseComponent);
|
2021-02-10 17:14:51 +01:00
|
|
|
|
2021-08-04 17:41:51 +02:00
|
|
|
/**
|
|
|
|
* --------------------------------------------------------------------------
|
2022-07-19 17:43:58 +02:00
|
|
|
* Bootstrap (v5.2.0): dropdown.js
|
2021-03-23 17:26:54 +01:00
|
|
|
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
|
|
|
* --------------------------------------------------------------------------
|
|
|
|
*/
|
2020-12-03 15:18:59 +01:00
|
|
|
/**
|
|
|
|
* Constants
|
|
|
|
*/
|
|
|
|
|
2021-03-23 17:26:54 +01:00
|
|
|
const NAME = 'dropdown';
|
|
|
|
const DATA_KEY = 'bs.dropdown';
|
|
|
|
const EVENT_KEY = `.${DATA_KEY}`;
|
|
|
|
const DATA_API_KEY = '.data-api';
|
|
|
|
const ESCAPE_KEY = 'Escape';
|
|
|
|
const TAB_KEY = 'Tab';
|
|
|
|
const ARROW_UP_KEY = 'ArrowUp';
|
|
|
|
const ARROW_DOWN_KEY = 'ArrowDown';
|
|
|
|
const RIGHT_MOUSE_BUTTON = 2; // MouseEvent.button value for the secondary button, usually the right button
|
|
|
|
|
|
|
|
const EVENT_HIDE = `hide${EVENT_KEY}`;
|
|
|
|
const EVENT_HIDDEN = `hidden${EVENT_KEY}`;
|
|
|
|
const EVENT_SHOW = `show${EVENT_KEY}`;
|
|
|
|
const EVENT_SHOWN = `shown${EVENT_KEY}`;
|
|
|
|
const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`;
|
|
|
|
const EVENT_KEYDOWN_DATA_API = `keydown${EVENT_KEY}${DATA_API_KEY}`;
|
|
|
|
const EVENT_KEYUP_DATA_API = `keyup${EVENT_KEY}${DATA_API_KEY}`;
|
|
|
|
const CLASS_NAME_SHOW = 'show';
|
|
|
|
const CLASS_NAME_DROPUP = 'dropup';
|
|
|
|
const CLASS_NAME_DROPEND = 'dropend';
|
|
|
|
const CLASS_NAME_DROPSTART = 'dropstart';
|
2022-05-13 08:07:23 +02:00
|
|
|
const CLASS_NAME_DROPUP_CENTER = 'dropup-center';
|
|
|
|
const CLASS_NAME_DROPDOWN_CENTER = 'dropdown-center';
|
|
|
|
const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="dropdown"]:not(.disabled):not(:disabled)';
|
|
|
|
const SELECTOR_DATA_TOGGLE_SHOWN = `${SELECTOR_DATA_TOGGLE}.${CLASS_NAME_SHOW}`;
|
2021-03-23 17:26:54 +01:00
|
|
|
const SELECTOR_MENU = '.dropdown-menu';
|
2022-05-13 08:07:23 +02:00
|
|
|
const SELECTOR_NAVBAR = '.navbar';
|
2021-03-23 17:26:54 +01:00
|
|
|
const SELECTOR_NAVBAR_NAV = '.navbar-nav';
|
|
|
|
const SELECTOR_VISIBLE_ITEMS = '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)';
|
2022-05-13 08:07:23 +02:00
|
|
|
const PLACEMENT_TOP = index.isRTL() ? 'top-end' : 'top-start';
|
|
|
|
const PLACEMENT_TOPEND = index.isRTL() ? 'top-start' : 'top-end';
|
|
|
|
const PLACEMENT_BOTTOM = index.isRTL() ? 'bottom-end' : 'bottom-start';
|
|
|
|
const PLACEMENT_BOTTOMEND = index.isRTL() ? 'bottom-start' : 'bottom-end';
|
|
|
|
const PLACEMENT_RIGHT = index.isRTL() ? 'left-start' : 'right-start';
|
|
|
|
const PLACEMENT_LEFT = index.isRTL() ? 'right-start' : 'left-start';
|
|
|
|
const PLACEMENT_TOPCENTER = 'top';
|
|
|
|
const PLACEMENT_BOTTOMCENTER = 'bottom';
|
2021-03-23 17:26:54 +01:00
|
|
|
const Default = {
|
2022-07-19 17:43:58 +02:00
|
|
|
autoClose: true,
|
2020-12-07 16:50:24 +01:00
|
|
|
boundary: 'clippingParents',
|
2019-08-27 15:03:21 +02:00
|
|
|
display: 'dynamic',
|
2022-07-19 17:43:58 +02:00
|
|
|
offset: [0, 2],
|
2021-05-05 21:32:12 +02:00
|
|
|
popperConfig: null,
|
2022-07-19 17:43:58 +02:00
|
|
|
reference: 'toggle'
|
2018-11-13 07:41:12 +01:00
|
|
|
};
|
2021-03-23 17:26:54 +01:00
|
|
|
const DefaultType = {
|
2022-07-19 17:43:58 +02:00
|
|
|
autoClose: '(boolean|string)',
|
2018-11-13 07:41:12 +01:00
|
|
|
boundary: '(string|element)',
|
2019-08-27 15:03:21 +02:00
|
|
|
display: 'string',
|
2022-07-19 17:43:58 +02:00
|
|
|
offset: '(array|string|function)',
|
2021-05-05 21:32:12 +02:00
|
|
|
popperConfig: '(null|object|function)',
|
2022-07-19 17:43:58 +02:00
|
|
|
reference: '(string|element|object)'
|
2018-11-13 07:41:12 +01:00
|
|
|
};
|
2019-10-08 08:39:10 +02:00
|
|
|
/**
|
2022-05-13 08:07:23 +02:00
|
|
|
* Class definition
|
2019-10-08 08:39:10 +02:00
|
|
|
*/
|
2015-05-13 21:48:34 +02:00
|
|
|
|
2021-10-05 17:50:18 +02:00
|
|
|
class Dropdown extends BaseComponent__default.default {
|
2021-03-23 17:26:54 +01:00
|
|
|
constructor(element, config) {
|
2022-05-13 08:07:23 +02:00
|
|
|
super(element, config);
|
2021-03-23 17:26:54 +01:00
|
|
|
this._popper = null;
|
2022-05-13 08:07:23 +02:00
|
|
|
this._parent = this._element.parentNode; // dropdown wrapper
|
|
|
|
|
|
|
|
this._menu = SelectorEngine__default.default.findOne(SELECTOR_MENU, this._parent);
|
2021-03-23 17:26:54 +01:00
|
|
|
this._inNavbar = this._detectNavbar();
|
|
|
|
} // Getters
|
2020-12-03 15:18:59 +01:00
|
|
|
|
2015-05-10 22:47:11 +02:00
|
|
|
|
2021-03-23 17:26:54 +01:00
|
|
|
static get Default() {
|
|
|
|
return Default;
|
|
|
|
}
|
2019-03-01 17:31:34 +01:00
|
|
|
|
2021-03-23 17:26:54 +01:00
|
|
|
static get DefaultType() {
|
|
|
|
return DefaultType;
|
|
|
|
}
|
2015-08-13 06:12:03 +02:00
|
|
|
|
2021-05-13 18:22:20 +02:00
|
|
|
static get NAME() {
|
|
|
|
return NAME;
|
2021-03-23 17:26:54 +01:00
|
|
|
} // Public
|
2015-05-10 22:47:11 +02:00
|
|
|
|
|
|
|
|
2021-03-23 17:26:54 +01:00
|
|
|
toggle() {
|
2021-08-04 17:41:51 +02:00
|
|
|
return this._isShown() ? this.hide() : this.show();
|
2021-03-23 17:26:54 +01:00
|
|
|
}
|
2019-08-27 15:03:21 +02:00
|
|
|
|
2021-03-23 17:26:54 +01:00
|
|
|
show() {
|
2022-05-13 08:07:23 +02:00
|
|
|
if (index.isDisabled(this._element) || this._isShown()) {
|
2019-08-27 15:03:21 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-03-23 17:26:54 +01:00
|
|
|
const relatedTarget = {
|
2018-11-13 07:41:12 +01:00
|
|
|
relatedTarget: this._element
|
|
|
|
};
|
2021-10-05 17:50:18 +02:00
|
|
|
const showEvent = EventHandler__default.default.trigger(this._element, EVENT_SHOW, relatedTarget);
|
2017-10-30 00:19:14 +01:00
|
|
|
|
2019-03-01 17:31:34 +01:00
|
|
|
if (showEvent.defaultPrevented) {
|
2018-11-13 07:41:12 +01:00
|
|
|
return;
|
2021-08-04 17:41:51 +02:00
|
|
|
}
|
2017-09-06 06:05:12 +02:00
|
|
|
|
2022-05-13 08:07:23 +02:00
|
|
|
this._createPopper(); // If this is a touch-enabled device we add extra
|
2018-11-13 07:41:12 +01:00
|
|
|
// empty mouseover listeners to the body's immediate children;
|
|
|
|
// only needed because of broken event delegation on iOS
|
|
|
|
// https://www.quirksmode.org/blog/archives/2014/02/mouse_event_bub.html
|
2017-09-30 23:28:03 +02:00
|
|
|
|
|
|
|
|
2022-05-13 08:07:23 +02:00
|
|
|
if ('ontouchstart' in document.documentElement && !this._parent.closest(SELECTOR_NAVBAR_NAV)) {
|
|
|
|
for (const element of [].concat(...document.body.children)) {
|
|
|
|
EventHandler__default.default.on(element, 'mouseover', index.noop);
|
|
|
|
}
|
2018-11-13 07:41:12 +01:00
|
|
|
}
|
2017-09-30 23:28:03 +02:00
|
|
|
|
2018-11-13 07:41:12 +01:00
|
|
|
this._element.focus();
|
2017-09-30 23:28:03 +02:00
|
|
|
|
2018-11-13 07:41:12 +01:00
|
|
|
this._element.setAttribute('aria-expanded', true);
|
2015-05-13 21:48:34 +02:00
|
|
|
|
2021-08-04 17:41:51 +02:00
|
|
|
this._menu.classList.add(CLASS_NAME_SHOW);
|
2020-10-28 04:45:48 +01:00
|
|
|
|
2021-08-04 17:41:51 +02:00
|
|
|
this._element.classList.add(CLASS_NAME_SHOW);
|
2020-10-28 04:45:48 +01:00
|
|
|
|
2021-10-05 17:50:18 +02:00
|
|
|
EventHandler__default.default.trigger(this._element, EVENT_SHOWN, relatedTarget);
|
2021-03-23 17:26:54 +01:00
|
|
|
}
|
2018-11-13 07:41:12 +01:00
|
|
|
|
2021-03-23 17:26:54 +01:00
|
|
|
hide() {
|
2022-05-13 08:07:23 +02:00
|
|
|
if (index.isDisabled(this._element) || !this._isShown()) {
|
2018-11-13 07:41:12 +01:00
|
|
|
return;
|
|
|
|
}
|
2017-09-30 23:28:03 +02:00
|
|
|
|
2021-03-23 17:26:54 +01:00
|
|
|
const relatedTarget = {
|
2018-11-13 07:41:12 +01:00
|
|
|
relatedTarget: this._element
|
2018-07-24 02:51:14 +02:00
|
|
|
};
|
2017-09-30 23:28:03 +02:00
|
|
|
|
2021-05-05 21:32:12 +02:00
|
|
|
this._completeHide(relatedTarget);
|
2021-03-23 17:26:54 +01:00
|
|
|
}
|
2020-12-03 15:18:59 +01:00
|
|
|
|
2021-03-23 17:26:54 +01:00
|
|
|
dispose() {
|
2019-08-27 15:03:21 +02:00
|
|
|
if (this._popper) {
|
2018-11-13 07:41:12 +01:00
|
|
|
this._popper.destroy();
|
|
|
|
}
|
2017-09-30 23:28:03 +02:00
|
|
|
|
2021-03-23 17:26:54 +01:00
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
update() {
|
2018-11-13 07:41:12 +01:00
|
|
|
this._inNavbar = this._detectNavbar();
|
2017-09-30 23:28:03 +02:00
|
|
|
|
2019-08-27 15:03:21 +02:00
|
|
|
if (this._popper) {
|
2020-12-07 16:50:24 +01:00
|
|
|
this._popper.update();
|
2018-11-13 07:41:12 +01:00
|
|
|
}
|
2019-01-04 17:29:45 +01:00
|
|
|
} // Private
|
2017-10-16 00:51:44 +02:00
|
|
|
|
|
|
|
|
2021-05-05 21:32:12 +02:00
|
|
|
_completeHide(relatedTarget) {
|
2021-10-05 17:50:18 +02:00
|
|
|
const hideEvent = EventHandler__default.default.trigger(this._element, EVENT_HIDE, relatedTarget);
|
2021-05-05 21:32:12 +02:00
|
|
|
|
|
|
|
if (hideEvent.defaultPrevented) {
|
|
|
|
return;
|
|
|
|
} // If this is a touch-enabled device we remove the extra
|
|
|
|
// empty mouseover listeners we added for iOS support
|
|
|
|
|
|
|
|
|
|
|
|
if ('ontouchstart' in document.documentElement) {
|
2022-05-13 08:07:23 +02:00
|
|
|
for (const element of [].concat(...document.body.children)) {
|
|
|
|
EventHandler__default.default.off(element, 'mouseover', index.noop);
|
|
|
|
}
|
2021-05-05 21:32:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (this._popper) {
|
|
|
|
this._popper.destroy();
|
|
|
|
}
|
|
|
|
|
|
|
|
this._menu.classList.remove(CLASS_NAME_SHOW);
|
|
|
|
|
|
|
|
this._element.classList.remove(CLASS_NAME_SHOW);
|
|
|
|
|
|
|
|
this._element.setAttribute('aria-expanded', 'false');
|
|
|
|
|
2021-10-05 17:50:18 +02:00
|
|
|
Manipulator__default.default.removeDataAttribute(this._menu, 'popper');
|
|
|
|
EventHandler__default.default.trigger(this._element, EVENT_HIDDEN, relatedTarget);
|
2021-05-05 21:32:12 +02:00
|
|
|
}
|
|
|
|
|
2021-03-23 17:26:54 +01:00
|
|
|
_getConfig(config) {
|
2022-05-13 08:07:23 +02:00
|
|
|
config = super._getConfig(config);
|
2021-02-10 17:14:51 +01:00
|
|
|
|
2022-05-13 08:07:23 +02:00
|
|
|
if (typeof config.reference === 'object' && !index.isElement(config.reference) && typeof config.reference.getBoundingClientRect !== 'function') {
|
2021-02-10 17:14:51 +01:00
|
|
|
// Popper virtual elements require a getBoundingClientRect method
|
2021-03-23 17:26:54 +01:00
|
|
|
throw new TypeError(`${NAME.toUpperCase()}: Option "reference" provided type "object" without a required "getBoundingClientRect" method.`);
|
2021-02-10 17:14:51 +01:00
|
|
|
}
|
|
|
|
|
2018-11-13 07:41:12 +01:00
|
|
|
return config;
|
2021-03-23 17:26:54 +01:00
|
|
|
}
|
2018-02-19 23:50:56 +01:00
|
|
|
|
2022-05-13 08:07:23 +02:00
|
|
|
_createPopper() {
|
2021-08-04 17:41:51 +02:00
|
|
|
if (typeof Popper__namespace === 'undefined') {
|
|
|
|
throw new TypeError('Bootstrap\'s dropdowns require Popper (https://popper.js.org)');
|
|
|
|
}
|
|
|
|
|
|
|
|
let referenceElement = this._element;
|
|
|
|
|
|
|
|
if (this._config.reference === 'parent') {
|
2022-05-13 08:07:23 +02:00
|
|
|
referenceElement = this._parent;
|
|
|
|
} else if (index.isElement(this._config.reference)) {
|
|
|
|
referenceElement = index.getElement(this._config.reference);
|
2021-08-04 17:41:51 +02:00
|
|
|
} else if (typeof this._config.reference === 'object') {
|
|
|
|
referenceElement = this._config.reference;
|
|
|
|
}
|
|
|
|
|
|
|
|
const popperConfig = this._getPopperConfig();
|
|
|
|
|
|
|
|
this._popper = Popper__namespace.createPopper(referenceElement, this._menu, popperConfig);
|
|
|
|
}
|
|
|
|
|
2022-05-13 08:07:23 +02:00
|
|
|
_isShown() {
|
|
|
|
return this._menu.classList.contains(CLASS_NAME_SHOW);
|
2021-03-23 17:26:54 +01:00
|
|
|
}
|
2017-09-30 23:28:03 +02:00
|
|
|
|
2021-03-23 17:26:54 +01:00
|
|
|
_getPlacement() {
|
2022-05-13 08:07:23 +02:00
|
|
|
const parentDropdown = this._parent;
|
2017-09-30 23:28:03 +02:00
|
|
|
|
2020-12-07 16:50:24 +01:00
|
|
|
if (parentDropdown.classList.contains(CLASS_NAME_DROPEND)) {
|
|
|
|
return PLACEMENT_RIGHT;
|
2018-11-13 07:41:12 +01:00
|
|
|
}
|
2018-07-24 02:51:14 +02:00
|
|
|
|
2020-12-07 16:50:24 +01:00
|
|
|
if (parentDropdown.classList.contains(CLASS_NAME_DROPSTART)) {
|
|
|
|
return PLACEMENT_LEFT;
|
2022-05-13 08:07:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (parentDropdown.classList.contains(CLASS_NAME_DROPUP_CENTER)) {
|
|
|
|
return PLACEMENT_TOPCENTER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (parentDropdown.classList.contains(CLASS_NAME_DROPDOWN_CENTER)) {
|
|
|
|
return PLACEMENT_BOTTOMCENTER;
|
2020-12-07 16:50:24 +01:00
|
|
|
} // We need to trim the value because custom properties can also include spaces
|
2017-09-30 23:28:03 +02:00
|
|
|
|
2018-11-13 07:41:12 +01:00
|
|
|
|
2021-03-23 17:26:54 +01:00
|
|
|
const isEnd = getComputedStyle(this._menu).getPropertyValue('--bs-position').trim() === 'end';
|
2018-11-13 07:41:12 +01:00
|
|
|
|
2020-12-07 16:50:24 +01:00
|
|
|
if (parentDropdown.classList.contains(CLASS_NAME_DROPUP)) {
|
|
|
|
return isEnd ? PLACEMENT_TOPEND : PLACEMENT_TOP;
|
2018-11-13 07:41:12 +01:00
|
|
|
}
|
2018-07-24 02:51:14 +02:00
|
|
|
|
2020-12-07 16:50:24 +01:00
|
|
|
return isEnd ? PLACEMENT_BOTTOMEND : PLACEMENT_BOTTOM;
|
2021-03-23 17:26:54 +01:00
|
|
|
}
|
2019-02-11 20:15:34 +01:00
|
|
|
|
2021-03-23 17:26:54 +01:00
|
|
|
_detectNavbar() {
|
2022-05-13 08:07:23 +02:00
|
|
|
return this._element.closest(SELECTOR_NAVBAR) !== null;
|
2021-03-23 17:26:54 +01:00
|
|
|
}
|
2021-02-10 17:14:51 +01:00
|
|
|
|
2021-03-23 17:26:54 +01:00
|
|
|
_getOffset() {
|
|
|
|
const {
|
|
|
|
offset
|
|
|
|
} = this._config;
|
2021-02-10 17:14:51 +01:00
|
|
|
|
|
|
|
if (typeof offset === 'string') {
|
2022-05-13 08:07:23 +02:00
|
|
|
return offset.split(',').map(value => Number.parseInt(value, 10));
|
2021-02-10 17:14:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (typeof offset === 'function') {
|
2021-03-23 17:26:54 +01:00
|
|
|
return popperData => offset(popperData, this._element);
|
2021-02-10 17:14:51 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
return offset;
|
2021-03-23 17:26:54 +01:00
|
|
|
}
|
2021-02-10 17:14:51 +01:00
|
|
|
|
2021-03-23 17:26:54 +01:00
|
|
|
_getPopperConfig() {
|
|
|
|
const defaultBsPopperConfig = {
|
2018-11-13 07:41:12 +01:00
|
|
|
placement: this._getPlacement(),
|
2020-12-07 16:50:24 +01:00
|
|
|
modifiers: [{
|
|
|
|
name: 'preventOverflow',
|
|
|
|
options: {
|
2021-02-10 17:14:51 +01:00
|
|
|
boundary: this._config.boundary
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
name: 'offset',
|
|
|
|
options: {
|
|
|
|
offset: this._getOffset()
|
2017-09-06 06:05:12 +02:00
|
|
|
}
|
2020-12-07 16:50:24 +01:00
|
|
|
}]
|
2022-05-13 08:07:23 +02:00
|
|
|
}; // Disable Popper if we have a static display or Dropdown is in Navbar
|
|
|
|
|
|
|
|
if (this._inNavbar || this._config.display === 'static') {
|
|
|
|
Manipulator__default.default.setDataAttribute(this._menu, 'popper', 'static'); // todo:v6 remove
|
2017-06-18 09:14:35 +02:00
|
|
|
|
2021-02-10 17:14:51 +01:00
|
|
|
defaultBsPopperConfig.modifiers = [{
|
2020-12-07 16:50:24 +01:00
|
|
|
name: 'applyStyles',
|
2018-11-13 07:41:12 +01:00
|
|
|
enabled: false
|
2020-12-07 16:50:24 +01:00
|
|
|
}];
|
2018-11-13 07:41:12 +01:00
|
|
|
}
|
2017-09-30 23:28:03 +02:00
|
|
|
|
2021-03-23 17:26:54 +01:00
|
|
|
return { ...defaultBsPopperConfig,
|
|
|
|
...(typeof this._config.popperConfig === 'function' ? this._config.popperConfig(defaultBsPopperConfig) : this._config.popperConfig)
|
|
|
|
};
|
2021-05-05 21:32:12 +02:00
|
|
|
}
|
|
|
|
|
2021-06-22 20:29:16 +02:00
|
|
|
_selectMenuItem({
|
|
|
|
key,
|
|
|
|
target
|
|
|
|
}) {
|
2022-05-13 08:07:23 +02:00
|
|
|
const items = SelectorEngine__default.default.find(SELECTOR_VISIBLE_ITEMS, this._menu).filter(element => index.isVisible(element));
|
2021-05-05 21:32:12 +02:00
|
|
|
|
|
|
|
if (!items.length) {
|
|
|
|
return;
|
2021-06-22 20:29:16 +02:00
|
|
|
} // if target isn't included in items (e.g. when expanding the dropdown)
|
|
|
|
// allow cycling to get the last item in case key equals ARROW_UP_KEY
|
2021-05-05 21:32:12 +02:00
|
|
|
|
|
|
|
|
2022-05-13 08:07:23 +02:00
|
|
|
index.getNextActiveElement(items, target, key === ARROW_DOWN_KEY, !items.includes(target)).focus();
|
2019-01-04 17:29:45 +01:00
|
|
|
} // Static
|
2015-05-10 22:47:11 +02:00
|
|
|
|
|
|
|
|
2021-08-04 17:41:51 +02:00
|
|
|
static jQueryInterface(config) {
|
|
|
|
return this.each(function () {
|
|
|
|
const data = Dropdown.getOrCreateInstance(this, config);
|
|
|
|
|
|
|
|
if (typeof config !== 'string') {
|
|
|
|
return;
|
|
|
|
}
|
2019-03-01 17:31:34 +01:00
|
|
|
|
|
|
|
if (typeof data[config] === 'undefined') {
|
2021-03-23 17:26:54 +01:00
|
|
|
throw new TypeError(`No method named "${config}"`);
|
2018-11-13 07:41:12 +01:00
|
|
|
}
|
2017-05-16 09:59:44 +02:00
|
|
|
|
2019-03-01 17:31:34 +01:00
|
|
|
data[config]();
|
2018-11-13 07:41:12 +01:00
|
|
|
});
|
2021-03-23 17:26:54 +01:00
|
|
|
}
|
2015-05-10 22:47:11 +02:00
|
|
|
|
2021-03-23 17:26:54 +01:00
|
|
|
static clearMenus(event) {
|
2022-05-13 08:07:23 +02:00
|
|
|
if (event.button === RIGHT_MOUSE_BUTTON || event.type === 'keyup' && event.key !== TAB_KEY) {
|
2021-05-13 18:22:20 +02:00
|
|
|
return;
|
2018-11-13 07:41:12 +01:00
|
|
|
}
|
2016-10-10 02:26:51 +02:00
|
|
|
|
2022-05-13 08:07:23 +02:00
|
|
|
const openToggles = SelectorEngine__default.default.find(SELECTOR_DATA_TOGGLE_SHOWN);
|
2017-03-20 03:03:32 +01:00
|
|
|
|
2022-05-13 08:07:23 +02:00
|
|
|
for (const toggle of openToggles) {
|
|
|
|
const context = Dropdown.getInstance(toggle);
|
2017-09-30 23:28:03 +02:00
|
|
|
|
2021-05-05 21:32:12 +02:00
|
|
|
if (!context || context._config.autoClose === false) {
|
2018-11-13 07:41:12 +01:00
|
|
|
continue;
|
2018-07-24 02:51:14 +02:00
|
|
|
}
|
2015-05-10 22:47:11 +02:00
|
|
|
|
2022-05-13 08:07:23 +02:00
|
|
|
const composedPath = event.composedPath();
|
|
|
|
const isMenuTarget = composedPath.includes(context._menu);
|
|
|
|
|
|
|
|
if (composedPath.includes(context._element) || context._config.autoClose === 'inside' && !isMenuTarget || context._config.autoClose === 'outside' && isMenuTarget) {
|
|
|
|
continue;
|
|
|
|
} // Tab navigation through the dropdown menu or events from contained inputs shouldn't close the menu
|
|
|
|
|
|
|
|
|
|
|
|
if (context._menu.contains(event.target) && (event.type === 'keyup' && event.key === TAB_KEY || /input|select|option|textarea|form/i.test(event.target.tagName))) {
|
2018-11-13 07:41:12 +01:00
|
|
|
continue;
|
|
|
|
}
|
2017-12-31 04:41:36 +01:00
|
|
|
|
2021-05-05 21:32:12 +02:00
|
|
|
const relatedTarget = {
|
|
|
|
relatedTarget: context._element
|
|
|
|
};
|
|
|
|
|
2022-05-13 08:07:23 +02:00
|
|
|
if (event.type === 'click') {
|
|
|
|
relatedTarget.clickEvent = event;
|
2019-08-27 15:03:21 +02:00
|
|
|
}
|
|
|
|
|
2021-05-05 21:32:12 +02:00
|
|
|
context._completeHide(relatedTarget);
|
2018-11-13 07:41:12 +01:00
|
|
|
}
|
2021-03-23 17:26:54 +01:00
|
|
|
}
|
2015-05-10 22:47:11 +02:00
|
|
|
|
2021-03-23 17:26:54 +01:00
|
|
|
static dataApiKeydownHandler(event) {
|
2022-05-13 08:07:23 +02:00
|
|
|
// If not an UP | DOWN | ESCAPE key => not a dropdown command
|
|
|
|
// If input/textarea && if key is other than ESCAPE => not a dropdown command
|
|
|
|
const isInput = /input|textarea/i.test(event.target.tagName);
|
|
|
|
const isEscapeEvent = event.key === ESCAPE_KEY;
|
|
|
|
const isUpOrDownEvent = [ARROW_UP_KEY, ARROW_DOWN_KEY].includes(event.key);
|
2015-05-10 22:47:11 +02:00
|
|
|
|
2022-05-13 08:07:23 +02:00
|
|
|
if (!isUpOrDownEvent && !isEscapeEvent) {
|
2021-05-05 21:32:12 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-05-13 08:07:23 +02:00
|
|
|
if (isInput && !isEscapeEvent) {
|
2018-11-13 07:41:12 +01:00
|
|
|
return;
|
|
|
|
}
|
2015-08-19 05:28:28 +02:00
|
|
|
|
2022-05-13 08:07:23 +02:00
|
|
|
event.preventDefault();
|
|
|
|
const getToggleButton = SelectorEngine__default.default.findOne(SELECTOR_DATA_TOGGLE, event.delegateTarget.parentNode);
|
2021-08-04 17:41:51 +02:00
|
|
|
const instance = Dropdown.getOrCreateInstance(getToggleButton);
|
2015-08-19 05:28:28 +02:00
|
|
|
|
2022-05-13 08:07:23 +02:00
|
|
|
if (isUpOrDownEvent) {
|
|
|
|
event.stopPropagation();
|
|
|
|
instance.show();
|
2021-06-22 20:29:16 +02:00
|
|
|
|
2021-08-04 17:41:51 +02:00
|
|
|
instance._selectMenuItem(event);
|
2021-06-22 20:29:16 +02:00
|
|
|
|
2021-02-10 17:14:51 +01:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-05-13 08:07:23 +02:00
|
|
|
if (instance._isShown()) {
|
|
|
|
// else is escape and we check if it is shown
|
|
|
|
event.stopPropagation();
|
|
|
|
instance.hide();
|
|
|
|
getToggleButton.focus();
|
2018-11-13 07:41:12 +01:00
|
|
|
}
|
2021-03-23 17:26:54 +01:00
|
|
|
}
|
2018-11-13 07:41:12 +01:00
|
|
|
|
2021-03-23 17:26:54 +01:00
|
|
|
}
|
2018-11-13 07:41:12 +01:00
|
|
|
/**
|
2022-05-13 08:07:23 +02:00
|
|
|
* Data API implementation
|
2018-11-13 07:41:12 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
2021-10-05 17:50:18 +02:00
|
|
|
EventHandler__default.default.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_DATA_TOGGLE, Dropdown.dataApiKeydownHandler);
|
|
|
|
EventHandler__default.default.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_MENU, Dropdown.dataApiKeydownHandler);
|
|
|
|
EventHandler__default.default.on(document, EVENT_CLICK_DATA_API, Dropdown.clearMenus);
|
|
|
|
EventHandler__default.default.on(document, EVENT_KEYUP_DATA_API, Dropdown.clearMenus);
|
|
|
|
EventHandler__default.default.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
|
2018-11-13 07:41:12 +01:00
|
|
|
event.preventDefault();
|
2021-08-04 17:41:51 +02:00
|
|
|
Dropdown.getOrCreateInstance(this).toggle();
|
2018-11-13 07:41:12 +01:00
|
|
|
});
|
|
|
|
/**
|
|
|
|
* jQuery
|
|
|
|
*/
|
|
|
|
|
2022-05-13 08:07:23 +02:00
|
|
|
index.defineJQueryPlugin(Dropdown);
|
2015-05-10 22:47:11 +02:00
|
|
|
|
|
|
|
return Dropdown;
|
2018-07-24 02:51:14 +02:00
|
|
|
|
2021-10-05 17:50:18 +02:00
|
|
|
}));
|
2018-07-24 02:51:14 +02:00
|
|
|
//# sourceMappingURL=dropdown.js.map
|