mekari-ui-toolkit
Version:
Mekari ui toolkit
1,676 lines (1,349 loc) • 119 kB
JavaScript
/*!
* Mekari UI (https://bitbucket.org/mekariuitoolkit/mekari-ui-toolkit#readme)
* Copyright 2011-2021 Mekari
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('jquery'), require('popper.js')) :
typeof define === 'function' && define.amd ? define(['exports', 'jquery', 'popper.js'], factory) :
(global = global || self, factory(global['mekari-ui'] = {}, global.jQuery, global.Popper));
}(this, function (exports, $, Popper) { 'use strict';
$ = $ && $.hasOwnProperty('default') ? $['default'] : $;
Popper = Popper && Popper.hasOwnProperty('default') ? Popper['default'] : Popper;
/**
* --------------------------------------------------------------------------
* Bootstrap (v4.5.2): util.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* ------------------------------------------------------------------------
* Private TransitionEnd Helpers
* ------------------------------------------------------------------------
*/
const TRANSITION_END = 'transitionend';
const MAX_UID = 1000000;
const MILLISECONDS_MULTIPLIER = 1000;
// Shoutout AngusCroll (https://goo.gl/pxwQGp)
function toType(obj) {
if (obj === null || typeof obj === 'undefined') {
return `${obj}`
}
return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase()
}
function getSpecialTransitionEndEvent() {
return {
bindType: TRANSITION_END,
delegateType: TRANSITION_END,
handle(event) {
if ($(event.target).is(this)) {
return event.handleObj.handler.apply(this, arguments) // eslint-disable-line prefer-rest-params
}
return undefined
}
}
}
function transitionEndEmulator(duration) {
let called = false;
$(this).one(Util.TRANSITION_END, () => {
called = true;
});
setTimeout(() => {
if (!called) {
Util.triggerTransitionEnd(this);
}
}, duration);
return this
}
function setTransitionEndSupport() {
$.fn.emulateTransitionEnd = transitionEndEmulator;
$.event.special[Util.TRANSITION_END] = getSpecialTransitionEndEvent();
}
/**
* --------------------------------------------------------------------------
* Public Util Api
* --------------------------------------------------------------------------
*/
const Util = {
TRANSITION_END: 'bsTransitionEnd',
getUID(prefix) {
do {
// eslint-disable-next-line no-bitwise
prefix += ~~(Math.random() * MAX_UID); // "~~" acts like a faster Math.floor() here
} while (document.getElementById(prefix))
return prefix
},
getSelectorFromElement(element) {
let selector = element.getAttribute('data-target');
if (!selector || selector === '#') {
const hrefAttr = element.getAttribute('href');
selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : '';
}
try {
return document.querySelector(selector) ? selector : null
} catch (err) {
return null
}
},
getTransitionDurationFromElement(element) {
if (!element) {
return 0
}
// Get transition-duration of the element
let transitionDuration = $(element).css('transition-duration');
let transitionDelay = $(element).css('transition-delay');
const floatTransitionDuration = parseFloat(transitionDuration);
const floatTransitionDelay = parseFloat(transitionDelay);
// Return 0 if element or transition duration is not found
if (!floatTransitionDuration && !floatTransitionDelay) {
return 0
}
// If multiple durations are defined, take the first
transitionDuration = transitionDuration.split(',')[0];
transitionDelay = transitionDelay.split(',')[0];
return (parseFloat(transitionDuration) + parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER
},
reflow(element) {
return element.offsetHeight
},
triggerTransitionEnd(element) {
$(element).trigger(TRANSITION_END);
},
// TODO: Remove in v5
supportsTransitionEnd() {
return Boolean(TRANSITION_END)
},
isElement(obj) {
return (obj[0] || obj).nodeType
},
typeCheckConfig(componentName, config, configTypes) {
for (const property in configTypes) {
if (Object.prototype.hasOwnProperty.call(configTypes, property)) {
const expectedTypes = configTypes[property];
const value = config[property];
const valueType = value && Util.isElement(value)
? 'element' : toType(value);
if (!new RegExp(expectedTypes).test(valueType)) {
throw new Error(
`${componentName.toUpperCase()}: ` +
`Option "${property}" provided type "${valueType}" ` +
`but expected type "${expectedTypes}".`)
}
}
}
},
findShadowRoot(element) {
if (!document.documentElement.attachShadow) {
return null
}
// Can find the shadow root otherwise it'll return the document
if (typeof element.getRootNode === 'function') {
const root = element.getRootNode();
return root instanceof ShadowRoot ? root : null
}
if (element instanceof ShadowRoot) {
return element
}
// when we don't find a shadow root
if (!element.parentNode) {
return null
}
return Util.findShadowRoot(element.parentNode)
},
jQueryDetection() {
if (typeof $ === 'undefined') {
throw new TypeError('Bootstrap\'s JavaScript requires jQuery. jQuery must be included before Bootstrap\'s JavaScript.')
}
const version = $.fn.jquery.split(' ')[0].split('.');
const minMajor = 1;
const ltMajor = 2;
const minMinor = 9;
const minPatch = 1;
const maxMajor = 4;
if (version[0] < ltMajor && version[1] < minMinor || version[0] === minMajor && version[1] === minMinor && version[2] < minPatch || version[0] >= maxMajor) {
throw new Error('Bootstrap\'s JavaScript requires at least jQuery v1.9.1 but less than v4.0.0')
}
}
};
Util.jQueryDetection();
setTransitionEndSupport();
/**
* --------------------------------------------------------------------------
* Bootstrap (v4.5.2): alert.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
const NAME = 'alert';
const VERSION = '4.5.2';
const DATA_KEY = 'bs.alert';
const EVENT_KEY = `.${DATA_KEY}`;
const DATA_API_KEY = '.data-api';
const JQUERY_NO_CONFLICT = $.fn[NAME];
const SELECTOR_DISMISS = '[data-dismiss="alert"]';
const EVENT_CLOSE = `close${EVENT_KEY}`;
const EVENT_CLOSED = `closed${EVENT_KEY}`;
const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`;
const CLASS_NAME_ALERT = 'alert';
const CLASS_NAME_FADE = 'fade';
const CLASS_NAME_SHOW = 'show';
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
class Alert {
constructor(element) {
this._element = element;
}
// Getters
static get VERSION() {
return VERSION
}
// Public
close(element) {
let rootElement = this._element;
if (element) {
rootElement = this._getRootElement(element);
}
const customEvent = this._triggerCloseEvent(rootElement);
if (customEvent.isDefaultPrevented()) {
return
}
this._removeElement(rootElement);
}
dispose() {
$.removeData(this._element, DATA_KEY);
this._element = null;
}
// Private
_getRootElement(element) {
const selector = Util.getSelectorFromElement(element);
let parent = false;
if (selector) {
parent = document.querySelector(selector);
}
if (!parent) {
parent = $(element).closest(`.${CLASS_NAME_ALERT}`)[0];
}
return parent
}
_triggerCloseEvent(element) {
const closeEvent = $.Event(EVENT_CLOSE);
$(element).trigger(closeEvent);
return closeEvent
}
_removeElement(element) {
$(element).removeClass(CLASS_NAME_SHOW);
if (!$(element).hasClass(CLASS_NAME_FADE)) {
this._destroyElement(element);
return
}
const transitionDuration = Util.getTransitionDurationFromElement(element);
$(element)
.one(Util.TRANSITION_END, (event) => this._destroyElement(element, event))
.emulateTransitionEnd(transitionDuration);
}
_destroyElement(element) {
$(element)
.detach()
.trigger(EVENT_CLOSED)
.remove();
}
// Static
static _jQueryInterface(config) {
return this.each(function () {
const $element = $(this);
let data = $element.data(DATA_KEY);
if (!data) {
data = new Alert(this);
$element.data(DATA_KEY, data);
}
if (config === 'close') {
data[config](this);
}
})
}
static _handleDismiss(alertInstance) {
return function (event) {
if (event) {
event.preventDefault();
}
alertInstance.close(this);
}
}
}
/**
* ------------------------------------------------------------------------
* Data Api implementation
* ------------------------------------------------------------------------
*/
$(document).on(
EVENT_CLICK_DATA_API,
SELECTOR_DISMISS,
Alert._handleDismiss(new Alert())
);
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
*/
$.fn[NAME] = Alert._jQueryInterface;
$.fn[NAME].Constructor = Alert;
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT;
return Alert._jQueryInterface
};
/**
* --------------------------------------------------------------------------
* Bootstrap (v4.5.2): button.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
const NAME$1 = 'button';
const VERSION$1 = '4.5.2';
const DATA_KEY$1 = 'bs.button';
const EVENT_KEY$1 = `.${DATA_KEY$1}`;
const DATA_API_KEY$1 = '.data-api';
const JQUERY_NO_CONFLICT$1 = $.fn[NAME$1];
const CLASS_NAME_ACTIVE = 'active';
const CLASS_NAME_BUTTON = 'btn';
const CLASS_NAME_FOCUS = 'focus';
const SELECTOR_DATA_TOGGLE_CARROT = '[data-toggle^="button"]';
const SELECTOR_DATA_TOGGLES = '[data-toggle="buttons"]';
const SELECTOR_DATA_TOGGLE = '[data-toggle="button"]';
const SELECTOR_DATA_TOGGLES_BUTTONS = '[data-toggle="buttons"] .btn';
const SELECTOR_INPUT = 'input:not([type="hidden"])';
const SELECTOR_ACTIVE = '.active';
const SELECTOR_BUTTON = '.btn';
const EVENT_CLICK_DATA_API$1 = `click${EVENT_KEY$1}${DATA_API_KEY$1}`;
const EVENT_FOCUS_BLUR_DATA_API = `focus${EVENT_KEY$1}${DATA_API_KEY$1} ` +
`blur${EVENT_KEY$1}${DATA_API_KEY$1}`;
const EVENT_LOAD_DATA_API = `load${EVENT_KEY$1}${DATA_API_KEY$1}`;
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
class Button {
constructor(element) {
this._element = element;
}
// Getters
static get VERSION() {
return VERSION$1
}
// Public
toggle() {
let triggerChangeEvent = true;
let addAriaPressed = true;
const rootElement = $(this._element).closest(
SELECTOR_DATA_TOGGLES
)[0];
if (rootElement) {
const input = this._element.querySelector(SELECTOR_INPUT);
if (input) {
if (input.type === 'radio') {
if (input.checked &&
this._element.classList.contains(CLASS_NAME_ACTIVE)) {
triggerChangeEvent = false;
} else {
const activeElement = rootElement.querySelector(SELECTOR_ACTIVE);
if (activeElement) {
$(activeElement).removeClass(CLASS_NAME_ACTIVE);
}
}
}
if (triggerChangeEvent) {
// if it's not a radio button or checkbox don't add a pointless/invalid checked property to the input
if (input.type === 'checkbox' || input.type === 'radio') {
input.checked = !this._element.classList.contains(CLASS_NAME_ACTIVE);
}
$(input).trigger('change');
}
input.focus();
addAriaPressed = false;
}
}
if (!(this._element.hasAttribute('disabled') || this._element.classList.contains('disabled'))) {
if (addAriaPressed) {
this._element.setAttribute('aria-pressed',
!this._element.classList.contains(CLASS_NAME_ACTIVE));
}
if (triggerChangeEvent) {
$(this._element).toggleClass(CLASS_NAME_ACTIVE);
}
}
}
dispose() {
$.removeData(this._element, DATA_KEY$1);
this._element = null;
}
// Static
static _jQueryInterface(config) {
return this.each(function () {
let data = $(this).data(DATA_KEY$1);
if (!data) {
data = new Button(this);
$(this).data(DATA_KEY$1, data);
}
if (config === 'toggle') {
data[config]();
}
})
}
}
/**
* ------------------------------------------------------------------------
* Data Api implementation
* ------------------------------------------------------------------------
*/
$(document)
.on(EVENT_CLICK_DATA_API$1, SELECTOR_DATA_TOGGLE_CARROT, (event) => {
let button = event.target;
const initialButton = button;
if (!$(button).hasClass(CLASS_NAME_BUTTON)) {
button = $(button).closest(SELECTOR_BUTTON)[0];
}
if (!button || button.hasAttribute('disabled') || button.classList.contains('disabled')) {
event.preventDefault(); // work around Firefox bug #1540995
} else {
const inputBtn = button.querySelector(SELECTOR_INPUT);
if (inputBtn && (inputBtn.hasAttribute('disabled') || inputBtn.classList.contains('disabled'))) {
event.preventDefault(); // work around Firefox bug #1540995
return
}
if (initialButton.tagName !== 'LABEL' || inputBtn && inputBtn.type !== 'checkbox') {
Button._jQueryInterface.call($(button), 'toggle');
}
}
})
.on(EVENT_FOCUS_BLUR_DATA_API, SELECTOR_DATA_TOGGLE_CARROT, (event) => {
const button = $(event.target).closest(SELECTOR_BUTTON)[0];
$(button).toggleClass(CLASS_NAME_FOCUS, /^focus(in)?$/.test(event.type));
});
$(window).on(EVENT_LOAD_DATA_API, () => {
// ensure correct active class is set to match the controls' actual values/states
// find all checkboxes/readio buttons inside data-toggle groups
let buttons = [].slice.call(document.querySelectorAll(SELECTOR_DATA_TOGGLES_BUTTONS));
for (let i = 0, len = buttons.length; i < len; i++) {
const button = buttons[i];
const input = button.querySelector(SELECTOR_INPUT);
if (input.checked || input.hasAttribute('checked')) {
button.classList.add(CLASS_NAME_ACTIVE);
} else {
button.classList.remove(CLASS_NAME_ACTIVE);
}
}
// find all button toggles
buttons = [].slice.call(document.querySelectorAll(SELECTOR_DATA_TOGGLE));
for (let i = 0, len = buttons.length; i < len; i++) {
const button = buttons[i];
if (button.getAttribute('aria-pressed') === 'true') {
button.classList.add(CLASS_NAME_ACTIVE);
} else {
button.classList.remove(CLASS_NAME_ACTIVE);
}
}
});
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
*/
$.fn[NAME$1] = Button._jQueryInterface;
$.fn[NAME$1].Constructor = Button;
$.fn[NAME$1].noConflict = () => {
$.fn[NAME$1] = JQUERY_NO_CONFLICT$1;
return Button._jQueryInterface
};
/**
* --------------------------------------------------------------------------
* Bootstrap (v4.5.2): collapse.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
const NAME$2 = 'collapse';
const VERSION$2 = '4.5.2';
const DATA_KEY$2 = 'bs.collapse';
const EVENT_KEY$2 = `.${DATA_KEY$2}`;
const DATA_API_KEY$2 = '.data-api';
const JQUERY_NO_CONFLICT$2 = $.fn[NAME$2];
const Default = {
toggle : true,
parent : ''
};
const DefaultType = {
toggle : 'boolean',
parent : '(string|element)'
};
const EVENT_SHOW = `show${EVENT_KEY$2}`;
const EVENT_SHOWN = `shown${EVENT_KEY$2}`;
const EVENT_HIDE = `hide${EVENT_KEY$2}`;
const EVENT_HIDDEN = `hidden${EVENT_KEY$2}`;
const EVENT_CLICK_DATA_API$2 = `click${EVENT_KEY$2}${DATA_API_KEY$2}`;
const CLASS_NAME_SHOW$1 = 'show';
const CLASS_NAME_COLLAPSE = 'collapse';
const CLASS_NAME_COLLAPSING = 'collapsing';
const CLASS_NAME_COLLAPSED = 'collapsed';
const DIMENSION_WIDTH = 'width';
const DIMENSION_HEIGHT = 'height';
const SELECTOR_ACTIVES = '.show, .collapsing';
const SELECTOR_DATA_TOGGLE$1 = '[data-toggle="collapse"]';
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
class Collapse {
constructor(element, config) {
this._isTransitioning = false;
this._element = element;
this._config = this._getConfig(config);
this._triggerArray = [].slice.call(document.querySelectorAll(
`[data-toggle="collapse"][href="#${element.id}"],` +
`[data-toggle="collapse"][data-target="#${element.id}"]`
));
const toggleList = [].slice.call(document.querySelectorAll(SELECTOR_DATA_TOGGLE$1));
for (let i = 0, len = toggleList.length; i < len; i++) {
const elem = toggleList[i];
const selector = Util.getSelectorFromElement(elem);
const filterElement = [].slice.call(document.querySelectorAll(selector))
.filter((foundElem) => foundElem === element);
if (selector !== null && filterElement.length > 0) {
this._selector = selector;
this._triggerArray.push(elem);
}
}
this._parent = this._config.parent ? this._getParent() : null;
if (!this._config.parent) {
this._addAriaAndCollapsedClass(this._element, this._triggerArray);
}
if (this._config.toggle) {
this.toggle();
}
}
// Getters
static get VERSION() {
return VERSION$2
}
static get Default() {
return Default
}
// Public
toggle() {
if ($(this._element).hasClass(CLASS_NAME_SHOW$1)) {
this.hide();
} else {
this.show();
}
}
show() {
if (this._isTransitioning ||
$(this._element).hasClass(CLASS_NAME_SHOW$1)) {
return
}
let actives;
let activesData;
if (this._parent) {
actives = [].slice.call(this._parent.querySelectorAll(SELECTOR_ACTIVES))
.filter((elem) => {
if (typeof this._config.parent === 'string') {
return elem.getAttribute('data-parent') === this._config.parent
}
return elem.classList.contains(CLASS_NAME_COLLAPSE)
});
if (actives.length === 0) {
actives = null;
}
}
if (actives) {
activesData = $(actives).not(this._selector).data(DATA_KEY$2);
if (activesData && activesData._isTransitioning) {
return
}
}
const startEvent = $.Event(EVENT_SHOW);
$(this._element).trigger(startEvent);
if (startEvent.isDefaultPrevented()) {
return
}
if (actives) {
Collapse._jQueryInterface.call($(actives).not(this._selector), 'hide');
if (!activesData) {
$(actives).data(DATA_KEY$2, null);
}
}
const dimension = this._getDimension();
$(this._element)
.removeClass(CLASS_NAME_COLLAPSE)
.addClass(CLASS_NAME_COLLAPSING);
this._element.style[dimension] = 0;
if (this._triggerArray.length) {
$(this._triggerArray)
.removeClass(CLASS_NAME_COLLAPSED)
.attr('aria-expanded', true);
}
this.setTransitioning(true);
const complete = () => {
$(this._element)
.removeClass(CLASS_NAME_COLLAPSING)
.addClass(`${CLASS_NAME_COLLAPSE} ${CLASS_NAME_SHOW$1}`);
this._element.style[dimension] = '';
this.setTransitioning(false);
$(this._element).trigger(EVENT_SHOWN);
};
const capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1);
const scrollSize = `scroll${capitalizedDimension}`;
const transitionDuration = Util.getTransitionDurationFromElement(this._element);
$(this._element)
.one(Util.TRANSITION_END, complete)
.emulateTransitionEnd(transitionDuration);
this._element.style[dimension] = `${this._element[scrollSize]}px`;
}
hide() {
if (this._isTransitioning ||
!$(this._element).hasClass(CLASS_NAME_SHOW$1)) {
return
}
const startEvent = $.Event(EVENT_HIDE);
$(this._element).trigger(startEvent);
if (startEvent.isDefaultPrevented()) {
return
}
const dimension = this._getDimension();
this._element.style[dimension] = `${this._element.getBoundingClientRect()[dimension]}px`;
Util.reflow(this._element);
$(this._element)
.addClass(CLASS_NAME_COLLAPSING)
.removeClass(`${CLASS_NAME_COLLAPSE} ${CLASS_NAME_SHOW$1}`);
const triggerArrayLength = this._triggerArray.length;
if (triggerArrayLength > 0) {
for (let i = 0; i < triggerArrayLength; i++) {
const trigger = this._triggerArray[i];
const selector = Util.getSelectorFromElement(trigger);
if (selector !== null) {
const $elem = $([].slice.call(document.querySelectorAll(selector)));
if (!$elem.hasClass(CLASS_NAME_SHOW$1)) {
$(trigger).addClass(CLASS_NAME_COLLAPSED)
.attr('aria-expanded', false);
}
}
}
}
this.setTransitioning(true);
const complete = () => {
this.setTransitioning(false);
$(this._element)
.removeClass(CLASS_NAME_COLLAPSING)
.addClass(CLASS_NAME_COLLAPSE)
.trigger(EVENT_HIDDEN);
};
this._element.style[dimension] = '';
const transitionDuration = Util.getTransitionDurationFromElement(this._element);
$(this._element)
.one(Util.TRANSITION_END, complete)
.emulateTransitionEnd(transitionDuration);
}
setTransitioning(isTransitioning) {
this._isTransitioning = isTransitioning;
}
dispose() {
$.removeData(this._element, DATA_KEY$2);
this._config = null;
this._parent = null;
this._element = null;
this._triggerArray = null;
this._isTransitioning = null;
}
// Private
_getConfig(config) {
config = {
...Default,
...config
};
config.toggle = Boolean(config.toggle); // Coerce string values
Util.typeCheckConfig(NAME$2, config, DefaultType);
return config
}
_getDimension() {
const hasWidth = $(this._element).hasClass(DIMENSION_WIDTH);
return hasWidth ? DIMENSION_WIDTH : DIMENSION_HEIGHT
}
_getParent() {
let parent;
if (Util.isElement(this._config.parent)) {
parent = this._config.parent;
// It's a jQuery object
if (typeof this._config.parent.jquery !== 'undefined') {
parent = this._config.parent[0];
}
} else {
parent = document.querySelector(this._config.parent);
}
const selector = `[data-toggle="collapse"][data-parent="${this._config.parent}"]`;
const children = [].slice.call(parent.querySelectorAll(selector));
$(children).each((i, element) => {
this._addAriaAndCollapsedClass(
Collapse._getTargetFromElement(element),
[element]
);
});
return parent
}
_addAriaAndCollapsedClass(element, triggerArray) {
const isOpen = $(element).hasClass(CLASS_NAME_SHOW$1);
if (triggerArray.length) {
$(triggerArray)
.toggleClass(CLASS_NAME_COLLAPSED, !isOpen)
.attr('aria-expanded', isOpen);
}
}
// Static
static _getTargetFromElement(element) {
const selector = Util.getSelectorFromElement(element);
return selector ? document.querySelector(selector) : null
}
static _jQueryInterface(config) {
return this.each(function () {
const $this = $(this);
let data = $this.data(DATA_KEY$2);
const _config = {
...Default,
...$this.data(),
...typeof config === 'object' && config ? config : {}
};
if (!data && _config.toggle && typeof config === 'string' && /show|hide/.test(config)) {
_config.toggle = false;
}
if (!data) {
data = new Collapse(this, _config);
$this.data(DATA_KEY$2, data);
}
if (typeof config === 'string') {
if (typeof data[config] === 'undefined') {
throw new TypeError(`No method named "${config}"`)
}
data[config]();
}
})
}
}
/**
* ------------------------------------------------------------------------
* Data Api implementation
* ------------------------------------------------------------------------
*/
$(document).on(EVENT_CLICK_DATA_API$2, SELECTOR_DATA_TOGGLE$1, function (event) {
// preventDefault only for <a> elements (which change the URL) not inside the collapsible element
if (event.currentTarget.tagName === 'A') {
event.preventDefault();
}
const $trigger = $(this);
const selector = Util.getSelectorFromElement(this);
const selectors = [].slice.call(document.querySelectorAll(selector));
$(selectors).each(function () {
const $target = $(this);
const data = $target.data(DATA_KEY$2);
const config = data ? 'toggle' : $trigger.data();
Collapse._jQueryInterface.call($target, config);
});
});
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
*/
$.fn[NAME$2] = Collapse._jQueryInterface;
$.fn[NAME$2].Constructor = Collapse;
$.fn[NAME$2].noConflict = () => {
$.fn[NAME$2] = JQUERY_NO_CONFLICT$2;
return Collapse._jQueryInterface
};
/**
* --------------------------------------------------------------------------
* Bootstrap (v4.5.2): dropdown.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
const NAME$3 = 'dropdown';
const VERSION$3 = '4.5.2';
const DATA_KEY$3 = 'bs.dropdown';
const EVENT_KEY$3 = `.${DATA_KEY$3}`;
const DATA_API_KEY$3 = '.data-api';
const JQUERY_NO_CONFLICT$3 = $.fn[NAME$3];
const ESCAPE_KEYCODE = 27; // KeyboardEvent.which value for Escape (Esc) key
const SPACE_KEYCODE = 32; // KeyboardEvent.which value for space key
const TAB_KEYCODE = 9; // KeyboardEvent.which value for tab key
const ARROW_UP_KEYCODE = 38; // KeyboardEvent.which value for up arrow key
const ARROW_DOWN_KEYCODE = 40; // KeyboardEvent.which value for down arrow key
const RIGHT_MOUSE_BUTTON_WHICH = 3; // MouseEvent.which value for the right button (assuming a right-handed mouse)
const REGEXP_KEYDOWN = new RegExp(`${ARROW_UP_KEYCODE}|${ARROW_DOWN_KEYCODE}|${ESCAPE_KEYCODE}`);
const EVENT_HIDE$1 = `hide${EVENT_KEY$3}`;
const EVENT_HIDDEN$1 = `hidden${EVENT_KEY$3}`;
const EVENT_SHOW$1 = `show${EVENT_KEY$3}`;
const EVENT_SHOWN$1 = `shown${EVENT_KEY$3}`;
const EVENT_CLICK = `click${EVENT_KEY$3}`;
const EVENT_CLICK_DATA_API$3 = `click${EVENT_KEY$3}${DATA_API_KEY$3}`;
const EVENT_KEYDOWN_DATA_API = `keydown${EVENT_KEY$3}${DATA_API_KEY$3}`;
const EVENT_KEYUP_DATA_API = `keyup${EVENT_KEY$3}${DATA_API_KEY$3}`;
const CLASS_NAME_DISABLED = 'disabled';
const CLASS_NAME_SHOW$2 = 'show';
const CLASS_NAME_DROPUP = 'dropup';
const CLASS_NAME_DROPRIGHT = 'dropright';
const CLASS_NAME_DROPLEFT = 'dropleft';
const CLASS_NAME_MENURIGHT = 'dropdown-menu-right';
const CLASS_NAME_POSITION_STATIC = 'position-static';
const SELECTOR_DATA_TOGGLE$2 = '[data-toggle="dropdown"]';
const SELECTOR_FORM_CHILD = '.dropdown form';
const SELECTOR_MENU = '.dropdown-menu';
const SELECTOR_NAVBAR_NAV = '.navbar-nav';
const SELECTOR_VISIBLE_ITEMS = '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)';
const PLACEMENT_TOP = 'top-start';
const PLACEMENT_TOPEND = 'top-end';
const PLACEMENT_BOTTOM = 'bottom-start';
const PLACEMENT_BOTTOMEND = 'bottom-end';
const PLACEMENT_RIGHT = 'right-start';
const PLACEMENT_LEFT = 'left-start';
const Default$1 = {
offset : 0,
flip : true,
boundary : 'scrollParent',
reference : 'toggle',
display : 'dynamic',
popperConfig : null
};
const DefaultType$1 = {
offset : '(number|string|function)',
flip : 'boolean',
boundary : '(string|element)',
reference : '(string|element)',
display : 'string',
popperConfig : '(null|object)'
};
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
class Dropdown {
constructor(element, config) {
this._element = element;
this._popper = null;
this._config = this._getConfig(config);
this._menu = this._getMenuElement();
this._inNavbar = this._detectNavbar();
this._addEventListeners();
}
// Getters
static get VERSION() {
return VERSION$3
}
static get Default() {
return Default$1
}
static get DefaultType() {
return DefaultType$1
}
// Public
toggle() {
if (this._element.disabled || $(this._element).hasClass(CLASS_NAME_DISABLED)) {
return
}
const isActive = $(this._menu).hasClass(CLASS_NAME_SHOW$2);
Dropdown._clearMenus();
if (isActive) {
return
}
this.show(true);
}
show(usePopper = false) {
if (this._element.disabled || $(this._element).hasClass(CLASS_NAME_DISABLED) || $(this._menu).hasClass(CLASS_NAME_SHOW$2)) {
return
}
const relatedTarget = {
relatedTarget: this._element
};
const showEvent = $.Event(EVENT_SHOW$1, relatedTarget);
const parent = Dropdown._getParentFromElement(this._element);
$(parent).trigger(showEvent);
if (showEvent.isDefaultPrevented()) {
return
}
// Disable totally Popper.js for Dropdown in Navbar
if (!this._inNavbar && usePopper) {
/**
* Check for Popper dependency
* Popper - https://popper.js.org
*/
if (typeof Popper === 'undefined') {
throw new TypeError('Bootstrap\'s dropdowns require Popper.js (https://popper.js.org/)')
}
let referenceElement = this._element;
if (this._config.reference === 'parent') {
referenceElement = parent;
} else if (Util.isElement(this._config.reference)) {
referenceElement = this._config.reference;
// Check if it's jQuery element
if (typeof this._config.reference.jquery !== 'undefined') {
referenceElement = this._config.reference[0];
}
}
// If boundary is not `scrollParent`, then set position to `static`
// to allow the menu to "escape" the scroll parent's boundaries
// https://github.com/twbs/bootstrap/issues/24251
if (this._config.boundary !== 'scrollParent') {
$(parent).addClass(CLASS_NAME_POSITION_STATIC);
}
this._popper = new Popper(referenceElement, this._menu, this._getPopperConfig());
}
// If this is a touch-enabled device we add extra
// 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
if ('ontouchstart' in document.documentElement &&
$(parent).closest(SELECTOR_NAVBAR_NAV).length === 0) {
$(document.body).children().on('mouseover', null, $.noop);
}
this._element.focus();
this._element.setAttribute('aria-expanded', true);
$(this._menu).toggleClass(CLASS_NAME_SHOW$2);
$(parent)
.toggleClass(CLASS_NAME_SHOW$2)
.trigger($.Event(EVENT_SHOWN$1, relatedTarget));
}
hide() {
if (this._element.disabled || $(this._element).hasClass(CLASS_NAME_DISABLED) || !$(this._menu).hasClass(CLASS_NAME_SHOW$2)) {
return
}
const relatedTarget = {
relatedTarget: this._element
};
const hideEvent = $.Event(EVENT_HIDE$1, relatedTarget);
const parent = Dropdown._getParentFromElement(this._element);
$(parent).trigger(hideEvent);
if (hideEvent.isDefaultPrevented()) {
return
}
if (this._popper) {
this._popper.destroy();
}
$(this._menu).toggleClass(CLASS_NAME_SHOW$2);
$(parent)
.toggleClass(CLASS_NAME_SHOW$2)
.trigger($.Event(EVENT_HIDDEN$1, relatedTarget));
}
dispose() {
$.removeData(this._element, DATA_KEY$3);
$(this._element).off(EVENT_KEY$3);
this._element = null;
this._menu = null;
if (this._popper !== null) {
this._popper.destroy();
this._popper = null;
}
}
update() {
this._inNavbar = this._detectNavbar();
if (this._popper !== null) {
this._popper.scheduleUpdate();
}
}
// Private
_addEventListeners() {
$(this._element).on(EVENT_CLICK, (event) => {
event.preventDefault();
event.stopPropagation();
this.toggle();
});
}
_getConfig(config) {
config = {
...this.constructor.Default,
...$(this._element).data(),
...config
};
Util.typeCheckConfig(
NAME$3,
config,
this.constructor.DefaultType
);
return config
}
_getMenuElement() {
if (!this._menu) {
const parent = Dropdown._getParentFromElement(this._element);
if (parent) {
this._menu = parent.querySelector(SELECTOR_MENU);
}
}
return this._menu
}
_getPlacement() {
const $parentDropdown = $(this._element.parentNode);
let placement = PLACEMENT_BOTTOM;
// Handle dropup
if ($parentDropdown.hasClass(CLASS_NAME_DROPUP)) {
placement = $(this._menu).hasClass(CLASS_NAME_MENURIGHT)
? PLACEMENT_TOPEND
: PLACEMENT_TOP;
} else if ($parentDropdown.hasClass(CLASS_NAME_DROPRIGHT)) {
placement = PLACEMENT_RIGHT;
} else if ($parentDropdown.hasClass(CLASS_NAME_DROPLEFT)) {
placement = PLACEMENT_LEFT;
} else if ($(this._menu).hasClass(CLASS_NAME_MENURIGHT)) {
placement = PLACEMENT_BOTTOMEND;
}
return placement
}
_detectNavbar() {
return $(this._element).closest('.navbar').length > 0
}
_getOffset() {
const offset = {};
if (typeof this._config.offset === 'function') {
offset.fn = (data) => {
data.offsets = {
...data.offsets,
...this._config.offset(data.offsets, this._element) || {}
};
return data
};
} else {
offset.offset = this._config.offset;
}
return offset
}
_getPopperConfig() {
const popperConfig = {
placement: this._getPlacement(),
modifiers: {
offset: this._getOffset(),
flip: {
enabled: this._config.flip
},
preventOverflow: {
boundariesElement: this._config.boundary
}
}
};
// Disable Popper.js if we have a static display
if (this._config.display === 'static') {
popperConfig.modifiers.applyStyle = {
enabled: false
};
}
return {
...popperConfig,
...this._config.popperConfig
}
}
// Static
static _jQueryInterface(config) {
return this.each(function () {
let data = $(this).data(DATA_KEY$3);
const _config = typeof config === 'object' ? config : null;
if (!data) {
data = new Dropdown(this, _config);
$(this).data(DATA_KEY$3, data);
}
if (typeof config === 'string') {
if (typeof data[config] === 'undefined') {
throw new TypeError(`No method named "${config}"`)
}
data[config]();
}
})
}
static _clearMenus(event) {
if (event && (event.which === RIGHT_MOUSE_BUTTON_WHICH ||
event.type === 'keyup' && event.which !== TAB_KEYCODE)) {
return
}
const toggles = [].slice.call(document.querySelectorAll(SELECTOR_DATA_TOGGLE$2));
for (let i = 0, len = toggles.length; i < len; i++) {
const parent = Dropdown._getParentFromElement(toggles[i]);
const context = $(toggles[i]).data(DATA_KEY$3);
const relatedTarget = {
relatedTarget: toggles[i]
};
if (event && event.type === 'click') {
relatedTarget.clickEvent = event;
}
if (!context) {
continue
}
const dropdownMenu = context._menu;
if (!$(parent).hasClass(CLASS_NAME_SHOW$2)) {
continue
}
if (event && (event.type === 'click' &&
/input|textarea/i.test(event.target.tagName) || event.type === 'keyup' && event.which === TAB_KEYCODE) &&
$.contains(parent, event.target)) {
continue
}
const hideEvent = $.Event(EVENT_HIDE$1, relatedTarget);
$(parent).trigger(hideEvent);
if (hideEvent.isDefaultPrevented()) {
continue
}
// If this is a touch-enabled device we remove the extra
// empty mouseover listeners we added for iOS support
if ('ontouchstart' in document.documentElement) {
$(document.body).children().off('mouseover', null, $.noop);
}
toggles[i].setAttribute('aria-expanded', 'false');
if (context._popper) {
context._popper.destroy();
}
$(dropdownMenu).removeClass(CLASS_NAME_SHOW$2);
$(parent)
.removeClass(CLASS_NAME_SHOW$2)
.trigger($.Event(EVENT_HIDDEN$1, relatedTarget));
}
}
static _getParentFromElement(element) {
let parent;
const selector = Util.getSelectorFromElement(element);
if (selector) {
parent = document.querySelector(selector);
}
return parent || element.parentNode
}
// eslint-disable-next-line complexity
static _dataApiKeydownHandler(event) {
// If not input/textarea:
// - And not a key in REGEXP_KEYDOWN => not a dropdown command
// If input/textarea:
// - If space key => not a dropdown command
// - If key is other than escape
// - If key is not up or down => not a dropdown command
// - If trigger inside the menu => not a dropdown command
if (/input|textarea/i.test(event.target.tagName)
? event.which === SPACE_KEYCODE || event.which !== ESCAPE_KEYCODE &&
(event.which !== ARROW_DOWN_KEYCODE && event.which !== ARROW_UP_KEYCODE ||
$(event.target).closest(SELECTOR_MENU).length) : !REGEXP_KEYDOWN.test(event.which)) {
return
}
if (this.disabled || $(this).hasClass(CLASS_NAME_DISABLED)) {
return
}
const parent = Dropdown._getParentFromElement(this);
const isActive = $(parent).hasClass(CLASS_NAME_SHOW$2);
if (!isActive && event.which === ESCAPE_KEYCODE) {
return
}
event.preventDefault();
event.stopPropagation();
if (!isActive || isActive && (event.which === ESCAPE_KEYCODE || event.which === SPACE_KEYCODE)) {
if (event.which === ESCAPE_KEYCODE) {
$(parent.querySelector(SELECTOR_DATA_TOGGLE$2)).trigger('focus');
}
$(this).trigger('click');
return
}
const items = [].slice.call(parent.querySelectorAll(SELECTOR_VISIBLE_ITEMS))
.filter((item) => $(item).is(':visible'));
if (items.length === 0) {
return
}
let index = items.indexOf(event.target);
if (event.which === ARROW_UP_KEYCODE && index > 0) { // Up
index--;
}
if (event.which === ARROW_DOWN_KEYCODE && index < items.length - 1) { // Down
index++;
}
if (index < 0) {
index = 0;
}
items[index].focus();
}
}
/**
* ------------------------------------------------------------------------
* Data Api implementation
* ------------------------------------------------------------------------
*/
$(document)
.on(EVENT_KEYDOWN_DATA_API, SELECTOR_DATA_TOGGLE$2, Dropdown._dataApiKeydownHandler)
.on(EVENT_KEYDOWN_DATA_API, SELECTOR_MENU, Dropdown._dataApiKeydownHandler)
.on(`${EVENT_CLICK_DATA_API$3} ${EVENT_KEYUP_DATA_API}`, Dropdown._clearMenus)
.on(EVENT_CLICK_DATA_API$3, SELECTOR_DATA_TOGGLE$2, function (event) {
event.preventDefault();
event.stopPropagation();
Dropdown._jQueryInterface.call($(this), 'toggle');
})
.on(EVENT_CLICK_DATA_API$3, SELECTOR_FORM_CHILD, (e) => {
e.stopPropagation();
});
/**
* ------------------------------------------------------------------------
* jQuery
* ------------------------------------------------------------------------
*/
$.fn[NAME$3] = Dropdown._jQueryInterface;
$.fn[NAME$3].Constructor = Dropdown;
$.fn[NAME$3].noConflict = () => {
$.fn[NAME$3] = JQUERY_NO_CONFLICT$3;
return Dropdown._jQueryInterface
};
/**
* --------------------------------------------------------------------------
* Bootstrap (v4.5.2): modal.js
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
* --------------------------------------------------------------------------
*/
/**
* ------------------------------------------------------------------------
* Constants
* ------------------------------------------------------------------------
*/
const NAME$4 = 'modal';
const VERSION$4 = '4.5.2';
const DATA_KEY$4 = 'bs.modal';
const EVENT_KEY$4 = `.${DATA_KEY$4}`;
const DATA_API_KEY$4 = '.data-api';
const JQUERY_NO_CONFLICT$4 = $.fn[NAME$4];
const ESCAPE_KEYCODE$1 = 27; // KeyboardEvent.which value for Escape (Esc) key
const Default$2 = {
backdrop : true,
keyboard : true,
focus : true,
show : true
};
const DefaultType$2 = {
backdrop : '(boolean|string)',
keyboard : 'boolean',
focus : 'boolean',
show : 'boolean'
};
const EVENT_HIDE$2 = `hide${EVENT_KEY$4}`;
const EVENT_HIDE_PREVENTED = `hidePrevented${EVENT_KEY$4}`;
const EVENT_HIDDEN$2 = `hidden${EVENT_KEY$4}`;
const EVENT_SHOW$2 = `show${EVENT_KEY$4}`;
const EVENT_SHOWN$2 = `shown${EVENT_KEY$4}`;
const EVENT_FOCUSIN = `focusin${EVENT_KEY$4}`;
const EVENT_RESIZE = `resize${EVENT_KEY$4}`;
const EVENT_CLICK_DISMISS = `click.dismiss${EVENT_KEY$4}`;
const EVENT_KEYDOWN_DISMISS = `keydown.dismiss${EVENT_KEY$4}`;
const EVENT_MOUSEUP_DISMISS = `mouseup.dismiss${EVENT_KEY$4}`;
const EVENT_MOUSEDOWN_DISMISS = `mousedown.dismiss${EVENT_KEY$4}`;
const EVENT_CLICK_DATA_API$4 = `click${EVENT_KEY$4}${DATA_API_KEY$4}`;
const CLASS_NAME_SCROLLABLE = 'modal-dialog-scrollable';
const CLASS_NAME_SCROLLBAR_MEASURER = 'modal-scrollbar-measure';
const CLASS_NAME_BACKDROP = 'modal-backdrop';
const CLASS_NAME_OPEN = 'modal-open';
const CLASS_NAME_FADE$1 = 'fade';
const CLASS_NAME_SHOW$3 = 'show';
const CLASS_NAME_STATIC = 'modal-static';
const SELECTOR_DIALOG = '.modal-dialog';
const SELECTOR_MODAL_BODY = '.modal-body';
const SELECTOR_DATA_TOGGLE$3 = '[data-toggle="modal"]';
const SELECTOR_DATA_DISMISS = '[data-dismiss="modal"]';
const SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top';
const SELECTOR_STICKY_CONTENT = '.sticky-top';
/**
* ------------------------------------------------------------------------
* Class Definition
* ------------------------------------------------------------------------
*/
class Modal {
constructor(element, config) {
this._config = this._getConfig(config);
this._element = element;
this._dialog = element.querySelector(SELECTOR_DIALOG);
this._backdrop = null;
this._isShown = false;
this._isBodyOverflowing = false;
this._ignoreBackdropClick = false;
this._isTransitioning = false;
this._scrollbarWidth = 0;
}
// Getters
static get VERSION() {
return VERSION$4
}
static get Default() {
return Default$2
}
// Public
toggle(relatedTarget) {
return this._isShown ? this.hide() : this.show(relatedTarget)
}
show(relatedTarget) {
if (this._isShown || this._isTransitioning) {
return
}
if ($(this._element).hasClass(CLASS_NAME_FADE$1)) {
this._isTransitioning = true;
}
const showEvent = $.Event(EVENT_SHOW$2, {
relatedTarget
});
$(this._element).trigger(showEvent);
if (this._isShown || showEvent.isDefaultPrevented()) {
return
}
this._isShown = true;
this._checkScrollbar();
this._setScrollbar();
this._adjustDialog();
this._setEscapeEvent();
this._setResizeEvent();
$(this._element).on(
EVENT_CLICK_DISMISS,
SELECTOR_DATA_DISMISS,
(event) => this.hide(event)
);
$(this._dialog).on(EVENT_MOUSEDOWN_DISMISS, () => {
$(this._element).one(EVENT_MOUSEUP_DISMISS, (event) => {
if ($(event.target).is(this._element)) {
this._ignoreBackdropClick = true;
}
});
});
this._showBackdrop(() => this._showElement(relatedTarget));
}
hide(event) {
if (event) {
event.preventDefault();
}
if (!this._isShown || this._isTransitioning) {
return
}
const hideEvent = $.Event(EVENT_HIDE$2);
$(this._element).trigger(hideEvent);
if (!this._isShown || hideEvent.isDefaultPrevented()) {
return
}
this._isShown = false;
const transition = $(this._element).hasClass(CLASS_NAME_FADE$1);
if (transition) {
this._isTransitioning = true;
}
this._setEscapeEvent();
this._setResizeEvent();
$(document).off(EVENT_FOCUSIN);
$(this._element).removeClass(CLASS_NAME_SHOW$3);
$(this._element).off(EVENT_CLICK_DISMISS);
$(this._dialog).off(EVENT_MOUSEDOWN_DISMISS);