diff options
author | Gleb Mazovetskiy <glex.spb@gmail.com> | 2022-07-20 11:48:15 +0300 |
---|---|---|
committer | Gleb Mazovetskiy <glex.spb@gmail.com> | 2022-07-20 11:48:15 +0300 |
commit | 003c627ea7589dbbd8aeff030353b8c5decb6fbf (patch) | |
tree | 8d97404ea5b287caf0ab8d07984042cd9c686397 | |
parent | badd3aed1ad8e7659485865687412ad3a27ff6a3 (diff) |
Update to v5.2.0v5.2.0
bundle exec rake update[v5.2.0]
89 files changed, 6506 insertions, 7449 deletions
@@ -20,7 +20,7 @@ Please see the appropriate guide for your environment of choice: Add `bootstrap` to your Gemfile: ```ruby -gem 'bootstrap', '~> 5.1.3' +gem 'bootstrap', '~> 5.2.0' ``` Ensure that `sprockets-rails` is at least v2.3.2. diff --git a/assets/javascripts/bootstrap-sprockets.js b/assets/javascripts/bootstrap-sprockets.js index 28c7365..10dfc94 100644 --- a/assets/javascripts/bootstrap-sprockets.js +++ b/assets/javascripts/bootstrap-sprockets.js @@ -1,16 +1,25 @@ //= require ./bootstrap-global-this-define //= require ./bootstrap/dom/data +//= require ./bootstrap/util/index //= require ./bootstrap/dom/event-handler +//= require ./bootstrap/dom/manipulator +//= require ./bootstrap/util/config //= require ./bootstrap/base-component +//= require ./bootstrap/util/component-functions //= require ./bootstrap/alert //= require ./bootstrap/button -//= require ./bootstrap/dom/manipulator //= require ./bootstrap/dom/selector-engine +//= require ./bootstrap/util/swipe //= require ./bootstrap/carousel //= require ./bootstrap/collapse //= require ./bootstrap/dropdown +//= require ./bootstrap/util/backdrop +//= require ./bootstrap/util/focustrap +//= require ./bootstrap/util/scrollbar //= require ./bootstrap/modal //= require ./bootstrap/offcanvas +//= require ./bootstrap/util/sanitizer +//= require ./bootstrap/util/template-factory //= require ./bootstrap/tooltip //= require ./bootstrap/popover //= require ./bootstrap/scrollspy diff --git a/assets/javascripts/bootstrap.js b/assets/javascripts/bootstrap.js index 14ec4f8..8b5696b 100644 --- a/assets/javascripts/bootstrap.js +++ b/assets/javascripts/bootstrap.js @@ -1,6 +1,6 @@ /*! - * Bootstrap v5.1.3 (https://getbootstrap.com/) - * Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) + * Bootstrap v5.2.0 (https://getbootstrap.com/) + * Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ (function (global, factory) { @@ -11,7 +11,7 @@ function _interopNamespace(e) { if (e && e.__esModule) return e; - const n = Object.create(null); + const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } }); if (e) { for (const k in e) { if (k !== 'default') { @@ -31,25 +31,23 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): util/index.js + * Bootstrap (v5.2.0): util/index.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ const MAX_UID = 1000000; const MILLISECONDS_MULTIPLIER = 1000; - const TRANSITION_END = 'transitionend'; // Shoutout AngusCroll (https://goo.gl/pxwQGp) + const TRANSITION_END = 'transitionend'; // Shout-out Angus Croll (https://goo.gl/pxwQGp) - const toType = obj => { - if (obj === null || obj === undefined) { - return `${obj}`; + const toType = object => { + if (object === null || object === undefined) { + return `${object}`; } - return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase(); + return Object.prototype.toString.call(object).match(/\s([a-z]+)/i)[1].toLowerCase(); }; /** - * -------------------------------------------------------------------------- - * Public Util Api - * -------------------------------------------------------------------------- + * Public Util API */ @@ -65,21 +63,21 @@ let selector = element.getAttribute('data-bs-target'); if (!selector || selector === '#') { - let hrefAttr = element.getAttribute('href'); // The only valid content that could double as a selector are IDs or classes, + let hrefAttribute = element.getAttribute('href'); // The only valid content that could double as a selector are IDs or classes, // so everything starting with `#` or `.`. If a "real" URL is used as the selector, // `document.querySelector` will rightfully complain it is invalid. // See https://github.com/twbs/bootstrap/issues/32273 - if (!hrefAttr || !hrefAttr.includes('#') && !hrefAttr.startsWith('.')) { + if (!hrefAttribute || !hrefAttribute.includes('#') && !hrefAttribute.startsWith('.')) { return null; } // Just in case some CMS puts out a full URL with the anchor appended - if (hrefAttr.includes('#') && !hrefAttr.startsWith('#')) { - hrefAttr = `#${hrefAttr.split('#')[1]}`; + if (hrefAttribute.includes('#') && !hrefAttribute.startsWith('#')) { + hrefAttribute = `#${hrefAttribute.split('#')[1]}`; } - selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : null; + selector = hrefAttribute && hrefAttribute !== '#' ? hrefAttribute.trim() : null; } return selector; @@ -127,49 +125,57 @@ element.dispatchEvent(new Event(TRANSITION_END)); }; - const isElement = obj => { - if (!obj || typeof obj !== 'object') { + const isElement = object => { + if (!object || typeof object !== 'object') { return false; } - if (typeof obj.jquery !== 'undefined') { - obj = obj[0]; + if (typeof object.jquery !== 'undefined') { + object = object[0]; } - return typeof obj.nodeType !== 'undefined'; + return typeof object.nodeType !== 'undefined'; }; - const getElement = obj => { - if (isElement(obj)) { - // it's a jQuery object or a node element - return obj.jquery ? obj[0] : obj; + const getElement = object => { + // it's a jQuery object or a node element + if (isElement(object)) { + return object.jquery ? object[0] : object; } - if (typeof obj === 'string' && obj.length > 0) { - return document.querySelector(obj); + if (typeof object === 'string' && object.length > 0) { + return document.querySelector(object); } return null; }; - const typeCheckConfig = (componentName, config, configTypes) => { - Object.keys(configTypes).forEach(property => { - const expectedTypes = configTypes[property]; - const value = config[property]; - const valueType = value && isElement(value) ? 'element' : toType(value); - - if (!new RegExp(expectedTypes).test(valueType)) { - throw new TypeError(`${componentName.toUpperCase()}: Option "${property}" provided type "${valueType}" but expected type "${expectedTypes}".`); - } - }); - }; - const isVisible = element => { if (!isElement(element) || element.getClientRects().length === 0) { return false; } - return getComputedStyle(element).getPropertyValue('visibility') === 'visible'; + const elementIsVisible = getComputedStyle(element).getPropertyValue('visibility') === 'visible'; // Handle `details` element as its content may falsie appear visible when it is closed + + const closedDetails = element.closest('details:not([open])'); + + if (!closedDetails) { + return elementIsVisible; + } + + if (closedDetails !== element) { + const summary = element.closest('summary'); + + if (summary && summary.parentNode !== closedDetails) { + return false; + } + + if (summary === null) { + return false; + } + } + + return elementIsVisible; }; const isDisabled = element => { @@ -223,17 +229,12 @@ const reflow = element => { - // eslint-disable-next-line no-unused-expressions - element.offsetHeight; + element.offsetHeight; // eslint-disable-line no-unused-expressions }; const getjQuery = () => { - const { - jQuery - } = window; - - if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) { - return jQuery; + if (window.jQuery && !document.body.hasAttribute('data-bs-no-jquery')) { + return window.jQuery; } return null; @@ -246,7 +247,9 @@ // add listener on the first call when the document is in loading state if (!DOMContentLoadedCallbacks.length) { document.addEventListener('DOMContentLoaded', () => { - DOMContentLoadedCallbacks.forEach(callback => callback()); + for (const callback of DOMContentLoadedCallbacks) { + callback(); + } }); } @@ -324,13 +327,14 @@ const getNextActiveElement = (list, activeElement, shouldGetNext, isCycleAllowed) => { - 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 + const listLength = list.length; + 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 if (index === -1) { - return list[!shouldGetNext && isCycleAllowed ? list.length - 1 : 0]; + return !shouldGetNext && isCycleAllowed ? list[listLength - 1] : list[0]; } - const listLength = list.length; index += shouldGetNext ? 1 : -1; if (isCycleAllowed) { @@ -342,14 +346,12 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): dom/event-handler.js + * Bootstrap (v5.2.0): dom/event-handler.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** - * ------------------------------------------------------------------------ * Constants - * ------------------------------------------------------------------------ */ const namespaceRegex = /[^.]*(?=\..*)\.|.*/; @@ -362,20 +364,17 @@ mouseenter: 'mouseover', mouseleave: 'mouseout' }; - const customEventsRegex = /^(mouseenter|mouseleave)/i; const nativeEvents = new Set(['click', 'dblclick', 'mouseup', 'mousedown', 'contextmenu', 'mousewheel', 'DOMMouseScroll', 'mouseover', 'mouseout', 'mousemove', 'selectstart', 'selectend', 'keydown', 'keypress', 'keyup', 'orientationchange', 'touchstart', 'touchmove', 'touchend', 'touchcancel', 'pointerdown', 'pointermove', 'pointerup', 'pointerleave', 'pointercancel', 'gesturestart', 'gesturechange', 'gestureend', 'focus', 'blur', 'change', 'reset', 'select', 'submit', 'focusin', 'focusout', 'load', 'unload', 'beforeunload', 'resize', 'move', 'DOMContentLoaded', 'readystatechange', 'error', 'abort', 'scroll']); /** - * ------------------------------------------------------------------------ * Private methods - * ------------------------------------------------------------------------ */ - function getUidEvent(element, uid) { + function makeEventUid(element, uid) { return uid && `${uid}::${uidEvent++}` || element.uidEvent || uidEvent++; } - function getEvent(element) { - const uid = getUidEvent(element); + function getElementEvents(element) { + const uid = makeEventUid(element); element.uidEvent = uid; eventRegistry[uid] = eventRegistry[uid] || {}; return eventRegistry[uid]; @@ -383,7 +382,9 @@ function bootstrapHandler(element, fn) { return function handler(event) { - event.delegateTarget = element; + hydrateObj(event, { + delegateTarget: element + }); if (handler.oneOff) { EventHandler.off(element, event.type, fn); @@ -400,65 +401,52 @@ for (let { target } = event; target && target !== this; target = target.parentNode) { - for (let i = domElements.length; i--;) { - if (domElements[i] === target) { - event.delegateTarget = target; + for (const domElement of domElements) { + if (domElement !== target) { + continue; + } - if (handler.oneOff) { - EventHandler.off(element, event.type, selector, fn); - } + hydrateObj(event, { + delegateTarget: target + }); - return fn.apply(target, [event]); + if (handler.oneOff) { + EventHandler.off(element, event.type, selector, fn); } - } - } // To please ESLint - - return null; + return fn.apply(target, [event]); + } + } }; } - function findHandler(events, handler, delegationSelector = null) { - const uidEventList = Object.keys(events); - - for (let i = 0, len = uidEventList.length; i < len; i++) { - const event = events[uidEventList[i]]; - - if (event.originalHandler === handler && event.delegationSelector === delegationSelector) { - return event; - } - } - - return null; + function findHandler(events, callable, delegationSelector = null) { + return Object.values(events).find(event => event.callable === callable && event.delegationSelector === delegationSelector); } - function normalizeParams(originalTypeEvent, handler, delegationFn) { - const delegation = typeof handler === 'string'; - const originalHandler = delegation ? delegationFn : handler; + function normalizeParameters(originalTypeEvent, handler, delegationFunction) { + const isDelegated = typeof handler === 'string'; // todo: tooltip passes `false` instead of selector, so we need to check + + const callable = isDelegated ? delegationFunction : handler || delegationFunction; let typeEvent = getTypeEvent(originalTypeEvent); - const isNative = nativeEvents.has(typeEvent); - if (!isNative) { + if (!nativeEvents.has(typeEvent)) { typeEvent = originalTypeEvent; } - return [delegation, originalHandler, typeEvent]; + return [isDelegated, callable, typeEvent]; } - function addHandler(element, originalTypeEvent, handler, delegationFn, oneOff) { + function addHandler(element, originalTypeEvent, handler, delegationFunction, oneOff) { if (typeof originalTypeEvent !== 'string' || !element) { return; } - if (!handler) { - handler = delegationFn; - delegationFn = null; - } // in case of mouseenter or mouseleave wrap the handler within a function that checks for its DOM position + let [isDelegated, callable, typeEvent] = normalizeParameters(originalTypeEvent, handler, delegationFunction); // in case of mouseenter or mouseleave wrap the handler within a function that checks for its DOM position // this prevents the handler from being dispatched the same way as mouseover or mouseout does - - if (customEventsRegex.test(originalTypeEvent)) { - const wrapFn = fn => { + if (originalTypeEvent in customEvents) { + const wrapFunction = fn => { return function (event) { if (!event.relatedTarget || event.relatedTarget !== event.delegateTarget && !event.delegateTarget.contains(event.relatedTarget)) { return fn.call(this, event); @@ -466,31 +454,26 @@ }; }; - if (delegationFn) { - delegationFn = wrapFn(delegationFn); - } else { - handler = wrapFn(handler); - } + callable = wrapFunction(callable); } - const [delegation, originalHandler, typeEvent] = normalizeParams(originalTypeEvent, handler, delegationFn); - const events = getEvent(element); + const events = getElementEvents(element); const handlers = events[typeEvent] || (events[typeEvent] = {}); - const previousFn = findHandler(handlers, originalHandler, delegation ? handler : null); + const previousFunction = findHandler(handlers, callable, isDelegated ? handler : null); - if (previousFn) { - previousFn.oneOff = previousFn.oneOff && oneOff; + if (previousFunction) { + previousFunction.oneOff = previousFunction.oneOff && oneOff; return; } - const uid = getUidEvent(originalHandler, originalTypeEvent.replace(namespaceRegex, '')); - const fn = delegation ? bootstrapDelegationHandler(element, handler, delegationFn) : bootstrapHandler(element, handler); - fn.delegationSelector = delegation ? handler : null; - fn.originalHandler = originalHandler; + const uid = makeEventUid(callable, originalTypeEvent.replace(namespaceRegex, '')); + const fn = isDelegated ? bootstrapDelegationHandler(element, handler, callable) : bootstrapHandler(element, callable); + fn.delegationSelector = isDelegated ? handler : null; + fn.callable = callable; fn.oneOff = oneOff; fn.uidEvent = uid; handlers[uid] = fn; - element.addEventListener(typeEvent, fn, delegation); + element.addEventListener(typeEvent, fn, isDelegated); } function removeHandler(element, events, typeEvent, handler, delegationSelector) { @@ -506,12 +489,13 @@ function removeNamespacedHandlers(element, events, typeEvent, namespace) { const storeElementEvent = events[typeEvent] || {}; - Object.keys(storeElementEvent).forEach(handlerKey => { + + for (const handlerKey of Object.keys(storeElementEvent)) { if (handlerKey.includes(namespace)) { const event = storeElementEvent[handlerKey]; - removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector); + removeHandler(element, events, typeEvent, event.callable, event.delegationSelector); } - }); + } } function getTypeEvent(event) { @@ -521,49 +505,49 @@ } const EventHandler = { - on(element, event, handler, delegationFn) { - addHandler(element, event, handler, delegationFn, false); + on(element, event, handler, delegationFunction) { + addHandler(element, event, handler, delegationFunction, false); }, - one(element, event, handler, delegationFn) { - addHandler(element, event, handler, delegationFn, true); + one(element, event, handler, delegationFunction) { + addHandler(element, event, handler, delegationFunction, true); }, - off(element, originalTypeEvent, handler, delegationFn) { + off(element, originalTypeEvent, handler, delegationFunction) { if (typeof originalTypeEvent !== 'string' || !element) { return; } - const [delegation, originalHandler, typeEvent] = normalizeParams(originalTypeEvent, handler, delegationFn); + const [isDelegated, callable, typeEvent] = normalizeParameters(originalTypeEvent, handler, delegationFunction); const inNamespace = typeEvent !== originalTypeEvent; - const events = getEvent(element); + const events = getElementEvents(element); + const storeElementEvent = events[typeEvent] || {}; const isNamespace = originalTypeEvent.startsWith('.'); - if (typeof originalHandler !== 'undefined') { + if (typeof callable !== 'undefined') { // Simplest case: handler is passed, remove that listener ONLY. - if (!events || !events[typeEvent]) { + if (!Object.keys(storeElementEvent).length) { return; } - removeHandler(element, events, typeEvent, originalHandler, delegation ? handler : null); + removeHandler(element, events, typeEvent, callable, isDelegated ? handler : null); return; } if (isNamespace) { - Object.keys(events).forEach(elementEvent => { + for (const elementEvent of Object.keys(events)) { removeNamespacedHandlers(element, events, elementEvent, originalTypeEvent.slice(1)); - }); + } } - const storeElementEvent = events[typeEvent] || {}; - Object.keys(storeElementEvent).forEach(keyHandlers => { + for (const keyHandlers of Object.keys(storeElementEvent)) { const handlerKey = keyHandlers.replace(stripUidRegex, ''); if (!inNamespace || originalTypeEvent.includes(handlerKey)) { const event = storeElementEvent[keyHandlers]; - removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector); + removeHandler(element, events, typeEvent, event.callable, event.delegationSelector); } - }); + } }, trigger(element, event, args) { @@ -574,12 +558,10 @@ const $ = getjQuery(); const typeEvent = getTypeEvent(event); const inNamespace = event !== typeEvent; - const isNative = nativeEvents.has(typeEvent); - let jQueryEvent; + let jQueryEvent = null; let bubbles = true; let nativeDispatch = true; let defaultPrevented = false; - let evt = null; if (inNamespace && $) { jQueryEvent = $.Event(event, args); @@ -589,27 +571,11 @@ defaultPrevented = jQueryEvent.isDefaultPrevented(); } - if (isNative) { - evt = document.createEvent('HTMLEvents'); - evt.initEvent(typeEvent, bubbles, true); - } else { - evt = new CustomEvent(event, { - bubbles, - cancelable: true - }); - } // merge custom information in our event - - - if (typeof args !== 'undefined') { - Object.keys(args).forEach(key => { - Object.defineProperty(evt, key, { - get() { - return args[key]; - } - - }); - }); - } + let evt = new Event(event, { + bubbles, + cancelable: true + }); + evt = hydrateObj(evt, args); if (defaultPrevented) { evt.preventDefault(); @@ -619,7 +585,7 @@ element.dispatchEvent(evt); } - if (evt.defaultPrevented && typeof jQueryEvent !== 'undefined') { + if (evt.defaultPrevented && jQueryEvent) { jQueryEvent.preventDefault(); } @@ -628,17 +594,34 @@ }; + function hydrateObj(obj, meta) { + for (const [key, value] of Object.entries(meta || {})) { + try { + obj[key] = value; + } catch (_unused) { + Object.defineProperty(obj, key, { + configurable: true, + + get() { + return value; + } + + }); + } + } + + return obj; + } + /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): dom/data.js + * Bootstrap (v5.2.0): dom/data.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** - * ------------------------------------------------------------------------ * Constants - * ------------------------------------------------------------------------ */ const elementMap = new Map(); const Data = { @@ -684,20 +667,153 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): base-component.js + * Bootstrap (v5.2.0): dom/manipulator.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) + * -------------------------------------------------------------------------- + */ + function normalizeData(value) { + if (value === 'true') { + return true; + } + + if (value === 'false') { + return false; + } + + if (value === Number(value).toString()) { + return Number(value); + } + + if (value === '' || value === 'null') { + return null; + } + + if (typeof value !== 'string') { + return value; + } + + try { + return JSON.parse(decodeURIComponent(value)); + } catch (_unused) { + return value; + } + } + + function normalizeDataKey(key) { + return key.replace(/[A-Z]/g, chr => `-${chr.toLowerCase()}`); + } + + const Manipulator = { + setDataAttribute(element, key, value) { + element.setAttribute(`data-bs-${normalizeDataKey(key)}`, value); + }, + + removeDataAttribute(element, key) { + element.removeAttribute(`data-bs-${normalizeDataKey(key)}`); + }, + + getDataAttributes(element) { + if (!element) { + return {}; + } + + const attributes = {}; + const bsKeys = Object.keys(element.dataset).filter(key => key.startsWith('bs') && !key.startsWith('bsConfig')); + + for (const key of bsKeys) { + let pureKey = key.replace(/^bs/, ''); + pureKey = pureKey.charAt(0).toLowerCase() + pureKey.slice(1, pureKey.length); + attributes[pureKey] = normalizeData(element.dataset[key]); + } + + return attributes; + }, + + getDataAttribute(element, key) { + return normalizeData(element.getAttribute(`data-bs-${normalizeDataKey(key)}`)); + } + + }; + + /** + * -------------------------------------------------------------------------- + * Bootstrap (v5.2.0): util/config.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) + * -------------------------------------------------------------------------- + */ + /** + * Class definition + */ + + class Config { + // Getters + static get Default() { + return {}; + } + + static get DefaultType() { + return {}; + } + + static get NAME() { + throw new Error('You have to implement the static method "NAME", for each component!'); + } + + _getConfig(config) { + config = this._mergeConfigObj(config); + config = this._configAfterMerge(config); + + this._typeCheckConfig(config); + + return config; + } + + _configAfterMerge(config) { + return config; + } + + _mergeConfigObj(config, element) { + const jsonConfig = isElement(element) ? Manipulator.getDataAttribute(element, 'config') : {}; // try to parse + + return { ...this.constructor.Default, + ...(typeof jsonConfig === 'object' ? jsonConfig : {}), + ...(isElement(element) ? Manipulator.getDataAttributes(element) : {}), + ...(typeof config === 'object' ? config : {}) + }; + } + + _typeCheckConfig(config, configTypes = this.constructor.DefaultType) { + for (const property of Object.keys(configTypes)) { + const expectedTypes = configTypes[property]; + const value = config[property]; + const valueType = isElement(value) ? 'element' : toType(value); + + if (!new RegExp(expectedTypes).test(valueType)) { + throw new TypeError(`${this.constructor.NAME.toUpperCase()}: Option "${property}" provided type "${valueType}" but expected type "${expectedTypes}".`); + } + } + } + + } + + /** + * -------------------------------------------------------------------------- + * Bootstrap (v5.2.0): base-component.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** - * ------------------------------------------------------------------------ * Constants - * ------------------------------------------------------------------------ */ - const VERSION = '5.1.3'; + const VERSION = '5.2.0'; + /** + * Class definition + */ - class BaseComponent { - constructor(element) { + class BaseComponent extends Config { + constructor(element, config) { + super(); element = getElement(element); if (!element) { @@ -705,21 +821,32 @@ } this._element = element; + this._config = this._getConfig(config); Data.set(this._element, this.constructor.DATA_KEY, this); - } + } // Public + dispose() { Data.remove(this._element, this.constructor.DATA_KEY); EventHandler.off(this._element, this.constructor.EVENT_KEY); - Object.getOwnPropertyNames(this).forEach(propertyName => { + + for (const propertyName of Object.getOwnPropertyNames(this)) { this[propertyName] = null; - }); + } } _queueCallback(callback, element, isAnimated = true) { executeAfterTransition(callback, element, isAnimated); } - /** Static */ + + _getConfig(config) { + config = this._mergeConfigObj(config, this._element); + config = this._configAfterMerge(config); + + this._typeCheckConfig(config); + + return config; + } // Static static getInstance(element) { @@ -734,10 +861,6 @@ return VERSION; } - static get NAME() { - throw new Error('You have to implement the static method "NAME", for each component!'); - } - static get DATA_KEY() { return `bs.${this.NAME}`; } @@ -746,11 +869,15 @@ return `.${this.DATA_KEY}`; } + static eventName(name) { + return `${name}${this.EVENT_KEY}`; + } + } /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): util/component-functions.js + * Bootstrap (v5.2.0): util/component-functions.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ @@ -776,33 +903,29 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): alert.js + * Bootstrap (v5.2.0): alert.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** - * ------------------------------------------------------------------------ * Constants - * ------------------------------------------------------------------------ */ - const NAME$d = 'alert'; - const DATA_KEY$c = 'bs.alert'; - const EVENT_KEY$c = `.${DATA_KEY$c}`; - const EVENT_CLOSE = `close${EVENT_KEY$c}`; - const EVENT_CLOSED = `closed${EVENT_KEY$c}`; + const NAME$f = 'alert'; + const DATA_KEY$a = 'bs.alert'; + const EVENT_KEY$b = `.${DATA_KEY$a}`; + const EVENT_CLOSE = `close${EVENT_KEY$b}`; + const EVENT_CLOSED = `closed${EVENT_KEY$b}`; const CLASS_NAME_FADE$5 = 'fade'; const CLASS_NAME_SHOW$8 = 'show'; /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ + * Class definition */ class Alert extends BaseComponent { // Getters static get NAME() { - return NAME$d; + return NAME$f; } // Public @@ -847,51 +970,42 @@ } /** - * ------------------------------------------------------------------------ - * Data Api implementation - * ------------------------------------------------------------------------ + * Data API implementation */ enableDismissTrigger(Alert, 'close'); /** - * ------------------------------------------------------------------------ * jQuery - * ------------------------------------------------------------------------ - * add .Alert to jQuery only if jQuery is present */ defineJQueryPlugin(Alert); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): button.js + * Bootstrap (v5.2.0): button.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** - * ------------------------------------------------------------------------ * Constants - * ------------------------------------------------------------------------ */ - const NAME$c = 'button'; - const DATA_KEY$b = 'bs.button'; - const EVENT_KEY$b = `.${DATA_KEY$b}`; - const DATA_API_KEY$7 = '.data-api'; + const NAME$e = 'button'; + const DATA_KEY$9 = 'bs.button'; + const EVENT_KEY$a = `.${DATA_KEY$9}`; + const DATA_API_KEY$6 = '.data-api'; const CLASS_NAME_ACTIVE$3 = 'active'; const SELECTOR_DATA_TOGGLE$5 = '[data-bs-toggle="button"]'; - const EVENT_CLICK_DATA_API$6 = `click${EVENT_KEY$b}${DATA_API_KEY$7}`; + const EVENT_CLICK_DATA_API$6 = `click${EVENT_KEY$a}${DATA_API_KEY$6}`; /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ + * Class definition */ class Button extends BaseComponent { // Getters static get NAME() { - return NAME$c; + return NAME$e; } // Public @@ -913,9 +1027,7 @@ } /** - * ------------------------------------------------------------------------ - * Data Api implementation - * ------------------------------------------------------------------------ + * Data API implementation */ @@ -926,95 +1038,21 @@ data.toggle(); }); /** - * ------------------------------------------------------------------------ * jQuery - * ------------------------------------------------------------------------ - * add .Button to jQuery only if jQuery is present */ defineJQueryPlugin(Button); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): dom/manipulator.js + * Bootstrap (v5.2.0): dom/selector-engine.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ - function normalizeData(val) { - if (val === 'true') { - return true; - } - - if (val === 'false') { - return false; - } - - if (val === Number(val).toString()) { - return Number(val); - } - - if (val === '' || val === 'null') { - return null; - } - - return val; - } - - function normalizeDataKey(key) { - return key.replace(/[A-Z]/g, chr => `-${chr.toLowerCase()}`); - } - - const Manipulator = { - setDataAttribute(element, key, value) { - element.setAttribute(`data-bs-${normalizeDataKey(key)}`, value); - }, - - removeDataAttribute(element, key) { - element.removeAttribute(`data-bs-${normalizeDataKey(key)}`); - }, - - getDataAttributes(element) { - if (!element) { - return {}; - } - - const attributes = {}; - Object.keys(element.dataset).filter(key => key.startsWith('bs')).forEach(key => { - let pureKey = key.replace(/^bs/, ''); - pureKey = pureKey.charAt(0).toLowerCase() + pureKey.slice(1, pureKey.length); - attributes[pureKey] = normalizeData(element.dataset[key]); - }); - return attributes; - }, - - getDataAttribute(element, key) { - return normalizeData(element.getAttribute(`data-bs-${normalizeDataKey(key)}`)); - }, - - offset(element) { - const rect = element.getBoundingClientRect(); - return { - top: rect.top + window.pageYOffset, - left: rect.left + window.pageXOffset - }; - }, - - position(element) { - return { - top: element.offsetTop, - left: element.offsetLeft - }; - } - - }; - /** - * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): dom/selector-engine.js - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) - * -------------------------------------------------------------------------- + * Constants */ - const NODE_TEXT = 3; + const SelectorEngine = { find(selector, element = document.documentElement) { return [].concat(...Element.prototype.querySelectorAll.call(element, selector)); @@ -1030,14 +1068,11 @@ parents(element, selector) { const parents = []; - let ancestor = element.parentNode; - - while (ancestor && ancestor.nodeType === Node.ELEMENT_NODE && ancestor.nodeType !== NODE_TEXT) { - if (ancestor.matches(selector)) { - parents.push(ancestor); - } + let ancestor = element.parentNode.closest(selector); - ancestor = ancestor.parentNode; + while (ancestor) { + parents.push(ancestor); + ancestor = ancestor.parentNode.closest(selector); } return parents; @@ -1057,6 +1092,7 @@ return []; }, + // TODO: this is now unused; remove later along with prev() next(element, selector) { let next = element.nextElementSibling; @@ -1072,7 +1108,7 @@ }, focusableChildren(element) { - const focusables = ['a', 'button', 'input', 'textarea', 'select', 'details', '[tabindex]', '[contenteditable="true"]'].map(selector => `${selector}:not([tabindex^="-"])`).join(', '); + const focusables = ['a', 'button', 'input', 'textarea', 'select', 'details', '[tabindex]', '[contenteditable="true"]'].map(selector => `${selector}:not([tabindex^="-"])`).join(','); return this.find(focusables, element).filter(el => !isDisabled(el) && isVisible(el)); } @@ -1080,62 +1116,170 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): carousel.js + * Bootstrap (v5.2.0): util/swipe.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** - * ------------------------------------------------------------------------ * Constants - * ------------------------------------------------------------------------ */ - const NAME$b = 'carousel'; - const DATA_KEY$a = 'bs.carousel'; - const EVENT_KEY$a = `.${DATA_KEY$a}`; - const DATA_API_KEY$6 = '.data-api'; - const ARROW_LEFT_KEY = 'ArrowLeft'; - const ARROW_RIGHT_KEY = 'ArrowRight'; - const TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch - + const NAME$d = 'swipe'; + const EVENT_KEY$9 = '.bs.swipe'; + const EVENT_TOUCHSTART = `touchstart${EVENT_KEY$9}`; + const EVENT_TOUCHMOVE = `touchmove${EVENT_KEY$9}`; + const EVENT_TOUCHEND = `touchend${EVENT_KEY$9}`; + const EVENT_POINTERDOWN = `pointerdown${EVENT_KEY$9}`; + const EVENT_POINTERUP = `pointerup${EVENT_KEY$9}`; + const POINTER_TYPE_TOUCH = 'touch'; + const POINTER_TYPE_PEN = 'pen'; + const CLASS_NAME_POINTER_EVENT = 'pointer-event'; const SWIPE_THRESHOLD = 40; - const Default$a = { - interval: 5000, - keyboard: true, - slide: false, - pause: 'hover', - wrap: true, - touch: true + const Default$c = { + endCallback: null, + leftCallback: null, + rightCallback: null }; - const DefaultType$a = { - interval: '(number|boolean)', - keyboard: 'boolean', - slide: '(boolean|string)', - pause: '(string|boolean)', - wrap: 'boolean', - touch: 'boolean' + const DefaultType$c = { + endCallback: '(function|null)', + leftCallback: '(function|null)', + rightCallback: '(function|null)' }; + /** + * Class definition + */ + + class Swipe extends Config { + constructor(element, config) { + super(); + this._element = element; + + if (!element || !Swipe.isSupported()) { + return; + } + + this._config = this._getConfig(config); + this._deltaX = 0; + this._supportPointerEvents = Boolean(window.PointerEvent); + + this._initEvents(); + } // Getters + + + static get Default() { + return Default$c; + } + + static get DefaultType() { + return DefaultType$c; + } + + static get NAME() { + return NAME$d; + } // Public + + + dispose() { + EventHandler.off(this._element, EVENT_KEY$9); + } // Private + + + _start(event) { + if (!this._supportPointerEvents) { + this._deltaX = event.touches[0].clientX; + return; + } + + if (this._eventIsPointerPenTouch(event)) { + this._deltaX = event.clientX; + } + } + + _end(event) { + if (this._eventIsPointerPenTouch(event)) { + this._deltaX = event.clientX - this._deltaX; + } + + this._handleSwipe(); + + execute(this._config.endCallback); + } + + _move(event) { + this._deltaX = event.touches && event.touches.length > 1 ? 0 : event.touches[0].clientX - this._deltaX; + } + + _handleSwipe() { + const absDeltaX = Math.abs(this._deltaX); + + if (absDeltaX <= SWIPE_THRESHOLD) { + return; + } + + const direction = absDeltaX / this._deltaX; + this._deltaX = 0; + + if (!direction) { + return; + } + + execute(direction > 0 ? this._config.rightCallback : this._config.leftCallback); + } + + _initEvents() { + if (this._supportPointerEvents) { + EventHandler.on(this._element, EVENT_POINTERDOWN, event => this._start(event)); + EventHandler.on(this._element, EVENT_POINTERUP, event => this._end(event)); + + this._element.classList.add(CLASS_NAME_POINTER_EVENT); + } else { + EventHandler.on(this._element, EVENT_TOUCHSTART, event => this._start(event)); + EventHandler.on(this._element, EVENT_TOUCHMOVE, event => this._move(event)); + EventHandler.on(this._element, EVENT_TOUCHEND, event => this._end(event)); + } + } + + _eventIsPointerPenTouch(event) { + return this._supportPointerEvents && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH); + } // Static + + + static isSupported() { + return 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0; + } + + } + + /** + * -------------------------------------------------------------------------- + * Bootstrap (v5.2.0): carousel.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) + * -------------------------------------------------------------------------- + */ + /** + * Constants + */ + + const NAME$c = 'carousel'; + const DATA_KEY$8 = 'bs.carousel'; + const EVENT_KEY$8 = `.${DATA_KEY$8}`; + const DATA_API_KEY$5 = '.data-api'; + const ARROW_LEFT_KEY$1 = 'ArrowLeft'; + const ARROW_RIGHT_KEY$1 = 'ArrowRight'; + const TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch + const ORDER_NEXT = 'next'; const ORDER_PREV = 'prev'; const DIRECTION_LEFT = 'left'; const DIRECTION_RIGHT = 'right'; - const KEY_TO_DIRECTION = { - [ARROW_LEFT_KEY]: DIRECTION_RIGHT, - [ARROW_RIGHT_KEY]: DIRECTION_LEFT - }; - const EVENT_SLIDE = `slide${EVENT_KEY$a}`; - const EVENT_SLID = `slid${EVENT_KEY$a}`; - const EVENT_KEYDOWN = `keydown${EVENT_KEY$a}`; - const EVENT_MOUSEENTER = `mouseenter${EVENT_KEY$a}`; - const EVENT_MOUSELEAVE = `mouseleave${EVENT_KEY$a}`; - const EVENT_TOUCHSTART = `touchstart${EVENT_KEY$a}`; - const EVENT_TOUCHMOVE = `touchmove${EVENT_KEY$a}`; - const EVENT_TOUCHEND = `touchend${EVENT_KEY$a}`; - const EVENT_POINTERDOWN = `pointerdown${EVENT_KEY$a}`; - const EVENT_POINTERUP = `pointerup${EVENT_KEY$a}`; - const EVENT_DRAG_START = `dragstart${EVENT_KEY$a}`; - const EVENT_LOAD_DATA_API$2 = `load${EVENT_KEY$a}${DATA_API_KEY$6}`; - const EVENT_CLICK_DATA_API$5 = `click${EVENT_KEY$a}${DATA_API_KEY$6}`; + const EVENT_SLIDE = `slide${EVENT_KEY$8}`; + const EVENT_SLID = `slid${EVENT_KEY$8}`; + const EVENT_KEYDOWN$1 = `keydown${EVENT_KEY$8}`; + const EVENT_MOUSEENTER$1 = `mouseenter${EVENT_KEY$8}`; + const EVENT_MOUSELEAVE$1 = `mouseleave${EVENT_KEY$8}`; + const EVENT_DRAG_START = `dragstart${EVENT_KEY$8}`; + const EVENT_LOAD_DATA_API$3 = `load${EVENT_KEY$8}${DATA_API_KEY$5}`; + const EVENT_CLICK_DATA_API$5 = `click${EVENT_KEY$8}${DATA_API_KEY$5}`; const CLASS_NAME_CAROUSEL = 'carousel'; const CLASS_NAME_ACTIVE$2 = 'active'; const CLASS_NAME_SLIDE = 'slide'; @@ -1143,50 +1287,66 @@ const CLASS_NAME_START = 'carousel-item-start'; const CLASS_NAME_NEXT = 'carousel-item-next'; const CLASS_NAME_PREV = 'carousel-item-prev'; - const CLASS_NAME_POINTER_EVENT = 'pointer-event'; - const SELECTOR_ACTIVE$1 = '.active'; - const SELECTOR_ACTIVE_ITEM = '.active.carousel-item'; + const SELECTOR_ACTIVE = '.active'; const SELECTOR_ITEM = '.carousel-item'; + const SELECTOR_ACTIVE_ITEM = SELECTOR_ACTIVE + SELECTOR_ITEM; const SELECTOR_ITEM_IMG = '.carousel-item img'; - const SELECTOR_NEXT_PREV = '.carousel-item-next, .carousel-item-prev'; const SELECTOR_INDICATORS = '.carousel-indicators'; - const SELECTOR_INDICATOR = '[data-bs-target]'; const SELECTOR_DATA_SLIDE = '[data-bs-slide], [data-bs-slide-to]'; const SELECTOR_DATA_RIDE = '[data-bs-ride="carousel"]'; - const POINTER_TYPE_TOUCH = 'touch'; - const POINTER_TYPE_PEN = 'pen'; + const KEY_TO_DIRECTION = { + [ARROW_LEFT_KEY$1]: DIRECTION_RIGHT, + [ARROW_RIGHT_KEY$1]: DIRECTION_LEFT + }; + const Default$b = { + interval: 5000, + keyboard: true, + pause: 'hover', + ride: false, + touch: true, + wrap: true + }; + const DefaultType$b = { + interval: '(number|boolean)', + // TODO:v6 remove boolean support + keyboard: 'boolean', + pause: '(string|boolean)', + ride: '(boolean|string)', + touch: 'boolean', + wrap: 'boolean' + }; /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ + * Class definition */ class Carousel extends BaseComponent { constructor(element, config) { - super(element); - this._items = null; + super(element, config); this._interval = null; this._activeElement = null; - this._isPaused = false; this._isSliding = false; this.touchTimeout = null; - this.touchStartX = 0; - this.touchDeltaX = 0; - this._config = this._getConfig(config); + this._swipeHelper = null; this._indicatorsElement = SelectorEngine.findOne(SELECTOR_INDICATORS, this._element); - this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0; - this._pointerEvent = Boolean(window.PointerEvent); this._addEventListeners(); + + if (this._config.ride === CLASS_NAME_CAROUSEL) { + this.cycle(); + } } // Getters static get Default() { - return Default$a; + return Default$b; + } + + static get DefaultType() { + return DefaultType$b; } static get NAME() { - return NAME$b; + return NAME$c; } // Public @@ -1195,6 +1355,7 @@ } nextWhenVisible() { + // FIXME TODO use `document.visibilityState` // Don't call next when the page isn't visible // or the carousel or its parent isn't visible if (!document.hidden && isVisible(this._element)) { @@ -1206,43 +1367,39 @@ this._slide(ORDER_PREV); } - pause(event) { - if (!event) { - this._isPaused = true; - } - - if (SelectorEngine.findOne(SELECTOR_NEXT_PREV, this._element)) { + pause() { + if (this._isSliding) { triggerTransitionEnd(this._element); - this.cycle(true); } - clearInterval(this._interval); - this._interval = null; + this._clearInterval(); } - cycle(event) { - if (!event) { - this._isPaused = false; - } + cycle() { + this._clearInterval(); - if (this._interval) { - clearInterval(this._interval); - this._interval = null; - } + this._updateInterval(); - if (this._config && this._config.interval && !this._isPaused) { - this._updateInterval(); + this._interval = setInterval(() => this.nextWhenVisible(), this._config.interval); + } - this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval); + _maybeEnableCycle() { + if (!this._config.ride) { + return; } + + if (this._isSliding) { + EventHandler.one(this._element, EVENT_SLID, () => this.cycle()); + return; + } + + this.cycle(); } to(index) { - this._activeElement = SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element); - - const activeIndex = this._getItemIndex(this._activeElement); + const items = this._getItems(); - if (index > this._items.length - 1 || index < 0) { + if (index > items.length - 1 || index < 0) { return; } @@ -1251,116 +1408,78 @@ return; } + const activeIndex = this._getItemIndex(this._getActive()); + if (activeIndex === index) { - this.pause(); - this.cycle(); return; } const order = index > activeIndex ? ORDER_NEXT : ORDER_PREV; - this._slide(order, this._items[index]); - } // Private - - - _getConfig(config) { - config = { ...Default$a, - ...Manipulator.getDataAttributes(this._element), - ...(typeof config === 'object' ? config : {}) - }; - typeCheckConfig(NAME$b, config, DefaultType$a); - return config; + this._slide(order, items[index]); } - _handleSwipe() { - const absDeltax = Math.abs(this.touchDeltaX); - - if (absDeltax <= SWIPE_THRESHOLD) { - return; + dispose() { + if (this._swipeHelper) { + this._swipeHelper.dispose(); } - const direction = absDeltax / this.touchDeltaX; - this.touchDeltaX = 0; + super.dispose(); + } // Private - if (!direction) { - return; - } - this._slide(direction > 0 ? DIRECTION_RIGHT : DIRECTION_LEFT); + _configAfterMerge(config) { + config.defaultInterval = config.interval; + return config; } _addEventListeners() { if (this._config.keyboard) { - EventHandler.on(this._element, EVENT_KEYDOWN, event => this._keydown(event)); + EventHandler.on(this._element, EVENT_KEYDOWN$1, event => this._keydown(event)); } if (this._config.pause === 'hover') { - EventHandler.on(this._element, EVENT_MOUSEENTER, event => this.pause(event)); - EventHandler.on(this._element, EVENT_MOUSELEAVE, event => this.cycle(event)); + EventHandler.on(this._element, EVENT_MOUSEENTER$1, () => this.pause()); + EventHandler.on(this._element, EVENT_MOUSELEAVE$1, () => this._maybeEnableCycle()); } - if (this._config.touch && this._touchSupported) { + if (this._config.touch && Swipe.isSupported()) { this._addTouchEventListeners(); } } _addTouchEventListeners() { - const hasPointerPenTouch = event => { - return this._pointerEvent && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH); - }; - - const start = event => { - if (hasPointerPenTouch(event)) { - this.touchStartX = event.clientX; - } else if (!this._pointerEvent) { - this.touchStartX = event.touches[0].clientX; - } - }; - - const move = event => { - // ensure swiping with one touch and not pinching - this.touchDeltaX = event.touches && event.touches.length > 1 ? 0 : event.touches[0].clientX - this.touchStartX; - }; - - const end = event => { - if (hasPointerPenTouch(event)) { - this.touchDeltaX = event.clientX - this.touchStartX; - } + for (const img of SelectorEngine.find(SELECTOR_ITEM_IMG, this._element)) { + EventHandler.on(img, EVENT_DRAG_START, event => event.preventDefault()); + } - this._handleSwipe(); + const endCallBack = () => { + if (this._config.pause !== 'hover') { + return; + } // If it's a touch-enabled device, mouseenter/leave are fired as + // part of the mouse compatibility events on first tap - the carousel + // would stop cycling until user tapped out of it; + // here, we listen for touchend, explicitly pause the carousel + // (as if it's the second time we tap on it, mouseenter compat event + // is NOT fired) and after a timeout (to allow for mouse compatibility + // events to fire) we explicitly restart cycling - if (this._config.pause === 'hover') { - // If it's a touch-enabled device, mouseenter/leave are fired as - // part of the mouse compatibility events on first tap - the carousel - // would stop cycling until user tapped out of it; - // here, we listen for touchend, explicitly pause the carousel - // (as if it's the second time we tap on it, mouseenter compat event - // is NOT fired) and after a timeout (to allow for mouse compatibility - // events to fire) we explicitly restart cycling - this.pause(); - if (this.touchTimeout) { - clearTimeout(this.touchTimeout); - } + this.pause(); - this.touchTimeout = setTimeout(event => this.cycle(event), TOUCHEVENT_COMPAT_WAIT + this._config.interval); + if (this.touchTimeout) { + clearTimeout(this.touchTimeout); } - }; - SelectorEngine.find(SELECTOR_ITEM_IMG, this._element).forEach(itemImg => { - EventHandler.on(itemImg, EVENT_DRAG_START, event => event.preventDefault()); - }); - - if (this._pointerEvent) { - EventHandler.on(this._element, EVENT_POINTERDOWN, event => start(event)); - EventHandler.on(this._element, EVENT_POINTERUP, event => end(event)); + this.touchTimeout = setTimeout(() => this._maybeEnableCycle(), TOUCHEVENT_COMPAT_WAIT + this._config.interval); + }; - this._element.classList.add(CLASS_NAME_POINTER_EVENT); - } else { - EventHandler.on(this._element, EVENT_TOUCHSTART, event => start(event)); - EventHandler.on(this._element, EVENT_TOUCHMOVE, event => move(event)); - EventHandler.on(this._element, EVENT_TOUCHEND, event => end(event)); - } + const swipeConfig = { + leftCallback: () => this._slide(this._directionToOrder(DIRECTION_LEFT)), + rightCallback: () => this._slide(this._directionToOrder(DIRECTION_RIGHT)), + endCallback: endCallBack + }; + this._swipeHelper = new Swipe(this._element, swipeConfig); } _keydown(event) { @@ -1373,95 +1492,67 @@ if (direction) { event.preventDefault(); - this._slide(direction); + this._slide(this._directionToOrder(direction)); } } _getItemIndex(element) { - this._items = element && element.parentNode ? SelectorEngine.find(SELECTOR_ITEM, element.parentNode) : []; - return this._items.indexOf(element); - } - - _getItemByOrder(order, activeElement) { - const isNext = order === ORDER_NEXT; - return getNextActiveElement(this._items, activeElement, isNext, this._config.wrap); + return this._getItems().indexOf(element); } - _triggerSlideEvent(relatedTarget, eventDirectionName) { - const targetIndex = this._getItemIndex(relatedTarget); - - const fromIndex = this._getItemIndex(SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element)); - - return EventHandler.trigger(this._element, EVENT_SLIDE, { - relatedTarget, - direction: eventDirectionName, - from: fromIndex, - to: targetIndex - }); - } + _setActiveIndicatorElement(index) { + if (!this._indicatorsElement) { + return; + } - _setActiveIndicatorElement(element) { - if (this._indicatorsElement) { - const activeIndicator = SelectorEngine.findOne(SELECTOR_ACTIVE$1, this._indicatorsElement); - activeIndicator.classList.remove(CLASS_NAME_ACTIVE$2); - activeIndicator.removeAttribute('aria-current'); - const indicators = SelectorEngine.find(SELECTOR_INDICATOR, this._indicatorsElement); + const activeIndicator = SelectorEngine.findOne(SELECTOR_ACTIVE, this._indicatorsElement); + activeIndicator.classList.remove(CLASS_NAME_ACTIVE$2); + activeIndicator.removeAttribute('aria-current'); + const newActiveIndicator = SelectorEngine.findOne(`[data-bs-slide-to="${index}"]`, this._indicatorsElement); - for (let i = 0; i < indicators.length; i++) { - if (Number.parseInt(indicators[i].getAttribute('data-bs-slide-to'), 10) === this._getItemIndex(element)) { - indicators[i].classList.add(CLASS_NAME_ACTIVE$2); - indicators[i].setAttribute('aria-current', 'true'); - break; - } - } + if (newActiveIndicator) { + newActiveIndicator.classList.add(CLASS_NAME_ACTIVE$2); + newActiveIndicator.setAttribute('aria-current', 'true'); } } _updateInterval() { - const element = this._activeElement || SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element); + const element = this._activeElement || this._getActive(); if (!element) { return; } const elementInterval = Number.parseInt(element.getAttribute('data-bs-interval'), 10); - - if (elementInterval) { - this._config.defaultInterval = this._config.defaultInterval || this._config.interval; - this._config.interval = elementInterval; - } else { - this._config.interval = this._config.defaultInterval || this._config.interval; - } + this._config.interval = elementInterval || this._config.defaultInterval; } - _slide(directionOrOrder, element) { - const order = this._directionToOrder(directionOrOrder); - - const activeElement = SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element); - - const activeElementIndex = this._getItemIndex(activeElement); - - const nextElement = element || this._getItemByOrder(order, activeElement); + _slide(order, element = null) { + if (this._isSliding) { + return; + } - const nextElementIndex = this._getItemIndex(nextElement); + const activeElement = this._getActive(); - const isCycling = Boolean(this._interval); const isNext = order === ORDER_NEXT; - const directionalClassName = isNext ? CLASS_NAME_START : CLASS_NAME_END; - const orderClassName = isNext ? CLASS_NAME_NEXT : CLASS_NAME_PREV; + const nextElement = element || getNextActiveElement(this._getItems(), activeElement, isNext, this._config.wrap); - const eventDirectionName = this._orderToDirection(order); - - if (nextElement && nextElement.classList.contains(CLASS_NAME_ACTIVE$2)) { - this._isSliding = false; + if (nextElement === activeElement) { return; } - if (this._isSliding) { - return; - } + const nextElementIndex = this._getItemIndex(nextElement); - const slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName); + const triggerEvent = eventName => { + return EventHandler.trigger(this._element, eventName, { + relatedTarget: nextElement, + direction: this._orderToDirection(order), + from: this._getItemIndex(activeElement), + to: nextElementIndex + }); + }; + + const slideEvent = triggerEvent(EVENT_SLIDE); if (slideEvent.defaultPrevented) { return; @@ -1469,60 +1560,59 @@ if (!activeElement || !nextElement) { // Some weirdness is happening, so we bail + // todo: change tests that use empty divs to avoid this check return; } + const isCycling = Boolean(this._interval); + this.pause(); this._isSliding = true; - if (isCycling) { - this.pause(); - } - - this._setActiveIndicatorElement(nextElement); + this._setActiveIndicatorElement(nextElementIndex); this._activeElement = nextElement; + const directionalClassName = isNext ? CLASS_NAME_START : CLASS_NAME_END; + const orderClassName = isNext ? CLASS_NAME_NEXT : CLASS_NAME_PREV; + nextElement.classList.add(orderClassName); + reflow(nextElement); + activeElement.classList.add(directionalClassName); + nextElement.classList.add(directionalClassName); - const triggerSlidEvent = () => { - EventHandler.trigger(this._element, EVENT_SLID, { - relatedTarget: nextElement, - direction: eventDirectionName, - from: activeElementIndex, - to: nextElementIndex - }); - }; - - if (this._element.classList.contains(CLASS_NAME_SLIDE)) { - nextElement.classList.add(orderClassName); - reflow(nextElement); - activeElement.classList.add(directionalClassName); - nextElement.classList.add(directionalClassName); - - const completeCallBack = () => { - nextElement.classList.remove(directionalClassName, orderClassName); - nextElement.classList.add(CLASS_NAME_ACTIVE$2); - activeElement.classList.remove(CLASS_NAME_ACTIVE$2, orderClassName, directionalClassName); - this._isSliding = false; - setTimeout(triggerSlidEvent, 0); - }; - - this._queueCallback(completeCallBack, activeElement, true); - } else { - activeElement.classList.remove(CLASS_NAME_ACTIVE$2); + const completeCallBack = () => { + nextElement.classList.remove(directionalClassName, orderClassName); nextElement.classList.add(CLASS_NAME_ACTIVE$2); + activeElement.classList.remove(CLASS_NAME_ACTIVE$2, orderClassName, directionalClassName); this._isSliding = false; - triggerSlidEvent(); - } + triggerEvent(EVENT_SLID); + }; + + this._queueCallback(completeCallBack, activeElement, this._isAnimated()); if (isCycling) { this.cycle(); } } - _directionToOrder(direction) { - if (![DIRECTION_RIGHT, DIRECTION_LEFT].includes(direction)) { - return direction; + _isAnimated() { + return this._element.classList.contains(CLASS_NAME_SLIDE); + } + + _getActive() { + return SelectorEngine.findOne(SELECTOR_ACTIVE_ITEM, this._element); + } + + _getItems() { + return SelectorEngine.find(SELECTOR_ITEM, this._element); + } + + _clearInterval() { + if (this._interval) { + clearInterval(this._interval); + this._interval = null; } + } + _directionToOrder(direction) { if (isRTL()) { return direction === DIRECTION_LEFT ? ORDER_PREV : ORDER_NEXT; } @@ -1531,10 +1621,6 @@ } _orderToDirection(order) { - if (![ORDER_NEXT, ORDER_PREV].includes(order)) { - return order; - } - if (isRTL()) { return order === ORDER_PREV ? DIRECTION_LEFT : DIRECTION_RIGHT; } @@ -1543,119 +1629,94 @@ } // Static - static carouselInterface(element, config) { - const data = Carousel.getOrCreateInstance(element, config); - let { - _config - } = data; - - if (typeof config === 'object') { - _config = { ..._config, - ...config - }; - } - - const action = typeof config === 'string' ? config : _config.slide; + static jQueryInterface(config) { + return this.each(function () { + const data = Carousel.getOrCreateInstance(this, config); - if (typeof config === 'number') { - data.to(config); - } else if (typeof action === 'string') { - if (typeof data[action] === 'undefined') { - throw new TypeError(`No method named "${action}"`); + if (typeof config === 'number') { + data.to(config); + return; } - data[action](); - } else if (_config.interval && _config.ride) { - data.pause(); - data.cycle(); - } - } + if (typeof config === 'string') { + if (data[config] === undefined || config.startsWith('_') || config === 'constructor') { + throw new TypeError(`No method named "${config}"`); + } - static jQueryInterface(config) { - return this.each(function () { - Carousel.carouselInterface(this, config); + data[config](); + } }); } - static dataApiClickHandler(event) { - const target = getElementFromSelector(this); + } + /** + * Data API implementation + */ - if (!target || !target.classList.contains(CLASS_NAME_CAROUSEL)) { - return; - } - const config = { ...Manipulator.getDataAttributes(target), - ...Manipulator.getDataAttributes(this) - }; - const slideIndex = this.getAttribute('data-bs-slide-to'); + EventHandler.on(document, EVENT_CLICK_DATA_API$5, SELECTOR_DATA_SLIDE, function (event) { + const target = getElementFromSelector(this); - if (slideIndex) { - config.interval = false; - } + if (!target || !target.classList.contains(CLASS_NAME_CAROUSEL)) { + return; + } + + event.preventDefault(); + const carousel = Carousel.getOrCreateInstance(target); + const slideIndex = this.getAttribute('data-bs-slide-to'); - Carousel.carouselInterface(target, config); + if (slideIndex) { + carousel.to(slideIndex); - if (slideIndex) { - Carousel.getInstance(target).to(slideIndex); - } + carousel._maybeEnableCycle(); - event.preventDefault(); + return; } - } - /** - * ------------------------------------------------------------------------ - * Data Api implementation - * ------------------------------------------------------------------------ - */ + if (Manipulator.getDataAttribute(this, 'slide') === 'next') { + carousel.next(); + carousel._maybeEnableCycle(); - EventHandler.on(document, EVENT_CLICK_DATA_API$5, SELECTOR_DATA_SLIDE, Carousel.dataApiClickHandler); - EventHandler.on(window, EVENT_LOAD_DATA_API$2, () => { + return; + } + + carousel.prev(); + + carousel._maybeEnableCycle(); + }); + EventHandler.on(window, EVENT_LOAD_DATA_API$3, () => { const carousels = SelectorEngine.find(SELECTOR_DATA_RIDE); - for (let i = 0, len = carousels.length; i < len; i++) { - Carousel.carouselInterface(carousels[i], Carousel.getInstance(carousels[i])); + for (const carousel of carousels) { + Carousel.getOrCreateInstance(carousel); } }); /** - * ------------------------------------------------------------------------ * jQuery - * ------------------------------------------------------------------------ - * add .Carousel to jQuery only if jQuery is present */ defineJQueryPlugin(Carousel); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): collapse.js + * Bootstrap (v5.2.0): collapse.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** - * ------------------------------------------------------------------------ * Constants - * ------------------------------------------------------------------------ */ - const NAME$a = 'collapse'; - const DATA_KEY$9 = 'bs.collapse'; - const EVENT_KEY$9 = `.${DATA_KEY$9}`; - const DATA_API_KEY$5 = '.data-api'; - const Default$9 = { - toggle: true, - parent: null - }; - const DefaultType$9 = { - toggle: 'boolean', - parent: '(null|element)' - }; - const EVENT_SHOW$5 = `show${EVENT_KEY$9}`; - const EVENT_SHOWN$5 = `shown${EVENT_KEY$9}`; - const EVENT_HIDE$5 = `hide${EVENT_KEY$9}`; - const EVENT_HIDDEN$5 = `hidden${EVENT_KEY$9}`; - const EVENT_CLICK_DATA_API$4 = `click${EVENT_KEY$9}${DATA_API_KEY$5}`; + const NAME$b = 'collapse'; + const DATA_KEY$7 = 'bs.collapse'; + const EVENT_KEY$7 = `.${DATA_KEY$7}`; + const DATA_API_KEY$4 = '.data-api'; + const EVENT_SHOW$6 = `show${EVENT_KEY$7}`; + const EVENT_SHOWN$6 = `shown${EVENT_KEY$7}`; + const EVENT_HIDE$6 = `hide${EVENT_KEY$7}`; + const EVENT_HIDDEN$6 = `hidden${EVENT_KEY$7}`; + const EVENT_CLICK_DATA_API$4 = `click${EVENT_KEY$7}${DATA_API_KEY$4}`; const CLASS_NAME_SHOW$7 = 'show'; const CLASS_NAME_COLLAPSE = 'collapse'; const CLASS_NAME_COLLAPSING = 'collapsing'; @@ -1666,28 +1727,30 @@ const HEIGHT = 'height'; const SELECTOR_ACTIVES = '.collapse.show, .collapse.collapsing'; const SELECTOR_DATA_TOGGLE$4 = '[data-bs-toggle="collapse"]'; + const Default$a = { + parent: null, + toggle: true + }; + const DefaultType$a = { + parent: '(null|element)', + toggle: 'boolean' + }; /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ + * Class definition */ class Collapse extends BaseComponent { constructor(element, config) { - super(element); + super(element, config); this._isTransitioning = false; - this._config = this._getConfig(config); this._triggerArray = []; const toggleList = SelectorEngine.find(SELECTOR_DATA_TOGGLE$4); - for (let i = 0, len = toggleList.length; i < len; i++) { - const elem = toggleList[i]; + for (const elem of toggleList) { const selector = getSelectorFromElement(elem); - const filterElement = SelectorEngine.find(selector).filter(foundElem => foundElem === this._element); + const filterElement = SelectorEngine.find(selector).filter(foundElement => foundElement === this._element); if (selector !== null && filterElement.length) { - this._selector = selector; - this._triggerArray.push(elem); } } @@ -1705,11 +1768,15 @@ static get Default() { - return Default$9; + return Default$a; + } + + static get DefaultType() { + return DefaultType$a; } static get NAME() { - return NAME$a; + return NAME$b; } // Public @@ -1726,42 +1793,27 @@ return; } - let actives = []; - let activesData; + let activeChildren = []; // find active children if (this._config.parent) { - const children = SelectorEngine.find(CLASS_NAME_DEEPER_CHILDREN, this._config.parent); - actives = SelectorEngine.find(SELECTOR_ACTIVES, this._config.parent).filter(elem => !children.includes(elem)); // remove children if greater depth + activeChildren = this._getFirstLevelChildren(SELECTOR_ACTIVES).filter(element => element !== this._element).map(element => Collapse.getOrCreateInstance(element, { + toggle: false + })); } - const container = SelectorEngine.findOne(this._selector); - - if (actives.length) { - const tempActiveData = actives.find(elem => container !== elem); - activesData = tempActiveData ? Collapse.getInstance(tempActiveData) : null; - - if (activesData && activesData._isTransitioning) { - return; - } + if (activeChildren.length && activeChildren[0]._isTransitioning) { + return; } - const startEvent = EventHandler.trigger(this._element, EVENT_SHOW$5); + const startEvent = EventHandler.trigger(this._element, EVENT_SHOW$6); if (startEvent.defaultPrevented) { return; } - actives.forEach(elemActive => { - if (container !== elemActive) { - Collapse.getOrCreateInstance(elemActive, { - toggle: false - }).hide(); - } - - if (!activesData) { - Data.set(elemActive, DATA_KEY$9, null); - } - }); + for (const activeInstance of activeChildren) { + activeInstance.hide(); + } const dimension = this._getDimension(); @@ -1783,7 +1835,7 @@ this._element.classList.add(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW$7); this._element.style[dimension] = ''; - EventHandler.trigger(this._element, EVENT_SHOWN$5); + EventHandler.trigger(this._element, EVENT_SHOWN$6); }; const capitalizedDimension = dimension[0].toUpperCase() + dimension.slice(1); @@ -1799,7 +1851,7 @@ return; } - const startEvent = EventHandler.trigger(this._element, EVENT_HIDE$5); + const startEvent = EventHandler.trigger(this._element, EVENT_HIDE$6); if (startEvent.defaultPrevented) { return; @@ -1814,13 +1866,10 @@ this._element.classList.remove(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW$7); - const triggerArrayLength = this._triggerArray.length; + for (const trigger of this._triggerArray) { + const element = getElementFromSelector(trigger); - for (let i = 0; i < triggerArrayLength; i++) { - const trigger = this._triggerArray[i]; - const elem = getElementFromSelector(trigger); - - if (elem && !this._isShown(elem)) { + if (element && !this._isShown(element)) { this._addAriaAndCollapsedClass([trigger], false); } } @@ -1834,7 +1883,7 @@ this._element.classList.add(CLASS_NAME_COLLAPSE); - EventHandler.trigger(this._element, EVENT_HIDDEN$5); + EventHandler.trigger(this._element, EVENT_HIDDEN$6); }; this._element.style[dimension] = ''; @@ -1847,15 +1896,10 @@ } // Private - _getConfig(config) { - config = { ...Default$9, - ...Manipulator.getDataAttributes(this._element), - ...config - }; + _configAfterMerge(config) { config.toggle = Boolean(config.toggle); // Coerce string values config.parent = getElement(config.parent); - typeCheckConfig(NAME$a, config, DefaultType$9); return config; } @@ -1868,14 +1912,21 @@ return; } - const children = SelectorEngine.find(CLASS_NAME_DEEPER_CHILDREN, this._config.parent); - SelectorEngine.find(SELECTOR_DATA_TOGGLE$4, this._config.parent).filter(elem => !children.includes(elem)).forEach(element => { + const children = this._getFirstLevelChildren(SELECTOR_DATA_TOGGLE$4); + + for (const element of children) { const selected = getElementFromSelector(element); if (selected) { this._addAriaAndCollapsedClass([element], this._isShown(selected)); } - }); + } + } + + _getFirstLevelChildren(selector) { + const children = SelectorEngine.find(CLASS_NAME_DEEPER_CHILDREN, this._config.parent); // remove children if greater depth + + return SelectorEngine.find(selector, this._config.parent).filter(element => !children.includes(element)); } _addAriaAndCollapsedClass(triggerArray, isOpen) { @@ -1883,26 +1934,21 @@ return; } - triggerArray.forEach(elem => { - if (isOpen) { - elem.classList.remove(CLASS_NAME_COLLAPSED); - } else { - elem.classList.add(CLASS_NAME_COLLAPSED); - } - - elem.setAttribute('aria-expanded', isOpen); - }); + for (const element of triggerArray) { + element.classList.toggle(CLASS_NAME_COLLAPSED, !isOpen); + element.setAttribute('aria-expanded', isOpen); + } } // Static static jQueryInterface(config) { - return this.each(function () { - const _config = {}; + const _config = {}; - if (typeof config === 'string' && /show|hide/.test(config)) { - _config.toggle = false; - } + if (typeof config === 'string' && /show|hide/.test(config)) { + _config.toggle = false; + } + return this.each(function () { const data = Collapse.getOrCreateInstance(this, _config); if (typeof config === 'string') { @@ -1917,9 +1963,7 @@ } /** - * ------------------------------------------------------------------------ - * Data Api implementation - * ------------------------------------------------------------------------ + * Data API implementation */ @@ -1931,59 +1975,56 @@ const selector = getSelectorFromElement(this); const selectorElements = SelectorEngine.find(selector); - selectorElements.forEach(element => { + + for (const element of selectorElements) { Collapse.getOrCreateInstance(element, { toggle: false }).toggle(); - }); + } }); /** - * ------------------------------------------------------------------------ * jQuery - * ------------------------------------------------------------------------ - * add .Collapse to jQuery only if jQuery is present */ defineJQueryPlugin(Collapse); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): dropdown.js + * Bootstrap (v5.2.0): dropdown.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** - * ------------------------------------------------------------------------ * Constants - * ------------------------------------------------------------------------ */ - const NAME$9 = 'dropdown'; - const DATA_KEY$8 = 'bs.dropdown'; - const EVENT_KEY$8 = `.${DATA_KEY$8}`; - const DATA_API_KEY$4 = '.data-api'; + const NAME$a = 'dropdown'; + const DATA_KEY$6 = 'bs.dropdown'; + const EVENT_KEY$6 = `.${DATA_KEY$6}`; + const DATA_API_KEY$3 = '.data-api'; const ESCAPE_KEY$2 = 'Escape'; - const SPACE_KEY = 'Space'; const TAB_KEY$1 = 'Tab'; - const ARROW_UP_KEY = 'ArrowUp'; - const ARROW_DOWN_KEY = 'ArrowDown'; + const ARROW_UP_KEY$1 = 'ArrowUp'; + const ARROW_DOWN_KEY$1 = 'ArrowDown'; const RIGHT_MOUSE_BUTTON = 2; // MouseEvent.button value for the secondary button, usually the right button - const REGEXP_KEYDOWN = new RegExp(`${ARROW_UP_KEY}|${ARROW_DOWN_KEY}|${ESCAPE_KEY$2}`); - const EVENT_HIDE$4 = `hide${EVENT_KEY$8}`; - const EVENT_HIDDEN$4 = `hidden${EVENT_KEY$8}`; - const EVENT_SHOW$4 = `show${EVENT_KEY$8}`; - const EVENT_SHOWN$4 = `shown${EVENT_KEY$8}`; - const EVENT_CLICK_DATA_API$3 = `click${EVENT_KEY$8}${DATA_API_KEY$4}`; - const EVENT_KEYDOWN_DATA_API = `keydown${EVENT_KEY$8}${DATA_API_KEY$4}`; - const EVENT_KEYUP_DATA_API = `keyup${EVENT_KEY$8}${DATA_API_KEY$4}`; + const EVENT_HIDE$5 = `hide${EVENT_KEY$6}`; + const EVENT_HIDDEN$5 = `hidden${EVENT_KEY$6}`; + const EVENT_SHOW$5 = `show${EVENT_KEY$6}`; + const EVENT_SHOWN$5 = `shown${EVENT_KEY$6}`; + const EVENT_CLICK_DATA_API$3 = `click${EVENT_KEY$6}${DATA_API_KEY$3}`; + const EVENT_KEYDOWN_DATA_API = `keydown${EVENT_KEY$6}${DATA_API_KEY$3}`; + const EVENT_KEYUP_DATA_API = `keyup${EVENT_KEY$6}${DATA_API_KEY$3}`; const CLASS_NAME_SHOW$6 = 'show'; const CLASS_NAME_DROPUP = 'dropup'; const CLASS_NAME_DROPEND = 'dropend'; const CLASS_NAME_DROPSTART = 'dropstart'; - const CLASS_NAME_NAVBAR = 'navbar'; - const SELECTOR_DATA_TOGGLE$3 = '[data-bs-toggle="dropdown"]'; + const CLASS_NAME_DROPUP_CENTER = 'dropup-center'; + const CLASS_NAME_DROPDOWN_CENTER = 'dropdown-center'; + const SELECTOR_DATA_TOGGLE$3 = '[data-bs-toggle="dropdown"]:not(.disabled):not(:disabled)'; + const SELECTOR_DATA_TOGGLE_SHOWN = `${SELECTOR_DATA_TOGGLE$3}.${CLASS_NAME_SHOW$6}`; const SELECTOR_MENU = '.dropdown-menu'; + const SELECTOR_NAVBAR = '.navbar'; const SELECTOR_NAVBAR_NAV = '.navbar-nav'; const SELECTOR_VISIBLE_ITEMS = '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)'; const PLACEMENT_TOP = isRTL() ? 'top-end' : 'top-start'; @@ -1992,48 +2033,49 @@ const PLACEMENT_BOTTOMEND = isRTL() ? 'bottom-start' : 'bottom-end'; const PLACEMENT_RIGHT = isRTL() ? 'left-start' : 'right-start'; const PLACEMENT_LEFT = isRTL() ? 'right-start' : 'left-start'; - const Default$8 = { - offset: [0, 2], + const PLACEMENT_TOPCENTER = 'top'; + const PLACEMENT_BOTTOMCENTER = 'bottom'; + const Default$9 = { + autoClose: true, boundary: 'clippingParents', - reference: 'toggle', display: 'dynamic', + offset: [0, 2], popperConfig: null, - autoClose: true + reference: 'toggle' }; - const DefaultType$8 = { - offset: '(array|string|function)', + const DefaultType$9 = { + autoClose: '(boolean|string)', boundary: '(string|element)', - reference: '(string|element|object)', display: 'string', + offset: '(array|string|function)', popperConfig: '(null|object|function)', - autoClose: '(boolean|string)' + reference: '(string|element|object)' }; /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ + * Class definition */ class Dropdown extends BaseComponent { constructor(element, config) { - super(element); + super(element, config); this._popper = null; - this._config = this._getConfig(config); - this._menu = this._getMenuElement(); + this._parent = this._element.parentNode; // dropdown wrapper + + this._menu = SelectorEngine.findOne(SELECTOR_MENU, this._parent); this._inNavbar = this._detectNavbar(); } // Getters static get Default() { - return Default$8; + return Default$9; } static get DefaultType() { - return DefaultType$8; + return DefaultType$9; } static get NAME() { - return NAME$9; + return NAME$a; } // Public @@ -2042,33 +2084,29 @@ } show() { - if (isDisabled(this._element) || this._isShown(this._menu)) { + if (isDisabled(this._element) || this._isShown()) { return; } const relatedTarget = { relatedTarget: this._element }; - const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$4, relatedTarget); + const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$5, relatedTarget); if (showEvent.defaultPrevented) { return; } - const parent = Dropdown.getParentFromElement(this._element); // Totally disable Popper for Dropdowns in Navbar - - if (this._inNavbar) { - Manipulator.setDataAttribute(this._menu, 'popper', 'none'); - } else { - this._createPopper(parent); - } // If this is a touch-enabled device we add extra + this._createPopper(); // 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)) { - [].concat(...document.body.children).forEach(elem => EventHandler.on(elem, 'mouseover', noop)); + if ('ontouchstart' in document.documentElement && !this._parent.closest(SELECTOR_NAVBAR_NAV)) { + for (const element of [].concat(...document.body.children)) { + EventHandler.on(element, 'mouseover', noop); + } } this._element.focus(); @@ -2079,11 +2117,11 @@ this._element.classList.add(CLASS_NAME_SHOW$6); - EventHandler.trigger(this._element, EVENT_SHOWN$4, relatedTarget); + EventHandler.trigger(this._element, EVENT_SHOWN$5, relatedTarget); } hide() { - if (isDisabled(this._element) || !this._isShown(this._menu)) { + if (isDisabled(this._element) || !this._isShown()) { return; } @@ -2112,7 +2150,7 @@ _completeHide(relatedTarget) { - const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$4, relatedTarget); + const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$5, relatedTarget); if (hideEvent.defaultPrevented) { return; @@ -2121,7 +2159,9 @@ if ('ontouchstart' in document.documentElement) { - [].concat(...document.body.children).forEach(elem => EventHandler.off(elem, 'mouseover', noop)); + for (const element of [].concat(...document.body.children)) { + EventHandler.off(element, 'mouseover', noop); + } } if (this._popper) { @@ -2135,25 +2175,21 @@ this._element.setAttribute('aria-expanded', 'false'); Manipulator.removeDataAttribute(this._menu, 'popper'); - EventHandler.trigger(this._element, EVENT_HIDDEN$4, relatedTarget); + EventHandler.trigger(this._element, EVENT_HIDDEN$5, relatedTarget); } _getConfig(config) { - config = { ...this.constructor.Default, - ...Manipulator.getDataAttributes(this._element), - ...config - }; - typeCheckConfig(NAME$9, config, this.constructor.DefaultType); + config = super._getConfig(config); if (typeof config.reference === 'object' && !isElement(config.reference) && typeof config.reference.getBoundingClientRect !== 'function') { // Popper virtual elements require a getBoundingClientRect method - throw new TypeError(`${NAME$9.toUpperCase()}: Option "reference" provided type "object" without a required "getBoundingClientRect" method.`); + throw new TypeError(`${NAME$a.toUpperCase()}: Option "reference" provided type "object" without a required "getBoundingClientRect" method.`); } return config; } - _createPopper(parent) { + _createPopper() { if (typeof Popper__namespace === 'undefined') { throw new TypeError('Bootstrap\'s dropdowns require Popper (https://popper.js.org)'); } @@ -2161,7 +2197,7 @@ let referenceElement = this._element; if (this._config.reference === 'parent') { - referenceElement = parent; + referenceElement = this._parent; } else if (isElement(this._config.reference)) { referenceElement = getElement(this._config.reference); } else if (typeof this._config.reference === 'object') { @@ -2170,24 +2206,15 @@ const popperConfig = this._getPopperConfig(); - const isDisplayStatic = popperConfig.modifiers.find(modifier => modifier.name === 'applyStyles' && modifier.enabled === false); this._popper = Popper__namespace.createPopper(referenceElement, this._menu, popperConfig); - - if (isDisplayStatic) { - Manipulator.setDataAttribute(this._menu, 'popper', 'static'); - } - } - - _isShown(element = this._element) { - return element.classList.contains(CLASS_NAME_SHOW$6); } - _getMenuElement() { - return SelectorEngine.next(this._element, SELECTOR_MENU)[0]; + _isShown() { + return this._menu.classList.contains(CLASS_NAME_SHOW$6); } _getPlacement() { - const parentDropdown = this._element.parentNode; + const parentDropdown = this._parent; if (parentDropdown.classList.contains(CLASS_NAME_DROPEND)) { return PLACEMENT_RIGHT; @@ -2195,6 +2222,14 @@ if (parentDropdown.classList.contains(CLASS_NAME_DROPSTART)) { return PLACEMENT_LEFT; + } + + if (parentDropdown.classList.contains(CLASS_NAME_DROPUP_CENTER)) { + return PLACEMENT_TOPCENTER; + } + + if (parentDropdown.classList.contains(CLASS_NAME_DROPDOWN_CENTER)) { + return PLACEMENT_BOTTOMCENTER; } // We need to trim the value because custom properties can also include spaces @@ -2208,7 +2243,7 @@ } _detectNavbar() { - return this._element.closest(`.${CLASS_NAME_NAVBAR}`) !== null; + return this._element.closest(SELECTOR_NAVBAR) !== null; } _getOffset() { @@ -2217,7 +2252,7 @@ } = this._config; if (typeof offset === 'string') { - return offset.split(',').map(val => Number.parseInt(val, 10)); + return offset.split(',').map(value => Number.parseInt(value, 10)); } if (typeof offset === 'function') { @@ -2241,9 +2276,11 @@ offset: this._getOffset() } }] - }; // Disable Popper if we have a static display + }; // Disable Popper if we have a static display or Dropdown is in Navbar + + if (this._inNavbar || this._config.display === 'static') { + Manipulator.setDataAttribute(this._menu, 'popper', 'static'); // todo:v6 remove - if (this._config.display === 'static') { defaultBsPopperConfig.modifiers = [{ name: 'applyStyles', enabled: false @@ -2259,7 +2296,7 @@ key, target }) { - const items = SelectorEngine.find(SELECTOR_VISIBLE_ITEMS, this._menu).filter(isVisible); + const items = SelectorEngine.find(SELECTOR_VISIBLE_ITEMS, this._menu).filter(element => isVisible(element)); if (!items.length) { return; @@ -2267,7 +2304,7 @@ // allow cycling to get the last item in case key equals ARROW_UP_KEY - getNextActiveElement(items, target, key === ARROW_DOWN_KEY, !items.includes(target)).focus(); + getNextActiveElement(items, target, key === ARROW_DOWN_KEY$1, !items.includes(target)).focus(); } // Static @@ -2288,20 +2325,28 @@ } static clearMenus(event) { - if (event && (event.button === RIGHT_MOUSE_BUTTON || event.type === 'keyup' && event.key !== TAB_KEY$1)) { + if (event.button === RIGHT_MOUSE_BUTTON || event.type === 'keyup' && event.key !== TAB_KEY$1) { return; } - const toggles = SelectorEngine.find(SELECTOR_DATA_TOGGLE$3); + const openToggles = SelectorEngine.find(SELECTOR_DATA_TOGGLE_SHOWN); - for (let i = 0, len = toggles.length; i < len; i++) { - const context = Dropdown.getInstance(toggles[i]); + for (const toggle of openToggles) { + const context = Dropdown.getInstance(toggle); if (!context || context._config.autoClose === false) { continue; } - if (!context._isShown()) { + 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$1 || /input|select|option|textarea|form/i.test(event.target.tagName))) { continue; } @@ -2309,85 +2354,53 @@ relatedTarget: context._element }; - if (event) { - 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$1 || /input|select|option|textarea|form/i.test(event.target.tagName))) { - continue; - } - - if (event.type === 'click') { - relatedTarget.clickEvent = event; - } + if (event.type === 'click') { + relatedTarget.clickEvent = event; } context._completeHide(relatedTarget); } } - static getParentFromElement(element) { - return getElementFromSelector(element) || element.parentNode; - } - 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.key === SPACE_KEY || event.key !== ESCAPE_KEY$2 && (event.key !== ARROW_DOWN_KEY && event.key !== ARROW_UP_KEY || event.target.closest(SELECTOR_MENU)) : !REGEXP_KEYDOWN.test(event.key)) { - return; - } + // 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$2; + const isUpOrDownEvent = [ARROW_UP_KEY$1, ARROW_DOWN_KEY$1].includes(event.key); - const isActive = this.classList.contains(CLASS_NAME_SHOW$6); - - if (!isActive && event.key === ESCAPE_KEY$2) { + if (!isUpOrDownEvent && !isEscapeEvent) { return; } - event.preventDefault(); - event.stopPropagation(); - - if (isDisabled(this)) { + if (isInput && !isEscapeEvent) { return; } - const getToggleButton = this.matches(SELECTOR_DATA_TOGGLE$3) ? this : SelectorEngine.prev(this, SELECTOR_DATA_TOGGLE$3)[0]; + event.preventDefault(); + const getToggleButton = SelectorEngine.findOne(SELECTOR_DATA_TOGGLE$3, event.delegateTarget.parentNode); const instance = Dropdown.getOrCreateInstance(getToggleButton); - if (event.key === ESCAPE_KEY$2) { - instance.hide(); - return; - } - - if (event.key === ARROW_UP_KEY || event.key === ARROW_DOWN_KEY) { - if (!isActive) { - instance.show(); - } + if (isUpOrDownEvent) { + event.stopPropagation(); + instance.show(); instance._selectMenuItem(event); return; } - if (!isActive || event.key === SPACE_KEY) { - Dropdown.clearMenus(); + if (instance._isShown()) { + // else is escape and we check if it is shown + event.stopPropagation(); + instance.hide(); + getToggleButton.focus(); } } } /** - * ------------------------------------------------------------------------ - * Data Api implementation - * ------------------------------------------------------------------------ + * Data API implementation */ @@ -2400,27 +2413,34 @@ Dropdown.getOrCreateInstance(this).toggle(); }); /** - * ------------------------------------------------------------------------ * jQuery - * ------------------------------------------------------------------------ - * add .Dropdown to jQuery only if jQuery is present */ defineJQueryPlugin(Dropdown); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): util/scrollBar.js + * Bootstrap (v5.2.0): util/scrollBar.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ + /** + * Constants + */ + const SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top'; const SELECTOR_STICKY_CONTENT = '.sticky-top'; + const PROPERTY_PADDING = 'padding-right'; + const PROPERTY_MARGIN = 'margin-right'; + /** + * Class definition + */ class ScrollBarHelper { constructor() { this._element = document.body; - } + } // Public + getWidth() { // https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes @@ -2434,21 +2454,36 @@ this._disableOverFlow(); // give padding to element to balance the hidden scrollbar width - this._setElementAttributes(this._element, 'paddingRight', calculatedValue => calculatedValue + width); // trick: We adjust positive paddingRight and negative marginRight to sticky-top elements to keep showing fullwidth + this._setElementAttributes(this._element, PROPERTY_PADDING, calculatedValue => calculatedValue + width); // trick: We adjust positive paddingRight and negative marginRight to sticky-top elements to keep showing fullwidth - this._setElementAttributes(SELECTOR_FIXED_CONTENT, 'paddingRight', calculatedValue => calculatedValue + width); + this._setElementAttributes(SELECTOR_FIXED_CONTENT, PROPERTY_PADDING, calculatedValue => calculatedValue + width); - this._setElementAttributes(SELECTOR_STICKY_CONTENT, 'marginRight', calculatedValue => calculatedValue - width); + this._setElementAttributes(SELECTOR_STICKY_CONTENT, PROPERTY_MARGIN, calculatedValue => calculatedValue - width); } + reset() { + this._resetElementAttributes(this._element, 'overflow'); + + this._resetElementAttributes(this._element, PROPERTY_PADDING); + + this._resetElementAttributes(SELECTOR_FIXED_CONTENT, PROPERTY_PADDING); + + this._resetElementAttributes(SELECTOR_STICKY_CONTENT, PROPERTY_MARGIN); + } + + isOverflowing() { + return this.getWidth() > 0; + } // Private + + _disableOverFlow() { this._saveInitialAttribute(this._element, 'overflow'); this._element.style.overflow = 'hidden'; } - _setElementAttributes(selector, styleProp, callback) { + _setElementAttributes(selector, styleProperty, callback) { const scrollbarWidth = this.getWidth(); const manipulationCallBack = element => { @@ -2456,43 +2491,34 @@ return; } - this._saveInitialAttribute(element, styleProp); + this._saveInitialAttribute(element, styleProperty); - const calculatedValue = window.getComputedStyle(element)[styleProp]; - element.style[styleProp] = `${callback(Number.parseFloat(calculatedValue))}px`; + const calculatedValue = window.getComputedStyle(element).getPropertyValue(styleProperty); + element.style.setProperty(styleProperty, `${callback(Number.parseFloat(calculatedValue))}px`); }; this._applyManipulationCallback(selector, manipulationCallBack); } - reset() { - this._resetElementAttributes(this._element, 'overflow'); - - this._resetElementAttributes(this._element, 'paddingRight'); - - this._resetElementAttributes(SELECTOR_FIXED_CONTENT, 'paddingRight'); - - this._resetElementAttributes(SELECTOR_STICKY_CONTENT, 'marginRight'); - } - - _saveInitialAttribute(element, styleProp) { - const actualValue = element.style[styleProp]; + _saveInitialAttribute(element, styleProperty) { + const actualValue = element.style.getPropertyValue(styleProperty); if (actualValue) { - Manipulator.setDataAttribute(element, styleProp, actualValue); + Manipulator.setDataAttribute(element, styleProperty, actualValue); } } - _resetElementAttributes(selector, styleProp) { + _resetElementAttributes(selector, styleProperty) { const manipulationCallBack = element => { - const value = Manipulator.getDataAttribute(element, styleProp); + const value = Manipulator.getDataAttribute(element, styleProperty); // We only want to remove the property if the value is `null`; the value can also be zero - if (typeof value === 'undefined') { - element.style.removeProperty(styleProp); - } else { - Manipulator.removeDataAttribute(element, styleProp); - element.style[styleProp] = value; + if (value === null) { + element.style.removeProperty(styleProperty); + return; } + + Manipulator.removeDataAttribute(element, styleProperty); + element.style.setProperty(styleProperty, value); }; this._applyManipulationCallback(selector, manipulationCallBack); @@ -2501,51 +2527,72 @@ _applyManipulationCallback(selector, callBack) { if (isElement(selector)) { callBack(selector); - } else { - SelectorEngine.find(selector, this._element).forEach(callBack); + return; } - } - isOverflowing() { - return this.getWidth() > 0; + for (const sel of SelectorEngine.find(selector, this._element)) { + callBack(sel); + } } } /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): util/backdrop.js + * Bootstrap (v5.2.0): util/backdrop.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ - const Default$7 = { + /** + * Constants + */ + + const NAME$9 = 'backdrop'; + const CLASS_NAME_FADE$4 = 'fade'; + const CLASS_NAME_SHOW$5 = 'show'; + const EVENT_MOUSEDOWN = `mousedown.bs.${NAME$9}`; + const Default$8 = { className: 'modal-backdrop', + clickCallback: null, + isAnimated: false, isVisible: true, // if false, we use the backdrop helper without adding any element to the dom - isAnimated: false, - rootElement: 'body', - // give the choice to place backdrop under different elements - clickCallback: null + rootElement: 'body' // give the choice to place backdrop under different elements + }; - const DefaultType$7 = { + const DefaultType$8 = { className: 'string', - isVisible: 'boolean', + clickCallback: '(function|null)', isAnimated: 'boolean', - rootElement: '(element|string)', - clickCallback: '(function|null)' + isVisible: 'boolean', + rootElement: '(element|string)' }; - const NAME$8 = 'backdrop'; - const CLASS_NAME_FADE$4 = 'fade'; - const CLASS_NAME_SHOW$5 = 'show'; - const EVENT_MOUSEDOWN = `mousedown.bs.${NAME$8}`; + /** + * Class definition + */ - class Backdrop { + class Backdrop extends Config { constructor(config) { + super(); this._config = this._getConfig(config); this._isAppended = false; this._element = null; + } // Getters + + + static get Default() { + return Default$8; } + static get DefaultType() { + return DefaultType$8; + } + + static get NAME() { + return NAME$9; + } // Public + + show(callback) { if (!this._config.isVisible) { execute(callback); @@ -2554,11 +2601,13 @@ this._append(); + const element = this._getElement(); + if (this._config.isAnimated) { - reflow(this._getElement()); + reflow(element); } - this._getElement().classList.add(CLASS_NAME_SHOW$5); + element.classList.add(CLASS_NAME_SHOW$5); this._emulateAnimation(() => { execute(callback); @@ -2577,6 +2626,18 @@ this.dispose(); execute(callback); }); + } + + dispose() { + if (!this._isAppended) { + return; + } + + EventHandler.off(this._element, EVENT_MOUSEDOWN); + + this._element.remove(); + + this._isAppended = false; } // Private @@ -2595,13 +2656,9 @@ return this._element; } - _getConfig(config) { - config = { ...Default$7, - ...(typeof config === 'object' ? config : {}) - }; // use getElement() with the default "body" to get a fresh Element on each instantiation - + _configAfterMerge(config) { + // use getElement() with the default "body" to get a fresh Element on each instantiation config.rootElement = getElement(config.rootElement); - typeCheckConfig(NAME$8, config, DefaultType$7); return config; } @@ -2610,26 +2667,16 @@ return; } - this._config.rootElement.append(this._getElement()); + const element = this._getElement(); - EventHandler.on(this._getElement(), EVENT_MOUSEDOWN, () => { + this._config.rootElement.append(element); + + EventHandler.on(element, EVENT_MOUSEDOWN, () => { execute(this._config.clickCallback); }); this._isAppended = true; } - dispose() { - if (!this._isAppended) { - return; - } - - EventHandler.off(this._element, EVENT_MOUSEDOWN); - - this._element.remove(); - - this._isAppended = false; - } - _emulateAnimation(callback) { executeAfterTransition(callback, this._getElement(), this._config.isAnimated); } @@ -2638,52 +2685,69 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): util/focustrap.js + * Bootstrap (v5.2.0): util/focustrap.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ - const Default$6 = { - trapElement: null, - // The element to trap focus inside of - autofocus: true - }; - const DefaultType$6 = { - trapElement: 'element', - autofocus: 'boolean' - }; - const NAME$7 = 'focustrap'; - const DATA_KEY$7 = 'bs.focustrap'; - const EVENT_KEY$7 = `.${DATA_KEY$7}`; - const EVENT_FOCUSIN$1 = `focusin${EVENT_KEY$7}`; - const EVENT_KEYDOWN_TAB = `keydown.tab${EVENT_KEY$7}`; + /** + * Constants + */ + + const NAME$8 = 'focustrap'; + const DATA_KEY$5 = 'bs.focustrap'; + const EVENT_KEY$5 = `.${DATA_KEY$5}`; + const EVENT_FOCUSIN$2 = `focusin${EVENT_KEY$5}`; + const EVENT_KEYDOWN_TAB = `keydown.tab${EVENT_KEY$5}`; const TAB_KEY = 'Tab'; const TAB_NAV_FORWARD = 'forward'; const TAB_NAV_BACKWARD = 'backward'; + const Default$7 = { + autofocus: true, + trapElement: null // The element to trap focus inside of - class FocusTrap { + }; + const DefaultType$7 = { + autofocus: 'boolean', + trapElement: 'element' + }; + /** + * Class definition + */ + + class FocusTrap extends Config { constructor(config) { + super(); this._config = this._getConfig(config); this._isActive = false; this._lastTabNavDirection = null; + } // Getters + + + static get Default() { + return Default$7; } - activate() { - const { - trapElement, - autofocus - } = this._config; + static get DefaultType() { + return DefaultType$7; + } + static get NAME() { + return NAME$8; + } // Public + + + activate() { if (this._isActive) { return; } - if (autofocus) { - trapElement.focus(); + if (this._config.autofocus) { + this._config.trapElement.focus(); } - EventHandler.off(document, EVENT_KEY$7); // guard against infinite focus loop + EventHandler.off(document, EVENT_KEY$5); // guard against infinite focus loop - EventHandler.on(document, EVENT_FOCUSIN$1, event => this._handleFocusin(event)); + EventHandler.on(document, EVENT_FOCUSIN$2, event => this._handleFocusin(event)); EventHandler.on(document, EVENT_KEYDOWN_TAB, event => this._handleKeydown(event)); this._isActive = true; } @@ -2694,19 +2758,16 @@ } this._isActive = false; - EventHandler.off(document, EVENT_KEY$7); + EventHandler.off(document, EVENT_KEY$5); } // Private _handleFocusin(event) { const { - target - } = event; - const { trapElement } = this._config; - if (target === document || target === trapElement || trapElement.contains(target)) { + if (event.target === document || event.target === trapElement || trapElement.contains(event.target)) { return; } @@ -2729,54 +2790,32 @@ this._lastTabNavDirection = event.shiftKey ? TAB_NAV_BACKWARD : TAB_NAV_FORWARD; } - _getConfig(config) { - config = { ...Default$6, - ...(typeof config === 'object' ? config : {}) - }; - typeCheckConfig(NAME$7, config, DefaultType$6); - return config; - } - } /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): modal.js + * Bootstrap (v5.2.0): modal.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** - * ------------------------------------------------------------------------ * Constants - * ------------------------------------------------------------------------ */ - const NAME$6 = 'modal'; - const DATA_KEY$6 = 'bs.modal'; - const EVENT_KEY$6 = `.${DATA_KEY$6}`; - const DATA_API_KEY$3 = '.data-api'; + const NAME$7 = 'modal'; + const DATA_KEY$4 = 'bs.modal'; + const EVENT_KEY$4 = `.${DATA_KEY$4}`; + const DATA_API_KEY$2 = '.data-api'; const ESCAPE_KEY$1 = 'Escape'; - const Default$5 = { - backdrop: true, - keyboard: true, - focus: true - }; - const DefaultType$5 = { - backdrop: '(boolean|string)', - keyboard: 'boolean', - focus: 'boolean' - }; - const EVENT_HIDE$3 = `hide${EVENT_KEY$6}`; - const EVENT_HIDE_PREVENTED = `hidePrevented${EVENT_KEY$6}`; - const EVENT_HIDDEN$3 = `hidden${EVENT_KEY$6}`; - const EVENT_SHOW$3 = `show${EVENT_KEY$6}`; - const EVENT_SHOWN$3 = `shown${EVENT_KEY$6}`; - const EVENT_RESIZE = `resize${EVENT_KEY$6}`; - const EVENT_CLICK_DISMISS = `click.dismiss${EVENT_KEY$6}`; - const EVENT_KEYDOWN_DISMISS$1 = `keydown.dismiss${EVENT_KEY$6}`; - const EVENT_MOUSEUP_DISMISS = `mouseup.dismiss${EVENT_KEY$6}`; - const EVENT_MOUSEDOWN_DISMISS = `mousedown.dismiss${EVENT_KEY$6}`; - const EVENT_CLICK_DATA_API$2 = `click${EVENT_KEY$6}${DATA_API_KEY$3}`; + const EVENT_HIDE$4 = `hide${EVENT_KEY$4}`; + const EVENT_HIDE_PREVENTED$1 = `hidePrevented${EVENT_KEY$4}`; + const EVENT_HIDDEN$4 = `hidden${EVENT_KEY$4}`; + const EVENT_SHOW$4 = `show${EVENT_KEY$4}`; + const EVENT_SHOWN$4 = `shown${EVENT_KEY$4}`; + const EVENT_RESIZE$1 = `resize${EVENT_KEY$4}`; + const EVENT_MOUSEDOWN_DISMISS = `mousedown.dismiss${EVENT_KEY$4}`; + const EVENT_KEYDOWN_DISMISS$1 = `keydown.dismiss${EVENT_KEY$4}`; + const EVENT_CLICK_DATA_API$2 = `click${EVENT_KEY$4}${DATA_API_KEY$2}`; const CLASS_NAME_OPEN = 'modal-open'; const CLASS_NAME_FADE$3 = 'fade'; const CLASS_NAME_SHOW$4 = 'show'; @@ -2785,32 +2824,44 @@ const SELECTOR_DIALOG = '.modal-dialog'; const SELECTOR_MODAL_BODY = '.modal-body'; const SELECTOR_DATA_TOGGLE$2 = '[data-bs-toggle="modal"]'; + const Default$6 = { + backdrop: true, + focus: true, + keyboard: true + }; + const DefaultType$6 = { + backdrop: '(boolean|string)', + focus: 'boolean', + keyboard: 'boolean' + }; /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ + * Class definition */ class Modal extends BaseComponent { constructor(element, config) { - super(element); - this._config = this._getConfig(config); + super(element, config); this._dialog = SelectorEngine.findOne(SELECTOR_DIALOG, this._element); this._backdrop = this._initializeBackDrop(); this._focustrap = this._initializeFocusTrap(); this._isShown = false; - this._ignoreBackdropClick = false; this._isTransitioning = false; this._scrollBar = new ScrollBarHelper(); + + this._addEventListeners(); } // Getters static get Default() { - return Default$5; + return Default$6; + } + + static get DefaultType() { + return DefaultType$6; } static get NAME() { - return NAME$6; + return NAME$7; } // Public @@ -2823,7 +2874,7 @@ return; } - const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$3, { + const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$4, { relatedTarget }); @@ -2832,10 +2883,7 @@ } this._isShown = true; - - if (this._isAnimated()) { - this._isTransitioning = true; - } + this._isTransitioning = true; this._scrollBar.hide(); @@ -2843,19 +2891,7 @@ this._adjustDialog(); - this._setEscapeEvent(); - - this._setResizeEvent(); - - EventHandler.on(this._dialog, EVENT_MOUSEDOWN_DISMISS, () => { - EventHandler.one(this._element, EVENT_MOUSEUP_DISMISS, event => { - if (event.target === this._element) { - this._ignoreBackdropClick = true; - } - }); - }); - - this._showBackdrop(() => this._showElement(relatedTarget)); + this._backdrop.show(() => this._showElement(relatedTarget)); } hide() { @@ -2863,36 +2899,26 @@ return; } - const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$3); + const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$4); if (hideEvent.defaultPrevented) { return; } this._isShown = false; - - const isAnimated = this._isAnimated(); - - if (isAnimated) { - this._isTransitioning = true; - } - - this._setEscapeEvent(); - - this._setResizeEvent(); + this._isTransitioning = true; this._focustrap.deactivate(); this._element.classList.remove(CLASS_NAME_SHOW$4); - EventHandler.off(this._element, EVENT_CLICK_DISMISS); - EventHandler.off(this._dialog, EVENT_MOUSEDOWN_DISMISS); - - this._queueCallback(() => this._hideModal(), this._element, isAnimated); + this._queueCallback(() => this._hideModal(), this._element, this._isAnimated()); } dispose() { - [window, this._dialog].forEach(htmlElement => EventHandler.off(htmlElement, EVENT_KEY$6)); + for (const htmlElement of [window, this._dialog]) { + EventHandler.off(htmlElement, EVENT_KEY$4); + } this._backdrop.dispose(); @@ -2909,7 +2935,7 @@ _initializeBackDrop() { return new Backdrop({ isVisible: Boolean(this._config.backdrop), - // 'static' option will be translated to true, and booleans will keep their value + // 'static' option will be translated to true, and booleans will keep their value, isAnimated: this._isAnimated() }); } @@ -2920,22 +2946,9 @@ }); } - _getConfig(config) { - config = { ...Default$5, - ...Manipulator.getDataAttributes(this._element), - ...(typeof config === 'object' ? config : {}) - }; - typeCheckConfig(NAME$6, config, DefaultType$5); - return config; - } - _showElement(relatedTarget) { - const isAnimated = this._isAnimated(); - - const modalBody = SelectorEngine.findOne(SELECTOR_MODAL_BODY, this._dialog); - - if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) { - // Don't move modal's DOM position + // try to append dynamic modal + if (!document.body.contains(this._element)) { document.body.append(this._element); } @@ -2948,14 +2961,13 @@ this._element.setAttribute('role', 'dialog'); this._element.scrollTop = 0; + const modalBody = SelectorEngine.findOne(SELECTOR_MODAL_BODY, this._dialog); if (modalBody) { modalBody.scrollTop = 0; } - if (isAnimated) { - reflow(this._element); - } + reflow(this._element); this._element.classList.add(CLASS_NAME_SHOW$4); @@ -2965,35 +2977,49 @@ } this._isTransitioning = false; - EventHandler.trigger(this._element, EVENT_SHOWN$3, { + EventHandler.trigger(this._element, EVENT_SHOWN$4, { relatedTarget }); }; - this._queueCallback(transitionComplete, this._dialog, isAnimated); + this._queueCallback(transitionComplete, this._dialog, this._isAnimated()); } - _setEscapeEvent() { - if (this._isShown) { - EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS$1, event => { - if (this._config.keyboard && event.key === ESCAPE_KEY$1) { - event.preventDefault(); - this.hide(); - } else if (!this._config.keyboard && event.key === ESCAPE_KEY$1) { - this._triggerBackdropTransition(); - } - }); - } else { - EventHandler.off(this._element, EVENT_KEYDOWN_DISMISS$1); - } - } + _addEventListeners() { + EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS$1, event => { + if (event.key !== ESCAPE_KEY$1) { + return; + } - _setResizeEvent() { - if (this._isShown) { - EventHandler.on(window, EVENT_RESIZE, () => this._adjustDialog()); - } else { - EventHandler.off(window, EVENT_RESIZE); - } + if (this._config.keyboard) { + event.preventDefault(); + this.hide(); + return; + } + + this._triggerBackdropTransition(); + }); + EventHandler.on(window, EVENT_RESIZE$1, () => { + if (this._isShown && !this._isTransitioning) { + this._adjustDialog(); + } + }); + EventHandler.on(this._element, EVENT_MOUSEDOWN_DISMISS, event => { + if (event.target !== event.currentTarget) { + // click is inside modal-dialog + return; + } + + if (this._config.backdrop === 'static') { + this._triggerBackdropTransition(); + + return; + } + + if (this._config.backdrop) { + this.hide(); + } + }); } _hideModal() { @@ -3014,73 +3040,47 @@ this._scrollBar.reset(); - EventHandler.trigger(this._element, EVENT_HIDDEN$3); + EventHandler.trigger(this._element, EVENT_HIDDEN$4); }); } - _showBackdrop(callback) { - EventHandler.on(this._element, EVENT_CLICK_DISMISS, event => { - if (this._ignoreBackdropClick) { - this._ignoreBackdropClick = false; - return; - } - - if (event.target !== event.currentTarget) { - return; - } - - if (this._config.backdrop === true) { - this.hide(); - } else if (this._config.backdrop === 'static') { - this._triggerBackdropTransition(); - } - }); - - this._backdrop.show(callback); - } - _isAnimated() { return this._element.classList.contains(CLASS_NAME_FADE$3); } _triggerBackdropTransition() { - const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED); + const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED$1); if (hideEvent.defaultPrevented) { return; } - const { - classList, - scrollHeight, - style - } = this._element; - const isModalOverflowing = scrollHeight > document.documentElement.clientHeight; // return if the following background transition hasn't yet completed + const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight; + const initialOverflowY = this._element.style.overflowY; // return if the following background transition hasn't yet completed - if (!isModalOverflowing && style.overflowY === 'hidden' || classList.contains(CLASS_NAME_STATIC)) { + if (initialOverflowY === 'hidden' || this._element.classList.contains(CLASS_NAME_STATIC)) { return; } if (!isModalOverflowing) { - style.overflowY = 'hidden'; + this._element.style.overflowY = 'hidden'; } - classList.add(CLASS_NAME_STATIC); + this._element.classList.add(CLASS_NAME_STATIC); this._queueCallback(() => { - classList.remove(CLASS_NAME_STATIC); + this._element.classList.remove(CLASS_NAME_STATIC); - if (!isModalOverflowing) { - this._queueCallback(() => { - style.overflowY = ''; - }, this._dialog); - } + this._queueCallback(() => { + this._element.style.overflowY = initialOverflowY; + }, this._dialog); }, this._dialog); this._element.focus(); - } // ---------------------------------------------------------------------- - // the following methods are used to handle overflowing modals - // ---------------------------------------------------------------------- + } + /** + * The following methods are used to handle overflowing modals + */ _adjustDialog() { @@ -3090,12 +3090,14 @@ const isBodyOverflowing = scrollbarWidth > 0; - if (!isBodyOverflowing && isModalOverflowing && !isRTL() || isBodyOverflowing && !isModalOverflowing && isRTL()) { - this._element.style.paddingLeft = `${scrollbarWidth}px`; + if (isBodyOverflowing && !isModalOverflowing) { + const property = isRTL() ? 'paddingLeft' : 'paddingRight'; + this._element.style[property] = `${scrollbarWidth}px`; } - if (isBodyOverflowing && !isModalOverflowing && !isRTL() || !isBodyOverflowing && isModalOverflowing && isRTL()) { - this._element.style.paddingRight = `${scrollbarWidth}px`; + if (!isBodyOverflowing && isModalOverflowing) { + const property = isRTL() ? 'paddingRight' : 'paddingLeft'; + this._element.style[property] = `${scrollbarWidth}px`; } } @@ -3123,9 +3125,7 @@ } /** - * ------------------------------------------------------------------------ - * Data Api implementation - * ------------------------------------------------------------------------ + * Data API implementation */ @@ -3136,23 +3136,23 @@ event.preventDefault(); } - EventHandler.one(target, EVENT_SHOW$3, showEvent => { + EventHandler.one(target, EVENT_SHOW$4, showEvent => { if (showEvent.defaultPrevented) { // only register focus restorer if modal will actually get shown return; } - EventHandler.one(target, EVENT_HIDDEN$3, () => { + EventHandler.one(target, EVENT_HIDDEN$4, () => { if (isVisible(this)) { this.focus(); } }); - }); // avoid conflict when clicking moddal toggler while another one is open + }); // avoid conflict when clicking modal toggler while another one is open - const allReadyOpen = SelectorEngine.findOne(OPEN_SELECTOR$1); + const alreadyOpen = SelectorEngine.findOne(OPEN_SELECTOR$1); - if (allReadyOpen) { - Modal.getInstance(allReadyOpen).hide(); + if (alreadyOpen) { + Modal.getInstance(alreadyOpen).hide(); } const data = Modal.getOrCreateInstance(target); @@ -3160,62 +3160,58 @@ }); enableDismissTrigger(Modal); /** - * ------------------------------------------------------------------------ * jQuery - * ------------------------------------------------------------------------ - * add .Modal to jQuery only if jQuery is present */ defineJQueryPlugin(Modal); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): offcanvas.js + * Bootstrap (v5.2.0): offcanvas.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** - * ------------------------------------------------------------------------ * Constants - * ------------------------------------------------------------------------ */ - const NAME$5 = 'offcanvas'; - const DATA_KEY$5 = 'bs.offcanvas'; - const EVENT_KEY$5 = `.${DATA_KEY$5}`; - const DATA_API_KEY$2 = '.data-api'; - const EVENT_LOAD_DATA_API$1 = `load${EVENT_KEY$5}${DATA_API_KEY$2}`; + const NAME$6 = 'offcanvas'; + const DATA_KEY$3 = 'bs.offcanvas'; + const EVENT_KEY$3 = `.${DATA_KEY$3}`; + const DATA_API_KEY$1 = '.data-api'; + const EVENT_LOAD_DATA_API$2 = `load${EVENT_KEY$3}${DATA_API_KEY$1}`; const ESCAPE_KEY = 'Escape'; - const Default$4 = { + const CLASS_NAME_SHOW$3 = 'show'; + const CLASS_NAME_SHOWING$1 = 'showing'; + const CLASS_NAME_HIDING = 'hiding'; + const CLASS_NAME_BACKDROP = 'offcanvas-backdrop'; + const OPEN_SELECTOR = '.offcanvas.show'; + const EVENT_SHOW$3 = `show${EVENT_KEY$3}`; + const EVENT_SHOWN$3 = `shown${EVENT_KEY$3}`; + const EVENT_HIDE$3 = `hide${EVENT_KEY$3}`; + const EVENT_HIDE_PREVENTED = `hidePrevented${EVENT_KEY$3}`; + const EVENT_HIDDEN$3 = `hidden${EVENT_KEY$3}`; + const EVENT_RESIZE = `resize${EVENT_KEY$3}`; + const EVENT_CLICK_DATA_API$1 = `click${EVENT_KEY$3}${DATA_API_KEY$1}`; + const EVENT_KEYDOWN_DISMISS = `keydown.dismiss${EVENT_KEY$3}`; + const SELECTOR_DATA_TOGGLE$1 = '[data-bs-toggle="offcanvas"]'; + const Default$5 = { backdrop: true, keyboard: true, scroll: false }; - const DefaultType$4 = { - backdrop: 'boolean', + const DefaultType$5 = { + backdrop: '(boolean|string)', keyboard: 'boolean', scroll: 'boolean' }; - const CLASS_NAME_SHOW$3 = 'show'; - const CLASS_NAME_BACKDROP = 'offcanvas-backdrop'; - const OPEN_SELECTOR = '.offcanvas.show'; - const EVENT_SHOW$2 = `show${EVENT_KEY$5}`; - const EVENT_SHOWN$2 = `shown${EVENT_KEY$5}`; - const EVENT_HIDE$2 = `hide${EVENT_KEY$5}`; - const EVENT_HIDDEN$2 = `hidden${EVENT_KEY$5}`; - const EVENT_CLICK_DATA_API$1 = `click${EVENT_KEY$5}${DATA_API_KEY$2}`; - const EVENT_KEYDOWN_DISMISS = `keydown.dismiss${EVENT_KEY$5}`; - const SELECTOR_DATA_TOGGLE$1 = '[data-bs-toggle="offcanvas"]'; /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ + * Class definition */ class Offcanvas extends BaseComponent { constructor(element, config) { - super(element); - this._config = this._getConfig(config); + super(element, config); this._isShown = false; this._backdrop = this._initializeBackDrop(); this._focustrap = this._initializeFocusTrap(); @@ -3224,12 +3220,16 @@ } // Getters - static get NAME() { - return NAME$5; + static get Default() { + return Default$5; } - static get Default() { - return Default$4; + static get DefaultType() { + return DefaultType$5; + } + + static get NAME() { + return NAME$6; } // Public @@ -3242,7 +3242,7 @@ return; } - const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$2, { + const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$3, { relatedTarget }); @@ -3251,7 +3251,6 @@ } this._isShown = true; - this._element.style.visibility = 'visible'; this._backdrop.show(); @@ -3259,20 +3258,22 @@ new ScrollBarHelper().hide(); } - this._element.removeAttribute('aria-hidden'); - this._element.setAttribute('aria-modal', true); this._element.setAttribute('role', 'dialog'); - this._element.classList.add(CLASS_NAME_SHOW$3); + this._element.classList.add(CLASS_NAME_SHOWING$1); const completeCallBack = () => { - if (!this._config.scroll) { + if (!this._config.scroll || this._config.backdrop) { this._focustrap.activate(); } - EventHandler.trigger(this._element, EVENT_SHOWN$2, { + this._element.classList.add(CLASS_NAME_SHOW$3); + + this._element.classList.remove(CLASS_NAME_SHOWING$1); + + EventHandler.trigger(this._element, EVENT_SHOWN$3, { relatedTarget }); }; @@ -3285,7 +3286,7 @@ return; } - const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$2); + const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE$3); if (hideEvent.defaultPrevented) { return; @@ -3297,24 +3298,22 @@ this._isShown = false; - this._element.classList.remove(CLASS_NAME_SHOW$3); + this._element.classList.add(CLASS_NAME_HIDING); this._backdrop.hide(); const completeCallback = () => { - this._element.setAttribute('aria-hidden', true); + this._element.classList.remove(CLASS_NAME_SHOW$3, CLASS_NAME_HIDING); this._element.removeAttribute('aria-modal'); this._element.removeAttribute('role'); - this._element.style.visibility = 'hidden'; - if (!this._config.scroll) { new ScrollBarHelper().reset(); } - EventHandler.trigger(this._element, EVENT_HIDDEN$2); + EventHandler.trigger(this._element, EVENT_HIDDEN$3); }; this._queueCallback(completeCallback, this._element, true); @@ -3329,22 +3328,24 @@ } // Private - _getConfig(config) { - config = { ...Default$4, - ...Manipulator.getDataAttributes(this._element), - ...(typeof config === 'object' ? config : {}) - }; - typeCheckConfig(NAME$5, config, DefaultType$4); - return config; - } - _initializeBackDrop() { + const clickCallback = () => { + if (this._config.backdrop === 'static') { + EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED); + return; + } + + this.hide(); + }; // 'static' option will be translated to true, and booleans will keep their value + + + const isVisible = Boolean(this._config.backdrop); return new Backdrop({ className: CLASS_NAME_BACKDROP, - isVisible: this._config.backdrop, + isVisible, isAnimated: true, rootElement: this._element.parentNode, - clickCallback: () => this.hide() + clickCallback: isVisible ? clickCallback : null }); } @@ -3356,9 +3357,16 @@ _addEventListeners() { EventHandler.on(this._element, EVENT_KEYDOWN_DISMISS, event => { - if (this._config.keyboard && event.key === ESCAPE_KEY) { - this.hide(); + if (event.key !== ESCAPE_KEY) { + return; + } + + if (!this._config.keyboard) { + EventHandler.trigger(this._element, EVENT_HIDE_PREVENTED); + return; } + + this.hide(); }); } // Static @@ -3381,9 +3389,7 @@ } /** - * ------------------------------------------------------------------------ - * Data Api implementation - * ------------------------------------------------------------------------ + * Data API implementation */ @@ -3398,35 +3404,44 @@ return; } - EventHandler.one(target, EVENT_HIDDEN$2, () => { + EventHandler.one(target, EVENT_HIDDEN$3, () => { // focus on trigger when it is closed if (isVisible(this)) { this.focus(); } }); // avoid conflict when clicking a toggler of an offcanvas, while another is open - const allReadyOpen = SelectorEngine.findOne(OPEN_SELECTOR); + const alreadyOpen = SelectorEngine.findOne(OPEN_SELECTOR); - if (allReadyOpen && allReadyOpen !== target) { - Offcanvas.getInstance(allReadyOpen).hide(); + if (alreadyOpen && alreadyOpen !== target) { + Offcanvas.getInstance(alreadyOpen).hide(); } const data = Offcanvas.getOrCreateInstance(target); data.toggle(this); }); - EventHandler.on(window, EVENT_LOAD_DATA_API$1, () => SelectorEngine.find(OPEN_SELECTOR).forEach(el => Offcanvas.getOrCreateInstance(el).show())); + EventHandler.on(window, EVENT_LOAD_DATA_API$2, () => { + for (const selector of SelectorEngine.find(OPEN_SELECTOR)) { + Offcanvas.getOrCreateInstance(selector).show(); + } + }); + EventHandler.on(window, EVENT_RESIZE, () => { + for (const element of SelectorEngine.find('[aria-modal][class*=show][class*=offcanvas-]')) { + if (getComputedStyle(element).position !== 'fixed') { + Offcanvas.getOrCreateInstance(element).hide(); + } + } + }); enableDismissTrigger(Offcanvas); /** - * ------------------------------------------------------------------------ * jQuery - * ------------------------------------------------------------------------ */ defineJQueryPlugin(Offcanvas); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): util/sanitizer.js + * Bootstrap (v5.2.0): util/sanitizer.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ @@ -3435,14 +3450,14 @@ /** * A pattern that recognizes a commonly useful subset of URLs that are safe. * - * Shoutout to Angular https://github.com/angular/angular/blob/12.2.x/packages/core/src/sanitization/url_sanitizer.ts + * Shout-out to Angular https://github.com/angular/angular/blob/12.2.x/packages/core/src/sanitization/url_sanitizer.ts */ const SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file|sms):|[^#&/:?]*(?:[#/?]|$))/i; /** * A pattern that matches safe data URLs. Only matches image, video and audio types. * - * Shoutout to Angular https://github.com/angular/angular/blob/12.2.x/packages/core/src/sanitization/url_sanitizer.ts + * Shout-out to Angular https://github.com/angular/angular/blob/12.2.x/packages/core/src/sanitization/url_sanitizer.ts */ const DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[\d+/a-z]+=*$/i; @@ -3456,17 +3471,10 @@ } return true; - } + } // Check if a regular expression validates the attribute. - const regExp = allowedAttributeList.filter(attributeRegex => attributeRegex instanceof RegExp); // Check if a regular expression validates the attribute. - - for (let i = 0, len = regExp.length; i < len; i++) { - if (regExp[i].test(attributeName)) { - return true; - } - } - return false; + return allowedAttributeList.filter(attributeRegex => attributeRegex instanceof RegExp).some(regex => regex.test(attributeName)); }; const DefaultAllowlist = { @@ -3502,21 +3510,20 @@ u: [], ul: [] }; - function sanitizeHtml(unsafeHtml, allowList, sanitizeFn) { + function sanitizeHtml(unsafeHtml, allowList, sanitizeFunction) { if (!unsafeHtml.length) { return unsafeHtml; } - if (sanitizeFn && typeof sanitizeFn === 'function') { - return sanitizeFn(unsafeHtml); + if (sanitizeFunction && typeof sanitizeFunction === 'function') { + return sanitizeFunction(unsafeHtml); } const domParser = new window.DOMParser(); const createdDocument = domParser.parseFromString(unsafeHtml, 'text/html'); const elements = [].concat(...createdDocument.body.querySelectorAll('*')); - for (let i = 0, len = elements.length; i < len; i++) { - const element = elements[i]; + for (const element of elements) { const elementName = element.nodeName.toLowerCase(); if (!Object.keys(allowList).includes(elementName)) { @@ -3526,11 +3533,12 @@ const attributeList = [].concat(...element.attributes); const allowedAttributes = [].concat(allowList['*'] || [], allowList[elementName] || []); - attributeList.forEach(attribute => { + + for (const attribute of attributeList) { if (!allowedAttribute(attribute, allowedAttributes)) { element.removeAttribute(attribute.nodeName); } - }); + } } return createdDocument.body.innerHTML; @@ -3538,40 +3546,194 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): tooltip.js + * Bootstrap (v5.2.0): util/template-factory.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** - * ------------------------------------------------------------------------ * Constants - * ------------------------------------------------------------------------ */ - const NAME$4 = 'tooltip'; - const DATA_KEY$4 = 'bs.tooltip'; - const EVENT_KEY$4 = `.${DATA_KEY$4}`; - const CLASS_PREFIX$1 = 'bs-tooltip'; - const DISALLOWED_ATTRIBUTES = new Set(['sanitize', 'allowList', 'sanitizeFn']); - const DefaultType$3 = { - animation: 'boolean', - template: 'string', - title: '(string|element|function)', - trigger: 'string', - delay: '(number|object)', + const NAME$5 = 'TemplateFactory'; + const Default$4 = { + allowList: DefaultAllowlist, + content: {}, + // { selector : text , selector2 : text2 , } + extraClass: '', + html: false, + sanitize: true, + sanitizeFn: null, + template: '<div></div>' + }; + const DefaultType$4 = { + allowList: 'object', + content: 'object', + extraClass: '(string|function)', html: 'boolean', - selector: '(string|boolean)', - placement: '(string|function)', - offset: '(array|string|function)', - container: '(string|element|boolean)', - fallbackPlacements: 'array', - boundary: '(string|element)', - customClass: '(string|function)', sanitize: 'boolean', sanitizeFn: '(null|function)', - allowList: 'object', - popperConfig: '(null|object|function)' + template: 'string' + }; + const DefaultContentType = { + entry: '(string|element|function|null)', + selector: '(string|element)' }; + /** + * Class definition + */ + + class TemplateFactory extends Config { + constructor(config) { + super(); + this._config = this._getConfig(config); + } // Getters + + + static get Default() { + return Default$4; + } + + static get DefaultType() { + return DefaultType$4; + } + + static get NAME() { + return NAME$5; + } // Public + + + getContent() { + return Object.values(this._config.content).map(config => this._resolvePossibleFunction(config)).filter(Boolean); + } + + hasContent() { + return this.getContent().length > 0; + } + + changeContent(content) { + this._checkContent(content); + + this._config.content = { ...this._config.content, + ...content + }; + return this; + } + + toHtml() { + const templateWrapper = document.createElement('div'); + templateWrapper.innerHTML = this._maybeSanitize(this._config.template); + + for (const [selector, text] of Object.entries(this._config.content)) { + this._setContent(templateWrapper, text, selector); + } + + const template = templateWrapper.children[0]; + + const extraClass = this._resolvePossibleFunction(this._config.extraClass); + + if (extraClass) { + template.classList.add(...extraClass.split(' ')); + } + + return template; + } // Private + + + _typeCheckConfig(config) { + super._typeCheckConfig(config); + + this._checkContent(config.content); + } + + _checkContent(arg) { + for (const [selector, content] of Object.entries(arg)) { + super._typeCheckConfig({ + selector, + entry: content + }, DefaultContentType); + } + } + + _setContent(template, content, selector) { + const templateElement = SelectorEngine.findOne(selector, template); + + if (!templateElement) { + return; + } + + content = this._resolvePossibleFunction(content); + + if (!content) { + templateElement.remove(); + return; + } + + if (isElement(content)) { + this._putElementInTemplate(getElement(content), templateElement); + + return; + } + + if (this._config.html) { + templateElement.innerHTML = this._maybeSanitize(content); + return; + } + + templateElement.textContent = content; + } + + _maybeSanitize(arg) { + return this._config.sanitize ? sanitizeHtml(arg, this._config.allowList, this._config.sanitizeFn) : arg; + } + + _resolvePossibleFunction(arg) { + return typeof arg === 'function' ? arg(this) : arg; + } + + _putElementInTemplate(element, templateElement) { + if (this._config.html) { + templateElement.innerHTML = ''; + templateElement.append(element); + return; + } + + templateElement.textContent = element.textContent; + } + + } + + /** + * -------------------------------------------------------------------------- + * Bootstrap (v5.2.0): tooltip.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) + * -------------------------------------------------------------------------- + */ + /** + * Constants + */ + + const NAME$4 = 'tooltip'; + const DISALLOWED_ATTRIBUTES = new Set(['sanitize', 'allowList', 'sanitizeFn']); + const CLASS_NAME_FADE$2 = 'fade'; + const CLASS_NAME_MODAL = 'modal'; + const CLASS_NAME_SHOW$2 = 'show'; + const SELECTOR_TOOLTIP_INNER = '.tooltip-inner'; + const SELECTOR_MODAL = `.${CLASS_NAME_MODAL}`; + const EVENT_MODAL_HIDE = 'hide.bs.modal'; + const TRIGGER_HOVER = 'hover'; + const TRIGGER_FOCUS = 'focus'; + const TRIGGER_CLICK = 'click'; + const TRIGGER_MANUAL = 'manual'; + const EVENT_HIDE$2 = 'hide'; + const EVENT_HIDDEN$2 = 'hidden'; + const EVENT_SHOW$2 = 'show'; + const EVENT_SHOWN$2 = 'shown'; + const EVENT_INSERTED = 'inserted'; + const EVENT_CLICK$1 = 'click'; + const EVENT_FOCUSIN$1 = 'focusin'; + const EVENT_FOCUSOUT$1 = 'focusout'; + const EVENT_MOUSEENTER = 'mouseenter'; + const EVENT_MOUSELEAVE = 'mouseleave'; const AttachmentMap = { AUTO: 'auto', TOP: 'top', @@ -3580,52 +3742,45 @@ LEFT: isRTL() ? 'right' : 'left' }; const Default$3 = { + allowList: DefaultAllowlist, animation: true, - template: '<div class="tooltip" role="tooltip">' + '<div class="tooltip-arrow"></div>' + '<div class="tooltip-inner"></div>' + '</div>', - trigger: 'hover focus', - title: '', + boundary: 'clippingParents', + container: false, + customClass: '', delay: 0, + fallbackPlacements: ['top', 'right', 'bottom', 'left'], html: false, - selector: false, - placement: 'top', offset: [0, 0], - container: false, - fallbackPlacements: ['top', 'right', 'bottom', 'left'], - boundary: 'clippingParents', - customClass: '', + placement: 'top', + popperConfig: null, sanitize: true, sanitizeFn: null, - allowList: DefaultAllowlist, - popperConfig: null + selector: false, + template: '<div class="tooltip" role="tooltip">' + '<div class="tooltip-arrow"></div>' + '<div class="tooltip-inner"></div>' + '</div>', + title: '', + trigger: 'hover focus' }; - const Event$2 = { - HIDE: `hide${EVENT_KEY$4}`, - HIDDEN: `hidden${EVENT_KEY$4}`, - SHOW: `show${EVENT_KEY$4}`, - SHOWN: `shown${EVENT_KEY$4}`, - INSERTED: `inserted${EVENT_KEY$4}`, - CLICK: `click${EVENT_KEY$4}`, - FOCUSIN: `focusin${EVENT_KEY$4}`, - FOCUSOUT: `focusout${EVENT_KEY$4}`, - MOUSEENTER: `mouseenter${EVENT_KEY$4}`, - MOUSELEAVE: `mouseleave${EVENT_KEY$4}` + const DefaultType$3 = { + allowList: 'object', + animation: 'boolean', + boundary: '(string|element)', + container: '(string|element|boolean)', + customClass: '(string|function)', + delay: '(number|object)', + fallbackPlacements: 'array', + html: 'boolean', + offset: '(array|string|function)', + placement: '(string|function)', + popperConfig: '(null|object|function)', + sanitize: 'boolean', + sanitizeFn: '(null|function)', + selector: '(string|boolean)', + template: 'string', + title: '(string|element|function)', + trigger: 'string' }; - const CLASS_NAME_FADE$2 = 'fade'; - const CLASS_NAME_MODAL = 'modal'; - const CLASS_NAME_SHOW$2 = 'show'; - const HOVER_STATE_SHOW = 'show'; - const HOVER_STATE_OUT = 'out'; - const SELECTOR_TOOLTIP_INNER = '.tooltip-inner'; - const SELECTOR_MODAL = `.${CLASS_NAME_MODAL}`; - const EVENT_MODAL_HIDE = 'hide.bs.modal'; - const TRIGGER_HOVER = 'hover'; - const TRIGGER_FOCUS = 'focus'; - const TRIGGER_CLICK = 'click'; - const TRIGGER_MANUAL = 'manual'; /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ + * Class definition */ class Tooltip extends BaseComponent { @@ -3634,15 +3789,16 @@ throw new TypeError('Bootstrap\'s tooltips require Popper (https://popper.js.org)'); } - super(element); // private + super(element, config); // Private this._isEnabled = true; this._timeout = 0; - this._hoverState = ''; + this._isHovered = false; this._activeTrigger = {}; - this._popper = null; // Protected + this._popper = null; + this._templateFactory = null; + this._newContent = null; // Protected - this._config = this._getConfig(config); this.tip = null; this._setListeners(); @@ -3653,16 +3809,12 @@ return Default$3; } - static get NAME() { - return NAME$4; - } - - static get Event() { - return Event$2; - } - static get DefaultType() { return DefaultType$3; + } + + static get NAME() { + return NAME$4; } // Public @@ -3689,19 +3841,21 @@ context._activeTrigger.click = !context._activeTrigger.click; if (context._isWithActiveTrigger()) { - context._enter(null, context); + context._enter(); } else { - context._leave(null, context); + context._leave(); } - } else { - if (this.getTipElement().classList.contains(CLASS_NAME_SHOW$2)) { - this._leave(null, this); - return; - } + return; + } + + if (this._isShown()) { + this._leave(); - this._enter(null, this); + return; } + + this._enter(); } dispose() { @@ -3722,233 +3876,206 @@ throw new Error('Please use show on visible elements'); } - if (!(this.isWithContent() && this._isEnabled)) { + if (!(this._isWithContent() && this._isEnabled)) { return; } - const showEvent = EventHandler.trigger(this._element, this.constructor.Event.SHOW); + const showEvent = EventHandler.trigger(this._element, this.constructor.eventName(EVENT_SHOW$2)); const shadowRoot = findShadowRoot(this._element); - const isInTheDom = shadowRoot === null ? this._element.ownerDocument.documentElement.contains(this._element) : shadowRoot.contains(this._element); + + const isInTheDom = (shadowRoot || this._element.ownerDocument.documentElement).contains(this._element); if (showEvent.defaultPrevented || !isInTheDom) { return; - } // A trick to recreate a tooltip in case a new title is given by using the NOT documented `data-bs-original-title` - // This will be removed later in favor of a `setContent` method + } // todo v6 remove this OR make it optional - if (this.constructor.NAME === 'tooltip' && this.tip && this.getTitle() !== this.tip.querySelector(SELECTOR_TOOLTIP_INNER).innerHTML) { - this._disposePopper(); - + if (this.tip) { this.tip.remove(); this.tip = null; } - const tip = this.getTipElement(); - const tipId = getUID(this.constructor.NAME); - tip.setAttribute('id', tipId); - - this._element.setAttribute('aria-describedby', tipId); - - if (this._config.animation) { - tip.classList.add(CLASS_NAME_FADE$2); - } - - const placement = typeof this._config.placement === 'function' ? this._config.placement.call(this, tip, this._element) : this._config.placement; - - const attachment = this._getAttachment(placement); + const tip = this._getTipElement(); - this._addAttachmentClass(attachment); + this._element.setAttribute('aria-describedby', tip.getAttribute('id')); const { container } = this._config; - Data.set(tip, this.constructor.DATA_KEY, this); if (!this._element.ownerDocument.documentElement.contains(this.tip)) { container.append(tip); - EventHandler.trigger(this._element, this.constructor.Event.INSERTED); + EventHandler.trigger(this._element, this.constructor.eventName(EVENT_INSERTED)); } if (this._popper) { this._popper.update(); } else { - this._popper = Popper__namespace.createPopper(this._element, tip, this._getPopperConfig(attachment)); + this._popper = this._createPopper(tip); } - tip.classList.add(CLASS_NAME_SHOW$2); - - const customClass = this._resolvePossibleFunction(this._config.customClass); - - if (customClass) { - tip.classList.add(...customClass.split(' ')); - } // If this is a touch-enabled device we add extra + tip.classList.add(CLASS_NAME_SHOW$2); // 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) { - [].concat(...document.body.children).forEach(element => { + for (const element of [].concat(...document.body.children)) { EventHandler.on(element, 'mouseover', noop); - }); + } } const complete = () => { - const prevHoverState = this._hoverState; - this._hoverState = null; - EventHandler.trigger(this._element, this.constructor.Event.SHOWN); + const previousHoverState = this._isHovered; + this._isHovered = false; + EventHandler.trigger(this._element, this.constructor.eventName(EVENT_SHOWN$2)); - if (prevHoverState === HOVER_STATE_OUT) { - this._leave(null, this); + if (previousHoverState) { + this._leave(); } }; - const isAnimated = this.tip.classList.contains(CLASS_NAME_FADE$2); - - this._queueCallback(complete, this.tip, isAnimated); + this._queueCallback(complete, this.tip, this._isAnimated()); } hide() { - if (!this._popper) { + if (!this._isShown()) { return; } - const tip = this.getTipElement(); - - const complete = () => { - if (this._isWithActiveTrigger()) { - return; - } - - if (this._hoverState !== HOVER_STATE_SHOW) { - tip.remove(); - } - - this._cleanTipClass(); - - this._element.removeAttribute('aria-describedby'); - - EventHandler.trigger(this._element, this.constructor.Event.HIDDEN); - - this._disposePopper(); - }; - - const hideEvent = EventHandler.trigger(this._element, this.constructor.Event.HIDE); + const hideEvent = EventHandler.trigger(this._element, this.constructor.eventName(EVENT_HIDE$2)); if (hideEvent.defaultPrevented) { return; } + const tip = this._getTipElement(); + tip.classList.remove(CLASS_NAME_SHOW$2); // If this is a touch-enabled device we remove the extra // empty mouseover listeners we added for iOS support if ('ontouchstart' in document.documentElement) { - [].concat(...document.body.children).forEach(element => EventHandler.off(element, 'mouseover', noop)); + for (const element of [].concat(...document.body.children)) { + EventHandler.off(element, 'mouseover', noop); + } } this._activeTrigger[TRIGGER_CLICK] = false; this._activeTrigger[TRIGGER_FOCUS] = false; this._activeTrigger[TRIGGER_HOVER] = false; - const isAnimated = this.tip.classList.contains(CLASS_NAME_FADE$2); + this._isHovered = false; - this._queueCallback(complete, this.tip, isAnimated); + const complete = () => { + if (this._isWithActiveTrigger()) { + return; + } - this._hoverState = ''; + if (!this._isHovered) { + tip.remove(); + } + + this._element.removeAttribute('aria-describedby'); + + EventHandler.trigger(this._element, this.constructor.eventName(EVENT_HIDDEN$2)); + + this._disposePopper(); + }; + + this._queueCallback(complete, this.tip, this._isAnimated()); } update() { - if (this._popper !== null) { + if (this._popper) { this._popper.update(); } } // Protected - isWithContent() { - return Boolean(this.getTitle()); + _isWithContent() { + return Boolean(this._getTitle()); } - getTipElement() { - if (this.tip) { - return this.tip; + _getTipElement() { + if (!this.tip) { + this.tip = this._createTipElement(this._newContent || this._getContentForTemplate()); } - const element = document.createElement('div'); - element.innerHTML = this._config.template; - const tip = element.children[0]; - this.setContent(tip); - tip.classList.remove(CLASS_NAME_FADE$2, CLASS_NAME_SHOW$2); - this.tip = tip; return this.tip; } - setContent(tip) { - this._sanitizeAndSetContent(tip, this.getTitle(), SELECTOR_TOOLTIP_INNER); - } + _createTipElement(content) { + const tip = this._getTemplateFactory(content).toHtml(); // todo: remove this check on v6 - _sanitizeAndSetContent(template, content, selector) { - const templateElement = SelectorEngine.findOne(selector, template); - if (!content && templateElement) { - templateElement.remove(); - return; - } // we use append for html objects to maintain js events + if (!tip) { + return null; + } + tip.classList.remove(CLASS_NAME_FADE$2, CLASS_NAME_SHOW$2); // todo: on v6 the following can be achieved with CSS only - this.setElementContent(templateElement, content); - } + tip.classList.add(`bs-${this.constructor.NAME}-auto`); + const tipId = getUID(this.constructor.NAME).toString(); + tip.setAttribute('id', tipId); - setElementContent(element, content) { - if (element === null) { - return; + if (this._isAnimated()) { + tip.classList.add(CLASS_NAME_FADE$2); } - if (isElement(content)) { - content = getElement(content); // content is a DOM node or a jQuery + return tip; + } - if (this._config.html) { - if (content.parentNode !== element) { - element.innerHTML = ''; - element.append(content); - } - } else { - element.textContent = content.textContent; - } + setContent(content) { + this._newContent = content; - return; - } + if (this._isShown()) { + this._disposePopper(); - if (this._config.html) { - if (this._config.sanitize) { - content = sanitizeHtml(content, this._config.allowList, this._config.sanitizeFn); - } + this.show(); + } + } - element.innerHTML = content; + _getTemplateFactory(content) { + if (this._templateFactory) { + this._templateFactory.changeContent(content); } else { - element.textContent = content; + this._templateFactory = new TemplateFactory({ ...this._config, + // the `content` var has to be after `this._config` + // to override config.content in case of popover + content, + extraClass: this._resolvePossibleFunction(this._config.customClass) + }); } - } - getTitle() { - const title = this._element.getAttribute('data-bs-original-title') || this._config.title; + return this._templateFactory; + } - return this._resolvePossibleFunction(title); + _getContentForTemplate() { + return { + [SELECTOR_TOOLTIP_INNER]: this._getTitle() + }; } - updateAttachment(attachment) { - if (attachment === 'right') { - return 'end'; - } + _getTitle() { + return this._resolvePossibleFunction(this._config.title) || this._config.originalTitle; + } // Private - if (attachment === 'left') { - return 'start'; - } - return attachment; - } // Private + _initializeOnDelegatedTarget(event) { + return this.constructor.getOrCreateInstance(event.delegateTarget, this._getDelegateConfig()); + } + + _isAnimated() { + return this._config.animation || this.tip && this.tip.classList.contains(CLASS_NAME_FADE$2); + } + _isShown() { + return this.tip && this.tip.classList.contains(CLASS_NAME_SHOW$2); + } - _initializeOnDelegatedTarget(event, context) { - return context || this.constructor.getOrCreateInstance(event.delegateTarget, this._getDelegateConfig()); + _createPopper(tip) { + const placement = typeof this._config.placement === 'function' ? this._config.placement.call(this, tip, this._element) : this._config.placement; + const attachment = AttachmentMap[placement.toUpperCase()]; + return Popper__namespace.createPopper(this._element, tip, this._getPopperConfig(attachment)); } _getOffset() { @@ -3957,7 +4084,7 @@ } = this._config; if (typeof offset === 'string') { - return offset.split(',').map(val => Number.parseInt(val, 10)); + return offset.split(',').map(value => Number.parseInt(value, 10)); } if (typeof offset === 'function') { @@ -3967,8 +4094,8 @@ return offset; } - _resolvePossibleFunction(content) { - return typeof content === 'function' ? content.call(this._element) : content; + _resolvePossibleFunction(arg) { + return typeof arg === 'function' ? arg.call(this._element) : arg; } _getPopperConfig(attachment) { @@ -3995,43 +4122,46 @@ element: `.${this.constructor.NAME}-arrow` } }, { - name: 'onChange', + name: 'preSetPlacement', enabled: true, - phase: 'afterWrite', - fn: data => this._handlePopperPlacementChange(data) - }], - onFirstUpdate: data => { - if (data.options.placement !== data.placement) { - this._handlePopperPlacementChange(data); + phase: 'beforeMain', + fn: data => { + // Pre-set Popper's placement attribute in order to read the arrow sizes properly. + // Otherwise, Popper mixes up the width and height dimensions since the initial arrow style is for top placement + this._getTipElement().setAttribute('data-popper-placement', data.state.placement); } - } + }] }; return { ...defaultBsPopperConfig, ...(typeof this._config.popperConfig === 'function' ? this._config.popperConfig(defaultBsPopperConfig) : this._config.popperConfig) }; } - _addAttachmentClass(attachment) { - this.getTipElement().classList.add(`${this._getBasicClassPrefix()}-${this.updateAttachment(attachment)}`); - } - - _getAttachment(placement) { - return AttachmentMap[placement.toUpperCase()]; - } - _setListeners() { const triggers = this._config.trigger.split(' '); - triggers.forEach(trigger => { + for (const trigger of triggers) { if (trigger === 'click') { - EventHandler.on(this._element, this.constructor.Event.CLICK, this._config.selector, event => this.toggle(event)); + EventHandler.on(this._element, this.constructor.eventName(EVENT_CLICK$1), this._config.selector, event => this.toggle(event)); } else if (trigger !== TRIGGER_MANUAL) { - const eventIn = trigger === TRIGGER_HOVER ? this.constructor.Event.MOUSEENTER : this.constructor.Event.FOCUSIN; - const eventOut = trigger === TRIGGER_HOVER ? this.constructor.Event.MOUSELEAVE : this.constructor.Event.FOCUSOUT; - EventHandler.on(this._element, eventIn, this._config.selector, event => this._enter(event)); - EventHandler.on(this._element, eventOut, this._config.selector, event => this._leave(event)); + const eventIn = trigger === TRIGGER_HOVER ? this.constructor.eventName(EVENT_MOUSEENTER) : this.constructor.eventName(EVENT_FOCUSIN$1); + const eventOut = trigger === TRIGGER_HOVER ? this.constructor.eventName(EVENT_MOUSELEAVE) : this.constructor.eventName(EVENT_FOCUSOUT$1); + EventHandler.on(this._element, eventIn, this._config.selector, event => { + const context = this._initializeOnDelegatedTarget(event); + + context._activeTrigger[event.type === 'focusin' ? TRIGGER_FOCUS : TRIGGER_HOVER] = true; + + context._enter(); + }); + EventHandler.on(this._element, eventOut, this._config.selector, event => { + const context = this._initializeOnDelegatedTarget(event); + + context._activeTrigger[event.type === 'focusout' ? TRIGGER_FOCUS : TRIGGER_HOVER] = context._element.contains(event.relatedTarget); + + context._leave(); + }); } - }); + } this._hideModalHandler = () => { if (this._element) { @@ -4052,95 +4182,78 @@ } _fixTitle() { - const title = this._element.getAttribute('title'); - - const originalTitleType = typeof this._element.getAttribute('data-bs-original-title'); - - if (title || originalTitleType !== 'string') { - this._element.setAttribute('data-bs-original-title', title || ''); - - if (title && !this._element.getAttribute('aria-label') && !this._element.textContent) { - this._element.setAttribute('aria-label', title); - } - - this._element.setAttribute('title', ''); - } - } + const title = this._config.originalTitle; - _enter(event, context) { - context = this._initializeOnDelegatedTarget(event, context); - - if (event) { - context._activeTrigger[event.type === 'focusin' ? TRIGGER_FOCUS : TRIGGER_HOVER] = true; + if (!title) { + return; } - if (context.getTipElement().classList.contains(CLASS_NAME_SHOW$2) || context._hoverState === HOVER_STATE_SHOW) { - context._hoverState = HOVER_STATE_SHOW; - return; + if (!this._element.getAttribute('aria-label') && !this._element.textContent.trim()) { + this._element.setAttribute('aria-label', title); } - clearTimeout(context._timeout); - context._hoverState = HOVER_STATE_SHOW; + this._element.removeAttribute('title'); + } - if (!context._config.delay || !context._config.delay.show) { - context.show(); + _enter() { + if (this._isShown() || this._isHovered) { + this._isHovered = true; return; } - context._timeout = setTimeout(() => { - if (context._hoverState === HOVER_STATE_SHOW) { - context.show(); + this._isHovered = true; + + this._setTimeout(() => { + if (this._isHovered) { + this.show(); } - }, context._config.delay.show); + }, this._config.delay.show); } - _leave(event, context) { - context = this._initializeOnDelegatedTarget(event, context); - - if (event) { - context._activeTrigger[event.type === 'focusout' ? TRIGGER_FOCUS : TRIGGER_HOVER] = context._element.contains(event.relatedTarget); - } - - if (context._isWithActiveTrigger()) { + _leave() { + if (this._isWithActiveTrigger()) { return; } - clearTimeout(context._timeout); - context._hoverState = HOVER_STATE_OUT; - - if (!context._config.delay || !context._config.delay.hide) { - context.hide(); - return; - } + this._isHovered = false; - context._timeout = setTimeout(() => { - if (context._hoverState === HOVER_STATE_OUT) { - context.hide(); + this._setTimeout(() => { + if (!this._isHovered) { + this.hide(); } - }, context._config.delay.hide); + }, this._config.delay.hide); } - _isWithActiveTrigger() { - for (const trigger in this._activeTrigger) { - if (this._activeTrigger[trigger]) { - return true; - } - } + _setTimeout(handler, timeout) { + clearTimeout(this._timeout); + this._timeout = setTimeout(handler, timeout); + } - return false; + _isWithActiveTrigger() { + return Object.values(this._activeTrigger).includes(true); } _getConfig(config) { const dataAttributes = Manipulator.getDataAttributes(this._element); - Object.keys(dataAttributes).forEach(dataAttr => { - if (DISALLOWED_ATTRIBUTES.has(dataAttr)) { - delete dataAttributes[dataAttr]; + + for (const dataAttribute of Object.keys(dataAttributes)) { + if (DISALLOWED_ATTRIBUTES.has(dataAttribute)) { + delete dataAttributes[dataAttribute]; } - }); - config = { ...this.constructor.Default, - ...dataAttributes, + } + + config = { ...dataAttributes, ...(typeof config === 'object' && config ? config : {}) }; + config = this._mergeConfigObj(config); + config = this._configAfterMerge(config); + + this._typeCheckConfig(config); + + return config; + } + + _configAfterMerge(config) { config.container = config.container === false ? document.body : getElement(config.container); if (typeof config.delay === 'number') { @@ -4150,6 +4263,8 @@ }; } + config.originalTitle = this._element.getAttribute('title') || ''; + if (typeof config.title === 'number') { config.title = config.title.toString(); } @@ -4158,12 +4273,6 @@ config.content = config.content.toString(); } - typeCheckConfig(NAME$4, config, this.constructor.DefaultType); - - if (config.sanitize) { - config.template = sanitizeHtml(config.template, config.allowList, config.sanitizeFn); - } - return config; } @@ -4182,36 +4291,6 @@ return config; } - _cleanTipClass() { - const tip = this.getTipElement(); - const basicClassPrefixRegex = new RegExp(`(^|\\s)${this._getBasicClassPrefix()}\\S+`, 'g'); - const tabClass = tip.getAttribute('class').match(basicClassPrefixRegex); - - if (tabClass !== null && tabClass.length > 0) { - tabClass.map(token => token.trim()).forEach(tClass => tip.classList.remove(tClass)); - } - } - - _getBasicClassPrefix() { - return CLASS_PREFIX$1; - } - - _handlePopperPlacementChange(popperData) { - const { - state - } = popperData; - - if (!state) { - return; - } - - this.tip = state.elements.popper; - - this._cleanTipClass(); - - this._addAttachmentClass(this._getAttachment(state.placement)); - } - _disposePopper() { if (this._popper) { this._popper.destroy(); @@ -4225,22 +4304,21 @@ return this.each(function () { const data = Tooltip.getOrCreateInstance(this, config); - if (typeof config === 'string') { - if (typeof data[config] === 'undefined') { - throw new TypeError(`No method named "${config}"`); - } + if (typeof config !== 'string') { + return; + } - data[config](); + if (typeof data[config] === 'undefined') { + throw new TypeError(`No method named "${config}"`); } + + data[config](); }); } } /** - * ------------------------------------------------------------------------ * jQuery - * ------------------------------------------------------------------------ - * add .Tooltip to jQuery only if jQuery is present */ @@ -4248,48 +4326,29 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): popover.js + * Bootstrap (v5.2.0): popover.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** - * ------------------------------------------------------------------------ * Constants - * ------------------------------------------------------------------------ */ const NAME$3 = 'popover'; - const DATA_KEY$3 = 'bs.popover'; - const EVENT_KEY$3 = `.${DATA_KEY$3}`; - const CLASS_PREFIX = 'bs-popover'; + const SELECTOR_TITLE = '.popover-header'; + const SELECTOR_CONTENT = '.popover-body'; const Default$2 = { ...Tooltip.Default, - placement: 'right', - offset: [0, 8], - trigger: 'click', content: '', - template: '<div class="popover" role="tooltip">' + '<div class="popover-arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div>' + '</div>' + offset: [0, 8], + placement: 'right', + template: '<div class="popover" role="tooltip">' + '<div class="popover-arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div>' + '</div>', + trigger: 'click' }; const DefaultType$2 = { ...Tooltip.DefaultType, - content: '(string|element|function)' - }; - const Event$1 = { - HIDE: `hide${EVENT_KEY$3}`, - HIDDEN: `hidden${EVENT_KEY$3}`, - SHOW: `show${EVENT_KEY$3}`, - SHOWN: `shown${EVENT_KEY$3}`, - INSERTED: `inserted${EVENT_KEY$3}`, - CLICK: `click${EVENT_KEY$3}`, - FOCUSIN: `focusin${EVENT_KEY$3}`, - FOCUSOUT: `focusout${EVENT_KEY$3}`, - MOUSEENTER: `mouseenter${EVENT_KEY$3}`, - MOUSELEAVE: `mouseleave${EVENT_KEY$3}` + content: '(null|string|element|function)' }; - const SELECTOR_TITLE = '.popover-header'; - const SELECTOR_CONTENT = '.popover-body'; /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ + * Class definition */ class Popover extends Tooltip { @@ -4298,36 +4357,29 @@ return Default$2; } - static get NAME() { - return NAME$3; - } - - static get Event() { - return Event$1; - } - static get DefaultType() { return DefaultType$2; - } // Overrides - - - isWithContent() { - return this.getTitle() || this._getContent(); } - setContent(tip) { - this._sanitizeAndSetContent(tip, this.getTitle(), SELECTOR_TITLE); + static get NAME() { + return NAME$3; + } // Overrides + - this._sanitizeAndSetContent(tip, this._getContent(), SELECTOR_CONTENT); + _isWithContent() { + return this._getTitle() || this._getContent(); } // Private - _getContent() { - return this._resolvePossibleFunction(this._config.content); + _getContentForTemplate() { + return { + [SELECTOR_TITLE]: this._getTitle(), + [SELECTOR_CONTENT]: this._getContent() + }; } - _getBasicClassPrefix() { - return CLASS_PREFIX; + _getContent() { + return this._resolvePossibleFunction(this._config.content); } // Static @@ -4335,22 +4387,21 @@ return this.each(function () { const data = Popover.getOrCreateInstance(this, config); - if (typeof config === 'string') { - if (typeof data[config] === 'undefined') { - throw new TypeError(`No method named "${config}"`); - } + if (typeof config !== 'string') { + return; + } - data[config](); + if (typeof data[config] === 'undefined') { + throw new TypeError(`No method named "${config}"`); } + + data[config](); }); } } /** - * ------------------------------------------------------------------------ * jQuery - * ------------------------------------------------------------------------ - * add .Popover to jQuery only if jQuery is present */ @@ -4358,64 +4409,64 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): scrollspy.js + * Bootstrap (v5.2.0): scrollspy.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** - * ------------------------------------------------------------------------ * Constants - * ------------------------------------------------------------------------ */ const NAME$2 = 'scrollspy'; const DATA_KEY$2 = 'bs.scrollspy'; const EVENT_KEY$2 = `.${DATA_KEY$2}`; - const DATA_API_KEY$1 = '.data-api'; - const Default$1 = { - offset: 10, - method: 'auto', - target: '' - }; - const DefaultType$1 = { - offset: 'number', - method: 'string', - target: '(string|element)' - }; + const DATA_API_KEY = '.data-api'; const EVENT_ACTIVATE = `activate${EVENT_KEY$2}`; - const EVENT_SCROLL = `scroll${EVENT_KEY$2}`; - const EVENT_LOAD_DATA_API = `load${EVENT_KEY$2}${DATA_API_KEY$1}`; + const EVENT_CLICK = `click${EVENT_KEY$2}`; + const EVENT_LOAD_DATA_API$1 = `load${EVENT_KEY$2}${DATA_API_KEY}`; const CLASS_NAME_DROPDOWN_ITEM = 'dropdown-item'; const CLASS_NAME_ACTIVE$1 = 'active'; const SELECTOR_DATA_SPY = '[data-bs-spy="scroll"]'; - const SELECTOR_NAV_LIST_GROUP$1 = '.nav, .list-group'; + const SELECTOR_TARGET_LINKS = '[href]'; + const SELECTOR_NAV_LIST_GROUP = '.nav, .list-group'; const SELECTOR_NAV_LINKS = '.nav-link'; const SELECTOR_NAV_ITEMS = '.nav-item'; const SELECTOR_LIST_ITEMS = '.list-group-item'; - const SELECTOR_LINK_ITEMS = `${SELECTOR_NAV_LINKS}, ${SELECTOR_LIST_ITEMS}, .${CLASS_NAME_DROPDOWN_ITEM}`; - const SELECTOR_DROPDOWN$1 = '.dropdown'; + const SELECTOR_LINK_ITEMS = `${SELECTOR_NAV_LINKS}, ${SELECTOR_NAV_ITEMS} > ${SELECTOR_NAV_LINKS}, ${SELECTOR_LIST_ITEMS}`; + const SELECTOR_DROPDOWN = '.dropdown'; const SELECTOR_DROPDOWN_TOGGLE$1 = '.dropdown-toggle'; - const METHOD_OFFSET = 'offset'; - const METHOD_POSITION = 'position'; + const Default$1 = { + offset: null, + // TODO: v6 @deprecated, keep it for backwards compatibility reasons + rootMargin: '0px 0px -25%', + smoothScroll: false, + target: null + }; + const DefaultType$1 = { + offset: '(number|null)', + // TODO v6 @deprecated, keep it for backwards compatibility reasons + rootMargin: 'string', + smoothScroll: 'boolean', + target: 'element' + }; /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ + * Class definition */ class ScrollSpy extends BaseComponent { constructor(element, config) { - super(element); - this._scrollElement = this._element.tagName === 'BODY' ? window : this._element; - this._config = this._getConfig(config); - this._offsets = []; - this._targets = []; - this._activeTarget = null; - this._scrollHeight = 0; - EventHandler.on(this._scrollElement, EVENT_SCROLL, () => this._process()); - this.refresh(); + super(element, config); // this._element is the observablesContainer and config.target the menu links wrapper - this._process(); + this._targetLinks = new Map(); + this._observableSections = new Map(); + this._rootElement = getComputedStyle(this._element).overflowY === 'visible' ? null : this._element; + this._activeTarget = null; + this._observer = null; + this._previousScrollData = { + visibleEntryTop: 0, + parentScrollTop: 0 + }; + this.refresh(); // initialize } // Getters @@ -4423,135 +4474,190 @@ return Default$1; } + static get DefaultType() { + return DefaultType$1; + } + static get NAME() { return NAME$2; } // Public refresh() { - const autoMethod = this._scrollElement === this._scrollElement.window ? METHOD_OFFSET : METHOD_POSITION; - const offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method; - const offsetBase = offsetMethod === METHOD_POSITION ? this._getScrollTop() : 0; - this._offsets = []; - this._targets = []; - this._scrollHeight = this._getScrollHeight(); - const targets = SelectorEngine.find(SELECTOR_LINK_ITEMS, this._config.target); - targets.map(element => { - const targetSelector = getSelectorFromElement(element); - const target = targetSelector ? SelectorEngine.findOne(targetSelector) : null; - - if (target) { - const targetBCR = target.getBoundingClientRect(); - - if (targetBCR.width || targetBCR.height) { - return [Manipulator[offsetMethod](target).top + offsetBase, targetSelector]; - } - } + this._initializeTargetsAndObservables(); - return null; - }).filter(item => item).sort((a, b) => a[0] - b[0]).forEach(item => { - this._offsets.push(item[0]); + this._maybeEnableSmoothScroll(); - this._targets.push(item[1]); - }); + if (this._observer) { + this._observer.disconnect(); + } else { + this._observer = this._getNewObserver(); + } + + for (const section of this._observableSections.values()) { + this._observer.observe(section); + } } dispose() { - EventHandler.off(this._scrollElement, EVENT_KEY$2); + this._observer.disconnect(); + super.dispose(); } // Private - _getConfig(config) { - config = { ...Default$1, - ...Manipulator.getDataAttributes(this._element), - ...(typeof config === 'object' && config ? config : {}) - }; - config.target = getElement(config.target) || document.documentElement; - typeCheckConfig(NAME$2, config, DefaultType$1); + _configAfterMerge(config) { + // TODO: on v6 target should be given explicitly & remove the {target: 'ss-target'} case + config.target = getElement(config.target) || document.body; return config; } - _getScrollTop() { - return this._scrollElement === window ? this._scrollElement.pageYOffset : this._scrollElement.scrollTop; - } + _maybeEnableSmoothScroll() { + if (!this._config.smoothScroll) { + return; + } // unregister any previous listeners - _getScrollHeight() { - return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight); - } - _getOffsetHeight() { - return this._scrollElement === window ? window.innerHeight : this._scrollElement.getBoundingClientRect().height; + EventHandler.off(this._config.target, EVENT_CLICK); + EventHandler.on(this._config.target, EVENT_CLICK, SELECTOR_TARGET_LINKS, event => { + const observableSection = this._observableSections.get(event.target.hash); + + if (observableSection) { + event.preventDefault(); + const root = this._rootElement || window; + const height = observableSection.offsetTop - this._element.offsetTop; + + if (root.scrollTo) { + root.scrollTo({ + top: height, + behavior: 'smooth' + }); + return; + } // Chrome 60 doesn't support `scrollTo` + + + root.scrollTop = height; + } + }); } - _process() { - const scrollTop = this._getScrollTop() + this._config.offset; + _getNewObserver() { + const options = { + root: this._rootElement, + threshold: [0.1, 0.5, 1], + rootMargin: this._getRootMargin() + }; + return new IntersectionObserver(entries => this._observerCallback(entries), options); + } // The logic of selection + - const scrollHeight = this._getScrollHeight(); + _observerCallback(entries) { + const targetElement = entry => this._targetLinks.get(`#${entry.target.id}`); - const maxScroll = this._config.offset + scrollHeight - this._getOffsetHeight(); + const activate = entry => { + this._previousScrollData.visibleEntryTop = entry.target.offsetTop; - if (this._scrollHeight !== scrollHeight) { - this.refresh(); - } + this._process(targetElement(entry)); + }; - if (scrollTop >= maxScroll) { - const target = this._targets[this._targets.length - 1]; + const parentScrollTop = (this._rootElement || document.documentElement).scrollTop; + const userScrollsDown = parentScrollTop >= this._previousScrollData.parentScrollTop; + this._previousScrollData.parentScrollTop = parentScrollTop; - if (this._activeTarget !== target) { - this._activate(target); + for (const entry of entries) { + if (!entry.isIntersecting) { + this._activeTarget = null; + + this._clearActiveClass(targetElement(entry)); + + continue; } - return; - } + const entryIsLowerThanPrevious = entry.target.offsetTop >= this._previousScrollData.visibleEntryTop; // if we are scrolling down, pick the bigger offsetTop - if (this._activeTarget && scrollTop < this._offsets[0] && this._offsets[0] > 0) { - this._activeTarget = null; + if (userScrollsDown && entryIsLowerThanPrevious) { + activate(entry); // if parent isn't scrolled, let's keep the first visible item, breaking the iteration - this._clear(); + if (!parentScrollTop) { + return; + } - return; - } + continue; + } // if we are scrolling up, pick the smallest offsetTop - for (let i = this._offsets.length; i--;) { - const isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (typeof this._offsets[i + 1] === 'undefined' || scrollTop < this._offsets[i + 1]); - if (isActiveTarget) { - this._activate(this._targets[i]); + if (!userScrollsDown && !entryIsLowerThanPrevious) { + activate(entry); } } + } // TODO: v6 Only for backwards compatibility reasons. Use rootMargin only + + + _getRootMargin() { + return this._config.offset ? `${this._config.offset}px 0px -30%` : this._config.rootMargin; } - _activate(target) { - this._activeTarget = target; + _initializeTargetsAndObservables() { + this._targetLinks = new Map(); + this._observableSections = new Map(); + const targetLinks = SelectorEngine.find(SELECTOR_TARGET_LINKS, this._config.target); - this._clear(); + for (const anchor of targetLinks) { + // ensure that the anchor has an id and is not disabled + if (!anchor.hash || isDisabled(anchor)) { + continue; + } - const queries = SELECTOR_LINK_ITEMS.split(',').map(selector => `${selector}[data-bs-target="${target}"],${selector}[href="${target}"]`); - const link = SelectorEngine.findOne(queries.join(','), this._config.target); - link.classList.add(CLASS_NAME_ACTIVE$1); + const observableSection = SelectorEngine.findOne(anchor.hash, this._element); // ensure that the observableSection exists & is visible - if (link.classList.contains(CLASS_NAME_DROPDOWN_ITEM)) { - SelectorEngine.findOne(SELECTOR_DROPDOWN_TOGGLE$1, link.closest(SELECTOR_DROPDOWN$1)).classList.add(CLASS_NAME_ACTIVE$1); - } else { - SelectorEngine.parents(link, SELECTOR_NAV_LIST_GROUP$1).forEach(listGroup => { - // Set triggered links parents as active - // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor - SelectorEngine.prev(listGroup, `${SELECTOR_NAV_LINKS}, ${SELECTOR_LIST_ITEMS}`).forEach(item => item.classList.add(CLASS_NAME_ACTIVE$1)); // Handle special case when .nav-link is inside .nav-item + if (isVisible(observableSection)) { + this._targetLinks.set(anchor.hash, anchor); - SelectorEngine.prev(listGroup, SELECTOR_NAV_ITEMS).forEach(navItem => { - SelectorEngine.children(navItem, SELECTOR_NAV_LINKS).forEach(item => item.classList.add(CLASS_NAME_ACTIVE$1)); - }); - }); + this._observableSections.set(anchor.hash, observableSection); + } + } + } + + _process(target) { + if (this._activeTarget === target) { + return; } - EventHandler.trigger(this._scrollElement, EVENT_ACTIVATE, { + this._clearActiveClass(this._config.target); + + this._activeTarget = target; + target.classList.add(CLASS_NAME_ACTIVE$1); + + this._activateParents(target); + + EventHandler.trigger(this._element, EVENT_ACTIVATE, { relatedTarget: target }); } - _clear() { - SelectorEngine.find(SELECTOR_LINK_ITEMS, this._config.target).filter(node => node.classList.contains(CLASS_NAME_ACTIVE$1)).forEach(node => node.classList.remove(CLASS_NAME_ACTIVE$1)); + _activateParents(target) { + // Activate dropdown parents + if (target.classList.contains(CLASS_NAME_DROPDOWN_ITEM)) { + SelectorEngine.findOne(SELECTOR_DROPDOWN_TOGGLE$1, target.closest(SELECTOR_DROPDOWN)).classList.add(CLASS_NAME_ACTIVE$1); + return; + } + + for (const listGroup of SelectorEngine.parents(target, SELECTOR_NAV_LIST_GROUP)) { + // Set triggered links parents as active + // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor + for (const item of SelectorEngine.prev(listGroup, SELECTOR_LINK_ITEMS)) { + item.classList.add(CLASS_NAME_ACTIVE$1); + } + } + } + + _clearActiveClass(parent) { + parent.classList.remove(CLASS_NAME_ACTIVE$1); + const activeNodes = SelectorEngine.find(`${SELECTOR_TARGET_LINKS}.${CLASS_NAME_ACTIVE$1}`, parent); + + for (const node of activeNodes) { + node.classList.remove(CLASS_NAME_ACTIVE$1); + } } // Static @@ -4563,7 +4669,7 @@ return; } - if (typeof data[config] === 'undefined') { + if (data[config] === undefined || config.startsWith('_') || config === 'constructor') { throw new TypeError(`No method named "${config}"`); } @@ -4573,176 +4679,283 @@ } /** - * ------------------------------------------------------------------------ - * Data Api implementation - * ------------------------------------------------------------------------ + * Data API implementation */ - EventHandler.on(window, EVENT_LOAD_DATA_API, () => { - SelectorEngine.find(SELECTOR_DATA_SPY).forEach(spy => new ScrollSpy(spy)); + EventHandler.on(window, EVENT_LOAD_DATA_API$1, () => { + for (const spy of SelectorEngine.find(SELECTOR_DATA_SPY)) { + ScrollSpy.getOrCreateInstance(spy); + } }); /** - * ------------------------------------------------------------------------ * jQuery - * ------------------------------------------------------------------------ - * add .ScrollSpy to jQuery only if jQuery is present */ defineJQueryPlugin(ScrollSpy); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): tab.js + * Bootstrap (v5.2.0): tab.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** - * ------------------------------------------------------------------------ * Constants - * ------------------------------------------------------------------------ */ const NAME$1 = 'tab'; const DATA_KEY$1 = 'bs.tab'; const EVENT_KEY$1 = `.${DATA_KEY$1}`; - const DATA_API_KEY = '.data-api'; const EVENT_HIDE$1 = `hide${EVENT_KEY$1}`; const EVENT_HIDDEN$1 = `hidden${EVENT_KEY$1}`; const EVENT_SHOW$1 = `show${EVENT_KEY$1}`; const EVENT_SHOWN$1 = `shown${EVENT_KEY$1}`; - const EVENT_CLICK_DATA_API = `click${EVENT_KEY$1}${DATA_API_KEY}`; - const CLASS_NAME_DROPDOWN_MENU = 'dropdown-menu'; + const EVENT_CLICK_DATA_API = `click${EVENT_KEY$1}`; + const EVENT_KEYDOWN = `keydown${EVENT_KEY$1}`; + const EVENT_LOAD_DATA_API = `load${EVENT_KEY$1}`; + const ARROW_LEFT_KEY = 'ArrowLeft'; + const ARROW_RIGHT_KEY = 'ArrowRight'; + const ARROW_UP_KEY = 'ArrowUp'; + const ARROW_DOWN_KEY = 'ArrowDown'; const CLASS_NAME_ACTIVE = 'active'; const CLASS_NAME_FADE$1 = 'fade'; const CLASS_NAME_SHOW$1 = 'show'; - const SELECTOR_DROPDOWN = '.dropdown'; - const SELECTOR_NAV_LIST_GROUP = '.nav, .list-group'; - const SELECTOR_ACTIVE = '.active'; - const SELECTOR_ACTIVE_UL = ':scope > li > .active'; - const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="tab"], [data-bs-toggle="pill"], [data-bs-toggle="list"]'; + const CLASS_DROPDOWN = 'dropdown'; const SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle'; - const SELECTOR_DROPDOWN_ACTIVE_CHILD = ':scope > .dropdown-menu .active'; + const SELECTOR_DROPDOWN_MENU = '.dropdown-menu'; + const SELECTOR_DROPDOWN_ITEM = '.dropdown-item'; + const NOT_SELECTOR_DROPDOWN_TOGGLE = ':not(.dropdown-toggle)'; + const SELECTOR_TAB_PANEL = '.list-group, .nav, [role="tablist"]'; + const SELECTOR_OUTER = '.nav-item, .list-group-item'; + const SELECTOR_INNER = `.nav-link${NOT_SELECTOR_DROPDOWN_TOGGLE}, .list-group-item${NOT_SELECTOR_DROPDOWN_TOGGLE}, [role="tab"]${NOT_SELECTOR_DROPDOWN_TOGGLE}`; + const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="tab"], [data-bs-toggle="pill"], [data-bs-toggle="list"]'; // todo:v6: could be only `tab` + + const SELECTOR_INNER_ELEM = `${SELECTOR_INNER}, ${SELECTOR_DATA_TOGGLE}`; + const SELECTOR_DATA_TOGGLE_ACTIVE = `.${CLASS_NAME_ACTIVE}[data-bs-toggle="tab"], .${CLASS_NAME_ACTIVE}[data-bs-toggle="pill"], .${CLASS_NAME_ACTIVE}[data-bs-toggle="list"]`; /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ + * Class definition */ class Tab extends BaseComponent { - // Getters + constructor(element) { + super(element); + this._parent = this._element.closest(SELECTOR_TAB_PANEL); + + if (!this._parent) { + return; // todo: should Throw exception on v6 + // throw new TypeError(`${element.outerHTML} has not a valid parent ${SELECTOR_INNER_ELEM}`) + } // Set up initial aria attributes + + + this._setInitialAttributes(this._parent, this._getChildren()); + + EventHandler.on(this._element, EVENT_KEYDOWN, event => this._keydown(event)); + } // Getters + + static get NAME() { return NAME$1; } // Public show() { - if (this._element.parentNode && this._element.parentNode.nodeType === Node.ELEMENT_NODE && this._element.classList.contains(CLASS_NAME_ACTIVE)) { + // Shows this elem and deactivate the active sibling if exists + const innerElem = this._element; + + if (this._elemIsActive(innerElem)) { return; - } + } // Search for active tab on same parent to deactivate it - let previous; - const target = getElementFromSelector(this._element); - const listElement = this._element.closest(SELECTOR_NAV_LIST_GROUP); + const active = this._getActiveElem(); - if (listElement) { - const itemSelector = listElement.nodeName === 'UL' || listElement.nodeName === 'OL' ? SELECTOR_ACTIVE_UL : SELECTOR_ACTIVE; - previous = SelectorEngine.find(itemSelector, listElement); - previous = previous[previous.length - 1]; - } - - const hideEvent = previous ? EventHandler.trigger(previous, EVENT_HIDE$1, { - relatedTarget: this._element + const hideEvent = active ? EventHandler.trigger(active, EVENT_HIDE$1, { + relatedTarget: innerElem }) : null; - const showEvent = EventHandler.trigger(this._element, EVENT_SHOW$1, { - relatedTarget: previous + const showEvent = EventHandler.trigger(innerElem, EVENT_SHOW$1, { + relatedTarget: active }); - if (showEvent.defaultPrevented || hideEvent !== null && hideEvent.defaultPrevented) { + if (showEvent.defaultPrevented || hideEvent && hideEvent.defaultPrevented) { return; } - this._activate(this._element, listElement); + this._deactivate(active, innerElem); + + this._activate(innerElem, active); + } // Private + + + _activate(element, relatedElem) { + if (!element) { + return; + } + + element.classList.add(CLASS_NAME_ACTIVE); + + this._activate(getElementFromSelector(element)); // Search and activate/show the proper section + const complete = () => { - EventHandler.trigger(previous, EVENT_HIDDEN$1, { - relatedTarget: this._element + if (element.getAttribute('role') !== 'tab') { + element.classList.add(CLASS_NAME_SHOW$1); + return; + } + + element.focus(); + element.removeAttribute('tabindex'); + element.setAttribute('aria-selected', true); + + this._toggleDropDown(element, true); + + EventHandler.trigger(element, EVENT_SHOWN$1, { + relatedTarget: relatedElem }); - EventHandler.trigger(this._element, EVENT_SHOWN$1, { - relatedTarget: previous + }; + + this._queueCallback(complete, element, element.classList.contains(CLASS_NAME_FADE$1)); + } + + _deactivate(element, relatedElem) { + if (!element) { + return; + } + + element.classList.remove(CLASS_NAME_ACTIVE); + element.blur(); + + this._deactivate(getElementFromSelector(element)); // Search and deactivate the shown section too + + + const complete = () => { + if (element.getAttribute('role') !== 'tab') { + element.classList.remove(CLASS_NAME_SHOW$1); + return; + } + + element.setAttribute('aria-selected', false); + element.setAttribute('tabindex', '-1'); + + this._toggleDropDown(element, false); + + EventHandler.trigger(element, EVENT_HIDDEN$1, { + relatedTarget: relatedElem }); }; - if (target) { - this._activate(target, target.parentNode, complete); - } else { - complete(); + this._queueCallback(complete, element, element.classList.contains(CLASS_NAME_FADE$1)); + } + + _keydown(event) { + if (![ARROW_LEFT_KEY, ARROW_RIGHT_KEY, ARROW_UP_KEY, ARROW_DOWN_KEY].includes(event.key)) { + return; } - } // Private + event.stopPropagation(); // stopPropagation/preventDefault both added to support up/down keys without scrolling the page + + event.preventDefault(); + const isNext = [ARROW_RIGHT_KEY, ARROW_DOWN_KEY].includes(event.key); + const nextActiveElement = getNextActiveElement(this._getChildren().filter(element => !isDisabled(element)), event.target, isNext, true); - _activate(element, container, callback) { - const activeElements = container && (container.nodeName === 'UL' || container.nodeName === 'OL') ? SelectorEngine.find(SELECTOR_ACTIVE_UL, container) : SelectorEngine.children(container, SELECTOR_ACTIVE); - const active = activeElements[0]; - const isTransitioning = callback && active && active.classList.contains(CLASS_NAME_FADE$1); + if (nextActiveElement) { + Tab.getOrCreateInstance(nextActiveElement).show(); + } + } - const complete = () => this._transitionComplete(element, active, callback); + _getChildren() { + // collection of inner elements + return SelectorEngine.find(SELECTOR_INNER_ELEM, this._parent); + } - if (active && isTransitioning) { - active.classList.remove(CLASS_NAME_SHOW$1); + _getActiveElem() { + return this._getChildren().find(child => this._elemIsActive(child)) || null; + } - this._queueCallback(complete, element, true); - } else { - complete(); + _setInitialAttributes(parent, children) { + this._setAttributeIfNotExists(parent, 'role', 'tablist'); + + for (const child of children) { + this._setInitialAttributesOnChild(child); } } - _transitionComplete(element, active, callback) { - if (active) { - active.classList.remove(CLASS_NAME_ACTIVE); - const dropdownChild = SelectorEngine.findOne(SELECTOR_DROPDOWN_ACTIVE_CHILD, active.parentNode); + _setInitialAttributesOnChild(child) { + child = this._getInnerElement(child); - if (dropdownChild) { - dropdownChild.classList.remove(CLASS_NAME_ACTIVE); - } + const isActive = this._elemIsActive(child); - if (active.getAttribute('role') === 'tab') { - active.setAttribute('aria-selected', false); - } + const outerElem = this._getOuterElement(child); + + child.setAttribute('aria-selected', isActive); + + if (outerElem !== child) { + this._setAttributeIfNotExists(outerElem, 'role', 'presentation'); } - element.classList.add(CLASS_NAME_ACTIVE); + if (!isActive) { + child.setAttribute('tabindex', '-1'); + } - if (element.getAttribute('role') === 'tab') { - element.setAttribute('aria-selected', true); + this._setAttributeIfNotExists(child, 'role', 'tab'); // set attributes to the related panel too + + + this._setInitialAttributesOnTargetPanel(child); + } + + _setInitialAttributesOnTargetPanel(child) { + const target = getElementFromSelector(child); + + if (!target) { + return; } - reflow(element); + this._setAttributeIfNotExists(target, 'role', 'tabpanel'); - if (element.classList.contains(CLASS_NAME_FADE$1)) { - element.classList.add(CLASS_NAME_SHOW$1); + if (child.id) { + this._setAttributeIfNotExists(target, 'aria-labelledby', `#${child.id}`); } + } - let parent = element.parentNode; + _toggleDropDown(element, open) { + const outerElem = this._getOuterElement(element); - if (parent && parent.nodeName === 'LI') { - parent = parent.parentNode; + if (!outerElem.classList.contains(CLASS_DROPDOWN)) { + return; } - if (parent && parent.classList.contains(CLASS_NAME_DROPDOWN_MENU)) { - const dropdownElement = element.closest(SELECTOR_DROPDOWN); + const toggle = (selector, className) => { + const element = SelectorEngine.findOne(selector, outerElem); - if (dropdownElement) { - SelectorEngine.find(SELECTOR_DROPDOWN_TOGGLE, dropdownElement).forEach(dropdown => dropdown.classList.add(CLASS_NAME_ACTIVE)); + if (element) { + element.classList.toggle(className, open); } + }; - element.setAttribute('aria-expanded', true); - } + toggle(SELECTOR_DROPDOWN_TOGGLE, CLASS_NAME_ACTIVE); + toggle(SELECTOR_DROPDOWN_MENU, CLASS_NAME_SHOW$1); + toggle(SELECTOR_DROPDOWN_ITEM, CLASS_NAME_ACTIVE); + outerElem.setAttribute('aria-expanded', open); + } - if (callback) { - callback(); + _setAttributeIfNotExists(element, attribute, value) { + if (!element.hasAttribute(attribute)) { + element.setAttribute(attribute, value); } + } + + _elemIsActive(elem) { + return elem.classList.contains(CLASS_NAME_ACTIVE); + } // Try to get the inner element (usually the .nav-link) + + + _getInnerElement(elem) { + return elem.matches(SELECTOR_INNER_ELEM) ? elem : SelectorEngine.findOne(SELECTOR_INNER_ELEM, elem); + } // Try to get the outer element (usually the .nav-item) + + + _getOuterElement(elem) { + return elem.closest(SELECTOR_OUTER) || elem; } // Static @@ -4750,21 +4963,21 @@ return this.each(function () { const data = Tab.getOrCreateInstance(this); - if (typeof config === 'string') { - if (typeof data[config] === 'undefined') { - throw new TypeError(`No method named "${config}"`); - } + if (typeof config !== 'string') { + return; + } - data[config](); + if (data[config] === undefined || config.startsWith('_') || config === 'constructor') { + throw new TypeError(`No method named "${config}"`); } + + data[config](); }); } } /** - * ------------------------------------------------------------------------ - * Data Api implementation - * ------------------------------------------------------------------------ + * Data API implementation */ @@ -4777,28 +4990,31 @@ return; } - const data = Tab.getOrCreateInstance(this); - data.show(); + Tab.getOrCreateInstance(this).show(); + }); + /** + * Initialize on focus + */ + + EventHandler.on(window, EVENT_LOAD_DATA_API, () => { + for (const element of SelectorEngine.find(SELECTOR_DATA_TOGGLE_ACTIVE)) { + Tab.getOrCreateInstance(element); + } }); /** - * ------------------------------------------------------------------------ * jQuery - * ------------------------------------------------------------------------ - * add .Tab to jQuery only if jQuery is present */ defineJQueryPlugin(Tab); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): toast.js + * Bootstrap (v5.2.0): toast.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** - * ------------------------------------------------------------------------ * Constants - * ------------------------------------------------------------------------ */ const NAME = 'toast'; @@ -4828,15 +5044,12 @@ delay: 5000 }; /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ + * Class definition */ class Toast extends BaseComponent { constructor(element, config) { - super(element); - this._config = this._getConfig(config); + super(element, config); this._timeout = null; this._hasMouseInteraction = false; this._hasKeyboardInteraction = false; @@ -4845,14 +5058,14 @@ } // Getters - static get DefaultType() { - return DefaultType; - } - static get Default() { return Default; } + static get DefaultType() { + return DefaultType; + } + static get NAME() { return NAME; } // Public @@ -4884,15 +5097,13 @@ reflow(this._element); - this._element.classList.add(CLASS_NAME_SHOW); - - this._element.classList.add(CLASS_NAME_SHOWING); + this._element.classList.add(CLASS_NAME_SHOW, CLASS_NAME_SHOWING); this._queueCallback(complete, this._element, this._config.animation); } hide() { - if (!this._element.classList.contains(CLASS_NAME_SHOW)) { + if (!this.isShown()) { return; } @@ -4906,9 +5117,7 @@ this._element.classList.add(CLASS_NAME_HIDE); // @deprecated - this._element.classList.remove(CLASS_NAME_SHOWING); - - this._element.classList.remove(CLASS_NAME_SHOW); + this._element.classList.remove(CLASS_NAME_SHOWING, CLASS_NAME_SHOW); EventHandler.trigger(this._element, EVENT_HIDDEN); }; @@ -4921,22 +5130,17 @@ dispose() { this._clearTimeout(); - if (this._element.classList.contains(CLASS_NAME_SHOW)) { + if (this.isShown()) { this._element.classList.remove(CLASS_NAME_SHOW); } super.dispose(); - } // Private + } + isShown() { + return this._element.classList.contains(CLASS_NAME_SHOW); + } // Private - _getConfig(config) { - config = { ...Default, - ...Manipulator.getDataAttributes(this._element), - ...(typeof config === 'object' && config ? config : {}) - }; - typeCheckConfig(NAME, config, this.constructor.DefaultType); - return config; - } _maybeScheduleHide() { if (!this._config.autohide) { @@ -5008,20 +5212,21 @@ } } + /** + * Data API implementation + */ + enableDismissTrigger(Toast); /** - * ------------------------------------------------------------------------ * jQuery - * ------------------------------------------------------------------------ - * add .Toast to jQuery only if jQuery is present */ defineJQueryPlugin(Toast); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): index.umd.js + * Bootstrap (v5.2.0): index.umd.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ diff --git a/assets/javascripts/bootstrap.min.js b/assets/javascripts/bootstrap.min.js index 00e3766..bd1a36c 100644 --- a/assets/javascripts/bootstrap.min.js +++ b/assets/javascripts/bootstrap.min.js @@ -1,6 +1,6 @@ /*! - * Bootstrap v5.1.3 (https://getbootstrap.com/) - * Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) + * Bootstrap v5.2.0 (https://getbootstrap.com/) + * Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ -!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("@popperjs/core")):"function"==typeof define&&define.amd?define(["@popperjs/core"],e):(t="undefined"!=typeof globalThis?globalThis:t||self).bootstrap=e(t.Popper)}(this,(function(t){"use strict";function e(t){if(t&&t.__esModule)return t;const e=Object.create(null);if(t)for(const i in t)if("default"!==i){const s=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:()=>t[i]})}return e.default=t,Object.freeze(e)}const i=e(t),s="transitionend",n=t=>{let e=t.getAttribute("data-bs-target");if(!e||"#"===e){let i=t.getAttribute("href");if(!i||!i.includes("#")&&!i.startsWith("."))return null;i.includes("#")&&!i.startsWith("#")&&(i=`#${i.split("#")[1]}`),e=i&&"#"!==i?i.trim():null}return e},o=t=>{const e=n(t);return e&&document.querySelector(e)?e:null},r=t=>{const e=n(t);return e?document.querySelector(e):null},a=t=>{t.dispatchEvent(new Event(s))},l=t=>!(!t||"object"!=typeof t)&&(void 0!==t.jquery&&(t=t[0]),void 0!==t.nodeType),c=t=>l(t)?t.jquery?t[0]:t:"string"==typeof t&&t.length>0?document.querySelector(t):null,h=(t,e,i)=>{Object.keys(i).forEach((s=>{const n=i[s],o=e[s],r=o&&l(o)?"element":null==(a=o)?`${a}`:{}.toString.call(a).match(/\s([a-z]+)/i)[1].toLowerCase();var a;if(!new RegExp(n).test(r))throw new TypeError(`${t.toUpperCase()}: Option "${s}" provided type "${r}" but expected type "${n}".`)}))},d=t=>!(!l(t)||0===t.getClientRects().length)&&"visible"===getComputedStyle(t).getPropertyValue("visibility"),u=t=>!t||t.nodeType!==Node.ELEMENT_NODE||!!t.classList.contains("disabled")||(void 0!==t.disabled?t.disabled:t.hasAttribute("disabled")&&"false"!==t.getAttribute("disabled")),g=t=>{if(!document.documentElement.attachShadow)return null;if("function"==typeof t.getRootNode){const e=t.getRootNode();return e instanceof ShadowRoot?e:null}return t instanceof ShadowRoot?t:t.parentNode?g(t.parentNode):null},_=()=>{},f=t=>{t.offsetHeight},p=()=>{const{jQuery:t}=window;return t&&!document.body.hasAttribute("data-bs-no-jquery")?t:null},m=[],b=()=>"rtl"===document.documentElement.dir,v=t=>{var e;e=()=>{const e=p();if(e){const i=t.NAME,s=e.fn[i];e.fn[i]=t.jQueryInterface,e.fn[i].Constructor=t,e.fn[i].noConflict=()=>(e.fn[i]=s,t.jQueryInterface)}},"loading"===document.readyState?(m.length||document.addEventListener("DOMContentLoaded",(()=>{m.forEach((t=>t()))})),m.push(e)):e()},y=t=>{"function"==typeof t&&t()},E=(t,e,i=!0)=>{if(!i)return void y(t);const n=(t=>{if(!t)return 0;let{transitionDuration:e,transitionDelay:i}=window.getComputedStyle(t);const s=Number.parseFloat(e),n=Number.parseFloat(i);return s||n?(e=e.split(",")[0],i=i.split(",")[0],1e3*(Number.parseFloat(e)+Number.parseFloat(i))):0})(e)+5;let o=!1;const r=({target:i})=>{i===e&&(o=!0,e.removeEventListener(s,r),y(t))};e.addEventListener(s,r),setTimeout((()=>{o||a(e)}),n)},w=(t,e,i,s)=>{let n=t.indexOf(e);if(-1===n)return t[!i&&s?t.length-1:0];const o=t.length;return n+=i?1:-1,s&&(n=(n+o)%o),t[Math.max(0,Math.min(n,o-1))]},A=/[^.]*(?=\..*)\.|.*/,T=/\..*/,C=/::\d+$/,k={};let L=1;const S={mouseenter:"mouseover",mouseleave:"mouseout"},O=/^(mouseenter|mouseleave)/i,N=new Set(["click","dblclick","mouseup","mousedown","contextmenu","mousewheel","DOMMouseScroll","mouseover","mouseout","mousemove","selectstart","selectend","keydown","keypress","keyup","orientationchange","touchstart","touchmove","touchend","touchcancel","pointerdown","pointermove","pointerup","pointerleave","pointercancel","gesturestart","gesturechange","gestureend","focus","blur","change","reset","select","submit","focusin","focusout","load","unload","beforeunload","resize","move","DOMContentLoaded","readystatechange","error","abort","scroll"]);function D(t,e){return e&&`${e}::${L++}`||t.uidEvent||L++}function I(t){const e=D(t);return t.uidEvent=e,k[e]=k[e]||{},k[e]}function P(t,e,i=null){const s=Object.keys(t);for(let n=0,o=s.length;n<o;n++){const o=t[s[n]];if(o.originalHandler===e&&o.delegationSelector===i)return o}return null}function x(t,e,i){const s="string"==typeof e,n=s?i:e;let o=H(t);return N.has(o)||(o=t),[s,n,o]}function M(t,e,i,s,n){if("string"!=typeof e||!t)return;if(i||(i=s,s=null),O.test(e)){const t=t=>function(e){if(!e.relatedTarget||e.relatedTarget!==e.delegateTarget&&!e.delegateTarget.contains(e.relatedTarget))return t.call(this,e)};s?s=t(s):i=t(i)}const[o,r,a]=x(e,i,s),l=I(t),c=l[a]||(l[a]={}),h=P(c,r,o?i:null);if(h)return void(h.oneOff=h.oneOff&&n);const d=D(r,e.replace(A,"")),u=o?function(t,e,i){return function s(n){const o=t.querySelectorAll(e);for(let{target:r}=n;r&&r!==this;r=r.parentNode)for(let a=o.length;a--;)if(o[a]===r)return n.delegateTarget=r,s.oneOff&&$.off(t,n.type,e,i),i.apply(r,[n]);return null}}(t,i,s):function(t,e){return function i(s){return s.delegateTarget=t,i.oneOff&&$.off(t,s.type,e),e.apply(t,[s])}}(t,i);u.delegationSelector=o?i:null,u.originalHandler=r,u.oneOff=n,u.uidEvent=d,c[d]=u,t.addEventListener(a,u,o)}function j(t,e,i,s,n){const o=P(e[i],s,n);o&&(t.removeEventListener(i,o,Boolean(n)),delete e[i][o.uidEvent])}function H(t){return t=t.replace(T,""),S[t]||t}const $={on(t,e,i,s){M(t,e,i,s,!1)},one(t,e,i,s){M(t,e,i,s,!0)},off(t,e,i,s){if("string"!=typeof e||!t)return;const[n,o,r]=x(e,i,s),a=r!==e,l=I(t),c=e.startsWith(".");if(void 0!==o){if(!l||!l[r])return;return void j(t,l,r,o,n?i:null)}c&&Object.keys(l).forEach((i=>{!function(t,e,i,s){const n=e[i]||{};Object.keys(n).forEach((o=>{if(o.includes(s)){const s=n[o];j(t,e,i,s.originalHandler,s.delegationSelector)}}))}(t,l,i,e.slice(1))}));const h=l[r]||{};Object.keys(h).forEach((i=>{const s=i.replace(C,"");if(!a||e.includes(s)){const e=h[i];j(t,l,r,e.originalHandler,e.delegationSelector)}}))},trigger(t,e,i){if("string"!=typeof e||!t)return null;const s=p(),n=H(e),o=e!==n,r=N.has(n);let a,l=!0,c=!0,h=!1,d=null;return o&&s&&(a=s.Event(e,i),s(t).trigger(a),l=!a.isPropagationStopped(),c=!a.isImmediatePropagationStopped(),h=a.isDefaultPrevented()),r?(d=document.createEvent("HTMLEvents"),d.initEvent(n,l,!0)):d=new CustomEvent(e,{bubbles:l,cancelable:!0}),void 0!==i&&Object.keys(i).forEach((t=>{Object.defineProperty(d,t,{get:()=>i[t]})})),h&&d.preventDefault(),c&&t.dispatchEvent(d),d.defaultPrevented&&void 0!==a&&a.preventDefault(),d}},B=new Map,z={set(t,e,i){B.has(t)||B.set(t,new Map);const s=B.get(t);s.has(e)||0===s.size?s.set(e,i):console.error(`Bootstrap doesn't allow more than one instance per element. Bound instance: ${Array.from(s.keys())[0]}.`)},get:(t,e)=>B.has(t)&&B.get(t).get(e)||null,remove(t,e){if(!B.has(t))return;const i=B.get(t);i.delete(e),0===i.size&&B.delete(t)}};class R{constructor(t){(t=c(t))&&(this._element=t,z.set(this._element,this.constructor.DATA_KEY,this))}dispose(){z.remove(this._element,this.constructor.DATA_KEY),$.off(this._element,this.constructor.EVENT_KEY),Object.getOwnPropertyNames(this).forEach((t=>{this[t]=null}))}_queueCallback(t,e,i=!0){E(t,e,i)}static getInstance(t){return z.get(c(t),this.DATA_KEY)}static getOrCreateInstance(t,e={}){return this.getInstance(t)||new this(t,"object"==typeof e?e:null)}static get VERSION(){return"5.1.3"}static get NAME(){throw new Error('You have to implement the static method "NAME", for each component!')}static get DATA_KEY(){return`bs.${this.NAME}`}static get EVENT_KEY(){return`.${this.DATA_KEY}`}}const F=(t,e="hide")=>{const i=`click.dismiss${t.EVENT_KEY}`,s=t.NAME;$.on(document,i,`[data-bs-dismiss="${s}"]`,(function(i){if(["A","AREA"].includes(this.tagName)&&i.preventDefault(),u(this))return;const n=r(this)||this.closest(`.${s}`);t.getOrCreateInstance(n)[e]()}))};class q extends R{static get NAME(){return"alert"}close(){if($.trigger(this._element,"close.bs.alert").defaultPrevented)return;this._element.classList.remove("show");const t=this._element.classList.contains("fade");this._queueCallback((()=>this._destroyElement()),this._element,t)}_destroyElement(){this._element.remove(),$.trigger(this._element,"closed.bs.alert"),this.dispose()}static jQueryInterface(t){return this.each((function(){const e=q.getOrCreateInstance(this);if("string"==typeof t){if(void 0===e[t]||t.startsWith("_")||"constructor"===t)throw new TypeError(`No method named "${t}"`);e[t](this)}}))}}F(q,"close"),v(q);const W='[data-bs-toggle="button"]';class U extends R{static get NAME(){return"button"}toggle(){this._element.setAttribute("aria-pressed",this._element.classList.toggle("active"))}static jQueryInterface(t){return this.each((function(){const e=U.getOrCreateInstance(this);"toggle"===t&&e[t]()}))}}function K(t){return"true"===t||"false"!==t&&(t===Number(t).toString()?Number(t):""===t||"null"===t?null:t)}function V(t){return t.replace(/[A-Z]/g,(t=>`-${t.toLowerCase()}`))}$.on(document,"click.bs.button.data-api",W,(t=>{t.preventDefault();const e=t.target.closest(W);U.getOrCreateInstance(e).toggle()})),v(U);const X={setDataAttribute(t,e,i){t.setAttribute(`data-bs-${V(e)}`,i)},removeDataAttribute(t,e){t.removeAttribute(`data-bs-${V(e)}`)},getDataAttributes(t){if(!t)return{};const e={};return Object.keys(t.dataset).filter((t=>t.startsWith("bs"))).forEach((i=>{let s=i.replace(/^bs/,"");s=s.charAt(0).toLowerCase()+s.slice(1,s.length),e[s]=K(t.dataset[i])})),e},getDataAttribute:(t,e)=>K(t.getAttribute(`data-bs-${V(e)}`)),offset(t){const e=t.getBoundingClientRect();return{top:e.top+window.pageYOffset,left:e.left+window.pageXOffset}},position:t=>({top:t.offsetTop,left:t.offsetLeft})},Y={find:(t,e=document.documentElement)=>[].concat(...Element.prototype.querySelectorAll.call(e,t)),findOne:(t,e=document.documentElement)=>Element.prototype.querySelector.call(e,t),children:(t,e)=>[].concat(...t.children).filter((t=>t.matches(e))),parents(t,e){const i=[];let s=t.parentNode;for(;s&&s.nodeType===Node.ELEMENT_NODE&&3!==s.nodeType;)s.matches(e)&&i.push(s),s=s.parentNode;return i},prev(t,e){let i=t.previousElementSibling;for(;i;){if(i.matches(e))return[i];i=i.previousElementSibling}return[]},next(t,e){let i=t.nextElementSibling;for(;i;){if(i.matches(e))return[i];i=i.nextElementSibling}return[]},focusableChildren(t){const e=["a","button","input","textarea","select","details","[tabindex]",'[contenteditable="true"]'].map((t=>`${t}:not([tabindex^="-"])`)).join(", ");return this.find(e,t).filter((t=>!u(t)&&d(t)))}},Q="carousel",G={interval:5e3,keyboard:!0,slide:!1,pause:"hover",wrap:!0,touch:!0},Z={interval:"(number|boolean)",keyboard:"boolean",slide:"(boolean|string)",pause:"(string|boolean)",wrap:"boolean",touch:"boolean"},J="next",tt="prev",et="left",it="right",st={ArrowLeft:it,ArrowRight:et},nt="slid.bs.carousel",ot="active",rt=".active.carousel-item";class at extends R{constructor(t,e){super(t),this._items=null,this._interval=null,this._activeElement=null,this._isPaused=!1,this._isSliding=!1,this.touchTimeout=null,this.touchStartX=0,this.touchDeltaX=0,this._config=this._getConfig(e),this._indicatorsElement=Y.findOne(".carousel-indicators",this._element),this._touchSupported="ontouchstart"in document.documentElement||navigator.maxTouchPoints>0,this._pointerEvent=Boolean(window.PointerEvent),this._addEventListeners()}static get Default(){return G}static get NAME(){return Q}next(){this._slide(J)}nextWhenVisible(){!document.hidden&&d(this._element)&&this.next()}prev(){this._slide(tt)}pause(t){t||(this._isPaused=!0),Y.findOne(".carousel-item-next, .carousel-item-prev",this._element)&&(a(this._element),this.cycle(!0)),clearInterval(this._interval),this._interval=null}cycle(t){t||(this._isPaused=!1),this._interval&&(clearInterval(this._interval),this._interval=null),this._config&&this._config.interval&&!this._isPaused&&(this._updateInterval(),this._interval=setInterval((document.visibilityState?this.nextWhenVisible:this.next).bind(this),this._config.interval))}to(t){this._activeElement=Y.findOne(rt,this._element);const e=this._getItemIndex(this._activeElement);if(t>this._items.length-1||t<0)return;if(this._isSliding)return void $.one(this._element,nt,(()=>this.to(t)));if(e===t)return this.pause(),void this.cycle();const i=t>e?J:tt;this._slide(i,this._items[t])}_getConfig(t){return t={...G,...X.getDataAttributes(this._element),..."object"==typeof t?t:{}},h(Q,t,Z),t}_handleSwipe(){const t=Math.abs(this.touchDeltaX);if(t<=40)return;const e=t/this.touchDeltaX;this.touchDeltaX=0,e&&this._slide(e>0?it:et)}_addEventListeners(){this._config.keyboard&&$.on(this._element,"keydown.bs.carousel",(t=>this._keydown(t))),"hover"===this._config.pause&&($.on(this._element,"mouseenter.bs.carousel",(t=>this.pause(t))),$.on(this._element,"mouseleave.bs.carousel",(t=>this.cycle(t)))),this._config.touch&&this._touchSupported&&this._addTouchEventListeners()}_addTouchEventListeners(){const t=t=>this._pointerEvent&&("pen"===t.pointerType||"touch"===t.pointerType),e=e=>{t(e)?this.touchStartX=e.clientX:this._pointerEvent||(this.touchStartX=e.touches[0].clientX)},i=t=>{this.touchDeltaX=t.touches&&t.touches.length>1?0:t.touches[0].clientX-this.touchStartX},s=e=>{t(e)&&(this.touchDeltaX=e.clientX-this.touchStartX),this._handleSwipe(),"hover"===this._config.pause&&(this.pause(),this.touchTimeout&&clearTimeout(this.touchTimeout),this.touchTimeout=setTimeout((t=>this.cycle(t)),500+this._config.interval))};Y.find(".carousel-item img",this._element).forEach((t=>{$.on(t,"dragstart.bs.carousel",(t=>t.preventDefault()))})),this._pointerEvent?($.on(this._element,"pointerdown.bs.carousel",(t=>e(t))),$.on(this._element,"pointerup.bs.carousel",(t=>s(t))),this._element.classList.add("pointer-event")):($.on(this._element,"touchstart.bs.carousel",(t=>e(t))),$.on(this._element,"touchmove.bs.carousel",(t=>i(t))),$.on(this._element,"touchend.bs.carousel",(t=>s(t))))}_keydown(t){if(/input|textarea/i.test(t.target.tagName))return;const e=st[t.key];e&&(t.preventDefault(),this._slide(e))}_getItemIndex(t){return this._items=t&&t.parentNode?Y.find(".carousel-item",t.parentNode):[],this._items.indexOf(t)}_getItemByOrder(t,e){const i=t===J;return w(this._items,e,i,this._config.wrap)}_triggerSlideEvent(t,e){const i=this._getItemIndex(t),s=this._getItemIndex(Y.findOne(rt,this._element));return $.trigger(this._element,"slide.bs.carousel",{relatedTarget:t,direction:e,from:s,to:i})}_setActiveIndicatorElement(t){if(this._indicatorsElement){const e=Y.findOne(".active",this._indicatorsElement);e.classList.remove(ot),e.removeAttribute("aria-current");const i=Y.find("[data-bs-target]",this._indicatorsElement);for(let e=0;e<i.length;e++)if(Number.parseInt(i[e].getAttribute("data-bs-slide-to"),10)===this._getItemIndex(t)){i[e].classList.add(ot),i[e].setAttribute("aria-current","true");break}}}_updateInterval(){const t=this._activeElement||Y.findOne(rt,this._element);if(!t)return;const e=Number.parseInt(t.getAttribute("data-bs-interval"),10);e?(this._config.defaultInterval=this._config.defaultInterval||this._config.interval,this._config.interval=e):this._config.interval=this._config.defaultInterval||this._config.interval}_slide(t,e){const i=this._directionToOrder(t),s=Y.findOne(rt,this._element),n=this._getItemIndex(s),o=e||this._getItemByOrder(i,s),r=this._getItemIndex(o),a=Boolean(this._interval),l=i===J,c=l?"carousel-item-start":"carousel-item-end",h=l?"carousel-item-next":"carousel-item-prev",d=this._orderToDirection(i);if(o&&o.classList.contains(ot))return void(this._isSliding=!1);if(this._isSliding)return;if(this._triggerSlideEvent(o,d).defaultPrevented)return;if(!s||!o)return;this._isSliding=!0,a&&this.pause(),this._setActiveIndicatorElement(o),this._activeElement=o;const u=()=>{$.trigger(this._element,nt,{relatedTarget:o,direction:d,from:n,to:r})};if(this._element.classList.contains("slide")){o.classList.add(h),f(o),s.classList.add(c),o.classList.add(c);const t=()=>{o.classList.remove(c,h),o.classList.add(ot),s.classList.remove(ot,h,c),this._isSliding=!1,setTimeout(u,0)};this._queueCallback(t,s,!0)}else s.classList.remove(ot),o.classList.add(ot),this._isSliding=!1,u();a&&this.cycle()}_directionToOrder(t){return[it,et].includes(t)?b()?t===et?tt:J:t===et?J:tt:t}_orderToDirection(t){return[J,tt].includes(t)?b()?t===tt?et:it:t===tt?it:et:t}static carouselInterface(t,e){const i=at.getOrCreateInstance(t,e);let{_config:s}=i;"object"==typeof e&&(s={...s,...e});const n="string"==typeof e?e:s.slide;if("number"==typeof e)i.to(e);else if("string"==typeof n){if(void 0===i[n])throw new TypeError(`No method named "${n}"`);i[n]()}else s.interval&&s.ride&&(i.pause(),i.cycle())}static jQueryInterface(t){return this.each((function(){at.carouselInterface(this,t)}))}static dataApiClickHandler(t){const e=r(this);if(!e||!e.classList.contains("carousel"))return;const i={...X.getDataAttributes(e),...X.getDataAttributes(this)},s=this.getAttribute("data-bs-slide-to");s&&(i.interval=!1),at.carouselInterface(e,i),s&&at.getInstance(e).to(s),t.preventDefault()}}$.on(document,"click.bs.carousel.data-api","[data-bs-slide], [data-bs-slide-to]",at.dataApiClickHandler),$.on(window,"load.bs.carousel.data-api",(()=>{const t=Y.find('[data-bs-ride="carousel"]');for(let e=0,i=t.length;e<i;e++)at.carouselInterface(t[e],at.getInstance(t[e]))})),v(at);const lt="collapse",ct={toggle:!0,parent:null},ht={toggle:"boolean",parent:"(null|element)"},dt="show",ut="collapse",gt="collapsing",_t="collapsed",ft=":scope .collapse .collapse",pt='[data-bs-toggle="collapse"]';class mt extends R{constructor(t,e){super(t),this._isTransitioning=!1,this._config=this._getConfig(e),this._triggerArray=[];const i=Y.find(pt);for(let t=0,e=i.length;t<e;t++){const e=i[t],s=o(e),n=Y.find(s).filter((t=>t===this._element));null!==s&&n.length&&(this._selector=s,this._triggerArray.push(e))}this._initializeChildren(),this._config.parent||this._addAriaAndCollapsedClass(this._triggerArray,this._isShown()),this._config.toggle&&this.toggle()}static get Default(){return ct}static get NAME(){return lt}toggle(){this._isShown()?this.hide():this.show()}show(){if(this._isTransitioning||this._isShown())return;let t,e=[];if(this._config.parent){const t=Y.find(ft,this._config.parent);e=Y.find(".collapse.show, .collapse.collapsing",this._config.parent).filter((e=>!t.includes(e)))}const i=Y.findOne(this._selector);if(e.length){const s=e.find((t=>i!==t));if(t=s?mt.getInstance(s):null,t&&t._isTransitioning)return}if($.trigger(this._element,"show.bs.collapse").defaultPrevented)return;e.forEach((e=>{i!==e&&mt.getOrCreateInstance(e,{toggle:!1}).hide(),t||z.set(e,"bs.collapse",null)}));const s=this._getDimension();this._element.classList.remove(ut),this._element.classList.add(gt),this._element.style[s]=0,this._addAriaAndCollapsedClass(this._triggerArray,!0),this._isTransitioning=!0;const n=`scroll${s[0].toUpperCase()+s.slice(1)}`;this._queueCallback((()=>{this._isTransitioning=!1,this._element.classList.remove(gt),this._element.classList.add(ut,dt),this._element.style[s]="",$.trigger(this._element,"shown.bs.collapse")}),this._element,!0),this._element.style[s]=`${this._element[n]}px`}hide(){if(this._isTransitioning||!this._isShown())return;if($.trigger(this._element,"hide.bs.collapse").defaultPrevented)return;const t=this._getDimension();this._element.style[t]=`${this._element.getBoundingClientRect()[t]}px`,f(this._element),this._element.classList.add(gt),this._element.classList.remove(ut,dt);const e=this._triggerArray.length;for(let t=0;t<e;t++){const e=this._triggerArray[t],i=r(e);i&&!this._isShown(i)&&this._addAriaAndCollapsedClass([e],!1)}this._isTransitioning=!0,this._element.style[t]="",this._queueCallback((()=>{this._isTransitioning=!1,this._element.classList.remove(gt),this._element.classList.add(ut),$.trigger(this._element,"hidden.bs.collapse")}),this._element,!0)}_isShown(t=this._element){return t.classList.contains(dt)}_getConfig(t){return(t={...ct,...X.getDataAttributes(this._element),...t}).toggle=Boolean(t.toggle),t.parent=c(t.parent),h(lt,t,ht),t}_getDimension(){return this._element.classList.contains("collapse-horizontal")?"width":"height"}_initializeChildren(){if(!this._config.parent)return;const t=Y.find(ft,this._config.parent);Y.find(pt,this._config.parent).filter((e=>!t.includes(e))).forEach((t=>{const e=r(t);e&&this._addAriaAndCollapsedClass([t],this._isShown(e))}))}_addAriaAndCollapsedClass(t,e){t.length&&t.forEach((t=>{e?t.classList.remove(_t):t.classList.add(_t),t.setAttribute("aria-expanded",e)}))}static jQueryInterface(t){return this.each((function(){const e={};"string"==typeof t&&/show|hide/.test(t)&&(e.toggle=!1);const i=mt.getOrCreateInstance(this,e);if("string"==typeof t){if(void 0===i[t])throw new TypeError(`No method named "${t}"`);i[t]()}}))}}$.on(document,"click.bs.collapse.data-api",pt,(function(t){("A"===t.target.tagName||t.delegateTarget&&"A"===t.delegateTarget.tagName)&&t.preventDefault();const e=o(this);Y.find(e).forEach((t=>{mt.getOrCreateInstance(t,{toggle:!1}).toggle()}))})),v(mt);const bt="dropdown",vt="Escape",yt="Space",Et="ArrowUp",wt="ArrowDown",At=new RegExp("ArrowUp|ArrowDown|Escape"),Tt="click.bs.dropdown.data-api",Ct="keydown.bs.dropdown.data-api",kt="show",Lt='[data-bs-toggle="dropdown"]',St=".dropdown-menu",Ot=b()?"top-end":"top-start",Nt=b()?"top-start":"top-end",Dt=b()?"bottom-end":"bottom-start",It=b()?"bottom-start":"bottom-end",Pt=b()?"left-start":"right-start",xt=b()?"right-start":"left-start",Mt={offset:[0,2],boundary:"clippingParents",reference:"toggle",display:"dynamic",popperConfig:null,autoClose:!0},jt={offset:"(array|string|function)",boundary:"(string|element)",reference:"(string|element|object)",display:"string",popperConfig:"(null|object|function)",autoClose:"(boolean|string)"};class Ht extends R{constructor(t,e){super(t),this._popper=null,this._config=this._getConfig(e),this._menu=this._getMenuElement(),this._inNavbar=this._detectNavbar()}static get Default(){return Mt}static get DefaultType(){return jt}static get NAME(){return bt}toggle(){return this._isShown()?this.hide():this.show()}show(){if(u(this._element)||this._isShown(this._menu))return;const t={relatedTarget:this._element};if($.trigger(this._element,"show.bs.dropdown",t).defaultPrevented)return;const e=Ht.getParentFromElement(this._element);this._inNavbar?X.setDataAttribute(this._menu,"popper","none"):this._createPopper(e),"ontouchstart"in document.documentElement&&!e.closest(".navbar-nav")&&[].concat(...document.body.children).forEach((t=>$.on(t,"mouseover",_))),this._element.focus(),this._element.setAttribute("aria-expanded",!0),this._menu.classList.add(kt),this._element.classList.add(kt),$.trigger(this._element,"shown.bs.dropdown",t)}hide(){if(u(this._element)||!this._isShown(this._menu))return;const t={relatedTarget:this._element};this._completeHide(t)}dispose(){this._popper&&this._popper.destroy(),super.dispose()}update(){this._inNavbar=this._detectNavbar(),this._popper&&this._popper.update()}_completeHide(t){$.trigger(this._element,"hide.bs.dropdown",t).defaultPrevented||("ontouchstart"in document.documentElement&&[].concat(...document.body.children).forEach((t=>$.off(t,"mouseover",_))),this._popper&&this._popper.destroy(),this._menu.classList.remove(kt),this._element.classList.remove(kt),this._element.setAttribute("aria-expanded","false"),X.removeDataAttribute(this._menu,"popper"),$.trigger(this._element,"hidden.bs.dropdown",t))}_getConfig(t){if(t={...this.constructor.Default,...X.getDataAttributes(this._element),...t},h(bt,t,this.constructor.DefaultType),"object"==typeof t.reference&&!l(t.reference)&&"function"!=typeof t.reference.getBoundingClientRect)throw new TypeError(`${bt.toUpperCase()}: Option "reference" provided type "object" without a required "getBoundingClientRect" method.`);return t}_createPopper(t){if(void 0===i)throw new TypeError("Bootstrap's dropdowns require Popper (https://popper.js.org)");let e=this._element;"parent"===this._config.reference?e=t:l(this._config.reference)?e=c(this._config.reference):"object"==typeof this._config.reference&&(e=this._config.reference);const s=this._getPopperConfig(),n=s.modifiers.find((t=>"applyStyles"===t.name&&!1===t.enabled));this._popper=i.createPopper(e,this._menu,s),n&&X.setDataAttribute(this._menu,"popper","static")}_isShown(t=this._element){return t.classList.contains(kt)}_getMenuElement(){return Y.next(this._element,St)[0]}_getPlacement(){const t=this._element.parentNode;if(t.classList.contains("dropend"))return Pt;if(t.classList.contains("dropstart"))return xt;const e="end"===getComputedStyle(this._menu).getPropertyValue("--bs-position").trim();return t.classList.contains("dropup")?e?Nt:Ot:e?It:Dt}_detectNavbar(){return null!==this._element.closest(".navbar")}_getOffset(){const{offset:t}=this._config;return"string"==typeof t?t.split(",").map((t=>Number.parseInt(t,10))):"function"==typeof t?e=>t(e,this._element):t}_getPopperConfig(){const t={placement:this._getPlacement(),modifiers:[{name:"preventOverflow",options:{boundary:this._config.boundary}},{name:"offset",options:{offset:this._getOffset()}}]};return"static"===this._config.display&&(t.modifiers=[{name:"applyStyles",enabled:!1}]),{...t,..."function"==typeof this._config.popperConfig?this._config.popperConfig(t):this._config.popperConfig}}_selectMenuItem({key:t,target:e}){const i=Y.find(".dropdown-menu .dropdown-item:not(.disabled):not(:disabled)",this._menu).filter(d);i.length&&w(i,e,t===wt,!i.includes(e)).focus()}static jQueryInterface(t){return this.each((function(){const e=Ht.getOrCreateInstance(this,t);if("string"==typeof t){if(void 0===e[t])throw new TypeError(`No method named "${t}"`);e[t]()}}))}static clearMenus(t){if(t&&(2===t.button||"keyup"===t.type&&"Tab"!==t.key))return;const e=Y.find(Lt);for(let i=0,s=e.length;i<s;i++){const s=Ht.getInstance(e[i]);if(!s||!1===s._config.autoClose)continue;if(!s._isShown())continue;const n={relatedTarget:s._element};if(t){const e=t.composedPath(),i=e.includes(s._menu);if(e.includes(s._element)||"inside"===s._config.autoClose&&!i||"outside"===s._config.autoClose&&i)continue;if(s._menu.contains(t.target)&&("keyup"===t.type&&"Tab"===t.key||/input|select|option|textarea|form/i.test(t.target.tagName)))continue;"click"===t.type&&(n.clickEvent=t)}s._completeHide(n)}}static getParentFromElement(t){return r(t)||t.parentNode}static dataApiKeydownHandler(t){if(/input|textarea/i.test(t.target.tagName)?t.key===yt||t.key!==vt&&(t.key!==wt&&t.key!==Et||t.target.closest(St)):!At.test(t.key))return;const e=this.classList.contains(kt);if(!e&&t.key===vt)return;if(t.preventDefault(),t.stopPropagation(),u(this))return;const i=this.matches(Lt)?this:Y.prev(this,Lt)[0],s=Ht.getOrCreateInstance(i);if(t.key!==vt)return t.key===Et||t.key===wt?(e||s.show(),void s._selectMenuItem(t)):void(e&&t.key!==yt||Ht.clearMenus());s.hide()}}$.on(document,Ct,Lt,Ht.dataApiKeydownHandler),$.on(document,Ct,St,Ht.dataApiKeydownHandler),$.on(document,Tt,Ht.clearMenus),$.on(document,"keyup.bs.dropdown.data-api",Ht.clearMenus),$.on(document,Tt,Lt,(function(t){t.preventDefault(),Ht.getOrCreateInstance(this).toggle()})),v(Ht);const $t=".fixed-top, .fixed-bottom, .is-fixed, .sticky-top",Bt=".sticky-top";class zt{constructor(){this._element=document.body}getWidth(){const t=document.documentElement.clientWidth;return Math.abs(window.innerWidth-t)}hide(){const t=this.getWidth();this._disableOverFlow(),this._setElementAttributes(this._element,"paddingRight",(e=>e+t)),this._setElementAttributes($t,"paddingRight",(e=>e+t)),this._setElementAttributes(Bt,"marginRight",(e=>e-t))}_disableOverFlow(){this._saveInitialAttribute(this._element,"overflow"),this._element.style.overflow="hidden"}_setElementAttributes(t,e,i){const s=this.getWidth();this._applyManipulationCallback(t,(t=>{if(t!==this._element&&window.innerWidth>t.clientWidth+s)return;this._saveInitialAttribute(t,e);const n=window.getComputedStyle(t)[e];t.style[e]=`${i(Number.parseFloat(n))}px`}))}reset(){this._resetElementAttributes(this._element,"overflow"),this._resetElementAttributes(this._element,"paddingRight"),this._resetElementAttributes($t,"paddingRight"),this._resetElementAttributes(Bt,"marginRight")}_saveInitialAttribute(t,e){const i=t.style[e];i&&X.setDataAttribute(t,e,i)}_resetElementAttributes(t,e){this._applyManipulationCallback(t,(t=>{const i=X.getDataAttribute(t,e);void 0===i?t.style.removeProperty(e):(X.removeDataAttribute(t,e),t.style[e]=i)}))}_applyManipulationCallback(t,e){l(t)?e(t):Y.find(t,this._element).forEach(e)}isOverflowing(){return this.getWidth()>0}}const Rt={className:"modal-backdrop",isVisible:!0,isAnimated:!1,rootElement:"body",clickCallback:null},Ft={className:"string",isVisible:"boolean",isAnimated:"boolean",rootElement:"(element|string)",clickCallback:"(function|null)"},qt="show",Wt="mousedown.bs.backdrop";class Ut{constructor(t){this._config=this._getConfig(t),this._isAppended=!1,this._element=null}show(t){this._config.isVisible?(this._append(),this._config.isAnimated&&f(this._getElement()),this._getElement().classList.add(qt),this._emulateAnimation((()=>{y(t)}))):y(t)}hide(t){this._config.isVisible?(this._getElement().classList.remove(qt),this._emulateAnimation((()=>{this.dispose(),y(t)}))):y(t)}_getElement(){if(!this._element){const t=document.createElement("div");t.className=this._config.className,this._config.isAnimated&&t.classList.add("fade"),this._element=t}return this._element}_getConfig(t){return(t={...Rt,..."object"==typeof t?t:{}}).rootElement=c(t.rootElement),h("backdrop",t,Ft),t}_append(){this._isAppended||(this._config.rootElement.append(this._getElement()),$.on(this._getElement(),Wt,(()=>{y(this._config.clickCallback)})),this._isAppended=!0)}dispose(){this._isAppended&&($.off(this._element,Wt),this._element.remove(),this._isAppended=!1)}_emulateAnimation(t){E(t,this._getElement(),this._config.isAnimated)}}const Kt={trapElement:null,autofocus:!0},Vt={trapElement:"element",autofocus:"boolean"},Xt=".bs.focustrap",Yt="backward";class Qt{constructor(t){this._config=this._getConfig(t),this._isActive=!1,this._lastTabNavDirection=null}activate(){const{trapElement:t,autofocus:e}=this._config;this._isActive||(e&&t.focus(),$.off(document,Xt),$.on(document,"focusin.bs.focustrap",(t=>this._handleFocusin(t))),$.on(document,"keydown.tab.bs.focustrap",(t=>this._handleKeydown(t))),this._isActive=!0)}deactivate(){this._isActive&&(this._isActive=!1,$.off(document,Xt))}_handleFocusin(t){const{target:e}=t,{trapElement:i}=this._config;if(e===document||e===i||i.contains(e))return;const s=Y.focusableChildren(i);0===s.length?i.focus():this._lastTabNavDirection===Yt?s[s.length-1].focus():s[0].focus()}_handleKeydown(t){"Tab"===t.key&&(this._lastTabNavDirection=t.shiftKey?Yt:"forward")}_getConfig(t){return t={...Kt,..."object"==typeof t?t:{}},h("focustrap",t,Vt),t}}const Gt="modal",Zt="Escape",Jt={backdrop:!0,keyboard:!0,focus:!0},te={backdrop:"(boolean|string)",keyboard:"boolean",focus:"boolean"},ee="hidden.bs.modal",ie="show.bs.modal",se="resize.bs.modal",ne="click.dismiss.bs.modal",oe="keydown.dismiss.bs.modal",re="mousedown.dismiss.bs.modal",ae="modal-open",le="show",ce="modal-static";class he extends R{constructor(t,e){super(t),this._config=this._getConfig(e),this._dialog=Y.findOne(".modal-dialog",this._element),this._backdrop=this._initializeBackDrop(),this._focustrap=this._initializeFocusTrap(),this._isShown=!1,this._ignoreBackdropClick=!1,this._isTransitioning=!1,this._scrollBar=new zt}static get Default(){return Jt}static get NAME(){return Gt}toggle(t){return this._isShown?this.hide():this.show(t)}show(t){this._isShown||this._isTransitioning||$.trigger(this._element,ie,{relatedTarget:t}).defaultPrevented||(this._isShown=!0,this._isAnimated()&&(this._isTransitioning=!0),this._scrollBar.hide(),document.body.classList.add(ae),this._adjustDialog(),this._setEscapeEvent(),this._setResizeEvent(),$.on(this._dialog,re,(()=>{$.one(this._element,"mouseup.dismiss.bs.modal",(t=>{t.target===this._element&&(this._ignoreBackdropClick=!0)}))})),this._showBackdrop((()=>this._showElement(t))))}hide(){if(!this._isShown||this._isTransitioning)return;if($.trigger(this._element,"hide.bs.modal").defaultPrevented)return;this._isShown=!1;const t=this._isAnimated();t&&(this._isTransitioning=!0),this._setEscapeEvent(),this._setResizeEvent(),this._focustrap.deactivate(),this._element.classList.remove(le),$.off(this._element,ne),$.off(this._dialog,re),this._queueCallback((()=>this._hideModal()),this._element,t)}dispose(){[window,this._dialog].forEach((t=>$.off(t,".bs.modal"))),this._backdrop.dispose(),this._focustrap.deactivate(),super.dispose()}handleUpdate(){this._adjustDialog()}_initializeBackDrop(){return new Ut({isVisible:Boolean(this._config.backdrop),isAnimated:this._isAnimated()})}_initializeFocusTrap(){return new Qt({trapElement:this._element})}_getConfig(t){return t={...Jt,...X.getDataAttributes(this._element),..."object"==typeof t?t:{}},h(Gt,t,te),t}_showElement(t){const e=this._isAnimated(),i=Y.findOne(".modal-body",this._dialog);this._element.parentNode&&this._element.parentNode.nodeType===Node.ELEMENT_NODE||document.body.append(this._element),this._element.style.display="block",this._element.removeAttribute("aria-hidden"),this._element.setAttribute("aria-modal",!0),this._element.setAttribute("role","dialog"),this._element.scrollTop=0,i&&(i.scrollTop=0),e&&f(this._element),this._element.classList.add(le),this._queueCallback((()=>{this._config.focus&&this._focustrap.activate(),this._isTransitioning=!1,$.trigger(this._element,"shown.bs.modal",{relatedTarget:t})}),this._dialog,e)}_setEscapeEvent(){this._isShown?$.on(this._element,oe,(t=>{this._config.keyboard&&t.key===Zt?(t.preventDefault(),this.hide()):this._config.keyboard||t.key!==Zt||this._triggerBackdropTransition()})):$.off(this._element,oe)}_setResizeEvent(){this._isShown?$.on(window,se,(()=>this._adjustDialog())):$.off(window,se)}_hideModal(){this._element.style.display="none",this._element.setAttribute("aria-hidden",!0),this._element.removeAttribute("aria-modal"),this._element.removeAttribute("role"),this._isTransitioning=!1,this._backdrop.hide((()=>{document.body.classList.remove(ae),this._resetAdjustments(),this._scrollBar.reset(),$.trigger(this._element,ee)}))}_showBackdrop(t){$.on(this._element,ne,(t=>{this._ignoreBackdropClick?this._ignoreBackdropClick=!1:t.target===t.currentTarget&&(!0===this._config.backdrop?this.hide():"static"===this._config.backdrop&&this._triggerBackdropTransition())})),this._backdrop.show(t)}_isAnimated(){return this._element.classList.contains("fade")}_triggerBackdropTransition(){if($.trigger(this._element,"hidePrevented.bs.modal").defaultPrevented)return;const{classList:t,scrollHeight:e,style:i}=this._element,s=e>document.documentElement.clientHeight;!s&&"hidden"===i.overflowY||t.contains(ce)||(s||(i.overflowY="hidden"),t.add(ce),this._queueCallback((()=>{t.remove(ce),s||this._queueCallback((()=>{i.overflowY=""}),this._dialog)}),this._dialog),this._element.focus())}_adjustDialog(){const t=this._element.scrollHeight>document.documentElement.clientHeight,e=this._scrollBar.getWidth(),i=e>0;(!i&&t&&!b()||i&&!t&&b())&&(this._element.style.paddingLeft=`${e}px`),(i&&!t&&!b()||!i&&t&&b())&&(this._element.style.paddingRight=`${e}px`)}_resetAdjustments(){this._element.style.paddingLeft="",this._element.style.paddingRight=""}static jQueryInterface(t,e){return this.each((function(){const i=he.getOrCreateInstance(this,t);if("string"==typeof t){if(void 0===i[t])throw new TypeError(`No method named "${t}"`);i[t](e)}}))}}$.on(document,"click.bs.modal.data-api",'[data-bs-toggle="modal"]',(function(t){const e=r(this);["A","AREA"].includes(this.tagName)&&t.preventDefault(),$.one(e,ie,(t=>{t.defaultPrevented||$.one(e,ee,(()=>{d(this)&&this.focus()}))}));const i=Y.findOne(".modal.show");i&&he.getInstance(i).hide(),he.getOrCreateInstance(e).toggle(this)})),F(he),v(he);const de="offcanvas",ue={backdrop:!0,keyboard:!0,scroll:!1},ge={backdrop:"boolean",keyboard:"boolean",scroll:"boolean"},_e="show",fe=".offcanvas.show",pe="hidden.bs.offcanvas";class me extends R{constructor(t,e){super(t),this._config=this._getConfig(e),this._isShown=!1,this._backdrop=this._initializeBackDrop(),this._focustrap=this._initializeFocusTrap(),this._addEventListeners()}static get NAME(){return de}static get Default(){return ue}toggle(t){return this._isShown?this.hide():this.show(t)}show(t){this._isShown||$.trigger(this._element,"show.bs.offcanvas",{relatedTarget:t}).defaultPrevented||(this._isShown=!0,this._element.style.visibility="visible",this._backdrop.show(),this._config.scroll||(new zt).hide(),this._element.removeAttribute("aria-hidden"),this._element.setAttribute("aria-modal",!0),this._element.setAttribute("role","dialog"),this._element.classList.add(_e),this._queueCallback((()=>{this._config.scroll||this._focustrap.activate(),$.trigger(this._element,"shown.bs.offcanvas",{relatedTarget:t})}),this._element,!0))}hide(){this._isShown&&($.trigger(this._element,"hide.bs.offcanvas").defaultPrevented||(this._focustrap.deactivate(),this._element.blur(),this._isShown=!1,this._element.classList.remove(_e),this._backdrop.hide(),this._queueCallback((()=>{this._element.setAttribute("aria-hidden",!0),this._element.removeAttribute("aria-modal"),this._element.removeAttribute("role"),this._element.style.visibility="hidden",this._config.scroll||(new zt).reset(),$.trigger(this._element,pe)}),this._element,!0)))}dispose(){this._backdrop.dispose(),this._focustrap.deactivate(),super.dispose()}_getConfig(t){return t={...ue,...X.getDataAttributes(this._element),..."object"==typeof t?t:{}},h(de,t,ge),t}_initializeBackDrop(){return new Ut({className:"offcanvas-backdrop",isVisible:this._config.backdrop,isAnimated:!0,rootElement:this._element.parentNode,clickCallback:()=>this.hide()})}_initializeFocusTrap(){return new Qt({trapElement:this._element})}_addEventListeners(){$.on(this._element,"keydown.dismiss.bs.offcanvas",(t=>{this._config.keyboard&&"Escape"===t.key&&this.hide()}))}static jQueryInterface(t){return this.each((function(){const e=me.getOrCreateInstance(this,t);if("string"==typeof t){if(void 0===e[t]||t.startsWith("_")||"constructor"===t)throw new TypeError(`No method named "${t}"`);e[t](this)}}))}}$.on(document,"click.bs.offcanvas.data-api",'[data-bs-toggle="offcanvas"]',(function(t){const e=r(this);if(["A","AREA"].includes(this.tagName)&&t.preventDefault(),u(this))return;$.one(e,pe,(()=>{d(this)&&this.focus()}));const i=Y.findOne(fe);i&&i!==e&&me.getInstance(i).hide(),me.getOrCreateInstance(e).toggle(this)})),$.on(window,"load.bs.offcanvas.data-api",(()=>Y.find(fe).forEach((t=>me.getOrCreateInstance(t).show())))),F(me),v(me);const be=new Set(["background","cite","href","itemtype","longdesc","poster","src","xlink:href"]),ve=/^(?:(?:https?|mailto|ftp|tel|file|sms):|[^#&/:?]*(?:[#/?]|$))/i,ye=/^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[\d+/a-z]+=*$/i,Ee=(t,e)=>{const i=t.nodeName.toLowerCase();if(e.includes(i))return!be.has(i)||Boolean(ve.test(t.nodeValue)||ye.test(t.nodeValue));const s=e.filter((t=>t instanceof RegExp));for(let t=0,e=s.length;t<e;t++)if(s[t].test(i))return!0;return!1};function we(t,e,i){if(!t.length)return t;if(i&&"function"==typeof i)return i(t);const s=(new window.DOMParser).parseFromString(t,"text/html"),n=[].concat(...s.body.querySelectorAll("*"));for(let t=0,i=n.length;t<i;t++){const i=n[t],s=i.nodeName.toLowerCase();if(!Object.keys(e).includes(s)){i.remove();continue}const o=[].concat(...i.attributes),r=[].concat(e["*"]||[],e[s]||[]);o.forEach((t=>{Ee(t,r)||i.removeAttribute(t.nodeName)}))}return s.body.innerHTML}const Ae="tooltip",Te=new Set(["sanitize","allowList","sanitizeFn"]),Ce={animation:"boolean",template:"string",title:"(string|element|function)",trigger:"string",delay:"(number|object)",html:"boolean",selector:"(string|boolean)",placement:"(string|function)",offset:"(array|string|function)",container:"(string|element|boolean)",fallbackPlacements:"array",boundary:"(string|element)",customClass:"(string|function)",sanitize:"boolean",sanitizeFn:"(null|function)",allowList:"object",popperConfig:"(null|object|function)"},ke={AUTO:"auto",TOP:"top",RIGHT:b()?"left":"right",BOTTOM:"bottom",LEFT:b()?"right":"left"},Le={animation:!0,template:'<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',trigger:"hover focus",title:"",delay:0,html:!1,selector:!1,placement:"top",offset:[0,0],container:!1,fallbackPlacements:["top","right","bottom","left"],boundary:"clippingParents",customClass:"",sanitize:!0,sanitizeFn:null,allowList:{"*":["class","dir","id","lang","role",/^aria-[\w-]*$/i],a:["target","href","title","rel"],area:[],b:[],br:[],col:[],code:[],div:[],em:[],hr:[],h1:[],h2:[],h3:[],h4:[],h5:[],h6:[],i:[],img:["src","srcset","alt","title","width","height"],li:[],ol:[],p:[],pre:[],s:[],small:[],span:[],sub:[],sup:[],strong:[],u:[],ul:[]},popperConfig:null},Se={HIDE:"hide.bs.tooltip",HIDDEN:"hidden.bs.tooltip",SHOW:"show.bs.tooltip",SHOWN:"shown.bs.tooltip",INSERTED:"inserted.bs.tooltip",CLICK:"click.bs.tooltip",FOCUSIN:"focusin.bs.tooltip",FOCUSOUT:"focusout.bs.tooltip",MOUSEENTER:"mouseenter.bs.tooltip",MOUSELEAVE:"mouseleave.bs.tooltip"},Oe="fade",Ne="show",De="show",Ie="out",Pe=".tooltip-inner",xe=".modal",Me="hide.bs.modal",je="hover",He="focus";class $e extends R{constructor(t,e){if(void 0===i)throw new TypeError("Bootstrap's tooltips require Popper (https://popper.js.org)");super(t),this._isEnabled=!0,this._timeout=0,this._hoverState="",this._activeTrigger={},this._popper=null,this._config=this._getConfig(e),this.tip=null,this._setListeners()}static get Default(){return Le}static get NAME(){return Ae}static get Event(){return Se}static get DefaultType(){return Ce}enable(){this._isEnabled=!0}disable(){this._isEnabled=!1}toggleEnabled(){this._isEnabled=!this._isEnabled}toggle(t){if(this._isEnabled)if(t){const e=this._initializeOnDelegatedTarget(t);e._activeTrigger.click=!e._activeTrigger.click,e._isWithActiveTrigger()?e._enter(null,e):e._leave(null,e)}else{if(this.getTipElement().classList.contains(Ne))return void this._leave(null,this);this._enter(null,this)}}dispose(){clearTimeout(this._timeout),$.off(this._element.closest(xe),Me,this._hideModalHandler),this.tip&&this.tip.remove(),this._disposePopper(),super.dispose()}show(){if("none"===this._element.style.display)throw new Error("Please use show on visible elements");if(!this.isWithContent()||!this._isEnabled)return;const t=$.trigger(this._element,this.constructor.Event.SHOW),e=g(this._element),s=null===e?this._element.ownerDocument.documentElement.contains(this._element):e.contains(this._element);if(t.defaultPrevented||!s)return;"tooltip"===this.constructor.NAME&&this.tip&&this.getTitle()!==this.tip.querySelector(Pe).innerHTML&&(this._disposePopper(),this.tip.remove(),this.tip=null);const n=this.getTipElement(),o=(t=>{do{t+=Math.floor(1e6*Math.random())}while(document.getElementById(t));return t})(this.constructor.NAME);n.setAttribute("id",o),this._element.setAttribute("aria-describedby",o),this._config.animation&&n.classList.add(Oe);const r="function"==typeof this._config.placement?this._config.placement.call(this,n,this._element):this._config.placement,a=this._getAttachment(r);this._addAttachmentClass(a);const{container:l}=this._config;z.set(n,this.constructor.DATA_KEY,this),this._element.ownerDocument.documentElement.contains(this.tip)||(l.append(n),$.trigger(this._element,this.constructor.Event.INSERTED)),this._popper?this._popper.update():this._popper=i.createPopper(this._element,n,this._getPopperConfig(a)),n.classList.add(Ne);const c=this._resolvePossibleFunction(this._config.customClass);c&&n.classList.add(...c.split(" ")),"ontouchstart"in document.documentElement&&[].concat(...document.body.children).forEach((t=>{$.on(t,"mouseover",_)}));const h=this.tip.classList.contains(Oe);this._queueCallback((()=>{const t=this._hoverState;this._hoverState=null,$.trigger(this._element,this.constructor.Event.SHOWN),t===Ie&&this._leave(null,this)}),this.tip,h)}hide(){if(!this._popper)return;const t=this.getTipElement();if($.trigger(this._element,this.constructor.Event.HIDE).defaultPrevented)return;t.classList.remove(Ne),"ontouchstart"in document.documentElement&&[].concat(...document.body.children).forEach((t=>$.off(t,"mouseover",_))),this._activeTrigger.click=!1,this._activeTrigger.focus=!1,this._activeTrigger.hover=!1;const e=this.tip.classList.contains(Oe);this._queueCallback((()=>{this._isWithActiveTrigger()||(this._hoverState!==De&&t.remove(),this._cleanTipClass(),this._element.removeAttribute("aria-describedby"),$.trigger(this._element,this.constructor.Event.HIDDEN),this._disposePopper())}),this.tip,e),this._hoverState=""}update(){null!==this._popper&&this._popper.update()}isWithContent(){return Boolean(this.getTitle())}getTipElement(){if(this.tip)return this.tip;const t=document.createElement("div");t.innerHTML=this._config.template;const e=t.children[0];return this.setContent(e),e.classList.remove(Oe,Ne),this.tip=e,this.tip}setContent(t){this._sanitizeAndSetContent(t,this.getTitle(),Pe)}_sanitizeAndSetContent(t,e,i){const s=Y.findOne(i,t);e||!s?this.setElementContent(s,e):s.remove()}setElementContent(t,e){if(null!==t)return l(e)?(e=c(e),void(this._config.html?e.parentNode!==t&&(t.innerHTML="",t.append(e)):t.textContent=e.textContent)):void(this._config.html?(this._config.sanitize&&(e=we(e,this._config.allowList,this._config.sanitizeFn)),t.innerHTML=e):t.textContent=e)}getTitle(){const t=this._element.getAttribute("data-bs-original-title")||this._config.title;return this._resolvePossibleFunction(t)}updateAttachment(t){return"right"===t?"end":"left"===t?"start":t}_initializeOnDelegatedTarget(t,e){return e||this.constructor.getOrCreateInstance(t.delegateTarget,this._getDelegateConfig())}_getOffset(){const{offset:t}=this._config;return"string"==typeof t?t.split(",").map((t=>Number.parseInt(t,10))):"function"==typeof t?e=>t(e,this._element):t}_resolvePossibleFunction(t){return"function"==typeof t?t.call(this._element):t}_getPopperConfig(t){const e={placement:t,modifiers:[{name:"flip",options:{fallbackPlacements:this._config.fallbackPlacements}},{name:"offset",options:{offset:this._getOffset()}},{name:"preventOverflow",options:{boundary:this._config.boundary}},{name:"arrow",options:{element:`.${this.constructor.NAME}-arrow`}},{name:"onChange",enabled:!0,phase:"afterWrite",fn:t=>this._handlePopperPlacementChange(t)}],onFirstUpdate:t=>{t.options.placement!==t.placement&&this._handlePopperPlacementChange(t)}};return{...e,..."function"==typeof this._config.popperConfig?this._config.popperConfig(e):this._config.popperConfig}}_addAttachmentClass(t){this.getTipElement().classList.add(`${this._getBasicClassPrefix()}-${this.updateAttachment(t)}`)}_getAttachment(t){return ke[t.toUpperCase()]}_setListeners(){this._config.trigger.split(" ").forEach((t=>{if("click"===t)$.on(this._element,this.constructor.Event.CLICK,this._config.selector,(t=>this.toggle(t)));else if("manual"!==t){const e=t===je?this.constructor.Event.MOUSEENTER:this.constructor.Event.FOCUSIN,i=t===je?this.constructor.Event.MOUSELEAVE:this.constructor.Event.FOCUSOUT;$.on(this._element,e,this._config.selector,(t=>this._enter(t))),$.on(this._element,i,this._config.selector,(t=>this._leave(t)))}})),this._hideModalHandler=()=>{this._element&&this.hide()},$.on(this._element.closest(xe),Me,this._hideModalHandler),this._config.selector?this._config={...this._config,trigger:"manual",selector:""}:this._fixTitle()}_fixTitle(){const t=this._element.getAttribute("title"),e=typeof this._element.getAttribute("data-bs-original-title");(t||"string"!==e)&&(this._element.setAttribute("data-bs-original-title",t||""),!t||this._element.getAttribute("aria-label")||this._element.textContent||this._element.setAttribute("aria-label",t),this._element.setAttribute("title",""))}_enter(t,e){e=this._initializeOnDelegatedTarget(t,e),t&&(e._activeTrigger["focusin"===t.type?He:je]=!0),e.getTipElement().classList.contains(Ne)||e._hoverState===De?e._hoverState=De:(clearTimeout(e._timeout),e._hoverState=De,e._config.delay&&e._config.delay.show?e._timeout=setTimeout((()=>{e._hoverState===De&&e.show()}),e._config.delay.show):e.show())}_leave(t,e){e=this._initializeOnDelegatedTarget(t,e),t&&(e._activeTrigger["focusout"===t.type?He:je]=e._element.contains(t.relatedTarget)),e._isWithActiveTrigger()||(clearTimeout(e._timeout),e._hoverState=Ie,e._config.delay&&e._config.delay.hide?e._timeout=setTimeout((()=>{e._hoverState===Ie&&e.hide()}),e._config.delay.hide):e.hide())}_isWithActiveTrigger(){for(const t in this._activeTrigger)if(this._activeTrigger[t])return!0;return!1}_getConfig(t){const e=X.getDataAttributes(this._element);return Object.keys(e).forEach((t=>{Te.has(t)&&delete e[t]})),(t={...this.constructor.Default,...e,..."object"==typeof t&&t?t:{}}).container=!1===t.container?document.body:c(t.container),"number"==typeof t.delay&&(t.delay={show:t.delay,hide:t.delay}),"number"==typeof t.title&&(t.title=t.title.toString()),"number"==typeof t.content&&(t.content=t.content.toString()),h(Ae,t,this.constructor.DefaultType),t.sanitize&&(t.template=we(t.template,t.allowList,t.sanitizeFn)),t}_getDelegateConfig(){const t={};for(const e in this._config)this.constructor.Default[e]!==this._config[e]&&(t[e]=this._config[e]);return t}_cleanTipClass(){const t=this.getTipElement(),e=new RegExp(`(^|\\s)${this._getBasicClassPrefix()}\\S+`,"g"),i=t.getAttribute("class").match(e);null!==i&&i.length>0&&i.map((t=>t.trim())).forEach((e=>t.classList.remove(e)))}_getBasicClassPrefix(){return"bs-tooltip"}_handlePopperPlacementChange(t){const{state:e}=t;e&&(this.tip=e.elements.popper,this._cleanTipClass(),this._addAttachmentClass(this._getAttachment(e.placement)))}_disposePopper(){this._popper&&(this._popper.destroy(),this._popper=null)}static jQueryInterface(t){return this.each((function(){const e=$e.getOrCreateInstance(this,t);if("string"==typeof t){if(void 0===e[t])throw new TypeError(`No method named "${t}"`);e[t]()}}))}}v($e);const Be={...$e.Default,placement:"right",offset:[0,8],trigger:"click",content:"",template:'<div class="popover" role="tooltip"><div class="popover-arrow"></div><h3 class="popover-header"></h3><div class="popover-body"></div></div>'},ze={...$e.DefaultType,content:"(string|element|function)"},Re={HIDE:"hide.bs.popover",HIDDEN:"hidden.bs.popover",SHOW:"show.bs.popover",SHOWN:"shown.bs.popover",INSERTED:"inserted.bs.popover",CLICK:"click.bs.popover",FOCUSIN:"focusin.bs.popover",FOCUSOUT:"focusout.bs.popover",MOUSEENTER:"mouseenter.bs.popover",MOUSELEAVE:"mouseleave.bs.popover"};class Fe extends $e{static get Default(){return Be}static get NAME(){return"popover"}static get Event(){return Re}static get DefaultType(){return ze}isWithContent(){return this.getTitle()||this._getContent()}setContent(t){this._sanitizeAndSetContent(t,this.getTitle(),".popover-header"),this._sanitizeAndSetContent(t,this._getContent(),".popover-body")}_getContent(){return this._resolvePossibleFunction(this._config.content)}_getBasicClassPrefix(){return"bs-popover"}static jQueryInterface(t){return this.each((function(){const e=Fe.getOrCreateInstance(this,t);if("string"==typeof t){if(void 0===e[t])throw new TypeError(`No method named "${t}"`);e[t]()}}))}}v(Fe);const qe="scrollspy",We={offset:10,method:"auto",target:""},Ue={offset:"number",method:"string",target:"(string|element)"},Ke="active",Ve=".nav-link, .list-group-item, .dropdown-item",Xe="position";class Ye extends R{constructor(t,e){super(t),this._scrollElement="BODY"===this._element.tagName?window:this._element,this._config=this._getConfig(e),this._offsets=[],this._targets=[],this._activeTarget=null,this._scrollHeight=0,$.on(this._scrollElement,"scroll.bs.scrollspy",(()=>this._process())),this.refresh(),this._process()}static get Default(){return We}static get NAME(){return qe}refresh(){const t=this._scrollElement===this._scrollElement.window?"offset":Xe,e="auto"===this._config.method?t:this._config.method,i=e===Xe?this._getScrollTop():0;this._offsets=[],this._targets=[],this._scrollHeight=this._getScrollHeight(),Y.find(Ve,this._config.target).map((t=>{const s=o(t),n=s?Y.findOne(s):null;if(n){const t=n.getBoundingClientRect();if(t.width||t.height)return[X[e](n).top+i,s]}return null})).filter((t=>t)).sort(((t,e)=>t[0]-e[0])).forEach((t=>{this._offsets.push(t[0]),this._targets.push(t[1])}))}dispose(){$.off(this._scrollElement,".bs.scrollspy"),super.dispose()}_getConfig(t){return(t={...We,...X.getDataAttributes(this._element),..."object"==typeof t&&t?t:{}}).target=c(t.target)||document.documentElement,h(qe,t,Ue),t}_getScrollTop(){return this._scrollElement===window?this._scrollElement.pageYOffset:this._scrollElement.scrollTop}_getScrollHeight(){return this._scrollElement.scrollHeight||Math.max(document.body.scrollHeight,document.documentElement.scrollHeight)}_getOffsetHeight(){return this._scrollElement===window?window.innerHeight:this._scrollElement.getBoundingClientRect().height}_process(){const t=this._getScrollTop()+this._config.offset,e=this._getScrollHeight(),i=this._config.offset+e-this._getOffsetHeight();if(this._scrollHeight!==e&&this.refresh(),t>=i){const t=this._targets[this._targets.length-1];this._activeTarget!==t&&this._activate(t)}else{if(this._activeTarget&&t<this._offsets[0]&&this._offsets[0]>0)return this._activeTarget=null,void this._clear();for(let e=this._offsets.length;e--;)this._activeTarget!==this._targets[e]&&t>=this._offsets[e]&&(void 0===this._offsets[e+1]||t<this._offsets[e+1])&&this._activate(this._targets[e])}}_activate(t){this._activeTarget=t,this._clear();const e=Ve.split(",").map((e=>`${e}[data-bs-target="${t}"],${e}[href="${t}"]`)),i=Y.findOne(e.join(","),this._config.target);i.classList.add(Ke),i.classList.contains("dropdown-item")?Y.findOne(".dropdown-toggle",i.closest(".dropdown")).classList.add(Ke):Y.parents(i,".nav, .list-group").forEach((t=>{Y.prev(t,".nav-link, .list-group-item").forEach((t=>t.classList.add(Ke))),Y.prev(t,".nav-item").forEach((t=>{Y.children(t,".nav-link").forEach((t=>t.classList.add(Ke)))}))})),$.trigger(this._scrollElement,"activate.bs.scrollspy",{relatedTarget:t})}_clear(){Y.find(Ve,this._config.target).filter((t=>t.classList.contains(Ke))).forEach((t=>t.classList.remove(Ke)))}static jQueryInterface(t){return this.each((function(){const e=Ye.getOrCreateInstance(this,t);if("string"==typeof t){if(void 0===e[t])throw new TypeError(`No method named "${t}"`);e[t]()}}))}}$.on(window,"load.bs.scrollspy.data-api",(()=>{Y.find('[data-bs-spy="scroll"]').forEach((t=>new Ye(t)))})),v(Ye);const Qe="active",Ge="fade",Ze="show",Je=".active",ti=":scope > li > .active";class ei extends R{static get NAME(){return"tab"}show(){if(this._element.parentNode&&this._element.parentNode.nodeType===Node.ELEMENT_NODE&&this._element.classList.contains(Qe))return;let t;const e=r(this._element),i=this._element.closest(".nav, .list-group");if(i){const e="UL"===i.nodeName||"OL"===i.nodeName?ti:Je;t=Y.find(e,i),t=t[t.length-1]}const s=t?$.trigger(t,"hide.bs.tab",{relatedTarget:this._element}):null;if($.trigger(this._element,"show.bs.tab",{relatedTarget:t}).defaultPrevented||null!==s&&s.defaultPrevented)return;this._activate(this._element,i);const n=()=>{$.trigger(t,"hidden.bs.tab",{relatedTarget:this._element}),$.trigger(this._element,"shown.bs.tab",{relatedTarget:t})};e?this._activate(e,e.parentNode,n):n()}_activate(t,e,i){const s=(!e||"UL"!==e.nodeName&&"OL"!==e.nodeName?Y.children(e,Je):Y.find(ti,e))[0],n=i&&s&&s.classList.contains(Ge),o=()=>this._transitionComplete(t,s,i);s&&n?(s.classList.remove(Ze),this._queueCallback(o,t,!0)):o()}_transitionComplete(t,e,i){if(e){e.classList.remove(Qe);const t=Y.findOne(":scope > .dropdown-menu .active",e.parentNode);t&&t.classList.remove(Qe),"tab"===e.getAttribute("role")&&e.setAttribute("aria-selected",!1)}t.classList.add(Qe),"tab"===t.getAttribute("role")&&t.setAttribute("aria-selected",!0),f(t),t.classList.contains(Ge)&&t.classList.add(Ze);let s=t.parentNode;if(s&&"LI"===s.nodeName&&(s=s.parentNode),s&&s.classList.contains("dropdown-menu")){const e=t.closest(".dropdown");e&&Y.find(".dropdown-toggle",e).forEach((t=>t.classList.add(Qe))),t.setAttribute("aria-expanded",!0)}i&&i()}static jQueryInterface(t){return this.each((function(){const e=ei.getOrCreateInstance(this);if("string"==typeof t){if(void 0===e[t])throw new TypeError(`No method named "${t}"`);e[t]()}}))}}$.on(document,"click.bs.tab.data-api",'[data-bs-toggle="tab"], [data-bs-toggle="pill"], [data-bs-toggle="list"]',(function(t){["A","AREA"].includes(this.tagName)&&t.preventDefault(),u(this)||ei.getOrCreateInstance(this).show()})),v(ei);const ii="toast",si="hide",ni="show",oi="showing",ri={animation:"boolean",autohide:"boolean",delay:"number"},ai={animation:!0,autohide:!0,delay:5e3};class li extends R{constructor(t,e){super(t),this._config=this._getConfig(e),this._timeout=null,this._hasMouseInteraction=!1,this._hasKeyboardInteraction=!1,this._setListeners()}static get DefaultType(){return ri}static get Default(){return ai}static get NAME(){return ii}show(){$.trigger(this._element,"show.bs.toast").defaultPrevented||(this._clearTimeout(),this._config.animation&&this._element.classList.add("fade"),this._element.classList.remove(si),f(this._element),this._element.classList.add(ni),this._element.classList.add(oi),this._queueCallback((()=>{this._element.classList.remove(oi),$.trigger(this._element,"shown.bs.toast"),this._maybeScheduleHide()}),this._element,this._config.animation))}hide(){this._element.classList.contains(ni)&&($.trigger(this._element,"hide.bs.toast").defaultPrevented||(this._element.classList.add(oi),this._queueCallback((()=>{this._element.classList.add(si),this._element.classList.remove(oi),this._element.classList.remove(ni),$.trigger(this._element,"hidden.bs.toast")}),this._element,this._config.animation)))}dispose(){this._clearTimeout(),this._element.classList.contains(ni)&&this._element.classList.remove(ni),super.dispose()}_getConfig(t){return t={...ai,...X.getDataAttributes(this._element),..."object"==typeof t&&t?t:{}},h(ii,t,this.constructor.DefaultType),t}_maybeScheduleHide(){this._config.autohide&&(this._hasMouseInteraction||this._hasKeyboardInteraction||(this._timeout=setTimeout((()=>{this.hide()}),this._config.delay)))}_onInteraction(t,e){switch(t.type){case"mouseover":case"mouseout":this._hasMouseInteraction=e;break;case"focusin":case"focusout":this._hasKeyboardInteraction=e}if(e)return void this._clearTimeout();const i=t.relatedTarget;this._element===i||this._element.contains(i)||this._maybeScheduleHide()}_setListeners(){$.on(this._element,"mouseover.bs.toast",(t=>this._onInteraction(t,!0))),$.on(this._element,"mouseout.bs.toast",(t=>this._onInteraction(t,!1))),$.on(this._element,"focusin.bs.toast",(t=>this._onInteraction(t,!0))),$.on(this._element,"focusout.bs.toast",(t=>this._onInteraction(t,!1)))}_clearTimeout(){clearTimeout(this._timeout),this._timeout=null}static jQueryInterface(t){return this.each((function(){const e=li.getOrCreateInstance(this,t);if("string"==typeof t){if(void 0===e[t])throw new TypeError(`No method named "${t}"`);e[t](this)}}))}}return F(li),v(li),{Alert:q,Button:U,Carousel:at,Collapse:mt,Dropdown:Ht,Modal:he,Offcanvas:me,Popover:Fe,ScrollSpy:Ye,Tab:ei,Toast:li,Tooltip:$e}})); +!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("@popperjs/core")):"function"==typeof define&&define.amd?define(["@popperjs/core"],e):(t="undefined"!=typeof globalThis?globalThis:t||self).bootstrap=e(t.Popper)}(this,(function(t){"use strict";function e(t){if(t&&t.__esModule)return t;const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t)for(const i in t)if("default"!==i){const s=Object.getOwnPropertyDescriptor(t,i);Object.defineProperty(e,i,s.get?s:{enumerable:!0,get:()=>t[i]})}return e.default=t,Object.freeze(e)}const i=e(t),s="transitionend",n=t=>{let e=t.getAttribute("data-bs-target");if(!e||"#"===e){let i=t.getAttribute("href");if(!i||!i.includes("#")&&!i.startsWith("."))return null;i.includes("#")&&!i.startsWith("#")&&(i=`#${i.split("#")[1]}`),e=i&&"#"!==i?i.trim():null}return e},o=t=>{const e=n(t);return e&&document.querySelector(e)?e:null},r=t=>{const e=n(t);return e?document.querySelector(e):null},a=t=>{t.dispatchEvent(new Event(s))},l=t=>!(!t||"object"!=typeof t)&&(void 0!==t.jquery&&(t=t[0]),void 0!==t.nodeType),c=t=>l(t)?t.jquery?t[0]:t:"string"==typeof t&&t.length>0?document.querySelector(t):null,h=t=>{if(!l(t)||0===t.getClientRects().length)return!1;const e="visible"===getComputedStyle(t).getPropertyValue("visibility"),i=t.closest("details:not([open])");if(!i)return e;if(i!==t){const e=t.closest("summary");if(e&&e.parentNode!==i)return!1;if(null===e)return!1}return e},d=t=>!t||t.nodeType!==Node.ELEMENT_NODE||!!t.classList.contains("disabled")||(void 0!==t.disabled?t.disabled:t.hasAttribute("disabled")&&"false"!==t.getAttribute("disabled")),u=t=>{if(!document.documentElement.attachShadow)return null;if("function"==typeof t.getRootNode){const e=t.getRootNode();return e instanceof ShadowRoot?e:null}return t instanceof ShadowRoot?t:t.parentNode?u(t.parentNode):null},_=()=>{},g=t=>{t.offsetHeight},f=()=>window.jQuery&&!document.body.hasAttribute("data-bs-no-jquery")?window.jQuery:null,p=[],m=()=>"rtl"===document.documentElement.dir,b=t=>{var e;e=()=>{const e=f();if(e){const i=t.NAME,s=e.fn[i];e.fn[i]=t.jQueryInterface,e.fn[i].Constructor=t,e.fn[i].noConflict=()=>(e.fn[i]=s,t.jQueryInterface)}},"loading"===document.readyState?(p.length||document.addEventListener("DOMContentLoaded",(()=>{for(const t of p)t()})),p.push(e)):e()},v=t=>{"function"==typeof t&&t()},y=(t,e,i=!0)=>{if(!i)return void v(t);const n=(t=>{if(!t)return 0;let{transitionDuration:e,transitionDelay:i}=window.getComputedStyle(t);const s=Number.parseFloat(e),n=Number.parseFloat(i);return s||n?(e=e.split(",")[0],i=i.split(",")[0],1e3*(Number.parseFloat(e)+Number.parseFloat(i))):0})(e)+5;let o=!1;const r=({target:i})=>{i===e&&(o=!0,e.removeEventListener(s,r),v(t))};e.addEventListener(s,r),setTimeout((()=>{o||a(e)}),n)},w=(t,e,i,s)=>{const n=t.length;let o=t.indexOf(e);return-1===o?!i&&s?t[n-1]:t[0]:(o+=i?1:-1,s&&(o=(o+n)%n),t[Math.max(0,Math.min(o,n-1))])},A=/[^.]*(?=\..*)\.|.*/,T=/\..*/,E=/::\d+$/,C={};let k=1;const L={mouseenter:"mouseover",mouseleave:"mouseout"},O=new Set(["click","dblclick","mouseup","mousedown","contextmenu","mousewheel","DOMMouseScroll","mouseover","mouseout","mousemove","selectstart","selectend","keydown","keypress","keyup","orientationchange","touchstart","touchmove","touchend","touchcancel","pointerdown","pointermove","pointerup","pointerleave","pointercancel","gesturestart","gesturechange","gestureend","focus","blur","change","reset","select","submit","focusin","focusout","load","unload","beforeunload","resize","move","DOMContentLoaded","readystatechange","error","abort","scroll"]);function I(t,e){return e&&`${e}::${k++}`||t.uidEvent||k++}function S(t){const e=I(t);return t.uidEvent=e,C[e]=C[e]||{},C[e]}function D(t,e,i=null){return Object.values(t).find((t=>t.callable===e&&t.delegationSelector===i))}function N(t,e,i){const s="string"==typeof e,n=s?i:e||i;let o=j(t);return O.has(o)||(o=t),[s,n,o]}function P(t,e,i,s,n){if("string"!=typeof e||!t)return;let[o,r,a]=N(e,i,s);if(e in L){const t=t=>function(e){if(!e.relatedTarget||e.relatedTarget!==e.delegateTarget&&!e.delegateTarget.contains(e.relatedTarget))return t.call(this,e)};r=t(r)}const l=S(t),c=l[a]||(l[a]={}),h=D(c,r,o?i:null);if(h)return void(h.oneOff=h.oneOff&&n);const d=I(r,e.replace(A,"")),u=o?function(t,e,i){return function s(n){const o=t.querySelectorAll(e);for(let{target:r}=n;r&&r!==this;r=r.parentNode)for(const a of o)if(a===r)return F(n,{delegateTarget:r}),s.oneOff&&$.off(t,n.type,e,i),i.apply(r,[n])}}(t,i,r):function(t,e){return function i(s){return F(s,{delegateTarget:t}),i.oneOff&&$.off(t,s.type,e),e.apply(t,[s])}}(t,r);u.delegationSelector=o?i:null,u.callable=r,u.oneOff=n,u.uidEvent=d,c[d]=u,t.addEventListener(a,u,o)}function x(t,e,i,s,n){const o=D(e[i],s,n);o&&(t.removeEventListener(i,o,Boolean(n)),delete e[i][o.uidEvent])}function M(t,e,i,s){const n=e[i]||{};for(const o of Object.keys(n))if(o.includes(s)){const s=n[o];x(t,e,i,s.callable,s.delegationSelector)}}function j(t){return t=t.replace(T,""),L[t]||t}const $={on(t,e,i,s){P(t,e,i,s,!1)},one(t,e,i,s){P(t,e,i,s,!0)},off(t,e,i,s){if("string"!=typeof e||!t)return;const[n,o,r]=N(e,i,s),a=r!==e,l=S(t),c=l[r]||{},h=e.startsWith(".");if(void 0===o){if(h)for(const i of Object.keys(l))M(t,l,i,e.slice(1));for(const i of Object.keys(c)){const s=i.replace(E,"");if(!a||e.includes(s)){const e=c[i];x(t,l,r,e.callable,e.delegationSelector)}}}else{if(!Object.keys(c).length)return;x(t,l,r,o,n?i:null)}},trigger(t,e,i){if("string"!=typeof e||!t)return null;const s=f();let n=null,o=!0,r=!0,a=!1;e!==j(e)&&s&&(n=s.Event(e,i),s(t).trigger(n),o=!n.isPropagationStopped(),r=!n.isImmediatePropagationStopped(),a=n.isDefaultPrevented());let l=new Event(e,{bubbles:o,cancelable:!0});return l=F(l,i),a&&l.preventDefault(),r&&t.dispatchEvent(l),l.defaultPrevented&&n&&n.preventDefault(),l}};function F(t,e){for(const[i,s]of Object.entries(e||{}))try{t[i]=s}catch(e){Object.defineProperty(t,i,{configurable:!0,get:()=>s})}return t}const z=new Map,H={set(t,e,i){z.has(t)||z.set(t,new Map);const s=z.get(t);s.has(e)||0===s.size?s.set(e,i):console.error(`Bootstrap doesn't allow more than one instance per element. Bound instance: ${Array.from(s.keys())[0]}.`)},get:(t,e)=>z.has(t)&&z.get(t).get(e)||null,remove(t,e){if(!z.has(t))return;const i=z.get(t);i.delete(e),0===i.size&&z.delete(t)}};function q(t){if("true"===t)return!0;if("false"===t)return!1;if(t===Number(t).toString())return Number(t);if(""===t||"null"===t)return null;if("string"!=typeof t)return t;try{return JSON.parse(decodeURIComponent(t))}catch(e){return t}}function B(t){return t.replace(/[A-Z]/g,(t=>`-${t.toLowerCase()}`))}const W={setDataAttribute(t,e,i){t.setAttribute(`data-bs-${B(e)}`,i)},removeDataAttribute(t,e){t.removeAttribute(`data-bs-${B(e)}`)},getDataAttributes(t){if(!t)return{};const e={},i=Object.keys(t.dataset).filter((t=>t.startsWith("bs")&&!t.startsWith("bsConfig")));for(const s of i){let i=s.replace(/^bs/,"");i=i.charAt(0).toLowerCase()+i.slice(1,i.length),e[i]=q(t.dataset[s])}return e},getDataAttribute:(t,e)=>q(t.getAttribute(`data-bs-${B(e)}`))};class R{static get Default(){return{}}static get DefaultType(){return{}}static get NAME(){throw new Error('You have to implement the static method "NAME", for each component!')}_getConfig(t){return t=this._mergeConfigObj(t),t=this._configAfterMerge(t),this._typeCheckConfig(t),t}_configAfterMerge(t){return t}_mergeConfigObj(t,e){const i=l(e)?W.getDataAttribute(e,"config"):{};return{...this.constructor.Default,..."object"==typeof i?i:{},...l(e)?W.getDataAttributes(e):{},..."object"==typeof t?t:{}}}_typeCheckConfig(t,e=this.constructor.DefaultType){for(const s of Object.keys(e)){const n=e[s],o=t[s],r=l(o)?"element":null==(i=o)?`${i}`:Object.prototype.toString.call(i).match(/\s([a-z]+)/i)[1].toLowerCase();if(!new RegExp(n).test(r))throw new TypeError(`${this.constructor.NAME.toUpperCase()}: Option "${s}" provided type "${r}" but expected type "${n}".`)}var i}}class V extends R{constructor(t,e){super(),(t=c(t))&&(this._element=t,this._config=this._getConfig(e),H.set(this._element,this.constructor.DATA_KEY,this))}dispose(){H.remove(this._element,this.constructor.DATA_KEY),$.off(this._element,this.constructor.EVENT_KEY);for(const t of Object.getOwnPropertyNames(this))this[t]=null}_queueCallback(t,e,i=!0){y(t,e,i)}_getConfig(t){return t=this._mergeConfigObj(t,this._element),t=this._configAfterMerge(t),this._typeCheckConfig(t),t}static getInstance(t){return H.get(c(t),this.DATA_KEY)}static getOrCreateInstance(t,e={}){return this.getInstance(t)||new this(t,"object"==typeof e?e:null)}static get VERSION(){return"5.2.0"}static get DATA_KEY(){return`bs.${this.NAME}`}static get EVENT_KEY(){return`.${this.DATA_KEY}`}static eventName(t){return`${t}${this.EVENT_KEY}`}}const K=(t,e="hide")=>{const i=`click.dismiss${t.EVENT_KEY}`,s=t.NAME;$.on(document,i,`[data-bs-dismiss="${s}"]`,(function(i){if(["A","AREA"].includes(this.tagName)&&i.preventDefault(),d(this))return;const n=r(this)||this.closest(`.${s}`);t.getOrCreateInstance(n)[e]()}))};class Q extends V{static get NAME(){return"alert"}close(){if($.trigger(this._element,"close.bs.alert").defaultPrevented)return;this._element.classList.remove("show");const t=this._element.classList.contains("fade");this._queueCallback((()=>this._destroyElement()),this._element,t)}_destroyElement(){this._element.remove(),$.trigger(this._element,"closed.bs.alert"),this.dispose()}static jQueryInterface(t){return this.each((function(){const e=Q.getOrCreateInstance(this);if("string"==typeof t){if(void 0===e[t]||t.startsWith("_")||"constructor"===t)throw new TypeError(`No method named "${t}"`);e[t](this)}}))}}K(Q,"close"),b(Q);const X='[data-bs-toggle="button"]';class Y extends V{static get NAME(){return"button"}toggle(){this._element.setAttribute("aria-pressed",this._element.classList.toggle("active"))}static jQueryInterface(t){return this.each((function(){const e=Y.getOrCreateInstance(this);"toggle"===t&&e[t]()}))}}$.on(document,"click.bs.button.data-api",X,(t=>{t.preventDefault();const e=t.target.closest(X);Y.getOrCreateInstance(e).toggle()})),b(Y);const U={find:(t,e=document.documentElement)=>[].concat(...Element.prototype.querySelectorAll.call(e,t)),findOne:(t,e=document.documentElement)=>Element.prototype.querySelector.call(e,t),children:(t,e)=>[].concat(...t.children).filter((t=>t.matches(e))),parents(t,e){const i=[];let s=t.parentNode.closest(e);for(;s;)i.push(s),s=s.parentNode.closest(e);return i},prev(t,e){let i=t.previousElementSibling;for(;i;){if(i.matches(e))return[i];i=i.previousElementSibling}return[]},next(t,e){let i=t.nextElementSibling;for(;i;){if(i.matches(e))return[i];i=i.nextElementSibling}return[]},focusableChildren(t){const e=["a","button","input","textarea","select","details","[tabindex]",'[contenteditable="true"]'].map((t=>`${t}:not([tabindex^="-"])`)).join(",");return this.find(e,t).filter((t=>!d(t)&&h(t)))}},G={endCallback:null,leftCallback:null,rightCallback:null},J={endCallback:"(function|null)",leftCallback:"(function|null)",rightCallback:"(function|null)"};class Z extends R{constructor(t,e){super(),this._element=t,t&&Z.isSupported()&&(this._config=this._getConfig(e),this._deltaX=0,this._supportPointerEvents=Boolean(window.PointerEvent),this._initEvents())}static get Default(){return G}static get DefaultType(){return J}static get NAME(){return"swipe"}dispose(){$.off(this._element,".bs.swipe")}_start(t){this._supportPointerEvents?this._eventIsPointerPenTouch(t)&&(this._deltaX=t.clientX):this._deltaX=t.touches[0].clientX}_end(t){this._eventIsPointerPenTouch(t)&&(this._deltaX=t.clientX-this._deltaX),this._handleSwipe(),v(this._config.endCallback)}_move(t){this._deltaX=t.touches&&t.touches.length>1?0:t.touches[0].clientX-this._deltaX}_handleSwipe(){const t=Math.abs(this._deltaX);if(t<=40)return;const e=t/this._deltaX;this._deltaX=0,e&&v(e>0?this._config.rightCallback:this._config.leftCallback)}_initEvents(){this._supportPointerEvents?($.on(this._element,"pointerdown.bs.swipe",(t=>this._start(t))),$.on(this._element,"pointerup.bs.swipe",(t=>this._end(t))),this._element.classList.add("pointer-event")):($.on(this._element,"touchstart.bs.swipe",(t=>this._start(t))),$.on(this._element,"touchmove.bs.swipe",(t=>this._move(t))),$.on(this._element,"touchend.bs.swipe",(t=>this._end(t))))}_eventIsPointerPenTouch(t){return this._supportPointerEvents&&("pen"===t.pointerType||"touch"===t.pointerType)}static isSupported(){return"ontouchstart"in document.documentElement||navigator.maxTouchPoints>0}}const tt="next",et="prev",it="left",st="right",nt="slid.bs.carousel",ot="carousel",rt="active",at={ArrowLeft:st,ArrowRight:it},lt={interval:5e3,keyboard:!0,pause:"hover",ride:!1,touch:!0,wrap:!0},ct={interval:"(number|boolean)",keyboard:"boolean",pause:"(string|boolean)",ride:"(boolean|string)",touch:"boolean",wrap:"boolean"};class ht extends V{constructor(t,e){super(t,e),this._interval=null,this._activeElement=null,this._isSliding=!1,this.touchTimeout=null,this._swipeHelper=null,this._indicatorsElement=U.findOne(".carousel-indicators",this._element),this._addEventListeners(),this._config.ride===ot&&this.cycle()}static get Default(){return lt}static get DefaultType(){return ct}static get NAME(){return"carousel"}next(){this._slide(tt)}nextWhenVisible(){!document.hidden&&h(this._element)&&this.next()}prev(){this._slide(et)}pause(){this._isSliding&&a(this._element),this._clearInterval()}cycle(){this._clearInterval(),this._updateInterval(),this._interval=setInterval((()=>this.nextWhenVisible()),this._config.interval)}_maybeEnableCycle(){this._config.ride&&(this._isSliding?$.one(this._element,nt,(()=>this.cycle())):this.cycle())}to(t){const e=this._getItems();if(t>e.length-1||t<0)return;if(this._isSliding)return void $.one(this._element,nt,(()=>this.to(t)));const i=this._getItemIndex(this._getActive());if(i===t)return;const s=t>i?tt:et;this._slide(s,e[t])}dispose(){this._swipeHelper&&this._swipeHelper.dispose(),super.dispose()}_configAfterMerge(t){return t.defaultInterval=t.interval,t}_addEventListeners(){this._config.keyboard&&$.on(this._element,"keydown.bs.carousel",(t=>this._keydown(t))),"hover"===this._config.pause&&($.on(this._element,"mouseenter.bs.carousel",(()=>this.pause())),$.on(this._element,"mouseleave.bs.carousel",(()=>this._maybeEnableCycle()))),this._config.touch&&Z.isSupported()&&this._addTouchEventListeners()}_addTouchEventListeners(){for(const t of U.find(".carousel-item img",this._element))$.on(t,"dragstart.bs.carousel",(t=>t.preventDefault()));const t={leftCallback:()=>this._slide(this._directionToOrder(it)),rightCallback:()=>this._slide(this._directionToOrder(st)),endCallback:()=>{"hover"===this._config.pause&&(this.pause(),this.touchTimeout&&clearTimeout(this.touchTimeout),this.touchTimeout=setTimeout((()=>this._maybeEnableCycle()),500+this._config.interval))}};this._swipeHelper=new Z(this._element,t)}_keydown(t){if(/input|textarea/i.test(t.target.tagName))return;const e=at[t.key];e&&(t.preventDefault(),this._slide(this._directionToOrder(e)))}_getItemIndex(t){return this._getItems().indexOf(t)}_setActiveIndicatorElement(t){if(!this._indicatorsElement)return;const e=U.findOne(".active",this._indicatorsElement);e.classList.remove(rt),e.removeAttribute("aria-current");const i=U.findOne(`[data-bs-slide-to="${t}"]`,this._indicatorsElement);i&&(i.classList.add(rt),i.setAttribute("aria-current","true"))}_updateInterval(){const t=this._activeElement||this._getActive();if(!t)return;const e=Number.parseInt(t.getAttribute("data-bs-interval"),10);this._config.interval=e||this._config.defaultInterval}_slide(t,e=null){if(this._isSliding)return;const i=this._getActive(),s=t===tt,n=e||w(this._getItems(),i,s,this._config.wrap);if(n===i)return;const o=this._getItemIndex(n),r=e=>$.trigger(this._element,e,{relatedTarget:n,direction:this._orderToDirection(t),from:this._getItemIndex(i),to:o});if(r("slide.bs.carousel").defaultPrevented)return;if(!i||!n)return;const a=Boolean(this._interval);this.pause(),this._isSliding=!0,this._setActiveIndicatorElement(o),this._activeElement=n;const l=s?"carousel-item-start":"carousel-item-end",c=s?"carousel-item-next":"carousel-item-prev";n.classList.add(c),g(n),i.classList.add(l),n.classList.add(l),this._queueCallback((()=>{n.classList.remove(l,c),n.classList.add(rt),i.classList.remove(rt,c,l),this._isSliding=!1,r(nt)}),i,this._isAnimated()),a&&this.cycle()}_isAnimated(){return this._element.classList.contains("slide")}_getActive(){return U.findOne(".active.carousel-item",this._element)}_getItems(){return U.find(".carousel-item",this._element)}_clearInterval(){this._interval&&(clearInterval(this._interval),this._interval=null)}_directionToOrder(t){return m()?t===it?et:tt:t===it?tt:et}_orderToDirection(t){return m()?t===et?it:st:t===et?st:it}static jQueryInterface(t){return this.each((function(){const e=ht.getOrCreateInstance(this,t);if("number"!=typeof t){if("string"==typeof t){if(void 0===e[t]||t.startsWith("_")||"constructor"===t)throw new TypeError(`No method named "${t}"`);e[t]()}}else e.to(t)}))}}$.on(document,"click.bs.carousel.data-api","[data-bs-slide], [data-bs-slide-to]",(function(t){const e=r(this);if(!e||!e.classList.contains(ot))return;t.preventDefault();const i=ht.getOrCreateInstance(e),s=this.getAttribute("data-bs-slide-to");return s?(i.to(s),void i._maybeEnableCycle()):"next"===W.getDataAttribute(this,"slide")?(i.next(),void i._maybeEnableCycle()):(i.prev(),void i._maybeEnableCycle())})),$.on(window,"load.bs.carousel.data-api",(()=>{const t=U.find('[data-bs-ride="carousel"]');for(const e of t)ht.getOrCreateInstance(e)})),b(ht);const dt="show",ut="collapse",_t="collapsing",gt='[data-bs-toggle="collapse"]',ft={parent:null,toggle:!0},pt={parent:"(null|element)",toggle:"boolean"};class mt extends V{constructor(t,e){super(t,e),this._isTransitioning=!1,this._triggerArray=[];const i=U.find(gt);for(const t of i){const e=o(t),i=U.find(e).filter((t=>t===this._element));null!==e&&i.length&&this._triggerArray.push(t)}this._initializeChildren(),this._config.parent||this._addAriaAndCollapsedClass(this._triggerArray,this._isShown()),this._config.toggle&&this.toggle()}static get Default(){return ft}static get DefaultType(){return pt}static get NAME(){return"collapse"}toggle(){this._isShown()?this.hide():this.show()}show(){if(this._isTransitioning||this._isShown())return;let t=[];if(this._config.parent&&(t=this._getFirstLevelChildren(".collapse.show, .collapse.collapsing").filter((t=>t!==this._element)).map((t=>mt.getOrCreateInstance(t,{toggle:!1})))),t.length&&t[0]._isTransitioning)return;if($.trigger(this._element,"show.bs.collapse").defaultPrevented)return;for(const e of t)e.hide();const e=this._getDimension();this._element.classList.remove(ut),this._element.classList.add(_t),this._element.style[e]=0,this._addAriaAndCollapsedClass(this._triggerArray,!0),this._isTransitioning=!0;const i=`scroll${e[0].toUpperCase()+e.slice(1)}`;this._queueCallback((()=>{this._isTransitioning=!1,this._element.classList.remove(_t),this._element.classList.add(ut,dt),this._element.style[e]="",$.trigger(this._element,"shown.bs.collapse")}),this._element,!0),this._element.style[e]=`${this._element[i]}px`}hide(){if(this._isTransitioning||!this._isShown())return;if($.trigger(this._element,"hide.bs.collapse").defaultPrevented)return;const t=this._getDimension();this._element.style[t]=`${this._element.getBoundingClientRect()[t]}px`,g(this._element),this._element.classList.add(_t),this._element.classList.remove(ut,dt);for(const t of this._triggerArray){const e=r(t);e&&!this._isShown(e)&&this._addAriaAndCollapsedClass([t],!1)}this._isTransitioning=!0,this._element.style[t]="",this._queueCallback((()=>{this._isTransitioning=!1,this._element.classList.remove(_t),this._element.classList.add(ut),$.trigger(this._element,"hidden.bs.collapse")}),this._element,!0)}_isShown(t=this._element){return t.classList.contains(dt)}_configAfterMerge(t){return t.toggle=Boolean(t.toggle),t.parent=c(t.parent),t}_getDimension(){return this._element.classList.contains("collapse-horizontal")?"width":"height"}_initializeChildren(){if(!this._config.parent)return;const t=this._getFirstLevelChildren(gt);for(const e of t){const t=r(e);t&&this._addAriaAndCollapsedClass([e],this._isShown(t))}}_getFirstLevelChildren(t){const e=U.find(":scope .collapse .collapse",this._config.parent);return U.find(t,this._config.parent).filter((t=>!e.includes(t)))}_addAriaAndCollapsedClass(t,e){if(t.length)for(const i of t)i.classList.toggle("collapsed",!e),i.setAttribute("aria-expanded",e)}static jQueryInterface(t){const e={};return"string"==typeof t&&/show|hide/.test(t)&&(e.toggle=!1),this.each((function(){const i=mt.getOrCreateInstance(this,e);if("string"==typeof t){if(void 0===i[t])throw new TypeError(`No method named "${t}"`);i[t]()}}))}}$.on(document,"click.bs.collapse.data-api",gt,(function(t){("A"===t.target.tagName||t.delegateTarget&&"A"===t.delegateTarget.tagName)&&t.preventDefault();const e=o(this),i=U.find(e);for(const t of i)mt.getOrCreateInstance(t,{toggle:!1}).toggle()})),b(mt);const bt="dropdown",vt="ArrowUp",yt="ArrowDown",wt="click.bs.dropdown.data-api",At="keydown.bs.dropdown.data-api",Tt="show",Et='[data-bs-toggle="dropdown"]:not(.disabled):not(:disabled)',Ct=`${Et}.show`,kt=".dropdown-menu",Lt=m()?"top-end":"top-start",Ot=m()?"top-start":"top-end",It=m()?"bottom-end":"bottom-start",St=m()?"bottom-start":"bottom-end",Dt=m()?"left-start":"right-start",Nt=m()?"right-start":"left-start",Pt={autoClose:!0,boundary:"clippingParents",display:"dynamic",offset:[0,2],popperConfig:null,reference:"toggle"},xt={autoClose:"(boolean|string)",boundary:"(string|element)",display:"string",offset:"(array|string|function)",popperConfig:"(null|object|function)",reference:"(string|element|object)"};class Mt extends V{constructor(t,e){super(t,e),this._popper=null,this._parent=this._element.parentNode,this._menu=U.findOne(kt,this._parent),this._inNavbar=this._detectNavbar()}static get Default(){return Pt}static get DefaultType(){return xt}static get NAME(){return bt}toggle(){return this._isShown()?this.hide():this.show()}show(){if(d(this._element)||this._isShown())return;const t={relatedTarget:this._element};if(!$.trigger(this._element,"show.bs.dropdown",t).defaultPrevented){if(this._createPopper(),"ontouchstart"in document.documentElement&&!this._parent.closest(".navbar-nav"))for(const t of[].concat(...document.body.children))$.on(t,"mouseover",_);this._element.focus(),this._element.setAttribute("aria-expanded",!0),this._menu.classList.add(Tt),this._element.classList.add(Tt),$.trigger(this._element,"shown.bs.dropdown",t)}}hide(){if(d(this._element)||!this._isShown())return;const t={relatedTarget:this._element};this._completeHide(t)}dispose(){this._popper&&this._popper.destroy(),super.dispose()}update(){this._inNavbar=this._detectNavbar(),this._popper&&this._popper.update()}_completeHide(t){if(!$.trigger(this._element,"hide.bs.dropdown",t).defaultPrevented){if("ontouchstart"in document.documentElement)for(const t of[].concat(...document.body.children))$.off(t,"mouseover",_);this._popper&&this._popper.destroy(),this._menu.classList.remove(Tt),this._element.classList.remove(Tt),this._element.setAttribute("aria-expanded","false"),W.removeDataAttribute(this._menu,"popper"),$.trigger(this._element,"hidden.bs.dropdown",t)}}_getConfig(t){if("object"==typeof(t=super._getConfig(t)).reference&&!l(t.reference)&&"function"!=typeof t.reference.getBoundingClientRect)throw new TypeError(`${bt.toUpperCase()}: Option "reference" provided type "object" without a required "getBoundingClientRect" method.`);return t}_createPopper(){if(void 0===i)throw new TypeError("Bootstrap's dropdowns require Popper (https://popper.js.org)");let t=this._element;"parent"===this._config.reference?t=this._parent:l(this._config.reference)?t=c(this._config.reference):"object"==typeof this._config.reference&&(t=this._config.reference);const e=this._getPopperConfig();this._popper=i.createPopper(t,this._menu,e)}_isShown(){return this._menu.classList.contains(Tt)}_getPlacement(){const t=this._parent;if(t.classList.contains("dropend"))return Dt;if(t.classList.contains("dropstart"))return Nt;if(t.classList.contains("dropup-center"))return"top";if(t.classList.contains("dropdown-center"))return"bottom";const e="end"===getComputedStyle(this._menu).getPropertyValue("--bs-position").trim();return t.classList.contains("dropup")?e?Ot:Lt:e?St:It}_detectNavbar(){return null!==this._element.closest(".navbar")}_getOffset(){const{offset:t}=this._config;return"string"==typeof t?t.split(",").map((t=>Number.parseInt(t,10))):"function"==typeof t?e=>t(e,this._element):t}_getPopperConfig(){const t={placement:this._getPlacement(),modifiers:[{name:"preventOverflow",options:{boundary:this._config.boundary}},{name:"offset",options:{offset:this._getOffset()}}]};return(this._inNavbar||"static"===this._config.display)&&(W.setDataAttribute(this._menu,"popper","static"),t.modifiers=[{name:"applyStyles",enabled:!1}]),{...t,..."function"==typeof this._config.popperConfig?this._config.popperConfig(t):this._config.popperConfig}}_selectMenuItem({key:t,target:e}){const i=U.find(".dropdown-menu .dropdown-item:not(.disabled):not(:disabled)",this._menu).filter((t=>h(t)));i.length&&w(i,e,t===yt,!i.includes(e)).focus()}static jQueryInterface(t){return this.each((function(){const e=Mt.getOrCreateInstance(this,t);if("string"==typeof t){if(void 0===e[t])throw new TypeError(`No method named "${t}"`);e[t]()}}))}static clearMenus(t){if(2===t.button||"keyup"===t.type&&"Tab"!==t.key)return;const e=U.find(Ct);for(const i of e){const e=Mt.getInstance(i);if(!e||!1===e._config.autoClose)continue;const s=t.composedPath(),n=s.includes(e._menu);if(s.includes(e._element)||"inside"===e._config.autoClose&&!n||"outside"===e._config.autoClose&&n)continue;if(e._menu.contains(t.target)&&("keyup"===t.type&&"Tab"===t.key||/input|select|option|textarea|form/i.test(t.target.tagName)))continue;const o={relatedTarget:e._element};"click"===t.type&&(o.clickEvent=t),e._completeHide(o)}}static dataApiKeydownHandler(t){const e=/input|textarea/i.test(t.target.tagName),i="Escape"===t.key,s=[vt,yt].includes(t.key);if(!s&&!i)return;if(e&&!i)return;t.preventDefault();const n=U.findOne(Et,t.delegateTarget.parentNode),o=Mt.getOrCreateInstance(n);if(s)return t.stopPropagation(),o.show(),void o._selectMenuItem(t);o._isShown()&&(t.stopPropagation(),o.hide(),n.focus())}}$.on(document,At,Et,Mt.dataApiKeydownHandler),$.on(document,At,kt,Mt.dataApiKeydownHandler),$.on(document,wt,Mt.clearMenus),$.on(document,"keyup.bs.dropdown.data-api",Mt.clearMenus),$.on(document,wt,Et,(function(t){t.preventDefault(),Mt.getOrCreateInstance(this).toggle()})),b(Mt);const jt=".fixed-top, .fixed-bottom, .is-fixed, .sticky-top",$t=".sticky-top",Ft="padding-right",zt="margin-right";class Ht{constructor(){this._element=document.body}getWidth(){const t=document.documentElement.clientWidth;return Math.abs(window.innerWidth-t)}hide(){const t=this.getWidth();this._disableOverFlow(),this._setElementAttributes(this._element,Ft,(e=>e+t)),this._setElementAttributes(jt,Ft,(e=>e+t)),this._setElementAttributes($t,zt,(e=>e-t))}reset(){this._resetElementAttributes(this._element,"overflow"),this._resetElementAttributes(this._element,Ft),this._resetElementAttributes(jt,Ft),this._resetElementAttributes($t,zt)}isOverflowing(){return this.getWidth()>0}_disableOverFlow(){this._saveInitialAttribute(this._element,"overflow"),this._element.style.overflow="hidden"}_setElementAttributes(t,e,i){const s=this.getWidth();this._applyManipulationCallback(t,(t=>{if(t!==this._element&&window.innerWidth>t.clientWidth+s)return;this._saveInitialAttribute(t,e);const n=window.getComputedStyle(t).getPropertyValue(e);t.style.setProperty(e,`${i(Number.parseFloat(n))}px`)}))}_saveInitialAttribute(t,e){const i=t.style.getPropertyValue(e);i&&W.setDataAttribute(t,e,i)}_resetElementAttributes(t,e){this._applyManipulationCallback(t,(t=>{const i=W.getDataAttribute(t,e);null!==i?(W.removeDataAttribute(t,e),t.style.setProperty(e,i)):t.style.removeProperty(e)}))}_applyManipulationCallback(t,e){if(l(t))e(t);else for(const i of U.find(t,this._element))e(i)}}const qt="show",Bt="mousedown.bs.backdrop",Wt={className:"modal-backdrop",clickCallback:null,isAnimated:!1,isVisible:!0,rootElement:"body"},Rt={className:"string",clickCallback:"(function|null)",isAnimated:"boolean",isVisible:"boolean",rootElement:"(element|string)"};class Vt extends R{constructor(t){super(),this._config=this._getConfig(t),this._isAppended=!1,this._element=null}static get Default(){return Wt}static get DefaultType(){return Rt}static get NAME(){return"backdrop"}show(t){if(!this._config.isVisible)return void v(t);this._append();const e=this._getElement();this._config.isAnimated&&g(e),e.classList.add(qt),this._emulateAnimation((()=>{v(t)}))}hide(t){this._config.isVisible?(this._getElement().classList.remove(qt),this._emulateAnimation((()=>{this.dispose(),v(t)}))):v(t)}dispose(){this._isAppended&&($.off(this._element,Bt),this._element.remove(),this._isAppended=!1)}_getElement(){if(!this._element){const t=document.createElement("div");t.className=this._config.className,this._config.isAnimated&&t.classList.add("fade"),this._element=t}return this._element}_configAfterMerge(t){return t.rootElement=c(t.rootElement),t}_append(){if(this._isAppended)return;const t=this._getElement();this._config.rootElement.append(t),$.on(t,Bt,(()=>{v(this._config.clickCallback)})),this._isAppended=!0}_emulateAnimation(t){y(t,this._getElement(),this._config.isAnimated)}}const Kt=".bs.focustrap",Qt="backward",Xt={autofocus:!0,trapElement:null},Yt={autofocus:"boolean",trapElement:"element"};class Ut extends R{constructor(t){super(),this._config=this._getConfig(t),this._isActive=!1,this._lastTabNavDirection=null}static get Default(){return Xt}static get DefaultType(){return Yt}static get NAME(){return"focustrap"}activate(){this._isActive||(this._config.autofocus&&this._config.trapElement.focus(),$.off(document,Kt),$.on(document,"focusin.bs.focustrap",(t=>this._handleFocusin(t))),$.on(document,"keydown.tab.bs.focustrap",(t=>this._handleKeydown(t))),this._isActive=!0)}deactivate(){this._isActive&&(this._isActive=!1,$.off(document,Kt))}_handleFocusin(t){const{trapElement:e}=this._config;if(t.target===document||t.target===e||e.contains(t.target))return;const i=U.focusableChildren(e);0===i.length?e.focus():this._lastTabNavDirection===Qt?i[i.length-1].focus():i[0].focus()}_handleKeydown(t){"Tab"===t.key&&(this._lastTabNavDirection=t.shiftKey?Qt:"forward")}}const Gt="hidden.bs.modal",Jt="show.bs.modal",Zt="modal-open",te="show",ee="modal-static",ie={backdrop:!0,focus:!0,keyboard:!0},se={backdrop:"(boolean|string)",focus:"boolean",keyboard:"boolean"};class ne extends V{constructor(t,e){super(t,e),this._dialog=U.findOne(".modal-dialog",this._element),this._backdrop=this._initializeBackDrop(),this._focustrap=this._initializeFocusTrap(),this._isShown=!1,this._isTransitioning=!1,this._scrollBar=new Ht,this._addEventListeners()}static get Default(){return ie}static get DefaultType(){return se}static get NAME(){return"modal"}toggle(t){return this._isShown?this.hide():this.show(t)}show(t){this._isShown||this._isTransitioning||$.trigger(this._element,Jt,{relatedTarget:t}).defaultPrevented||(this._isShown=!0,this._isTransitioning=!0,this._scrollBar.hide(),document.body.classList.add(Zt),this._adjustDialog(),this._backdrop.show((()=>this._showElement(t))))}hide(){this._isShown&&!this._isTransitioning&&($.trigger(this._element,"hide.bs.modal").defaultPrevented||(this._isShown=!1,this._isTransitioning=!0,this._focustrap.deactivate(),this._element.classList.remove(te),this._queueCallback((()=>this._hideModal()),this._element,this._isAnimated())))}dispose(){for(const t of[window,this._dialog])$.off(t,".bs.modal");this._backdrop.dispose(),this._focustrap.deactivate(),super.dispose()}handleUpdate(){this._adjustDialog()}_initializeBackDrop(){return new Vt({isVisible:Boolean(this._config.backdrop),isAnimated:this._isAnimated()})}_initializeFocusTrap(){return new Ut({trapElement:this._element})}_showElement(t){document.body.contains(this._element)||document.body.append(this._element),this._element.style.display="block",this._element.removeAttribute("aria-hidden"),this._element.setAttribute("aria-modal",!0),this._element.setAttribute("role","dialog"),this._element.scrollTop=0;const e=U.findOne(".modal-body",this._dialog);e&&(e.scrollTop=0),g(this._element),this._element.classList.add(te),this._queueCallback((()=>{this._config.focus&&this._focustrap.activate(),this._isTransitioning=!1,$.trigger(this._element,"shown.bs.modal",{relatedTarget:t})}),this._dialog,this._isAnimated())}_addEventListeners(){$.on(this._element,"keydown.dismiss.bs.modal",(t=>{if("Escape"===t.key)return this._config.keyboard?(t.preventDefault(),void this.hide()):void this._triggerBackdropTransition()})),$.on(window,"resize.bs.modal",(()=>{this._isShown&&!this._isTransitioning&&this._adjustDialog()})),$.on(this._element,"mousedown.dismiss.bs.modal",(t=>{t.target===t.currentTarget&&("static"!==this._config.backdrop?this._config.backdrop&&this.hide():this._triggerBackdropTransition())}))}_hideModal(){this._element.style.display="none",this._element.setAttribute("aria-hidden",!0),this._element.removeAttribute("aria-modal"),this._element.removeAttribute("role"),this._isTransitioning=!1,this._backdrop.hide((()=>{document.body.classList.remove(Zt),this._resetAdjustments(),this._scrollBar.reset(),$.trigger(this._element,Gt)}))}_isAnimated(){return this._element.classList.contains("fade")}_triggerBackdropTransition(){if($.trigger(this._element,"hidePrevented.bs.modal").defaultPrevented)return;const t=this._element.scrollHeight>document.documentElement.clientHeight,e=this._element.style.overflowY;"hidden"===e||this._element.classList.contains(ee)||(t||(this._element.style.overflowY="hidden"),this._element.classList.add(ee),this._queueCallback((()=>{this._element.classList.remove(ee),this._queueCallback((()=>{this._element.style.overflowY=e}),this._dialog)}),this._dialog),this._element.focus())}_adjustDialog(){const t=this._element.scrollHeight>document.documentElement.clientHeight,e=this._scrollBar.getWidth(),i=e>0;if(i&&!t){const t=m()?"paddingLeft":"paddingRight";this._element.style[t]=`${e}px`}if(!i&&t){const t=m()?"paddingRight":"paddingLeft";this._element.style[t]=`${e}px`}}_resetAdjustments(){this._element.style.paddingLeft="",this._element.style.paddingRight=""}static jQueryInterface(t,e){return this.each((function(){const i=ne.getOrCreateInstance(this,t);if("string"==typeof t){if(void 0===i[t])throw new TypeError(`No method named "${t}"`);i[t](e)}}))}}$.on(document,"click.bs.modal.data-api",'[data-bs-toggle="modal"]',(function(t){const e=r(this);["A","AREA"].includes(this.tagName)&&t.preventDefault(),$.one(e,Jt,(t=>{t.defaultPrevented||$.one(e,Gt,(()=>{h(this)&&this.focus()}))}));const i=U.findOne(".modal.show");i&&ne.getInstance(i).hide(),ne.getOrCreateInstance(e).toggle(this)})),K(ne),b(ne);const oe="show",re="showing",ae="hiding",le=".offcanvas.show",ce="hidePrevented.bs.offcanvas",he="hidden.bs.offcanvas",de={backdrop:!0,keyboard:!0,scroll:!1},ue={backdrop:"(boolean|string)",keyboard:"boolean",scroll:"boolean"};class _e extends V{constructor(t,e){super(t,e),this._isShown=!1,this._backdrop=this._initializeBackDrop(),this._focustrap=this._initializeFocusTrap(),this._addEventListeners()}static get Default(){return de}static get DefaultType(){return ue}static get NAME(){return"offcanvas"}toggle(t){return this._isShown?this.hide():this.show(t)}show(t){this._isShown||$.trigger(this._element,"show.bs.offcanvas",{relatedTarget:t}).defaultPrevented||(this._isShown=!0,this._backdrop.show(),this._config.scroll||(new Ht).hide(),this._element.setAttribute("aria-modal",!0),this._element.setAttribute("role","dialog"),this._element.classList.add(re),this._queueCallback((()=>{this._config.scroll&&!this._config.backdrop||this._focustrap.activate(),this._element.classList.add(oe),this._element.classList.remove(re),$.trigger(this._element,"shown.bs.offcanvas",{relatedTarget:t})}),this._element,!0))}hide(){this._isShown&&($.trigger(this._element,"hide.bs.offcanvas").defaultPrevented||(this._focustrap.deactivate(),this._element.blur(),this._isShown=!1,this._element.classList.add(ae),this._backdrop.hide(),this._queueCallback((()=>{this._element.classList.remove(oe,ae),this._element.removeAttribute("aria-modal"),this._element.removeAttribute("role"),this._config.scroll||(new Ht).reset(),$.trigger(this._element,he)}),this._element,!0)))}dispose(){this._backdrop.dispose(),this._focustrap.deactivate(),super.dispose()}_initializeBackDrop(){const t=Boolean(this._config.backdrop);return new Vt({className:"offcanvas-backdrop",isVisible:t,isAnimated:!0,rootElement:this._element.parentNode,clickCallback:t?()=>{"static"!==this._config.backdrop?this.hide():$.trigger(this._element,ce)}:null})}_initializeFocusTrap(){return new Ut({trapElement:this._element})}_addEventListeners(){$.on(this._element,"keydown.dismiss.bs.offcanvas",(t=>{"Escape"===t.key&&(this._config.keyboard?this.hide():$.trigger(this._element,ce))}))}static jQueryInterface(t){return this.each((function(){const e=_e.getOrCreateInstance(this,t);if("string"==typeof t){if(void 0===e[t]||t.startsWith("_")||"constructor"===t)throw new TypeError(`No method named "${t}"`);e[t](this)}}))}}$.on(document,"click.bs.offcanvas.data-api",'[data-bs-toggle="offcanvas"]',(function(t){const e=r(this);if(["A","AREA"].includes(this.tagName)&&t.preventDefault(),d(this))return;$.one(e,he,(()=>{h(this)&&this.focus()}));const i=U.findOne(le);i&&i!==e&&_e.getInstance(i).hide(),_e.getOrCreateInstance(e).toggle(this)})),$.on(window,"load.bs.offcanvas.data-api",(()=>{for(const t of U.find(le))_e.getOrCreateInstance(t).show()})),$.on(window,"resize.bs.offcanvas",(()=>{for(const t of U.find("[aria-modal][class*=show][class*=offcanvas-]"))"fixed"!==getComputedStyle(t).position&&_e.getOrCreateInstance(t).hide()})),K(_e),b(_e);const ge=new Set(["background","cite","href","itemtype","longdesc","poster","src","xlink:href"]),fe=/^(?:(?:https?|mailto|ftp|tel|file|sms):|[^#&/:?]*(?:[#/?]|$))/i,pe=/^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[\d+/a-z]+=*$/i,me=(t,e)=>{const i=t.nodeName.toLowerCase();return e.includes(i)?!ge.has(i)||Boolean(fe.test(t.nodeValue)||pe.test(t.nodeValue)):e.filter((t=>t instanceof RegExp)).some((t=>t.test(i)))},be={"*":["class","dir","id","lang","role",/^aria-[\w-]*$/i],a:["target","href","title","rel"],area:[],b:[],br:[],col:[],code:[],div:[],em:[],hr:[],h1:[],h2:[],h3:[],h4:[],h5:[],h6:[],i:[],img:["src","srcset","alt","title","width","height"],li:[],ol:[],p:[],pre:[],s:[],small:[],span:[],sub:[],sup:[],strong:[],u:[],ul:[]},ve={allowList:be,content:{},extraClass:"",html:!1,sanitize:!0,sanitizeFn:null,template:"<div></div>"},ye={allowList:"object",content:"object",extraClass:"(string|function)",html:"boolean",sanitize:"boolean",sanitizeFn:"(null|function)",template:"string"},we={entry:"(string|element|function|null)",selector:"(string|element)"};class Ae extends R{constructor(t){super(),this._config=this._getConfig(t)}static get Default(){return ve}static get DefaultType(){return ye}static get NAME(){return"TemplateFactory"}getContent(){return Object.values(this._config.content).map((t=>this._resolvePossibleFunction(t))).filter(Boolean)}hasContent(){return this.getContent().length>0}changeContent(t){return this._checkContent(t),this._config.content={...this._config.content,...t},this}toHtml(){const t=document.createElement("div");t.innerHTML=this._maybeSanitize(this._config.template);for(const[e,i]of Object.entries(this._config.content))this._setContent(t,i,e);const e=t.children[0],i=this._resolvePossibleFunction(this._config.extraClass);return i&&e.classList.add(...i.split(" ")),e}_typeCheckConfig(t){super._typeCheckConfig(t),this._checkContent(t.content)}_checkContent(t){for(const[e,i]of Object.entries(t))super._typeCheckConfig({selector:e,entry:i},we)}_setContent(t,e,i){const s=U.findOne(i,t);s&&((e=this._resolvePossibleFunction(e))?l(e)?this._putElementInTemplate(c(e),s):this._config.html?s.innerHTML=this._maybeSanitize(e):s.textContent=e:s.remove())}_maybeSanitize(t){return this._config.sanitize?function(t,e,i){if(!t.length)return t;if(i&&"function"==typeof i)return i(t);const s=(new window.DOMParser).parseFromString(t,"text/html"),n=[].concat(...s.body.querySelectorAll("*"));for(const t of n){const i=t.nodeName.toLowerCase();if(!Object.keys(e).includes(i)){t.remove();continue}const s=[].concat(...t.attributes),n=[].concat(e["*"]||[],e[i]||[]);for(const e of s)me(e,n)||t.removeAttribute(e.nodeName)}return s.body.innerHTML}(t,this._config.allowList,this._config.sanitizeFn):t}_resolvePossibleFunction(t){return"function"==typeof t?t(this):t}_putElementInTemplate(t,e){if(this._config.html)return e.innerHTML="",void e.append(t);e.textContent=t.textContent}}const Te=new Set(["sanitize","allowList","sanitizeFn"]),Ee="fade",Ce="show",ke=".modal",Le="hide.bs.modal",Oe="hover",Ie="focus",Se={AUTO:"auto",TOP:"top",RIGHT:m()?"left":"right",BOTTOM:"bottom",LEFT:m()?"right":"left"},De={allowList:be,animation:!0,boundary:"clippingParents",container:!1,customClass:"",delay:0,fallbackPlacements:["top","right","bottom","left"],html:!1,offset:[0,0],placement:"top",popperConfig:null,sanitize:!0,sanitizeFn:null,selector:!1,template:'<div class="tooltip" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>',title:"",trigger:"hover focus"},Ne={allowList:"object",animation:"boolean",boundary:"(string|element)",container:"(string|element|boolean)",customClass:"(string|function)",delay:"(number|object)",fallbackPlacements:"array",html:"boolean",offset:"(array|string|function)",placement:"(string|function)",popperConfig:"(null|object|function)",sanitize:"boolean",sanitizeFn:"(null|function)",selector:"(string|boolean)",template:"string",title:"(string|element|function)",trigger:"string"};class Pe extends V{constructor(t,e){if(void 0===i)throw new TypeError("Bootstrap's tooltips require Popper (https://popper.js.org)");super(t,e),this._isEnabled=!0,this._timeout=0,this._isHovered=!1,this._activeTrigger={},this._popper=null,this._templateFactory=null,this._newContent=null,this.tip=null,this._setListeners()}static get Default(){return De}static get DefaultType(){return Ne}static get NAME(){return"tooltip"}enable(){this._isEnabled=!0}disable(){this._isEnabled=!1}toggleEnabled(){this._isEnabled=!this._isEnabled}toggle(t){if(this._isEnabled){if(t){const e=this._initializeOnDelegatedTarget(t);return e._activeTrigger.click=!e._activeTrigger.click,void(e._isWithActiveTrigger()?e._enter():e._leave())}this._isShown()?this._leave():this._enter()}}dispose(){clearTimeout(this._timeout),$.off(this._element.closest(ke),Le,this._hideModalHandler),this.tip&&this.tip.remove(),this._disposePopper(),super.dispose()}show(){if("none"===this._element.style.display)throw new Error("Please use show on visible elements");if(!this._isWithContent()||!this._isEnabled)return;const t=$.trigger(this._element,this.constructor.eventName("show")),e=(u(this._element)||this._element.ownerDocument.documentElement).contains(this._element);if(t.defaultPrevented||!e)return;this.tip&&(this.tip.remove(),this.tip=null);const i=this._getTipElement();this._element.setAttribute("aria-describedby",i.getAttribute("id"));const{container:s}=this._config;if(this._element.ownerDocument.documentElement.contains(this.tip)||(s.append(i),$.trigger(this._element,this.constructor.eventName("inserted"))),this._popper?this._popper.update():this._popper=this._createPopper(i),i.classList.add(Ce),"ontouchstart"in document.documentElement)for(const t of[].concat(...document.body.children))$.on(t,"mouseover",_);this._queueCallback((()=>{const t=this._isHovered;this._isHovered=!1,$.trigger(this._element,this.constructor.eventName("shown")),t&&this._leave()}),this.tip,this._isAnimated())}hide(){if(!this._isShown())return;if($.trigger(this._element,this.constructor.eventName("hide")).defaultPrevented)return;const t=this._getTipElement();if(t.classList.remove(Ce),"ontouchstart"in document.documentElement)for(const t of[].concat(...document.body.children))$.off(t,"mouseover",_);this._activeTrigger.click=!1,this._activeTrigger.focus=!1,this._activeTrigger.hover=!1,this._isHovered=!1,this._queueCallback((()=>{this._isWithActiveTrigger()||(this._isHovered||t.remove(),this._element.removeAttribute("aria-describedby"),$.trigger(this._element,this.constructor.eventName("hidden")),this._disposePopper())}),this.tip,this._isAnimated())}update(){this._popper&&this._popper.update()}_isWithContent(){return Boolean(this._getTitle())}_getTipElement(){return this.tip||(this.tip=this._createTipElement(this._newContent||this._getContentForTemplate())),this.tip}_createTipElement(t){const e=this._getTemplateFactory(t).toHtml();if(!e)return null;e.classList.remove(Ee,Ce),e.classList.add(`bs-${this.constructor.NAME}-auto`);const i=(t=>{do{t+=Math.floor(1e6*Math.random())}while(document.getElementById(t));return t})(this.constructor.NAME).toString();return e.setAttribute("id",i),this._isAnimated()&&e.classList.add(Ee),e}setContent(t){this._newContent=t,this._isShown()&&(this._disposePopper(),this.show())}_getTemplateFactory(t){return this._templateFactory?this._templateFactory.changeContent(t):this._templateFactory=new Ae({...this._config,content:t,extraClass:this._resolvePossibleFunction(this._config.customClass)}),this._templateFactory}_getContentForTemplate(){return{".tooltip-inner":this._getTitle()}}_getTitle(){return this._resolvePossibleFunction(this._config.title)||this._config.originalTitle}_initializeOnDelegatedTarget(t){return this.constructor.getOrCreateInstance(t.delegateTarget,this._getDelegateConfig())}_isAnimated(){return this._config.animation||this.tip&&this.tip.classList.contains(Ee)}_isShown(){return this.tip&&this.tip.classList.contains(Ce)}_createPopper(t){const e="function"==typeof this._config.placement?this._config.placement.call(this,t,this._element):this._config.placement,s=Se[e.toUpperCase()];return i.createPopper(this._element,t,this._getPopperConfig(s))}_getOffset(){const{offset:t}=this._config;return"string"==typeof t?t.split(",").map((t=>Number.parseInt(t,10))):"function"==typeof t?e=>t(e,this._element):t}_resolvePossibleFunction(t){return"function"==typeof t?t.call(this._element):t}_getPopperConfig(t){const e={placement:t,modifiers:[{name:"flip",options:{fallbackPlacements:this._config.fallbackPlacements}},{name:"offset",options:{offset:this._getOffset()}},{name:"preventOverflow",options:{boundary:this._config.boundary}},{name:"arrow",options:{element:`.${this.constructor.NAME}-arrow`}},{name:"preSetPlacement",enabled:!0,phase:"beforeMain",fn:t=>{this._getTipElement().setAttribute("data-popper-placement",t.state.placement)}}]};return{...e,..."function"==typeof this._config.popperConfig?this._config.popperConfig(e):this._config.popperConfig}}_setListeners(){const t=this._config.trigger.split(" ");for(const e of t)if("click"===e)$.on(this._element,this.constructor.eventName("click"),this._config.selector,(t=>this.toggle(t)));else if("manual"!==e){const t=e===Oe?this.constructor.eventName("mouseenter"):this.constructor.eventName("focusin"),i=e===Oe?this.constructor.eventName("mouseleave"):this.constructor.eventName("focusout");$.on(this._element,t,this._config.selector,(t=>{const e=this._initializeOnDelegatedTarget(t);e._activeTrigger["focusin"===t.type?Ie:Oe]=!0,e._enter()})),$.on(this._element,i,this._config.selector,(t=>{const e=this._initializeOnDelegatedTarget(t);e._activeTrigger["focusout"===t.type?Ie:Oe]=e._element.contains(t.relatedTarget),e._leave()}))}this._hideModalHandler=()=>{this._element&&this.hide()},$.on(this._element.closest(ke),Le,this._hideModalHandler),this._config.selector?this._config={...this._config,trigger:"manual",selector:""}:this._fixTitle()}_fixTitle(){const t=this._config.originalTitle;t&&(this._element.getAttribute("aria-label")||this._element.textContent.trim()||this._element.setAttribute("aria-label",t),this._element.removeAttribute("title"))}_enter(){this._isShown()||this._isHovered?this._isHovered=!0:(this._isHovered=!0,this._setTimeout((()=>{this._isHovered&&this.show()}),this._config.delay.show))}_leave(){this._isWithActiveTrigger()||(this._isHovered=!1,this._setTimeout((()=>{this._isHovered||this.hide()}),this._config.delay.hide))}_setTimeout(t,e){clearTimeout(this._timeout),this._timeout=setTimeout(t,e)}_isWithActiveTrigger(){return Object.values(this._activeTrigger).includes(!0)}_getConfig(t){const e=W.getDataAttributes(this._element);for(const t of Object.keys(e))Te.has(t)&&delete e[t];return t={...e,..."object"==typeof t&&t?t:{}},t=this._mergeConfigObj(t),t=this._configAfterMerge(t),this._typeCheckConfig(t),t}_configAfterMerge(t){return t.container=!1===t.container?document.body:c(t.container),"number"==typeof t.delay&&(t.delay={show:t.delay,hide:t.delay}),t.originalTitle=this._element.getAttribute("title")||"","number"==typeof t.title&&(t.title=t.title.toString()),"number"==typeof t.content&&(t.content=t.content.toString()),t}_getDelegateConfig(){const t={};for(const e in this._config)this.constructor.Default[e]!==this._config[e]&&(t[e]=this._config[e]);return t}_disposePopper(){this._popper&&(this._popper.destroy(),this._popper=null)}static jQueryInterface(t){return this.each((function(){const e=Pe.getOrCreateInstance(this,t);if("string"==typeof t){if(void 0===e[t])throw new TypeError(`No method named "${t}"`);e[t]()}}))}}b(Pe);const xe={...Pe.Default,content:"",offset:[0,8],placement:"right",template:'<div class="popover" role="tooltip"><div class="popover-arrow"></div><h3 class="popover-header"></h3><div class="popover-body"></div></div>',trigger:"click"},Me={...Pe.DefaultType,content:"(null|string|element|function)"};class je extends Pe{static get Default(){return xe}static get DefaultType(){return Me}static get NAME(){return"popover"}_isWithContent(){return this._getTitle()||this._getContent()}_getContentForTemplate(){return{".popover-header":this._getTitle(),".popover-body":this._getContent()}}_getContent(){return this._resolvePossibleFunction(this._config.content)}static jQueryInterface(t){return this.each((function(){const e=je.getOrCreateInstance(this,t);if("string"==typeof t){if(void 0===e[t])throw new TypeError(`No method named "${t}"`);e[t]()}}))}}b(je);const $e="click.bs.scrollspy",Fe="active",ze="[href]",He={offset:null,rootMargin:"0px 0px -25%",smoothScroll:!1,target:null},qe={offset:"(number|null)",rootMargin:"string",smoothScroll:"boolean",target:"element"};class Be extends V{constructor(t,e){super(t,e),this._targetLinks=new Map,this._observableSections=new Map,this._rootElement="visible"===getComputedStyle(this._element).overflowY?null:this._element,this._activeTarget=null,this._observer=null,this._previousScrollData={visibleEntryTop:0,parentScrollTop:0},this.refresh()}static get Default(){return He}static get DefaultType(){return qe}static get NAME(){return"scrollspy"}refresh(){this._initializeTargetsAndObservables(),this._maybeEnableSmoothScroll(),this._observer?this._observer.disconnect():this._observer=this._getNewObserver();for(const t of this._observableSections.values())this._observer.observe(t)}dispose(){this._observer.disconnect(),super.dispose()}_configAfterMerge(t){return t.target=c(t.target)||document.body,t}_maybeEnableSmoothScroll(){this._config.smoothScroll&&($.off(this._config.target,$e),$.on(this._config.target,$e,ze,(t=>{const e=this._observableSections.get(t.target.hash);if(e){t.preventDefault();const i=this._rootElement||window,s=e.offsetTop-this._element.offsetTop;if(i.scrollTo)return void i.scrollTo({top:s,behavior:"smooth"});i.scrollTop=s}})))}_getNewObserver(){const t={root:this._rootElement,threshold:[.1,.5,1],rootMargin:this._getRootMargin()};return new IntersectionObserver((t=>this._observerCallback(t)),t)}_observerCallback(t){const e=t=>this._targetLinks.get(`#${t.target.id}`),i=t=>{this._previousScrollData.visibleEntryTop=t.target.offsetTop,this._process(e(t))},s=(this._rootElement||document.documentElement).scrollTop,n=s>=this._previousScrollData.parentScrollTop;this._previousScrollData.parentScrollTop=s;for(const o of t){if(!o.isIntersecting){this._activeTarget=null,this._clearActiveClass(e(o));continue}const t=o.target.offsetTop>=this._previousScrollData.visibleEntryTop;if(n&&t){if(i(o),!s)return}else n||t||i(o)}}_getRootMargin(){return this._config.offset?`${this._config.offset}px 0px -30%`:this._config.rootMargin}_initializeTargetsAndObservables(){this._targetLinks=new Map,this._observableSections=new Map;const t=U.find(ze,this._config.target);for(const e of t){if(!e.hash||d(e))continue;const t=U.findOne(e.hash,this._element);h(t)&&(this._targetLinks.set(e.hash,e),this._observableSections.set(e.hash,t))}}_process(t){this._activeTarget!==t&&(this._clearActiveClass(this._config.target),this._activeTarget=t,t.classList.add(Fe),this._activateParents(t),$.trigger(this._element,"activate.bs.scrollspy",{relatedTarget:t}))}_activateParents(t){if(t.classList.contains("dropdown-item"))U.findOne(".dropdown-toggle",t.closest(".dropdown")).classList.add(Fe);else for(const e of U.parents(t,".nav, .list-group"))for(const t of U.prev(e,".nav-link, .nav-item > .nav-link, .list-group-item"))t.classList.add(Fe)}_clearActiveClass(t){t.classList.remove(Fe);const e=U.find("[href].active",t);for(const t of e)t.classList.remove(Fe)}static jQueryInterface(t){return this.each((function(){const e=Be.getOrCreateInstance(this,t);if("string"==typeof t){if(void 0===e[t]||t.startsWith("_")||"constructor"===t)throw new TypeError(`No method named "${t}"`);e[t]()}}))}}$.on(window,"load.bs.scrollspy.data-api",(()=>{for(const t of U.find('[data-bs-spy="scroll"]'))Be.getOrCreateInstance(t)})),b(Be);const We="ArrowLeft",Re="ArrowRight",Ve="ArrowUp",Ke="ArrowDown",Qe="active",Xe="fade",Ye="show",Ue='[data-bs-toggle="tab"], [data-bs-toggle="pill"], [data-bs-toggle="list"]',Ge=`.nav-link:not(.dropdown-toggle), .list-group-item:not(.dropdown-toggle), [role="tab"]:not(.dropdown-toggle), ${Ue}`;class Je extends V{constructor(t){super(t),this._parent=this._element.closest('.list-group, .nav, [role="tablist"]'),this._parent&&(this._setInitialAttributes(this._parent,this._getChildren()),$.on(this._element,"keydown.bs.tab",(t=>this._keydown(t))))}static get NAME(){return"tab"}show(){const t=this._element;if(this._elemIsActive(t))return;const e=this._getActiveElem(),i=e?$.trigger(e,"hide.bs.tab",{relatedTarget:t}):null;$.trigger(t,"show.bs.tab",{relatedTarget:e}).defaultPrevented||i&&i.defaultPrevented||(this._deactivate(e,t),this._activate(t,e))}_activate(t,e){t&&(t.classList.add(Qe),this._activate(r(t)),this._queueCallback((()=>{"tab"===t.getAttribute("role")?(t.focus(),t.removeAttribute("tabindex"),t.setAttribute("aria-selected",!0),this._toggleDropDown(t,!0),$.trigger(t,"shown.bs.tab",{relatedTarget:e})):t.classList.add(Ye)}),t,t.classList.contains(Xe)))}_deactivate(t,e){t&&(t.classList.remove(Qe),t.blur(),this._deactivate(r(t)),this._queueCallback((()=>{"tab"===t.getAttribute("role")?(t.setAttribute("aria-selected",!1),t.setAttribute("tabindex","-1"),this._toggleDropDown(t,!1),$.trigger(t,"hidden.bs.tab",{relatedTarget:e})):t.classList.remove(Ye)}),t,t.classList.contains(Xe)))}_keydown(t){if(![We,Re,Ve,Ke].includes(t.key))return;t.stopPropagation(),t.preventDefault();const e=[Re,Ke].includes(t.key),i=w(this._getChildren().filter((t=>!d(t))),t.target,e,!0);i&&Je.getOrCreateInstance(i).show()}_getChildren(){return U.find(Ge,this._parent)}_getActiveElem(){return this._getChildren().find((t=>this._elemIsActive(t)))||null}_setInitialAttributes(t,e){this._setAttributeIfNotExists(t,"role","tablist");for(const t of e)this._setInitialAttributesOnChild(t)}_setInitialAttributesOnChild(t){t=this._getInnerElement(t);const e=this._elemIsActive(t),i=this._getOuterElement(t);t.setAttribute("aria-selected",e),i!==t&&this._setAttributeIfNotExists(i,"role","presentation"),e||t.setAttribute("tabindex","-1"),this._setAttributeIfNotExists(t,"role","tab"),this._setInitialAttributesOnTargetPanel(t)}_setInitialAttributesOnTargetPanel(t){const e=r(t);e&&(this._setAttributeIfNotExists(e,"role","tabpanel"),t.id&&this._setAttributeIfNotExists(e,"aria-labelledby",`#${t.id}`))}_toggleDropDown(t,e){const i=this._getOuterElement(t);if(!i.classList.contains("dropdown"))return;const s=(t,s)=>{const n=U.findOne(t,i);n&&n.classList.toggle(s,e)};s(".dropdown-toggle",Qe),s(".dropdown-menu",Ye),s(".dropdown-item",Qe),i.setAttribute("aria-expanded",e)}_setAttributeIfNotExists(t,e,i){t.hasAttribute(e)||t.setAttribute(e,i)}_elemIsActive(t){return t.classList.contains(Qe)}_getInnerElement(t){return t.matches(Ge)?t:U.findOne(Ge,t)}_getOuterElement(t){return t.closest(".nav-item, .list-group-item")||t}static jQueryInterface(t){return this.each((function(){const e=Je.getOrCreateInstance(this);if("string"==typeof t){if(void 0===e[t]||t.startsWith("_")||"constructor"===t)throw new TypeError(`No method named "${t}"`);e[t]()}}))}}$.on(document,"click.bs.tab",Ue,(function(t){["A","AREA"].includes(this.tagName)&&t.preventDefault(),d(this)||Je.getOrCreateInstance(this).show()})),$.on(window,"load.bs.tab",(()=>{for(const t of U.find('.active[data-bs-toggle="tab"], .active[data-bs-toggle="pill"], .active[data-bs-toggle="list"]'))Je.getOrCreateInstance(t)})),b(Je);const Ze="hide",ti="show",ei="showing",ii={animation:"boolean",autohide:"boolean",delay:"number"},si={animation:!0,autohide:!0,delay:5e3};class ni extends V{constructor(t,e){super(t,e),this._timeout=null,this._hasMouseInteraction=!1,this._hasKeyboardInteraction=!1,this._setListeners()}static get Default(){return si}static get DefaultType(){return ii}static get NAME(){return"toast"}show(){$.trigger(this._element,"show.bs.toast").defaultPrevented||(this._clearTimeout(),this._config.animation&&this._element.classList.add("fade"),this._element.classList.remove(Ze),g(this._element),this._element.classList.add(ti,ei),this._queueCallback((()=>{this._element.classList.remove(ei),$.trigger(this._element,"shown.bs.toast"),this._maybeScheduleHide()}),this._element,this._config.animation))}hide(){this.isShown()&&($.trigger(this._element,"hide.bs.toast").defaultPrevented||(this._element.classList.add(ei),this._queueCallback((()=>{this._element.classList.add(Ze),this._element.classList.remove(ei,ti),$.trigger(this._element,"hidden.bs.toast")}),this._element,this._config.animation)))}dispose(){this._clearTimeout(),this.isShown()&&this._element.classList.remove(ti),super.dispose()}isShown(){return this._element.classList.contains(ti)}_maybeScheduleHide(){this._config.autohide&&(this._hasMouseInteraction||this._hasKeyboardInteraction||(this._timeout=setTimeout((()=>{this.hide()}),this._config.delay)))}_onInteraction(t,e){switch(t.type){case"mouseover":case"mouseout":this._hasMouseInteraction=e;break;case"focusin":case"focusout":this._hasKeyboardInteraction=e}if(e)return void this._clearTimeout();const i=t.relatedTarget;this._element===i||this._element.contains(i)||this._maybeScheduleHide()}_setListeners(){$.on(this._element,"mouseover.bs.toast",(t=>this._onInteraction(t,!0))),$.on(this._element,"mouseout.bs.toast",(t=>this._onInteraction(t,!1))),$.on(this._element,"focusin.bs.toast",(t=>this._onInteraction(t,!0))),$.on(this._element,"focusout.bs.toast",(t=>this._onInteraction(t,!1)))}_clearTimeout(){clearTimeout(this._timeout),this._timeout=null}static jQueryInterface(t){return this.each((function(){const e=ni.getOrCreateInstance(this,t);if("string"==typeof t){if(void 0===e[t])throw new TypeError(`No method named "${t}"`);e[t](this)}}))}}return K(ni),b(ni),{Alert:Q,Button:Y,Carousel:ht,Collapse:mt,Dropdown:Mt,Modal:ne,Offcanvas:_e,Popover:je,ScrollSpy:Be,Tab:Je,Toast:ni,Tooltip:Pe}})); diff --git a/assets/javascripts/bootstrap/alert.js b/assets/javascripts/bootstrap/alert.js index 35a3b98..be8aa57 100644 --- a/assets/javascripts/bootstrap/alert.js +++ b/assets/javascripts/bootstrap/alert.js @@ -1,13 +1,13 @@ /*! - * Bootstrap alert.js v5.1.3 (https://getbootstrap.com/) - * Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) + * Bootstrap alert.js v5.2.0 (https://getbootstrap.com/) + * Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/event-handler.js'), require('./base-component.js')) : - typeof define === 'function' && define.amd ? define(['./dom/event-handler', './base-component'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Alert = factory(global.EventHandler, global.Base)); -})(this, (function (EventHandler, BaseComponent) { 'use strict'; + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./util/index'), require('./dom/event-handler'), require('./base-component'), require('./util/component-functions')) : + typeof define === 'function' && define.amd ? define(['./util/index', './dom/event-handler', './base-component', './util/component-functions'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Alert = factory(global.Index, global.EventHandler, global.BaseComponent, global.ComponentFunctions)); +})(this, (function (index, EventHandler, BaseComponent, componentFunctions) { 'use strict'; const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e }; @@ -16,140 +16,12 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): util/index.js - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) - * -------------------------------------------------------------------------- - */ - - const getSelector = element => { - let selector = element.getAttribute('data-bs-target'); - - if (!selector || selector === '#') { - let hrefAttr = element.getAttribute('href'); // The only valid content that could double as a selector are IDs or classes, - // so everything starting with `#` or `.`. If a "real" URL is used as the selector, - // `document.querySelector` will rightfully complain it is invalid. - // See https://github.com/twbs/bootstrap/issues/32273 - - if (!hrefAttr || !hrefAttr.includes('#') && !hrefAttr.startsWith('.')) { - return null; - } // Just in case some CMS puts out a full URL with the anchor appended - - - if (hrefAttr.includes('#') && !hrefAttr.startsWith('#')) { - hrefAttr = `#${hrefAttr.split('#')[1]}`; - } - - selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : null; - } - - return selector; - }; - - const getElementFromSelector = element => { - const selector = getSelector(element); - return selector ? document.querySelector(selector) : null; - }; - - const isDisabled = element => { - if (!element || element.nodeType !== Node.ELEMENT_NODE) { - return true; - } - - if (element.classList.contains('disabled')) { - return true; - } - - if (typeof element.disabled !== 'undefined') { - return element.disabled; - } - - return element.hasAttribute('disabled') && element.getAttribute('disabled') !== 'false'; - }; - - const getjQuery = () => { - const { - jQuery - } = window; - - if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) { - return jQuery; - } - - return null; - }; - - const DOMContentLoadedCallbacks = []; - - const onDOMContentLoaded = callback => { - if (document.readyState === 'loading') { - // add listener on the first call when the document is in loading state - if (!DOMContentLoadedCallbacks.length) { - document.addEventListener('DOMContentLoaded', () => { - DOMContentLoadedCallbacks.forEach(callback => callback()); - }); - } - - DOMContentLoadedCallbacks.push(callback); - } else { - callback(); - } - }; - - const defineJQueryPlugin = plugin => { - onDOMContentLoaded(() => { - const $ = getjQuery(); - /* istanbul ignore if */ - - if ($) { - const name = plugin.NAME; - const JQUERY_NO_CONFLICT = $.fn[name]; - $.fn[name] = plugin.jQueryInterface; - $.fn[name].Constructor = plugin; - - $.fn[name].noConflict = () => { - $.fn[name] = JQUERY_NO_CONFLICT; - return plugin.jQueryInterface; - }; - } - }); - }; - - /** - * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): util/component-functions.js - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) - * -------------------------------------------------------------------------- - */ - - const enableDismissTrigger = (component, method = 'hide') => { - const clickEvent = `click.dismiss${component.EVENT_KEY}`; - const name = component.NAME; - EventHandler__default.default.on(document, clickEvent, `[data-bs-dismiss="${name}"]`, function (event) { - if (['A', 'AREA'].includes(this.tagName)) { - event.preventDefault(); - } - - if (isDisabled(this)) { - return; - } - - const target = getElementFromSelector(this) || this.closest(`.${name}`); - const instance = component.getOrCreateInstance(target); // Method argument is left, for Alert and only, as it doesn't implement the 'hide' method - - instance[method](); - }); - }; - - /** - * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): alert.js + * Bootstrap (v5.2.0): alert.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** - * ------------------------------------------------------------------------ * Constants - * ------------------------------------------------------------------------ */ const NAME = 'alert'; @@ -160,9 +32,7 @@ const CLASS_NAME_FADE = 'fade'; const CLASS_NAME_SHOW = 'show'; /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ + * Class definition */ class Alert extends BaseComponent__default.default { @@ -213,21 +83,16 @@ } /** - * ------------------------------------------------------------------------ - * Data Api implementation - * ------------------------------------------------------------------------ + * Data API implementation */ - enableDismissTrigger(Alert, 'close'); + componentFunctions.enableDismissTrigger(Alert, 'close'); /** - * ------------------------------------------------------------------------ * jQuery - * ------------------------------------------------------------------------ - * add .Alert to jQuery only if jQuery is present */ - defineJQueryPlugin(Alert); + index.defineJQueryPlugin(Alert); return Alert; diff --git a/assets/javascripts/bootstrap/base-component.js b/assets/javascripts/bootstrap/base-component.js index 84eb159..ff88b03 100644 --- a/assets/javascripts/bootstrap/base-component.js +++ b/assets/javascripts/bootstrap/base-component.js @@ -1,158 +1,75 @@ /*! - * Bootstrap base-component.js v5.1.3 (https://getbootstrap.com/) - * Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) + * Bootstrap base-component.js v5.2.0 (https://getbootstrap.com/) + * Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/data.js'), require('./dom/event-handler.js')) : - typeof define === 'function' && define.amd ? define(['./dom/data', './dom/event-handler'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Base = factory(global.Data, global.EventHandler)); -})(this, (function (Data, EventHandler) { 'use strict'; + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/data'), require('./util/index'), require('./dom/event-handler'), require('./util/config')) : + typeof define === 'function' && define.amd ? define(['./dom/data', './util/index', './dom/event-handler', './util/config'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.BaseComponent = factory(global.Data, global.Index, global.EventHandler, global.Config)); +})(this, (function (Data, index, EventHandler, Config) { 'use strict'; const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e }; const Data__default = /*#__PURE__*/_interopDefaultLegacy(Data); const EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler); + const Config__default = /*#__PURE__*/_interopDefaultLegacy(Config); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): util/index.js - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) - * -------------------------------------------------------------------------- - */ - const MILLISECONDS_MULTIPLIER = 1000; - const TRANSITION_END = 'transitionend'; // Shoutout AngusCroll (https://goo.gl/pxwQGp) - - const getTransitionDurationFromElement = element => { - if (!element) { - return 0; - } // Get transition-duration of the element - - - let { - transitionDuration, - transitionDelay - } = window.getComputedStyle(element); - const floatTransitionDuration = Number.parseFloat(transitionDuration); - const floatTransitionDelay = Number.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 (Number.parseFloat(transitionDuration) + Number.parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER; - }; - - const triggerTransitionEnd = element => { - element.dispatchEvent(new Event(TRANSITION_END)); - }; - - const isElement = obj => { - if (!obj || typeof obj !== 'object') { - return false; - } - - if (typeof obj.jquery !== 'undefined') { - obj = obj[0]; - } - - return typeof obj.nodeType !== 'undefined'; - }; - - const getElement = obj => { - if (isElement(obj)) { - // it's a jQuery object or a node element - return obj.jquery ? obj[0] : obj; - } - - if (typeof obj === 'string' && obj.length > 0) { - return document.querySelector(obj); - } - - return null; - }; - - const execute = callback => { - if (typeof callback === 'function') { - callback(); - } - }; - - const executeAfterTransition = (callback, transitionElement, waitForTransition = true) => { - if (!waitForTransition) { - execute(callback); - return; - } - - const durationPadding = 5; - const emulatedDuration = getTransitionDurationFromElement(transitionElement) + durationPadding; - let called = false; - - const handler = ({ - target - }) => { - if (target !== transitionElement) { - return; - } - - called = true; - transitionElement.removeEventListener(TRANSITION_END, handler); - execute(callback); - }; - - transitionElement.addEventListener(TRANSITION_END, handler); - setTimeout(() => { - if (!called) { - triggerTransitionEnd(transitionElement); - } - }, emulatedDuration); - }; - - /** - * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): base-component.js + * Bootstrap (v5.2.0): base-component.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** - * ------------------------------------------------------------------------ * Constants - * ------------------------------------------------------------------------ */ - const VERSION = '5.1.3'; + const VERSION = '5.2.0'; + /** + * Class definition + */ - class BaseComponent { - constructor(element) { - element = getElement(element); + class BaseComponent extends Config__default.default { + constructor(element, config) { + super(); + element = index.getElement(element); if (!element) { return; } this._element = element; + this._config = this._getConfig(config); Data__default.default.set(this._element, this.constructor.DATA_KEY, this); - } + } // Public + dispose() { Data__default.default.remove(this._element, this.constructor.DATA_KEY); EventHandler__default.default.off(this._element, this.constructor.EVENT_KEY); - Object.getOwnPropertyNames(this).forEach(propertyName => { + + for (const propertyName of Object.getOwnPropertyNames(this)) { this[propertyName] = null; - }); + } } _queueCallback(callback, element, isAnimated = true) { - executeAfterTransition(callback, element, isAnimated); + index.executeAfterTransition(callback, element, isAnimated); } - /** Static */ + + _getConfig(config) { + config = this._mergeConfigObj(config, this._element); + config = this._configAfterMerge(config); + + this._typeCheckConfig(config); + + return config; + } // Static static getInstance(element) { - return Data__default.default.get(getElement(element), this.DATA_KEY); + return Data__default.default.get(index.getElement(element), this.DATA_KEY); } static getOrCreateInstance(element, config = {}) { @@ -163,10 +80,6 @@ return VERSION; } - static get NAME() { - throw new Error('You have to implement the static method "NAME", for each component!'); - } - static get DATA_KEY() { return `bs.${this.NAME}`; } @@ -175,6 +88,10 @@ return `.${this.DATA_KEY}`; } + static eventName(name) { + return `${name}${this.EVENT_KEY}`; + } + } return BaseComponent; diff --git a/assets/javascripts/bootstrap/button.js b/assets/javascripts/bootstrap/button.js index 352d706..e662afd 100644 --- a/assets/javascripts/bootstrap/button.js +++ b/assets/javascripts/bootstrap/button.js @@ -1,13 +1,13 @@ /*! - * Bootstrap button.js v5.1.3 (https://getbootstrap.com/) - * Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) + * Bootstrap button.js v5.2.0 (https://getbootstrap.com/) + * Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/event-handler.js'), require('./base-component.js')) : - typeof define === 'function' && define.amd ? define(['./dom/event-handler', './base-component'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Button = factory(global.EventHandler, global.Base)); -})(this, (function (EventHandler, BaseComponent) { 'use strict'; + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./util/index'), require('./dom/event-handler'), require('./base-component')) : + typeof define === 'function' && define.amd ? define(['./util/index', './dom/event-handler', './base-component'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Button = factory(global.Index, global.EventHandler, global.BaseComponent)); +})(this, (function (index, EventHandler, BaseComponent) { 'use strict'; const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e }; @@ -16,69 +16,12 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): util/index.js - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) - * -------------------------------------------------------------------------- - */ - - const getjQuery = () => { - const { - jQuery - } = window; - - if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) { - return jQuery; - } - - return null; - }; - - const DOMContentLoadedCallbacks = []; - - const onDOMContentLoaded = callback => { - if (document.readyState === 'loading') { - // add listener on the first call when the document is in loading state - if (!DOMContentLoadedCallbacks.length) { - document.addEventListener('DOMContentLoaded', () => { - DOMContentLoadedCallbacks.forEach(callback => callback()); - }); - } - - DOMContentLoadedCallbacks.push(callback); - } else { - callback(); - } - }; - - const defineJQueryPlugin = plugin => { - onDOMContentLoaded(() => { - const $ = getjQuery(); - /* istanbul ignore if */ - - if ($) { - const name = plugin.NAME; - const JQUERY_NO_CONFLICT = $.fn[name]; - $.fn[name] = plugin.jQueryInterface; - $.fn[name].Constructor = plugin; - - $.fn[name].noConflict = () => { - $.fn[name] = JQUERY_NO_CONFLICT; - return plugin.jQueryInterface; - }; - } - }); - }; - - /** - * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): button.js + * Bootstrap (v5.2.0): button.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** - * ------------------------------------------------------------------------ * Constants - * ------------------------------------------------------------------------ */ const NAME = 'button'; @@ -89,9 +32,7 @@ const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="button"]'; const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`; /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ + * Class definition */ class Button extends BaseComponent__default.default { @@ -119,9 +60,7 @@ } /** - * ------------------------------------------------------------------------ - * Data Api implementation - * ------------------------------------------------------------------------ + * Data API implementation */ @@ -132,13 +71,10 @@ data.toggle(); }); /** - * ------------------------------------------------------------------------ * jQuery - * ------------------------------------------------------------------------ - * add .Button to jQuery only if jQuery is present */ - defineJQueryPlugin(Button); + index.defineJQueryPlugin(Button); return Button; diff --git a/assets/javascripts/bootstrap/carousel.js b/assets/javascripts/bootstrap/carousel.js index c0ca942..9ec3d62 100644 --- a/assets/javascripts/bootstrap/carousel.js +++ b/assets/javascripts/bootstrap/carousel.js @@ -1,203 +1,30 @@ /*! - * Bootstrap carousel.js v5.1.3 (https://getbootstrap.com/) - * Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) + * Bootstrap carousel.js v5.2.0 (https://getbootstrap.com/) + * Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/event-handler.js'), require('./dom/manipulator.js'), require('./dom/selector-engine.js'), require('./base-component.js')) : - typeof define === 'function' && define.amd ? define(['./dom/event-handler', './dom/manipulator', './dom/selector-engine', './base-component'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Carousel = factory(global.EventHandler, global.Manipulator, global.SelectorEngine, global.Base)); -})(this, (function (EventHandler, Manipulator, SelectorEngine, BaseComponent) { 'use strict'; + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./util/index'), require('./dom/event-handler'), require('./dom/manipulator'), require('./dom/selector-engine'), require('./util/swipe'), require('./base-component')) : + typeof define === 'function' && define.amd ? define(['./util/index', './dom/event-handler', './dom/manipulator', './dom/selector-engine', './util/swipe', './base-component'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Carousel = factory(global.Index, global.EventHandler, global.Manipulator, global.SelectorEngine, global.Swipe, global.BaseComponent)); +})(this, (function (index, EventHandler, Manipulator, SelectorEngine, Swipe, BaseComponent) { 'use strict'; const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e }; const EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler); const Manipulator__default = /*#__PURE__*/_interopDefaultLegacy(Manipulator); const SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine); + const Swipe__default = /*#__PURE__*/_interopDefaultLegacy(Swipe); const BaseComponent__default = /*#__PURE__*/_interopDefaultLegacy(BaseComponent); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): util/index.js + * Bootstrap (v5.2.0): carousel.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ - const TRANSITION_END = 'transitionend'; // Shoutout AngusCroll (https://goo.gl/pxwQGp) - - const toType = obj => { - if (obj === null || obj === undefined) { - return `${obj}`; - } - - return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase(); - }; - - const getSelector = element => { - let selector = element.getAttribute('data-bs-target'); - - if (!selector || selector === '#') { - let hrefAttr = element.getAttribute('href'); // The only valid content that could double as a selector are IDs or classes, - // so everything starting with `#` or `.`. If a "real" URL is used as the selector, - // `document.querySelector` will rightfully complain it is invalid. - // See https://github.com/twbs/bootstrap/issues/32273 - - if (!hrefAttr || !hrefAttr.includes('#') && !hrefAttr.startsWith('.')) { - return null; - } // Just in case some CMS puts out a full URL with the anchor appended - - - if (hrefAttr.includes('#') && !hrefAttr.startsWith('#')) { - hrefAttr = `#${hrefAttr.split('#')[1]}`; - } - - selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : null; - } - - return selector; - }; - - const getElementFromSelector = element => { - const selector = getSelector(element); - return selector ? document.querySelector(selector) : null; - }; - - const triggerTransitionEnd = element => { - element.dispatchEvent(new Event(TRANSITION_END)); - }; - - const isElement = obj => { - if (!obj || typeof obj !== 'object') { - return false; - } - - if (typeof obj.jquery !== 'undefined') { - obj = obj[0]; - } - - return typeof obj.nodeType !== 'undefined'; - }; - - const typeCheckConfig = (componentName, config, configTypes) => { - Object.keys(configTypes).forEach(property => { - const expectedTypes = configTypes[property]; - const value = config[property]; - const valueType = value && isElement(value) ? 'element' : toType(value); - - if (!new RegExp(expectedTypes).test(valueType)) { - throw new TypeError(`${componentName.toUpperCase()}: Option "${property}" provided type "${valueType}" but expected type "${expectedTypes}".`); - } - }); - }; - - const isVisible = element => { - if (!isElement(element) || element.getClientRects().length === 0) { - return false; - } - - return getComputedStyle(element).getPropertyValue('visibility') === 'visible'; - }; - /** - * Trick to restart an element's animation - * - * @param {HTMLElement} element - * @return void - * - * @see https://www.charistheo.io/blog/2021/02/restart-a-css-animation-with-javascript/#restarting-a-css-animation - */ - - - const reflow = element => { - // eslint-disable-next-line no-unused-expressions - element.offsetHeight; - }; - - const getjQuery = () => { - const { - jQuery - } = window; - - if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) { - return jQuery; - } - - return null; - }; - - const DOMContentLoadedCallbacks = []; - - const onDOMContentLoaded = callback => { - if (document.readyState === 'loading') { - // add listener on the first call when the document is in loading state - if (!DOMContentLoadedCallbacks.length) { - document.addEventListener('DOMContentLoaded', () => { - DOMContentLoadedCallbacks.forEach(callback => callback()); - }); - } - - DOMContentLoadedCallbacks.push(callback); - } else { - callback(); - } - }; - - const isRTL = () => document.documentElement.dir === 'rtl'; - - const defineJQueryPlugin = plugin => { - onDOMContentLoaded(() => { - const $ = getjQuery(); - /* istanbul ignore if */ - - if ($) { - const name = plugin.NAME; - const JQUERY_NO_CONFLICT = $.fn[name]; - $.fn[name] = plugin.jQueryInterface; - $.fn[name].Constructor = plugin; - - $.fn[name].noConflict = () => { - $.fn[name] = JQUERY_NO_CONFLICT; - return plugin.jQueryInterface; - }; - } - }); - }; /** - * Return the previous/next element of a list. - * - * @param {array} list The list of elements - * @param activeElement The active element - * @param shouldGetNext Choose to get next or previous element - * @param isCycleAllowed - * @return {Element|elem} The proper element - */ - - - const getNextActiveElement = (list, activeElement, shouldGetNext, isCycleAllowed) => { - 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 - - if (index === -1) { - return list[!shouldGetNext && isCycleAllowed ? list.length - 1 : 0]; - } - - const listLength = list.length; - index += shouldGetNext ? 1 : -1; - - if (isCycleAllowed) { - index = (index + listLength) % listLength; - } - - return list[Math.max(0, Math.min(index, listLength - 1))]; - }; - - /** - * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): carousel.js - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) - * -------------------------------------------------------------------------- - */ - /** - * ------------------------------------------------------------------------ * Constants - * ------------------------------------------------------------------------ */ const NAME = 'carousel'; @@ -208,41 +35,15 @@ const ARROW_RIGHT_KEY = 'ArrowRight'; const TOUCHEVENT_COMPAT_WAIT = 500; // Time for mouse compat events to fire after touch - const SWIPE_THRESHOLD = 40; - const Default = { - interval: 5000, - keyboard: true, - slide: false, - pause: 'hover', - wrap: true, - touch: true - }; - const DefaultType = { - interval: '(number|boolean)', - keyboard: 'boolean', - slide: '(boolean|string)', - pause: '(string|boolean)', - wrap: 'boolean', - touch: 'boolean' - }; const ORDER_NEXT = 'next'; const ORDER_PREV = 'prev'; const DIRECTION_LEFT = 'left'; const DIRECTION_RIGHT = 'right'; - const KEY_TO_DIRECTION = { - [ARROW_LEFT_KEY]: DIRECTION_RIGHT, - [ARROW_RIGHT_KEY]: DIRECTION_LEFT - }; const EVENT_SLIDE = `slide${EVENT_KEY}`; const EVENT_SLID = `slid${EVENT_KEY}`; const EVENT_KEYDOWN = `keydown${EVENT_KEY}`; const EVENT_MOUSEENTER = `mouseenter${EVENT_KEY}`; const EVENT_MOUSELEAVE = `mouseleave${EVENT_KEY}`; - const EVENT_TOUCHSTART = `touchstart${EVENT_KEY}`; - const EVENT_TOUCHMOVE = `touchmove${EVENT_KEY}`; - const EVENT_TOUCHEND = `touchend${EVENT_KEY}`; - const EVENT_POINTERDOWN = `pointerdown${EVENT_KEY}`; - const EVENT_POINTERUP = `pointerup${EVENT_KEY}`; const EVENT_DRAG_START = `dragstart${EVENT_KEY}`; const EVENT_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}`; const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`; @@ -253,41 +54,53 @@ const CLASS_NAME_START = 'carousel-item-start'; const CLASS_NAME_NEXT = 'carousel-item-next'; const CLASS_NAME_PREV = 'carousel-item-prev'; - const CLASS_NAME_POINTER_EVENT = 'pointer-event'; const SELECTOR_ACTIVE = '.active'; - const SELECTOR_ACTIVE_ITEM = '.active.carousel-item'; const SELECTOR_ITEM = '.carousel-item'; + const SELECTOR_ACTIVE_ITEM = SELECTOR_ACTIVE + SELECTOR_ITEM; const SELECTOR_ITEM_IMG = '.carousel-item img'; - const SELECTOR_NEXT_PREV = '.carousel-item-next, .carousel-item-prev'; const SELECTOR_INDICATORS = '.carousel-indicators'; - const SELECTOR_INDICATOR = '[data-bs-target]'; const SELECTOR_DATA_SLIDE = '[data-bs-slide], [data-bs-slide-to]'; const SELECTOR_DATA_RIDE = '[data-bs-ride="carousel"]'; - const POINTER_TYPE_TOUCH = 'touch'; - const POINTER_TYPE_PEN = 'pen'; + const KEY_TO_DIRECTION = { + [ARROW_LEFT_KEY]: DIRECTION_RIGHT, + [ARROW_RIGHT_KEY]: DIRECTION_LEFT + }; + const Default = { + interval: 5000, + keyboard: true, + pause: 'hover', + ride: false, + touch: true, + wrap: true + }; + const DefaultType = { + interval: '(number|boolean)', + // TODO:v6 remove boolean support + keyboard: 'boolean', + pause: '(string|boolean)', + ride: '(boolean|string)', + touch: 'boolean', + wrap: 'boolean' + }; /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ + * Class definition */ class Carousel extends BaseComponent__default.default { constructor(element, config) { - super(element); - this._items = null; + super(element, config); this._interval = null; this._activeElement = null; - this._isPaused = false; this._isSliding = false; this.touchTimeout = null; - this.touchStartX = 0; - this.touchDeltaX = 0; - this._config = this._getConfig(config); + this._swipeHelper = null; this._indicatorsElement = SelectorEngine__default.default.findOne(SELECTOR_INDICATORS, this._element); - this._touchSupported = 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0; - this._pointerEvent = Boolean(window.PointerEvent); this._addEventListeners(); + + if (this._config.ride === CLASS_NAME_CAROUSEL) { + this.cycle(); + } } // Getters @@ -295,6 +108,10 @@ return Default; } + static get DefaultType() { + return DefaultType; + } + static get NAME() { return NAME; } // Public @@ -305,9 +122,10 @@ } nextWhenVisible() { + // FIXME TODO use `document.visibilityState` // Don't call next when the page isn't visible // or the carousel or its parent isn't visible - if (!document.hidden && isVisible(this._element)) { + if (!document.hidden && index.isVisible(this._element)) { this.next(); } } @@ -316,43 +134,39 @@ this._slide(ORDER_PREV); } - pause(event) { - if (!event) { - this._isPaused = true; + pause() { + if (this._isSliding) { + index.triggerTransitionEnd(this._element); } - if (SelectorEngine__default.default.findOne(SELECTOR_NEXT_PREV, this._element)) { - triggerTransitionEnd(this._element); - this.cycle(true); - } + this._clearInterval(); + } - clearInterval(this._interval); - this._interval = null; + cycle() { + this._clearInterval(); + + this._updateInterval(); + + this._interval = setInterval(() => this.nextWhenVisible(), this._config.interval); } - cycle(event) { - if (!event) { - this._isPaused = false; + _maybeEnableCycle() { + if (!this._config.ride) { + return; } - if (this._interval) { - clearInterval(this._interval); - this._interval = null; + if (this._isSliding) { + EventHandler__default.default.one(this._element, EVENT_SLID, () => this.cycle()); + return; } - if (this._config && this._config.interval && !this._isPaused) { - this._updateInterval(); - - this._interval = setInterval((document.visibilityState ? this.nextWhenVisible : this.next).bind(this), this._config.interval); - } + this.cycle(); } to(index) { - this._activeElement = SelectorEngine__default.default.findOne(SELECTOR_ACTIVE_ITEM, this._element); - - const activeIndex = this._getItemIndex(this._activeElement); + const items = this._getItems(); - if (index > this._items.length - 1 || index < 0) { + if (index > items.length - 1 || index < 0) { return; } @@ -361,42 +175,29 @@ return; } + const activeIndex = this._getItemIndex(this._getActive()); + if (activeIndex === index) { - this.pause(); - this.cycle(); return; } const order = index > activeIndex ? ORDER_NEXT : ORDER_PREV; - this._slide(order, this._items[index]); - } // Private - - - _getConfig(config) { - config = { ...Default, - ...Manipulator__default.default.getDataAttributes(this._element), - ...(typeof config === 'object' ? config : {}) - }; - typeCheckConfig(NAME, config, DefaultType); - return config; + this._slide(order, items[index]); } - _handleSwipe() { - const absDeltax = Math.abs(this.touchDeltaX); - - if (absDeltax <= SWIPE_THRESHOLD) { - return; + dispose() { + if (this._swipeHelper) { + this._swipeHelper.dispose(); } - const direction = absDeltax / this.touchDeltaX; - this.touchDeltaX = 0; + super.dispose(); + } // Private - if (!direction) { - return; - } - this._slide(direction > 0 ? DIRECTION_RIGHT : DIRECTION_LEFT); + _configAfterMerge(config) { + config.defaultInterval = config.interval; + return config; } _addEventListeners() { @@ -405,72 +206,47 @@ } if (this._config.pause === 'hover') { - EventHandler__default.default.on(this._element, EVENT_MOUSEENTER, event => this.pause(event)); - EventHandler__default.default.on(this._element, EVENT_MOUSELEAVE, event => this.cycle(event)); + EventHandler__default.default.on(this._element, EVENT_MOUSEENTER, () => this.pause()); + EventHandler__default.default.on(this._element, EVENT_MOUSELEAVE, () => this._maybeEnableCycle()); } - if (this._config.touch && this._touchSupported) { + if (this._config.touch && Swipe__default.default.isSupported()) { this._addTouchEventListeners(); } } _addTouchEventListeners() { - const hasPointerPenTouch = event => { - return this._pointerEvent && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH); - }; - - const start = event => { - if (hasPointerPenTouch(event)) { - this.touchStartX = event.clientX; - } else if (!this._pointerEvent) { - this.touchStartX = event.touches[0].clientX; - } - }; - - const move = event => { - // ensure swiping with one touch and not pinching - this.touchDeltaX = event.touches && event.touches.length > 1 ? 0 : event.touches[0].clientX - this.touchStartX; - }; - - const end = event => { - if (hasPointerPenTouch(event)) { - this.touchDeltaX = event.clientX - this.touchStartX; - } + for (const img of SelectorEngine__default.default.find(SELECTOR_ITEM_IMG, this._element)) { + EventHandler__default.default.on(img, EVENT_DRAG_START, event => event.preventDefault()); + } - this._handleSwipe(); + const endCallBack = () => { + if (this._config.pause !== 'hover') { + return; + } // If it's a touch-enabled device, mouseenter/leave are fired as + // part of the mouse compatibility events on first tap - the carousel + // would stop cycling until user tapped out of it; + // here, we listen for touchend, explicitly pause the carousel + // (as if it's the second time we tap on it, mouseenter compat event + // is NOT fired) and after a timeout (to allow for mouse compatibility + // events to fire) we explicitly restart cycling - if (this._config.pause === 'hover') { - // If it's a touch-enabled device, mouseenter/leave are fired as - // part of the mouse compatibility events on first tap - the carousel - // would stop cycling until user tapped out of it; - // here, we listen for touchend, explicitly pause the carousel - // (as if it's the second time we tap on it, mouseenter compat event - // is NOT fired) and after a timeout (to allow for mouse compatibility - // events to fire) we explicitly restart cycling - this.pause(); - if (this.touchTimeout) { - clearTimeout(this.touchTimeout); - } + this.pause(); - this.touchTimeout = setTimeout(event => this.cycle(event), TOUCHEVENT_COMPAT_WAIT + this._config.interval); + if (this.touchTimeout) { + clearTimeout(this.touchTimeout); } - }; - - SelectorEngine__default.default.find(SELECTOR_ITEM_IMG, this._element).forEach(itemImg => { - EventHandler__default.default.on(itemImg, EVENT_DRAG_START, event => event.preventDefault()); - }); - if (this._pointerEvent) { - EventHandler__default.default.on(this._element, EVENT_POINTERDOWN, event => start(event)); - EventHandler__default.default.on(this._element, EVENT_POINTERUP, event => end(event)); + this.touchTimeout = setTimeout(() => this._maybeEnableCycle(), TOUCHEVENT_COMPAT_WAIT + this._config.interval); + }; - this._element.classList.add(CLASS_NAME_POINTER_EVENT); - } else { - EventHandler__default.default.on(this._element, EVENT_TOUCHSTART, event => start(event)); - EventHandler__default.default.on(this._element, EVENT_TOUCHMOVE, event => move(event)); - EventHandler__default.default.on(this._element, EVENT_TOUCHEND, event => end(event)); - } + const swipeConfig = { + leftCallback: () => this._slide(this._directionToOrder(DIRECTION_LEFT)), + rightCallback: () => this._slide(this._directionToOrder(DIRECTION_RIGHT)), + endCallback: endCallBack + }; + this._swipeHelper = new Swipe__default.default(this._element, swipeConfig); } _keydown(event) { @@ -483,95 +259,67 @@ if (direction) { event.preventDefault(); - this._slide(direction); + this._slide(this._directionToOrder(direction)); } } _getItemIndex(element) { - this._items = element && element.parentNode ? SelectorEngine__default.default.find(SELECTOR_ITEM, element.parentNode) : []; - return this._items.indexOf(element); + return this._getItems().indexOf(element); } - _getItemByOrder(order, activeElement) { - const isNext = order === ORDER_NEXT; - return getNextActiveElement(this._items, activeElement, isNext, this._config.wrap); - } - - _triggerSlideEvent(relatedTarget, eventDirectionName) { - const targetIndex = this._getItemIndex(relatedTarget); - - const fromIndex = this._getItemIndex(SelectorEngine__default.default.findOne(SELECTOR_ACTIVE_ITEM, this._element)); + _setActiveIndicatorElement(index) { + if (!this._indicatorsElement) { + return; + } - return EventHandler__default.default.trigger(this._element, EVENT_SLIDE, { - relatedTarget, - direction: eventDirectionName, - from: fromIndex, - to: targetIndex - }); - } + const activeIndicator = SelectorEngine__default.default.findOne(SELECTOR_ACTIVE, this._indicatorsElement); + activeIndicator.classList.remove(CLASS_NAME_ACTIVE); + activeIndicator.removeAttribute('aria-current'); + const newActiveIndicator = SelectorEngine__default.default.findOne(`[data-bs-slide-to="${index}"]`, this._indicatorsElement); - _setActiveIndicatorElement(element) { - if (this._indicatorsElement) { - const activeIndicator = SelectorEngine__default.default.findOne(SELECTOR_ACTIVE, this._indicatorsElement); - activeIndicator.classList.remove(CLASS_NAME_ACTIVE); - activeIndicator.removeAttribute('aria-current'); - const indicators = SelectorEngine__default.default.find(SELECTOR_INDICATOR, this._indicatorsElement); - - for (let i = 0; i < indicators.length; i++) { - if (Number.parseInt(indicators[i].getAttribute('data-bs-slide-to'), 10) === this._getItemIndex(element)) { - indicators[i].classList.add(CLASS_NAME_ACTIVE); - indicators[i].setAttribute('aria-current', 'true'); - break; - } - } + if (newActiveIndicator) { + newActiveIndicator.classList.add(CLASS_NAME_ACTIVE); + newActiveIndicator.setAttribute('aria-current', 'true'); } } _updateInterval() { - const element = this._activeElement || SelectorEngine__default.default.findOne(SELECTOR_ACTIVE_ITEM, this._element); + const element = this._activeElement || this._getActive(); if (!element) { return; } const elementInterval = Number.parseInt(element.getAttribute('data-bs-interval'), 10); - - if (elementInterval) { - this._config.defaultInterval = this._config.defaultInterval || this._config.interval; - this._config.interval = elementInterval; - } else { - this._config.interval = this._config.defaultInterval || this._config.interval; - } + this._config.interval = elementInterval || this._config.defaultInterval; } - _slide(directionOrOrder, element) { - const order = this._directionToOrder(directionOrOrder); - - const activeElement = SelectorEngine__default.default.findOne(SELECTOR_ACTIVE_ITEM, this._element); - - const activeElementIndex = this._getItemIndex(activeElement); - - const nextElement = element || this._getItemByOrder(order, activeElement); + _slide(order, element = null) { + if (this._isSliding) { + return; + } - const nextElementIndex = this._getItemIndex(nextElement); + const activeElement = this._getActive(); - const isCycling = Boolean(this._interval); const isNext = order === ORDER_NEXT; - const directionalClassName = isNext ? CLASS_NAME_START : CLASS_NAME_END; - const orderClassName = isNext ? CLASS_NAME_NEXT : CLASS_NAME_PREV; - - const eventDirectionName = this._orderToDirection(order); + const nextElement = element || index.getNextActiveElement(this._getItems(), activeElement, isNext, this._config.wrap); - if (nextElement && nextElement.classList.contains(CLASS_NAME_ACTIVE)) { - this._isSliding = false; + if (nextElement === activeElement) { return; } - if (this._isSliding) { - return; - } + const nextElementIndex = this._getItemIndex(nextElement); + + const triggerEvent = eventName => { + return EventHandler__default.default.trigger(this._element, eventName, { + relatedTarget: nextElement, + direction: this._orderToDirection(order), + from: this._getItemIndex(activeElement), + to: nextElementIndex + }); + }; - const slideEvent = this._triggerSlideEvent(nextElement, eventDirectionName); + const slideEvent = triggerEvent(EVENT_SLIDE); if (slideEvent.defaultPrevented) { return; @@ -579,61 +327,60 @@ if (!activeElement || !nextElement) { // Some weirdness is happening, so we bail + // todo: change tests that use empty divs to avoid this check return; } + const isCycling = Boolean(this._interval); + this.pause(); this._isSliding = true; - if (isCycling) { - this.pause(); - } - - this._setActiveIndicatorElement(nextElement); + this._setActiveIndicatorElement(nextElementIndex); this._activeElement = nextElement; + const directionalClassName = isNext ? CLASS_NAME_START : CLASS_NAME_END; + const orderClassName = isNext ? CLASS_NAME_NEXT : CLASS_NAME_PREV; + nextElement.classList.add(orderClassName); + index.reflow(nextElement); + activeElement.classList.add(directionalClassName); + nextElement.classList.add(directionalClassName); - const triggerSlidEvent = () => { - EventHandler__default.default.trigger(this._element, EVENT_SLID, { - relatedTarget: nextElement, - direction: eventDirectionName, - from: activeElementIndex, - to: nextElementIndex - }); - }; - - if (this._element.classList.contains(CLASS_NAME_SLIDE)) { - nextElement.classList.add(orderClassName); - reflow(nextElement); - activeElement.classList.add(directionalClassName); - nextElement.classList.add(directionalClassName); - - const completeCallBack = () => { - nextElement.classList.remove(directionalClassName, orderClassName); - nextElement.classList.add(CLASS_NAME_ACTIVE); - activeElement.classList.remove(CLASS_NAME_ACTIVE, orderClassName, directionalClassName); - this._isSliding = false; - setTimeout(triggerSlidEvent, 0); - }; - - this._queueCallback(completeCallBack, activeElement, true); - } else { - activeElement.classList.remove(CLASS_NAME_ACTIVE); + const completeCallBack = () => { + nextElement.classList.remove(directionalClassName, orderClassName); nextElement.classList.add(CLASS_NAME_ACTIVE); + activeElement.classList.remove(CLASS_NAME_ACTIVE, orderClassName, directionalClassName); this._isSliding = false; - triggerSlidEvent(); - } + triggerEvent(EVENT_SLID); + }; + + this._queueCallback(completeCallBack, activeElement, this._isAnimated()); if (isCycling) { this.cycle(); } } - _directionToOrder(direction) { - if (![DIRECTION_RIGHT, DIRECTION_LEFT].includes(direction)) { - return direction; + _isAnimated() { + return this._element.classList.contains(CLASS_NAME_SLIDE); + } + + _getActive() { + return SelectorEngine__default.default.findOne(SELECTOR_ACTIVE_ITEM, this._element); + } + + _getItems() { + return SelectorEngine__default.default.find(SELECTOR_ITEM, this._element); + } + + _clearInterval() { + if (this._interval) { + clearInterval(this._interval); + this._interval = null; } + } - if (isRTL()) { + _directionToOrder(direction) { + if (index.isRTL()) { return direction === DIRECTION_LEFT ? ORDER_PREV : ORDER_NEXT; } @@ -641,11 +388,7 @@ } _orderToDirection(order) { - if (![ORDER_NEXT, ORDER_PREV].includes(order)) { - return order; - } - - if (isRTL()) { + if (index.isRTL()) { return order === ORDER_PREV ? DIRECTION_LEFT : DIRECTION_RIGHT; } @@ -653,89 +396,74 @@ } // Static - static carouselInterface(element, config) { - const data = Carousel.getOrCreateInstance(element, config); - let { - _config - } = data; - - if (typeof config === 'object') { - _config = { ..._config, - ...config - }; - } - - const action = typeof config === 'string' ? config : _config.slide; + static jQueryInterface(config) { + return this.each(function () { + const data = Carousel.getOrCreateInstance(this, config); - if (typeof config === 'number') { - data.to(config); - } else if (typeof action === 'string') { - if (typeof data[action] === 'undefined') { - throw new TypeError(`No method named "${action}"`); + if (typeof config === 'number') { + data.to(config); + return; } - data[action](); - } else if (_config.interval && _config.ride) { - data.pause(); - data.cycle(); - } - } + if (typeof config === 'string') { + if (data[config] === undefined || config.startsWith('_') || config === 'constructor') { + throw new TypeError(`No method named "${config}"`); + } - static jQueryInterface(config) { - return this.each(function () { - Carousel.carouselInterface(this, config); + data[config](); + } }); } - static dataApiClickHandler(event) { - const target = getElementFromSelector(this); + } + /** + * Data API implementation + */ + - if (!target || !target.classList.contains(CLASS_NAME_CAROUSEL)) { - return; - } + EventHandler__default.default.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_SLIDE, function (event) { + const target = index.getElementFromSelector(this); - const config = { ...Manipulator__default.default.getDataAttributes(target), - ...Manipulator__default.default.getDataAttributes(this) - }; - const slideIndex = this.getAttribute('data-bs-slide-to'); + if (!target || !target.classList.contains(CLASS_NAME_CAROUSEL)) { + return; + } - if (slideIndex) { - config.interval = false; - } + event.preventDefault(); + const carousel = Carousel.getOrCreateInstance(target); + const slideIndex = this.getAttribute('data-bs-slide-to'); - Carousel.carouselInterface(target, config); + if (slideIndex) { + carousel.to(slideIndex); - if (slideIndex) { - Carousel.getInstance(target).to(slideIndex); - } + carousel._maybeEnableCycle(); - event.preventDefault(); + return; } - } - /** - * ------------------------------------------------------------------------ - * Data Api implementation - * ------------------------------------------------------------------------ - */ + if (Manipulator__default.default.getDataAttribute(this, 'slide') === 'next') { + carousel.next(); + carousel._maybeEnableCycle(); - EventHandler__default.default.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_SLIDE, Carousel.dataApiClickHandler); + return; + } + + carousel.prev(); + + carousel._maybeEnableCycle(); + }); EventHandler__default.default.on(window, EVENT_LOAD_DATA_API, () => { const carousels = SelectorEngine__default.default.find(SELECTOR_DATA_RIDE); - for (let i = 0, len = carousels.length; i < len; i++) { - Carousel.carouselInterface(carousels[i], Carousel.getInstance(carousels[i])); + for (const carousel of carousels) { + Carousel.getOrCreateInstance(carousel); } }); /** - * ------------------------------------------------------------------------ * jQuery - * ------------------------------------------------------------------------ - * add .Carousel to jQuery only if jQuery is present */ - defineJQueryPlugin(Carousel); + index.defineJQueryPlugin(Carousel); return Carousel; diff --git a/assets/javascripts/bootstrap/collapse.js b/assets/javascripts/bootstrap/collapse.js index 696d9b0..c3aed6c 100644 --- a/assets/javascripts/bootstrap/collapse.js +++ b/assets/javascripts/bootstrap/collapse.js @@ -1,199 +1,34 @@ /*! - * Bootstrap collapse.js v5.1.3 (https://getbootstrap.com/) - * Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) + * Bootstrap collapse.js v5.2.0 (https://getbootstrap.com/) + * Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/data.js'), require('./dom/event-handler.js'), require('./dom/manipulator.js'), require('./dom/selector-engine.js'), require('./base-component.js')) : - typeof define === 'function' && define.amd ? define(['./dom/data', './dom/event-handler', './dom/manipulator', './dom/selector-engine', './base-component'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Collapse = factory(global.Data, global.EventHandler, global.Manipulator, global.SelectorEngine, global.Base)); -})(this, (function (Data, EventHandler, Manipulator, SelectorEngine, BaseComponent) { 'use strict'; + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./util/index'), require('./dom/event-handler'), require('./dom/selector-engine'), require('./base-component')) : + typeof define === 'function' && define.amd ? define(['./util/index', './dom/event-handler', './dom/selector-engine', './base-component'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Collapse = factory(global.Index, global.EventHandler, global.SelectorEngine, global.BaseComponent)); +})(this, (function (index, EventHandler, SelectorEngine, BaseComponent) { 'use strict'; const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e }; - const Data__default = /*#__PURE__*/_interopDefaultLegacy(Data); const EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler); - const Manipulator__default = /*#__PURE__*/_interopDefaultLegacy(Manipulator); const SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine); const BaseComponent__default = /*#__PURE__*/_interopDefaultLegacy(BaseComponent); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): util/index.js + * Bootstrap (v5.2.0): collapse.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ - - const toType = obj => { - if (obj === null || obj === undefined) { - return `${obj}`; - } - - return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase(); - }; - - const getSelector = element => { - let selector = element.getAttribute('data-bs-target'); - - if (!selector || selector === '#') { - let hrefAttr = element.getAttribute('href'); // The only valid content that could double as a selector are IDs or classes, - // so everything starting with `#` or `.`. If a "real" URL is used as the selector, - // `document.querySelector` will rightfully complain it is invalid. - // See https://github.com/twbs/bootstrap/issues/32273 - - if (!hrefAttr || !hrefAttr.includes('#') && !hrefAttr.startsWith('.')) { - return null; - } // Just in case some CMS puts out a full URL with the anchor appended - - - if (hrefAttr.includes('#') && !hrefAttr.startsWith('#')) { - hrefAttr = `#${hrefAttr.split('#')[1]}`; - } - - selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : null; - } - - return selector; - }; - - const getSelectorFromElement = element => { - const selector = getSelector(element); - - if (selector) { - return document.querySelector(selector) ? selector : null; - } - - return null; - }; - - const getElementFromSelector = element => { - const selector = getSelector(element); - return selector ? document.querySelector(selector) : null; - }; - - const isElement = obj => { - if (!obj || typeof obj !== 'object') { - return false; - } - - if (typeof obj.jquery !== 'undefined') { - obj = obj[0]; - } - - return typeof obj.nodeType !== 'undefined'; - }; - - const getElement = obj => { - if (isElement(obj)) { - // it's a jQuery object or a node element - return obj.jquery ? obj[0] : obj; - } - - if (typeof obj === 'string' && obj.length > 0) { - return document.querySelector(obj); - } - - return null; - }; - - const typeCheckConfig = (componentName, config, configTypes) => { - Object.keys(configTypes).forEach(property => { - const expectedTypes = configTypes[property]; - const value = config[property]; - const valueType = value && isElement(value) ? 'element' : toType(value); - - if (!new RegExp(expectedTypes).test(valueType)) { - throw new TypeError(`${componentName.toUpperCase()}: Option "${property}" provided type "${valueType}" but expected type "${expectedTypes}".`); - } - }); - }; - /** - * Trick to restart an element's animation - * - * @param {HTMLElement} element - * @return void - * - * @see https://www.charistheo.io/blog/2021/02/restart-a-css-animation-with-javascript/#restarting-a-css-animation - */ - - - const reflow = element => { - // eslint-disable-next-line no-unused-expressions - element.offsetHeight; - }; - - const getjQuery = () => { - const { - jQuery - } = window; - - if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) { - return jQuery; - } - - return null; - }; - - const DOMContentLoadedCallbacks = []; - - const onDOMContentLoaded = callback => { - if (document.readyState === 'loading') { - // add listener on the first call when the document is in loading state - if (!DOMContentLoadedCallbacks.length) { - document.addEventListener('DOMContentLoaded', () => { - DOMContentLoadedCallbacks.forEach(callback => callback()); - }); - } - - DOMContentLoadedCallbacks.push(callback); - } else { - callback(); - } - }; - - const defineJQueryPlugin = plugin => { - onDOMContentLoaded(() => { - const $ = getjQuery(); - /* istanbul ignore if */ - - if ($) { - const name = plugin.NAME; - const JQUERY_NO_CONFLICT = $.fn[name]; - $.fn[name] = plugin.jQueryInterface; - $.fn[name].Constructor = plugin; - - $.fn[name].noConflict = () => { - $.fn[name] = JQUERY_NO_CONFLICT; - return plugin.jQueryInterface; - }; - } - }); - }; - /** - * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): collapse.js - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) - * -------------------------------------------------------------------------- - */ - /** - * ------------------------------------------------------------------------ * Constants - * ------------------------------------------------------------------------ */ const NAME = 'collapse'; const DATA_KEY = 'bs.collapse'; const EVENT_KEY = `.${DATA_KEY}`; const DATA_API_KEY = '.data-api'; - const Default = { - toggle: true, - parent: null - }; - const DefaultType = { - toggle: 'boolean', - parent: '(null|element)' - }; const EVENT_SHOW = `show${EVENT_KEY}`; const EVENT_SHOWN = `shown${EVENT_KEY}`; const EVENT_HIDE = `hide${EVENT_KEY}`; @@ -209,28 +44,30 @@ const HEIGHT = 'height'; const SELECTOR_ACTIVES = '.collapse.show, .collapse.collapsing'; const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="collapse"]'; + const Default = { + parent: null, + toggle: true + }; + const DefaultType = { + parent: '(null|element)', + toggle: 'boolean' + }; /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ + * Class definition */ class Collapse extends BaseComponent__default.default { constructor(element, config) { - super(element); + super(element, config); this._isTransitioning = false; - this._config = this._getConfig(config); this._triggerArray = []; const toggleList = SelectorEngine__default.default.find(SELECTOR_DATA_TOGGLE); - for (let i = 0, len = toggleList.length; i < len; i++) { - const elem = toggleList[i]; - const selector = getSelectorFromElement(elem); - const filterElement = SelectorEngine__default.default.find(selector).filter(foundElem => foundElem === this._element); + for (const elem of toggleList) { + const selector = index.getSelectorFromElement(elem); + const filterElement = SelectorEngine__default.default.find(selector).filter(foundElement => foundElement === this._element); if (selector !== null && filterElement.length) { - this._selector = selector; - this._triggerArray.push(elem); } } @@ -251,6 +88,10 @@ return Default; } + static get DefaultType() { + return DefaultType; + } + static get NAME() { return NAME; } // Public @@ -269,23 +110,16 @@ return; } - let actives = []; - let activesData; + let activeChildren = []; // find active children if (this._config.parent) { - const children = SelectorEngine__default.default.find(CLASS_NAME_DEEPER_CHILDREN, this._config.parent); - actives = SelectorEngine__default.default.find(SELECTOR_ACTIVES, this._config.parent).filter(elem => !children.includes(elem)); // remove children if greater depth + activeChildren = this._getFirstLevelChildren(SELECTOR_ACTIVES).filter(element => element !== this._element).map(element => Collapse.getOrCreateInstance(element, { + toggle: false + })); } - const container = SelectorEngine__default.default.findOne(this._selector); - - if (actives.length) { - const tempActiveData = actives.find(elem => container !== elem); - activesData = tempActiveData ? Collapse.getInstance(tempActiveData) : null; - - if (activesData && activesData._isTransitioning) { - return; - } + if (activeChildren.length && activeChildren[0]._isTransitioning) { + return; } const startEvent = EventHandler__default.default.trigger(this._element, EVENT_SHOW); @@ -294,17 +128,9 @@ return; } - actives.forEach(elemActive => { - if (container !== elemActive) { - Collapse.getOrCreateInstance(elemActive, { - toggle: false - }).hide(); - } - - if (!activesData) { - Data__default.default.set(elemActive, DATA_KEY, null); - } - }); + for (const activeInstance of activeChildren) { + activeInstance.hide(); + } const dimension = this._getDimension(); @@ -351,19 +177,16 @@ const dimension = this._getDimension(); this._element.style[dimension] = `${this._element.getBoundingClientRect()[dimension]}px`; - reflow(this._element); + index.reflow(this._element); this._element.classList.add(CLASS_NAME_COLLAPSING); this._element.classList.remove(CLASS_NAME_COLLAPSE, CLASS_NAME_SHOW); - const triggerArrayLength = this._triggerArray.length; + for (const trigger of this._triggerArray) { + const element = index.getElementFromSelector(trigger); - for (let i = 0; i < triggerArrayLength; i++) { - const trigger = this._triggerArray[i]; - const elem = getElementFromSelector(trigger); - - if (elem && !this._isShown(elem)) { + if (element && !this._isShown(element)) { this._addAriaAndCollapsedClass([trigger], false); } } @@ -390,15 +213,10 @@ } // Private - _getConfig(config) { - config = { ...Default, - ...Manipulator__default.default.getDataAttributes(this._element), - ...config - }; + _configAfterMerge(config) { config.toggle = Boolean(config.toggle); // Coerce string values - config.parent = getElement(config.parent); - typeCheckConfig(NAME, config, DefaultType); + config.parent = index.getElement(config.parent); return config; } @@ -411,14 +229,21 @@ return; } - const children = SelectorEngine__default.default.find(CLASS_NAME_DEEPER_CHILDREN, this._config.parent); - SelectorEngine__default.default.find(SELECTOR_DATA_TOGGLE, this._config.parent).filter(elem => !children.includes(elem)).forEach(element => { - const selected = getElementFromSelector(element); + const children = this._getFirstLevelChildren(SELECTOR_DATA_TOGGLE); + + for (const element of children) { + const selected = index.getElementFromSelector(element); if (selected) { this._addAriaAndCollapsedClass([element], this._isShown(selected)); } - }); + } + } + + _getFirstLevelChildren(selector) { + const children = SelectorEngine__default.default.find(CLASS_NAME_DEEPER_CHILDREN, this._config.parent); // remove children if greater depth + + return SelectorEngine__default.default.find(selector, this._config.parent).filter(element => !children.includes(element)); } _addAriaAndCollapsedClass(triggerArray, isOpen) { @@ -426,26 +251,21 @@ return; } - triggerArray.forEach(elem => { - if (isOpen) { - elem.classList.remove(CLASS_NAME_COLLAPSED); - } else { - elem.classList.add(CLASS_NAME_COLLAPSED); - } - - elem.setAttribute('aria-expanded', isOpen); - }); + for (const element of triggerArray) { + element.classList.toggle(CLASS_NAME_COLLAPSED, !isOpen); + element.setAttribute('aria-expanded', isOpen); + } } // Static static jQueryInterface(config) { - return this.each(function () { - const _config = {}; + const _config = {}; - if (typeof config === 'string' && /show|hide/.test(config)) { - _config.toggle = false; - } + if (typeof config === 'string' && /show|hide/.test(config)) { + _config.toggle = false; + } + return this.each(function () { const data = Collapse.getOrCreateInstance(this, _config); if (typeof config === 'string') { @@ -460,9 +280,7 @@ } /** - * ------------------------------------------------------------------------ - * Data Api implementation - * ------------------------------------------------------------------------ + * Data API implementation */ @@ -472,22 +290,20 @@ event.preventDefault(); } - const selector = getSelectorFromElement(this); + const selector = index.getSelectorFromElement(this); const selectorElements = SelectorEngine__default.default.find(selector); - selectorElements.forEach(element => { + + for (const element of selectorElements) { Collapse.getOrCreateInstance(element, { toggle: false }).toggle(); - }); + } }); /** - * ------------------------------------------------------------------------ * jQuery - * ------------------------------------------------------------------------ - * add .Collapse to jQuery only if jQuery is present */ - defineJQueryPlugin(Collapse); + index.defineJQueryPlugin(Collapse); return Collapse; diff --git a/assets/javascripts/bootstrap/dom/data.js b/assets/javascripts/bootstrap/dom/data.js index 85e1bb6..59cfa84 100644 --- a/assets/javascripts/bootstrap/dom/data.js +++ b/assets/javascripts/bootstrap/dom/data.js @@ -1,6 +1,6 @@ /*! - * Bootstrap data.js v5.1.3 (https://getbootstrap.com/) - * Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) + * Bootstrap data.js v5.2.0 (https://getbootstrap.com/) + * Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ (function (global, factory) { @@ -11,15 +11,13 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): dom/data.js + * Bootstrap (v5.2.0): dom/data.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** - * ------------------------------------------------------------------------ * Constants - * ------------------------------------------------------------------------ */ const elementMap = new Map(); const data = { diff --git a/assets/javascripts/bootstrap/dom/event-handler.js b/assets/javascripts/bootstrap/dom/event-handler.js index 15f9eb0..2b7251b 100644 --- a/assets/javascripts/bootstrap/dom/event-handler.js +++ b/assets/javascripts/bootstrap/dom/event-handler.js @@ -1,43 +1,22 @@ /*! - * Bootstrap event-handler.js v5.1.3 (https://getbootstrap.com/) - * Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) + * Bootstrap event-handler.js v5.2.0 (https://getbootstrap.com/) + * Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : - typeof define === 'function' && define.amd ? define(factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.EventHandler = factory()); -})(this, (function () { 'use strict'; + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('../util/index')) : + typeof define === 'function' && define.amd ? define(['../util/index'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.EventHandler = factory(global.Index)); +})(this, (function (index) { 'use strict'; /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): util/index.js + * Bootstrap (v5.2.0): dom/event-handler.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ - - const getjQuery = () => { - const { - jQuery - } = window; - - if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) { - return jQuery; - } - - return null; - }; - /** - * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): dom/event-handler.js - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) - * -------------------------------------------------------------------------- - */ - /** - * ------------------------------------------------------------------------ * Constants - * ------------------------------------------------------------------------ */ const namespaceRegex = /[^.]*(?=\..*)\.|.*/; @@ -50,20 +29,17 @@ mouseenter: 'mouseover', mouseleave: 'mouseout' }; - const customEventsRegex = /^(mouseenter|mouseleave)/i; const nativeEvents = new Set(['click', 'dblclick', 'mouseup', 'mousedown', 'contextmenu', 'mousewheel', 'DOMMouseScroll', 'mouseover', 'mouseout', 'mousemove', 'selectstart', 'selectend', 'keydown', 'keypress', 'keyup', 'orientationchange', 'touchstart', 'touchmove', 'touchend', 'touchcancel', 'pointerdown', 'pointermove', 'pointerup', 'pointerleave', 'pointercancel', 'gesturestart', 'gesturechange', 'gestureend', 'focus', 'blur', 'change', 'reset', 'select', 'submit', 'focusin', 'focusout', 'load', 'unload', 'beforeunload', 'resize', 'move', 'DOMContentLoaded', 'readystatechange', 'error', 'abort', 'scroll']); /** - * ------------------------------------------------------------------------ * Private methods - * ------------------------------------------------------------------------ */ - function getUidEvent(element, uid) { + function makeEventUid(element, uid) { return uid && `${uid}::${uidEvent++}` || element.uidEvent || uidEvent++; } - function getEvent(element) { - const uid = getUidEvent(element); + function getElementEvents(element) { + const uid = makeEventUid(element); element.uidEvent = uid; eventRegistry[uid] = eventRegistry[uid] || {}; return eventRegistry[uid]; @@ -71,7 +47,9 @@ function bootstrapHandler(element, fn) { return function handler(event) { - event.delegateTarget = element; + hydrateObj(event, { + delegateTarget: element + }); if (handler.oneOff) { EventHandler.off(element, event.type, fn); @@ -88,65 +66,52 @@ for (let { target } = event; target && target !== this; target = target.parentNode) { - for (let i = domElements.length; i--;) { - if (domElements[i] === target) { - event.delegateTarget = target; + for (const domElement of domElements) { + if (domElement !== target) { + continue; + } - if (handler.oneOff) { - EventHandler.off(element, event.type, selector, fn); - } + hydrateObj(event, { + delegateTarget: target + }); - return fn.apply(target, [event]); + if (handler.oneOff) { + EventHandler.off(element, event.type, selector, fn); } - } - } // To please ESLint - - return null; + return fn.apply(target, [event]); + } + } }; } - function findHandler(events, handler, delegationSelector = null) { - const uidEventList = Object.keys(events); - - for (let i = 0, len = uidEventList.length; i < len; i++) { - const event = events[uidEventList[i]]; - - if (event.originalHandler === handler && event.delegationSelector === delegationSelector) { - return event; - } - } - - return null; + function findHandler(events, callable, delegationSelector = null) { + return Object.values(events).find(event => event.callable === callable && event.delegationSelector === delegationSelector); } - function normalizeParams(originalTypeEvent, handler, delegationFn) { - const delegation = typeof handler === 'string'; - const originalHandler = delegation ? delegationFn : handler; + function normalizeParameters(originalTypeEvent, handler, delegationFunction) { + const isDelegated = typeof handler === 'string'; // todo: tooltip passes `false` instead of selector, so we need to check + + const callable = isDelegated ? delegationFunction : handler || delegationFunction; let typeEvent = getTypeEvent(originalTypeEvent); - const isNative = nativeEvents.has(typeEvent); - if (!isNative) { + if (!nativeEvents.has(typeEvent)) { typeEvent = originalTypeEvent; } - return [delegation, originalHandler, typeEvent]; + return [isDelegated, callable, typeEvent]; } - function addHandler(element, originalTypeEvent, handler, delegationFn, oneOff) { + function addHandler(element, originalTypeEvent, handler, delegationFunction, oneOff) { if (typeof originalTypeEvent !== 'string' || !element) { return; } - if (!handler) { - handler = delegationFn; - delegationFn = null; - } // in case of mouseenter or mouseleave wrap the handler within a function that checks for its DOM position + let [isDelegated, callable, typeEvent] = normalizeParameters(originalTypeEvent, handler, delegationFunction); // in case of mouseenter or mouseleave wrap the handler within a function that checks for its DOM position // this prevents the handler from being dispatched the same way as mouseover or mouseout does - - if (customEventsRegex.test(originalTypeEvent)) { - const wrapFn = fn => { + if (originalTypeEvent in customEvents) { + const wrapFunction = fn => { return function (event) { if (!event.relatedTarget || event.relatedTarget !== event.delegateTarget && !event.delegateTarget.contains(event.relatedTarget)) { return fn.call(this, event); @@ -154,31 +119,26 @@ }; }; - if (delegationFn) { - delegationFn = wrapFn(delegationFn); - } else { - handler = wrapFn(handler); - } + callable = wrapFunction(callable); } - const [delegation, originalHandler, typeEvent] = normalizeParams(originalTypeEvent, handler, delegationFn); - const events = getEvent(element); + const events = getElementEvents(element); const handlers = events[typeEvent] || (events[typeEvent] = {}); - const previousFn = findHandler(handlers, originalHandler, delegation ? handler : null); + const previousFunction = findHandler(handlers, callable, isDelegated ? handler : null); - if (previousFn) { - previousFn.oneOff = previousFn.oneOff && oneOff; + if (previousFunction) { + previousFunction.oneOff = previousFunction.oneOff && oneOff; return; } - const uid = getUidEvent(originalHandler, originalTypeEvent.replace(namespaceRegex, '')); - const fn = delegation ? bootstrapDelegationHandler(element, handler, delegationFn) : bootstrapHandler(element, handler); - fn.delegationSelector = delegation ? handler : null; - fn.originalHandler = originalHandler; + const uid = makeEventUid(callable, originalTypeEvent.replace(namespaceRegex, '')); + const fn = isDelegated ? bootstrapDelegationHandler(element, handler, callable) : bootstrapHandler(element, callable); + fn.delegationSelector = isDelegated ? handler : null; + fn.callable = callable; fn.oneOff = oneOff; fn.uidEvent = uid; handlers[uid] = fn; - element.addEventListener(typeEvent, fn, delegation); + element.addEventListener(typeEvent, fn, isDelegated); } function removeHandler(element, events, typeEvent, handler, delegationSelector) { @@ -194,12 +154,13 @@ function removeNamespacedHandlers(element, events, typeEvent, namespace) { const storeElementEvent = events[typeEvent] || {}; - Object.keys(storeElementEvent).forEach(handlerKey => { + + for (const handlerKey of Object.keys(storeElementEvent)) { if (handlerKey.includes(namespace)) { const event = storeElementEvent[handlerKey]; - removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector); + removeHandler(element, events, typeEvent, event.callable, event.delegationSelector); } - }); + } } function getTypeEvent(event) { @@ -209,49 +170,49 @@ } const EventHandler = { - on(element, event, handler, delegationFn) { - addHandler(element, event, handler, delegationFn, false); + on(element, event, handler, delegationFunction) { + addHandler(element, event, handler, delegationFunction, false); }, - one(element, event, handler, delegationFn) { - addHandler(element, event, handler, delegationFn, true); + one(element, event, handler, delegationFunction) { + addHandler(element, event, handler, delegationFunction, true); }, - off(element, originalTypeEvent, handler, delegationFn) { + off(element, originalTypeEvent, handler, delegationFunction) { if (typeof originalTypeEvent !== 'string' || !element) { return; } - const [delegation, originalHandler, typeEvent] = normalizeParams(originalTypeEvent, handler, delegationFn); + const [isDelegated, callable, typeEvent] = normalizeParameters(originalTypeEvent, handler, delegationFunction); const inNamespace = typeEvent !== originalTypeEvent; - const events = getEvent(element); + const events = getElementEvents(element); + const storeElementEvent = events[typeEvent] || {}; const isNamespace = originalTypeEvent.startsWith('.'); - if (typeof originalHandler !== 'undefined') { + if (typeof callable !== 'undefined') { // Simplest case: handler is passed, remove that listener ONLY. - if (!events || !events[typeEvent]) { + if (!Object.keys(storeElementEvent).length) { return; } - removeHandler(element, events, typeEvent, originalHandler, delegation ? handler : null); + removeHandler(element, events, typeEvent, callable, isDelegated ? handler : null); return; } if (isNamespace) { - Object.keys(events).forEach(elementEvent => { + for (const elementEvent of Object.keys(events)) { removeNamespacedHandlers(element, events, elementEvent, originalTypeEvent.slice(1)); - }); + } } - const storeElementEvent = events[typeEvent] || {}; - Object.keys(storeElementEvent).forEach(keyHandlers => { + for (const keyHandlers of Object.keys(storeElementEvent)) { const handlerKey = keyHandlers.replace(stripUidRegex, ''); if (!inNamespace || originalTypeEvent.includes(handlerKey)) { const event = storeElementEvent[keyHandlers]; - removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector); + removeHandler(element, events, typeEvent, event.callable, event.delegationSelector); } - }); + } }, trigger(element, event, args) { @@ -259,15 +220,13 @@ return null; } - const $ = getjQuery(); + const $ = index.getjQuery(); const typeEvent = getTypeEvent(event); const inNamespace = event !== typeEvent; - const isNative = nativeEvents.has(typeEvent); - let jQueryEvent; + let jQueryEvent = null; let bubbles = true; let nativeDispatch = true; let defaultPrevented = false; - let evt = null; if (inNamespace && $) { jQueryEvent = $.Event(event, args); @@ -277,27 +236,11 @@ defaultPrevented = jQueryEvent.isDefaultPrevented(); } - if (isNative) { - evt = document.createEvent('HTMLEvents'); - evt.initEvent(typeEvent, bubbles, true); - } else { - evt = new CustomEvent(event, { - bubbles, - cancelable: true - }); - } // merge custom information in our event - - - if (typeof args !== 'undefined') { - Object.keys(args).forEach(key => { - Object.defineProperty(evt, key, { - get() { - return args[key]; - } - - }); - }); - } + let evt = new Event(event, { + bubbles, + cancelable: true + }); + evt = hydrateObj(evt, args); if (defaultPrevented) { evt.preventDefault(); @@ -307,7 +250,7 @@ element.dispatchEvent(evt); } - if (evt.defaultPrevented && typeof jQueryEvent !== 'undefined') { + if (evt.defaultPrevented && jQueryEvent) { jQueryEvent.preventDefault(); } @@ -316,6 +259,25 @@ }; + function hydrateObj(obj, meta) { + for (const [key, value] of Object.entries(meta || {})) { + try { + obj[key] = value; + } catch (_unused) { + Object.defineProperty(obj, key, { + configurable: true, + + get() { + return value; + } + + }); + } + } + + return obj; + } + return EventHandler; })); diff --git a/assets/javascripts/bootstrap/dom/manipulator.js b/assets/javascripts/bootstrap/dom/manipulator.js index 199e304..00acc8a 100644 --- a/assets/javascripts/bootstrap/dom/manipulator.js +++ b/assets/javascripts/bootstrap/dom/manipulator.js @@ -1,6 +1,6 @@ /*! - * Bootstrap manipulator.js v5.1.3 (https://getbootstrap.com/) - * Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) + * Bootstrap manipulator.js v5.2.0 (https://getbootstrap.com/) + * Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ (function (global, factory) { @@ -11,28 +11,36 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): dom/manipulator.js + * Bootstrap (v5.2.0): dom/manipulator.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ - function normalizeData(val) { - if (val === 'true') { + function normalizeData(value) { + if (value === 'true') { return true; } - if (val === 'false') { + if (value === 'false') { return false; } - if (val === Number(val).toString()) { - return Number(val); + if (value === Number(value).toString()) { + return Number(value); } - if (val === '' || val === 'null') { + if (value === '' || value === 'null') { return null; } - return val; + if (typeof value !== 'string') { + return value; + } + + try { + return JSON.parse(decodeURIComponent(value)); + } catch (_unused) { + return value; + } } function normalizeDataKey(key) { @@ -54,31 +62,19 @@ } const attributes = {}; - Object.keys(element.dataset).filter(key => key.startsWith('bs')).forEach(key => { + const bsKeys = Object.keys(element.dataset).filter(key => key.startsWith('bs') && !key.startsWith('bsConfig')); + + for (const key of bsKeys) { let pureKey = key.replace(/^bs/, ''); pureKey = pureKey.charAt(0).toLowerCase() + pureKey.slice(1, pureKey.length); attributes[pureKey] = normalizeData(element.dataset[key]); - }); + } + return attributes; }, getDataAttribute(element, key) { return normalizeData(element.getAttribute(`data-bs-${normalizeDataKey(key)}`)); - }, - - offset(element) { - const rect = element.getBoundingClientRect(); - return { - top: rect.top + window.pageYOffset, - left: rect.left + window.pageXOffset - }; - }, - - position(element) { - return { - top: element.offsetTop, - left: element.offsetLeft - }; } }; diff --git a/assets/javascripts/bootstrap/dom/selector-engine.js b/assets/javascripts/bootstrap/dom/selector-engine.js index 637133b..8c23ee7 100644 --- a/assets/javascripts/bootstrap/dom/selector-engine.js +++ b/assets/javascripts/bootstrap/dom/selector-engine.js @@ -1,64 +1,24 @@ /*! - * Bootstrap selector-engine.js v5.1.3 (https://getbootstrap.com/) - * Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) + * Bootstrap selector-engine.js v5.2.0 (https://getbootstrap.com/) + * Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : - typeof define === 'function' && define.amd ? define(factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.SelectorEngine = factory()); -})(this, (function () { 'use strict'; + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('../util/index')) : + typeof define === 'function' && define.amd ? define(['../util/index'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.SelectorEngine = factory(global.Index)); +})(this, (function (index) { 'use strict'; /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): util/index.js + * Bootstrap (v5.2.0): dom/selector-engine.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ - - const isElement = obj => { - if (!obj || typeof obj !== 'object') { - return false; - } - - if (typeof obj.jquery !== 'undefined') { - obj = obj[0]; - } - - return typeof obj.nodeType !== 'undefined'; - }; - - const isVisible = element => { - if (!isElement(element) || element.getClientRects().length === 0) { - return false; - } - - return getComputedStyle(element).getPropertyValue('visibility') === 'visible'; - }; - - const isDisabled = element => { - if (!element || element.nodeType !== Node.ELEMENT_NODE) { - return true; - } - - if (element.classList.contains('disabled')) { - return true; - } - - if (typeof element.disabled !== 'undefined') { - return element.disabled; - } - - return element.hasAttribute('disabled') && element.getAttribute('disabled') !== 'false'; - }; - /** - * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): dom/selector-engine.js - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) - * -------------------------------------------------------------------------- + * Constants */ - const NODE_TEXT = 3; + const SelectorEngine = { find(selector, element = document.documentElement) { return [].concat(...Element.prototype.querySelectorAll.call(element, selector)); @@ -74,14 +34,11 @@ parents(element, selector) { const parents = []; - let ancestor = element.parentNode; - - while (ancestor && ancestor.nodeType === Node.ELEMENT_NODE && ancestor.nodeType !== NODE_TEXT) { - if (ancestor.matches(selector)) { - parents.push(ancestor); - } + let ancestor = element.parentNode.closest(selector); - ancestor = ancestor.parentNode; + while (ancestor) { + parents.push(ancestor); + ancestor = ancestor.parentNode.closest(selector); } return parents; @@ -101,6 +58,7 @@ return []; }, + // TODO: this is now unused; remove later along with prev() next(element, selector) { let next = element.nextElementSibling; @@ -116,8 +74,8 @@ }, focusableChildren(element) { - const focusables = ['a', 'button', 'input', 'textarea', 'select', 'details', '[tabindex]', '[contenteditable="true"]'].map(selector => `${selector}:not([tabindex^="-"])`).join(', '); - return this.find(focusables, element).filter(el => !isDisabled(el) && isVisible(el)); + const focusables = ['a', 'button', 'input', 'textarea', 'select', 'details', '[tabindex]', '[contenteditable="true"]'].map(selector => `${selector}:not([tabindex^="-"])`).join(','); + return this.find(focusables, element).filter(el => !index.isDisabled(el) && index.isVisible(el)); } }; diff --git a/assets/javascripts/bootstrap/dropdown.js b/assets/javascripts/bootstrap/dropdown.js index 4cc82b4..ee7b804 100644 --- a/assets/javascripts/bootstrap/dropdown.js +++ b/assets/javascripts/bootstrap/dropdown.js @@ -1,19 +1,19 @@ /*! - * Bootstrap dropdown.js v5.1.3 (https://getbootstrap.com/) - * Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) + * Bootstrap dropdown.js v5.2.0 (https://getbootstrap.com/) + * Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ (function (global, factory) { - 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')) : - typeof define === 'function' && define.amd ? define(['@popperjs/core', './dom/event-handler', './dom/manipulator', './dom/selector-engine', './base-component'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Dropdown = factory(global.Popper, global.EventHandler, global.Manipulator, global.SelectorEngine, global.Base)); -})(this, (function (Popper, EventHandler, Manipulator, SelectorEngine, BaseComponent) { 'use strict'; + 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'; const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e }; function _interopNamespace(e) { if (e && e.__esModule) return e; - const n = Object.create(null); + const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } }); if (e) { for (const k in e) { if (k !== 'default') { @@ -37,198 +37,12 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): util/index.js + * Bootstrap (v5.2.0): dropdown.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ - - const toType = obj => { - if (obj === null || obj === undefined) { - return `${obj}`; - } - - return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase(); - }; - - const getSelector = element => { - let selector = element.getAttribute('data-bs-target'); - - if (!selector || selector === '#') { - let hrefAttr = element.getAttribute('href'); // The only valid content that could double as a selector are IDs or classes, - // so everything starting with `#` or `.`. If a "real" URL is used as the selector, - // `document.querySelector` will rightfully complain it is invalid. - // See https://github.com/twbs/bootstrap/issues/32273 - - if (!hrefAttr || !hrefAttr.includes('#') && !hrefAttr.startsWith('.')) { - return null; - } // Just in case some CMS puts out a full URL with the anchor appended - - - if (hrefAttr.includes('#') && !hrefAttr.startsWith('#')) { - hrefAttr = `#${hrefAttr.split('#')[1]}`; - } - - selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : null; - } - - return selector; - }; - - const getElementFromSelector = element => { - const selector = getSelector(element); - return selector ? document.querySelector(selector) : null; - }; - - const isElement = obj => { - if (!obj || typeof obj !== 'object') { - return false; - } - - if (typeof obj.jquery !== 'undefined') { - obj = obj[0]; - } - - return typeof obj.nodeType !== 'undefined'; - }; - - const getElement = obj => { - if (isElement(obj)) { - // it's a jQuery object or a node element - return obj.jquery ? obj[0] : obj; - } - - if (typeof obj === 'string' && obj.length > 0) { - return document.querySelector(obj); - } - - return null; - }; - - const typeCheckConfig = (componentName, config, configTypes) => { - Object.keys(configTypes).forEach(property => { - const expectedTypes = configTypes[property]; - const value = config[property]; - const valueType = value && isElement(value) ? 'element' : toType(value); - - if (!new RegExp(expectedTypes).test(valueType)) { - throw new TypeError(`${componentName.toUpperCase()}: Option "${property}" provided type "${valueType}" but expected type "${expectedTypes}".`); - } - }); - }; - - const isVisible = element => { - if (!isElement(element) || element.getClientRects().length === 0) { - return false; - } - - return getComputedStyle(element).getPropertyValue('visibility') === 'visible'; - }; - - const isDisabled = element => { - if (!element || element.nodeType !== Node.ELEMENT_NODE) { - return true; - } - - if (element.classList.contains('disabled')) { - return true; - } - - if (typeof element.disabled !== 'undefined') { - return element.disabled; - } - - return element.hasAttribute('disabled') && element.getAttribute('disabled') !== 'false'; - }; - - const noop = () => {}; - - const getjQuery = () => { - const { - jQuery - } = window; - - if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) { - return jQuery; - } - - return null; - }; - - const DOMContentLoadedCallbacks = []; - - const onDOMContentLoaded = callback => { - if (document.readyState === 'loading') { - // add listener on the first call when the document is in loading state - if (!DOMContentLoadedCallbacks.length) { - document.addEventListener('DOMContentLoaded', () => { - DOMContentLoadedCallbacks.forEach(callback => callback()); - }); - } - - DOMContentLoadedCallbacks.push(callback); - } else { - callback(); - } - }; - - const isRTL = () => document.documentElement.dir === 'rtl'; - - const defineJQueryPlugin = plugin => { - onDOMContentLoaded(() => { - const $ = getjQuery(); - /* istanbul ignore if */ - - if ($) { - const name = plugin.NAME; - const JQUERY_NO_CONFLICT = $.fn[name]; - $.fn[name] = plugin.jQueryInterface; - $.fn[name].Constructor = plugin; - - $.fn[name].noConflict = () => { - $.fn[name] = JQUERY_NO_CONFLICT; - return plugin.jQueryInterface; - }; - } - }); - }; - /** - * Return the previous/next element of a list. - * - * @param {array} list The list of elements - * @param activeElement The active element - * @param shouldGetNext Choose to get next or previous element - * @param isCycleAllowed - * @return {Element|elem} The proper element - */ - - - const getNextActiveElement = (list, activeElement, shouldGetNext, isCycleAllowed) => { - 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 - - if (index === -1) { - return list[!shouldGetNext && isCycleAllowed ? list.length - 1 : 0]; - } - - const listLength = list.length; - index += shouldGetNext ? 1 : -1; - - if (isCycleAllowed) { - index = (index + listLength) % listLength; - } - - return list[Math.max(0, Math.min(index, listLength - 1))]; - }; - /** - * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): dropdown.js - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) - * -------------------------------------------------------------------------- - */ - /** - * ------------------------------------------------------------------------ * Constants - * ------------------------------------------------------------------------ */ const NAME = 'dropdown'; @@ -236,13 +50,11 @@ const EVENT_KEY = `.${DATA_KEY}`; const DATA_API_KEY = '.data-api'; const ESCAPE_KEY = 'Escape'; - const SPACE_KEY = 'Space'; 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 REGEXP_KEYDOWN = new RegExp(`${ARROW_UP_KEY}|${ARROW_DOWN_KEY}|${ESCAPE_KEY}`); const EVENT_HIDE = `hide${EVENT_KEY}`; const EVENT_HIDDEN = `hidden${EVENT_KEY}`; const EVENT_SHOW = `show${EVENT_KEY}`; @@ -254,45 +66,49 @@ const CLASS_NAME_DROPUP = 'dropup'; const CLASS_NAME_DROPEND = 'dropend'; const CLASS_NAME_DROPSTART = 'dropstart'; - const CLASS_NAME_NAVBAR = 'navbar'; - const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="dropdown"]'; + 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}`; const SELECTOR_MENU = '.dropdown-menu'; + const SELECTOR_NAVBAR = '.navbar'; const SELECTOR_NAVBAR_NAV = '.navbar-nav'; const SELECTOR_VISIBLE_ITEMS = '.dropdown-menu .dropdown-item:not(.disabled):not(:disabled)'; - const PLACEMENT_TOP = isRTL() ? 'top-end' : 'top-start'; - const PLACEMENT_TOPEND = isRTL() ? 'top-start' : 'top-end'; - const PLACEMENT_BOTTOM = isRTL() ? 'bottom-end' : 'bottom-start'; - const PLACEMENT_BOTTOMEND = isRTL() ? 'bottom-start' : 'bottom-end'; - const PLACEMENT_RIGHT = isRTL() ? 'left-start' : 'right-start'; - const PLACEMENT_LEFT = isRTL() ? 'right-start' : 'left-start'; + 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'; const Default = { - offset: [0, 2], + autoClose: true, boundary: 'clippingParents', - reference: 'toggle', display: 'dynamic', + offset: [0, 2], popperConfig: null, - autoClose: true + reference: 'toggle' }; const DefaultType = { - offset: '(array|string|function)', + autoClose: '(boolean|string)', boundary: '(string|element)', - reference: '(string|element|object)', display: 'string', + offset: '(array|string|function)', popperConfig: '(null|object|function)', - autoClose: '(boolean|string)' + reference: '(string|element|object)' }; /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ + * Class definition */ class Dropdown extends BaseComponent__default.default { constructor(element, config) { - super(element); + super(element, config); this._popper = null; - this._config = this._getConfig(config); - this._menu = this._getMenuElement(); + this._parent = this._element.parentNode; // dropdown wrapper + + this._menu = SelectorEngine__default.default.findOne(SELECTOR_MENU, this._parent); this._inNavbar = this._detectNavbar(); } // Getters @@ -315,7 +131,7 @@ } show() { - if (isDisabled(this._element) || this._isShown(this._menu)) { + if (index.isDisabled(this._element) || this._isShown()) { return; } @@ -328,20 +144,16 @@ return; } - const parent = Dropdown.getParentFromElement(this._element); // Totally disable Popper for Dropdowns in Navbar - - if (this._inNavbar) { - Manipulator__default.default.setDataAttribute(this._menu, 'popper', 'none'); - } else { - this._createPopper(parent); - } // If this is a touch-enabled device we add extra + this._createPopper(); // 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)) { - [].concat(...document.body.children).forEach(elem => EventHandler__default.default.on(elem, 'mouseover', noop)); + 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); + } } this._element.focus(); @@ -356,7 +168,7 @@ } hide() { - if (isDisabled(this._element) || !this._isShown(this._menu)) { + if (index.isDisabled(this._element) || !this._isShown()) { return; } @@ -394,7 +206,9 @@ if ('ontouchstart' in document.documentElement) { - [].concat(...document.body.children).forEach(elem => EventHandler__default.default.off(elem, 'mouseover', noop)); + for (const element of [].concat(...document.body.children)) { + EventHandler__default.default.off(element, 'mouseover', index.noop); + } } if (this._popper) { @@ -412,13 +226,9 @@ } _getConfig(config) { - config = { ...this.constructor.Default, - ...Manipulator__default.default.getDataAttributes(this._element), - ...config - }; - typeCheckConfig(NAME, config, this.constructor.DefaultType); + config = super._getConfig(config); - if (typeof config.reference === 'object' && !isElement(config.reference) && typeof config.reference.getBoundingClientRect !== 'function') { + if (typeof config.reference === 'object' && !index.isElement(config.reference) && typeof config.reference.getBoundingClientRect !== 'function') { // Popper virtual elements require a getBoundingClientRect method throw new TypeError(`${NAME.toUpperCase()}: Option "reference" provided type "object" without a required "getBoundingClientRect" method.`); } @@ -426,7 +236,7 @@ return config; } - _createPopper(parent) { + _createPopper() { if (typeof Popper__namespace === 'undefined') { throw new TypeError('Bootstrap\'s dropdowns require Popper (https://popper.js.org)'); } @@ -434,33 +244,24 @@ let referenceElement = this._element; if (this._config.reference === 'parent') { - referenceElement = parent; - } else if (isElement(this._config.reference)) { - referenceElement = getElement(this._config.reference); + referenceElement = this._parent; + } else if (index.isElement(this._config.reference)) { + referenceElement = index.getElement(this._config.reference); } else if (typeof this._config.reference === 'object') { referenceElement = this._config.reference; } const popperConfig = this._getPopperConfig(); - const isDisplayStatic = popperConfig.modifiers.find(modifier => modifier.name === 'applyStyles' && modifier.enabled === false); this._popper = Popper__namespace.createPopper(referenceElement, this._menu, popperConfig); - - if (isDisplayStatic) { - Manipulator__default.default.setDataAttribute(this._menu, 'popper', 'static'); - } } - _isShown(element = this._element) { - return element.classList.contains(CLASS_NAME_SHOW); - } - - _getMenuElement() { - return SelectorEngine__default.default.next(this._element, SELECTOR_MENU)[0]; + _isShown() { + return this._menu.classList.contains(CLASS_NAME_SHOW); } _getPlacement() { - const parentDropdown = this._element.parentNode; + const parentDropdown = this._parent; if (parentDropdown.classList.contains(CLASS_NAME_DROPEND)) { return PLACEMENT_RIGHT; @@ -468,6 +269,14 @@ if (parentDropdown.classList.contains(CLASS_NAME_DROPSTART)) { return PLACEMENT_LEFT; + } + + if (parentDropdown.classList.contains(CLASS_NAME_DROPUP_CENTER)) { + return PLACEMENT_TOPCENTER; + } + + if (parentDropdown.classList.contains(CLASS_NAME_DROPDOWN_CENTER)) { + return PLACEMENT_BOTTOMCENTER; } // We need to trim the value because custom properties can also include spaces @@ -481,7 +290,7 @@ } _detectNavbar() { - return this._element.closest(`.${CLASS_NAME_NAVBAR}`) !== null; + return this._element.closest(SELECTOR_NAVBAR) !== null; } _getOffset() { @@ -490,7 +299,7 @@ } = this._config; if (typeof offset === 'string') { - return offset.split(',').map(val => Number.parseInt(val, 10)); + return offset.split(',').map(value => Number.parseInt(value, 10)); } if (typeof offset === 'function') { @@ -514,9 +323,11 @@ offset: this._getOffset() } }] - }; // Disable Popper if we have a static display + }; // 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 - if (this._config.display === 'static') { defaultBsPopperConfig.modifiers = [{ name: 'applyStyles', enabled: false @@ -532,7 +343,7 @@ key, target }) { - const items = SelectorEngine__default.default.find(SELECTOR_VISIBLE_ITEMS, this._menu).filter(isVisible); + const items = SelectorEngine__default.default.find(SELECTOR_VISIBLE_ITEMS, this._menu).filter(element => index.isVisible(element)); if (!items.length) { return; @@ -540,7 +351,7 @@ // allow cycling to get the last item in case key equals ARROW_UP_KEY - getNextActiveElement(items, target, key === ARROW_DOWN_KEY, !items.includes(target)).focus(); + index.getNextActiveElement(items, target, key === ARROW_DOWN_KEY, !items.includes(target)).focus(); } // Static @@ -561,20 +372,28 @@ } static clearMenus(event) { - if (event && (event.button === RIGHT_MOUSE_BUTTON || event.type === 'keyup' && event.key !== TAB_KEY)) { + if (event.button === RIGHT_MOUSE_BUTTON || event.type === 'keyup' && event.key !== TAB_KEY) { return; } - const toggles = SelectorEngine__default.default.find(SELECTOR_DATA_TOGGLE); + const openToggles = SelectorEngine__default.default.find(SELECTOR_DATA_TOGGLE_SHOWN); - for (let i = 0, len = toggles.length; i < len; i++) { - const context = Dropdown.getInstance(toggles[i]); + for (const toggle of openToggles) { + const context = Dropdown.getInstance(toggle); if (!context || context._config.autoClose === false) { continue; } - if (!context._isShown()) { + 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))) { continue; } @@ -582,85 +401,53 @@ relatedTarget: context._element }; - if (event) { - 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))) { - continue; - } - - if (event.type === 'click') { - relatedTarget.clickEvent = event; - } + if (event.type === 'click') { + relatedTarget.clickEvent = event; } context._completeHide(relatedTarget); } } - static getParentFromElement(element) { - return getElementFromSelector(element) || element.parentNode; - } - 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.key === SPACE_KEY || event.key !== ESCAPE_KEY && (event.key !== ARROW_DOWN_KEY && event.key !== ARROW_UP_KEY || event.target.closest(SELECTOR_MENU)) : !REGEXP_KEYDOWN.test(event.key)) { - return; - } - - const isActive = this.classList.contains(CLASS_NAME_SHOW); + // 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); - if (!isActive && event.key === ESCAPE_KEY) { + if (!isUpOrDownEvent && !isEscapeEvent) { return; } - event.preventDefault(); - event.stopPropagation(); - - if (isDisabled(this)) { + if (isInput && !isEscapeEvent) { return; } - const getToggleButton = this.matches(SELECTOR_DATA_TOGGLE) ? this : SelectorEngine__default.default.prev(this, SELECTOR_DATA_TOGGLE)[0]; + event.preventDefault(); + const getToggleButton = SelectorEngine__default.default.findOne(SELECTOR_DATA_TOGGLE, event.delegateTarget.parentNode); const instance = Dropdown.getOrCreateInstance(getToggleButton); - if (event.key === ESCAPE_KEY) { - instance.hide(); - return; - } - - if (event.key === ARROW_UP_KEY || event.key === ARROW_DOWN_KEY) { - if (!isActive) { - instance.show(); - } + if (isUpOrDownEvent) { + event.stopPropagation(); + instance.show(); instance._selectMenuItem(event); return; } - if (!isActive || event.key === SPACE_KEY) { - Dropdown.clearMenus(); + if (instance._isShown()) { + // else is escape and we check if it is shown + event.stopPropagation(); + instance.hide(); + getToggleButton.focus(); } } } /** - * ------------------------------------------------------------------------ - * Data Api implementation - * ------------------------------------------------------------------------ + * Data API implementation */ @@ -673,13 +460,10 @@ Dropdown.getOrCreateInstance(this).toggle(); }); /** - * ------------------------------------------------------------------------ * jQuery - * ------------------------------------------------------------------------ - * add .Dropdown to jQuery only if jQuery is present */ - defineJQueryPlugin(Dropdown); + index.defineJQueryPlugin(Dropdown); return Dropdown; diff --git a/assets/javascripts/bootstrap/modal.js b/assets/javascripts/bootstrap/modal.js index e968964..24cde8a 100644 --- a/assets/javascripts/bootstrap/modal.js +++ b/assets/javascripts/bootstrap/modal.js @@ -1,622 +1,31 @@ /*! - * Bootstrap modal.js v5.1.3 (https://getbootstrap.com/) - * Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) + * Bootstrap modal.js v5.2.0 (https://getbootstrap.com/) + * Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/event-handler.js'), require('./dom/manipulator.js'), require('./dom/selector-engine.js'), require('./base-component.js')) : - typeof define === 'function' && define.amd ? define(['./dom/event-handler', './dom/manipulator', './dom/selector-engine', './base-component'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Modal = factory(global.EventHandler, global.Manipulator, global.SelectorEngine, global.Base)); -})(this, (function (EventHandler, Manipulator, SelectorEngine, BaseComponent) { 'use strict'; + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./util/index'), require('./dom/event-handler'), require('./dom/selector-engine'), require('./util/scrollbar'), require('./base-component'), require('./util/backdrop'), require('./util/focustrap'), require('./util/component-functions')) : + typeof define === 'function' && define.amd ? define(['./util/index', './dom/event-handler', './dom/selector-engine', './util/scrollbar', './base-component', './util/backdrop', './util/focustrap', './util/component-functions'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Modal = factory(global.Index, global.EventHandler, global.SelectorEngine, global.Scrollbar, global.BaseComponent, global.Backdrop, global.Focustrap, global.ComponentFunctions)); +})(this, (function (index, EventHandler, SelectorEngine, ScrollBarHelper, BaseComponent, Backdrop, FocusTrap, componentFunctions) { 'use strict'; const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e }; const EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler); - const Manipulator__default = /*#__PURE__*/_interopDefaultLegacy(Manipulator); const SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine); + const ScrollBarHelper__default = /*#__PURE__*/_interopDefaultLegacy(ScrollBarHelper); const BaseComponent__default = /*#__PURE__*/_interopDefaultLegacy(BaseComponent); + const Backdrop__default = /*#__PURE__*/_interopDefaultLegacy(Backdrop); + const FocusTrap__default = /*#__PURE__*/_interopDefaultLegacy(FocusTrap); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): util/index.js + * Bootstrap (v5.2.0): modal.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ - const MILLISECONDS_MULTIPLIER = 1000; - const TRANSITION_END = 'transitionend'; // Shoutout AngusCroll (https://goo.gl/pxwQGp) - - const toType = obj => { - if (obj === null || obj === undefined) { - return `${obj}`; - } - - return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase(); - }; - - const getSelector = element => { - let selector = element.getAttribute('data-bs-target'); - - if (!selector || selector === '#') { - let hrefAttr = element.getAttribute('href'); // The only valid content that could double as a selector are IDs or classes, - // so everything starting with `#` or `.`. If a "real" URL is used as the selector, - // `document.querySelector` will rightfully complain it is invalid. - // See https://github.com/twbs/bootstrap/issues/32273 - - if (!hrefAttr || !hrefAttr.includes('#') && !hrefAttr.startsWith('.')) { - return null; - } // Just in case some CMS puts out a full URL with the anchor appended - - - if (hrefAttr.includes('#') && !hrefAttr.startsWith('#')) { - hrefAttr = `#${hrefAttr.split('#')[1]}`; - } - - selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : null; - } - - return selector; - }; - - const getElementFromSelector = element => { - const selector = getSelector(element); - return selector ? document.querySelector(selector) : null; - }; - - const getTransitionDurationFromElement = element => { - if (!element) { - return 0; - } // Get transition-duration of the element - - - let { - transitionDuration, - transitionDelay - } = window.getComputedStyle(element); - const floatTransitionDuration = Number.parseFloat(transitionDuration); - const floatTransitionDelay = Number.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 (Number.parseFloat(transitionDuration) + Number.parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER; - }; - - const triggerTransitionEnd = element => { - element.dispatchEvent(new Event(TRANSITION_END)); - }; - - const isElement = obj => { - if (!obj || typeof obj !== 'object') { - return false; - } - - if (typeof obj.jquery !== 'undefined') { - obj = obj[0]; - } - - return typeof obj.nodeType !== 'undefined'; - }; - - const getElement = obj => { - if (isElement(obj)) { - // it's a jQuery object or a node element - return obj.jquery ? obj[0] : obj; - } - - if (typeof obj === 'string' && obj.length > 0) { - return document.querySelector(obj); - } - - return null; - }; - - const typeCheckConfig = (componentName, config, configTypes) => { - Object.keys(configTypes).forEach(property => { - const expectedTypes = configTypes[property]; - const value = config[property]; - const valueType = value && isElement(value) ? 'element' : toType(value); - - if (!new RegExp(expectedTypes).test(valueType)) { - throw new TypeError(`${componentName.toUpperCase()}: Option "${property}" provided type "${valueType}" but expected type "${expectedTypes}".`); - } - }); - }; - - const isVisible = element => { - if (!isElement(element) || element.getClientRects().length === 0) { - return false; - } - - return getComputedStyle(element).getPropertyValue('visibility') === 'visible'; - }; - - const isDisabled = element => { - if (!element || element.nodeType !== Node.ELEMENT_NODE) { - return true; - } - - if (element.classList.contains('disabled')) { - return true; - } - - if (typeof element.disabled !== 'undefined') { - return element.disabled; - } - - return element.hasAttribute('disabled') && element.getAttribute('disabled') !== 'false'; - }; /** - * Trick to restart an element's animation - * - * @param {HTMLElement} element - * @return void - * - * @see https://www.charistheo.io/blog/2021/02/restart-a-css-animation-with-javascript/#restarting-a-css-animation - */ - - - const reflow = element => { - // eslint-disable-next-line no-unused-expressions - element.offsetHeight; - }; - - const getjQuery = () => { - const { - jQuery - } = window; - - if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) { - return jQuery; - } - - return null; - }; - - const DOMContentLoadedCallbacks = []; - - const onDOMContentLoaded = callback => { - if (document.readyState === 'loading') { - // add listener on the first call when the document is in loading state - if (!DOMContentLoadedCallbacks.length) { - document.addEventListener('DOMContentLoaded', () => { - DOMContentLoadedCallbacks.forEach(callback => callback()); - }); - } - - DOMContentLoadedCallbacks.push(callback); - } else { - callback(); - } - }; - - const isRTL = () => document.documentElement.dir === 'rtl'; - - const defineJQueryPlugin = plugin => { - onDOMContentLoaded(() => { - const $ = getjQuery(); - /* istanbul ignore if */ - - if ($) { - const name = plugin.NAME; - const JQUERY_NO_CONFLICT = $.fn[name]; - $.fn[name] = plugin.jQueryInterface; - $.fn[name].Constructor = plugin; - - $.fn[name].noConflict = () => { - $.fn[name] = JQUERY_NO_CONFLICT; - return plugin.jQueryInterface; - }; - } - }); - }; - - const execute = callback => { - if (typeof callback === 'function') { - callback(); - } - }; - - const executeAfterTransition = (callback, transitionElement, waitForTransition = true) => { - if (!waitForTransition) { - execute(callback); - return; - } - - const durationPadding = 5; - const emulatedDuration = getTransitionDurationFromElement(transitionElement) + durationPadding; - let called = false; - - const handler = ({ - target - }) => { - if (target !== transitionElement) { - return; - } - - called = true; - transitionElement.removeEventListener(TRANSITION_END, handler); - execute(callback); - }; - - transitionElement.addEventListener(TRANSITION_END, handler); - setTimeout(() => { - if (!called) { - triggerTransitionEnd(transitionElement); - } - }, emulatedDuration); - }; - - /** - * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): util/scrollBar.js - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) - * -------------------------------------------------------------------------- - */ - const SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top'; - const SELECTOR_STICKY_CONTENT = '.sticky-top'; - - class ScrollBarHelper { - constructor() { - this._element = document.body; - } - - getWidth() { - // https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes - const documentWidth = document.documentElement.clientWidth; - return Math.abs(window.innerWidth - documentWidth); - } - - hide() { - const width = this.getWidth(); - - this._disableOverFlow(); // give padding to element to balance the hidden scrollbar width - - - this._setElementAttributes(this._element, 'paddingRight', calculatedValue => calculatedValue + width); // trick: We adjust positive paddingRight and negative marginRight to sticky-top elements to keep showing fullwidth - - - this._setElementAttributes(SELECTOR_FIXED_CONTENT, 'paddingRight', calculatedValue => calculatedValue + width); - - this._setElementAttributes(SELECTOR_STICKY_CONTENT, 'marginRight', calculatedValue => calculatedValue - width); - } - - _disableOverFlow() { - this._saveInitialAttribute(this._element, 'overflow'); - - this._element.style.overflow = 'hidden'; - } - - _setElementAttributes(selector, styleProp, callback) { - const scrollbarWidth = this.getWidth(); - - const manipulationCallBack = element => { - if (element !== this._element && window.innerWidth > element.clientWidth + scrollbarWidth) { - return; - } - - this._saveInitialAttribute(element, styleProp); - - const calculatedValue = window.getComputedStyle(element)[styleProp]; - element.style[styleProp] = `${callback(Number.parseFloat(calculatedValue))}px`; - }; - - this._applyManipulationCallback(selector, manipulationCallBack); - } - - reset() { - this._resetElementAttributes(this._element, 'overflow'); - - this._resetElementAttributes(this._element, 'paddingRight'); - - this._resetElementAttributes(SELECTOR_FIXED_CONTENT, 'paddingRight'); - - this._resetElementAttributes(SELECTOR_STICKY_CONTENT, 'marginRight'); - } - - _saveInitialAttribute(element, styleProp) { - const actualValue = element.style[styleProp]; - - if (actualValue) { - Manipulator__default.default.setDataAttribute(element, styleProp, actualValue); - } - } - - _resetElementAttributes(selector, styleProp) { - const manipulationCallBack = element => { - const value = Manipulator__default.default.getDataAttribute(element, styleProp); - - if (typeof value === 'undefined') { - element.style.removeProperty(styleProp); - } else { - Manipulator__default.default.removeDataAttribute(element, styleProp); - element.style[styleProp] = value; - } - }; - - this._applyManipulationCallback(selector, manipulationCallBack); - } - - _applyManipulationCallback(selector, callBack) { - if (isElement(selector)) { - callBack(selector); - } else { - SelectorEngine__default.default.find(selector, this._element).forEach(callBack); - } - } - - isOverflowing() { - return this.getWidth() > 0; - } - - } - - /** - * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): util/backdrop.js - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) - * -------------------------------------------------------------------------- - */ - const Default$2 = { - className: 'modal-backdrop', - isVisible: true, - // if false, we use the backdrop helper without adding any element to the dom - isAnimated: false, - rootElement: 'body', - // give the choice to place backdrop under different elements - clickCallback: null - }; - const DefaultType$2 = { - className: 'string', - isVisible: 'boolean', - isAnimated: 'boolean', - rootElement: '(element|string)', - clickCallback: '(function|null)' - }; - const NAME$2 = 'backdrop'; - const CLASS_NAME_FADE$1 = 'fade'; - const CLASS_NAME_SHOW$1 = 'show'; - const EVENT_MOUSEDOWN = `mousedown.bs.${NAME$2}`; - - class Backdrop { - constructor(config) { - this._config = this._getConfig(config); - this._isAppended = false; - this._element = null; - } - - show(callback) { - if (!this._config.isVisible) { - execute(callback); - return; - } - - this._append(); - - if (this._config.isAnimated) { - reflow(this._getElement()); - } - - this._getElement().classList.add(CLASS_NAME_SHOW$1); - - this._emulateAnimation(() => { - execute(callback); - }); - } - - hide(callback) { - if (!this._config.isVisible) { - execute(callback); - return; - } - - this._getElement().classList.remove(CLASS_NAME_SHOW$1); - - this._emulateAnimation(() => { - this.dispose(); - execute(callback); - }); - } // Private - - - _getElement() { - if (!this._element) { - const backdrop = document.createElement('div'); - backdrop.className = this._config.className; - - if (this._config.isAnimated) { - backdrop.classList.add(CLASS_NAME_FADE$1); - } - - this._element = backdrop; - } - - return this._element; - } - - _getConfig(config) { - config = { ...Default$2, - ...(typeof config === 'object' ? config : {}) - }; // use getElement() with the default "body" to get a fresh Element on each instantiation - - config.rootElement = getElement(config.rootElement); - typeCheckConfig(NAME$2, config, DefaultType$2); - return config; - } - - _append() { - if (this._isAppended) { - return; - } - - this._config.rootElement.append(this._getElement()); - - EventHandler__default.default.on(this._getElement(), EVENT_MOUSEDOWN, () => { - execute(this._config.clickCallback); - }); - this._isAppended = true; - } - - dispose() { - if (!this._isAppended) { - return; - } - - EventHandler__default.default.off(this._element, EVENT_MOUSEDOWN); - - this._element.remove(); - - this._isAppended = false; - } - - _emulateAnimation(callback) { - executeAfterTransition(callback, this._getElement(), this._config.isAnimated); - } - - } - - /** - * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): util/focustrap.js - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) - * -------------------------------------------------------------------------- - */ - const Default$1 = { - trapElement: null, - // The element to trap focus inside of - autofocus: true - }; - const DefaultType$1 = { - trapElement: 'element', - autofocus: 'boolean' - }; - const NAME$1 = 'focustrap'; - const DATA_KEY$1 = 'bs.focustrap'; - const EVENT_KEY$1 = `.${DATA_KEY$1}`; - const EVENT_FOCUSIN = `focusin${EVENT_KEY$1}`; - const EVENT_KEYDOWN_TAB = `keydown.tab${EVENT_KEY$1}`; - const TAB_KEY = 'Tab'; - const TAB_NAV_FORWARD = 'forward'; - const TAB_NAV_BACKWARD = 'backward'; - - class FocusTrap { - constructor(config) { - this._config = this._getConfig(config); - this._isActive = false; - this._lastTabNavDirection = null; - } - - activate() { - const { - trapElement, - autofocus - } = this._config; - - if (this._isActive) { - return; - } - - if (autofocus) { - trapElement.focus(); - } - - EventHandler__default.default.off(document, EVENT_KEY$1); // guard against infinite focus loop - - EventHandler__default.default.on(document, EVENT_FOCUSIN, event => this._handleFocusin(event)); - EventHandler__default.default.on(document, EVENT_KEYDOWN_TAB, event => this._handleKeydown(event)); - this._isActive = true; - } - - deactivate() { - if (!this._isActive) { - return; - } - - this._isActive = false; - EventHandler__default.default.off(document, EVENT_KEY$1); - } // Private - - - _handleFocusin(event) { - const { - target - } = event; - const { - trapElement - } = this._config; - - if (target === document || target === trapElement || trapElement.contains(target)) { - return; - } - - const elements = SelectorEngine__default.default.focusableChildren(trapElement); - - if (elements.length === 0) { - trapElement.focus(); - } else if (this._lastTabNavDirection === TAB_NAV_BACKWARD) { - elements[elements.length - 1].focus(); - } else { - elements[0].focus(); - } - } - - _handleKeydown(event) { - if (event.key !== TAB_KEY) { - return; - } - - this._lastTabNavDirection = event.shiftKey ? TAB_NAV_BACKWARD : TAB_NAV_FORWARD; - } - - _getConfig(config) { - config = { ...Default$1, - ...(typeof config === 'object' ? config : {}) - }; - typeCheckConfig(NAME$1, config, DefaultType$1); - return config; - } - - } - - /** - * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): util/component-functions.js - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) - * -------------------------------------------------------------------------- - */ - - const enableDismissTrigger = (component, method = 'hide') => { - const clickEvent = `click.dismiss${component.EVENT_KEY}`; - const name = component.NAME; - EventHandler__default.default.on(document, clickEvent, `[data-bs-dismiss="${name}"]`, function (event) { - if (['A', 'AREA'].includes(this.tagName)) { - event.preventDefault(); - } - - if (isDisabled(this)) { - return; - } - - const target = getElementFromSelector(this) || this.closest(`.${name}`); - const instance = component.getOrCreateInstance(target); // Method argument is left, for Alert and only, as it doesn't implement the 'hide' method - - instance[method](); - }); - }; - - /** - * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): modal.js - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) - * -------------------------------------------------------------------------- - */ - /** - * ------------------------------------------------------------------------ * Constants - * ------------------------------------------------------------------------ */ const NAME = 'modal'; @@ -624,26 +33,14 @@ const EVENT_KEY = `.${DATA_KEY}`; const DATA_API_KEY = '.data-api'; const ESCAPE_KEY = 'Escape'; - const Default = { - backdrop: true, - keyboard: true, - focus: true - }; - const DefaultType = { - backdrop: '(boolean|string)', - keyboard: 'boolean', - focus: 'boolean' - }; const EVENT_HIDE = `hide${EVENT_KEY}`; const EVENT_HIDE_PREVENTED = `hidePrevented${EVENT_KEY}`; const EVENT_HIDDEN = `hidden${EVENT_KEY}`; const EVENT_SHOW = `show${EVENT_KEY}`; const EVENT_SHOWN = `shown${EVENT_KEY}`; const EVENT_RESIZE = `resize${EVENT_KEY}`; - const EVENT_CLICK_DISMISS = `click.dismiss${EVENT_KEY}`; - const EVENT_KEYDOWN_DISMISS = `keydown.dismiss${EVENT_KEY}`; - const EVENT_MOUSEUP_DISMISS = `mouseup.dismiss${EVENT_KEY}`; const EVENT_MOUSEDOWN_DISMISS = `mousedown.dismiss${EVENT_KEY}`; + const EVENT_KEYDOWN_DISMISS = `keydown.dismiss${EVENT_KEY}`; const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`; const CLASS_NAME_OPEN = 'modal-open'; const CLASS_NAME_FADE = 'fade'; @@ -653,23 +50,31 @@ const SELECTOR_DIALOG = '.modal-dialog'; const SELECTOR_MODAL_BODY = '.modal-body'; const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="modal"]'; + const Default = { + backdrop: true, + focus: true, + keyboard: true + }; + const DefaultType = { + backdrop: '(boolean|string)', + focus: 'boolean', + keyboard: 'boolean' + }; /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ + * Class definition */ class Modal extends BaseComponent__default.default { constructor(element, config) { - super(element); - this._config = this._getConfig(config); + super(element, config); this._dialog = SelectorEngine__default.default.findOne(SELECTOR_DIALOG, this._element); this._backdrop = this._initializeBackDrop(); this._focustrap = this._initializeFocusTrap(); this._isShown = false; - this._ignoreBackdropClick = false; this._isTransitioning = false; - this._scrollBar = new ScrollBarHelper(); + this._scrollBar = new ScrollBarHelper__default.default(); + + this._addEventListeners(); } // Getters @@ -677,6 +82,10 @@ return Default; } + static get DefaultType() { + return DefaultType; + } + static get NAME() { return NAME; } // Public @@ -700,10 +109,7 @@ } this._isShown = true; - - if (this._isAnimated()) { - this._isTransitioning = true; - } + this._isTransitioning = true; this._scrollBar.hide(); @@ -711,19 +117,7 @@ this._adjustDialog(); - this._setEscapeEvent(); - - this._setResizeEvent(); - - EventHandler__default.default.on(this._dialog, EVENT_MOUSEDOWN_DISMISS, () => { - EventHandler__default.default.one(this._element, EVENT_MOUSEUP_DISMISS, event => { - if (event.target === this._element) { - this._ignoreBackdropClick = true; - } - }); - }); - - this._showBackdrop(() => this._showElement(relatedTarget)); + this._backdrop.show(() => this._showElement(relatedTarget)); } hide() { @@ -738,29 +132,19 @@ } this._isShown = false; - - const isAnimated = this._isAnimated(); - - if (isAnimated) { - this._isTransitioning = true; - } - - this._setEscapeEvent(); - - this._setResizeEvent(); + this._isTransitioning = true; this._focustrap.deactivate(); this._element.classList.remove(CLASS_NAME_SHOW); - EventHandler__default.default.off(this._element, EVENT_CLICK_DISMISS); - EventHandler__default.default.off(this._dialog, EVENT_MOUSEDOWN_DISMISS); - - this._queueCallback(() => this._hideModal(), this._element, isAnimated); + this._queueCallback(() => this._hideModal(), this._element, this._isAnimated()); } dispose() { - [window, this._dialog].forEach(htmlElement => EventHandler__default.default.off(htmlElement, EVENT_KEY)); + for (const htmlElement of [window, this._dialog]) { + EventHandler__default.default.off(htmlElement, EVENT_KEY); + } this._backdrop.dispose(); @@ -775,35 +159,22 @@ _initializeBackDrop() { - return new Backdrop({ + return new Backdrop__default.default({ isVisible: Boolean(this._config.backdrop), - // 'static' option will be translated to true, and booleans will keep their value + // 'static' option will be translated to true, and booleans will keep their value, isAnimated: this._isAnimated() }); } _initializeFocusTrap() { - return new FocusTrap({ + return new FocusTrap__default.default({ trapElement: this._element }); } - _getConfig(config) { - config = { ...Default, - ...Manipulator__default.default.getDataAttributes(this._element), - ...(typeof config === 'object' ? config : {}) - }; - typeCheckConfig(NAME, config, DefaultType); - return config; - } - _showElement(relatedTarget) { - const isAnimated = this._isAnimated(); - - const modalBody = SelectorEngine__default.default.findOne(SELECTOR_MODAL_BODY, this._dialog); - - if (!this._element.parentNode || this._element.parentNode.nodeType !== Node.ELEMENT_NODE) { - // Don't move modal's DOM position + // try to append dynamic modal + if (!document.body.contains(this._element)) { document.body.append(this._element); } @@ -816,14 +187,13 @@ this._element.setAttribute('role', 'dialog'); this._element.scrollTop = 0; + const modalBody = SelectorEngine__default.default.findOne(SELECTOR_MODAL_BODY, this._dialog); if (modalBody) { modalBody.scrollTop = 0; } - if (isAnimated) { - reflow(this._element); - } + index.reflow(this._element); this._element.classList.add(CLASS_NAME_SHOW); @@ -838,30 +208,44 @@ }); }; - this._queueCallback(transitionComplete, this._dialog, isAnimated); + this._queueCallback(transitionComplete, this._dialog, this._isAnimated()); } - _setEscapeEvent() { - if (this._isShown) { - EventHandler__default.default.on(this._element, EVENT_KEYDOWN_DISMISS, event => { - if (this._config.keyboard && event.key === ESCAPE_KEY) { - event.preventDefault(); - this.hide(); - } else if (!this._config.keyboard && event.key === ESCAPE_KEY) { - this._triggerBackdropTransition(); - } - }); - } else { - EventHandler__default.default.off(this._element, EVENT_KEYDOWN_DISMISS); - } - } + _addEventListeners() { + EventHandler__default.default.on(this._element, EVENT_KEYDOWN_DISMISS, event => { + if (event.key !== ESCAPE_KEY) { + return; + } - _setResizeEvent() { - if (this._isShown) { - EventHandler__default.default.on(window, EVENT_RESIZE, () => this._adjustDialog()); - } else { - EventHandler__default.default.off(window, EVENT_RESIZE); - } + if (this._config.keyboard) { + event.preventDefault(); + this.hide(); + return; + } + + this._triggerBackdropTransition(); + }); + EventHandler__default.default.on(window, EVENT_RESIZE, () => { + if (this._isShown && !this._isTransitioning) { + this._adjustDialog(); + } + }); + EventHandler__default.default.on(this._element, EVENT_MOUSEDOWN_DISMISS, event => { + if (event.target !== event.currentTarget) { + // click is inside modal-dialog + return; + } + + if (this._config.backdrop === 'static') { + this._triggerBackdropTransition(); + + return; + } + + if (this._config.backdrop) { + this.hide(); + } + }); } _hideModal() { @@ -886,27 +270,6 @@ }); } - _showBackdrop(callback) { - EventHandler__default.default.on(this._element, EVENT_CLICK_DISMISS, event => { - if (this._ignoreBackdropClick) { - this._ignoreBackdropClick = false; - return; - } - - if (event.target !== event.currentTarget) { - return; - } - - if (this._config.backdrop === true) { - this.hide(); - } else if (this._config.backdrop === 'static') { - this._triggerBackdropTransition(); - } - }); - - this._backdrop.show(callback); - } - _isAnimated() { return this._element.classList.contains(CLASS_NAME_FADE); } @@ -918,37 +281,32 @@ return; } - const { - classList, - scrollHeight, - style - } = this._element; - const isModalOverflowing = scrollHeight > document.documentElement.clientHeight; // return if the following background transition hasn't yet completed + const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight; + const initialOverflowY = this._element.style.overflowY; // return if the following background transition hasn't yet completed - if (!isModalOverflowing && style.overflowY === 'hidden' || classList.contains(CLASS_NAME_STATIC)) { + if (initialOverflowY === 'hidden' || this._element.classList.contains(CLASS_NAME_STATIC)) { return; } if (!isModalOverflowing) { - style.overflowY = 'hidden'; + this._element.style.overflowY = 'hidden'; } - classList.add(CLASS_NAME_STATIC); + this._element.classList.add(CLASS_NAME_STATIC); this._queueCallback(() => { - classList.remove(CLASS_NAME_STATIC); + this._element.classList.remove(CLASS_NAME_STATIC); - if (!isModalOverflowing) { - this._queueCallback(() => { - style.overflowY = ''; - }, this._dialog); - } + this._queueCallback(() => { + this._element.style.overflowY = initialOverflowY; + }, this._dialog); }, this._dialog); this._element.focus(); - } // ---------------------------------------------------------------------- - // the following methods are used to handle overflowing modals - // ---------------------------------------------------------------------- + } + /** + * The following methods are used to handle overflowing modals + */ _adjustDialog() { @@ -958,12 +316,14 @@ const isBodyOverflowing = scrollbarWidth > 0; - if (!isBodyOverflowing && isModalOverflowing && !isRTL() || isBodyOverflowing && !isModalOverflowing && isRTL()) { - this._element.style.paddingLeft = `${scrollbarWidth}px`; + if (isBodyOverflowing && !isModalOverflowing) { + const property = index.isRTL() ? 'paddingLeft' : 'paddingRight'; + this._element.style[property] = `${scrollbarWidth}px`; } - if (isBodyOverflowing && !isModalOverflowing && !isRTL() || !isBodyOverflowing && isModalOverflowing && isRTL()) { - this._element.style.paddingRight = `${scrollbarWidth}px`; + if (!isBodyOverflowing && isModalOverflowing) { + const property = index.isRTL() ? 'paddingRight' : 'paddingLeft'; + this._element.style[property] = `${scrollbarWidth}px`; } } @@ -991,14 +351,12 @@ } /** - * ------------------------------------------------------------------------ - * Data Api implementation - * ------------------------------------------------------------------------ + * Data API implementation */ EventHandler__default.default.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) { - const target = getElementFromSelector(this); + const target = index.getElementFromSelector(this); if (['A', 'AREA'].includes(this.tagName)) { event.preventDefault(); @@ -1011,30 +369,27 @@ } EventHandler__default.default.one(target, EVENT_HIDDEN, () => { - if (isVisible(this)) { + if (index.isVisible(this)) { this.focus(); } }); - }); // avoid conflict when clicking moddal toggler while another one is open + }); // avoid conflict when clicking modal toggler while another one is open - const allReadyOpen = SelectorEngine__default.default.findOne(OPEN_SELECTOR); + const alreadyOpen = SelectorEngine__default.default.findOne(OPEN_SELECTOR); - if (allReadyOpen) { - Modal.getInstance(allReadyOpen).hide(); + if (alreadyOpen) { + Modal.getInstance(alreadyOpen).hide(); } const data = Modal.getOrCreateInstance(target); data.toggle(this); }); - enableDismissTrigger(Modal); + componentFunctions.enableDismissTrigger(Modal); /** - * ------------------------------------------------------------------------ * jQuery - * ------------------------------------------------------------------------ - * add .Modal to jQuery only if jQuery is present */ - defineJQueryPlugin(Modal); + index.defineJQueryPlugin(Modal); return Modal; diff --git a/assets/javascripts/bootstrap/offcanvas.js b/assets/javascripts/bootstrap/offcanvas.js index 4dc30ac..f8f3864 100644 --- a/assets/javascripts/bootstrap/offcanvas.js +++ b/assets/javascripts/bootstrap/offcanvas.js @@ -1,620 +1,31 @@ /*! - * Bootstrap offcanvas.js v5.1.3 (https://getbootstrap.com/) - * Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) + * Bootstrap offcanvas.js v5.2.0 (https://getbootstrap.com/) + * Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/selector-engine.js'), require('./dom/manipulator.js'), require('./dom/event-handler.js'), require('./base-component.js')) : - typeof define === 'function' && define.amd ? define(['./dom/selector-engine', './dom/manipulator', './dom/event-handler', './base-component'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Offcanvas = factory(global.SelectorEngine, global.Manipulator, global.EventHandler, global.Base)); -})(this, (function (SelectorEngine, Manipulator, EventHandler, BaseComponent) { 'use strict'; + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./util/index'), require('./util/scrollbar'), require('./dom/event-handler'), require('./base-component'), require('./dom/selector-engine'), require('./util/backdrop'), require('./util/focustrap'), require('./util/component-functions')) : + typeof define === 'function' && define.amd ? define(['./util/index', './util/scrollbar', './dom/event-handler', './base-component', './dom/selector-engine', './util/backdrop', './util/focustrap', './util/component-functions'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Offcanvas = factory(global.Index, global.Scrollbar, global.EventHandler, global.BaseComponent, global.SelectorEngine, global.Backdrop, global.Focustrap, global.ComponentFunctions)); +})(this, (function (index, ScrollBarHelper, EventHandler, BaseComponent, SelectorEngine, Backdrop, FocusTrap, componentFunctions) { 'use strict'; const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e }; - const SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine); - const Manipulator__default = /*#__PURE__*/_interopDefaultLegacy(Manipulator); + const ScrollBarHelper__default = /*#__PURE__*/_interopDefaultLegacy(ScrollBarHelper); const EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler); const BaseComponent__default = /*#__PURE__*/_interopDefaultLegacy(BaseComponent); + const SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine); + const Backdrop__default = /*#__PURE__*/_interopDefaultLegacy(Backdrop); + const FocusTrap__default = /*#__PURE__*/_interopDefaultLegacy(FocusTrap); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): util/index.js - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) - * -------------------------------------------------------------------------- - */ - const MILLISECONDS_MULTIPLIER = 1000; - const TRANSITION_END = 'transitionend'; // Shoutout AngusCroll (https://goo.gl/pxwQGp) - - const toType = obj => { - if (obj === null || obj === undefined) { - return `${obj}`; - } - - return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase(); - }; - - const getSelector = element => { - let selector = element.getAttribute('data-bs-target'); - - if (!selector || selector === '#') { - let hrefAttr = element.getAttribute('href'); // The only valid content that could double as a selector are IDs or classes, - // so everything starting with `#` or `.`. If a "real" URL is used as the selector, - // `document.querySelector` will rightfully complain it is invalid. - // See https://github.com/twbs/bootstrap/issues/32273 - - if (!hrefAttr || !hrefAttr.includes('#') && !hrefAttr.startsWith('.')) { - return null; - } // Just in case some CMS puts out a full URL with the anchor appended - - - if (hrefAttr.includes('#') && !hrefAttr.startsWith('#')) { - hrefAttr = `#${hrefAttr.split('#')[1]}`; - } - - selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : null; - } - - return selector; - }; - - const getElementFromSelector = element => { - const selector = getSelector(element); - return selector ? document.querySelector(selector) : null; - }; - - const getTransitionDurationFromElement = element => { - if (!element) { - return 0; - } // Get transition-duration of the element - - - let { - transitionDuration, - transitionDelay - } = window.getComputedStyle(element); - const floatTransitionDuration = Number.parseFloat(transitionDuration); - const floatTransitionDelay = Number.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 (Number.parseFloat(transitionDuration) + Number.parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER; - }; - - const triggerTransitionEnd = element => { - element.dispatchEvent(new Event(TRANSITION_END)); - }; - - const isElement = obj => { - if (!obj || typeof obj !== 'object') { - return false; - } - - if (typeof obj.jquery !== 'undefined') { - obj = obj[0]; - } - - return typeof obj.nodeType !== 'undefined'; - }; - - const getElement = obj => { - if (isElement(obj)) { - // it's a jQuery object or a node element - return obj.jquery ? obj[0] : obj; - } - - if (typeof obj === 'string' && obj.length > 0) { - return document.querySelector(obj); - } - - return null; - }; - - const typeCheckConfig = (componentName, config, configTypes) => { - Object.keys(configTypes).forEach(property => { - const expectedTypes = configTypes[property]; - const value = config[property]; - const valueType = value && isElement(value) ? 'element' : toType(value); - - if (!new RegExp(expectedTypes).test(valueType)) { - throw new TypeError(`${componentName.toUpperCase()}: Option "${property}" provided type "${valueType}" but expected type "${expectedTypes}".`); - } - }); - }; - - const isVisible = element => { - if (!isElement(element) || element.getClientRects().length === 0) { - return false; - } - - return getComputedStyle(element).getPropertyValue('visibility') === 'visible'; - }; - - const isDisabled = element => { - if (!element || element.nodeType !== Node.ELEMENT_NODE) { - return true; - } - - if (element.classList.contains('disabled')) { - return true; - } - - if (typeof element.disabled !== 'undefined') { - return element.disabled; - } - - return element.hasAttribute('disabled') && element.getAttribute('disabled') !== 'false'; - }; - /** - * Trick to restart an element's animation - * - * @param {HTMLElement} element - * @return void - * - * @see https://www.charistheo.io/blog/2021/02/restart-a-css-animation-with-javascript/#restarting-a-css-animation - */ - - - const reflow = element => { - // eslint-disable-next-line no-unused-expressions - element.offsetHeight; - }; - - const getjQuery = () => { - const { - jQuery - } = window; - - if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) { - return jQuery; - } - - return null; - }; - - const DOMContentLoadedCallbacks = []; - - const onDOMContentLoaded = callback => { - if (document.readyState === 'loading') { - // add listener on the first call when the document is in loading state - if (!DOMContentLoadedCallbacks.length) { - document.addEventListener('DOMContentLoaded', () => { - DOMContentLoadedCallbacks.forEach(callback => callback()); - }); - } - - DOMContentLoadedCallbacks.push(callback); - } else { - callback(); - } - }; - - const defineJQueryPlugin = plugin => { - onDOMContentLoaded(() => { - const $ = getjQuery(); - /* istanbul ignore if */ - - if ($) { - const name = plugin.NAME; - const JQUERY_NO_CONFLICT = $.fn[name]; - $.fn[name] = plugin.jQueryInterface; - $.fn[name].Constructor = plugin; - - $.fn[name].noConflict = () => { - $.fn[name] = JQUERY_NO_CONFLICT; - return plugin.jQueryInterface; - }; - } - }); - }; - - const execute = callback => { - if (typeof callback === 'function') { - callback(); - } - }; - - const executeAfterTransition = (callback, transitionElement, waitForTransition = true) => { - if (!waitForTransition) { - execute(callback); - return; - } - - const durationPadding = 5; - const emulatedDuration = getTransitionDurationFromElement(transitionElement) + durationPadding; - let called = false; - - const handler = ({ - target - }) => { - if (target !== transitionElement) { - return; - } - - called = true; - transitionElement.removeEventListener(TRANSITION_END, handler); - execute(callback); - }; - - transitionElement.addEventListener(TRANSITION_END, handler); - setTimeout(() => { - if (!called) { - triggerTransitionEnd(transitionElement); - } - }, emulatedDuration); - }; - - /** - * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): util/scrollBar.js - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) - * -------------------------------------------------------------------------- - */ - const SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top'; - const SELECTOR_STICKY_CONTENT = '.sticky-top'; - - class ScrollBarHelper { - constructor() { - this._element = document.body; - } - - getWidth() { - // https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes - const documentWidth = document.documentElement.clientWidth; - return Math.abs(window.innerWidth - documentWidth); - } - - hide() { - const width = this.getWidth(); - - this._disableOverFlow(); // give padding to element to balance the hidden scrollbar width - - - this._setElementAttributes(this._element, 'paddingRight', calculatedValue => calculatedValue + width); // trick: We adjust positive paddingRight and negative marginRight to sticky-top elements to keep showing fullwidth - - - this._setElementAttributes(SELECTOR_FIXED_CONTENT, 'paddingRight', calculatedValue => calculatedValue + width); - - this._setElementAttributes(SELECTOR_STICKY_CONTENT, 'marginRight', calculatedValue => calculatedValue - width); - } - - _disableOverFlow() { - this._saveInitialAttribute(this._element, 'overflow'); - - this._element.style.overflow = 'hidden'; - } - - _setElementAttributes(selector, styleProp, callback) { - const scrollbarWidth = this.getWidth(); - - const manipulationCallBack = element => { - if (element !== this._element && window.innerWidth > element.clientWidth + scrollbarWidth) { - return; - } - - this._saveInitialAttribute(element, styleProp); - - const calculatedValue = window.getComputedStyle(element)[styleProp]; - element.style[styleProp] = `${callback(Number.parseFloat(calculatedValue))}px`; - }; - - this._applyManipulationCallback(selector, manipulationCallBack); - } - - reset() { - this._resetElementAttributes(this._element, 'overflow'); - - this._resetElementAttributes(this._element, 'paddingRight'); - - this._resetElementAttributes(SELECTOR_FIXED_CONTENT, 'paddingRight'); - - this._resetElementAttributes(SELECTOR_STICKY_CONTENT, 'marginRight'); - } - - _saveInitialAttribute(element, styleProp) { - const actualValue = element.style[styleProp]; - - if (actualValue) { - Manipulator__default.default.setDataAttribute(element, styleProp, actualValue); - } - } - - _resetElementAttributes(selector, styleProp) { - const manipulationCallBack = element => { - const value = Manipulator__default.default.getDataAttribute(element, styleProp); - - if (typeof value === 'undefined') { - element.style.removeProperty(styleProp); - } else { - Manipulator__default.default.removeDataAttribute(element, styleProp); - element.style[styleProp] = value; - } - }; - - this._applyManipulationCallback(selector, manipulationCallBack); - } - - _applyManipulationCallback(selector, callBack) { - if (isElement(selector)) { - callBack(selector); - } else { - SelectorEngine__default.default.find(selector, this._element).forEach(callBack); - } - } - - isOverflowing() { - return this.getWidth() > 0; - } - - } - - /** - * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): util/backdrop.js - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) - * -------------------------------------------------------------------------- - */ - const Default$2 = { - className: 'modal-backdrop', - isVisible: true, - // if false, we use the backdrop helper without adding any element to the dom - isAnimated: false, - rootElement: 'body', - // give the choice to place backdrop under different elements - clickCallback: null - }; - const DefaultType$2 = { - className: 'string', - isVisible: 'boolean', - isAnimated: 'boolean', - rootElement: '(element|string)', - clickCallback: '(function|null)' - }; - const NAME$2 = 'backdrop'; - const CLASS_NAME_FADE = 'fade'; - const CLASS_NAME_SHOW$1 = 'show'; - const EVENT_MOUSEDOWN = `mousedown.bs.${NAME$2}`; - - class Backdrop { - constructor(config) { - this._config = this._getConfig(config); - this._isAppended = false; - this._element = null; - } - - show(callback) { - if (!this._config.isVisible) { - execute(callback); - return; - } - - this._append(); - - if (this._config.isAnimated) { - reflow(this._getElement()); - } - - this._getElement().classList.add(CLASS_NAME_SHOW$1); - - this._emulateAnimation(() => { - execute(callback); - }); - } - - hide(callback) { - if (!this._config.isVisible) { - execute(callback); - return; - } - - this._getElement().classList.remove(CLASS_NAME_SHOW$1); - - this._emulateAnimation(() => { - this.dispose(); - execute(callback); - }); - } // Private - - - _getElement() { - if (!this._element) { - const backdrop = document.createElement('div'); - backdrop.className = this._config.className; - - if (this._config.isAnimated) { - backdrop.classList.add(CLASS_NAME_FADE); - } - - this._element = backdrop; - } - - return this._element; - } - - _getConfig(config) { - config = { ...Default$2, - ...(typeof config === 'object' ? config : {}) - }; // use getElement() with the default "body" to get a fresh Element on each instantiation - - config.rootElement = getElement(config.rootElement); - typeCheckConfig(NAME$2, config, DefaultType$2); - return config; - } - - _append() { - if (this._isAppended) { - return; - } - - this._config.rootElement.append(this._getElement()); - - EventHandler__default.default.on(this._getElement(), EVENT_MOUSEDOWN, () => { - execute(this._config.clickCallback); - }); - this._isAppended = true; - } - - dispose() { - if (!this._isAppended) { - return; - } - - EventHandler__default.default.off(this._element, EVENT_MOUSEDOWN); - - this._element.remove(); - - this._isAppended = false; - } - - _emulateAnimation(callback) { - executeAfterTransition(callback, this._getElement(), this._config.isAnimated); - } - - } - - /** - * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): util/focustrap.js - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) - * -------------------------------------------------------------------------- - */ - const Default$1 = { - trapElement: null, - // The element to trap focus inside of - autofocus: true - }; - const DefaultType$1 = { - trapElement: 'element', - autofocus: 'boolean' - }; - const NAME$1 = 'focustrap'; - const DATA_KEY$1 = 'bs.focustrap'; - const EVENT_KEY$1 = `.${DATA_KEY$1}`; - const EVENT_FOCUSIN = `focusin${EVENT_KEY$1}`; - const EVENT_KEYDOWN_TAB = `keydown.tab${EVENT_KEY$1}`; - const TAB_KEY = 'Tab'; - const TAB_NAV_FORWARD = 'forward'; - const TAB_NAV_BACKWARD = 'backward'; - - class FocusTrap { - constructor(config) { - this._config = this._getConfig(config); - this._isActive = false; - this._lastTabNavDirection = null; - } - - activate() { - const { - trapElement, - autofocus - } = this._config; - - if (this._isActive) { - return; - } - - if (autofocus) { - trapElement.focus(); - } - - EventHandler__default.default.off(document, EVENT_KEY$1); // guard against infinite focus loop - - EventHandler__default.default.on(document, EVENT_FOCUSIN, event => this._handleFocusin(event)); - EventHandler__default.default.on(document, EVENT_KEYDOWN_TAB, event => this._handleKeydown(event)); - this._isActive = true; - } - - deactivate() { - if (!this._isActive) { - return; - } - - this._isActive = false; - EventHandler__default.default.off(document, EVENT_KEY$1); - } // Private - - - _handleFocusin(event) { - const { - target - } = event; - const { - trapElement - } = this._config; - - if (target === document || target === trapElement || trapElement.contains(target)) { - return; - } - - const elements = SelectorEngine__default.default.focusableChildren(trapElement); - - if (elements.length === 0) { - trapElement.focus(); - } else if (this._lastTabNavDirection === TAB_NAV_BACKWARD) { - elements[elements.length - 1].focus(); - } else { - elements[0].focus(); - } - } - - _handleKeydown(event) { - if (event.key !== TAB_KEY) { - return; - } - - this._lastTabNavDirection = event.shiftKey ? TAB_NAV_BACKWARD : TAB_NAV_FORWARD; - } - - _getConfig(config) { - config = { ...Default$1, - ...(typeof config === 'object' ? config : {}) - }; - typeCheckConfig(NAME$1, config, DefaultType$1); - return config; - } - - } - - /** - * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): util/component-functions.js - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) - * -------------------------------------------------------------------------- - */ - - const enableDismissTrigger = (component, method = 'hide') => { - const clickEvent = `click.dismiss${component.EVENT_KEY}`; - const name = component.NAME; - EventHandler__default.default.on(document, clickEvent, `[data-bs-dismiss="${name}"]`, function (event) { - if (['A', 'AREA'].includes(this.tagName)) { - event.preventDefault(); - } - - if (isDisabled(this)) { - return; - } - - const target = getElementFromSelector(this) || this.closest(`.${name}`); - const instance = component.getOrCreateInstance(target); // Method argument is left, for Alert and only, as it doesn't implement the 'hide' method - - instance[method](); - }); - }; - - /** - * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): offcanvas.js + * Bootstrap (v5.2.0): offcanvas.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** - * ------------------------------------------------------------------------ * Constants - * ------------------------------------------------------------------------ */ const NAME = 'offcanvas'; @@ -623,36 +34,37 @@ const DATA_API_KEY = '.data-api'; const EVENT_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}`; const ESCAPE_KEY = 'Escape'; - const Default = { - backdrop: true, - keyboard: true, - scroll: false - }; - const DefaultType = { - backdrop: 'boolean', - keyboard: 'boolean', - scroll: 'boolean' - }; const CLASS_NAME_SHOW = 'show'; + const CLASS_NAME_SHOWING = 'showing'; + const CLASS_NAME_HIDING = 'hiding'; const CLASS_NAME_BACKDROP = 'offcanvas-backdrop'; const OPEN_SELECTOR = '.offcanvas.show'; const EVENT_SHOW = `show${EVENT_KEY}`; const EVENT_SHOWN = `shown${EVENT_KEY}`; const EVENT_HIDE = `hide${EVENT_KEY}`; + const EVENT_HIDE_PREVENTED = `hidePrevented${EVENT_KEY}`; const EVENT_HIDDEN = `hidden${EVENT_KEY}`; + const EVENT_RESIZE = `resize${EVENT_KEY}`; const EVENT_CLICK_DATA_API = `click${EVENT_KEY}${DATA_API_KEY}`; const EVENT_KEYDOWN_DISMISS = `keydown.dismiss${EVENT_KEY}`; const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="offcanvas"]'; + const Default = { + backdrop: true, + keyboard: true, + scroll: false + }; + const DefaultType = { + backdrop: '(boolean|string)', + keyboard: 'boolean', + scroll: 'boolean' + }; /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ + * Class definition */ class Offcanvas extends BaseComponent__default.default { constructor(element, config) { - super(element); - this._config = this._getConfig(config); + super(element, config); this._isShown = false; this._backdrop = this._initializeBackDrop(); this._focustrap = this._initializeFocusTrap(); @@ -661,12 +73,16 @@ } // Getters - static get NAME() { - return NAME; - } - static get Default() { return Default; + } + + static get DefaultType() { + return DefaultType; + } + + static get NAME() { + return NAME; } // Public @@ -688,27 +104,28 @@ } this._isShown = true; - this._element.style.visibility = 'visible'; this._backdrop.show(); if (!this._config.scroll) { - new ScrollBarHelper().hide(); + new ScrollBarHelper__default.default().hide(); } - this._element.removeAttribute('aria-hidden'); - this._element.setAttribute('aria-modal', true); this._element.setAttribute('role', 'dialog'); - this._element.classList.add(CLASS_NAME_SHOW); + this._element.classList.add(CLASS_NAME_SHOWING); const completeCallBack = () => { - if (!this._config.scroll) { + if (!this._config.scroll || this._config.backdrop) { this._focustrap.activate(); } + this._element.classList.add(CLASS_NAME_SHOW); + + this._element.classList.remove(CLASS_NAME_SHOWING); + EventHandler__default.default.trigger(this._element, EVENT_SHOWN, { relatedTarget }); @@ -734,21 +151,19 @@ this._isShown = false; - this._element.classList.remove(CLASS_NAME_SHOW); + this._element.classList.add(CLASS_NAME_HIDING); this._backdrop.hide(); const completeCallback = () => { - this._element.setAttribute('aria-hidden', true); + this._element.classList.remove(CLASS_NAME_SHOW, CLASS_NAME_HIDING); this._element.removeAttribute('aria-modal'); this._element.removeAttribute('role'); - this._element.style.visibility = 'hidden'; - if (!this._config.scroll) { - new ScrollBarHelper().reset(); + new ScrollBarHelper__default.default().reset(); } EventHandler__default.default.trigger(this._element, EVENT_HIDDEN); @@ -766,36 +181,45 @@ } // Private - _getConfig(config) { - config = { ...Default, - ...Manipulator__default.default.getDataAttributes(this._element), - ...(typeof config === 'object' ? config : {}) - }; - typeCheckConfig(NAME, config, DefaultType); - return config; - } - _initializeBackDrop() { - return new Backdrop({ + const clickCallback = () => { + if (this._config.backdrop === 'static') { + EventHandler__default.default.trigger(this._element, EVENT_HIDE_PREVENTED); + return; + } + + this.hide(); + }; // 'static' option will be translated to true, and booleans will keep their value + + + const isVisible = Boolean(this._config.backdrop); + return new Backdrop__default.default({ className: CLASS_NAME_BACKDROP, - isVisible: this._config.backdrop, + isVisible, isAnimated: true, rootElement: this._element.parentNode, - clickCallback: () => this.hide() + clickCallback: isVisible ? clickCallback : null }); } _initializeFocusTrap() { - return new FocusTrap({ + return new FocusTrap__default.default({ trapElement: this._element }); } _addEventListeners() { EventHandler__default.default.on(this._element, EVENT_KEYDOWN_DISMISS, event => { - if (this._config.keyboard && event.key === ESCAPE_KEY) { - this.hide(); + if (event.key !== ESCAPE_KEY) { + return; } + + if (!this._config.keyboard) { + EventHandler__default.default.trigger(this._element, EVENT_HIDE_PREVENTED); + return; + } + + this.hide(); }); } // Static @@ -818,48 +242,55 @@ } /** - * ------------------------------------------------------------------------ - * Data Api implementation - * ------------------------------------------------------------------------ + * Data API implementation */ EventHandler__default.default.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) { - const target = getElementFromSelector(this); + const target = index.getElementFromSelector(this); if (['A', 'AREA'].includes(this.tagName)) { event.preventDefault(); } - if (isDisabled(this)) { + if (index.isDisabled(this)) { return; } EventHandler__default.default.one(target, EVENT_HIDDEN, () => { // focus on trigger when it is closed - if (isVisible(this)) { + if (index.isVisible(this)) { this.focus(); } }); // avoid conflict when clicking a toggler of an offcanvas, while another is open - const allReadyOpen = SelectorEngine__default.default.findOne(OPEN_SELECTOR); + const alreadyOpen = SelectorEngine__default.default.findOne(OPEN_SELECTOR); - if (allReadyOpen && allReadyOpen !== target) { - Offcanvas.getInstance(allReadyOpen).hide(); + if (alreadyOpen && alreadyOpen !== target) { + Offcanvas.getInstance(alreadyOpen).hide(); } const data = Offcanvas.getOrCreateInstance(target); data.toggle(this); }); - EventHandler__default.default.on(window, EVENT_LOAD_DATA_API, () => SelectorEngine__default.default.find(OPEN_SELECTOR).forEach(el => Offcanvas.getOrCreateInstance(el).show())); - enableDismissTrigger(Offcanvas); + EventHandler__default.default.on(window, EVENT_LOAD_DATA_API, () => { + for (const selector of SelectorEngine__default.default.find(OPEN_SELECTOR)) { + Offcanvas.getOrCreateInstance(selector).show(); + } + }); + EventHandler__default.default.on(window, EVENT_RESIZE, () => { + for (const element of SelectorEngine__default.default.find('[aria-modal][class*=show][class*=offcanvas-]')) { + if (getComputedStyle(element).position !== 'fixed') { + Offcanvas.getOrCreateInstance(element).hide(); + } + } + }); + componentFunctions.enableDismissTrigger(Offcanvas); /** - * ------------------------------------------------------------------------ * jQuery - * ------------------------------------------------------------------------ */ - defineJQueryPlugin(Offcanvas); + index.defineJQueryPlugin(Offcanvas); return Offcanvas; diff --git a/assets/javascripts/bootstrap/popover.js b/assets/javascripts/bootstrap/popover.js index 36d3f2a..5a63cf1 100644 --- a/assets/javascripts/bootstrap/popover.js +++ b/assets/javascripts/bootstrap/popover.js @@ -1,13 +1,13 @@ /*! - * Bootstrap popover.js v5.1.3 (https://getbootstrap.com/) - * Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) + * Bootstrap popover.js v5.2.0 (https://getbootstrap.com/) + * Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./tooltip.js')) : - typeof define === 'function' && define.amd ? define(['./tooltip'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Popover = factory(global.Tooltip)); -})(this, (function (Tooltip) { 'use strict'; + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./util/index'), require('./tooltip')) : + typeof define === 'function' && define.amd ? define(['./util/index', './tooltip'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Popover = factory(global.Index, global.Tooltip)); +})(this, (function (index, Tooltip) { 'use strict'; const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e }; @@ -15,103 +15,29 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): util/index.js - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) - * -------------------------------------------------------------------------- - */ - - const getjQuery = () => { - const { - jQuery - } = window; - - if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) { - return jQuery; - } - - return null; - }; - - const DOMContentLoadedCallbacks = []; - - const onDOMContentLoaded = callback => { - if (document.readyState === 'loading') { - // add listener on the first call when the document is in loading state - if (!DOMContentLoadedCallbacks.length) { - document.addEventListener('DOMContentLoaded', () => { - DOMContentLoadedCallbacks.forEach(callback => callback()); - }); - } - - DOMContentLoadedCallbacks.push(callback); - } else { - callback(); - } - }; - - const defineJQueryPlugin = plugin => { - onDOMContentLoaded(() => { - const $ = getjQuery(); - /* istanbul ignore if */ - - if ($) { - const name = plugin.NAME; - const JQUERY_NO_CONFLICT = $.fn[name]; - $.fn[name] = plugin.jQueryInterface; - $.fn[name].Constructor = plugin; - - $.fn[name].noConflict = () => { - $.fn[name] = JQUERY_NO_CONFLICT; - return plugin.jQueryInterface; - }; - } - }); - }; - - /** - * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): popover.js + * Bootstrap (v5.2.0): popover.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** - * ------------------------------------------------------------------------ * Constants - * ------------------------------------------------------------------------ */ const NAME = 'popover'; - const DATA_KEY = 'bs.popover'; - const EVENT_KEY = `.${DATA_KEY}`; - const CLASS_PREFIX = 'bs-popover'; + const SELECTOR_TITLE = '.popover-header'; + const SELECTOR_CONTENT = '.popover-body'; const Default = { ...Tooltip__default.default.Default, - placement: 'right', - offset: [0, 8], - trigger: 'click', content: '', - template: '<div class="popover" role="tooltip">' + '<div class="popover-arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div>' + '</div>' + offset: [0, 8], + placement: 'right', + template: '<div class="popover" role="tooltip">' + '<div class="popover-arrow"></div>' + '<h3 class="popover-header"></h3>' + '<div class="popover-body"></div>' + '</div>', + trigger: 'click' }; const DefaultType = { ...Tooltip__default.default.DefaultType, - content: '(string|element|function)' - }; - const Event = { - HIDE: `hide${EVENT_KEY}`, - HIDDEN: `hidden${EVENT_KEY}`, - SHOW: `show${EVENT_KEY}`, - SHOWN: `shown${EVENT_KEY}`, - INSERTED: `inserted${EVENT_KEY}`, - CLICK: `click${EVENT_KEY}`, - FOCUSIN: `focusin${EVENT_KEY}`, - FOCUSOUT: `focusout${EVENT_KEY}`, - MOUSEENTER: `mouseenter${EVENT_KEY}`, - MOUSELEAVE: `mouseleave${EVENT_KEY}` + content: '(null|string|element|function)' }; - const SELECTOR_TITLE = '.popover-header'; - const SELECTOR_CONTENT = '.popover-body'; /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ + * Class definition */ class Popover extends Tooltip__default.default { @@ -120,36 +46,29 @@ return Default; } - static get NAME() { - return NAME; - } - - static get Event() { - return Event; - } - static get DefaultType() { return DefaultType; - } // Overrides - - - isWithContent() { - return this.getTitle() || this._getContent(); } - setContent(tip) { - this._sanitizeAndSetContent(tip, this.getTitle(), SELECTOR_TITLE); + static get NAME() { + return NAME; + } // Overrides + - this._sanitizeAndSetContent(tip, this._getContent(), SELECTOR_CONTENT); + _isWithContent() { + return this._getTitle() || this._getContent(); } // Private - _getContent() { - return this._resolvePossibleFunction(this._config.content); + _getContentForTemplate() { + return { + [SELECTOR_TITLE]: this._getTitle(), + [SELECTOR_CONTENT]: this._getContent() + }; } - _getBasicClassPrefix() { - return CLASS_PREFIX; + _getContent() { + return this._resolvePossibleFunction(this._config.content); } // Static @@ -157,26 +76,25 @@ return this.each(function () { const data = Popover.getOrCreateInstance(this, config); - if (typeof config === 'string') { - if (typeof data[config] === 'undefined') { - throw new TypeError(`No method named "${config}"`); - } + if (typeof config !== 'string') { + return; + } - data[config](); + if (typeof data[config] === 'undefined') { + throw new TypeError(`No method named "${config}"`); } + + data[config](); }); } } /** - * ------------------------------------------------------------------------ * jQuery - * ------------------------------------------------------------------------ - * add .Popover to jQuery only if jQuery is present */ - defineJQueryPlugin(Popover); + index.defineJQueryPlugin(Popover); return Popover; diff --git a/assets/javascripts/bootstrap/scrollspy.js b/assets/javascripts/bootstrap/scrollspy.js index d562529..97f4272 100644 --- a/assets/javascripts/bootstrap/scrollspy.js +++ b/assets/javascripts/bootstrap/scrollspy.js @@ -1,215 +1,80 @@ /*! - * Bootstrap scrollspy.js v5.1.3 (https://getbootstrap.com/) - * Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) + * Bootstrap scrollspy.js v5.2.0 (https://getbootstrap.com/) + * Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/event-handler.js'), require('./dom/manipulator.js'), require('./dom/selector-engine.js'), require('./base-component.js')) : - typeof define === 'function' && define.amd ? define(['./dom/event-handler', './dom/manipulator', './dom/selector-engine', './base-component'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.ScrollSpy = factory(global.EventHandler, global.Manipulator, global.SelectorEngine, global.Base)); -})(this, (function (EventHandler, Manipulator, SelectorEngine, BaseComponent) { 'use strict'; + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./util/index'), require('./dom/event-handler'), require('./dom/selector-engine'), require('./base-component')) : + typeof define === 'function' && define.amd ? define(['./util/index', './dom/event-handler', './dom/selector-engine', './base-component'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Scrollspy = factory(global.Index, global.EventHandler, global.SelectorEngine, global.BaseComponent)); +})(this, (function (index, EventHandler, SelectorEngine, BaseComponent) { 'use strict'; const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e }; const EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler); - const Manipulator__default = /*#__PURE__*/_interopDefaultLegacy(Manipulator); const SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine); const BaseComponent__default = /*#__PURE__*/_interopDefaultLegacy(BaseComponent); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): util/index.js + * Bootstrap (v5.2.0): scrollspy.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ - - const toType = obj => { - if (obj === null || obj === undefined) { - return `${obj}`; - } - - return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase(); - }; - - const getSelector = element => { - let selector = element.getAttribute('data-bs-target'); - - if (!selector || selector === '#') { - let hrefAttr = element.getAttribute('href'); // The only valid content that could double as a selector are IDs or classes, - // so everything starting with `#` or `.`. If a "real" URL is used as the selector, - // `document.querySelector` will rightfully complain it is invalid. - // See https://github.com/twbs/bootstrap/issues/32273 - - if (!hrefAttr || !hrefAttr.includes('#') && !hrefAttr.startsWith('.')) { - return null; - } // Just in case some CMS puts out a full URL with the anchor appended - - - if (hrefAttr.includes('#') && !hrefAttr.startsWith('#')) { - hrefAttr = `#${hrefAttr.split('#')[1]}`; - } - - selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : null; - } - - return selector; - }; - - const getSelectorFromElement = element => { - const selector = getSelector(element); - - if (selector) { - return document.querySelector(selector) ? selector : null; - } - - return null; - }; - - const isElement = obj => { - if (!obj || typeof obj !== 'object') { - return false; - } - - if (typeof obj.jquery !== 'undefined') { - obj = obj[0]; - } - - return typeof obj.nodeType !== 'undefined'; - }; - - const getElement = obj => { - if (isElement(obj)) { - // it's a jQuery object or a node element - return obj.jquery ? obj[0] : obj; - } - - if (typeof obj === 'string' && obj.length > 0) { - return document.querySelector(obj); - } - - return null; - }; - - const typeCheckConfig = (componentName, config, configTypes) => { - Object.keys(configTypes).forEach(property => { - const expectedTypes = configTypes[property]; - const value = config[property]; - const valueType = value && isElement(value) ? 'element' : toType(value); - - if (!new RegExp(expectedTypes).test(valueType)) { - throw new TypeError(`${componentName.toUpperCase()}: Option "${property}" provided type "${valueType}" but expected type "${expectedTypes}".`); - } - }); - }; - - const getjQuery = () => { - const { - jQuery - } = window; - - if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) { - return jQuery; - } - - return null; - }; - - const DOMContentLoadedCallbacks = []; - - const onDOMContentLoaded = callback => { - if (document.readyState === 'loading') { - // add listener on the first call when the document is in loading state - if (!DOMContentLoadedCallbacks.length) { - document.addEventListener('DOMContentLoaded', () => { - DOMContentLoadedCallbacks.forEach(callback => callback()); - }); - } - - DOMContentLoadedCallbacks.push(callback); - } else { - callback(); - } - }; - - const defineJQueryPlugin = plugin => { - onDOMContentLoaded(() => { - const $ = getjQuery(); - /* istanbul ignore if */ - - if ($) { - const name = plugin.NAME; - const JQUERY_NO_CONFLICT = $.fn[name]; - $.fn[name] = plugin.jQueryInterface; - $.fn[name].Constructor = plugin; - - $.fn[name].noConflict = () => { - $.fn[name] = JQUERY_NO_CONFLICT; - return plugin.jQueryInterface; - }; - } - }); - }; - /** - * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): scrollspy.js - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) - * -------------------------------------------------------------------------- - */ - /** - * ------------------------------------------------------------------------ * Constants - * ------------------------------------------------------------------------ */ const NAME = 'scrollspy'; const DATA_KEY = 'bs.scrollspy'; const EVENT_KEY = `.${DATA_KEY}`; const DATA_API_KEY = '.data-api'; - const Default = { - offset: 10, - method: 'auto', - target: '' - }; - const DefaultType = { - offset: 'number', - method: 'string', - target: '(string|element)' - }; const EVENT_ACTIVATE = `activate${EVENT_KEY}`; - const EVENT_SCROLL = `scroll${EVENT_KEY}`; + const EVENT_CLICK = `click${EVENT_KEY}`; const EVENT_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}`; const CLASS_NAME_DROPDOWN_ITEM = 'dropdown-item'; const CLASS_NAME_ACTIVE = 'active'; const SELECTOR_DATA_SPY = '[data-bs-spy="scroll"]'; + const SELECTOR_TARGET_LINKS = '[href]'; const SELECTOR_NAV_LIST_GROUP = '.nav, .list-group'; const SELECTOR_NAV_LINKS = '.nav-link'; const SELECTOR_NAV_ITEMS = '.nav-item'; const SELECTOR_LIST_ITEMS = '.list-group-item'; - const SELECTOR_LINK_ITEMS = `${SELECTOR_NAV_LINKS}, ${SELECTOR_LIST_ITEMS}, .${CLASS_NAME_DROPDOWN_ITEM}`; + const SELECTOR_LINK_ITEMS = `${SELECTOR_NAV_LINKS}, ${SELECTOR_NAV_ITEMS} > ${SELECTOR_NAV_LINKS}, ${SELECTOR_LIST_ITEMS}`; const SELECTOR_DROPDOWN = '.dropdown'; const SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle'; - const METHOD_OFFSET = 'offset'; - const METHOD_POSITION = 'position'; + const Default = { + offset: null, + // TODO: v6 @deprecated, keep it for backwards compatibility reasons + rootMargin: '0px 0px -25%', + smoothScroll: false, + target: null + }; + const DefaultType = { + offset: '(number|null)', + // TODO v6 @deprecated, keep it for backwards compatibility reasons + rootMargin: 'string', + smoothScroll: 'boolean', + target: 'element' + }; /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ + * Class definition */ class ScrollSpy extends BaseComponent__default.default { constructor(element, config) { - super(element); - this._scrollElement = this._element.tagName === 'BODY' ? window : this._element; - this._config = this._getConfig(config); - this._offsets = []; - this._targets = []; - this._activeTarget = null; - this._scrollHeight = 0; - EventHandler__default.default.on(this._scrollElement, EVENT_SCROLL, () => this._process()); - this.refresh(); + super(element, config); // this._element is the observablesContainer and config.target the menu links wrapper - this._process(); + this._targetLinks = new Map(); + this._observableSections = new Map(); + this._rootElement = getComputedStyle(this._element).overflowY === 'visible' ? null : this._element; + this._activeTarget = null; + this._observer = null; + this._previousScrollData = { + visibleEntryTop: 0, + parentScrollTop: 0 + }; + this.refresh(); // initialize } // Getters @@ -217,135 +82,190 @@ return Default; } + static get DefaultType() { + return DefaultType; + } + static get NAME() { return NAME; } // Public refresh() { - const autoMethod = this._scrollElement === this._scrollElement.window ? METHOD_OFFSET : METHOD_POSITION; - const offsetMethod = this._config.method === 'auto' ? autoMethod : this._config.method; - const offsetBase = offsetMethod === METHOD_POSITION ? this._getScrollTop() : 0; - this._offsets = []; - this._targets = []; - this._scrollHeight = this._getScrollHeight(); - const targets = SelectorEngine__default.default.find(SELECTOR_LINK_ITEMS, this._config.target); - targets.map(element => { - const targetSelector = getSelectorFromElement(element); - const target = targetSelector ? SelectorEngine__default.default.findOne(targetSelector) : null; - - if (target) { - const targetBCR = target.getBoundingClientRect(); - - if (targetBCR.width || targetBCR.height) { - return [Manipulator__default.default[offsetMethod](target).top + offsetBase, targetSelector]; - } - } + this._initializeTargetsAndObservables(); - return null; - }).filter(item => item).sort((a, b) => a[0] - b[0]).forEach(item => { - this._offsets.push(item[0]); + this._maybeEnableSmoothScroll(); - this._targets.push(item[1]); - }); + if (this._observer) { + this._observer.disconnect(); + } else { + this._observer = this._getNewObserver(); + } + + for (const section of this._observableSections.values()) { + this._observer.observe(section); + } } dispose() { - EventHandler__default.default.off(this._scrollElement, EVENT_KEY); + this._observer.disconnect(); + super.dispose(); } // Private - _getConfig(config) { - config = { ...Default, - ...Manipulator__default.default.getDataAttributes(this._element), - ...(typeof config === 'object' && config ? config : {}) - }; - config.target = getElement(config.target) || document.documentElement; - typeCheckConfig(NAME, config, DefaultType); + _configAfterMerge(config) { + // TODO: on v6 target should be given explicitly & remove the {target: 'ss-target'} case + config.target = index.getElement(config.target) || document.body; return config; } - _getScrollTop() { - return this._scrollElement === window ? this._scrollElement.pageYOffset : this._scrollElement.scrollTop; - } + _maybeEnableSmoothScroll() { + if (!this._config.smoothScroll) { + return; + } // unregister any previous listeners - _getScrollHeight() { - return this._scrollElement.scrollHeight || Math.max(document.body.scrollHeight, document.documentElement.scrollHeight); - } - _getOffsetHeight() { - return this._scrollElement === window ? window.innerHeight : this._scrollElement.getBoundingClientRect().height; + EventHandler__default.default.off(this._config.target, EVENT_CLICK); + EventHandler__default.default.on(this._config.target, EVENT_CLICK, SELECTOR_TARGET_LINKS, event => { + const observableSection = this._observableSections.get(event.target.hash); + + if (observableSection) { + event.preventDefault(); + const root = this._rootElement || window; + const height = observableSection.offsetTop - this._element.offsetTop; + + if (root.scrollTo) { + root.scrollTo({ + top: height, + behavior: 'smooth' + }); + return; + } // Chrome 60 doesn't support `scrollTo` + + + root.scrollTop = height; + } + }); } - _process() { - const scrollTop = this._getScrollTop() + this._config.offset; + _getNewObserver() { + const options = { + root: this._rootElement, + threshold: [0.1, 0.5, 1], + rootMargin: this._getRootMargin() + }; + return new IntersectionObserver(entries => this._observerCallback(entries), options); + } // The logic of selection + - const scrollHeight = this._getScrollHeight(); + _observerCallback(entries) { + const targetElement = entry => this._targetLinks.get(`#${entry.target.id}`); - const maxScroll = this._config.offset + scrollHeight - this._getOffsetHeight(); + const activate = entry => { + this._previousScrollData.visibleEntryTop = entry.target.offsetTop; - if (this._scrollHeight !== scrollHeight) { - this.refresh(); - } + this._process(targetElement(entry)); + }; + + const parentScrollTop = (this._rootElement || document.documentElement).scrollTop; + const userScrollsDown = parentScrollTop >= this._previousScrollData.parentScrollTop; + this._previousScrollData.parentScrollTop = parentScrollTop; + + for (const entry of entries) { + if (!entry.isIntersecting) { + this._activeTarget = null; - if (scrollTop >= maxScroll) { - const target = this._targets[this._targets.length - 1]; + this._clearActiveClass(targetElement(entry)); - if (this._activeTarget !== target) { - this._activate(target); + continue; } - return; - } + const entryIsLowerThanPrevious = entry.target.offsetTop >= this._previousScrollData.visibleEntryTop; // if we are scrolling down, pick the bigger offsetTop - if (this._activeTarget && scrollTop < this._offsets[0] && this._offsets[0] > 0) { - this._activeTarget = null; + if (userScrollsDown && entryIsLowerThanPrevious) { + activate(entry); // if parent isn't scrolled, let's keep the first visible item, breaking the iteration - this._clear(); + if (!parentScrollTop) { + return; + } - return; - } + continue; + } // if we are scrolling up, pick the smallest offsetTop - for (let i = this._offsets.length; i--;) { - const isActiveTarget = this._activeTarget !== this._targets[i] && scrollTop >= this._offsets[i] && (typeof this._offsets[i + 1] === 'undefined' || scrollTop < this._offsets[i + 1]); - if (isActiveTarget) { - this._activate(this._targets[i]); + if (!userScrollsDown && !entryIsLowerThanPrevious) { + activate(entry); } } + } // TODO: v6 Only for backwards compatibility reasons. Use rootMargin only + + + _getRootMargin() { + return this._config.offset ? `${this._config.offset}px 0px -30%` : this._config.rootMargin; } - _activate(target) { - this._activeTarget = target; + _initializeTargetsAndObservables() { + this._targetLinks = new Map(); + this._observableSections = new Map(); + const targetLinks = SelectorEngine__default.default.find(SELECTOR_TARGET_LINKS, this._config.target); - this._clear(); + for (const anchor of targetLinks) { + // ensure that the anchor has an id and is not disabled + if (!anchor.hash || index.isDisabled(anchor)) { + continue; + } - const queries = SELECTOR_LINK_ITEMS.split(',').map(selector => `${selector}[data-bs-target="${target}"],${selector}[href="${target}"]`); - const link = SelectorEngine__default.default.findOne(queries.join(','), this._config.target); - link.classList.add(CLASS_NAME_ACTIVE); + const observableSection = SelectorEngine__default.default.findOne(anchor.hash, this._element); // ensure that the observableSection exists & is visible - if (link.classList.contains(CLASS_NAME_DROPDOWN_ITEM)) { - SelectorEngine__default.default.findOne(SELECTOR_DROPDOWN_TOGGLE, link.closest(SELECTOR_DROPDOWN)).classList.add(CLASS_NAME_ACTIVE); - } else { - SelectorEngine__default.default.parents(link, SELECTOR_NAV_LIST_GROUP).forEach(listGroup => { - // Set triggered links parents as active - // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor - SelectorEngine__default.default.prev(listGroup, `${SELECTOR_NAV_LINKS}, ${SELECTOR_LIST_ITEMS}`).forEach(item => item.classList.add(CLASS_NAME_ACTIVE)); // Handle special case when .nav-link is inside .nav-item - - SelectorEngine__default.default.prev(listGroup, SELECTOR_NAV_ITEMS).forEach(navItem => { - SelectorEngine__default.default.children(navItem, SELECTOR_NAV_LINKS).forEach(item => item.classList.add(CLASS_NAME_ACTIVE)); - }); - }); + if (index.isVisible(observableSection)) { + this._targetLinks.set(anchor.hash, anchor); + + this._observableSections.set(anchor.hash, observableSection); + } + } + } + + _process(target) { + if (this._activeTarget === target) { + return; } - EventHandler__default.default.trigger(this._scrollElement, EVENT_ACTIVATE, { + this._clearActiveClass(this._config.target); + + this._activeTarget = target; + target.classList.add(CLASS_NAME_ACTIVE); + + this._activateParents(target); + + EventHandler__default.default.trigger(this._element, EVENT_ACTIVATE, { relatedTarget: target }); } - _clear() { - SelectorEngine__default.default.find(SELECTOR_LINK_ITEMS, this._config.target).filter(node => node.classList.contains(CLASS_NAME_ACTIVE)).forEach(node => node.classList.remove(CLASS_NAME_ACTIVE)); + _activateParents(target) { + // Activate dropdown parents + if (target.classList.contains(CLASS_NAME_DROPDOWN_ITEM)) { + SelectorEngine__default.default.findOne(SELECTOR_DROPDOWN_TOGGLE, target.closest(SELECTOR_DROPDOWN)).classList.add(CLASS_NAME_ACTIVE); + return; + } + + for (const listGroup of SelectorEngine__default.default.parents(target, SELECTOR_NAV_LIST_GROUP)) { + // Set triggered links parents as active + // With both <ul> and <nav> markup a parent is the previous sibling of any nav ancestor + for (const item of SelectorEngine__default.default.prev(listGroup, SELECTOR_LINK_ITEMS)) { + item.classList.add(CLASS_NAME_ACTIVE); + } + } + } + + _clearActiveClass(parent) { + parent.classList.remove(CLASS_NAME_ACTIVE); + const activeNodes = SelectorEngine__default.default.find(`${SELECTOR_TARGET_LINKS}.${CLASS_NAME_ACTIVE}`, parent); + + for (const node of activeNodes) { + node.classList.remove(CLASS_NAME_ACTIVE); + } } // Static @@ -357,7 +277,7 @@ return; } - if (typeof data[config] === 'undefined') { + if (data[config] === undefined || config.startsWith('_') || config === 'constructor') { throw new TypeError(`No method named "${config}"`); } @@ -367,23 +287,20 @@ } /** - * ------------------------------------------------------------------------ - * Data Api implementation - * ------------------------------------------------------------------------ + * Data API implementation */ EventHandler__default.default.on(window, EVENT_LOAD_DATA_API, () => { - SelectorEngine__default.default.find(SELECTOR_DATA_SPY).forEach(spy => new ScrollSpy(spy)); + for (const spy of SelectorEngine__default.default.find(SELECTOR_DATA_SPY)) { + ScrollSpy.getOrCreateInstance(spy); + } }); /** - * ------------------------------------------------------------------------ * jQuery - * ------------------------------------------------------------------------ - * add .ScrollSpy to jQuery only if jQuery is present */ - defineJQueryPlugin(ScrollSpy); + index.defineJQueryPlugin(ScrollSpy); return ScrollSpy; diff --git a/assets/javascripts/bootstrap/tab.js b/assets/javascripts/bootstrap/tab.js index 95f643b..34cc96b 100644 --- a/assets/javascripts/bootstrap/tab.js +++ b/assets/javascripts/bootstrap/tab.js @@ -1,13 +1,13 @@ /*! - * Bootstrap tab.js v5.1.3 (https://getbootstrap.com/) - * Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) + * Bootstrap tab.js v5.2.0 (https://getbootstrap.com/) + * Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/event-handler.js'), require('./dom/selector-engine.js'), require('./base-component.js')) : - typeof define === 'function' && define.amd ? define(['./dom/event-handler', './dom/selector-engine', './base-component'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Tab = factory(global.EventHandler, global.SelectorEngine, global.Base)); -})(this, (function (EventHandler, SelectorEngine, BaseComponent) { 'use strict'; + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./util/index'), require('./dom/event-handler'), require('./dom/selector-engine'), require('./base-component')) : + typeof define === 'function' && define.amd ? define(['./util/index', './dom/event-handler', './dom/selector-engine', './base-component'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Tab = factory(global.Index, global.EventHandler, global.SelectorEngine, global.BaseComponent)); +})(this, (function (index, EventHandler, SelectorEngine, BaseComponent) { 'use strict'; const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e }; @@ -17,270 +17,266 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): util/index.js - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) - * -------------------------------------------------------------------------- - */ - - const getSelector = element => { - let selector = element.getAttribute('data-bs-target'); - - if (!selector || selector === '#') { - let hrefAttr = element.getAttribute('href'); // The only valid content that could double as a selector are IDs or classes, - // so everything starting with `#` or `.`. If a "real" URL is used as the selector, - // `document.querySelector` will rightfully complain it is invalid. - // See https://github.com/twbs/bootstrap/issues/32273 - - if (!hrefAttr || !hrefAttr.includes('#') && !hrefAttr.startsWith('.')) { - return null; - } // Just in case some CMS puts out a full URL with the anchor appended - - - if (hrefAttr.includes('#') && !hrefAttr.startsWith('#')) { - hrefAttr = `#${hrefAttr.split('#')[1]}`; - } - - selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : null; - } - - return selector; - }; - - const getElementFromSelector = element => { - const selector = getSelector(element); - return selector ? document.querySelector(selector) : null; - }; - - const isDisabled = element => { - if (!element || element.nodeType !== Node.ELEMENT_NODE) { - return true; - } - - if (element.classList.contains('disabled')) { - return true; - } - - if (typeof element.disabled !== 'undefined') { - return element.disabled; - } - - return element.hasAttribute('disabled') && element.getAttribute('disabled') !== 'false'; - }; - /** - * Trick to restart an element's animation - * - * @param {HTMLElement} element - * @return void - * - * @see https://www.charistheo.io/blog/2021/02/restart-a-css-animation-with-javascript/#restarting-a-css-animation - */ - - - const reflow = element => { - // eslint-disable-next-line no-unused-expressions - element.offsetHeight; - }; - - const getjQuery = () => { - const { - jQuery - } = window; - - if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) { - return jQuery; - } - - return null; - }; - - const DOMContentLoadedCallbacks = []; - - const onDOMContentLoaded = callback => { - if (document.readyState === 'loading') { - // add listener on the first call when the document is in loading state - if (!DOMContentLoadedCallbacks.length) { - document.addEventListener('DOMContentLoaded', () => { - DOMContentLoadedCallbacks.forEach(callback => callback()); - }); - } - - DOMContentLoadedCallbacks.push(callback); - } else { - callback(); - } - }; - - const defineJQueryPlugin = plugin => { - onDOMContentLoaded(() => { - const $ = getjQuery(); - /* istanbul ignore if */ - - if ($) { - const name = plugin.NAME; - const JQUERY_NO_CONFLICT = $.fn[name]; - $.fn[name] = plugin.jQueryInterface; - $.fn[name].Constructor = plugin; - - $.fn[name].noConflict = () => { - $.fn[name] = JQUERY_NO_CONFLICT; - return plugin.jQueryInterface; - }; - } - }); - }; - - /** - * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): tab.js + * Bootstrap (v5.2.0): tab.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ /** - * ------------------------------------------------------------------------ * Constants - * ------------------------------------------------------------------------ */ const NAME = 'tab'; const DATA_KEY = 'bs.tab'; const EVENT_KEY = `.${DATA_KEY}`; - const DATA_API_KEY = '.data-api'; 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 CLASS_NAME_DROPDOWN_MENU = 'dropdown-menu'; + const EVENT_CLICK_DATA_API = `click${EVENT_KEY}`; + const EVENT_KEYDOWN = `keydown${EVENT_KEY}`; + const EVENT_LOAD_DATA_API = `load${EVENT_KEY}`; + const ARROW_LEFT_KEY = 'ArrowLeft'; + const ARROW_RIGHT_KEY = 'ArrowRight'; + const ARROW_UP_KEY = 'ArrowUp'; + const ARROW_DOWN_KEY = 'ArrowDown'; const CLASS_NAME_ACTIVE = 'active'; const CLASS_NAME_FADE = 'fade'; const CLASS_NAME_SHOW = 'show'; - const SELECTOR_DROPDOWN = '.dropdown'; - const SELECTOR_NAV_LIST_GROUP = '.nav, .list-group'; - const SELECTOR_ACTIVE = '.active'; - const SELECTOR_ACTIVE_UL = ':scope > li > .active'; - const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="tab"], [data-bs-toggle="pill"], [data-bs-toggle="list"]'; + const CLASS_DROPDOWN = 'dropdown'; const SELECTOR_DROPDOWN_TOGGLE = '.dropdown-toggle'; - const SELECTOR_DROPDOWN_ACTIVE_CHILD = ':scope > .dropdown-menu .active'; + const SELECTOR_DROPDOWN_MENU = '.dropdown-menu'; + const SELECTOR_DROPDOWN_ITEM = '.dropdown-item'; + const NOT_SELECTOR_DROPDOWN_TOGGLE = ':not(.dropdown-toggle)'; + const SELECTOR_TAB_PANEL = '.list-group, .nav, [role="tablist"]'; + const SELECTOR_OUTER = '.nav-item, .list-group-item'; + const SELECTOR_INNER = `.nav-link${NOT_SELECTOR_DROPDOWN_TOGGLE}, .list-group-item${NOT_SELECTOR_DROPDOWN_TOGGLE}, [role="tab"]${NOT_SELECTOR_DROPDOWN_TOGGLE}`; + const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="tab"], [data-bs-toggle="pill"], [data-bs-toggle="list"]'; // todo:v6: could be only `tab` + + const SELECTOR_INNER_ELEM = `${SELECTOR_INNER}, ${SELECTOR_DATA_TOGGLE}`; + const SELECTOR_DATA_TOGGLE_ACTIVE = `.${CLASS_NAME_ACTIVE}[data-bs-toggle="tab"], .${CLASS_NAME_ACTIVE}[data-bs-toggle="pill"], .${CLASS_NAME_ACTIVE}[data-bs-toggle="list"]`; /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ + * Class definition */ class Tab extends BaseComponent__default.default { - // Getters + constructor(element) { + super(element); + this._parent = this._element.closest(SELECTOR_TAB_PANEL); + + if (!this._parent) { + return; // todo: should Throw exception on v6 + // throw new TypeError(`${element.outerHTML} has not a valid parent ${SELECTOR_INNER_ELEM}`) + } // Set up initial aria attributes + + + this._setInitialAttributes(this._parent, this._getChildren()); + + EventHandler__default.default.on(this._element, EVENT_KEYDOWN, event => this._keydown(event)); + } // Getters + + static get NAME() { return NAME; } // Public show() { - if (this._element.parentNode && this._element.parentNode.nodeType === Node.ELEMENT_NODE && this._element.classList.contains(CLASS_NAME_ACTIVE)) { - return; - } + // Shows this elem and deactivate the active sibling if exists + const innerElem = this._element; - let previous; - const target = getElementFromSelector(this._element); + if (this._elemIsActive(innerElem)) { + return; + } // Search for active tab on same parent to deactivate it - const listElement = this._element.closest(SELECTOR_NAV_LIST_GROUP); - if (listElement) { - const itemSelector = listElement.nodeName === 'UL' || listElement.nodeName === 'OL' ? SELECTOR_ACTIVE_UL : SELECTOR_ACTIVE; - previous = SelectorEngine__default.default.find(itemSelector, listElement); - previous = previous[previous.length - 1]; - } + const active = this._getActiveElem(); - const hideEvent = previous ? EventHandler__default.default.trigger(previous, EVENT_HIDE, { - relatedTarget: this._element + const hideEvent = active ? EventHandler__default.default.trigger(active, EVENT_HIDE, { + relatedTarget: innerElem }) : null; - const showEvent = EventHandler__default.default.trigger(this._element, EVENT_SHOW, { - relatedTarget: previous + const showEvent = EventHandler__default.default.trigger(innerElem, EVENT_SHOW, { + relatedTarget: active }); - if (showEvent.defaultPrevented || hideEvent !== null && hideEvent.defaultPrevented) { + if (showEvent.defaultPrevented || hideEvent && hideEvent.defaultPrevented) { return; } - this._activate(this._element, listElement); + this._deactivate(active, innerElem); + + this._activate(innerElem, active); + } // Private + + + _activate(element, relatedElem) { + if (!element) { + return; + } + + element.classList.add(CLASS_NAME_ACTIVE); + + this._activate(index.getElementFromSelector(element)); // Search and activate/show the proper section + const complete = () => { - EventHandler__default.default.trigger(previous, EVENT_HIDDEN, { - relatedTarget: this._element + if (element.getAttribute('role') !== 'tab') { + element.classList.add(CLASS_NAME_SHOW); + return; + } + + element.focus(); + element.removeAttribute('tabindex'); + element.setAttribute('aria-selected', true); + + this._toggleDropDown(element, true); + + EventHandler__default.default.trigger(element, EVENT_SHOWN, { + relatedTarget: relatedElem }); - EventHandler__default.default.trigger(this._element, EVENT_SHOWN, { - relatedTarget: previous + }; + + this._queueCallback(complete, element, element.classList.contains(CLASS_NAME_FADE)); + } + + _deactivate(element, relatedElem) { + if (!element) { + return; + } + + element.classList.remove(CLASS_NAME_ACTIVE); + element.blur(); + + this._deactivate(index.getElementFromSelector(element)); // Search and deactivate the shown section too + + + const complete = () => { + if (element.getAttribute('role') !== 'tab') { + element.classList.remove(CLASS_NAME_SHOW); + return; + } + + element.setAttribute('aria-selected', false); + element.setAttribute('tabindex', '-1'); + + this._toggleDropDown(element, false); + + EventHandler__default.default.trigger(element, EVENT_HIDDEN, { + relatedTarget: relatedElem }); }; - if (target) { - this._activate(target, target.parentNode, complete); - } else { - complete(); + this._queueCallback(complete, element, element.classList.contains(CLASS_NAME_FADE)); + } + + _keydown(event) { + if (![ARROW_LEFT_KEY, ARROW_RIGHT_KEY, ARROW_UP_KEY, ARROW_DOWN_KEY].includes(event.key)) { + return; } - } // Private + event.stopPropagation(); // stopPropagation/preventDefault both added to support up/down keys without scrolling the page - _activate(element, container, callback) { - const activeElements = container && (container.nodeName === 'UL' || container.nodeName === 'OL') ? SelectorEngine__default.default.find(SELECTOR_ACTIVE_UL, container) : SelectorEngine__default.default.children(container, SELECTOR_ACTIVE); - const active = activeElements[0]; - const isTransitioning = callback && active && active.classList.contains(CLASS_NAME_FADE); + event.preventDefault(); + const isNext = [ARROW_RIGHT_KEY, ARROW_DOWN_KEY].includes(event.key); + const nextActiveElement = index.getNextActiveElement(this._getChildren().filter(element => !index.isDisabled(element)), event.target, isNext, true); - const complete = () => this._transitionComplete(element, active, callback); + if (nextActiveElement) { + Tab.getOrCreateInstance(nextActiveElement).show(); + } + } - if (active && isTransitioning) { - active.classList.remove(CLASS_NAME_SHOW); + _getChildren() { + // collection of inner elements + return SelectorEngine__default.default.find(SELECTOR_INNER_ELEM, this._parent); + } - this._queueCallback(complete, element, true); - } else { - complete(); + _getActiveElem() { + return this._getChildren().find(child => this._elemIsActive(child)) || null; + } + + _setInitialAttributes(parent, children) { + this._setAttributeIfNotExists(parent, 'role', 'tablist'); + + for (const child of children) { + this._setInitialAttributesOnChild(child); } } - _transitionComplete(element, active, callback) { - if (active) { - active.classList.remove(CLASS_NAME_ACTIVE); - const dropdownChild = SelectorEngine__default.default.findOne(SELECTOR_DROPDOWN_ACTIVE_CHILD, active.parentNode); + _setInitialAttributesOnChild(child) { + child = this._getInnerElement(child); - if (dropdownChild) { - dropdownChild.classList.remove(CLASS_NAME_ACTIVE); - } + const isActive = this._elemIsActive(child); - if (active.getAttribute('role') === 'tab') { - active.setAttribute('aria-selected', false); - } + const outerElem = this._getOuterElement(child); + + child.setAttribute('aria-selected', isActive); + + if (outerElem !== child) { + this._setAttributeIfNotExists(outerElem, 'role', 'presentation'); } - element.classList.add(CLASS_NAME_ACTIVE); + if (!isActive) { + child.setAttribute('tabindex', '-1'); + } - if (element.getAttribute('role') === 'tab') { - element.setAttribute('aria-selected', true); + this._setAttributeIfNotExists(child, 'role', 'tab'); // set attributes to the related panel too + + + this._setInitialAttributesOnTargetPanel(child); + } + + _setInitialAttributesOnTargetPanel(child) { + const target = index.getElementFromSelector(child); + + if (!target) { + return; } - reflow(element); + this._setAttributeIfNotExists(target, 'role', 'tabpanel'); - if (element.classList.contains(CLASS_NAME_FADE)) { - element.classList.add(CLASS_NAME_SHOW); + if (child.id) { + this._setAttributeIfNotExists(target, 'aria-labelledby', `#${child.id}`); } + } - let parent = element.parentNode; + _toggleDropDown(element, open) { + const outerElem = this._getOuterElement(element); - if (parent && parent.nodeName === 'LI') { - parent = parent.parentNode; + if (!outerElem.classList.contains(CLASS_DROPDOWN)) { + return; } - if (parent && parent.classList.contains(CLASS_NAME_DROPDOWN_MENU)) { - const dropdownElement = element.closest(SELECTOR_DROPDOWN); + const toggle = (selector, className) => { + const element = SelectorEngine__default.default.findOne(selector, outerElem); - if (dropdownElement) { - SelectorEngine__default.default.find(SELECTOR_DROPDOWN_TOGGLE, dropdownElement).forEach(dropdown => dropdown.classList.add(CLASS_NAME_ACTIVE)); + if (element) { + element.classList.toggle(className, open); } + }; - element.setAttribute('aria-expanded', true); - } + toggle(SELECTOR_DROPDOWN_TOGGLE, CLASS_NAME_ACTIVE); + toggle(SELECTOR_DROPDOWN_MENU, CLASS_NAME_SHOW); + toggle(SELECTOR_DROPDOWN_ITEM, CLASS_NAME_ACTIVE); + outerElem.setAttribute('aria-expanded', open); + } - if (callback) { - callback(); + _setAttributeIfNotExists(element, attribute, value) { + if (!element.hasAttribute(attribute)) { + element.setAttribute(attribute, value); } + } + + _elemIsActive(elem) { + return elem.classList.contains(CLASS_NAME_ACTIVE); + } // Try to get the inner element (usually the .nav-link) + + + _getInnerElement(elem) { + return elem.matches(SELECTOR_INNER_ELEM) ? elem : SelectorEngine__default.default.findOne(SELECTOR_INNER_ELEM, elem); + } // Try to get the outer element (usually the .nav-item) + + + _getOuterElement(elem) { + return elem.closest(SELECTOR_OUTER) || elem; } // Static @@ -288,21 +284,21 @@ return this.each(function () { const data = Tab.getOrCreateInstance(this); - if (typeof config === 'string') { - if (typeof data[config] === 'undefined') { - throw new TypeError(`No method named "${config}"`); - } + if (typeof config !== 'string') { + return; + } - data[config](); + if (data[config] === undefined || config.startsWith('_') || config === 'constructor') { + throw new TypeError(`No method named "${config}"`); } + + data[config](); }); } } /** - * ------------------------------------------------------------------------ - * Data Api implementation - * ------------------------------------------------------------------------ + * Data API implementation */ @@ -311,21 +307,26 @@ event.preventDefault(); } - if (isDisabled(this)) { + if (index.isDisabled(this)) { return; } - const data = Tab.getOrCreateInstance(this); - data.show(); + Tab.getOrCreateInstance(this).show(); + }); + /** + * Initialize on focus + */ + + EventHandler__default.default.on(window, EVENT_LOAD_DATA_API, () => { + for (const element of SelectorEngine__default.default.find(SELECTOR_DATA_TOGGLE_ACTIVE)) { + Tab.getOrCreateInstance(element); + } }); /** - * ------------------------------------------------------------------------ * jQuery - * ------------------------------------------------------------------------ - * add .Tab to jQuery only if jQuery is present */ - defineJQueryPlugin(Tab); + index.defineJQueryPlugin(Tab); return Tab; diff --git a/assets/javascripts/bootstrap/toast.js b/assets/javascripts/bootstrap/toast.js index 1636cf9..861128d 100644 --- a/assets/javascripts/bootstrap/toast.js +++ b/assets/javascripts/bootstrap/toast.js @@ -1,202 +1,27 @@ /*! - * Bootstrap toast.js v5.1.3 (https://getbootstrap.com/) - * Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) + * Bootstrap toast.js v5.2.0 (https://getbootstrap.com/) + * Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./dom/event-handler.js'), require('./dom/manipulator.js'), require('./base-component.js')) : - typeof define === 'function' && define.amd ? define(['./dom/event-handler', './dom/manipulator', './base-component'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Toast = factory(global.EventHandler, global.Manipulator, global.Base)); -})(this, (function (EventHandler, Manipulator, BaseComponent) { 'use strict'; + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./util/index'), require('./dom/event-handler'), require('./base-component'), require('./util/component-functions')) : + typeof define === 'function' && define.amd ? define(['./util/index', './dom/event-handler', './base-component', './util/component-functions'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Toast = factory(global.Index, global.EventHandler, global.BaseComponent, global.ComponentFunctions)); +})(this, (function (index, EventHandler, BaseComponent, componentFunctions) { 'use strict'; const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e }; const EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler); - const Manipulator__default = /*#__PURE__*/_interopDefaultLegacy(Manipulator); const BaseComponent__default = /*#__PURE__*/_interopDefaultLegacy(BaseComponent); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): util/index.js + * Bootstrap (v5.2.0): toast.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ - - const toType = obj => { - if (obj === null || obj === undefined) { - return `${obj}`; - } - - return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase(); - }; - - const getSelector = element => { - let selector = element.getAttribute('data-bs-target'); - - if (!selector || selector === '#') { - let hrefAttr = element.getAttribute('href'); // The only valid content that could double as a selector are IDs or classes, - // so everything starting with `#` or `.`. If a "real" URL is used as the selector, - // `document.querySelector` will rightfully complain it is invalid. - // See https://github.com/twbs/bootstrap/issues/32273 - - if (!hrefAttr || !hrefAttr.includes('#') && !hrefAttr.startsWith('.')) { - return null; - } // Just in case some CMS puts out a full URL with the anchor appended - - - if (hrefAttr.includes('#') && !hrefAttr.startsWith('#')) { - hrefAttr = `#${hrefAttr.split('#')[1]}`; - } - - selector = hrefAttr && hrefAttr !== '#' ? hrefAttr.trim() : null; - } - - return selector; - }; - - const getElementFromSelector = element => { - const selector = getSelector(element); - return selector ? document.querySelector(selector) : null; - }; - - const isElement = obj => { - if (!obj || typeof obj !== 'object') { - return false; - } - - if (typeof obj.jquery !== 'undefined') { - obj = obj[0]; - } - - return typeof obj.nodeType !== 'undefined'; - }; - - const typeCheckConfig = (componentName, config, configTypes) => { - Object.keys(configTypes).forEach(property => { - const expectedTypes = configTypes[property]; - const value = config[property]; - const valueType = value && isElement(value) ? 'element' : toType(value); - - if (!new RegExp(expectedTypes).test(valueType)) { - throw new TypeError(`${componentName.toUpperCase()}: Option "${property}" provided type "${valueType}" but expected type "${expectedTypes}".`); - } - }); - }; - - const isDisabled = element => { - if (!element || element.nodeType !== Node.ELEMENT_NODE) { - return true; - } - - if (element.classList.contains('disabled')) { - return true; - } - - if (typeof element.disabled !== 'undefined') { - return element.disabled; - } - - return element.hasAttribute('disabled') && element.getAttribute('disabled') !== 'false'; - }; - /** - * Trick to restart an element's animation - * - * @param {HTMLElement} element - * @return void - * - * @see https://www.charistheo.io/blog/2021/02/restart-a-css-animation-with-javascript/#restarting-a-css-animation - */ - - - const reflow = element => { - // eslint-disable-next-line no-unused-expressions - element.offsetHeight; - }; - - const getjQuery = () => { - const { - jQuery - } = window; - - if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) { - return jQuery; - } - - return null; - }; - - const DOMContentLoadedCallbacks = []; - - const onDOMContentLoaded = callback => { - if (document.readyState === 'loading') { - // add listener on the first call when the document is in loading state - if (!DOMContentLoadedCallbacks.length) { - document.addEventListener('DOMContentLoaded', () => { - DOMContentLoadedCallbacks.forEach(callback => callback()); - }); - } - - DOMContentLoadedCallbacks.push(callback); - } else { - callback(); - } - }; - - const defineJQueryPlugin = plugin => { - onDOMContentLoaded(() => { - const $ = getjQuery(); - /* istanbul ignore if */ - - if ($) { - const name = plugin.NAME; - const JQUERY_NO_CONFLICT = $.fn[name]; - $.fn[name] = plugin.jQueryInterface; - $.fn[name].Constructor = plugin; - - $.fn[name].noConflict = () => { - $.fn[name] = JQUERY_NO_CONFLICT; - return plugin.jQueryInterface; - }; - } - }); - }; - - /** - * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): util/component-functions.js - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) - * -------------------------------------------------------------------------- - */ - - const enableDismissTrigger = (component, method = 'hide') => { - const clickEvent = `click.dismiss${component.EVENT_KEY}`; - const name = component.NAME; - EventHandler__default.default.on(document, clickEvent, `[data-bs-dismiss="${name}"]`, function (event) { - if (['A', 'AREA'].includes(this.tagName)) { - event.preventDefault(); - } - - if (isDisabled(this)) { - return; - } - - const target = getElementFromSelector(this) || this.closest(`.${name}`); - const instance = component.getOrCreateInstance(target); // Method argument is left, for Alert and only, as it doesn't implement the 'hide' method - - instance[method](); - }); - }; - /** - * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): toast.js - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) - * -------------------------------------------------------------------------- - */ - /** - * ------------------------------------------------------------------------ * Constants - * ------------------------------------------------------------------------ */ const NAME = 'toast'; @@ -226,15 +51,12 @@ delay: 5000 }; /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ + * Class definition */ class Toast extends BaseComponent__default.default { constructor(element, config) { - super(element); - this._config = this._getConfig(config); + super(element, config); this._timeout = null; this._hasMouseInteraction = false; this._hasKeyboardInteraction = false; @@ -243,14 +65,14 @@ } // Getters - static get DefaultType() { - return DefaultType; - } - static get Default() { return Default; } + static get DefaultType() { + return DefaultType; + } + static get NAME() { return NAME; } // Public @@ -280,17 +102,15 @@ this._element.classList.remove(CLASS_NAME_HIDE); // @deprecated - reflow(this._element); - - this._element.classList.add(CLASS_NAME_SHOW); + index.reflow(this._element); - this._element.classList.add(CLASS_NAME_SHOWING); + this._element.classList.add(CLASS_NAME_SHOW, CLASS_NAME_SHOWING); this._queueCallback(complete, this._element, this._config.animation); } hide() { - if (!this._element.classList.contains(CLASS_NAME_SHOW)) { + if (!this.isShown()) { return; } @@ -304,9 +124,7 @@ this._element.classList.add(CLASS_NAME_HIDE); // @deprecated - this._element.classList.remove(CLASS_NAME_SHOWING); - - this._element.classList.remove(CLASS_NAME_SHOW); + this._element.classList.remove(CLASS_NAME_SHOWING, CLASS_NAME_SHOW); EventHandler__default.default.trigger(this._element, EVENT_HIDDEN); }; @@ -319,23 +137,18 @@ dispose() { this._clearTimeout(); - if (this._element.classList.contains(CLASS_NAME_SHOW)) { + if (this.isShown()) { this._element.classList.remove(CLASS_NAME_SHOW); } super.dispose(); + } + + isShown() { + return this._element.classList.contains(CLASS_NAME_SHOW); } // Private - _getConfig(config) { - config = { ...Default, - ...Manipulator__default.default.getDataAttributes(this._element), - ...(typeof config === 'object' && config ? config : {}) - }; - typeCheckConfig(NAME, config, this.constructor.DefaultType); - return config; - } - _maybeScheduleHide() { if (!this._config.autohide) { return; @@ -406,16 +219,17 @@ } } + /** + * Data API implementation + */ + - enableDismissTrigger(Toast); + componentFunctions.enableDismissTrigger(Toast); /** - * ------------------------------------------------------------------------ * jQuery - * ------------------------------------------------------------------------ - * add .Toast to jQuery only if jQuery is present */ - defineJQueryPlugin(Toast); + index.defineJQueryPlugin(Toast); return Toast; diff --git a/assets/javascripts/bootstrap/tooltip.js b/assets/javascripts/bootstrap/tooltip.js index 931f4ca..d05f238 100644 --- a/assets/javascripts/bootstrap/tooltip.js +++ b/assets/javascripts/bootstrap/tooltip.js @@ -1,19 +1,19 @@ /*! - * Bootstrap tooltip.js v5.1.3 (https://getbootstrap.com/) - * Copyright 2011-2021 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) + * Bootstrap tooltip.js v5.2.0 (https://getbootstrap.com/) + * Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) */ (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@popperjs/core'), require('./dom/data.js'), require('./dom/event-handler.js'), require('./dom/manipulator.js'), require('./dom/selector-engine.js'), require('./base-component.js')) : - typeof define === 'function' && define.amd ? define(['@popperjs/core', './dom/data', './dom/event-handler', './dom/manipulator', './dom/selector-engine', './base-component'], factory) : - (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Tooltip = factory(global.Popper, global.Data, global.EventHandler, global.Manipulator, global.SelectorEngine, global.Base)); -})(this, (function (Popper, Data, EventHandler, Manipulator, SelectorEngine, BaseComponent) { 'use strict'; + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('@popperjs/core'), require('./util/index'), require('./util/sanitizer'), require('./dom/event-handler'), require('./dom/manipulator'), require('./base-component'), require('./util/template-factory')) : + typeof define === 'function' && define.amd ? define(['@popperjs/core', './util/index', './util/sanitizer', './dom/event-handler', './dom/manipulator', './base-component', './util/template-factory'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Tooltip = factory(global["@popperjs/core"], global.Index, global.Sanitizer, global.EventHandler, global.Manipulator, global.BaseComponent, global.TemplateFactory)); +})(this, (function (Popper, index, sanitizer, EventHandler, Manipulator, BaseComponent, TemplateFactory) { 'use strict'; const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e }; function _interopNamespace(e) { if (e && e.__esModule) return e; - const n = Object.create(null); + const n = Object.create(null, { [Symbol.toStringTag]: { value: 'Module' } }); if (e) { for (const k in e) { if (k !== 'default') { @@ -30,356 +30,90 @@ } const Popper__namespace = /*#__PURE__*/_interopNamespace(Popper); - const Data__default = /*#__PURE__*/_interopDefaultLegacy(Data); const EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler); const Manipulator__default = /*#__PURE__*/_interopDefaultLegacy(Manipulator); - const SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine); const BaseComponent__default = /*#__PURE__*/_interopDefaultLegacy(BaseComponent); + const TemplateFactory__default = /*#__PURE__*/_interopDefaultLegacy(TemplateFactory); /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): util/index.js + * Bootstrap (v5.2.0): tooltip.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ - const MAX_UID = 1000000; - - const toType = obj => { - if (obj === null || obj === undefined) { - return `${obj}`; - } - - return {}.toString.call(obj).match(/\s([a-z]+)/i)[1].toLowerCase(); - }; - /** - * -------------------------------------------------------------------------- - * Public Util Api - * -------------------------------------------------------------------------- - */ - - - const getUID = prefix => { - do { - prefix += Math.floor(Math.random() * MAX_UID); - } while (document.getElementById(prefix)); - - return prefix; - }; - - const isElement = obj => { - if (!obj || typeof obj !== 'object') { - return false; - } - - if (typeof obj.jquery !== 'undefined') { - obj = obj[0]; - } - - return typeof obj.nodeType !== 'undefined'; - }; - - const getElement = obj => { - if (isElement(obj)) { - // it's a jQuery object or a node element - return obj.jquery ? obj[0] : obj; - } - - if (typeof obj === 'string' && obj.length > 0) { - return document.querySelector(obj); - } - - return null; - }; - - const typeCheckConfig = (componentName, config, configTypes) => { - Object.keys(configTypes).forEach(property => { - const expectedTypes = configTypes[property]; - const value = config[property]; - const valueType = value && isElement(value) ? 'element' : toType(value); - - if (!new RegExp(expectedTypes).test(valueType)) { - throw new TypeError(`${componentName.toUpperCase()}: Option "${property}" provided type "${valueType}" but expected type "${expectedTypes}".`); - } - }); - }; - - const 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 findShadowRoot(element.parentNode); - }; - - const noop = () => {}; - - const getjQuery = () => { - const { - jQuery - } = window; - - if (jQuery && !document.body.hasAttribute('data-bs-no-jquery')) { - return jQuery; - } - - return null; - }; - - const DOMContentLoadedCallbacks = []; - - const onDOMContentLoaded = callback => { - if (document.readyState === 'loading') { - // add listener on the first call when the document is in loading state - if (!DOMContentLoadedCallbacks.length) { - document.addEventListener('DOMContentLoaded', () => { - DOMContentLoadedCallbacks.forEach(callback => callback()); - }); - } - - DOMContentLoadedCallbacks.push(callback); - } else { - callback(); - } - }; - - const isRTL = () => document.documentElement.dir === 'rtl'; - - const defineJQueryPlugin = plugin => { - onDOMContentLoaded(() => { - const $ = getjQuery(); - /* istanbul ignore if */ - - if ($) { - const name = plugin.NAME; - const JQUERY_NO_CONFLICT = $.fn[name]; - $.fn[name] = plugin.jQueryInterface; - $.fn[name].Constructor = plugin; - - $.fn[name].noConflict = () => { - $.fn[name] = JQUERY_NO_CONFLICT; - return plugin.jQueryInterface; - }; - } - }); - }; - /** - * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): util/sanitizer.js - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) - * -------------------------------------------------------------------------- - */ - const uriAttributes = new Set(['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href']); - const ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i; - /** - * A pattern that recognizes a commonly useful subset of URLs that are safe. - * - * Shoutout to Angular https://github.com/angular/angular/blob/12.2.x/packages/core/src/sanitization/url_sanitizer.ts - */ - - const SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file|sms):|[^#&/:?]*(?:[#/?]|$))/i; - /** - * A pattern that matches safe data URLs. Only matches image, video and audio types. - * - * Shoutout to Angular https://github.com/angular/angular/blob/12.2.x/packages/core/src/sanitization/url_sanitizer.ts - */ - - const DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[\d+/a-z]+=*$/i; - - const allowedAttribute = (attribute, allowedAttributeList) => { - const attributeName = attribute.nodeName.toLowerCase(); - - if (allowedAttributeList.includes(attributeName)) { - if (uriAttributes.has(attributeName)) { - return Boolean(SAFE_URL_PATTERN.test(attribute.nodeValue) || DATA_URL_PATTERN.test(attribute.nodeValue)); - } - - return true; - } - - const regExp = allowedAttributeList.filter(attributeRegex => attributeRegex instanceof RegExp); // Check if a regular expression validates the attribute. - - for (let i = 0, len = regExp.length; i < len; i++) { - if (regExp[i].test(attributeName)) { - return true; - } - } - - return false; - }; - - const DefaultAllowlist = { - // Global attributes allowed on any supplied element below. - '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN], - a: ['target', 'href', 'title', 'rel'], - area: [], - b: [], - br: [], - col: [], - code: [], - div: [], - em: [], - hr: [], - h1: [], - h2: [], - h3: [], - h4: [], - h5: [], - h6: [], - i: [], - img: ['src', 'srcset', 'alt', 'title', 'width', 'height'], - li: [], - ol: [], - p: [], - pre: [], - s: [], - small: [], - span: [], - sub: [], - sup: [], - strong: [], - u: [], - ul: [] - }; - function sanitizeHtml(unsafeHtml, allowList, sanitizeFn) { - if (!unsafeHtml.length) { - return unsafeHtml; - } - - if (sanitizeFn && typeof sanitizeFn === 'function') { - return sanitizeFn(unsafeHtml); - } - - const domParser = new window.DOMParser(); - const createdDocument = domParser.parseFromString(unsafeHtml, 'text/html'); - const elements = [].concat(...createdDocument.body.querySelectorAll('*')); - - for (let i = 0, len = elements.length; i < len; i++) { - const element = elements[i]; - const elementName = element.nodeName.toLowerCase(); - - if (!Object.keys(allowList).includes(elementName)) { - element.remove(); - continue; - } - - const attributeList = [].concat(...element.attributes); - const allowedAttributes = [].concat(allowList['*'] || [], allowList[elementName] || []); - attributeList.forEach(attribute => { - if (!allowedAttribute(attribute, allowedAttributes)) { - element.removeAttribute(attribute.nodeName); - } - }); - } - - return createdDocument.body.innerHTML; - } - - /** - * -------------------------------------------------------------------------- - * Bootstrap (v5.1.3): tooltip.js - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) - * -------------------------------------------------------------------------- - */ - /** - * ------------------------------------------------------------------------ * Constants - * ------------------------------------------------------------------------ */ const NAME = 'tooltip'; - const DATA_KEY = 'bs.tooltip'; - const EVENT_KEY = `.${DATA_KEY}`; - const CLASS_PREFIX = 'bs-tooltip'; const DISALLOWED_ATTRIBUTES = new Set(['sanitize', 'allowList', 'sanitizeFn']); - const DefaultType = { - animation: 'boolean', - template: 'string', - title: '(string|element|function)', - trigger: 'string', - delay: '(number|object)', - html: 'boolean', - selector: '(string|boolean)', - placement: '(string|function)', - offset: '(array|string|function)', - container: '(string|element|boolean)', - fallbackPlacements: 'array', - boundary: '(string|element)', - customClass: '(string|function)', - sanitize: 'boolean', - sanitizeFn: '(null|function)', - allowList: 'object', - popperConfig: '(null|object|function)' - }; + const CLASS_NAME_FADE = 'fade'; + const CLASS_NAME_MODAL = 'modal'; + const CLASS_NAME_SHOW = 'show'; + const SELECTOR_TOOLTIP_INNER = '.tooltip-inner'; + const SELECTOR_MODAL = `.${CLASS_NAME_MODAL}`; + const EVENT_MODAL_HIDE = 'hide.bs.modal'; + const TRIGGER_HOVER = 'hover'; + const TRIGGER_FOCUS = 'focus'; + const TRIGGER_CLICK = 'click'; + const TRIGGER_MANUAL = 'manual'; + const EVENT_HIDE = 'hide'; + const EVENT_HIDDEN = 'hidden'; + const EVENT_SHOW = 'show'; + const EVENT_SHOWN = 'shown'; + const EVENT_INSERTED = 'inserted'; + const EVENT_CLICK = 'click'; + const EVENT_FOCUSIN = 'focusin'; + const EVENT_FOCUSOUT = 'focusout'; + const EVENT_MOUSEENTER = 'mouseenter'; + const EVENT_MOUSELEAVE = 'mouseleave'; const AttachmentMap = { AUTO: 'auto', TOP: 'top', - RIGHT: isRTL() ? 'left' : 'right', + RIGHT: index.isRTL() ? 'left' : 'right', BOTTOM: 'bottom', - LEFT: isRTL() ? 'right' : 'left' + LEFT: index.isRTL() ? 'right' : 'left' }; const Default = { + allowList: sanitizer.DefaultAllowlist, animation: true, - template: '<div class="tooltip" role="tooltip">' + '<div class="tooltip-arrow"></div>' + '<div class="tooltip-inner"></div>' + '</div>', - trigger: 'hover focus', - title: '', + boundary: 'clippingParents', + container: false, + customClass: '', delay: 0, + fallbackPlacements: ['top', 'right', 'bottom', 'left'], html: false, - selector: false, - placement: 'top', offset: [0, 0], - container: false, - fallbackPlacements: ['top', 'right', 'bottom', 'left'], - boundary: 'clippingParents', - customClass: '', + placement: 'top', + popperConfig: null, sanitize: true, sanitizeFn: null, - allowList: DefaultAllowlist, - popperConfig: null + selector: false, + template: '<div class="tooltip" role="tooltip">' + '<div class="tooltip-arrow"></div>' + '<div class="tooltip-inner"></div>' + '</div>', + title: '', + trigger: 'hover focus' }; - const Event = { - HIDE: `hide${EVENT_KEY}`, - HIDDEN: `hidden${EVENT_KEY}`, - SHOW: `show${EVENT_KEY}`, - SHOWN: `shown${EVENT_KEY}`, - INSERTED: `inserted${EVENT_KEY}`, - CLICK: `click${EVENT_KEY}`, - FOCUSIN: `focusin${EVENT_KEY}`, - FOCUSOUT: `focusout${EVENT_KEY}`, - MOUSEENTER: `mouseenter${EVENT_KEY}`, - MOUSELEAVE: `mouseleave${EVENT_KEY}` + const DefaultType = { + allowList: 'object', + animation: 'boolean', + boundary: '(string|element)', + container: '(string|element|boolean)', + customClass: '(string|function)', + delay: '(number|object)', + fallbackPlacements: 'array', + html: 'boolean', + offset: '(array|string|function)', + placement: '(string|function)', + popperConfig: '(null|object|function)', + sanitize: 'boolean', + sanitizeFn: '(null|function)', + selector: '(string|boolean)', + template: 'string', + title: '(string|element|function)', + trigger: 'string' }; - const CLASS_NAME_FADE = 'fade'; - const CLASS_NAME_MODAL = 'modal'; - const CLASS_NAME_SHOW = 'show'; - const HOVER_STATE_SHOW = 'show'; - const HOVER_STATE_OUT = 'out'; - const SELECTOR_TOOLTIP_INNER = '.tooltip-inner'; - const SELECTOR_MODAL = `.${CLASS_NAME_MODAL}`; - const EVENT_MODAL_HIDE = 'hide.bs.modal'; - const TRIGGER_HOVER = 'hover'; - const TRIGGER_FOCUS = 'focus'; - const TRIGGER_CLICK = 'click'; - const TRIGGER_MANUAL = 'manual'; /** - * ------------------------------------------------------------------------ - * Class Definition - * ------------------------------------------------------------------------ + * Class definition */ class Tooltip extends BaseComponent__default.default { @@ -388,15 +122,16 @@ throw new TypeError('Bootstrap\'s tooltips require Popper (https://popper.js.org)'); } - super(element); // private + super(element, config); // Private this._isEnabled = true; this._timeout = 0; - this._hoverState = ''; + this._isHovered = false; this._activeTrigger = {}; - this._popper = null; // Protected + this._popper = null; + this._templateFactory = null; + this._newContent = null; // Protected - this._config = this._getConfig(config); this.tip = null; this._setListeners(); @@ -407,16 +142,12 @@ return Default; } - static get NAME() { - return NAME; - } - - static get Event() { - return Event; - } - static get DefaultType() { return DefaultType; + } + + static get NAME() { + return NAME; } // Public @@ -443,19 +174,21 @@ context._activeTrigger.click = !context._activeTrigger.click; if (context._isWithActiveTrigger()) { - context._enter(null, context); + context._enter(); } else { - context._leave(null, context); + context._leave(); } - } else { - if (this.getTipElement().classList.contains(CLASS_NAME_SHOW)) { - this._leave(null, this); - return; - } + return; + } + + if (this._isShown()) { + this._leave(); - this._enter(null, this); + return; } + + this._enter(); } dispose() { @@ -476,233 +209,206 @@ throw new Error('Please use show on visible elements'); } - if (!(this.isWithContent() && this._isEnabled)) { + if (!(this._isWithContent() && this._isEnabled)) { return; } - const showEvent = EventHandler__default.default.trigger(this._element, this.constructor.Event.SHOW); - const shadowRoot = findShadowRoot(this._element); - const isInTheDom = shadowRoot === null ? this._element.ownerDocument.documentElement.contains(this._element) : shadowRoot.contains(this._element); + const showEvent = EventHandler__default.default.trigger(this._element, this.constructor.eventName(EVENT_SHOW)); + const shadowRoot = index.findShadowRoot(this._element); + + const isInTheDom = (shadowRoot || this._element.ownerDocument.documentElement).contains(this._element); if (showEvent.defaultPrevented || !isInTheDom) { return; - } // A trick to recreate a tooltip in case a new title is given by using the NOT documented `data-bs-original-title` - // This will be removed later in favor of a `setContent` method + } // todo v6 remove this OR make it optional - if (this.constructor.NAME === 'tooltip' && this.tip && this.getTitle() !== this.tip.querySelector(SELECTOR_TOOLTIP_INNER).innerHTML) { - this._disposePopper(); - + if (this.tip) { this.tip.remove(); this.tip = null; } - const tip = this.getTipElement(); - const tipId = getUID(this.constructor.NAME); - tip.setAttribute('id', tipId); - - this._element.setAttribute('aria-describedby', tipId); - - if (this._config.animation) { - tip.classList.add(CLASS_NAME_FADE); - } + const tip = this._getTipElement(); - const placement = typeof this._config.placement === 'function' ? this._config.placement.call(this, tip, this._element) : this._config.placement; - - const attachment = this._getAttachment(placement); - - this._addAttachmentClass(attachment); + this._element.setAttribute('aria-describedby', tip.getAttribute('id')); const { container } = this._config; - Data__default.default.set(tip, this.constructor.DATA_KEY, this); if (!this._element.ownerDocument.documentElement.contains(this.tip)) { container.append(tip); - EventHandler__default.default.trigger(this._element, this.constructor.Event.INSERTED); + EventHandler__default.default.trigger(this._element, this.constructor.eventName(EVENT_INSERTED)); } if (this._popper) { this._popper.update(); } else { - this._popper = Popper__namespace.createPopper(this._element, tip, this._getPopperConfig(attachment)); + this._popper = this._createPopper(tip); } - tip.classList.add(CLASS_NAME_SHOW); - - const customClass = this._resolvePossibleFunction(this._config.customClass); - - if (customClass) { - tip.classList.add(...customClass.split(' ')); - } // If this is a touch-enabled device we add extra + tip.classList.add(CLASS_NAME_SHOW); // 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) { - [].concat(...document.body.children).forEach(element => { - EventHandler__default.default.on(element, 'mouseover', noop); - }); + for (const element of [].concat(...document.body.children)) { + EventHandler__default.default.on(element, 'mouseover', index.noop); + } } const complete = () => { - const prevHoverState = this._hoverState; - this._hoverState = null; - EventHandler__default.default.trigger(this._element, this.constructor.Event.SHOWN); + const previousHoverState = this._isHovered; + this._isHovered = false; + EventHandler__default.default.trigger(this._element, this.constructor.eventName(EVENT_SHOWN)); - if (prevHoverState === HOVER_STATE_OUT) { - this._leave(null, this); + if (previousHoverState) { + this._leave(); } }; - const isAnimated = this.tip.classList.contains(CLASS_NAME_FADE); - - this._queueCallback(complete, this.tip, isAnimated); + this._queueCallback(complete, this.tip, this._isAnimated()); } hide() { - if (!this._popper) { + if (!this._isShown()) { return; } - const tip = this.getTipElement(); - - const complete = () => { - if (this._isWithActiveTrigger()) { - return; - } - - if (this._hoverState !== HOVER_STATE_SHOW) { - tip.remove(); - } - - this._cleanTipClass(); - - this._element.removeAttribute('aria-describedby'); - - EventHandler__default.default.trigger(this._element, this.constructor.Event.HIDDEN); - - this._disposePopper(); - }; - - const hideEvent = EventHandler__default.default.trigger(this._element, this.constructor.Event.HIDE); + const hideEvent = EventHandler__default.default.trigger(this._element, this.constructor.eventName(EVENT_HIDE)); if (hideEvent.defaultPrevented) { return; } + const tip = this._getTipElement(); + tip.classList.remove(CLASS_NAME_SHOW); // If this is a touch-enabled device we remove the extra // empty mouseover listeners we added for iOS support if ('ontouchstart' in document.documentElement) { - [].concat(...document.body.children).forEach(element => EventHandler__default.default.off(element, 'mouseover', noop)); + for (const element of [].concat(...document.body.children)) { + EventHandler__default.default.off(element, 'mouseover', index.noop); + } } this._activeTrigger[TRIGGER_CLICK] = false; this._activeTrigger[TRIGGER_FOCUS] = false; this._activeTrigger[TRIGGER_HOVER] = false; - const isAnimated = this.tip.classList.contains(CLASS_NAME_FADE); + this._isHovered = false; - this._queueCallback(complete, this.tip, isAnimated); + const complete = () => { + if (this._isWithActiveTrigger()) { + return; + } - this._hoverState = ''; + if (!this._isHovered) { + tip.remove(); + } + + this._element.removeAttribute('aria-describedby'); + + EventHandler__default.default.trigger(this._element, this.constructor.eventName(EVENT_HIDDEN)); + + this._disposePopper(); + }; + + this._queueCallback(complete, this.tip, this._isAnimated()); } update() { - if (this._popper !== null) { + if (this._popper) { this._popper.update(); } } // Protected - isWithContent() { - return Boolean(this.getTitle()); + _isWithContent() { + return Boolean(this._getTitle()); } - getTipElement() { - if (this.tip) { - return this.tip; + _getTipElement() { + if (!this.tip) { + this.tip = this._createTipElement(this._newContent || this._getContentForTemplate()); } - const element = document.createElement('div'); - element.innerHTML = this._config.template; - const tip = element.children[0]; - this.setContent(tip); - tip.classList.remove(CLASS_NAME_FADE, CLASS_NAME_SHOW); - this.tip = tip; return this.tip; } - setContent(tip) { - this._sanitizeAndSetContent(tip, this.getTitle(), SELECTOR_TOOLTIP_INNER); - } + _createTipElement(content) { + const tip = this._getTemplateFactory(content).toHtml(); // todo: remove this check on v6 - _sanitizeAndSetContent(template, content, selector) { - const templateElement = SelectorEngine__default.default.findOne(selector, template); - if (!content && templateElement) { - templateElement.remove(); - return; - } // we use append for html objects to maintain js events + if (!tip) { + return null; + } + tip.classList.remove(CLASS_NAME_FADE, CLASS_NAME_SHOW); // todo: on v6 the following can be achieved with CSS only - this.setElementContent(templateElement, content); - } + tip.classList.add(`bs-${this.constructor.NAME}-auto`); + const tipId = index.getUID(this.constructor.NAME).toString(); + tip.setAttribute('id', tipId); - setElementContent(element, content) { - if (element === null) { - return; + if (this._isAnimated()) { + tip.classList.add(CLASS_NAME_FADE); } - if (isElement(content)) { - content = getElement(content); // content is a DOM node or a jQuery + return tip; + } - if (this._config.html) { - if (content.parentNode !== element) { - element.innerHTML = ''; - element.append(content); - } - } else { - element.textContent = content.textContent; - } + setContent(content) { + this._newContent = content; - return; - } + if (this._isShown()) { + this._disposePopper(); - if (this._config.html) { - if (this._config.sanitize) { - content = sanitizeHtml(content, this._config.allowList, this._config.sanitizeFn); - } + this.show(); + } + } - element.innerHTML = content; + _getTemplateFactory(content) { + if (this._templateFactory) { + this._templateFactory.changeContent(content); } else { - element.textContent = content; + this._templateFactory = new TemplateFactory__default.default({ ...this._config, + // the `content` var has to be after `this._config` + // to override config.content in case of popover + content, + extraClass: this._resolvePossibleFunction(this._config.customClass) + }); } - } - getTitle() { - const title = this._element.getAttribute('data-bs-original-title') || this._config.title; + return this._templateFactory; + } - return this._resolvePossibleFunction(title); + _getContentForTemplate() { + return { + [SELECTOR_TOOLTIP_INNER]: this._getTitle() + }; } - updateAttachment(attachment) { - if (attachment === 'right') { - return 'end'; - } + _getTitle() { + return this._resolvePossibleFunction(this._config.title) || this._config.originalTitle; + } // Private - if (attachment === 'left') { - return 'start'; - } - return attachment; - } // Private + _initializeOnDelegatedTarget(event) { + return this.constructor.getOrCreateInstance(event.delegateTarget, this._getDelegateConfig()); + } + + _isAnimated() { + return this._config.animation || this.tip && this.tip.classList.contains(CLASS_NAME_FADE); + } + _isShown() { + return this.tip && this.tip.classList.contains(CLASS_NAME_SHOW); + } - _initializeOnDelegatedTarget(event, context) { - return context || this.constructor.getOrCreateInstance(event.delegateTarget, this._getDelegateConfig()); + _createPopper(tip) { + const placement = typeof this._config.placement === 'function' ? this._config.placement.call(this, tip, this._element) : this._config.placement; + const attachment = AttachmentMap[placement.toUpperCase()]; + return Popper__namespace.createPopper(this._element, tip, this._getPopperConfig(attachment)); } _getOffset() { @@ -711,7 +417,7 @@ } = this._config; if (typeof offset === 'string') { - return offset.split(',').map(val => Number.parseInt(val, 10)); + return offset.split(',').map(value => Number.parseInt(value, 10)); } if (typeof offset === 'function') { @@ -721,8 +427,8 @@ return offset; } - _resolvePossibleFunction(content) { - return typeof content === 'function' ? content.call(this._element) : content; + _resolvePossibleFunction(arg) { + return typeof arg === 'function' ? arg.call(this._element) : arg; } _getPopperConfig(attachment) { @@ -749,43 +455,46 @@ element: `.${this.constructor.NAME}-arrow` } }, { - name: 'onChange', + name: 'preSetPlacement', enabled: true, - phase: 'afterWrite', - fn: data => this._handlePopperPlacementChange(data) - }], - onFirstUpdate: data => { - if (data.options.placement !== data.placement) { - this._handlePopperPlacementChange(data); + phase: 'beforeMain', + fn: data => { + // Pre-set Popper's placement attribute in order to read the arrow sizes properly. + // Otherwise, Popper mixes up the width and height dimensions since the initial arrow style is for top placement + this._getTipElement().setAttribute('data-popper-placement', data.state.placement); } - } + }] }; return { ...defaultBsPopperConfig, ...(typeof this._config.popperConfig === 'function' ? this._config.popperConfig(defaultBsPopperConfig) : this._config.popperConfig) }; } - _addAttachmentClass(attachment) { - this.getTipElement().classList.add(`${this._getBasicClassPrefix()}-${this.updateAttachment(attachment)}`); - } - - _getAttachment(placement) { - return AttachmentMap[placement.toUpperCase()]; - } - _setListeners() { const triggers = this._config.trigger.split(' '); - triggers.forEach(trigger => { + for (const trigger of triggers) { if (trigger === 'click') { - EventHandler__default.default.on(this._element, this.constructor.Event.CLICK, this._config.selector, event => this.toggle(event)); + EventHandler__default.default.on(this._element, this.constructor.eventName(EVENT_CLICK), this._config.selector, event => this.toggle(event)); } else if (trigger !== TRIGGER_MANUAL) { - const eventIn = trigger === TRIGGER_HOVER ? this.constructor.Event.MOUSEENTER : this.constructor.Event.FOCUSIN; - const eventOut = trigger === TRIGGER_HOVER ? this.constructor.Event.MOUSELEAVE : this.constructor.Event.FOCUSOUT; - EventHandler__default.default.on(this._element, eventIn, this._config.selector, event => this._enter(event)); - EventHandler__default.default.on(this._element, eventOut, this._config.selector, event => this._leave(event)); + const eventIn = trigger === TRIGGER_HOVER ? this.constructor.eventName(EVENT_MOUSEENTER) : this.constructor.eventName(EVENT_FOCUSIN); + const eventOut = trigger === TRIGGER_HOVER ? this.constructor.eventName(EVENT_MOUSELEAVE) : this.constructor.eventName(EVENT_FOCUSOUT); + EventHandler__default.default.on(this._element, eventIn, this._config.selector, event => { + const context = this._initializeOnDelegatedTarget(event); + + context._activeTrigger[event.type === 'focusin' ? TRIGGER_FOCUS : TRIGGER_HOVER] = true; + + context._enter(); + }); + EventHandler__default.default.on(this._element, eventOut, this._config.selector, event => { + const context = this._initializeOnDelegatedTarget(event); + + context._activeTrigger[event.type === 'focusout' ? TRIGGER_FOCUS : TRIGGER_HOVER] = context._element.contains(event.relatedTarget); + + context._leave(); + }); } - }); + } this._hideModalHandler = () => { if (this._element) { @@ -806,96 +515,79 @@ } _fixTitle() { - const title = this._element.getAttribute('title'); - - const originalTitleType = typeof this._element.getAttribute('data-bs-original-title'); - - if (title || originalTitleType !== 'string') { - this._element.setAttribute('data-bs-original-title', title || ''); - - if (title && !this._element.getAttribute('aria-label') && !this._element.textContent) { - this._element.setAttribute('aria-label', title); - } - - this._element.setAttribute('title', ''); - } - } + const title = this._config.originalTitle; - _enter(event, context) { - context = this._initializeOnDelegatedTarget(event, context); - - if (event) { - context._activeTrigger[event.type === 'focusin' ? TRIGGER_FOCUS : TRIGGER_HOVER] = true; + if (!title) { + return; } - if (context.getTipElement().classList.contains(CLASS_NAME_SHOW) || context._hoverState === HOVER_STATE_SHOW) { - context._hoverState = HOVER_STATE_SHOW; - return; + if (!this._element.getAttribute('aria-label') && !this._element.textContent.trim()) { + this._element.setAttribute('aria-label', title); } - clearTimeout(context._timeout); - context._hoverState = HOVER_STATE_SHOW; + this._element.removeAttribute('title'); + } - if (!context._config.delay || !context._config.delay.show) { - context.show(); + _enter() { + if (this._isShown() || this._isHovered) { + this._isHovered = true; return; } - context._timeout = setTimeout(() => { - if (context._hoverState === HOVER_STATE_SHOW) { - context.show(); + this._isHovered = true; + + this._setTimeout(() => { + if (this._isHovered) { + this.show(); } - }, context._config.delay.show); + }, this._config.delay.show); } - _leave(event, context) { - context = this._initializeOnDelegatedTarget(event, context); - - if (event) { - context._activeTrigger[event.type === 'focusout' ? TRIGGER_FOCUS : TRIGGER_HOVER] = context._element.contains(event.relatedTarget); - } - - if (context._isWithActiveTrigger()) { + _leave() { + if (this._isWithActiveTrigger()) { return; } - clearTimeout(context._timeout); - context._hoverState = HOVER_STATE_OUT; + this._isHovered = false; - if (!context._config.delay || !context._config.delay.hide) { - context.hide(); - return; - } - - context._timeout = setTimeout(() => { - if (context._hoverState === HOVER_STATE_OUT) { - context.hide(); + this._setTimeout(() => { + if (!this._isHovered) { + this.hide(); } - }, context._config.delay.hide); + }, this._config.delay.hide); } - _isWithActiveTrigger() { - for (const trigger in this._activeTrigger) { - if (this._activeTrigger[trigger]) { - return true; - } - } + _setTimeout(handler, timeout) { + clearTimeout(this._timeout); + this._timeout = setTimeout(handler, timeout); + } - return false; + _isWithActiveTrigger() { + return Object.values(this._activeTrigger).includes(true); } _getConfig(config) { const dataAttributes = Manipulator__default.default.getDataAttributes(this._element); - Object.keys(dataAttributes).forEach(dataAttr => { - if (DISALLOWED_ATTRIBUTES.has(dataAttr)) { - delete dataAttributes[dataAttr]; + + for (const dataAttribute of Object.keys(dataAttributes)) { + if (DISALLOWED_ATTRIBUTES.has(dataAttribute)) { + delete dataAttributes[dataAttribute]; } - }); - config = { ...this.constructor.Default, - ...dataAttributes, + } + + config = { ...dataAttributes, ...(typeof config === 'object' && config ? config : {}) }; - config.container = config.container === false ? document.body : getElement(config.container); + config = this._mergeConfigObj(config); + config = this._configAfterMerge(config); + + this._typeCheckConfig(config); + + return config; + } + + _configAfterMerge(config) { + config.container = config.container === false ? document.body : index.getElement(config.container); if (typeof config.delay === 'number') { config.delay = { @@ -904,6 +596,8 @@ }; } + config.originalTitle = this._element.getAttribute('title') || ''; + if (typeof config.title === 'number') { config.title = config.title.toString(); } @@ -912,12 +606,6 @@ config.content = config.content.toString(); } - typeCheckConfig(NAME, config, this.constructor.DefaultType); - - if (config.sanitize) { - config.template = sanitizeHtml(config.template, config.allowList, config.sanitizeFn); - } - return config; } @@ -936,36 +624,6 @@ return config; } - _cleanTipClass() { - const tip = this.getTipElement(); - const basicClassPrefixRegex = new RegExp(`(^|\\s)${this._getBasicClassPrefix()}\\S+`, 'g'); - const tabClass = tip.getAttribute('class').match(basicClassPrefixRegex); - - if (tabClass !== null && tabClass.length > 0) { - tabClass.map(token => token.trim()).forEach(tClass => tip.classList.remove(tClass)); - } - } - - _getBasicClassPrefix() { - return CLASS_PREFIX; - } - - _handlePopperPlacementChange(popperData) { - const { - state - } = popperData; - - if (!state) { - return; - } - - this.tip = state.elements.popper; - - this._cleanTipClass(); - - this._addAttachmentClass(this._getAttachment(state.placement)); - } - _disposePopper() { if (this._popper) { this._popper.destroy(); @@ -979,26 +637,25 @@ return this.each(function () { const data = Tooltip.getOrCreateInstance(this, config); - if (typeof config === 'string') { - if (typeof data[config] === 'undefined') { - throw new TypeError(`No method named "${config}"`); - } + if (typeof config !== 'string') { + return; + } - data[config](); + if (typeof data[config] === 'undefined') { + throw new TypeError(`No method named "${config}"`); } + + data[config](); }); } } /** - * ------------------------------------------------------------------------ * jQuery - * ------------------------------------------------------------------------ - * add .Tooltip to jQuery only if jQuery is present */ - defineJQueryPlugin(Tooltip); + index.defineJQueryPlugin(Tooltip); return Tooltip; diff --git a/assets/javascripts/bootstrap/util/backdrop.js b/assets/javascripts/bootstrap/util/backdrop.js new file mode 100644 index 0000000..a38ab38 --- /dev/null +++ b/assets/javascripts/bootstrap/util/backdrop.js @@ -0,0 +1,165 @@ +/*! + * Bootstrap backdrop.js v5.2.0 (https://getbootstrap.com/) + * Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) + */ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('../dom/event-handler'), require('./index'), require('./config')) : + typeof define === 'function' && define.amd ? define(['../dom/event-handler', './index', './config'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Backdrop = factory(global.EventHandler, global.Index, global.Config)); +})(this, (function (EventHandler, index, Config) { 'use strict'; + + const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e }; + + const EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler); + const Config__default = /*#__PURE__*/_interopDefaultLegacy(Config); + + /** + * -------------------------------------------------------------------------- + * Bootstrap (v5.2.0): util/backdrop.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) + * -------------------------------------------------------------------------- + */ + /** + * Constants + */ + + const NAME = 'backdrop'; + const CLASS_NAME_FADE = 'fade'; + const CLASS_NAME_SHOW = 'show'; + const EVENT_MOUSEDOWN = `mousedown.bs.${NAME}`; + const Default = { + className: 'modal-backdrop', + clickCallback: null, + isAnimated: false, + isVisible: true, + // if false, we use the backdrop helper without adding any element to the dom + rootElement: 'body' // give the choice to place backdrop under different elements + + }; + const DefaultType = { + className: 'string', + clickCallback: '(function|null)', + isAnimated: 'boolean', + isVisible: 'boolean', + rootElement: '(element|string)' + }; + /** + * Class definition + */ + + class Backdrop extends Config__default.default { + constructor(config) { + super(); + this._config = this._getConfig(config); + this._isAppended = false; + this._element = null; + } // Getters + + + static get Default() { + return Default; + } + + static get DefaultType() { + return DefaultType; + } + + static get NAME() { + return NAME; + } // Public + + + show(callback) { + if (!this._config.isVisible) { + index.execute(callback); + return; + } + + this._append(); + + const element = this._getElement(); + + if (this._config.isAnimated) { + index.reflow(element); + } + + element.classList.add(CLASS_NAME_SHOW); + + this._emulateAnimation(() => { + index.execute(callback); + }); + } + + hide(callback) { + if (!this._config.isVisible) { + index.execute(callback); + return; + } + + this._getElement().classList.remove(CLASS_NAME_SHOW); + + this._emulateAnimation(() => { + this.dispose(); + index.execute(callback); + }); + } + + dispose() { + if (!this._isAppended) { + return; + } + + EventHandler__default.default.off(this._element, EVENT_MOUSEDOWN); + + this._element.remove(); + + this._isAppended = false; + } // Private + + + _getElement() { + if (!this._element) { + const backdrop = document.createElement('div'); + backdrop.className = this._config.className; + + if (this._config.isAnimated) { + backdrop.classList.add(CLASS_NAME_FADE); + } + + this._element = backdrop; + } + + return this._element; + } + + _configAfterMerge(config) { + // use getElement() with the default "body" to get a fresh Element on each instantiation + config.rootElement = index.getElement(config.rootElement); + return config; + } + + _append() { + if (this._isAppended) { + return; + } + + const element = this._getElement(); + + this._config.rootElement.append(element); + + EventHandler__default.default.on(element, EVENT_MOUSEDOWN, () => { + index.execute(this._config.clickCallback); + }); + this._isAppended = true; + } + + _emulateAnimation(callback) { + index.executeAfterTransition(callback, this._getElement(), this._config.isAnimated); + } + + } + + return Backdrop; + +})); diff --git a/assets/javascripts/bootstrap/util/component-functions.js b/assets/javascripts/bootstrap/util/component-functions.js new file mode 100644 index 0000000..d996b48 --- /dev/null +++ b/assets/javascripts/bootstrap/util/component-functions.js @@ -0,0 +1,46 @@ +/*! + * Bootstrap component-functions.js v5.2.0 (https://getbootstrap.com/) + * Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) + */ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('../dom/event-handler'), require('./index')) : + typeof define === 'function' && define.amd ? define(['exports', '../dom/event-handler', './index'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ComponentFunctions = {}, global.EventHandler, global.Index)); +})(this, (function (exports, EventHandler, index) { 'use strict'; + + const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e }; + + const EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler); + + /** + * -------------------------------------------------------------------------- + * Bootstrap (v5.2.0): util/component-functions.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) + * -------------------------------------------------------------------------- + */ + + const enableDismissTrigger = (component, method = 'hide') => { + const clickEvent = `click.dismiss${component.EVENT_KEY}`; + const name = component.NAME; + EventHandler__default.default.on(document, clickEvent, `[data-bs-dismiss="${name}"]`, function (event) { + if (['A', 'AREA'].includes(this.tagName)) { + event.preventDefault(); + } + + if (index.isDisabled(this)) { + return; + } + + const target = index.getElementFromSelector(this) || this.closest(`.${name}`); + const instance = component.getOrCreateInstance(target); // Method argument is left, for Alert and only, as it doesn't implement the 'hide' method + + instance[method](); + }); + }; + + exports.enableDismissTrigger = enableDismissTrigger; + + Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } }); + +})); diff --git a/assets/javascripts/bootstrap/util/config.js b/assets/javascripts/bootstrap/util/config.js new file mode 100644 index 0000000..c284a49 --- /dev/null +++ b/assets/javascripts/bootstrap/util/config.js @@ -0,0 +1,79 @@ +/*! + * Bootstrap config.js v5.2.0 (https://getbootstrap.com/) + * Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) + */ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./index'), require('../dom/manipulator')) : + typeof define === 'function' && define.amd ? define(['./index', '../dom/manipulator'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Config = factory(global.Index, global.Manipulator)); +})(this, (function (index, Manipulator) { 'use strict'; + + const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e }; + + const Manipulator__default = /*#__PURE__*/_interopDefaultLegacy(Manipulator); + + /** + * -------------------------------------------------------------------------- + * Bootstrap (v5.2.0): util/config.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) + * -------------------------------------------------------------------------- + */ + /** + * Class definition + */ + + class Config { + // Getters + static get Default() { + return {}; + } + + static get DefaultType() { + return {}; + } + + static get NAME() { + throw new Error('You have to implement the static method "NAME", for each component!'); + } + + _getConfig(config) { + config = this._mergeConfigObj(config); + config = this._configAfterMerge(config); + + this._typeCheckConfig(config); + + return config; + } + + _configAfterMerge(config) { + return config; + } + + _mergeConfigObj(config, element) { + const jsonConfig = index.isElement(element) ? Manipulator__default.default.getDataAttribute(element, 'config') : {}; // try to parse + + return { ...this.constructor.Default, + ...(typeof jsonConfig === 'object' ? jsonConfig : {}), + ...(index.isElement(element) ? Manipulator__default.default.getDataAttributes(element) : {}), + ...(typeof config === 'object' ? config : {}) + }; + } + + _typeCheckConfig(config, configTypes = this.constructor.DefaultType) { + for (const property of Object.keys(configTypes)) { + const expectedTypes = configTypes[property]; + const value = config[property]; + const valueType = index.isElement(value) ? 'element' : index.toType(value); + + if (!new RegExp(expectedTypes).test(valueType)) { + throw new TypeError(`${this.constructor.NAME.toUpperCase()}: Option "${property}" provided type "${valueType}" but expected type "${expectedTypes}".`); + } + } + } + + } + + return Config; + +})); diff --git a/assets/javascripts/bootstrap/util/focustrap.js b/assets/javascripts/bootstrap/util/focustrap.js new file mode 100644 index 0000000..7dee8f7 --- /dev/null +++ b/assets/javascripts/bootstrap/util/focustrap.js @@ -0,0 +1,129 @@ +/*! + * Bootstrap focustrap.js v5.2.0 (https://getbootstrap.com/) + * Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) + */ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('../dom/event-handler'), require('../dom/selector-engine'), require('./config')) : + typeof define === 'function' && define.amd ? define(['../dom/event-handler', '../dom/selector-engine', './config'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Focustrap = factory(global.EventHandler, global.SelectorEngine, global.Config)); +})(this, (function (EventHandler, SelectorEngine, Config) { 'use strict'; + + const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e }; + + const EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler); + const SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine); + const Config__default = /*#__PURE__*/_interopDefaultLegacy(Config); + + /** + * -------------------------------------------------------------------------- + * Bootstrap (v5.2.0): util/focustrap.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) + * -------------------------------------------------------------------------- + */ + /** + * Constants + */ + + const NAME = 'focustrap'; + const DATA_KEY = 'bs.focustrap'; + const EVENT_KEY = `.${DATA_KEY}`; + const EVENT_FOCUSIN = `focusin${EVENT_KEY}`; + const EVENT_KEYDOWN_TAB = `keydown.tab${EVENT_KEY}`; + const TAB_KEY = 'Tab'; + const TAB_NAV_FORWARD = 'forward'; + const TAB_NAV_BACKWARD = 'backward'; + const Default = { + autofocus: true, + trapElement: null // The element to trap focus inside of + + }; + const DefaultType = { + autofocus: 'boolean', + trapElement: 'element' + }; + /** + * Class definition + */ + + class FocusTrap extends Config__default.default { + constructor(config) { + super(); + this._config = this._getConfig(config); + this._isActive = false; + this._lastTabNavDirection = null; + } // Getters + + + static get Default() { + return Default; + } + + static get DefaultType() { + return DefaultType; + } + + static get NAME() { + return NAME; + } // Public + + + activate() { + if (this._isActive) { + return; + } + + if (this._config.autofocus) { + this._config.trapElement.focus(); + } + + EventHandler__default.default.off(document, EVENT_KEY); // guard against infinite focus loop + + EventHandler__default.default.on(document, EVENT_FOCUSIN, event => this._handleFocusin(event)); + EventHandler__default.default.on(document, EVENT_KEYDOWN_TAB, event => this._handleKeydown(event)); + this._isActive = true; + } + + deactivate() { + if (!this._isActive) { + return; + } + + this._isActive = false; + EventHandler__default.default.off(document, EVENT_KEY); + } // Private + + + _handleFocusin(event) { + const { + trapElement + } = this._config; + + if (event.target === document || event.target === trapElement || trapElement.contains(event.target)) { + return; + } + + const elements = SelectorEngine__default.default.focusableChildren(trapElement); + + if (elements.length === 0) { + trapElement.focus(); + } else if (this._lastTabNavDirection === TAB_NAV_BACKWARD) { + elements[elements.length - 1].focus(); + } else { + elements[0].focus(); + } + } + + _handleKeydown(event) { + if (event.key !== TAB_KEY) { + return; + } + + this._lastTabNavDirection = event.shiftKey ? TAB_NAV_BACKWARD : TAB_NAV_FORWARD; + } + + } + + return FocusTrap; + +})); diff --git a/assets/javascripts/bootstrap/util/index.js b/assets/javascripts/bootstrap/util/index.js new file mode 100644 index 0000000..b35a3b5 --- /dev/null +++ b/assets/javascripts/bootstrap/util/index.js @@ -0,0 +1,350 @@ +/*! + * Bootstrap index.js v5.2.0 (https://getbootstrap.com/) + * Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) + */ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Index = {})); +})(this, (function (exports) { 'use strict'; + + /** + * -------------------------------------------------------------------------- + * Bootstrap (v5.2.0): util/index.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) + * -------------------------------------------------------------------------- + */ + const MAX_UID = 1000000; + const MILLISECONDS_MULTIPLIER = 1000; + const TRANSITION_END = 'transitionend'; // Shout-out Angus Croll (https://goo.gl/pxwQGp) + + const toType = object => { + if (object === null || object === undefined) { + return `${object}`; + } + + return Object.prototype.toString.call(object).match(/\s([a-z]+)/i)[1].toLowerCase(); + }; + /** + * Public Util API + */ + + + const getUID = prefix => { + do { + prefix += Math.floor(Math.random() * MAX_UID); + } while (document.getElementById(prefix)); + + return prefix; + }; + + const getSelector = element => { + let selector = element.getAttribute('data-bs-target'); + + if (!selector || selector === '#') { + let hrefAttribute = element.getAttribute('href'); // The only valid content that could double as a selector are IDs or classes, + // so everything starting with `#` or `.`. If a "real" URL is used as the selector, + // `document.querySelector` will rightfully complain it is invalid. + // See https://github.com/twbs/bootstrap/issues/32273 + + if (!hrefAttribute || !hrefAttribute.includes('#') && !hrefAttribute.startsWith('.')) { + return null; + } // Just in case some CMS puts out a full URL with the anchor appended + + + if (hrefAttribute.includes('#') && !hrefAttribute.startsWith('#')) { + hrefAttribute = `#${hrefAttribute.split('#')[1]}`; + } + + selector = hrefAttribute && hrefAttribute !== '#' ? hrefAttribute.trim() : null; + } + + return selector; + }; + + const getSelectorFromElement = element => { + const selector = getSelector(element); + + if (selector) { + return document.querySelector(selector) ? selector : null; + } + + return null; + }; + + const getElementFromSelector = element => { + const selector = getSelector(element); + return selector ? document.querySelector(selector) : null; + }; + + const getTransitionDurationFromElement = element => { + if (!element) { + return 0; + } // Get transition-duration of the element + + + let { + transitionDuration, + transitionDelay + } = window.getComputedStyle(element); + const floatTransitionDuration = Number.parseFloat(transitionDuration); + const floatTransitionDelay = Number.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 (Number.parseFloat(transitionDuration) + Number.parseFloat(transitionDelay)) * MILLISECONDS_MULTIPLIER; + }; + + const triggerTransitionEnd = element => { + element.dispatchEvent(new Event(TRANSITION_END)); + }; + + const isElement = object => { + if (!object || typeof object !== 'object') { + return false; + } + + if (typeof object.jquery !== 'undefined') { + object = object[0]; + } + + return typeof object.nodeType !== 'undefined'; + }; + + const getElement = object => { + // it's a jQuery object or a node element + if (isElement(object)) { + return object.jquery ? object[0] : object; + } + + if (typeof object === 'string' && object.length > 0) { + return document.querySelector(object); + } + + return null; + }; + + const isVisible = element => { + if (!isElement(element) || element.getClientRects().length === 0) { + return false; + } + + const elementIsVisible = getComputedStyle(element).getPropertyValue('visibility') === 'visible'; // Handle `details` element as its content may falsie appear visible when it is closed + + const closedDetails = element.closest('details:not([open])'); + + if (!closedDetails) { + return elementIsVisible; + } + + if (closedDetails !== element) { + const summary = element.closest('summary'); + + if (summary && summary.parentNode !== closedDetails) { + return false; + } + + if (summary === null) { + return false; + } + } + + return elementIsVisible; + }; + + const isDisabled = element => { + if (!element || element.nodeType !== Node.ELEMENT_NODE) { + return true; + } + + if (element.classList.contains('disabled')) { + return true; + } + + if (typeof element.disabled !== 'undefined') { + return element.disabled; + } + + return element.hasAttribute('disabled') && element.getAttribute('disabled') !== 'false'; + }; + + const 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 findShadowRoot(element.parentNode); + }; + + const noop = () => {}; + /** + * Trick to restart an element's animation + * + * @param {HTMLElement} element + * @return void + * + * @see https://www.charistheo.io/blog/2021/02/restart-a-css-animation-with-javascript/#restarting-a-css-animation + */ + + + const reflow = element => { + element.offsetHeight; // eslint-disable-line no-unused-expressions + }; + + const getjQuery = () => { + if (window.jQuery && !document.body.hasAttribute('data-bs-no-jquery')) { + return window.jQuery; + } + + return null; + }; + + const DOMContentLoadedCallbacks = []; + + const onDOMContentLoaded = callback => { + if (document.readyState === 'loading') { + // add listener on the first call when the document is in loading state + if (!DOMContentLoadedCallbacks.length) { + document.addEventListener('DOMContentLoaded', () => { + for (const callback of DOMContentLoadedCallbacks) { + callback(); + } + }); + } + + DOMContentLoadedCallbacks.push(callback); + } else { + callback(); + } + }; + + const isRTL = () => document.documentElement.dir === 'rtl'; + + const defineJQueryPlugin = plugin => { + onDOMContentLoaded(() => { + const $ = getjQuery(); + /* istanbul ignore if */ + + if ($) { + const name = plugin.NAME; + const JQUERY_NO_CONFLICT = $.fn[name]; + $.fn[name] = plugin.jQueryInterface; + $.fn[name].Constructor = plugin; + + $.fn[name].noConflict = () => { + $.fn[name] = JQUERY_NO_CONFLICT; + return plugin.jQueryInterface; + }; + } + }); + }; + + const execute = callback => { + if (typeof callback === 'function') { + callback(); + } + }; + + const executeAfterTransition = (callback, transitionElement, waitForTransition = true) => { + if (!waitForTransition) { + execute(callback); + return; + } + + const durationPadding = 5; + const emulatedDuration = getTransitionDurationFromElement(transitionElement) + durationPadding; + let called = false; + + const handler = ({ + target + }) => { + if (target !== transitionElement) { + return; + } + + called = true; + transitionElement.removeEventListener(TRANSITION_END, handler); + execute(callback); + }; + + transitionElement.addEventListener(TRANSITION_END, handler); + setTimeout(() => { + if (!called) { + triggerTransitionEnd(transitionElement); + } + }, emulatedDuration); + }; + /** + * Return the previous/next element of a list. + * + * @param {array} list The list of elements + * @param activeElement The active element + * @param shouldGetNext Choose to get next or previous element + * @param isCycleAllowed + * @return {Element|elem} The proper element + */ + + + const getNextActiveElement = (list, activeElement, shouldGetNext, isCycleAllowed) => { + const listLength = list.length; + 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 + + if (index === -1) { + return !shouldGetNext && isCycleAllowed ? list[listLength - 1] : list[0]; + } + + index += shouldGetNext ? 1 : -1; + + if (isCycleAllowed) { + index = (index + listLength) % listLength; + } + + return list[Math.max(0, Math.min(index, listLength - 1))]; + }; + + exports.defineJQueryPlugin = defineJQueryPlugin; + exports.execute = execute; + exports.executeAfterTransition = executeAfterTransition; + exports.findShadowRoot = findShadowRoot; + exports.getElement = getElement; + exports.getElementFromSelector = getElementFromSelector; + exports.getNextActiveElement = getNextActiveElement; + exports.getSelectorFromElement = getSelectorFromElement; + exports.getTransitionDurationFromElement = getTransitionDurationFromElement; + exports.getUID = getUID; + exports.getjQuery = getjQuery; + exports.isDisabled = isDisabled; + exports.isElement = isElement; + exports.isRTL = isRTL; + exports.isVisible = isVisible; + exports.noop = noop; + exports.onDOMContentLoaded = onDOMContentLoaded; + exports.reflow = reflow; + exports.toType = toType; + exports.triggerTransitionEnd = triggerTransitionEnd; + + Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } }); + +})); diff --git a/assets/javascripts/bootstrap/util/sanitizer.js b/assets/javascripts/bootstrap/util/sanitizer.js new file mode 100644 index 0000000..b9c8683 --- /dev/null +++ b/assets/javascripts/bootstrap/util/sanitizer.js @@ -0,0 +1,122 @@ +/*! + * Bootstrap sanitizer.js v5.2.0 (https://getbootstrap.com/) + * Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) + */ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Sanitizer = {})); +})(this, (function (exports) { 'use strict'; + + /** + * -------------------------------------------------------------------------- + * Bootstrap (v5.2.0): util/sanitizer.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) + * -------------------------------------------------------------------------- + */ + const uriAttributes = new Set(['background', 'cite', 'href', 'itemtype', 'longdesc', 'poster', 'src', 'xlink:href']); + const ARIA_ATTRIBUTE_PATTERN = /^aria-[\w-]*$/i; + /** + * A pattern that recognizes a commonly useful subset of URLs that are safe. + * + * Shout-out to Angular https://github.com/angular/angular/blob/12.2.x/packages/core/src/sanitization/url_sanitizer.ts + */ + + const SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file|sms):|[^#&/:?]*(?:[#/?]|$))/i; + /** + * A pattern that matches safe data URLs. Only matches image, video and audio types. + * + * Shout-out to Angular https://github.com/angular/angular/blob/12.2.x/packages/core/src/sanitization/url_sanitizer.ts + */ + + const DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[\d+/a-z]+=*$/i; + + const allowedAttribute = (attribute, allowedAttributeList) => { + const attributeName = attribute.nodeName.toLowerCase(); + + if (allowedAttributeList.includes(attributeName)) { + if (uriAttributes.has(attributeName)) { + return Boolean(SAFE_URL_PATTERN.test(attribute.nodeValue) || DATA_URL_PATTERN.test(attribute.nodeValue)); + } + + return true; + } // Check if a regular expression validates the attribute. + + + return allowedAttributeList.filter(attributeRegex => attributeRegex instanceof RegExp).some(regex => regex.test(attributeName)); + }; + + const DefaultAllowlist = { + // Global attributes allowed on any supplied element below. + '*': ['class', 'dir', 'id', 'lang', 'role', ARIA_ATTRIBUTE_PATTERN], + a: ['target', 'href', 'title', 'rel'], + area: [], + b: [], + br: [], + col: [], + code: [], + div: [], + em: [], + hr: [], + h1: [], + h2: [], + h3: [], + h4: [], + h5: [], + h6: [], + i: [], + img: ['src', 'srcset', 'alt', 'title', 'width', 'height'], + li: [], + ol: [], + p: [], + pre: [], + s: [], + small: [], + span: [], + sub: [], + sup: [], + strong: [], + u: [], + ul: [] + }; + function sanitizeHtml(unsafeHtml, allowList, sanitizeFunction) { + if (!unsafeHtml.length) { + return unsafeHtml; + } + + if (sanitizeFunction && typeof sanitizeFunction === 'function') { + return sanitizeFunction(unsafeHtml); + } + + const domParser = new window.DOMParser(); + const createdDocument = domParser.parseFromString(unsafeHtml, 'text/html'); + const elements = [].concat(...createdDocument.body.querySelectorAll('*')); + + for (const element of elements) { + const elementName = element.nodeName.toLowerCase(); + + if (!Object.keys(allowList).includes(elementName)) { + element.remove(); + continue; + } + + const attributeList = [].concat(...element.attributes); + const allowedAttributes = [].concat(allowList['*'] || [], allowList[elementName] || []); + + for (const attribute of attributeList) { + if (!allowedAttribute(attribute, allowedAttributes)) { + element.removeAttribute(attribute.nodeName); + } + } + } + + return createdDocument.body.innerHTML; + } + + exports.DefaultAllowlist = DefaultAllowlist; + exports.sanitizeHtml = sanitizeHtml; + + Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: 'Module' } }); + +})); diff --git a/assets/javascripts/bootstrap/util/scrollbar.js b/assets/javascripts/bootstrap/util/scrollbar.js new file mode 100644 index 0000000..2607f94 --- /dev/null +++ b/assets/javascripts/bootstrap/util/scrollbar.js @@ -0,0 +1,138 @@ +/*! + * Bootstrap scrollbar.js v5.2.0 (https://getbootstrap.com/) + * Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) + */ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('../dom/selector-engine'), require('../dom/manipulator'), require('./index')) : + typeof define === 'function' && define.amd ? define(['../dom/selector-engine', '../dom/manipulator', './index'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Scrollbar = factory(global.SelectorEngine, global.Manipulator, global.Index)); +})(this, (function (SelectorEngine, Manipulator, index) { 'use strict'; + + const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e }; + + const SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine); + const Manipulator__default = /*#__PURE__*/_interopDefaultLegacy(Manipulator); + + /** + * -------------------------------------------------------------------------- + * Bootstrap (v5.2.0): util/scrollBar.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) + * -------------------------------------------------------------------------- + */ + /** + * Constants + */ + + const SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top'; + const SELECTOR_STICKY_CONTENT = '.sticky-top'; + const PROPERTY_PADDING = 'padding-right'; + const PROPERTY_MARGIN = 'margin-right'; + /** + * Class definition + */ + + class ScrollBarHelper { + constructor() { + this._element = document.body; + } // Public + + + getWidth() { + // https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes + const documentWidth = document.documentElement.clientWidth; + return Math.abs(window.innerWidth - documentWidth); + } + + hide() { + const width = this.getWidth(); + + this._disableOverFlow(); // give padding to element to balance the hidden scrollbar width + + + this._setElementAttributes(this._element, PROPERTY_PADDING, calculatedValue => calculatedValue + width); // trick: We adjust positive paddingRight and negative marginRight to sticky-top elements to keep showing fullwidth + + + this._setElementAttributes(SELECTOR_FIXED_CONTENT, PROPERTY_PADDING, calculatedValue => calculatedValue + width); + + this._setElementAttributes(SELECTOR_STICKY_CONTENT, PROPERTY_MARGIN, calculatedValue => calculatedValue - width); + } + + reset() { + this._resetElementAttributes(this._element, 'overflow'); + + this._resetElementAttributes(this._element, PROPERTY_PADDING); + + this._resetElementAttributes(SELECTOR_FIXED_CONTENT, PROPERTY_PADDING); + + this._resetElementAttributes(SELECTOR_STICKY_CONTENT, PROPERTY_MARGIN); + } + + isOverflowing() { + return this.getWidth() > 0; + } // Private + + + _disableOverFlow() { + this._saveInitialAttribute(this._element, 'overflow'); + + this._element.style.overflow = 'hidden'; + } + + _setElementAttributes(selector, styleProperty, callback) { + const scrollbarWidth = this.getWidth(); + + const manipulationCallBack = element => { + if (element !== this._element && window.innerWidth > element.clientWidth + scrollbarWidth) { + return; + } + + this._saveInitialAttribute(element, styleProperty); + + const calculatedValue = window.getComputedStyle(element).getPropertyValue(styleProperty); + element.style.setProperty(styleProperty, `${callback(Number.parseFloat(calculatedValue))}px`); + }; + + this._applyManipulationCallback(selector, manipulationCallBack); + } + + _saveInitialAttribute(element, styleProperty) { + const actualValue = element.style.getPropertyValue(styleProperty); + + if (actualValue) { + Manipulator__default.default.setDataAttribute(element, styleProperty, actualValue); + } + } + + _resetElementAttributes(selector, styleProperty) { + const manipulationCallBack = element => { + const value = Manipulator__default.default.getDataAttribute(element, styleProperty); // We only want to remove the property if the value is `null`; the value can also be zero + + if (value === null) { + element.style.removeProperty(styleProperty); + return; + } + + Manipulator__default.default.removeDataAttribute(element, styleProperty); + element.style.setProperty(styleProperty, value); + }; + + this._applyManipulationCallback(selector, manipulationCallBack); + } + + _applyManipulationCallback(selector, callBack) { + if (index.isElement(selector)) { + callBack(selector); + return; + } + + for (const sel of SelectorEngine__default.default.find(selector, this._element)) { + callBack(sel); + } + } + + } + + return ScrollBarHelper; + +})); diff --git a/assets/javascripts/bootstrap/util/swipe.js b/assets/javascripts/bootstrap/util/swipe.js new file mode 100644 index 0000000..8fe2711 --- /dev/null +++ b/assets/javascripts/bootstrap/util/swipe.js @@ -0,0 +1,155 @@ +/*! + * Bootstrap swipe.js v5.2.0 (https://getbootstrap.com/) + * Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) + */ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./config'), require('../dom/event-handler'), require('./index')) : + typeof define === 'function' && define.amd ? define(['./config', '../dom/event-handler', './index'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.Swipe = factory(global.Config, global.EventHandler, global.Index)); +})(this, (function (Config, EventHandler, index) { 'use strict'; + + const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e }; + + const Config__default = /*#__PURE__*/_interopDefaultLegacy(Config); + const EventHandler__default = /*#__PURE__*/_interopDefaultLegacy(EventHandler); + + /** + * -------------------------------------------------------------------------- + * Bootstrap (v5.2.0): util/swipe.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) + * -------------------------------------------------------------------------- + */ + /** + * Constants + */ + + const NAME = 'swipe'; + const EVENT_KEY = '.bs.swipe'; + const EVENT_TOUCHSTART = `touchstart${EVENT_KEY}`; + const EVENT_TOUCHMOVE = `touchmove${EVENT_KEY}`; + const EVENT_TOUCHEND = `touchend${EVENT_KEY}`; + const EVENT_POINTERDOWN = `pointerdown${EVENT_KEY}`; + const EVENT_POINTERUP = `pointerup${EVENT_KEY}`; + const POINTER_TYPE_TOUCH = 'touch'; + const POINTER_TYPE_PEN = 'pen'; + const CLASS_NAME_POINTER_EVENT = 'pointer-event'; + const SWIPE_THRESHOLD = 40; + const Default = { + endCallback: null, + leftCallback: null, + rightCallback: null + }; + const DefaultType = { + endCallback: '(function|null)', + leftCallback: '(function|null)', + rightCallback: '(function|null)' + }; + /** + * Class definition + */ + + class Swipe extends Config__default.default { + constructor(element, config) { + super(); + this._element = element; + + if (!element || !Swipe.isSupported()) { + return; + } + + this._config = this._getConfig(config); + this._deltaX = 0; + this._supportPointerEvents = Boolean(window.PointerEvent); + + this._initEvents(); + } // Getters + + + static get Default() { + return Default; + } + + static get DefaultType() { + return DefaultType; + } + + static get NAME() { + return NAME; + } // Public + + + dispose() { + EventHandler__default.default.off(this._element, EVENT_KEY); + } // Private + + + _start(event) { + if (!this._supportPointerEvents) { + this._deltaX = event.touches[0].clientX; + return; + } + + if (this._eventIsPointerPenTouch(event)) { + this._deltaX = event.clientX; + } + } + + _end(event) { + if (this._eventIsPointerPenTouch(event)) { + this._deltaX = event.clientX - this._deltaX; + } + + this._handleSwipe(); + + index.execute(this._config.endCallback); + } + + _move(event) { + this._deltaX = event.touches && event.touches.length > 1 ? 0 : event.touches[0].clientX - this._deltaX; + } + + _handleSwipe() { + const absDeltaX = Math.abs(this._deltaX); + + if (absDeltaX <= SWIPE_THRESHOLD) { + return; + } + + const direction = absDeltaX / this._deltaX; + this._deltaX = 0; + + if (!direction) { + return; + } + + index.execute(direction > 0 ? this._config.rightCallback : this._config.leftCallback); + } + + _initEvents() { + if (this._supportPointerEvents) { + EventHandler__default.default.on(this._element, EVENT_POINTERDOWN, event => this._start(event)); + EventHandler__default.default.on(this._element, EVENT_POINTERUP, event => this._end(event)); + + this._element.classList.add(CLASS_NAME_POINTER_EVENT); + } else { + EventHandler__default.default.on(this._element, EVENT_TOUCHSTART, event => this._start(event)); + EventHandler__default.default.on(this._element, EVENT_TOUCHMOVE, event => this._move(event)); + EventHandler__default.default.on(this._element, EVENT_TOUCHEND, event => this._end(event)); + } + } + + _eventIsPointerPenTouch(event) { + return this._supportPointerEvents && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH); + } // Static + + + static isSupported() { + return 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0; + } + + } + + return Swipe; + +})); diff --git a/assets/javascripts/bootstrap/util/template-factory.js b/assets/javascripts/bootstrap/util/template-factory.js new file mode 100644 index 0000000..f1f8b50 --- /dev/null +++ b/assets/javascripts/bootstrap/util/template-factory.js @@ -0,0 +1,177 @@ +/*! + * Bootstrap template-factory.js v5.2.0 (https://getbootstrap.com/) + * Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors) + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) + */ +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('./sanitizer'), require('./index'), require('../dom/selector-engine'), require('./config')) : + typeof define === 'function' && define.amd ? define(['./sanitizer', './index', '../dom/selector-engine', './config'], factory) : + (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.TemplateFactory = factory(global.Sanitizer, global.Index, global.SelectorEngine, global.Config)); +})(this, (function (sanitizer, index, SelectorEngine, Config) { 'use strict'; + + const _interopDefaultLegacy = e => e && typeof e === 'object' && 'default' in e ? e : { default: e }; + + const SelectorEngine__default = /*#__PURE__*/_interopDefaultLegacy(SelectorEngine); + const Config__default = /*#__PURE__*/_interopDefaultLegacy(Config); + + /** + * -------------------------------------------------------------------------- + * Bootstrap (v5.2.0): util/template-factory.js + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) + * -------------------------------------------------------------------------- + */ + /** + * Constants + */ + + const NAME = 'TemplateFactory'; + const Default = { + allowList: sanitizer.DefaultAllowlist, + content: {}, + // { selector : text , selector2 : text2 , } + extraClass: '', + html: false, + sanitize: true, + sanitizeFn: null, + template: '<div></div>' + }; + const DefaultType = { + allowList: 'object', + content: 'object', + extraClass: '(string|function)', + html: 'boolean', + sanitize: 'boolean', + sanitizeFn: '(null|function)', + template: 'string' + }; + const DefaultContentType = { + entry: '(string|element|function|null)', + selector: '(string|element)' + }; + /** + * Class definition + */ + + class TemplateFactory extends Config__default.default { + constructor(config) { + super(); + this._config = this._getConfig(config); + } // Getters + + + static get Default() { + return Default; + } + + static get DefaultType() { + return DefaultType; + } + + static get NAME() { + return NAME; + } // Public + + + getContent() { + return Object.values(this._config.content).map(config => this._resolvePossibleFunction(config)).filter(Boolean); + } + + hasContent() { + return this.getContent().length > 0; + } + + changeContent(content) { + this._checkContent(content); + + this._config.content = { ...this._config.content, + ...content + }; + return this; + } + + toHtml() { + const templateWrapper = document.createElement('div'); + templateWrapper.innerHTML = this._maybeSanitize(this._config.template); + + for (const [selector, text] of Object.entries(this._config.content)) { + this._setContent(templateWrapper, text, selector); + } + + const template = templateWrapper.children[0]; + + const extraClass = this._resolvePossibleFunction(this._config.extraClass); + + if (extraClass) { + template.classList.add(...extraClass.split(' ')); + } + + return template; + } // Private + + + _typeCheckConfig(config) { + super._typeCheckConfig(config); + + this._checkContent(config.content); + } + + _checkContent(arg) { + for (const [selector, content] of Object.entries(arg)) { + super._typeCheckConfig({ + selector, + entry: content + }, DefaultContentType); + } + } + + _setContent(template, content, selector) { + const templateElement = SelectorEngine__default.default.findOne(selector, template); + + if (!templateElement) { + return; + } + + content = this._resolvePossibleFunction(content); + + if (!content) { + templateElement.remove(); + return; + } + + if (index.isElement(content)) { + this._putElementInTemplate(index.getElement(content), templateElement); + + return; + } + + if (this._config.html) { + templateElement.innerHTML = this._maybeSanitize(content); + return; + } + + templateElement.textContent = content; + } + + _maybeSanitize(arg) { + return this._config.sanitize ? sanitizer.sanitizeHtml(arg, this._config.allowList, this._config.sanitizeFn) : arg; + } + + _resolvePossibleFunction(arg) { + return typeof arg === 'function' ? arg(this) : arg; + } + + _putElementInTemplate(element, templateElement) { + if (this._config.html) { + templateElement.innerHTML = ''; + templateElement.append(element); + return; + } + + templateElement.textContent = element.textContent; + } + + } + + return TemplateFactory; + +})); diff --git a/assets/stylesheets/_bootstrap-grid.scss b/assets/stylesheets/_bootstrap-grid.scss index c4830a7..24a8bdb 100644 --- a/assets/stylesheets/_bootstrap-grid.scss +++ b/assets/stylesheets/_bootstrap-grid.scss @@ -1,14 +1,11 @@ -/*! - * Bootstrap Grid v5.1.3 (https://getbootstrap.com/) - * Copyright 2011-2021 The Bootstrap Authors - * Copyright 2011-2021 Twitter, Inc. - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) - */ +@import "bootstrap/mixins/banner"; +@include bsBanner(Grid); $include-column-box-sizing: true !default; @import "bootstrap/functions"; @import "bootstrap/variables"; +@import "bootstrap/maps"; @import "bootstrap/mixins/lists"; @import "bootstrap/mixins/breakpoints"; diff --git a/assets/stylesheets/_bootstrap-reboot.scss b/assets/stylesheets/_bootstrap-reboot.scss index 6596b91..c13af02 100644 --- a/assets/stylesheets/_bootstrap-reboot.scss +++ b/assets/stylesheets/_bootstrap-reboot.scss @@ -1,13 +1,9 @@ -/*! - * Bootstrap Reboot v5.1.3 (https://getbootstrap.com/) - * Copyright 2011-2021 The Bootstrap Authors - * Copyright 2011-2021 Twitter, Inc. - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) - * Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md) - */ +@import "bootstrap/mixins/banner"; +@include bsBanner(Reboot); @import "bootstrap/functions"; @import "bootstrap/variables"; +@import "bootstrap/maps"; @import "bootstrap/mixins"; @import "bootstrap/root"; @import "bootstrap/reboot"; diff --git a/assets/stylesheets/_bootstrap.scss b/assets/stylesheets/_bootstrap.scss index 713f127..48439c3 100644 --- a/assets/stylesheets/_bootstrap.scss +++ b/assets/stylesheets/_bootstrap.scss @@ -1,14 +1,12 @@ -/*! - * Bootstrap v5.1.3 (https://getbootstrap.com/) - * Copyright 2011-2021 The Bootstrap Authors - * Copyright 2011-2021 Twitter, Inc. - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) - */ +@import "bootstrap/mixins/banner"; +@include bsBanner(""); + // scss-docs-start import-stack // Configuration @import "bootstrap/functions"; @import "bootstrap/variables"; +@import "bootstrap/maps"; @import "bootstrap/mixins"; @import "bootstrap/utilities"; diff --git a/assets/stylesheets/bootstrap/_accordion.scss b/assets/stylesheets/bootstrap/_accordion.scss index fc62ceb..b306540 100644 --- a/assets/stylesheets/bootstrap/_accordion.scss +++ b/assets/stylesheets/bootstrap/_accordion.scss @@ -2,43 +2,70 @@ // Base styles // +.accordion { + // scss-docs-start accordion-css-vars + --#{$prefix}accordion-color: #{color-contrast($accordion-bg)}; + --#{$prefix}accordion-bg: #{$accordion-bg}; + --#{$prefix}accordion-transition: #{$accordion-transition}; + --#{$prefix}accordion-border-color: #{$accordion-border-color}; + --#{$prefix}accordion-border-width: #{$accordion-border-width}; + --#{$prefix}accordion-border-radius: #{$accordion-border-radius}; + --#{$prefix}accordion-inner-border-radius: #{$accordion-inner-border-radius}; + --#{$prefix}accordion-btn-padding-x: #{$accordion-button-padding-x}; + --#{$prefix}accordion-btn-padding-y: #{$accordion-button-padding-y}; + --#{$prefix}accordion-btn-color: #{$accordion-color}; + --#{$prefix}accordion-btn-bg: #{$accordion-button-bg}; + --#{$prefix}accordion-btn-icon: #{escape-svg($accordion-button-icon)}; + --#{$prefix}accordion-btn-icon-width: #{$accordion-icon-width}; + --#{$prefix}accordion-btn-icon-transform: #{$accordion-icon-transform}; + --#{$prefix}accordion-btn-icon-transition: #{$accordion-icon-transition}; + --#{$prefix}accordion-btn-active-icon: #{escape-svg($accordion-button-active-icon)}; + --#{$prefix}accordion-btn-focus-border-color: #{$accordion-button-focus-border-color}; + --#{$prefix}accordion-btn-focus-box-shadow: #{$accordion-button-focus-box-shadow}; + --#{$prefix}accordion-body-padding-x: #{$accordion-body-padding-x}; + --#{$prefix}accordion-body-padding-y: #{$accordion-body-padding-y}; + --#{$prefix}accordion-active-color: #{$accordion-button-active-color}; + --#{$prefix}accordion-active-bg: #{$accordion-button-active-bg}; + // scss-docs-end accordion-css-vars +} + .accordion-button { position: relative; display: flex; align-items: center; width: 100%; - padding: $accordion-button-padding-y $accordion-button-padding-x; + padding: var(--#{$prefix}accordion-btn-padding-y) var(--#{$prefix}accordion-btn-padding-x); @include font-size($font-size-base); - color: $accordion-button-color; + color: var(--#{$prefix}accordion-btn-color); text-align: left; // Reset button style - background-color: $accordion-button-bg; + background-color: var(--#{$prefix}accordion-btn-bg); border: 0; @include border-radius(0); overflow-anchor: none; - @include transition($accordion-transition); + @include transition(var(--#{$prefix}accordion-transition)); &:not(.collapsed) { - color: $accordion-button-active-color; - background-color: $accordion-button-active-bg; - box-shadow: inset 0 ($accordion-border-width * -1) 0 $accordion-border-color; + color: var(--#{$prefix}accordion-active-color); + background-color: var(--#{$prefix}accordion-active-bg); + box-shadow: inset 0 calc(var(--#{$prefix}accordion-border-width) * -1) 0 var(--#{$prefix}accordion-border-color); // stylelint-disable-line function-disallowed-list &::after { - background-image: escape-svg($accordion-button-active-icon); - transform: $accordion-icon-transform; + background-image: var(--#{$prefix}accordion-btn-active-icon); + transform: var(--#{$prefix}accordion-btn-icon-transform); } } // Accordion icon &::after { flex-shrink: 0; - width: $accordion-icon-width; - height: $accordion-icon-width; + width: var(--#{$prefix}accordion-btn-icon-width); + height: var(--#{$prefix}accordion-btn-icon-width); margin-left: auto; content: ""; - background-image: escape-svg($accordion-button-icon); + background-image: var(--#{$prefix}accordion-btn-icon); background-repeat: no-repeat; - background-size: $accordion-icon-width; - @include transition($accordion-icon-transition); + background-size: var(--#{$prefix}accordion-btn-icon-width); + @include transition(var(--#{$prefix}accordion-btn-icon-transition)); } &:hover { @@ -47,9 +74,9 @@ &:focus { z-index: 3; - border-color: $accordion-button-focus-border-color; + border-color: var(--#{$prefix}accordion-btn-focus-border-color); outline: 0; - box-shadow: $accordion-button-focus-box-shadow; + box-shadow: var(--#{$prefix}accordion-btn-focus-box-shadow); } } @@ -58,14 +85,15 @@ } .accordion-item { - background-color: $accordion-bg; - border: $accordion-border-width solid $accordion-border-color; + color: var(--#{$prefix}accordion-color); + background-color: var(--#{$prefix}accordion-bg); + border: var(--#{$prefix}accordion-border-width) solid var(--#{$prefix}accordion-border-color); &:first-of-type { - @include border-top-radius($accordion-border-radius); + @include border-top-radius(var(--#{$prefix}accordion-border-radius)); .accordion-button { - @include border-top-radius($accordion-inner-border-radius); + @include border-top-radius(var(--#{$prefix}accordion-inner-border-radius)); } } @@ -75,22 +103,22 @@ // Only set a border-radius on the last item if the accordion is collapsed &:last-of-type { - @include border-bottom-radius($accordion-border-radius); + @include border-bottom-radius(var(--#{$prefix}accordion-border-radius)); .accordion-button { &.collapsed { - @include border-bottom-radius($accordion-inner-border-radius); + @include border-bottom-radius(var(--#{$prefix}accordion-inner-border-radius)); } } .accordion-collapse { - @include border-bottom-radius($accordion-border-radius); + @include border-bottom-radius(var(--#{$prefix}accordion-border-radius)); } } } .accordion-body { - padding: $accordion-body-padding-y $accordion-body-padding-x; + padding: var(--#{$prefix}accordion-body-padding-y) var(--#{$prefix}accordion-body-padding-x); } diff --git a/assets/stylesheets/bootstrap/_alert.scss b/assets/stylesheets/bootstrap/_alert.scss index 34f1e84..c8bc91b 100644 --- a/assets/stylesheets/bootstrap/_alert.scss +++ b/assets/stylesheets/bootstrap/_alert.scss @@ -3,11 +3,24 @@ // .alert { + // scss-docs-start alert-css-vars + --#{$prefix}alert-bg: transparent; + --#{$prefix}alert-padding-x: #{$alert-padding-x}; + --#{$prefix}alert-padding-y: #{$alert-padding-y}; + --#{$prefix}alert-margin-bottom: #{$alert-margin-bottom}; + --#{$prefix}alert-color: inherit; + --#{$prefix}alert-border-color: transparent; + --#{$prefix}alert-border: #{$alert-border-width} solid var(--#{$prefix}alert-border-color); + --#{$prefix}alert-border-radius: #{$alert-border-radius}; + // scss-docs-end alert-css-vars + position: relative; - padding: $alert-padding-y $alert-padding-x; - margin-bottom: $alert-margin-bottom; - border: $alert-border-width solid transparent; - @include border-radius($alert-border-radius); + padding: var(--#{$prefix}alert-padding-y) var(--#{$prefix}alert-padding-x); + margin-bottom: var(--#{$prefix}alert-margin-bottom); + color: var(--#{$prefix}alert-color); + background-color: var(--#{$prefix}alert-bg); + border: var(--#{$prefix}alert-border); + @include border-radius(var(--#{$prefix}alert-border-radius)); } // Headings for larger alerts @@ -47,6 +60,7 @@ $alert-background: shift-color($value, $alert-bg-scale); $alert-border: shift-color($value, $alert-border-scale); $alert-color: shift-color($value, $alert-color-scale); + @if (contrast-ratio($alert-background, $alert-color) < $min-contrast-ratio) { $alert-color: mix($value, color-contrast($alert-background), abs($alert-color-scale)); } diff --git a/assets/stylesheets/bootstrap/_badge.scss b/assets/stylesheets/bootstrap/_badge.scss index 08df1b8..cc3d269 100644 --- a/assets/stylesheets/bootstrap/_badge.scss +++ b/assets/stylesheets/bootstrap/_badge.scss @@ -4,16 +4,25 @@ // `background-color`. .badge { + // scss-docs-start badge-css-vars + --#{$prefix}badge-padding-x: #{$badge-padding-x}; + --#{$prefix}badge-padding-y: #{$badge-padding-y}; + @include rfs($badge-font-size, --#{$prefix}badge-font-size); + --#{$prefix}badge-font-weight: #{$badge-font-weight}; + --#{$prefix}badge-color: #{$badge-color}; + --#{$prefix}badge-border-radius: #{$badge-border-radius}; + // scss-docs-end badge-css-vars + display: inline-block; - padding: $badge-padding-y $badge-padding-x; - @include font-size($badge-font-size); - font-weight: $badge-font-weight; + padding: var(--#{$prefix}badge-padding-y) var(--#{$prefix}badge-padding-x); + @include font-size(var(--#{$prefix}badge-font-size)); + font-weight: var(--#{$prefix}badge-font-weight); line-height: 1; - color: $badge-color; + color: var(--#{$prefix}badge-color); text-align: center; white-space: nowrap; vertical-align: baseline; - @include border-radius($badge-border-radius); + @include border-radius(var(--#{$prefix}badge-border-radius)); @include gradient-bg(); // Empty badges collapse automatically diff --git a/assets/stylesheets/bootstrap/_breadcrumb.scss b/assets/stylesheets/bootstrap/_breadcrumb.scss index f7fafe7..b8252ff 100644 --- a/assets/stylesheets/bootstrap/_breadcrumb.scss +++ b/assets/stylesheets/bootstrap/_breadcrumb.scss @@ -1,28 +1,40 @@ .breadcrumb { + // scss-docs-start breadcrumb-css-vars + --#{$prefix}breadcrumb-padding-x: #{$breadcrumb-padding-x}; + --#{$prefix}breadcrumb-padding-y: #{$breadcrumb-padding-y}; + --#{$prefix}breadcrumb-margin-bottom: #{$breadcrumb-margin-bottom}; + @include rfs($breadcrumb-font-size, --#{$prefix}breadcrumb-font-size); + --#{$prefix}breadcrumb-bg: #{$breadcrumb-bg}; + --#{$prefix}breadcrumb-border-radius: #{$breadcrumb-border-radius}; + --#{$prefix}breadcrumb-divider-color: #{$breadcrumb-divider-color}; + --#{$prefix}breadcrumb-item-padding-x: #{$breadcrumb-item-padding-x}; + --#{$prefix}breadcrumb-item-active-color: #{$breadcrumb-active-color}; + // scss-docs-end breadcrumb-css-vars + display: flex; flex-wrap: wrap; - padding: $breadcrumb-padding-y $breadcrumb-padding-x; - margin-bottom: $breadcrumb-margin-bottom; - @include font-size($breadcrumb-font-size); + padding: var(--#{$prefix}breadcrumb-padding-y) var(--#{$prefix}breadcrumb-padding-x); + margin-bottom: var(--#{$prefix}breadcrumb-margin-bottom); + @include font-size(var(--#{$prefix}breadcrumb-font-size)); list-style: none; - background-color: $breadcrumb-bg; - @include border-radius($breadcrumb-border-radius); + background-color: var(--#{$prefix}breadcrumb-bg); + @include border-radius(var(--#{$prefix}breadcrumb-border-radius)); } .breadcrumb-item { // The separator between breadcrumbs (by default, a forward-slash: "/") + .breadcrumb-item { - padding-left: $breadcrumb-item-padding-x; + padding-left: var(--#{$prefix}breadcrumb-item-padding-x); &::before { float: left; // Suppress inline spacings and underlining of the separator - padding-right: $breadcrumb-item-padding-x; - color: $breadcrumb-divider-color; - content: var(--#{$variable-prefix}breadcrumb-divider, escape-svg($breadcrumb-divider)) #{"/* rtl:"} var(--#{$variable-prefix}breadcrumb-divider, escape-svg($breadcrumb-divider-flipped)) #{"*/"}; + padding-right: var(--#{$prefix}breadcrumb-item-padding-x); + color: var(--#{$prefix}breadcrumb-divider-color); + content: var(--#{$prefix}breadcrumb-divider, escape-svg($breadcrumb-divider)) #{"/* rtl:"} var(--#{$prefix}breadcrumb-divider, escape-svg($breadcrumb-divider-flipped)) #{"*/"}; } } &.active { - color: $breadcrumb-active-color; + color: var(--#{$prefix}breadcrumb-item-active-color); } } diff --git a/assets/stylesheets/bootstrap/_button-group.scss b/assets/stylesheets/bootstrap/_button-group.scss index 13aa056..f78b8c1 100644 --- a/assets/stylesheets/bootstrap/_button-group.scss +++ b/assets/stylesheets/bootstrap/_button-group.scss @@ -34,6 +34,8 @@ } .btn-group { + @include border-radius($btn-border-radius); + // Prevent double borders when buttons are next to each other > .btn:not(:first-child), > .btn-group:not(:first-child) { @@ -42,6 +44,7 @@ // Reset rounded corners > .btn:not(:last-child):not(.dropdown-toggle), + > .btn.dropdown-toggle-split:first-child, > .btn-group:not(:last-child) > .btn { @include border-end-radius(0); } diff --git a/assets/stylesheets/bootstrap/_buttons.scss b/assets/stylesheets/bootstrap/_buttons.scss index ee4287c..044b8d6 100644 --- a/assets/stylesheets/bootstrap/_buttons.scss +++ b/assets/stylesheets/bootstrap/_buttons.scss @@ -3,49 +3,94 @@ // .btn { + // scss-docs-start btn-css-vars + --#{$prefix}btn-padding-x: #{$btn-padding-x}; + --#{$prefix}btn-padding-y: #{$btn-padding-y}; + --#{$prefix}btn-font-family: #{$btn-font-family}; + @include rfs($btn-font-size, --#{$prefix}btn-font-size); + --#{$prefix}btn-font-weight: #{$btn-font-weight}; + --#{$prefix}btn-line-height: #{$btn-line-height}; + --#{$prefix}btn-color: #{$body-color}; + --#{$prefix}btn-bg: transparent; + --#{$prefix}btn-border-width: #{$btn-border-width}; + --#{$prefix}btn-border-color: transparent; + --#{$prefix}btn-border-radius: #{$btn-border-radius}; + --#{$prefix}btn-box-shadow: #{$btn-box-shadow}; + --#{$prefix}btn-disabled-opacity: #{$btn-disabled-opacity}; + --#{$prefix}btn-focus-box-shadow: 0 0 0 #{$btn-focus-width} rgba(var(--#{$prefix}btn-focus-shadow-rgb), .5); + // scss-docs-end btn-css-vars + display: inline-block; - font-family: $btn-font-family; - font-weight: $btn-font-weight; - line-height: $btn-line-height; - color: $body-color; + padding: var(--#{$prefix}btn-padding-y) var(--#{$prefix}btn-padding-x); + font-family: var(--#{$prefix}btn-font-family); + @include font-size(var(--#{$prefix}btn-font-size)); + font-weight: var(--#{$prefix}btn-font-weight); + line-height: var(--#{$prefix}btn-line-height); + color: var(--#{$prefix}btn-color); text-align: center; text-decoration: if($link-decoration == none, null, none); white-space: $btn-white-space; vertical-align: middle; cursor: if($enable-button-pointers, pointer, null); user-select: none; - background-color: transparent; - border: $btn-border-width solid transparent; - @include button-size($btn-padding-y, $btn-padding-x, $btn-font-size, $btn-border-radius); + border: var(--#{$prefix}btn-border-width) solid var(--#{$prefix}btn-border-color); + @include border-radius(var(--#{$prefix}btn-border-radius)); + @include gradient-bg(var(--#{$prefix}btn-bg)); + @include box-shadow(var(--#{$prefix}btn-box-shadow)); @include transition($btn-transition); &:hover { - color: $body-color; + color: var(--#{$prefix}btn-hover-color); text-decoration: if($link-hover-decoration == underline, none, null); + background-color: var(--#{$prefix}btn-hover-bg); + border-color: var(--#{$prefix}btn-hover-border-color); } .btn-check:focus + &, &:focus { + color: var(--#{$prefix}btn-hover-color); + @include gradient-bg(var(--#{$prefix}btn-hover-bg)); + border-color: var(--#{$prefix}btn-hover-border-color); outline: 0; - box-shadow: $btn-focus-box-shadow; + // Avoid using mixin so we can pass custom focus shadow properly + @if $enable-shadows { + box-shadow: var(--#{$prefix}btn-box-shadow), var(--#{$prefix}btn-focus-box-shadow); + } @else { + box-shadow: var(--#{$prefix}btn-focus-box-shadow); + } } .btn-check:checked + &, .btn-check:active + &, &:active, - &.active { - @include box-shadow($btn-active-box-shadow); + &.active, + &.show { + color: var(--#{$prefix}btn-active-color); + background-color: var(--#{$prefix}btn-active-bg); + // Remove CSS gradients if they're enabled + background-image: if($enable-gradients, none, null); + border-color: var(--#{$prefix}btn-active-border-color); + @include box-shadow(var(--#{$prefix}btn-active-shadow)); &:focus { - @include box-shadow($btn-focus-box-shadow, $btn-active-box-shadow); + // Avoid using mixin so we can pass custom focus shadow properly + @if $enable-shadows { + box-shadow: var(--#{$prefix}btn-active-shadow), var(--#{$prefix}btn-focus-box-shadow); + } @else { + box-shadow: var(--#{$prefix}btn-focus-box-shadow); + } } } &:disabled, &.disabled, fieldset:disabled & { + color: var(--#{$prefix}btn-disabled-color); pointer-events: none; - opacity: $btn-disabled-opacity; + background-color: var(--#{$prefix}btn-disabled-bg); + background-image: if($enable-gradients, none, null); + border-color: var(--#{$prefix}btn-disabled-border-color); + opacity: var(--#{$prefix}btn-disabled-opacity); @include box-shadow(none); } } @@ -58,7 +103,27 @@ // scss-docs-start btn-variant-loops @each $color, $value in $theme-colors { .btn-#{$color} { - @include button-variant($value, $value); + @if $color == "light" { + @include button-variant( + $value, + $value, + $hover-background: shade-color($value, $btn-hover-bg-shade-amount), + $hover-border: shade-color($value, $btn-hover-border-shade-amount), + $active-background: shade-color($value, $btn-active-bg-shade-amount), + $active-border: shade-color($value, $btn-active-border-shade-amount) + ); + } @else if $color == "dark" { + @include button-variant( + $value, + $value, + $hover-background: tint-color($value, $btn-hover-bg-tint-amount), + $hover-border: tint-color($value, $btn-hover-border-tint-amount), + $active-background: tint-color($value, $btn-active-bg-tint-amount), + $active-border: tint-color($value, $btn-active-border-tint-amount) + ); + } @else { + @include button-variant($value, $value); + } } } @@ -76,22 +141,32 @@ // Make a button look and behave like a link .btn-link { - font-weight: $font-weight-normal; - color: $btn-link-color; + --#{$prefix}btn-font-weight: #{$font-weight-normal}; + --#{$prefix}btn-color: #{$btn-link-color}; + --#{$prefix}btn-bg: transparent; + --#{$prefix}btn-border-color: transparent; + --#{$prefix}btn-hover-color: #{$btn-link-hover-color}; + --#{$prefix}btn-hover-border-color: transparent; + --#{$prefix}btn-active-color: #{$btn-link-hover-color}; + --#{$prefix}btn-active-border-color: transparent; + --#{$prefix}btn-disabled-color: #{$btn-link-disabled-color}; + --#{$prefix}btn-disabled-border-color: transparent; + --#{$prefix}btn-box-shadow: none; + --#{$prefix}btn-focus-shadow-rgb: #{to-rgb(mix(color-contrast($primary), $primary, 15%))}; + text-decoration: $link-decoration; - &:hover { - color: $btn-link-hover-color; + &:hover, + &:focus { text-decoration: $link-hover-decoration; } &:focus { - text-decoration: $link-hover-decoration; + color: var(--#{$prefix}btn-color); } - &:disabled, - &.disabled { - color: $btn-link-disabled-color; + &:hover { + color: var(--#{$prefix}btn-hover-color); } // No need for an active state here diff --git a/assets/stylesheets/bootstrap/_card.scss b/assets/stylesheets/bootstrap/_card.scss index 22890f5..ce8c02f 100644 --- a/assets/stylesheets/bootstrap/_card.scss +++ b/assets/stylesheets/bootstrap/_card.scss @@ -3,17 +3,37 @@ // .card { + // scss-docs-start card-css-vars + --#{$prefix}card-spacer-y: #{$card-spacer-y}; + --#{$prefix}card-spacer-x: #{$card-spacer-x}; + --#{$prefix}card-title-spacer-y: #{$card-title-spacer-y}; + --#{$prefix}card-border-width: #{$card-border-width}; + --#{$prefix}card-border-color: #{$card-border-color}; + --#{$prefix}card-border-radius: #{$card-border-radius}; + --#{$prefix}card-box-shadow: #{$card-box-shadow}; + --#{$prefix}card-inner-border-radius: #{$card-inner-border-radius}; + --#{$prefix}card-cap-padding-y: #{$card-cap-padding-y}; + --#{$prefix}card-cap-padding-x: #{$card-cap-padding-x}; + --#{$prefix}card-cap-bg: #{$card-cap-bg}; + --#{$prefix}card-cap-color: #{$card-cap-color}; + --#{$prefix}card-height: #{$card-height}; + --#{$prefix}card-color: #{$card-color}; + --#{$prefix}card-bg: #{$card-bg}; + --#{$prefix}card-img-overlay-padding: #{$card-img-overlay-padding}; + --#{$prefix}card-group-margin: #{$card-group-margin}; + // scss-docs-end card-css-vars + position: relative; display: flex; flex-direction: column; min-width: 0; // See https://github.com/twbs/bootstrap/pull/22740#issuecomment-305868106 - height: $card-height; + height: var(--#{$prefix}card-height); word-wrap: break-word; - background-color: $card-bg; + background-color: var(--#{$prefix}card-bg); background-clip: border-box; - border: $card-border-width solid $card-border-color; - @include border-radius($card-border-radius); - @include box-shadow($card-box-shadow); + border: var(--#{$prefix}card-border-width) solid var(--#{$prefix}card-border-color); + @include border-radius(var(--#{$prefix}card-border-radius)); + @include box-shadow(var(--#{$prefix}card-box-shadow)); > hr { margin-right: 0; @@ -26,12 +46,12 @@ &:first-child { border-top-width: 0; - @include border-top-radius($card-inner-border-radius); + @include border-top-radius(var(--#{$prefix}card-inner-border-radius)); } &:last-child { border-bottom-width: 0; - @include border-bottom-radius($card-inner-border-radius); + @include border-bottom-radius(var(--#{$prefix}card-inner-border-radius)); } } @@ -47,16 +67,16 @@ // Enable `flex-grow: 1` for decks and groups so that card blocks take up // as much space as possible, ensuring footers are aligned to the bottom. flex: 1 1 auto; - padding: $card-spacer-y $card-spacer-x; - color: $card-color; + padding: var(--#{$prefix}card-spacer-y) var(--#{$prefix}card-spacer-x); + color: var(--#{$prefix}card-color); } .card-title { - margin-bottom: $card-title-spacer-y; + margin-bottom: var(--#{$prefix}card-title-spacer-y); } .card-subtitle { - margin-top: -$card-title-spacer-y * .5; + margin-top: calc(-.5 * var(--#{$prefix}card-title-spacer-y)); // stylelint-disable-line function-disallowed-list margin-bottom: 0; } @@ -70,7 +90,7 @@ } + .card-link { - margin-left: $card-spacer-x; + margin-left: var(--#{$prefix}card-spacer-x); } } @@ -79,25 +99,25 @@ // .card-header { - padding: $card-cap-padding-y $card-cap-padding-x; + padding: var(--#{$prefix}card-cap-padding-y) var(--#{$prefix}card-cap-padding-x); margin-bottom: 0; // Removes the default margin-bottom of <hN> - color: $card-cap-color; - background-color: $card-cap-bg; - border-bottom: $card-border-width solid $card-border-color; + color: var(--#{$prefix}card-cap-color); + background-color: var(--#{$prefix}card-cap-bg); + border-bottom: var(--#{$prefix}card-border-width) solid var(--#{$prefix}card-border-color); &:first-child { - @include border-radius($card-inner-border-radius $card-inner-border-radius 0 0); + @include border-radius(var(--#{$prefix}card-inner-border-radius) var(--#{$prefix}card-inner-border-radius) 0 0); } } .card-footer { - padding: $card-cap-padding-y $card-cap-padding-x; - color: $card-cap-color; - background-color: $card-cap-bg; - border-top: $card-border-width solid $card-border-color; + padding: var(--#{$prefix}card-cap-padding-y) var(--#{$prefix}card-cap-padding-x); + color: var(--#{$prefix}card-cap-color); + background-color: var(--#{$prefix}card-cap-bg); + border-top: var(--#{$prefix}card-border-width) solid var(--#{$prefix}card-border-color); &:last-child { - @include border-radius(0 0 $card-inner-border-radius $card-inner-border-radius); + @include border-radius(0 0 var(--#{$prefix}card-inner-border-radius) var(--#{$prefix}card-inner-border-radius)); } } @@ -107,22 +127,20 @@ // .card-header-tabs { - margin-right: -$card-cap-padding-x * .5; - margin-bottom: -$card-cap-padding-y; - margin-left: -$card-cap-padding-x * .5; + margin-right: calc(-.5 * var(--#{$prefix}card-cap-padding-x)); // stylelint-disable-line function-disallowed-list + margin-bottom: calc(-1 * var(--#{$prefix}card-cap-padding-y)); // stylelint-disable-line function-disallowed-list + margin-left: calc(-.5 * var(--#{$prefix}card-cap-padding-x)); // stylelint-disable-line function-disallowed-list border-bottom: 0; - @if $nav-tabs-link-active-bg != $card-bg { - .nav-link.active { - background-color: $card-bg; - border-bottom-color: $card-bg; - } + .nav-link.active { + background-color: var(--#{$prefix}card-bg); + border-bottom-color: var(--#{$prefix}card-bg); } } .card-header-pills { - margin-right: -$card-cap-padding-x * .5; - margin-left: -$card-cap-padding-x * .5; + margin-right: calc(-.5 * var(--#{$prefix}card-cap-padding-x)); // stylelint-disable-line function-disallowed-list + margin-left: calc(-.5 * var(--#{$prefix}card-cap-padding-x)); // stylelint-disable-line function-disallowed-list } // Card image @@ -132,8 +150,8 @@ right: 0; bottom: 0; left: 0; - padding: $card-img-overlay-padding; - @include border-radius($card-inner-border-radius); + padding: var(--#{$prefix}card-img-overlay-padding); + @include border-radius(var(--#{$prefix}card-inner-border-radius)); } .card-img, @@ -144,12 +162,12 @@ .card-img, .card-img-top { - @include border-top-radius($card-inner-border-radius); + @include border-top-radius(var(--#{$prefix}card-inner-border-radius)); } .card-img, .card-img-bottom { - @include border-bottom-radius($card-inner-border-radius); + @include border-bottom-radius(var(--#{$prefix}card-inner-border-radius)); } @@ -161,7 +179,7 @@ // The child selector allows nested `.card` within `.card-group` // to display properly. > .card { - margin-bottom: $card-group-margin; + margin-bottom: var(--#{$prefix}card-group-margin); } @include media-breakpoint-up(sm) { diff --git a/assets/stylesheets/bootstrap/_close.scss b/assets/stylesheets/bootstrap/_close.scss index 32a0f68..a0813de 100644 --- a/assets/stylesheets/bootstrap/_close.scss +++ b/assets/stylesheets/bootstrap/_close.scss @@ -1,4 +1,4 @@ -// transparent background and border properties included for button version. +// Transparent background and border properties included for button version. // iOS requires the button element instead of an anchor tag. // If you want the anchor version, it requires `href="#"`. // See https://developer.mozilla.org/en-US/docs/Web/Events/click#Safari_Mobile diff --git a/assets/stylesheets/bootstrap/_containers.scss b/assets/stylesheets/bootstrap/_containers.scss index f88f1e5..83b3138 100644 --- a/assets/stylesheets/bootstrap/_containers.scss +++ b/assets/stylesheets/bootstrap/_containers.scss @@ -2,7 +2,7 @@ // // Set the container width, and override it for fixed navbars in media queries. -@if $enable-grid-classes { +@if $enable-container-classes { // Single container class with breakpoint max-widths .container, // 100% wide container at all breakpoints diff --git a/assets/stylesheets/bootstrap/_dropdown.scss b/assets/stylesheets/bootstrap/_dropdown.scss index adc1143..62125b9 100644 --- a/assets/stylesheets/bootstrap/_dropdown.scss +++ b/assets/stylesheets/bootstrap/_dropdown.scss @@ -2,7 +2,9 @@ .dropup, .dropend, .dropdown, -.dropstart { +.dropstart, +.dropup-center, +.dropdown-center { position: relative; } @@ -15,26 +17,66 @@ // The dropdown menu .dropdown-menu { + // scss-docs-start dropdown-css-vars + --#{$prefix}dropdown-min-width: #{$dropdown-min-width}; + --#{$prefix}dropdown-padding-x: #{$dropdown-padding-x}; + --#{$prefix}dropdown-padding-y: #{$dropdown-padding-y}; + --#{$prefix}dropdown-spacer: #{$dropdown-spacer}; + @include rfs($dropdown-font-size, --#{$prefix}dropdown-font-size); + --#{$prefix}dropdown-color: #{$dropdown-color}; + --#{$prefix}dropdown-bg: #{$dropdown-bg}; + --#{$prefix}dropdown-border-color: #{$dropdown-border-color}; + --#{$prefix}dropdown-border-radius: #{$dropdown-border-radius}; + --#{$prefix}dropdown-border-width: #{$dropdown-border-width}; + --#{$prefix}dropdown-inner-border-radius: #{$dropdown-inner-border-radius}; + --#{$prefix}dropdown-divider-bg: #{$dropdown-divider-bg}; + --#{$prefix}dropdown-divider-margin-y: #{$dropdown-divider-margin-y}; + --#{$prefix}dropdown-box-shadow: #{$dropdown-box-shadow}; + --#{$prefix}dropdown-link-color: #{$dropdown-link-color}; + --#{$prefix}dropdown-link-hover-color: #{$dropdown-link-hover-color}; + --#{$prefix}dropdown-link-hover-bg: #{$dropdown-link-hover-bg}; + --#{$prefix}dropdown-link-active-color: #{$dropdown-link-active-color}; + --#{$prefix}dropdown-link-active-bg: #{$dropdown-link-active-bg}; + --#{$prefix}dropdown-link-disabled-color: #{$dropdown-link-disabled-color}; + --#{$prefix}dropdown-item-padding-x: #{$dropdown-item-padding-x}; + --#{$prefix}dropdown-item-padding-y: #{$dropdown-item-padding-y}; + --#{$prefix}dropdown-header-color: #{$dropdown-header-color}; + --#{$prefix}dropdown-header-padding-x: #{$dropdown-header-padding-x}; + --#{$prefix}dropdown-header-padding-y: #{$dropdown-header-padding-y}; + // scss-docs-end dropdown-css-vars + position: absolute; z-index: $zindex-dropdown; display: none; // none by default, but block on "open" of the menu - min-width: $dropdown-min-width; - padding: $dropdown-padding-y $dropdown-padding-x; + min-width: var(--#{$prefix}dropdown-min-width); + padding: var(--#{$prefix}dropdown-padding-y) var(--#{$prefix}dropdown-padding-x); margin: 0; // Override default margin of ul - @include font-size($dropdown-font-size); - color: $dropdown-color; + @include font-size(var(--#{$prefix}dropdown-font-size)); + color: var(--#{$prefix}dropdown-color); text-align: left; // Ensures proper alignment if parent has it changed (e.g., modal footer) list-style: none; - background-color: $dropdown-bg; + background-color: var(--#{$prefix}dropdown-bg); background-clip: padding-box; - border: $dropdown-border-width solid $dropdown-border-color; - @include border-radius($dropdown-border-radius); - @include box-shadow($dropdown-box-shadow); + border: var(--#{$prefix}dropdown-border-width) solid var(--#{$prefix}dropdown-border-color); + @include border-radius(var(--#{$prefix}dropdown-border-radius)); + @include box-shadow(var(--#{$prefix}dropdown-box-shadow)); &[data-bs-popper] { top: 100%; left: 0; - margin-top: $dropdown-spacer; + margin-top: var(--#{$prefix}dropdown-spacer); + } + + @if $dropdown-padding-y == 0 { + > .dropdown-item:first-child, + > li:first-child .dropdown-item { + @include border-top-radius(var(--#{$prefix}dropdown-inner-border-radius)); + } + > .dropdown-item:last-child, + > li:last-child .dropdown-item { + @include border-bottom-radius(var(--#{$prefix}dropdown-inner-border-radius)); + } + } } @@ -74,7 +116,7 @@ top: auto; bottom: 100%; margin-top: 0; - margin-bottom: $dropdown-spacer; + margin-bottom: var(--#{$prefix}dropdown-spacer); } .dropdown-toggle { @@ -88,7 +130,7 @@ right: auto; left: 100%; margin-top: 0; - margin-left: $dropdown-spacer; + margin-left: var(--#{$prefix}dropdown-spacer); } .dropdown-toggle { @@ -105,7 +147,7 @@ right: 100%; left: auto; margin-top: 0; - margin-right: $dropdown-spacer; + margin-right: var(--#{$prefix}dropdown-spacer); } .dropdown-toggle { @@ -120,9 +162,10 @@ // Dividers (basically an `<hr>`) within the dropdown .dropdown-divider { height: 0; - margin: $dropdown-divider-margin-y 0; + margin: var(--#{$prefix}dropdown-divider-margin-y) 0; overflow: hidden; - border-top: 1px solid $dropdown-divider-bg; + border-top: 1px solid var(--#{$prefix}dropdown-divider-bg); + opacity: 1; // Revisit in v6 to de-dupe styles that conflict with <hr> element } // Links, buttons, and more within the dropdown menu @@ -131,45 +174,33 @@ .dropdown-item { display: block; width: 100%; // For `<button>`s - padding: $dropdown-item-padding-y $dropdown-item-padding-x; + padding: var(--#{$prefix}dropdown-item-padding-y) var(--#{$prefix}dropdown-item-padding-x); clear: both; font-weight: $font-weight-normal; - color: $dropdown-link-color; + color: var(--#{$prefix}dropdown-link-color); text-align: inherit; // For `<button>`s text-decoration: if($link-decoration == none, null, none); white-space: nowrap; // prevent links from randomly breaking onto new lines background-color: transparent; // For `<button>`s border: 0; // For `<button>`s - // Prevent dropdown overflow if there's no padding - // See https://github.com/twbs/bootstrap/pull/27703 - @if $dropdown-padding-y == 0 { - &:first-child { - @include border-top-radius($dropdown-inner-border-radius); - } - - &:last-child { - @include border-bottom-radius($dropdown-inner-border-radius); - } - } - &:hover, &:focus { - color: $dropdown-link-hover-color; + color: var(--#{$prefix}dropdown-link-hover-color); text-decoration: if($link-hover-decoration == underline, none, null); - @include gradient-bg($dropdown-link-hover-bg); + @include gradient-bg(var(--#{$prefix}dropdown-link-hover-bg)); } &.active, &:active { - color: $dropdown-link-active-color; + color: var(--#{$prefix}dropdown-link-active-color); text-decoration: none; - @include gradient-bg($dropdown-link-active-bg); + @include gradient-bg(var(--#{$prefix}dropdown-link-active-bg)); } &.disabled, &:disabled { - color: $dropdown-link-disabled-color; + color: var(--#{$prefix}dropdown-link-disabled-color); pointer-events: none; background-color: transparent; // Remove CSS gradients if they're enabled @@ -184,57 +215,34 @@ // Dropdown section headers .dropdown-header { display: block; - padding: $dropdown-header-padding; + padding: var(--#{$prefix}dropdown-header-padding-y) var(--#{$prefix}dropdown-header-padding-x); margin-bottom: 0; // for use with heading elements @include font-size($font-size-sm); - color: $dropdown-header-color; + color: var(--#{$prefix}dropdown-header-color); white-space: nowrap; // as with > li > a } // Dropdown text .dropdown-item-text { display: block; - padding: $dropdown-item-padding-y $dropdown-item-padding-x; - color: $dropdown-link-color; + padding: var(--#{$prefix}dropdown-item-padding-y) var(--#{$prefix}dropdown-item-padding-x); + color: var(--#{$prefix}dropdown-link-color); } // Dark dropdowns .dropdown-menu-dark { - color: $dropdown-dark-color; - background-color: $dropdown-dark-bg; - border-color: $dropdown-dark-border-color; - @include box-shadow($dropdown-dark-box-shadow); - - .dropdown-item { - color: $dropdown-dark-link-color; - - &:hover, - &:focus { - color: $dropdown-dark-link-hover-color; - @include gradient-bg($dropdown-dark-link-hover-bg); - } - - &.active, - &:active { - color: $dropdown-dark-link-active-color; - @include gradient-bg($dropdown-dark-link-active-bg); - } - - &.disabled, - &:disabled { - color: $dropdown-dark-link-disabled-color; - } - } - - .dropdown-divider { - border-color: $dropdown-dark-divider-bg; - } - - .dropdown-item-text { - color: $dropdown-dark-link-color; - } - - .dropdown-header { - color: $dropdown-dark-header-color; - } + // scss-docs-start dropdown-dark-css-vars + --#{$prefix}dropdown-color: #{$dropdown-dark-color}; + --#{$prefix}dropdown-bg: #{$dropdown-dark-bg}; + --#{$prefix}dropdown-border-color: #{$dropdown-dark-border-color}; + --#{$prefix}dropdown-box-shadow: #{$dropdown-dark-box-shadow}; + --#{$prefix}dropdown-link-color: #{$dropdown-dark-link-color}; + --#{$prefix}dropdown-link-hover-color: #{$dropdown-dark-link-hover-color}; + --#{$prefix}dropdown-divider-bg: #{$dropdown-dark-divider-bg}; + --#{$prefix}dropdown-link-hover-bg: #{$dropdown-dark-link-hover-bg}; + --#{$prefix}dropdown-link-active-color: #{$dropdown-dark-link-active-color}; + --#{$prefix}dropdown-link-active-bg: #{$dropdown-dark-link-active-bg}; + --#{$prefix}dropdown-link-disabled-color: #{$dropdown-dark-link-disabled-color}; + --#{$prefix}dropdown-header-color: #{$dropdown-dark-header-color}; + // scss-docs-end dropdown-dark-css-vars } diff --git a/assets/stylesheets/bootstrap/_functions.scss b/assets/stylesheets/bootstrap/_functions.scss index 30539b3..855768b 100644 --- a/assets/stylesheets/bootstrap/_functions.scss +++ b/assets/stylesheets/bootstrap/_functions.scss @@ -40,11 +40,11 @@ // stylelint-disable scss/dollar-variable-pattern @function rgba-css-var($identifier, $target) { @if $identifier == "body" and $target == "bg" { - @return rgba(var(--#{$variable-prefix}#{$identifier}-bg-rgb), var(--#{$variable-prefix}#{$target}-opacity)); + @return rgba(var(--#{$prefix}#{$identifier}-bg-rgb), var(--#{$prefix}#{$target}-opacity)); } @if $identifier == "body" and $target == "text" { - @return rgba(var(--#{$variable-prefix}#{$identifier}-color-rgb), var(--#{$variable-prefix}#{$target}-opacity)); + @return rgba(var(--#{$prefix}#{$identifier}-color-rgb), var(--#{$prefix}#{$target}-opacity)); } @else { - @return rgba(var(--#{$variable-prefix}#{$identifier}-rgb), var(--#{$variable-prefix}#{$target}-opacity)); + @return rgba(var(--#{$prefix}#{$identifier}-rgb), var(--#{$prefix}#{$target}-opacity)); } } @@ -68,7 +68,7 @@ @function varify($list) { $result: null; @each $entry in $list { - $result: append($result, var(--#{$variable-prefix}#{$entry}), space); + $result: append($result, var(--#{$prefix}#{$entry}), space); } @return $result; } @@ -177,9 +177,9 @@ $_luminance-list: .0008 .001 .0011 .0013 .0015 .0017 .002 .0022 .0025 .0027 .003 @return if($l1 > $l2, divide($l1 + .05, $l2 + .05), divide($l2 + .05, $l1 + .05)); } -// Return WCAG2.0 relative luminance -// See https://www.w3.org/WAI/GL/wiki/Relative_luminance -// See https://www.w3.org/TR/WCAG20-TECHS/G17.html#G17-tests +// Return WCAG2.1 relative luminance +// See https://www.w3.org/TR/WCAG/#dfn-relative-luminance +// See https://www.w3.org/TR/WCAG/#dfn-contrast-ratio @function luminance($color) { $rgb: ( "r": red($color), diff --git a/assets/stylesheets/bootstrap/_grid.scss b/assets/stylesheets/bootstrap/_grid.scss index 27fd558..0e0ba21 100644 --- a/assets/stylesheets/bootstrap/_grid.scss +++ b/assets/stylesheets/bootstrap/_grid.scss @@ -15,9 +15,9 @@ @if $enable-cssgrid { .grid { display: grid; - grid-template-rows: repeat(var(--#{$variable-prefix}rows, 1), 1fr); - grid-template-columns: repeat(var(--#{$variable-prefix}columns, #{$grid-columns}), 1fr); - gap: var(--#{$variable-prefix}gap, #{$grid-gutter-width}); + grid-template-rows: repeat(var(--#{$prefix}rows, 1), 1fr); + grid-template-columns: repeat(var(--#{$prefix}columns, #{$grid-columns}), 1fr); + gap: var(--#{$prefix}gap, #{$grid-gutter-width}); @include make-cssgrid(); } diff --git a/assets/stylesheets/bootstrap/_helpers.scss b/assets/stylesheets/bootstrap/_helpers.scss index 4a989f5..644b693 100644 --- a/assets/stylesheets/bootstrap/_helpers.scss +++ b/assets/stylesheets/bootstrap/_helpers.scss @@ -1,4 +1,5 @@ @import "helpers/clearfix"; +@import "helpers/color-bg"; @import "helpers/colored-links"; @import "helpers/ratio"; @import "helpers/position"; diff --git a/assets/stylesheets/bootstrap/_list-group.scss b/assets/stylesheets/bootstrap/_list-group.scss index dcd61d2..22546cc 100644 --- a/assets/stylesheets/bootstrap/_list-group.scss +++ b/assets/stylesheets/bootstrap/_list-group.scss @@ -3,27 +3,46 @@ // Easily usable on <ul>, <ol>, or <div>. .list-group { + // scss-docs-start list-group-css-vars + --#{$prefix}list-group-color: #{$list-group-color}; + --#{$prefix}list-group-bg: #{$list-group-bg}; + --#{$prefix}list-group-border-color: #{$list-group-border-color}; + --#{$prefix}list-group-border-width: #{$list-group-border-width}; + --#{$prefix}list-group-border-radius: #{$list-group-border-radius}; + --#{$prefix}list-group-item-padding-x: #{$list-group-item-padding-x}; + --#{$prefix}list-group-item-padding-y: #{$list-group-item-padding-y}; + --#{$prefix}list-group-action-color: #{$list-group-action-color}; + --#{$prefix}list-group-action-hover-color: #{$list-group-action-hover-color}; + --#{$prefix}list-group-action-hover-bg: #{$list-group-hover-bg}; + --#{$prefix}list-group-action-active-color: #{$list-group-action-active-color}; + --#{$prefix}list-group-action-active-bg: #{$list-group-action-active-bg}; + --#{$prefix}list-group-disabled-color: #{$list-group-disabled-color}; + --#{$prefix}list-group-disabled-bg: #{$list-group-disabled-bg}; + --#{$prefix}list-group-active-color: #{$list-group-active-color}; + --#{$prefix}list-group-active-bg: #{$list-group-active-bg}; + --#{$prefix}list-group-active-border-color: #{$list-group-active-border-color}; + // scss-docs-end list-group-css-vars + display: flex; flex-direction: column; // No need to set list-style: none; since .list-group-item is block level padding-left: 0; // reset padding because ul and ol margin-bottom: 0; - @include border-radius($list-group-border-radius); + @include border-radius(var(--#{$prefix}list-group-border-radius)); } .list-group-numbered { list-style-type: none; counter-reset: section; - > li::before { + > .list-group-item::before { // Increments only this instance of the section counter content: counters(section, ".") ". "; counter-increment: section; } } - // Interactive list items // // Use anchor or button elements instead of `li`s or `div`s to create interactive @@ -31,25 +50,24 @@ .list-group-item-action { width: 100%; // For `<button>`s (anchors become 100% by default though) - color: $list-group-action-color; + color: var(--#{$prefix}list-group-action-color); text-align: inherit; // For `<button>`s (anchors inherit) // Hover state &:hover, &:focus { z-index: 1; // Place hover/focus items above their siblings for proper border styling - color: $list-group-action-hover-color; + color: var(--#{$prefix}list-group-action-hover-color); text-decoration: none; - background-color: $list-group-hover-bg; + background-color: var(--#{$prefix}list-group-action-hover-bg); } &:active { - color: $list-group-action-active-color; - background-color: $list-group-action-active-bg; + color: var(--#{$prefix}list-group-action-active-color); + background-color: var(--#{$prefix}list-group-action-active-bg); } } - // Individual list items // // Use on `li`s or `div`s within the `.list-group` parent. @@ -57,11 +75,11 @@ .list-group-item { position: relative; display: block; - padding: $list-group-item-padding-y $list-group-item-padding-x; - color: $list-group-color; + padding: var(--#{$prefix}list-group-item-padding-y) var(--#{$prefix}list-group-item-padding-x); + color: var(--#{$prefix}list-group-color); text-decoration: if($link-decoration == none, null, none); - background-color: $list-group-bg; - border: $list-group-border-width solid $list-group-border-color; + background-color: var(--#{$prefix}list-group-bg); + border: var(--#{$prefix}list-group-border-width) solid var(--#{$prefix}list-group-border-color); &:first-child { @include border-top-radius(inherit); @@ -73,30 +91,29 @@ &.disabled, &:disabled { - color: $list-group-disabled-color; + color: var(--#{$prefix}list-group-disabled-color); pointer-events: none; - background-color: $list-group-disabled-bg; + background-color: var(--#{$prefix}list-group-disabled-bg); } // Include both here for `<a>`s and `<button>`s &.active { z-index: 2; // Place active items above their siblings for proper border styling - color: $list-group-active-color; - background-color: $list-group-active-bg; - border-color: $list-group-active-border-color; + color: var(--#{$prefix}list-group-active-color); + background-color: var(--#{$prefix}list-group-active-bg); + border-color: var(--#{$prefix}list-group-active-border-color); } & + & { border-top-width: 0; &.active { - margin-top: -$list-group-border-width; - border-top-width: $list-group-border-width; + margin-top: calc(var(--#{$prefix}list-group-border-width) * -1); // stylelint-disable-line function-disallowed-list + border-top-width: var(--#{$prefix}list-group-border-width); } } } - // Horizontal // // Change the layout of list group items from vertical (default) to horizontal. @@ -110,12 +127,12 @@ > .list-group-item { &:first-child { - @include border-bottom-start-radius($list-group-border-radius); + @include border-bottom-start-radius(var(--#{$prefix}list-group-border-radius)); @include border-top-end-radius(0); } &:last-child { - @include border-top-end-radius($list-group-border-radius); + @include border-top-end-radius(var(--#{$prefix}list-group-border-radius)); @include border-bottom-start-radius(0); } @@ -124,12 +141,12 @@ } + .list-group-item { - border-top-width: $list-group-border-width; + border-top-width: var(--#{$prefix}list-group-border-width); border-left-width: 0; &.active { - margin-left: -$list-group-border-width; - border-left-width: $list-group-border-width; + margin-left: calc(var(--#{$prefix}list-group-border-width) * -1); // stylelint-disable-line function-disallowed-list + border-left-width: var(--#{$prefix}list-group-border-width); } } } @@ -147,7 +164,7 @@ @include border-radius(0); > .list-group-item { - border-width: 0 0 $list-group-border-width; + border-width: 0 0 var(--#{$prefix}list-group-border-width); &:last-child { border-bottom-width: 0; diff --git a/assets/stylesheets/bootstrap/_maps.scss b/assets/stylesheets/bootstrap/_maps.scss new file mode 100644 index 0000000..2770a67 --- /dev/null +++ b/assets/stylesheets/bootstrap/_maps.scss @@ -0,0 +1,54 @@ +// Re-assigned maps +// +// Placed here so that others can override the default Sass maps and see automatic updates to utilities and more. + +// scss-docs-start theme-colors-rgb +$theme-colors-rgb: map-loop($theme-colors, to-rgb, "$value") !default; +// scss-docs-end theme-colors-rgb + +// Utilities maps +// +// Extends the default `$theme-colors` maps to help create our utilities. + +// Come v6, we'll de-dupe these variables. Until then, for backward compatibility, we keep them to reassign. +// scss-docs-start utilities-colors +$utilities-colors: $theme-colors-rgb !default; +// scss-docs-end utilities-colors + +// scss-docs-start utilities-text-colors +$utilities-text: map-merge( + $utilities-colors, + ( + "black": to-rgb($black), + "white": to-rgb($white), + "body": to-rgb($body-color) + ) +) !default; +$utilities-text-colors: map-loop($utilities-text, rgba-css-var, "$key", "text") !default; +// scss-docs-end utilities-text-colors + +// scss-docs-start utilities-bg-colors +$utilities-bg: map-merge( + $utilities-colors, + ( + "black": to-rgb($black), + "white": to-rgb($white), + "body": to-rgb($body-bg) + ) +) !default; +$utilities-bg-colors: map-loop($utilities-bg, rgba-css-var, "$key", "bg") !default; +// scss-docs-end utilities-bg-colors + +// scss-docs-start utilities-border-colors +$utilities-border: map-merge( + $utilities-colors, + ( + "white": to-rgb($white) + ) +) !default; +$utilities-border-colors: map-loop($utilities-border, rgba-css-var, "$key", "border") !default; +// scss-docs-end utilities-border-colors + +$negative-spacers: if($enable-negative-margins, negativify-map($spacers), null) !default; + +$gutters: $spacers !default; diff --git a/assets/stylesheets/bootstrap/_modal.scss b/assets/stylesheets/bootstrap/_modal.scss index 21e1258..a25af57 100644 --- a/assets/stylesheets/bootstrap/_modal.scss +++ b/assets/stylesheets/bootstrap/_modal.scss @@ -1,3 +1,5 @@ +// stylelint-disable function-disallowed-list + // .modal-open - body class for killing the scroll // .modal - container to scroll within // .modal-dialog - positioning shell for the actual modal @@ -6,10 +8,34 @@ // Container that the modal scrolls within .modal { + // scss-docs-start modal-css-vars + --#{$prefix}modal-zindex: #{$zindex-modal}; + --#{$prefix}modal-width: #{$modal-md}; + --#{$prefix}modal-padding: #{$modal-inner-padding}; + --#{$prefix}modal-margin: #{$modal-dialog-margin}; + --#{$prefix}modal-color: #{$modal-content-color}; + --#{$prefix}modal-bg: #{$modal-content-bg}; + --#{$prefix}modal-border-color: #{$modal-content-border-color}; + --#{$prefix}modal-border-width: #{$modal-content-border-width}; + --#{$prefix}modal-border-radius: #{$modal-content-border-radius}; + --#{$prefix}modal-box-shadow: #{$modal-content-box-shadow-xs}; + --#{$prefix}modal-inner-border-radius: #{$modal-content-inner-border-radius}; + --#{$prefix}modal-header-padding-x: #{$modal-header-padding-x}; + --#{$prefix}modal-header-padding-y: #{$modal-header-padding-y}; + --#{$prefix}modal-header-padding: #{$modal-header-padding}; // Todo in v6: Split this padding into x and y + --#{$prefix}modal-header-border-color: #{$modal-header-border-color}; + --#{$prefix}modal-header-border-width: #{$modal-header-border-width}; + --#{$prefix}modal-title-line-height: #{$modal-title-line-height}; + --#{$prefix}modal-footer-gap: #{$modal-footer-margin-between}; + --#{$prefix}modal-footer-bg: #{$modal-footer-bg}; + --#{$prefix}modal-footer-border-color: #{$modal-footer-border-color}; + --#{$prefix}modal-footer-border-width: #{$modal-footer-border-width}; + // scss-docs-end modal-css-vars + position: fixed; top: 0; left: 0; - z-index: $zindex-modal; + z-index: var(--#{$prefix}modal-zindex); display: none; width: 100%; height: 100%; @@ -27,7 +53,7 @@ .modal-dialog { position: relative; width: auto; - margin: $modal-dialog-margin; + margin: var(--#{$prefix}modal-margin); // allow clicks to pass through for custom click handling to close modal pointer-events: none; @@ -47,7 +73,7 @@ } .modal-dialog-scrollable { - height: subtract(100%, $modal-dialog-margin * 2); + height: calc(100% - var(--#{$prefix}modal-margin) * 2); .modal-content { max-height: 100%; @@ -62,7 +88,7 @@ .modal-dialog-centered { display: flex; align-items: center; - min-height: subtract(100%, $modal-dialog-margin * 2); + min-height: calc(100% - var(--#{$prefix}modal-margin) * 2); } // Actual modal @@ -72,20 +98,26 @@ flex-direction: column; width: 100%; // Ensure `.modal-content` extends the full width of the parent `.modal-dialog` // counteract the pointer-events: none; in the .modal-dialog - color: $modal-content-color; + color: var(--#{$prefix}modal-color); pointer-events: auto; - background-color: $modal-content-bg; + background-color: var(--#{$prefix}modal-bg); background-clip: padding-box; - border: $modal-content-border-width solid $modal-content-border-color; - @include border-radius($modal-content-border-radius); - @include box-shadow($modal-content-box-shadow-xs); + border: var(--#{$prefix}modal-border-width) solid var(--#{$prefix}modal-border-color); + @include border-radius(var(--#{$prefix}modal-border-radius)); + @include box-shadow(var(--#{$prefix}modal-box-shadow)); // Remove focus outline from opened modal outline: 0; } // Modal background .modal-backdrop { - @include overlay-backdrop($zindex-modal-backdrop, $modal-backdrop-bg, $modal-backdrop-opacity); + // scss-docs-start modal-backdrop-css-vars + --#{$prefix}backdrop-zindex: #{$zindex-modal-backdrop}; + --#{$prefix}backdrop-bg: #{$modal-backdrop-bg}; + --#{$prefix}backdrop-opacity: #{$modal-backdrop-opacity}; + // scss-docs-end modal-backdrop-css-vars + + @include overlay-backdrop(var(--#{$prefix}backdrop-zindex), var(--#{$prefix}backdrop-bg), var(--#{$prefix}backdrop-opacity)); } // Modal header @@ -95,20 +127,20 @@ flex-shrink: 0; align-items: center; justify-content: space-between; // Put modal header elements (title and dismiss) on opposite ends - padding: $modal-header-padding; - border-bottom: $modal-header-border-width solid $modal-header-border-color; - @include border-top-radius($modal-content-inner-border-radius); + padding: var(--#{$prefix}modal-header-padding); + border-bottom: var(--#{$prefix}modal-header-border-width) solid var(--#{$prefix}modal-header-border-color); + @include border-top-radius(var(--#{$prefix}modal-inner-border-radius)); .btn-close { - padding: ($modal-header-padding-y * .5) ($modal-header-padding-x * .5); - margin: ($modal-header-padding-y * -.5) ($modal-header-padding-x * -.5) ($modal-header-padding-y * -.5) auto; + padding: calc(var(--#{$prefix}modal-header-padding-y) * .5) calc(var(--#{$prefix}modal-header-padding-x) * .5); + margin: calc(var(--#{$prefix}modal-header-padding-y) * -.5) calc(var(--#{$prefix}modal-header-padding-x) * -.5) calc(var(--#{$prefix}modal-header-padding-y) * -.5) auto; } } // Title text within header .modal-title { margin-bottom: 0; - line-height: $modal-title-line-height; + line-height: var(--#{$prefix}modal-title-line-height); } // Modal body @@ -118,60 +150,59 @@ // Enable `flex-grow: 1` so that the body take up as much space as possible // when there should be a fixed height on `.modal-dialog`. flex: 1 1 auto; - padding: $modal-inner-padding; + padding: var(--#{$prefix}modal-padding); } // Footer (for actions) .modal-footer { display: flex; - flex-wrap: wrap; flex-shrink: 0; + flex-wrap: wrap; align-items: center; // vertically center justify-content: flex-end; // Right align buttons with flex property because text-align doesn't work on flex items - padding: $modal-inner-padding - $modal-footer-margin-between * .5; - border-top: $modal-footer-border-width solid $modal-footer-border-color; - @include border-bottom-radius($modal-content-inner-border-radius); + padding: calc(var(--#{$prefix}modal-padding) - var(--#{$prefix}modal-footer-gap) * .5); + background-color: var(--#{$prefix}modal-footer-bg); + border-top: var(--#{$prefix}modal-footer-border-width) solid var(--#{$prefix}modal-footer-border-color); + @include border-bottom-radius(var(--#{$prefix}modal-inner-border-radius)); // Place margin between footer elements // This solution is far from ideal because of the universal selector usage, // but is needed to fix https://github.com/twbs/bootstrap/issues/24800 > * { - margin: $modal-footer-margin-between * .5; + margin: calc(var(--#{$prefix}modal-footer-gap) * .5); // Todo in v6: replace with gap on parent class } } // Scale up the modal @include media-breakpoint-up(sm) { - // Automatically set modal's width for larger viewports - .modal-dialog { - max-width: $modal-md; - margin: $modal-dialog-margin-y-sm-up auto; + .modal { + --#{$prefix}modal-margin: #{$modal-dialog-margin-y-sm-up}; + --#{$prefix}modal-box-shadow: #{$modal-content-box-shadow-sm-up}; } - .modal-dialog-scrollable { - height: subtract(100%, $modal-dialog-margin-y-sm-up * 2); - } - - .modal-dialog-centered { - min-height: subtract(100%, $modal-dialog-margin-y-sm-up * 2); + // Automatically set modal's width for larger viewports + .modal-dialog { + max-width: var(--#{$prefix}modal-width); + margin-right: auto; + margin-left: auto; } - .modal-content { - @include box-shadow($modal-content-box-shadow-sm-up); + .modal-sm { + --#{$prefix}modal-width: #{$modal-sm}; } - - .modal-sm { max-width: $modal-sm; } } @include media-breakpoint-up(lg) { .modal-lg, .modal-xl { - max-width: $modal-lg; + --#{$prefix}modal-width: #{$modal-lg}; } } @include media-breakpoint-up(xl) { - .modal-xl { max-width: $modal-xl; } + .modal-xl { + --#{$prefix}modal-width: #{$modal-xl}; + } } // scss-docs-start modal-fullscreen-loop @@ -192,17 +223,14 @@ @include border-radius(0); } - .modal-header { + .modal-header, + .modal-footer { @include border-radius(0); } .modal-body { overflow-y: auto; } - - .modal-footer { - @include border-radius(0); - } } } } diff --git a/assets/stylesheets/bootstrap/_nav.scss b/assets/stylesheets/bootstrap/_nav.scss index ffb27d8..e96b273 100644 --- a/assets/stylesheets/bootstrap/_nav.scss +++ b/assets/stylesheets/bootstrap/_nav.scss @@ -4,6 +4,16 @@ // `<nav>`s, `<ul>`s or `<ol>`s. .nav { + // scss-docs-start nav-css-vars + --#{$prefix}nav-link-padding-x: #{$nav-link-padding-x}; + --#{$prefix}nav-link-padding-y: #{$nav-link-padding-y}; + @include rfs($nav-link-font-size, --#{$prefix}nav-link-font-size); + --#{$prefix}nav-link-font-weight: #{$nav-link-font-weight}; + --#{$prefix}nav-link-color: #{$nav-link-color}; + --#{$prefix}nav-link-hover-color: #{$nav-link-hover-color}; + --#{$prefix}nav-link-disabled-color: #{$nav-link-disabled-color}; + // scss-docs-end nav-css-vars + display: flex; flex-wrap: wrap; padding-left: 0; @@ -13,22 +23,22 @@ .nav-link { display: block; - padding: $nav-link-padding-y $nav-link-padding-x; - @include font-size($nav-link-font-size); - font-weight: $nav-link-font-weight; - color: $nav-link-color; + padding: var(--#{$prefix}nav-link-padding-y) var(--#{$prefix}nav-link-padding-x); + @include font-size(var(--#{$prefix}nav-link-font-size)); + font-weight: var(--#{$prefix}nav-link-font-weight); + color: var(--#{$prefix}nav-link-color); text-decoration: if($link-decoration == none, null, none); @include transition($nav-link-transition); &:hover, &:focus { - color: $nav-link-hover-color; + color: var(--#{$prefix}nav-link-hover-color); text-decoration: if($link-hover-decoration == underline, none, null); } // Disabled state lightens text &.disabled { - color: $nav-link-disabled-color; + color: var(--#{$prefix}nav-link-disabled-color); pointer-events: none; cursor: default; } @@ -39,23 +49,34 @@ // .nav-tabs { - border-bottom: $nav-tabs-border-width solid $nav-tabs-border-color; + // scss-docs-start nav-tabs-css-vars + --#{$prefix}nav-tabs-border-width: #{$nav-tabs-border-width}; + --#{$prefix}nav-tabs-border-color: #{$nav-tabs-border-color}; + --#{$prefix}nav-tabs-border-radius: #{$nav-tabs-border-radius}; + --#{$prefix}nav-tabs-link-hover-border-color: #{$nav-tabs-link-hover-border-color}; + --#{$prefix}nav-tabs-link-active-color: #{$nav-tabs-link-active-color}; + --#{$prefix}nav-tabs-link-active-bg: #{$nav-tabs-link-active-bg}; + --#{$prefix}nav-tabs-link-active-border-color: #{$nav-tabs-link-active-border-color}; + // scss-docs-end nav-tabs-css-vars + + border-bottom: var(--#{$prefix}nav-tabs-border-width) solid var(--#{$prefix}nav-tabs-border-color); .nav-link { - margin-bottom: -$nav-tabs-border-width; + margin-bottom: calc(var(--#{$prefix}nav-tabs-border-width) * -1); // stylelint-disable-line function-disallowed-list background: none; - border: $nav-tabs-border-width solid transparent; - @include border-top-radius($nav-tabs-border-radius); + border: var(--#{$prefix}nav-tabs-border-width) solid transparent; + @include border-top-radius(var(--#{$prefix}nav-tabs-border-radius)); &:hover, &:focus { - border-color: $nav-tabs-link-hover-border-color; // Prevents active .nav-link tab overlapping focus outline of previous/next .nav-link isolation: isolate; + border-color: var(--#{$prefix}nav-tabs-link-hover-border-color); } - &.disabled { - color: $nav-link-disabled-color; + &.disabled, + &:disabled { + color: var(--#{$prefix}nav-link-disabled-color); background-color: transparent; border-color: transparent; } @@ -63,14 +84,14 @@ .nav-link.active, .nav-item.show .nav-link { - color: $nav-tabs-link-active-color; - background-color: $nav-tabs-link-active-bg; - border-color: $nav-tabs-link-active-border-color; + color: var(--#{$prefix}nav-tabs-link-active-color); + background-color: var(--#{$prefix}nav-tabs-link-active-bg); + border-color: var(--#{$prefix}nav-tabs-link-active-border-color); } .dropdown-menu { // Make dropdown border overlap tab border - margin-top: -$nav-tabs-border-width; + margin-top: calc(var(--#{$prefix}nav-tabs-border-width) * -1); // stylelint-disable-line function-disallowed-list // Remove the top rounded corners here since there is a hard edge above the menu @include border-top-radius(0); } @@ -82,16 +103,28 @@ // .nav-pills { + // scss-docs-start nav-pills-css-vars + --#{$prefix}nav-pills-border-radius: #{$nav-pills-border-radius}; + --#{$prefix}nav-pills-link-active-color: #{$nav-pills-link-active-color}; + --#{$prefix}nav-pills-link-active-bg: #{$nav-pills-link-active-bg}; + // scss-docs-end nav-pills-css-vars + .nav-link { background: none; border: 0; - @include border-radius($nav-pills-border-radius); + @include border-radius(var(--#{$prefix}nav-pills-border-radius)); + + &:disabled { + color: var(--#{$prefix}nav-link-disabled-color); + background-color: transparent; + border-color: transparent; + } } .nav-link.active, .show > .nav-link { - color: $nav-pills-link-active-color; - @include gradient-bg($nav-pills-link-active-bg); + color: var(--#{$prefix}nav-pills-link-active-color); + @include gradient-bg(var(--#{$prefix}nav-pills-link-active-bg)); } } diff --git a/assets/stylesheets/bootstrap/_navbar.scss b/assets/stylesheets/bootstrap/_navbar.scss index 001dfc9..fd6603d 100644 --- a/assets/stylesheets/bootstrap/_navbar.scss +++ b/assets/stylesheets/bootstrap/_navbar.scss @@ -1,29 +1,38 @@ -// Contents -// -// Navbar -// Navbar brand -// Navbar nav -// Navbar text -// Responsive navbar -// Navbar position -// Navbar themes - - // Navbar // // Provide a static navbar from which we expand to create full-width, fixed, and // other navbar variations. .navbar { + // scss-docs-start navbar-css-vars + --#{$prefix}navbar-padding-x: #{if($navbar-padding-x == null, 0, $navbar-padding-x)}; + --#{$prefix}navbar-padding-y: #{$navbar-padding-y}; + --#{$prefix}navbar-color: #{$navbar-light-color}; + --#{$prefix}navbar-hover-color: #{$navbar-light-hover-color}; + --#{$prefix}navbar-disabled-color: #{$navbar-light-disabled-color}; + --#{$prefix}navbar-active-color: #{$navbar-light-active-color}; + --#{$prefix}navbar-brand-padding-y: #{$navbar-brand-padding-y}; + --#{$prefix}navbar-brand-margin-end: #{$navbar-brand-margin-end}; + --#{$prefix}navbar-brand-font-size: #{$navbar-brand-font-size}; + --#{$prefix}navbar-brand-color: #{$navbar-light-brand-color}; + --#{$prefix}navbar-brand-hover-color: #{$navbar-light-brand-hover-color}; + --#{$prefix}navbar-nav-link-padding-x: #{$navbar-nav-link-padding-x}; + --#{$prefix}navbar-toggler-padding-y: #{$navbar-toggler-padding-y}; + --#{$prefix}navbar-toggler-padding-x: #{$navbar-toggler-padding-x}; + --#{$prefix}navbar-toggler-font-size: #{$navbar-toggler-font-size}; + --#{$prefix}navbar-toggler-icon-bg: #{escape-svg($navbar-light-toggler-icon-bg)}; + --#{$prefix}navbar-toggler-border-color: #{$navbar-light-toggler-border-color}; + --#{$prefix}navbar-toggler-border-radius: #{$navbar-toggler-border-radius}; + --#{$prefix}navbar-toggler-focus-width: #{$navbar-toggler-focus-width}; + --#{$prefix}navbar-toggler-transition: #{$navbar-toggler-transition}; + // scss-docs-end navbar-css-vars + position: relative; display: flex; flex-wrap: wrap; // allow us to do the line break for collapsing content align-items: center; justify-content: space-between; // space out brand from logo - padding-top: $navbar-padding-y; - padding-right: $navbar-padding-x; // default: null - padding-bottom: $navbar-padding-y; - padding-left: $navbar-padding-x; // default: null + padding: var(--#{$prefix}navbar-padding-y) var(--#{$prefix}navbar-padding-x); @include gradient-bg(); // Because flex properties aren't inherited, we need to redeclare these first @@ -54,15 +63,17 @@ // Used for brand, project, or site names. .navbar-brand { - padding-top: $navbar-brand-padding-y; - padding-bottom: $navbar-brand-padding-y; - margin-right: $navbar-brand-margin-end; - @include font-size($navbar-brand-font-size); + padding-top: var(--#{$prefix}navbar-brand-padding-y); + padding-bottom: var(--#{$prefix}navbar-brand-padding-y); + margin-right: var(--#{$prefix}navbar-brand-margin-end); + @include font-size(var(--#{$prefix}navbar-brand-font-size)); + color: var(--#{$prefix}navbar-brand-color); text-decoration: if($link-decoration == none, null, none); white-space: nowrap; &:hover, &:focus { + color: var(--#{$prefix}navbar-brand-hover-color); text-decoration: if($link-hover-decoration == underline, none, null); } } @@ -73,15 +84,25 @@ // Custom navbar navigation (doesn't require `.nav`, but does make use of `.nav-link`). .navbar-nav { + // scss-docs-start navbar-nav-css-vars + --#{$prefix}nav-link-padding-x: 0; + --#{$prefix}nav-link-padding-y: #{$nav-link-padding-y}; + @include rfs($nav-link-font-size, --#{$prefix}nav-link-font-size); + --#{$prefix}nav-link-font-weight: #{$nav-link-font-weight}; + --#{$prefix}nav-link-color: var(--#{$prefix}navbar-color); + --#{$prefix}nav-link-hover-color: var(--#{$prefix}navbar-hover-color); + --#{$prefix}nav-link-disabled-color: var(--#{$prefix}navbar-disabled-color); + // scss-docs-end navbar-nav-css-vars + display: flex; flex-direction: column; // cannot use `inherit` to get the `.navbar`s value padding-left: 0; margin-bottom: 0; list-style: none; - .nav-link { - padding-right: 0; - padding-left: 0; + .show > .nav-link, + .nav-link.active { + color: var(--#{$prefix}navbar-active-color); } .dropdown-menu { @@ -97,6 +118,13 @@ .navbar-text { padding-top: $nav-link-padding-y; padding-bottom: $nav-link-padding-y; + color: var(--#{$prefix}navbar-color); + + a, + a:hover, + a:focus { + color: var(--#{$prefix}navbar-active-color); + } } @@ -118,13 +146,14 @@ // Button for toggling the navbar when in its collapsed state .navbar-toggler { - padding: $navbar-toggler-padding-y $navbar-toggler-padding-x; - @include font-size($navbar-toggler-font-size); + padding: var(--#{$prefix}navbar-toggler-padding-y) var(--#{$prefix}navbar-toggler-padding-x); + @include font-size(var(--#{$prefix}navbar-toggler-font-size)); line-height: 1; + color: var(--#{$prefix}navbar-color); background-color: transparent; // remove default button style - border: $border-width solid transparent; // remove default button style - @include border-radius($navbar-toggler-border-radius); - @include transition($navbar-toggler-transition); + border: var(--#{$prefix}border-width) solid var(--#{$prefix}navbar-toggler-border-color); // remove default button style + @include border-radius(var(--#{$prefix}navbar-toggler-border-radius)); + @include transition(var(--#{$prefix}navbar-toggler-transition)); &:hover { text-decoration: none; @@ -133,7 +162,7 @@ &:focus { text-decoration: none; outline: 0; - box-shadow: 0 0 0 $navbar-toggler-focus-width; + box-shadow: 0 0 0 var(--#{$prefix}navbar-toggler-focus-width); } } @@ -144,13 +173,14 @@ width: 1.5em; height: 1.5em; vertical-align: middle; + background-image: var(--#{$prefix}navbar-toggler-icon-bg); background-repeat: no-repeat; background-position: center; background-size: 100%; } .navbar-nav-scroll { - max-height: var(--#{$variable-prefix}scroll-height, 75vh); + max-height: var(--#{$prefix}scroll-height, 75vh); overflow-y: auto; } @@ -176,8 +206,8 @@ } .nav-link { - padding-right: $navbar-nav-link-padding-x; - padding-left: $navbar-nav-link-padding-x; + padding-right: var(--#{$prefix}navbar-nav-link-padding-x); + padding-left: var(--#{$prefix}navbar-nav-link-padding-x); } } @@ -194,34 +224,31 @@ display: none; } - .offcanvas-header { - display: none; - } - .offcanvas { - position: inherit; - bottom: 0; - z-index: 1000; + // stylelint-disable declaration-no-important + position: static; + z-index: auto; flex-grow: 1; - visibility: visible !important; // stylelint-disable-line declaration-no-important - background-color: transparent; - border-right: 0; - border-left: 0; + width: auto !important; + height: auto !important; + visibility: visible !important; + background-color: transparent !important; + border: 0 !important; + transform: none !important; + @include box-shadow(none); @include transition(none); - transform: none; - } - .offcanvas-top, - .offcanvas-bottom { - height: auto; - border-top: 0; - border-bottom: 0; - } + // stylelint-enable declaration-no-important + + .offcanvas-header { + display: none; + } - .offcanvas-body { - display: flex; - flex-grow: 0; - padding: 0; - overflow-y: visible; + .offcanvas-body { + display: flex; + flex-grow: 0; + padding: 0; + overflow-y: visible; + } } } } @@ -233,103 +260,17 @@ // // Styles for switching between navbars with light or dark background. -// Dark links against a light background .navbar-light { - .navbar-brand { - color: $navbar-light-brand-color; - - &:hover, - &:focus { - color: $navbar-light-brand-hover-color; - } - } - - .navbar-nav { - .nav-link { - color: $navbar-light-color; - - &:hover, - &:focus { - color: $navbar-light-hover-color; - } - - &.disabled { - color: $navbar-light-disabled-color; - } - } - - .show > .nav-link, - .nav-link.active { - color: $navbar-light-active-color; - } - } - - .navbar-toggler { - color: $navbar-light-color; - border-color: $navbar-light-toggler-border-color; - } - - .navbar-toggler-icon { - background-image: escape-svg($navbar-light-toggler-icon-bg); - } - - .navbar-text { - color: $navbar-light-color; - - a, - a:hover, - a:focus { - color: $navbar-light-active-color; - } - } + @include deprecate("`.navbar-light`", "v5.2.0", "v6.0.0", true); } -// White links against a dark background .navbar-dark { - .navbar-brand { - color: $navbar-dark-brand-color; - - &:hover, - &:focus { - color: $navbar-dark-brand-hover-color; - } - } - - .navbar-nav { - .nav-link { - color: $navbar-dark-color; - - &:hover, - &:focus { - color: $navbar-dark-hover-color; - } - - &.disabled { - color: $navbar-dark-disabled-color; - } - } - - .show > .nav-link, - .nav-link.active { - color: $navbar-dark-active-color; - } - } - - .navbar-toggler { - color: $navbar-dark-color; - border-color: $navbar-dark-toggler-border-color; - } - - .navbar-toggler-icon { - background-image: escape-svg($navbar-dark-toggler-icon-bg); - } - - .navbar-text { - color: $navbar-dark-color; - a, - a:hover, - a:focus { - color: $navbar-dark-active-color; - } - } + --#{$prefix}navbar-color: #{$navbar-dark-color}; + --#{$prefix}navbar-hover-color: #{$navbar-dark-hover-color}; + --#{$prefix}navbar-disabled-color: #{$navbar-dark-disabled-color}; + --#{$prefix}navbar-active-color: #{$navbar-dark-active-color}; + --#{$prefix}navbar-brand-color: #{$navbar-dark-brand-color}; + --#{$prefix}navbar-brand-hover-color: #{$navbar-dark-brand-hover-color}; + --#{$prefix}navbar-toggler-border-color: #{$navbar-dark-toggler-border-color}; + --#{$prefix}navbar-toggler-icon-bg: #{escape-svg($navbar-dark-toggler-icon-bg)}; } diff --git a/assets/stylesheets/bootstrap/_offcanvas.scss b/assets/stylesheets/bootstrap/_offcanvas.scss index a089c2a..5709479 100644 --- a/assets/stylesheets/bootstrap/_offcanvas.scss +++ b/assets/stylesheets/bootstrap/_offcanvas.scss @@ -1,17 +1,116 @@ -.offcanvas { - position: fixed; - bottom: 0; - z-index: $zindex-offcanvas; - display: flex; - flex-direction: column; - max-width: 100%; - color: $offcanvas-color; - visibility: hidden; - background-color: $offcanvas-bg-color; - background-clip: padding-box; - outline: 0; - @include box-shadow($offcanvas-box-shadow); - @include transition(transform $offcanvas-transition-duration ease-in-out); +// stylelint-disable function-disallowed-list + +%offcanvas-css-vars { + // scss-docs-start offcanvas-css-vars + --#{$prefix}offcanvas-width: #{$offcanvas-horizontal-width}; + --#{$prefix}offcanvas-height: #{$offcanvas-vertical-height}; + --#{$prefix}offcanvas-padding-x: #{$offcanvas-padding-x}; + --#{$prefix}offcanvas-padding-y: #{$offcanvas-padding-y}; + --#{$prefix}offcanvas-color: #{$offcanvas-color}; + --#{$prefix}offcanvas-bg: #{$offcanvas-bg-color}; + --#{$prefix}offcanvas-border-width: #{$offcanvas-border-width}; + --#{$prefix}offcanvas-border-color: #{$offcanvas-border-color}; + --#{$prefix}offcanvas-box-shadow: #{$offcanvas-box-shadow}; + // scss-docs-end offcanvas-css-vars +} + +@each $breakpoint in map-keys($grid-breakpoints) { + $next: breakpoint-next($breakpoint, $grid-breakpoints); + $infix: breakpoint-infix($next, $grid-breakpoints); + + .offcanvas#{$infix} { + @extend %offcanvas-css-vars; + } +} + +@each $breakpoint in map-keys($grid-breakpoints) { + $next: breakpoint-next($breakpoint, $grid-breakpoints); + $infix: breakpoint-infix($next, $grid-breakpoints); + + .offcanvas#{$infix} { + @include media-breakpoint-down($next) { + position: fixed; + bottom: 0; + z-index: $zindex-offcanvas; + display: flex; + flex-direction: column; + max-width: 100%; + color: var(--#{$prefix}offcanvas-color); + visibility: hidden; + background-color: var(--#{$prefix}offcanvas-bg); + background-clip: padding-box; + outline: 0; + @include box-shadow(var(--#{$prefix}offcanvas-box-shadow)); + @include transition(transform $offcanvas-transition-duration ease-in-out); + + &.offcanvas-start { + top: 0; + left: 0; + width: var(--#{$prefix}offcanvas-width); + border-right: var(--#{$prefix}offcanvas-border-width) solid var(--#{$prefix}offcanvas-border-color); + transform: translateX(-100%); + } + + &.offcanvas-end { + top: 0; + right: 0; + width: var(--#{$prefix}offcanvas-width); + border-left: var(--#{$prefix}offcanvas-border-width) solid var(--#{$prefix}offcanvas-border-color); + transform: translateX(100%); + } + + &.offcanvas-top { + top: 0; + right: 0; + left: 0; + height: var(--#{$prefix}offcanvas-height); + max-height: 100%; + border-bottom: var(--#{$prefix}offcanvas-border-width) solid var(--#{$prefix}offcanvas-border-color); + transform: translateY(-100%); + } + + &.offcanvas-bottom { + right: 0; + left: 0; + height: var(--#{$prefix}offcanvas-height); + max-height: 100%; + border-top: var(--#{$prefix}offcanvas-border-width) solid var(--#{$prefix}offcanvas-border-color); + transform: translateY(100%); + } + + &.showing, + &.show:not(.hiding) { + transform: none; + } + + &.showing, + &.hiding, + &.show { + visibility: visible; + } + } + + @if not ($infix == "") { + @include media-breakpoint-up($next) { + --#{$prefix}offcanvas-height: auto; + --#{$prefix}offcanvas-border-width: 0; + background-color: transparent !important; // stylelint-disable-line declaration-no-important + + .offcanvas-header { + display: none; + } + + .offcanvas-body { + display: flex; + flex-grow: 0; + padding: 0; + overflow-y: visible; + // Reset `background-color` in case `.bg-*` classes are used in offcanvas + background-color: transparent !important; // stylelint-disable-line declaration-no-important + } + } + } + } } .offcanvas-backdrop { @@ -22,13 +121,13 @@ display: flex; align-items: center; justify-content: space-between; - padding: $offcanvas-padding-y $offcanvas-padding-x; + padding: var(--#{$prefix}offcanvas-padding-y) var(--#{$prefix}offcanvas-padding-x); .btn-close { - padding: ($offcanvas-padding-y * .5) ($offcanvas-padding-x * .5); - margin-top: $offcanvas-padding-y * -.5; - margin-right: $offcanvas-padding-x * -.5; - margin-bottom: $offcanvas-padding-y * -.5; + padding: calc(var(--#{$prefix}offcanvas-padding-y) * .5) calc(var(--#{$prefix}offcanvas-padding-x) * .5); + margin-top: calc(var(--#{$prefix}offcanvas-padding-y) * -.5); + margin-right: calc(var(--#{$prefix}offcanvas-padding-x) * -.5); + margin-bottom: calc(var(--#{$prefix}offcanvas-padding-y) * -.5); } } @@ -39,45 +138,6 @@ .offcanvas-body { flex-grow: 1; - padding: $offcanvas-padding-y $offcanvas-padding-x; + padding: var(--#{$prefix}offcanvas-padding-y) var(--#{$prefix}offcanvas-padding-x); overflow-y: auto; } - -.offcanvas-start { - top: 0; - left: 0; - width: $offcanvas-horizontal-width; - border-right: $offcanvas-border-width solid $offcanvas-border-color; - transform: translateX(-100%); -} - -.offcanvas-end { - top: 0; - right: 0; - width: $offcanvas-horizontal-width; - border-left: $offcanvas-border-width solid $offcanvas-border-color; - transform: translateX(100%); -} - -.offcanvas-top { - top: 0; - right: 0; - left: 0; - height: $offcanvas-vertical-height; - max-height: 100%; - border-bottom: $offcanvas-border-width solid $offcanvas-border-color; - transform: translateY(-100%); -} - -.offcanvas-bottom { - right: 0; - left: 0; - height: $offcanvas-vertical-height; - max-height: 100%; - border-top: $offcanvas-border-width solid $offcanvas-border-color; - transform: translateY(100%); -} - -.offcanvas.show { - transform: none; -} diff --git a/assets/stylesheets/bootstrap/_pagination.scss b/assets/stylesheets/bootstrap/_pagination.scss index 9c46666..e8e10a6 100644 --- a/assets/stylesheets/bootstrap/_pagination.scss +++ b/assets/stylesheets/bootstrap/_pagination.scss @@ -1,4 +1,27 @@ .pagination { + // scss-docs-start pagination-css-vars + --#{$prefix}pagination-padding-x: #{$pagination-padding-x}; + --#{$prefix}pagination-padding-y: #{$pagination-padding-y}; + @include rfs($pagination-font-size, --#{$prefix}pagination-font-size); + --#{$prefix}pagination-color: #{$pagination-color}; + --#{$prefix}pagination-bg: #{$pagination-bg}; + --#{$prefix}pagination-border-width: #{$pagination-border-width}; + --#{$prefix}pagination-border-color: #{$pagination-border-color}; + --#{$prefix}pagination-border-radius: #{$pagination-border-radius}; + --#{$prefix}pagination-hover-color: #{$pagination-hover-color}; + --#{$prefix}pagination-hover-bg: #{$pagination-hover-bg}; + --#{$prefix}pagination-hover-border-color: #{$pagination-hover-border-color}; + --#{$prefix}pagination-focus-color: #{$pagination-focus-color}; + --#{$prefix}pagination-focus-bg: #{$pagination-focus-bg}; + --#{$prefix}pagination-focus-box-shadow: #{$pagination-focus-box-shadow}; + --#{$prefix}pagination-active-color: #{$pagination-active-color}; + --#{$prefix}pagination-active-bg: #{$pagination-active-bg}; + --#{$prefix}pagination-active-border-color: #{$pagination-active-border-color}; + --#{$prefix}pagination-disabled-color: #{$pagination-disabled-color}; + --#{$prefix}pagination-disabled-bg: #{$pagination-disabled-bg}; + --#{$prefix}pagination-disabled-border-color: #{$pagination-disabled-border-color}; + // scss-docs-end pagination-css-vars + display: flex; @include list-unstyled(); } @@ -6,26 +29,44 @@ .page-link { position: relative; display: block; - color: $pagination-color; + padding: var(--#{$prefix}pagination-padding-y) var(--#{$prefix}pagination-padding-x); + @include font-size(var(--#{$prefix}pagination-font-size)); + color: var(--#{$prefix}pagination-color); text-decoration: if($link-decoration == none, null, none); - background-color: $pagination-bg; - border: $pagination-border-width solid $pagination-border-color; + background-color: var(--#{$prefix}pagination-bg); + border: var(--#{$prefix}pagination-border-width) solid var(--#{$prefix}pagination-border-color); @include transition($pagination-transition); &:hover { z-index: 2; - color: $pagination-hover-color; + color: var(--#{$prefix}pagination-hover-color); text-decoration: if($link-hover-decoration == underline, none, null); - background-color: $pagination-hover-bg; - border-color: $pagination-hover-border-color; + background-color: var(--#{$prefix}pagination-hover-bg); + border-color: var(--#{$prefix}pagination-hover-border-color); } &:focus { z-index: 3; - color: $pagination-focus-color; - background-color: $pagination-focus-bg; + color: var(--#{$prefix}pagination-focus-color); + background-color: var(--#{$prefix}pagination-focus-bg); outline: $pagination-focus-outline; - box-shadow: $pagination-focus-box-shadow; + box-shadow: var(--#{$prefix}pagination-focus-box-shadow); + } + + &.active, + .active > & { + z-index: 3; + color: var(--#{$prefix}pagination-active-color); + @include gradient-bg(var(--#{$prefix}pagination-active-bg)); + border-color: var(--#{$prefix}pagination-active-border-color); + } + + &.disabled, + .disabled > & { + color: var(--#{$prefix}pagination-disabled-color); + pointer-events: none; + background-color: var(--#{$prefix}pagination-disabled-bg); + border-color: var(--#{$prefix}pagination-disabled-border-color); } } @@ -34,18 +75,23 @@ margin-left: $pagination-margin-start; } - &.active .page-link { - z-index: 3; - color: $pagination-active-color; - @include gradient-bg($pagination-active-bg); - border-color: $pagination-active-border-color; - } + @if $pagination-margin-start == (calc($pagination-border-width * -1)) { + &:first-child { + .page-link { + @include border-start-radius(var(--#{$prefix}pagination-border-radius)); + } + } - &.disabled .page-link { - color: $pagination-disabled-color; - pointer-events: none; - background-color: $pagination-disabled-bg; - border-color: $pagination-disabled-border-color; + &:last-child { + .page-link { + @include border-end-radius(var(--#{$prefix}pagination-border-radius)); + } + } + } @else { + // Add border-radius to all pageLinks in case they have left margin + .page-link { + @include border-radius(var(--#{$prefix}pagination-border-radius)); + } } } @@ -53,7 +99,6 @@ // // Sizing // -@include pagination-size($pagination-padding-y, $pagination-padding-x, null, $pagination-border-radius); .pagination-lg { @include pagination-size($pagination-padding-y-lg, $pagination-padding-x-lg, $font-size-lg, $pagination-border-radius-lg); diff --git a/assets/stylesheets/bootstrap/_placeholders.scss b/assets/stylesheets/bootstrap/_placeholders.scss index 2f647cc..6e32e1c 100644 --- a/assets/stylesheets/bootstrap/_placeholders.scss +++ b/assets/stylesheets/bootstrap/_placeholders.scss @@ -3,7 +3,7 @@ min-height: 1em; vertical-align: middle; cursor: wait; - background-color: currentColor; + background-color: currentcolor; opacity: $placeholder-opacity-max; &.btn::before { diff --git a/assets/stylesheets/bootstrap/_popover.scss b/assets/stylesheets/bootstrap/_popover.scss index 3b8208e..b00c029 100644 --- a/assets/stylesheets/bootstrap/_popover.scss +++ b/assets/stylesheets/bootstrap/_popover.scss @@ -1,27 +1,46 @@ .popover { - position: absolute; - top: 0; - left: 0 #{"/* rtl:ignore */"}; - z-index: $zindex-popover; + // scss-docs-start popover-css-vars + --#{$prefix}popover-zindex: #{$zindex-popover}; + --#{$prefix}popover-max-width: #{$popover-max-width}; + @include rfs($popover-font-size, --#{$prefix}popover-font-size); + --#{$prefix}popover-bg: #{$popover-bg}; + --#{$prefix}popover-border-width: #{$popover-border-width}; + --#{$prefix}popover-border-color: #{$popover-border-color}; + --#{$prefix}popover-border-radius: #{$popover-border-radius}; + --#{$prefix}popover-inner-border-radius: #{$popover-inner-border-radius}; + --#{$prefix}popover-box-shadow: #{$popover-box-shadow}; + --#{$prefix}popover-header-padding-x: #{$popover-header-padding-x}; + --#{$prefix}popover-header-padding-y: #{$popover-header-padding-y}; + @include rfs($popover-header-font-size, --#{$prefix}popover-header-font-size); + --#{$prefix}popover-header-color: #{$popover-header-color}; + --#{$prefix}popover-header-bg: #{$popover-header-bg}; + --#{$prefix}popover-body-padding-x: #{$popover-body-padding-x}; + --#{$prefix}popover-body-padding-y: #{$popover-body-padding-y}; + --#{$prefix}popover-body-color: #{$popover-body-color}; + --#{$prefix}popover-arrow-width: #{$popover-arrow-width}; + --#{$prefix}popover-arrow-height: #{$popover-arrow-height}; + --#{$prefix}popover-arrow-border: var(--#{$prefix}popover-border-color); + // scss-docs-end popover-css-vars + + z-index: var(--#{$prefix}popover-zindex); display: block; - max-width: $popover-max-width; + max-width: var(--#{$prefix}popover-max-width); // Our parent element can be arbitrary since tooltips are by default inserted as a sibling of their target element. // So reset our font and text properties to avoid inheriting weird values. @include reset-text(); - @include font-size($popover-font-size); + @include font-size(var(--#{$prefix}popover-font-size)); // Allow breaking very long words so they don't overflow the popover's bounds word-wrap: break-word; - background-color: $popover-bg; + background-color: var(--#{$prefix}popover-bg); background-clip: padding-box; - border: $popover-border-width solid $popover-border-color; - @include border-radius($popover-border-radius); - @include box-shadow($popover-box-shadow); + border: var(--#{$prefix}popover-border-width) solid var(--#{$prefix}popover-border-color); + @include border-radius(var(--#{$prefix}popover-border-radius)); + @include box-shadow(var(--#{$prefix}popover-box-shadow)); .popover-arrow { - position: absolute; display: block; - width: $popover-arrow-width; - height: $popover-arrow-height; + width: var(--#{$prefix}popover-arrow-width); + height: var(--#{$prefix}popover-arrow-height); &::before, &::after { @@ -30,62 +49,75 @@ content: ""; border-color: transparent; border-style: solid; + border-width: 0; } } } .bs-popover-top { > .popover-arrow { - bottom: subtract(-$popover-arrow-height, $popover-border-width); + bottom: calc((var(--#{$prefix}popover-arrow-height) * -1) - var(--#{$prefix}popover-border-width)); // stylelint-disable-line function-disallowed-list + + &::before, + &::after { + border-width: var(--#{$prefix}popover-arrow-height) calc(var(--#{$prefix}popover-arrow-width) * .5) 0; // stylelint-disable-line function-disallowed-list + } &::before { bottom: 0; - border-width: $popover-arrow-height ($popover-arrow-width * .5) 0; - border-top-color: $popover-arrow-outer-color; + border-top-color: var(--#{$prefix}popover-arrow-border); } &::after { - bottom: $popover-border-width; - border-width: $popover-arrow-height ($popover-arrow-width * .5) 0; - border-top-color: $popover-arrow-color; + bottom: var(--#{$prefix}popover-border-width); + border-top-color: var(--#{$prefix}popover-bg); } } } +/* rtl:begin:ignore */ .bs-popover-end { > .popover-arrow { - left: subtract(-$popover-arrow-height, $popover-border-width); - width: $popover-arrow-height; - height: $popover-arrow-width; + left: calc((var(--#{$prefix}popover-arrow-height) * -1) - var(--#{$prefix}popover-border-width)); // stylelint-disable-line function-disallowed-list + width: var(--#{$prefix}popover-arrow-height); + height: var(--#{$prefix}popover-arrow-width); + + &::before, + &::after { + border-width: calc(var(--#{$prefix}popover-arrow-width) * .5) var(--#{$prefix}popover-arrow-height) calc(var(--#{$prefix}popover-arrow-width) * .5) 0; // stylelint-disable-line function-disallowed-list + } &::before { left: 0; - border-width: ($popover-arrow-width * .5) $popover-arrow-height ($popover-arrow-width * .5) 0; - border-right-color: $popover-arrow-outer-color; + border-right-color: var(--#{$prefix}popover-arrow-border); } &::after { - left: $popover-border-width; - border-width: ($popover-arrow-width * .5) $popover-arrow-height ($popover-arrow-width * .5) 0; - border-right-color: $popover-arrow-color; + left: var(--#{$prefix}popover-border-width); + border-right-color: var(--#{$prefix}popover-bg); } } } +/* rtl:end:ignore */ + .bs-popover-bottom { > .popover-arrow { - top: subtract(-$popover-arrow-height, $popover-border-width); + top: calc((var(--#{$prefix}popover-arrow-height) * -1) - var(--#{$prefix}popover-border-width)); // stylelint-disable-line function-disallowed-list + + &::before, + &::after { + border-width: 0 calc(var(--#{$prefix}popover-arrow-width) * .5) var(--#{$prefix}popover-arrow-height); // stylelint-disable-line function-disallowed-list + } &::before { top: 0; - border-width: 0 ($popover-arrow-width * .5) $popover-arrow-height ($popover-arrow-width * .5); - border-bottom-color: $popover-arrow-outer-color; + border-bottom-color: var(--#{$prefix}popover-arrow-border); } &::after { - top: $popover-border-width; - border-width: 0 ($popover-arrow-width * .5) $popover-arrow-height ($popover-arrow-width * .5); - border-bottom-color: $popover-arrow-color; + top: var(--#{$prefix}popover-border-width); + border-bottom-color: var(--#{$prefix}popover-bg); } } @@ -95,33 +127,39 @@ top: 0; left: 50%; display: block; - width: $popover-arrow-width; - margin-left: -$popover-arrow-width * .5; + width: var(--#{$prefix}popover-arrow-width); + margin-left: calc(var(--#{$prefix}popover-arrow-width) * -.5); // stylelint-disable-line function-disallowed-list content: ""; - border-bottom: $popover-border-width solid $popover-header-bg; + border-bottom: var(--#{$prefix}popover-border-width) solid var(--#{$prefix}popover-header-bg); } } +/* rtl:begin:ignore */ .bs-popover-start { > .popover-arrow { - right: subtract(-$popover-arrow-height, $popover-border-width); - width: $popover-arrow-height; - height: $popover-arrow-width; + right: calc((var(--#{$prefix}popover-arrow-height) * -1) - var(--#{$prefix}popover-border-width)); // stylelint-disable-line function-disallowed-list + width: var(--#{$prefix}popover-arrow-height); + height: var(--#{$prefix}popover-arrow-width); + + &::before, + &::after { + border-width: calc(var(--#{$prefix}popover-arrow-width) * .5) 0 calc(var(--#{$prefix}popover-arrow-width) * .5) var(--#{$prefix}popover-arrow-height); // stylelint-disable-line function-disallowed-list + } &::before { right: 0; - border-width: ($popover-arrow-width * .5) 0 ($popover-arrow-width * .5) $popover-arrow-height; - border-left-color: $popover-arrow-outer-color; + border-left-color: var(--#{$prefix}popover-arrow-border); } &::after { - right: $popover-border-width; - border-width: ($popover-arrow-width * .5) 0 ($popover-arrow-width * .5) $popover-arrow-height; - border-left-color: $popover-arrow-color; + right: var(--#{$prefix}popover-border-width); + border-left-color: var(--#{$prefix}popover-bg); } } } +/* rtl:end:ignore */ + .bs-popover-auto { &[data-popper-placement^="top"] { @extend .bs-popover-top; @@ -139,13 +177,13 @@ // Offset the popover to account for the popover arrow .popover-header { - padding: $popover-header-padding-y $popover-header-padding-x; + padding: var(--#{$prefix}popover-header-padding-y) var(--#{$prefix}popover-header-padding-x); margin-bottom: 0; // Reset the default from Reboot - @include font-size($font-size-base); - color: $popover-header-color; - background-color: $popover-header-bg; - border-bottom: $popover-border-width solid $popover-border-color; - @include border-top-radius($popover-inner-border-radius); + @include font-size(var(--#{$prefix}popover-header-font-size)); + color: var(--#{$prefix}popover-header-color); + background-color: var(--#{$prefix}popover-header-bg); + border-bottom: var(--#{$prefix}popover-border-width) solid var(--#{$prefix}popover-border-color); + @include border-top-radius(var(--#{$prefix}popover-inner-border-radius)); &:empty { display: none; @@ -153,6 +191,6 @@ } .popover-body { - padding: $popover-body-padding-y $popover-body-padding-x; - color: $popover-body-color; + padding: var(--#{$prefix}popover-body-padding-y) var(--#{$prefix}popover-body-padding-x); + color: var(--#{$prefix}popover-body-color); } diff --git a/assets/stylesheets/bootstrap/_progress.scss b/assets/stylesheets/bootstrap/_progress.scss index 5715ab0..1bfafb5 100644 --- a/assets/stylesheets/bootstrap/_progress.scss +++ b/assets/stylesheets/bootstrap/_progress.scss @@ -9,13 +9,24 @@ // scss-docs-end progress-keyframes .progress { + // scss-docs-start progress-css-vars + --#{$prefix}progress-height: #{$progress-height}; + @include rfs($progress-font-size, --#{$prefix}progress-font-size); + --#{$prefix}progress-bg: #{$progress-bg}; + --#{$prefix}progress-border-radius: #{$progress-border-radius}; + --#{$prefix}progress-box-shadow: #{$progress-box-shadow}; + --#{$prefix}progress-bar-color: #{$progress-bar-color}; + --#{$prefix}progress-bar-bg: #{$progress-bar-bg}; + --#{$prefix}progress-bar-transition: #{$progress-bar-transition}; + // scss-docs-end progress-css-vars + display: flex; - height: $progress-height; + height: var(--#{$prefix}progress-height); overflow: hidden; // force rounded corners by cropping it - @include font-size($progress-font-size); - background-color: $progress-bg; - @include border-radius($progress-border-radius); - @include box-shadow($progress-box-shadow); + @include font-size(var(--#{$prefix}progress-font-size)); + background-color: var(--#{$prefix}progress-bg); + @include border-radius(var(--#{$prefix}progress-border-radius)); + @include box-shadow(var(--#{$prefix}progress-box-shadow)); } .progress-bar { @@ -23,16 +34,16 @@ flex-direction: column; justify-content: center; overflow: hidden; - color: $progress-bar-color; + color: var(--#{$prefix}progress-bar-color); text-align: center; white-space: nowrap; - background-color: $progress-bar-bg; - @include transition($progress-bar-transition); + background-color: var(--#{$prefix}progress-bar-bg); + @include transition(var(--#{$prefix}progress-bar-transition)); } .progress-bar-striped { @include gradient-striped(); - background-size: $progress-height $progress-height; + background-size: var(--#{$prefix}progress-height) var(--#{$prefix}progress-height); } @if $enable-transitions { diff --git a/assets/stylesheets/bootstrap/_reboot.scss b/assets/stylesheets/bootstrap/_reboot.scss index 79fedc6..8ac7903 100644 --- a/assets/stylesheets/bootstrap/_reboot.scss +++ b/assets/stylesheets/bootstrap/_reboot.scss @@ -27,7 +27,7 @@ :root { @if $font-size-root != null { - font-size: var(--#{$variable-prefix}root-font-size); + @include font-size(var(--#{$prefix}root-font-size)); } @if $enable-smooth-scroll { @@ -48,13 +48,13 @@ // scss-docs-start reboot-body-rules body { margin: 0; // 1 - font-family: var(--#{$variable-prefix}body-font-family); - @include font-size(var(--#{$variable-prefix}body-font-size)); - font-weight: var(--#{$variable-prefix}body-font-weight); - line-height: var(--#{$variable-prefix}body-line-height); - color: var(--#{$variable-prefix}body-color); - text-align: var(--#{$variable-prefix}body-text-align); - background-color: var(--#{$variable-prefix}body-bg); // 2 + font-family: var(--#{$prefix}body-font-family); + @include font-size(var(--#{$prefix}body-font-size)); + font-weight: var(--#{$prefix}body-font-weight); + line-height: var(--#{$prefix}body-line-height); + color: var(--#{$prefix}body-color); + text-align: var(--#{$prefix}body-text-align); + background-color: var(--#{$prefix}body-bg); // 2 -webkit-text-size-adjust: 100%; // 3 -webkit-tap-highlight-color: rgba($black, 0); // 4 } @@ -64,20 +64,15 @@ body { // Content grouping // // 1. Reset Firefox's gray color -// 2. Set correct height and prevent the `size` attribute to make the `hr` look like an input field hr { margin: $hr-margin-y 0; color: $hr-color; // 1 - background-color: currentColor; border: 0; + border-top: $hr-border-width solid $hr-border-color; opacity: $hr-opacity; } -hr:not([size]) { - height: $hr-height; // 2 -} - // Typography // @@ -139,16 +134,14 @@ p { // Abbreviations // -// 1. Duplicate behavior to the data-bs-* attribute for our tooltip plugin -// 2. Add the correct text decoration in Chrome, Edge, Opera, and Safari. -// 3. Add explicit cursor to indicate changed behavior. -// 4. Prevent the text-decoration to be skipped. +// 1. Add the correct text decoration in Chrome, Edge, Opera, and Safari. +// 2. Add explicit cursor to indicate changed behavior. +// 3. Prevent the text-decoration to be skipped. -abbr[title], -abbr[data-bs-original-title] { // 1 - text-decoration: underline dotted; // 2 - cursor: help; // 3 - text-decoration-skip-ink: none; // 4 +abbr[title] { + text-decoration: underline dotted; // 1 + cursor: help; // 2 + text-decoration-skip-ink: none; // 3 } @@ -224,7 +217,7 @@ small { mark { padding: $mark-padding; - background-color: $mark-bg; + background-color: var(--#{$prefix}highlight-bg); } @@ -248,11 +241,11 @@ sup { top: -.5em; } // Links a { - color: $link-color; + color: var(--#{$prefix}link-color); text-decoration: $link-decoration; &:hover { - color: $link-hover-color; + color: var(--#{$prefix}link-hover-color); text-decoration: $link-hover-decoration; } } @@ -279,8 +272,6 @@ kbd, samp { font-family: $font-family-code; @include font-size(1em); // Correct the odd `em` font sizing in all browsers. - direction: ltr #{"/* rtl:ignore */"}; - unicode-bidi: bidi-override; } // 1. Remove browser default top margin @@ -305,7 +296,7 @@ pre { code { @include font-size($code-font-size); - color: $code-color; + color: var(--#{$prefix}code-color); word-wrap: break-word; // Streamline the style when inside anchors to avoid broken underline and more @@ -445,11 +436,11 @@ select { } } -// Remove the dropdown arrow in Chrome from inputs built with datalists. +// Remove the dropdown arrow only from text type inputs built with datalists in Chrome. // See https://stackoverflow.com/a/54997118 -[list]::-webkit-calendar-picker-indicator { - display: none; +[list]:not([type="date"]):not([type="datetime-local"]):not([type="month"]):not([type="week"]):not([type="time"])::-webkit-calendar-picker-indicator { + display: none !important; } // 1. Prevent a WebKit bug where (2) destroys native `audio` and `video` @@ -571,16 +562,10 @@ legend { } -// Inherit font family and line height for file input buttons - -::file-selector-button { - font: inherit; -} - -// 1. Change font properties to `inherit` +// 1. Inherit font family and line height for file input buttons // 2. Correct the inability to style clickable types in iOS and Safari. -::-webkit-file-upload-button { +::file-selector-button { font: inherit; // 1 -webkit-appearance: button; // 2 } diff --git a/assets/stylesheets/bootstrap/_root.scss b/assets/stylesheets/bootstrap/_root.scss index 5e138e9..e64ae04 100644 --- a/assets/stylesheets/bootstrap/_root.scss +++ b/assets/stylesheets/bootstrap/_root.scss @@ -6,49 +6,68 @@ // Generate palettes for full colors, grays, and theme colors. @each $color, $value in $colors { - --#{$variable-prefix}#{$color}: #{$value}; + --#{$prefix}#{$color}: #{$value}; } @each $color, $value in $grays { - --#{$variable-prefix}gray-#{$color}: #{$value}; + --#{$prefix}gray-#{$color}: #{$value}; } @each $color, $value in $theme-colors { - --#{$variable-prefix}#{$color}: #{$value}; + --#{$prefix}#{$color}: #{$value}; } @each $color, $value in $theme-colors-rgb { - --#{$variable-prefix}#{$color}-rgb: #{$value}; + --#{$prefix}#{$color}-rgb: #{$value}; } - --#{$variable-prefix}white-rgb: #{to-rgb($white)}; - --#{$variable-prefix}black-rgb: #{to-rgb($black)}; - --#{$variable-prefix}body-color-rgb: #{to-rgb($body-color)}; - --#{$variable-prefix}body-bg-rgb: #{to-rgb($body-bg)}; + --#{$prefix}white-rgb: #{to-rgb($white)}; + --#{$prefix}black-rgb: #{to-rgb($black)}; + --#{$prefix}body-color-rgb: #{to-rgb($body-color)}; + --#{$prefix}body-bg-rgb: #{to-rgb($body-bg)}; // Fonts // Note: Use `inspect` for lists so that quoted items keep the quotes. // See https://github.com/sass/sass/issues/2383#issuecomment-336349172 - --#{$variable-prefix}font-sans-serif: #{inspect($font-family-sans-serif)}; - --#{$variable-prefix}font-monospace: #{inspect($font-family-monospace)}; - --#{$variable-prefix}gradient: #{$gradient}; + --#{$prefix}font-sans-serif: #{inspect($font-family-sans-serif)}; + --#{$prefix}font-monospace: #{inspect($font-family-monospace)}; + --#{$prefix}gradient: #{$gradient}; // Root and body - // stylelint-disable custom-property-empty-line-before // scss-docs-start root-body-variables @if $font-size-root != null { - --#{$variable-prefix}root-font-size: #{$font-size-root}; + --#{$prefix}root-font-size: #{$font-size-root}; } - --#{$variable-prefix}body-font-family: #{$font-family-base}; - --#{$variable-prefix}body-font-size: #{$font-size-base}; - --#{$variable-prefix}body-font-weight: #{$font-weight-base}; - --#{$variable-prefix}body-line-height: #{$line-height-base}; - --#{$variable-prefix}body-color: #{$body-color}; + --#{$prefix}body-font-family: #{$font-family-base}; + @include rfs($font-size-base, --#{$prefix}body-font-size); + --#{$prefix}body-font-weight: #{$font-weight-base}; + --#{$prefix}body-line-height: #{$line-height-base}; + --#{$prefix}body-color: #{$body-color}; @if $body-text-align != null { - --#{$variable-prefix}body-text-align: #{$body-text-align}; + --#{$prefix}body-text-align: #{$body-text-align}; } - --#{$variable-prefix}body-bg: #{$body-bg}; + --#{$prefix}body-bg: #{$body-bg}; // scss-docs-end root-body-variables - // stylelint-enable custom-property-empty-line-before + + // scss-docs-start root-border-var + --#{$prefix}border-width: #{$border-width}; + --#{$prefix}border-style: #{$border-style}; + --#{$prefix}border-color: #{$border-color}; + --#{$prefix}border-color-translucent: #{$border-color-translucent}; + + --#{$prefix}border-radius: #{$border-radius}; + --#{$prefix}border-radius-sm: #{$border-radius-sm}; + --#{$prefix}border-radius-lg: #{$border-radius-lg}; + --#{$prefix}border-radius-xl: #{$border-radius-xl}; + --#{$prefix}border-radius-2xl: #{$border-radius-2xl}; + --#{$prefix}border-radius-pill: #{$border-radius-pill}; + // scss-docs-end root-border-var + + --#{$prefix}link-color: #{$link-color}; + --#{$prefix}link-hover-color: #{$link-hover-color}; + + --#{$prefix}code-color: #{$code-color}; + + --#{$prefix}highlight-bg: #{$mark-bg}; } diff --git a/assets/stylesheets/bootstrap/_spinners.scss b/assets/stylesheets/bootstrap/_spinners.scss index a4a2c77..ec84732 100644 --- a/assets/stylesheets/bootstrap/_spinners.scss +++ b/assets/stylesheets/bootstrap/_spinners.scss @@ -2,6 +2,17 @@ // Rotating border // +.spinner-grow, +.spinner-border { + display: inline-block; + width: var(--#{$prefix}spinner-width); + height: var(--#{$prefix}spinner-height); + vertical-align: var(--#{$prefix}spinner-vertical-align); + // stylelint-disable-next-line property-disallowed-list + border-radius: 50%; + animation: var(--#{$prefix}spinner-animation-speed) linear infinite var(--#{$prefix}spinner-animation-name); +} + // scss-docs-start spinner-border-keyframes @keyframes spinner-border { to { transform: rotate(360deg) #{"/* rtl:ignore */"}; } @@ -9,21 +20,25 @@ // scss-docs-end spinner-border-keyframes .spinner-border { - display: inline-block; - width: $spinner-width; - height: $spinner-height; - vertical-align: $spinner-vertical-align; - border: $spinner-border-width solid currentColor; + // scss-docs-start spinner-border-css-vars + --#{$prefix}spinner-width: #{$spinner-width}; + --#{$prefix}spinner-height: #{$spinner-height}; + --#{$prefix}spinner-vertical-align: #{$spinner-vertical-align}; + --#{$prefix}spinner-border-width: #{$spinner-border-width}; + --#{$prefix}spinner-animation-speed: #{$spinner-animation-speed}; + --#{$prefix}spinner-animation-name: spinner-border; + // scss-docs-end spinner-border-css-vars + + border: var(--#{$prefix}spinner-border-width) solid currentcolor; border-right-color: transparent; - // stylelint-disable-next-line property-disallowed-list - border-radius: 50%; - animation: $spinner-animation-speed linear infinite spinner-border; } .spinner-border-sm { - width: $spinner-width-sm; - height: $spinner-height-sm; - border-width: $spinner-border-width-sm; + // scss-docs-start spinner-border-sm-css-vars + --#{$prefix}spinner-width: #{$spinner-width-sm}; + --#{$prefix}spinner-height: #{$spinner-height-sm}; + --#{$prefix}spinner-border-width: #{$spinner-border-width-sm}; + // scss-docs-end spinner-border-sm-css-vars } // @@ -43,27 +58,28 @@ // scss-docs-end spinner-grow-keyframes .spinner-grow { - display: inline-block; - width: $spinner-width; - height: $spinner-height; - vertical-align: $spinner-vertical-align; - background-color: currentColor; - // stylelint-disable-next-line property-disallowed-list - border-radius: 50%; + // scss-docs-start spinner-grow-css-vars + --#{$prefix}spinner-width: #{$spinner-width}; + --#{$prefix}spinner-height: #{$spinner-height}; + --#{$prefix}spinner-vertical-align: #{$spinner-vertical-align}; + --#{$prefix}spinner-animation-speed: #{$spinner-animation-speed}; + --#{$prefix}spinner-animation-name: spinner-grow; + // scss-docs-end spinner-grow-css-vars + + background-color: currentcolor; opacity: 0; - animation: $spinner-animation-speed linear infinite spinner-grow; } .spinner-grow-sm { - width: $spinner-width-sm; - height: $spinner-height-sm; + --#{$prefix}spinner-width: #{$spinner-width-sm}; + --#{$prefix}spinner-height: #{$spinner-height-sm}; } @if $enable-reduced-motion { @media (prefers-reduced-motion: reduce) { .spinner-border, .spinner-grow { - animation-duration: $spinner-animation-speed * 2; + --#{$prefix}spinner-animation-speed: #{$spinner-animation-speed * 2}; } } } diff --git a/assets/stylesheets/bootstrap/_tables.scss b/assets/stylesheets/bootstrap/_tables.scss index e10e4c4..1fdd43c 100644 --- a/assets/stylesheets/bootstrap/_tables.scss +++ b/assets/stylesheets/bootstrap/_tables.scss @@ -3,20 +3,22 @@ // .table { - --#{$variable-prefix}table-bg: #{$table-bg}; - --#{$variable-prefix}table-accent-bg: #{$table-accent-bg}; - --#{$variable-prefix}table-striped-color: #{$table-striped-color}; - --#{$variable-prefix}table-striped-bg: #{$table-striped-bg}; - --#{$variable-prefix}table-active-color: #{$table-active-color}; - --#{$variable-prefix}table-active-bg: #{$table-active-bg}; - --#{$variable-prefix}table-hover-color: #{$table-hover-color}; - --#{$variable-prefix}table-hover-bg: #{$table-hover-bg}; + --#{$prefix}table-color: #{$table-color}; + --#{$prefix}table-bg: #{$table-bg}; + --#{$prefix}table-border-color: #{$table-border-color}; + --#{$prefix}table-accent-bg: #{$table-accent-bg}; + --#{$prefix}table-striped-color: #{$table-striped-color}; + --#{$prefix}table-striped-bg: #{$table-striped-bg}; + --#{$prefix}table-active-color: #{$table-active-color}; + --#{$prefix}table-active-bg: #{$table-active-bg}; + --#{$prefix}table-hover-color: #{$table-hover-color}; + --#{$prefix}table-hover-bg: #{$table-hover-bg}; width: 100%; margin-bottom: $spacer; - color: $table-color; + color: var(--#{$prefix}table-color); vertical-align: $table-cell-vertical-align; - border-color: $table-border-color; + border-color: var(--#{$prefix}table-border-color); // Target th & td // We need the child combinator to prevent styles leaking to nested tables which doesn't have a `.table` class. @@ -25,9 +27,9 @@ // stylelint-disable-next-line selector-max-universal > :not(caption) > * > * { padding: $table-cell-padding-y $table-cell-padding-x; - background-color: var(--#{$variable-prefix}table-bg); + background-color: var(--#{$prefix}table-bg); border-bottom-width: $table-border-width; - box-shadow: inset 0 0 0 9999px var(--#{$variable-prefix}table-accent-bg); + box-shadow: inset 0 0 0 9999px var(--#{$prefix}table-accent-bg); } > tbody { @@ -37,13 +39,11 @@ > thead { vertical-align: bottom; } - - // Highlight border color between thead, tbody and tfoot. - > :not(:first-child) { - border-top: (2 * $table-border-width) solid $table-group-separator-color; - } } +.table-group-divider { + border-top: ($table-border-width * 2) solid $table-group-separator-color; +} // // Change placement of captions with a class @@ -101,10 +101,19 @@ // // Default zebra-stripe styles (alternating gray and transparent backgrounds) +// For rows .table-striped { > tbody > tr:nth-of-type(#{$table-striped-order}) > * { - --#{$variable-prefix}table-accent-bg: var(--#{$variable-prefix}table-striped-bg); - color: var(--#{$variable-prefix}table-striped-color); + --#{$prefix}table-accent-bg: var(--#{$prefix}table-striped-bg); + color: var(--#{$prefix}table-striped-color); + } +} + +// For columns +.table-striped-columns { + > :not(caption) > tr > :nth-child(#{$table-striped-columns-order}) { + --#{$prefix}table-accent-bg: var(--#{$prefix}table-striped-bg); + color: var(--#{$prefix}table-striped-color); } } @@ -113,8 +122,8 @@ // The `.table-active` class can be added to highlight rows or cells .table-active { - --#{$variable-prefix}table-accent-bg: var(--#{$variable-prefix}table-active-bg); - color: var(--#{$variable-prefix}table-active-color); + --#{$prefix}table-accent-bg: var(--#{$prefix}table-active-bg); + color: var(--#{$prefix}table-active-color); } // Hover effect @@ -123,8 +132,8 @@ .table-hover { > tbody > tr:hover > * { - --#{$variable-prefix}table-accent-bg: var(--#{$variable-prefix}table-hover-bg); - color: var(--#{$variable-prefix}table-hover-color); + --#{$prefix}table-accent-bg: var(--#{$prefix}table-hover-bg); + color: var(--#{$prefix}table-hover-color); } } diff --git a/assets/stylesheets/bootstrap/_toasts.scss b/assets/stylesheets/bootstrap/_toasts.scss index 0a2d6ec..68ed8ab 100644 --- a/assets/stylesheets/bootstrap/_toasts.scss +++ b/assets/stylesheets/bootstrap/_toasts.scss @@ -1,14 +1,31 @@ .toast { - width: $toast-max-width; + // scss-docs-start toast-css-vars + --#{$prefix}toast-padding-x: #{$toast-padding-x}; + --#{$prefix}toast-padding-y: #{$toast-padding-y}; + --#{$prefix}toast-spacing: #{$toast-spacing}; + --#{$prefix}toast-max-width: #{$toast-max-width}; + @include rfs($toast-font-size, --#{$prefix}toast-font-size); + --#{$prefix}toast-color: #{$toast-color}; + --#{$prefix}toast-bg: #{$toast-background-color}; + --#{$prefix}toast-border-width: #{$toast-border-width}; + --#{$prefix}toast-border-color: #{$toast-border-color}; + --#{$prefix}toast-border-radius: #{$toast-border-radius}; + --#{$prefix}toast-box-shadow: #{$toast-box-shadow}; + --#{$prefix}toast-header-color: #{$toast-header-color}; + --#{$prefix}toast-header-bg: #{$toast-header-background-color}; + --#{$prefix}toast-header-border-color: #{$toast-header-border-color}; + // scss-docs-end toast-css-vars + + width: var(--#{$prefix}toast-max-width); max-width: 100%; - @include font-size($toast-font-size); - color: $toast-color; + @include font-size(var(--#{$prefix}toast-font-size)); + color: var(--#{$prefix}toast-color); pointer-events: auto; - background-color: $toast-background-color; + background-color: var(--#{$prefix}toast-bg); background-clip: padding-box; - border: $toast-border-width solid $toast-border-color; - box-shadow: $toast-box-shadow; - @include border-radius($toast-border-radius); + border: var(--#{$prefix}toast-border-width) solid var(--#{$prefix}toast-border-color); + box-shadow: var(--#{$prefix}toast-box-shadow); + @include border-radius(var(--#{$prefix}toast-border-radius)); &.showing { opacity: 0; @@ -20,32 +37,34 @@ } .toast-container { + position: absolute; + z-index: $zindex-toast; width: max-content; max-width: 100%; pointer-events: none; > :not(:last-child) { - margin-bottom: $toast-spacing; + margin-bottom: var(--#{$prefix}toast-spacing); } } .toast-header { display: flex; align-items: center; - padding: $toast-padding-y $toast-padding-x; - color: $toast-header-color; - background-color: $toast-header-background-color; + padding: var(--#{$prefix}toast-padding-y) var(--#{$prefix}toast-padding-x); + color: var(--#{$prefix}toast-header-color); + background-color: var(--#{$prefix}toast-header-bg); background-clip: padding-box; - border-bottom: $toast-border-width solid $toast-header-border-color; - @include border-top-radius(subtract($toast-border-radius, $toast-border-width)); + border-bottom: var(--#{$prefix}toast-border-width) solid var(--#{$prefix}toast-header-border-color); + @include border-top-radius(calc(var(--#{$prefix}toast-border-radius) - var(--#{$prefix}toast-border-width))); .btn-close { - margin-right: $toast-padding-x * -.5; - margin-left: $toast-padding-x; + margin-right: calc(var(--#{$prefix}toast-padding-x) * -.5); // stylelint-disable-line function-disallowed-list + margin-left: var(--#{$prefix}toast-padding-x); } } .toast-body { - padding: $toast-padding-x; // apply to both vertical and horizontal + padding: var(--#{$prefix}toast-padding-x); word-wrap: break-word; } diff --git a/assets/stylesheets/bootstrap/_tooltip.scss b/assets/stylesheets/bootstrap/_tooltip.scss index 75ff078..7da3df3 100644 --- a/assets/stylesheets/bootstrap/_tooltip.scss +++ b/assets/stylesheets/bootstrap/_tooltip.scss @@ -1,24 +1,39 @@ // Base class .tooltip { - position: absolute; - z-index: $zindex-tooltip; + // scss-docs-start tooltip-css-vars + --#{$prefix}tooltip-zindex: #{$zindex-tooltip}; + --#{$prefix}tooltip-max-width: #{$tooltip-max-width}; + --#{$prefix}tooltip-padding-x: #{$tooltip-padding-x}; + --#{$prefix}tooltip-padding-y: #{$tooltip-padding-y}; + --#{$prefix}tooltip-margin: #{$tooltip-margin}; + @include rfs($tooltip-font-size, --#{$prefix}tooltip-font-size); + --#{$prefix}tooltip-color: #{$tooltip-color}; + --#{$prefix}tooltip-bg: #{$tooltip-bg}; + --#{$prefix}tooltip-border-radius: #{$tooltip-border-radius}; + --#{$prefix}tooltip-opacity: #{$tooltip-opacity}; + --#{$prefix}tooltip-arrow-width: #{$tooltip-arrow-width}; + --#{$prefix}tooltip-arrow-height: #{$tooltip-arrow-height}; + // scss-docs-end tooltip-css-vars + + z-index: var(--#{$prefix}tooltip-zindex); display: block; - margin: $tooltip-margin; + padding: var(--#{$prefix}tooltip-arrow-height); + margin: var(--#{$prefix}tooltip-margin); + @include deprecate("`$tooltip-margin`", "v5", "v5.x", true); // Our parent element can be arbitrary since tooltips are by default inserted as a sibling of their target element. // So reset our font and text properties to avoid inheriting weird values. @include reset-text(); - @include font-size($tooltip-font-size); + @include font-size(var(--#{$prefix}tooltip-font-size)); // Allow breaking very long words so they don't overflow the tooltip's bounds word-wrap: break-word; opacity: 0; - &.show { opacity: $tooltip-opacity; } + &.show { opacity: var(--#{$prefix}tooltip-opacity); } .tooltip-arrow { - position: absolute; display: block; - width: $tooltip-arrow-width; - height: $tooltip-arrow-height; + width: var(--#{$prefix}tooltip-arrow-width); + height: var(--#{$prefix}tooltip-arrow-height); &::before { position: absolute; @@ -29,66 +44,56 @@ } } -.bs-tooltip-top { - padding: $tooltip-arrow-height 0; +.bs-tooltip-top .tooltip-arrow { + bottom: 0; - .tooltip-arrow { - bottom: 0; - - &::before { - top: -1px; - border-width: $tooltip-arrow-height ($tooltip-arrow-width * .5) 0; - border-top-color: $tooltip-arrow-color; - } + &::before { + top: -1px; + border-width: var(--#{$prefix}tooltip-arrow-height) calc(var(--#{$prefix}tooltip-arrow-width) * .5) 0; // stylelint-disable-line function-disallowed-list + border-top-color: var(--#{$prefix}tooltip-bg); } } -.bs-tooltip-end { - padding: 0 $tooltip-arrow-height; +/* rtl:begin:ignore */ +.bs-tooltip-end .tooltip-arrow { + left: 0; + width: var(--#{$prefix}tooltip-arrow-height); + height: var(--#{$prefix}tooltip-arrow-width); - .tooltip-arrow { - left: 0; - width: $tooltip-arrow-height; - height: $tooltip-arrow-width; - - &::before { - right: -1px; - border-width: ($tooltip-arrow-width * .5) $tooltip-arrow-height ($tooltip-arrow-width * .5) 0; - border-right-color: $tooltip-arrow-color; - } + &::before { + right: -1px; + border-width: calc(var(--#{$prefix}tooltip-arrow-width) * .5) var(--#{$prefix}tooltip-arrow-height) calc(var(--#{$prefix}tooltip-arrow-width) * .5) 0; // stylelint-disable-line function-disallowed-list + border-right-color: var(--#{$prefix}tooltip-bg); } } -.bs-tooltip-bottom { - padding: $tooltip-arrow-height 0; +/* rtl:end:ignore */ - .tooltip-arrow { - top: 0; +.bs-tooltip-bottom .tooltip-arrow { + top: 0; - &::before { - bottom: -1px; - border-width: 0 ($tooltip-arrow-width * .5) $tooltip-arrow-height; - border-bottom-color: $tooltip-arrow-color; - } + &::before { + bottom: -1px; + border-width: 0 calc(var(--#{$prefix}tooltip-arrow-width) * .5) var(--#{$prefix}tooltip-arrow-height); // stylelint-disable-line function-disallowed-list + border-bottom-color: var(--#{$prefix}tooltip-bg); } } -.bs-tooltip-start { - padding: 0 $tooltip-arrow-height; - - .tooltip-arrow { - right: 0; - width: $tooltip-arrow-height; - height: $tooltip-arrow-width; +/* rtl:begin:ignore */ +.bs-tooltip-start .tooltip-arrow { + right: 0; + width: var(--#{$prefix}tooltip-arrow-height); + height: var(--#{$prefix}tooltip-arrow-width); - &::before { - left: -1px; - border-width: ($tooltip-arrow-width * .5) 0 ($tooltip-arrow-width * .5) $tooltip-arrow-height; - border-left-color: $tooltip-arrow-color; - } + &::before { + left: -1px; + border-width: calc(var(--#{$prefix}tooltip-arrow-width) * .5) 0 calc(var(--#{$prefix}tooltip-arrow-width) * .5) var(--#{$prefix}tooltip-arrow-height); // stylelint-disable-line function-disallowed-list + border-left-color: var(--#{$prefix}tooltip-bg); } } +/* rtl:end:ignore */ + .bs-tooltip-auto { &[data-popper-placement^="top"] { @extend .bs-tooltip-top; @@ -106,10 +111,10 @@ // Wrapper for the tooltip content .tooltip-inner { - max-width: $tooltip-max-width; - padding: $tooltip-padding-y $tooltip-padding-x; - color: $tooltip-color; + max-width: var(--#{$prefix}tooltip-max-width); + padding: var(--#{$prefix}tooltip-padding-y) var(--#{$prefix}tooltip-padding-x); + color: var(--#{$prefix}tooltip-color); text-align: center; - background-color: $tooltip-bg; - @include border-radius($tooltip-border-radius); + background-color: var(--#{$prefix}tooltip-bg); + @include border-radius(var(--#{$prefix}tooltip-border-radius)); } diff --git a/assets/stylesheets/bootstrap/_type.scss b/assets/stylesheets/bootstrap/_type.scss index b2d524c..37d64bf 100644 --- a/assets/stylesheets/bootstrap/_type.scss +++ b/assets/stylesheets/bootstrap/_type.scss @@ -35,6 +35,8 @@ @each $display, $font-size in $display-font-sizes { .display-#{$display} { @include font-size($font-size); + font-family: $display-font-family; + font-style: $display-font-style; font-weight: $display-font-weight; line-height: $display-line-height; } diff --git a/assets/stylesheets/bootstrap/_utilities.scss b/assets/stylesheets/bootstrap/_utilities.scss index 960d6f1..1e0d141 100644 --- a/assets/stylesheets/bootstrap/_utilities.scss +++ b/assets/stylesheets/bootstrap/_utilities.scss @@ -1,5 +1,3 @@ -// stylelint-disable indentation - // Utilities $utilities: () !default; @@ -101,14 +99,14 @@ $utilities: map-merge( "border": ( property: border, values: ( - null: $border-width solid $border-color, + null: var(--#{$prefix}border-width) var(--#{$prefix}border-style) var(--#{$prefix}border-color), 0: 0, ) ), "border-top": ( property: border-top, values: ( - null: $border-width solid $border-color, + null: var(--#{$prefix}border-width) var(--#{$prefix}border-style) var(--#{$prefix}border-color), 0: 0, ) ), @@ -116,14 +114,14 @@ $utilities: map-merge( property: border-right, class: border-end, values: ( - null: $border-width solid $border-color, + null: var(--#{$prefix}border-width) var(--#{$prefix}border-style) var(--#{$prefix}border-color), 0: 0, ) ), "border-bottom": ( property: border-bottom, values: ( - null: $border-width solid $border-color, + null: var(--#{$prefix}border-width) var(--#{$prefix}border-style) var(--#{$prefix}border-color), 0: 0, ) ), @@ -131,20 +129,35 @@ $utilities: map-merge( property: border-left, class: border-start, values: ( - null: $border-width solid $border-color, + null: var(--#{$prefix}border-width) var(--#{$prefix}border-style) var(--#{$prefix}border-color), 0: 0, ) ), "border-color": ( property: border-color, class: border, - values: map-merge($theme-colors, ("white": $white)) + local-vars: ( + "border-opacity": 1 + ), + values: $utilities-border-colors ), "border-width": ( - property: border-width, + css-var: true, + css-variable-name: border-width, class: border, values: $border-widths ), + "border-opacity": ( + css-var: true, + class: border-opacity, + values: ( + 10: .1, + 25: .25, + 50: .5, + 75: .75, + 100: 1 + ) + ), // scss-docs-end utils-borders // Sizing utilities // scss-docs-start utils-sizing @@ -238,12 +251,6 @@ $utilities: map-merge( class: flex, values: wrap nowrap wrap-reverse ), - "gap": ( - responsive: true, - property: gap, - class: gap, - values: $spacers - ), "justify-content": ( responsive: true, property: justify-content, @@ -436,13 +443,20 @@ $utilities: map-merge( class: ps, values: $spacers ), + // Gap utility + "gap": ( + responsive: true, + property: gap, + class: gap, + values: $spacers + ), // scss-docs-end utils-spacing // Text // scss-docs-start utils-text "font-family": ( property: font-family, class: font, - values: (monospace: var(--#{$variable-prefix}font-monospace)) + values: (monospace: var(--#{$prefix}font-monospace)) ), "font-size": ( rfs: true, @@ -463,6 +477,7 @@ $utilities: map-merge( lighter: $font-weight-lighter, normal: $font-weight-normal, bold: $font-weight-bold, + semibold: $font-weight-semibold, bolder: $font-weight-bolder ) ), @@ -567,7 +582,7 @@ $utilities: map-merge( "gradient": ( property: background-image, class: bg, - values: (gradient: var(--#{$variable-prefix}gradient)) + values: (gradient: var(--#{$prefix}gradient)) ), // scss-docs-start utils-interaction "user-select": ( @@ -585,34 +600,36 @@ $utilities: map-merge( property: border-radius, class: rounded, values: ( - null: $border-radius, + null: var(--#{$prefix}border-radius), 0: 0, - 1: $border-radius-sm, - 2: $border-radius, - 3: $border-radius-lg, + 1: var(--#{$prefix}border-radius-sm), + 2: var(--#{$prefix}border-radius), + 3: var(--#{$prefix}border-radius-lg), + 4: var(--#{$prefix}border-radius-xl), + 5: var(--#{$prefix}border-radius-2xl), circle: 50%, - pill: $border-radius-pill + pill: var(--#{$prefix}border-radius-pill) ) ), "rounded-top": ( property: border-top-left-radius border-top-right-radius, class: rounded-top, - values: (null: $border-radius) + values: (null: var(--#{$prefix}border-radius)) ), "rounded-end": ( property: border-top-right-radius border-bottom-right-radius, class: rounded-end, - values: (null: $border-radius) + values: (null: var(--#{$prefix}border-radius)) ), "rounded-bottom": ( property: border-bottom-right-radius border-bottom-left-radius, class: rounded-bottom, - values: (null: $border-radius) + values: (null: var(--#{$prefix}border-radius)) ), "rounded-start": ( property: border-bottom-left-radius border-top-left-radius, class: rounded-start, - values: (null: $border-radius) + values: (null: var(--#{$prefix}border-radius)) ), // scss-docs-end utils-border-radius // scss-docs-start utils-visibility diff --git a/assets/stylesheets/bootstrap/_variables.scss b/assets/stylesheets/bootstrap/_variables.scss index f33b804..3048510 100644 --- a/assets/stylesheets/bootstrap/_variables.scss +++ b/assets/stylesheets/bootstrap/_variables.scss @@ -60,40 +60,13 @@ $colors: ( "green": $green, "teal": $teal, "cyan": $cyan, + "black": $black, "white": $white, "gray": $gray-600, "gray-dark": $gray-800 ) !default; // scss-docs-end colors-map -// scss-docs-start theme-color-variables -$primary: $blue !default; -$secondary: $gray-600 !default; -$success: $green !default; -$info: $cyan !default; -$warning: $yellow !default; -$danger: $red !default; -$light: $gray-100 !default; -$dark: $gray-900 !default; -// scss-docs-end theme-color-variables - -// scss-docs-start theme-colors-map -$theme-colors: ( - "primary": $primary, - "secondary": $secondary, - "success": $success, - "info": $info, - "warning": $warning, - "danger": $danger, - "light": $light, - "dark": $dark -) !default; -// scss-docs-end theme-colors-map - -// scss-docs-start theme-colors-rgb -$theme-colors-rgb: map-loop($theme-colors, to-rgb, "$value") !default; -// scss-docs-end theme-colors-rgb - // The contrast ratio to reach against white, to determine if color changes from "light" to "dark". Acceptable values for WCAG 2.0 are 3, 4.5 and 7. // See https://www.w3.org/TR/WCAG20/#visual-audio-contrast-contrast $min-contrast-ratio: 4.5 !default; @@ -228,8 +201,8 @@ $indigos: ( ) !default; $purples: ( - "purple-100": $purple-200, - "purple-200": $purple-100, + "purple-100": $purple-100, + "purple-200": $purple-200, "purple-300": $purple-300, "purple-400": $purple-400, "purple-500": $purple-500, @@ -324,6 +297,30 @@ $cyans: ( ) !default; // fusv-enable +// scss-docs-start theme-color-variables +$primary: $blue !default; +$secondary: $gray-600 !default; +$success: $green !default; +$info: $cyan !default; +$warning: $yellow !default; +$danger: $red !default; +$light: $gray-100 !default; +$dark: $gray-900 !default; +// scss-docs-end theme-color-variables + +// scss-docs-start theme-colors-map +$theme-colors: ( + "primary": $primary, + "secondary": $secondary, + "success": $success, + "info": $info, + "warning": $warning, + "danger": $danger, + "light": $light, + "dark": $dark +) !default; +// scss-docs-end theme-colors-map + // Characters which are escaped by the escape-svg function $escaped-characters: ( ("<", "%3c"), @@ -345,6 +342,7 @@ $enable-transitions: true !default; $enable-reduced-motion: true !default; $enable-smooth-scroll: true !default; $enable-grid-classes: true !default; +$enable-container-classes: true !default; $enable-cssgrid: false !default; $enable-button-pointers: true !default; $enable-rfs: true !default; @@ -355,7 +353,8 @@ $enable-important-utilities: true !default; // Prefix for :root CSS variables -$variable-prefix: bs- !default; +$variable-prefix: bs- !default; // Deprecated in v5.2.0 for the shorter `$prefix` +$prefix: $variable-prefix !default; // Gradient // @@ -381,8 +380,6 @@ $spacers: ( 4: $spacer * 1.5, 5: $spacer * 3, ) !default; - -$negative-spacers: if($enable-negative-margins, negativify-map($spacers), null) !default; // scss-docs-end spacer-variables-maps // Position @@ -405,39 +402,6 @@ $body-bg: $white !default; $body-color: $gray-900 !default; $body-text-align: null !default; -// Utilities maps -// -// Extends the default `$theme-colors` maps to help create our utilities. - -// Come v6, we'll de-dupe these variables. Until then, for backward compatibility, we keep them to reassign. -// scss-docs-start utilities-colors -$utilities-colors: $theme-colors-rgb !default; -// scss-docs-end utilities-colors - -// scss-docs-start utilities-text-colors -$utilities-text: map-merge( - $utilities-colors, - ( - "black": to-rgb($black), - "white": to-rgb($white), - "body": to-rgb($body-color) - ) -) !default; -$utilities-text-colors: map-loop($utilities-text, rgba-css-var, "$key", "text") !default; -// scss-docs-end utilities-text-colors - -// scss-docs-start utilities-bg-colors -$utilities-bg: map-merge( - $utilities-colors, - ( - "black": to-rgb($black), - "white": to-rgb($white), - "body": to-rgb($body-bg) - ) -) !default; -$utilities-bg-colors: map-loop($utilities-bg, rgba-css-var, "$key", "bg") !default; -// scss-docs-end utilities-bg-colors - // Links // // Style anchor elements. @@ -503,11 +467,9 @@ $grid-columns: 12 !default; $grid-gutter-width: 1.5rem !default; $grid-row-columns: 6 !default; -$gutters: $spacers !default; - // Container padding -$container-padding-x: $grid-gutter-width * .5 !default; +$container-padding-x: $grid-gutter-width !default; // Components @@ -524,13 +486,17 @@ $border-widths: ( 5: 5px ) !default; +$border-style: solid !default; $border-color: $gray-300 !default; +$border-color-translucent: rgba($black, .175) !default; // scss-docs-end border-variables // scss-docs-start border-radius-variables -$border-radius: .25rem !default; -$border-radius-sm: .2rem !default; -$border-radius-lg: .3rem !default; +$border-radius: .375rem !default; +$border-radius-sm: .25rem !default; +$border-radius-lg: .5rem !default; +$border-radius-xl: 1rem !default; +$border-radius-2xl: 2rem !default; $border-radius-pill: 50rem !default; // scss-docs-end border-radius-variables @@ -574,11 +540,11 @@ $aspect-ratios: ( // scss-docs-start font-variables // stylelint-disable value-keyword-case -$font-family-sans-serif: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji" !default; +$font-family-sans-serif: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji" !default; $font-family-monospace: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace !default; // stylelint-enable value-keyword-case -$font-family-base: var(--#{$variable-prefix}font-sans-serif) !default; -$font-family-code: var(--#{$variable-prefix}font-monospace) !default; +$font-family-base: var(--#{$prefix}font-sans-serif) !default; +$font-family-code: var(--#{$prefix}font-monospace) !default; // $font-size-root affects the value of `rem`, which is used for as well font sizes, paddings, and margins // $font-size-base affects the font size of the body text @@ -590,6 +556,7 @@ $font-size-lg: $font-size-base * 1.25 !default; $font-weight-lighter: lighter !default; $font-weight-light: 300 !default; $font-weight-normal: 400 !default; +$font-weight-semibold: 600 !default; $font-weight-bold: 700 !default; $font-weight-bolder: bolder !default; @@ -637,6 +604,8 @@ $display-font-sizes: ( 6: 2.5rem ) !default; +$display-font-family: null !default; +$display-font-style: null !default; $display-font-weight: 300 !default; $display-line-height: $headings-line-height !default; // scss-docs-end display-headings @@ -660,22 +629,26 @@ $blockquote-footer-font-size: $small-font-size !default; $hr-margin-y: $spacer !default; $hr-color: inherit !default; -$hr-height: $border-width !default; + +// fusv-disable +$hr-bg-color: null !default; // Deprecated in v5.2.0 +$hr-height: null !default; // Deprecated in v5.2.0 +// fusv-enable + +$hr-border-color: null !default; // Allows for inherited colors +$hr-border-width: $border-width !default; $hr-opacity: .25 !default; $legend-margin-bottom: .5rem !default; $legend-font-size: 1.5rem !default; $legend-font-weight: null !default; -$mark-padding: .2em !default; - $dt-font-weight: $font-weight-bold !default; -$nested-kbd-font-weight: $font-weight-bold !default; - $list-inline-padding: .5rem !default; -$mark-bg: #fcf8e3 !default; +$mark-padding: .1875em !default; +$mark-bg: $yellow-100 !default; // scss-docs-end type-variables @@ -691,7 +664,7 @@ $table-cell-padding-x-sm: .25rem !default; $table-cell-vertical-align: top !default; -$table-color: $body-color !default; +$table-color: var(--#{$prefix}body-color) !default; $table-bg: transparent !default; $table-accent-bg: transparent !default; @@ -711,11 +684,12 @@ $table-hover-bg: rgba($black, $table-hover-bg-factor) !default; $table-border-factor: .1 !default; $table-border-width: $border-width !default; -$table-border-color: $border-color !default; +$table-border-color: var(--#{$prefix}border-color) !default; $table-striped-order: odd !default; +$table-striped-columns-order: even !default; -$table-group-separator-color: currentColor !default; +$table-group-separator-color: currentcolor !default; $table-caption-color: $text-muted !default; @@ -794,8 +768,8 @@ $btn-focus-box-shadow: $input-btn-focus-box-shadow !default; $btn-disabled-opacity: .65 !default; $btn-active-box-shadow: inset 0 3px 5px rgba($black, .125) !default; -$btn-link-color: $link-color !default; -$btn-link-hover-color: $link-hover-color !default; +$btn-link-color: var(--#{$prefix}link-color) !default; +$btn-link-hover-color: var(--#{$prefix}link-hover-color) !default; $btn-link-disabled-color: $gray-600 !default; // Allows for customizing button radius independently from global border radius @@ -851,6 +825,7 @@ $input-padding-x-lg: $input-btn-padding-x-lg !default; $input-font-size-lg: $input-btn-font-size-lg !default; $input-bg: $body-bg !default; +$input-disabled-color: null !default; $input-disabled-bg: $gray-200 !default; $input-disabled-border-color: null !default; @@ -908,7 +883,7 @@ $form-check-input-focus-box-shadow: $input-btn-focus-box-shadow !default; $form-check-input-checked-color: $component-active-color !default; $form-check-input-checked-bg-color: $component-active-bg !default; $form-check-input-checked-border-color: $form-check-input-checked-bg-color !default; -$form-check-input-checked-bg-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'><path fill='none' stroke='#{$form-check-input-checked-color}' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='M6 10l3 3l6-6'/></svg>") !default; +$form-check-input-checked-bg-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'><path fill='none' stroke='#{$form-check-input-checked-color}' stroke-linecap='round' stroke-linejoin='round' stroke-width='3' d='m6 10 3 3 6-6'/></svg>") !default; $form-check-radio-checked-bg-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'><circle r='2' fill='#{$form-check-input-checked-color}'/></svg>") !default; $form-check-input-indeterminate-color: $component-active-color !default; @@ -964,7 +939,7 @@ $form-select-disabled-border-color: $input-disabled-border-color !default; $form-select-bg-position: right $form-select-padding-x center !default; $form-select-bg-size: 16px 12px !default; // In pixels because image dimensions $form-select-indicator-color: $gray-800 !default; -$form-select-indicator: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill='none' stroke='#{$form-select-indicator-color}' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/></svg>") !default; +$form-select-indicator: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'><path fill='none' stroke='#{$form-select-indicator-color}' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/></svg>") !default; $form-select-feedback-icon-padding-end: $form-select-padding-x * 2.5 + $form-select-indicator-padding !default; $form-select-feedback-icon-position: center right $form-select-indicator-padding !default; @@ -1041,7 +1016,7 @@ $form-feedback-valid-color: $success !default; $form-feedback-invalid-color: $danger !default; $form-feedback-icon-valid-color: $form-feedback-valid-color !default; -$form-feedback-icon-valid: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'><path fill='#{$form-feedback-icon-valid-color}' d='M2.3 6.73L.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/></svg>") !default; +$form-feedback-icon-valid: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'><path fill='#{$form-feedback-icon-valid-color}' d='M2.3 6.73.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/></svg>") !default; $form-feedback-icon-invalid-color: $form-feedback-invalid-color !default; $form-feedback-icon-invalid: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='#{$form-feedback-icon-invalid-color}'><circle cx='6' cy='6' r='4.5'/><path stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/><circle cx='6' cy='8.2' r='.6' fill='#{$form-feedback-icon-invalid-color}' stroke='none'/></svg>") !default; // scss-docs-end form-feedback-variables @@ -1074,6 +1049,7 @@ $zindex-modal-backdrop: 1050 !default; $zindex-modal: 1055 !default; $zindex-popover: 1070 !default; $zindex-tooltip: 1080 !default; +$zindex-toast: 1090 !default; // scss-docs-end zindex-stack @@ -1084,8 +1060,8 @@ $nav-link-padding-y: .5rem !default; $nav-link-padding-x: 1rem !default; $nav-link-font-size: null !default; $nav-link-font-weight: null !default; -$nav-link-color: $link-color !default; -$nav-link-hover-color: $link-hover-color !default; +$nav-link-color: var(--#{$prefix}link-color) !default; +$nav-link-hover-color: var(--#{$prefix}link-hover-color) !default; $nav-link-transition: color .15s ease-in-out, background-color .15s ease-in-out, border-color .15s ease-in-out !default; $nav-link-disabled-color: $gray-600 !default; @@ -1160,7 +1136,7 @@ $dropdown-spacer: .125rem !default; $dropdown-font-size: $font-size-base !default; $dropdown-color: $body-color !default; $dropdown-bg: $white !default; -$dropdown-border-color: rgba($black, .15) !default; +$dropdown-border-color: var(--#{$prefix}border-color-translucent) !default; $dropdown-border-radius: $border-radius !default; $dropdown-border-width: $border-width !default; $dropdown-inner-border-radius: subtract($dropdown-border-radius, $dropdown-border-width) !default; @@ -1181,7 +1157,11 @@ $dropdown-item-padding-y: $spacer * .25 !default; $dropdown-item-padding-x: $spacer !default; $dropdown-header-color: $gray-600 !default; -$dropdown-header-padding: $dropdown-padding-y $dropdown-item-padding-x !default; +$dropdown-header-padding-x: $dropdown-item-padding-x !default; +$dropdown-header-padding-y: $dropdown-padding-y !default; +// fusv-disable +$dropdown-header-padding: $dropdown-header-padding-y $dropdown-header-padding-x !default; // Deprecated in v5.2.0 +// fusv-enable // scss-docs-end dropdown-variables // scss-docs-start dropdown-dark-variables @@ -1210,19 +1190,21 @@ $pagination-padding-x-sm: .5rem !default; $pagination-padding-y-lg: .75rem !default; $pagination-padding-x-lg: 1.5rem !default; -$pagination-color: $link-color !default; +$pagination-font-size: $font-size-base !default; + +$pagination-color: var(--#{$prefix}link-color) !default; $pagination-bg: $white !default; -$pagination-border-width: $border-width !default; $pagination-border-radius: $border-radius !default; -$pagination-margin-start: -$pagination-border-width !default; +$pagination-border-width: $border-width !default; +$pagination-margin-start: ($pagination-border-width * -1) !default; $pagination-border-color: $gray-300 !default; -$pagination-focus-color: $link-hover-color !default; +$pagination-focus-color: var(--#{$prefix}link-hover-color) !default; $pagination-focus-bg: $gray-200 !default; $pagination-focus-box-shadow: $input-btn-focus-box-shadow !default; $pagination-focus-outline: 0 !default; -$pagination-hover-color: $link-hover-color !default; +$pagination-hover-color: var(--#{$prefix}link-hover-color) !default; $pagination-hover-bg: $gray-200 !default; $pagination-hover-border-color: $gray-300 !default; @@ -1255,7 +1237,7 @@ $card-spacer-y: $spacer !default; $card-spacer-x: $spacer !default; $card-title-spacer-y: $spacer * .5 !default; $card-border-width: $border-width !default; -$card-border-color: rgba($black, .125) !default; +$card-border-color: var(--#{$prefix}border-color-translucent) !default; $card-border-radius: $border-radius !default; $card-box-shadow: null !default; $card-inner-border-radius: subtract($card-border-radius, $card-border-width) !default; @@ -1275,10 +1257,10 @@ $card-group-margin: $grid-gutter-width * .5 !default; // scss-docs-start accordion-variables $accordion-padding-y: 1rem !default; $accordion-padding-x: 1.25rem !default; -$accordion-color: $body-color !default; +$accordion-color: var(--#{$prefix}body-color) !default; $accordion-bg: $body-bg !default; $accordion-border-width: $border-width !default; -$accordion-border-color: rgba($black, .125) !default; +$accordion-border-color: var(--#{$prefix}border-color) !default; $accordion-border-radius: $border-radius !default; $accordion-inner-border-radius: subtract($accordion-border-radius, $accordion-border-width) !default; @@ -1288,7 +1270,7 @@ $accordion-body-padding-x: $accordion-padding-x !default; $accordion-button-padding-y: $accordion-padding-y !default; $accordion-button-padding-x: $accordion-padding-x !default; $accordion-button-color: $accordion-color !default; -$accordion-button-bg: $accordion-bg !default; +$accordion-button-bg: var(--#{$prefix}accordion-bg) !default; $accordion-transition: $btn-transition, border-radius .15s ease !default; $accordion-button-active-bg: tint-color($component-active-bg, 90%) !default; $accordion-button-active-color: shade-color($primary, 10%) !default; @@ -1317,11 +1299,13 @@ $tooltip-border-radius: $border-radius !default; $tooltip-opacity: .9 !default; $tooltip-padding-y: $spacer * .25 !default; $tooltip-padding-x: $spacer * .5 !default; -$tooltip-margin: 0 !default; +$tooltip-margin: null !default; // TODO: remove this in v6 $tooltip-arrow-width: .8rem !default; $tooltip-arrow-height: .4rem !default; -$tooltip-arrow-color: $tooltip-bg !default; +// fusv-disable +$tooltip-arrow-color: null !default; // Deprecated in Bootstrap 5.2.0 for CSS variables +// fusv-enable // scss-docs-end tooltip-variables // Form tooltips must come after regular tooltips @@ -1342,13 +1326,14 @@ $popover-font-size: $font-size-sm !default; $popover-bg: $white !default; $popover-max-width: 276px !default; $popover-border-width: $border-width !default; -$popover-border-color: rgba($black, .2) !default; +$popover-border-color: var(--#{$prefix}border-color-translucent) !default; $popover-border-radius: $border-radius-lg !default; $popover-inner-border-radius: subtract($popover-border-radius, $popover-border-width) !default; $popover-box-shadow: $box-shadow !default; +$popover-header-font-size: $font-size-base !default; $popover-header-bg: shade-color($popover-bg, 6%) !default; -$popover-header-color: $headings-color !default; +$popover-header-color: var(--#{$prefix}heading-color) !default; $popover-header-padding-y: .5rem !default; $popover-header-padding-x: $spacer !default; @@ -1358,11 +1343,14 @@ $popover-body-padding-x: $spacer !default; $popover-arrow-width: 1rem !default; $popover-arrow-height: .5rem !default; -$popover-arrow-color: $popover-bg !default; - -$popover-arrow-outer-color: fade-in($popover-border-color, .05) !default; // scss-docs-end popover-variables +// fusv-disable +// Deprecated in Bootstrap 5.2.0 for CSS variables +$popover-arrow-color: $popover-bg !default; +$popover-arrow-outer-color: var(--#{$prefix}border-color-translucent) !default; +// fusv-enable + // Toasts @@ -1373,8 +1361,8 @@ $toast-padding-y: .5rem !default; $toast-font-size: .875rem !default; $toast-color: null !default; $toast-background-color: rgba($white, .85) !default; -$toast-border-width: 1px !default; -$toast-border-color: rgba($black, .1) !default; +$toast-border-width: $border-width !default; +$toast-border-color: var(--#{$prefix}border-color-translucent) !default; $toast-border-radius: $border-radius !default; $toast-box-shadow: $box-shadow !default; $toast-spacing: $container-padding-x !default; @@ -1411,7 +1399,7 @@ $modal-title-line-height: $line-height-base !default; $modal-content-color: null !default; $modal-content-bg: $white !default; -$modal-content-border-color: rgba($black, .2) !default; +$modal-content-border-color: var(--#{$prefix}border-color-translucent) !default; $modal-content-border-width: $border-width !default; $modal-content-border-radius: $border-radius-lg !default; $modal-content-inner-border-radius: subtract($modal-content-border-radius, $modal-content-border-width) !default; @@ -1420,14 +1408,17 @@ $modal-content-box-shadow-sm-up: $box-shadow !default; $modal-backdrop-bg: $black !default; $modal-backdrop-opacity: .5 !default; -$modal-header-border-color: $border-color !default; -$modal-footer-border-color: $modal-header-border-color !default; + +$modal-header-border-color: var(--#{$prefix}border-color) !default; $modal-header-border-width: $modal-content-border-width !default; -$modal-footer-border-width: $modal-header-border-width !default; $modal-header-padding-y: $modal-inner-padding !default; $modal-header-padding-x: $modal-inner-padding !default; $modal-header-padding: $modal-header-padding-y $modal-header-padding-x !default; // Keep this for backwards compatibility +$modal-footer-bg: null !default; +$modal-footer-border-color: $modal-header-border-color !default; +$modal-footer-border-width: $modal-header-border-width !default; + $modal-sm: 300px !default; $modal-md: 500px !default; $modal-lg: 800px !default; @@ -1509,7 +1500,7 @@ $list-group-action-active-bg: $gray-200 !default; $thumbnail-padding: .25rem !default; $thumbnail-bg: $body-bg !default; $thumbnail-border-width: $border-width !default; -$thumbnail-border-color: $gray-300 !default; +$thumbnail-border-color: var(--#{$prefix}border-color) !default; $thumbnail-border-radius: $border-radius !default; $thumbnail-box-shadow: $box-shadow-sm !default; // scss-docs-end thumbnail-variables @@ -1599,7 +1590,7 @@ $btn-close-height: $btn-close-width !default; $btn-close-padding-x: .25em !default; $btn-close-padding-y: $btn-close-padding-x !default; $btn-close-color: $black !default; -$btn-close-bg: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='#{$btn-close-color}'><path d='M.293.293a1 1 0 011.414 0L8 6.586 14.293.293a1 1 0 111.414 1.414L9.414 8l6.293 6.293a1 1 0 01-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 01-1.414-1.414L6.586 8 .293 1.707a1 1 0 010-1.414z'/></svg>") !default; +$btn-close-bg: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='#{$btn-close-color}'><path d='M.293.293a1 1 0 0 1 1.414 0L8 6.586 14.293.293a1 1 0 1 1 1.414 1.414L9.414 8l6.293 6.293a1 1 0 0 1-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 0 1-1.414-1.414L6.586 8 .293 1.707a1 1 0 0 1 0-1.414z'/></svg>") !default; $btn-close-focus-shadow: $input-btn-focus-box-shadow !default; $btn-close-opacity: .5 !default; $btn-close-hover-opacity: .75 !default; @@ -1632,10 +1623,11 @@ $offcanvas-backdrop-opacity: $modal-backdrop-opacity !default; $code-font-size: $small-font-size !default; $code-color: $pink !default; -$kbd-padding-y: .2rem !default; -$kbd-padding-x: .4rem !default; +$kbd-padding-y: .1875rem !default; +$kbd-padding-x: .375rem !default; $kbd-font-size: $code-font-size !default; -$kbd-color: $white !default; -$kbd-bg: $gray-900 !default; +$kbd-color: var(--#{$prefix}body-bg) !default; +$kbd-bg: var(--#{$prefix}body-color) !default; +$nested-kbd-font-weight: null !default; // Deprecated in v5.2.0, removing in v6 $pre-color: null !default; diff --git a/assets/stylesheets/bootstrap/bootstrap-utilities.scss b/assets/stylesheets/bootstrap/bootstrap-utilities.scss index d4f981d..c940676 100644 --- a/assets/stylesheets/bootstrap/bootstrap-utilities.scss +++ b/assets/stylesheets/bootstrap/bootstrap-utilities.scss @@ -1,13 +1,10 @@ -/*! - * Bootstrap Utilities v5.1.3 (https://getbootstrap.com/) - * Copyright 2011-2021 The Bootstrap Authors - * Copyright 2011-2021 Twitter, Inc. - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) - */ +@import "mixins/banner"; +@include bsBanner(Utilities); // Configuration @import "functions"; @import "variables"; +@import "maps"; @import "mixins"; @import "utilities"; diff --git a/assets/stylesheets/bootstrap/forms/_floating-labels.scss b/assets/stylesheets/bootstrap/forms/_floating-labels.scss index 2f42954..acefe4e 100644 --- a/assets/stylesheets/bootstrap/forms/_floating-labels.scss +++ b/assets/stylesheets/bootstrap/forms/_floating-labels.scss @@ -2,6 +2,7 @@ position: relative; > .form-control, + > .form-control-plaintext, > .form-select { height: $form-floating-height; line-height: $form-floating-line-height; @@ -11,16 +12,20 @@ position: absolute; top: 0; left: 0; + width: 100%; height: 100%; // allow textareas padding: $form-floating-padding-y $form-floating-padding-x; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; pointer-events: none; border: $input-border-width solid transparent; // Required for aligning label's text with the input as it affects inner box model transform-origin: 0 0; @include transition($form-floating-transition); } - // stylelint-disable no-duplicate-selectors - > .form-control { + > .form-control, + > .form-control-plaintext { padding: $form-floating-padding-y $form-floating-padding-x; &::placeholder { @@ -46,6 +51,7 @@ > .form-control:focus, > .form-control:not(:placeholder-shown), + > .form-control-plaintext, > .form-select { ~ label { opacity: $form-floating-label-opacity; @@ -59,5 +65,10 @@ transform: $form-floating-label-transform; } } - // stylelint-enable no-duplicate-selectors + + > .form-control-plaintext { + ~ label { + border-width: $input-border-width 0; // Required to properly position label text - as explained above + } + } } diff --git a/assets/stylesheets/bootstrap/forms/_form-check.scss b/assets/stylesheets/bootstrap/forms/_form-check.scss index 6321b41..42a2a96 100644 --- a/assets/stylesheets/bootstrap/forms/_form-check.scss +++ b/assets/stylesheets/bootstrap/forms/_form-check.scss @@ -14,6 +14,18 @@ } } +.form-check-reverse { + padding-right: $form-check-padding-start; + padding-left: 0; + text-align: right; + + .form-check-input { + float: right; + margin-right: $form-check-padding-start * -1; + margin-left: 0; + } +} + .form-check-input { width: $form-check-input-width; height: $form-check-input-width; @@ -25,7 +37,7 @@ background-size: contain; border: $form-check-input-border; appearance: none; - color-adjust: exact; // Keep themed appearance for print + print-color-adjust: exact; // Keep themed appearance for print @include transition($form-check-transition); &[type="checkbox"] { @@ -53,7 +65,7 @@ &[type="checkbox"] { @if $enable-gradients { - background-image: escape-svg($form-check-input-checked-bg-image), var(--#{$variable-prefix}gradient); + background-image: escape-svg($form-check-input-checked-bg-image), var(--#{$prefix}gradient); } @else { background-image: escape-svg($form-check-input-checked-bg-image); } @@ -61,7 +73,7 @@ &[type="radio"] { @if $enable-gradients { - background-image: escape-svg($form-check-radio-checked-bg-image), var(--#{$variable-prefix}gradient); + background-image: escape-svg($form-check-radio-checked-bg-image), var(--#{$prefix}gradient); } @else { background-image: escape-svg($form-check-radio-checked-bg-image); } @@ -73,7 +85,7 @@ border-color: $form-check-input-indeterminate-border-color; @if $enable-gradients { - background-image: escape-svg($form-check-input-indeterminate-bg-image), var(--#{$variable-prefix}gradient); + background-image: escape-svg($form-check-input-indeterminate-bg-image), var(--#{$prefix}gradient); } @else { background-image: escape-svg($form-check-input-indeterminate-bg-image); } @@ -90,6 +102,7 @@ &[disabled], &:disabled { ~ .form-check-label { + cursor: default; opacity: $form-check-label-disabled-opacity; } } @@ -123,12 +136,22 @@ background-position: $form-switch-checked-bg-position; @if $enable-gradients { - background-image: escape-svg($form-switch-checked-bg-image), var(--#{$variable-prefix}gradient); + background-image: escape-svg($form-switch-checked-bg-image), var(--#{$prefix}gradient); } @else { background-image: escape-svg($form-switch-checked-bg-image); } } } + + &.form-check-reverse { + padding-right: $form-switch-padding-start; + padding-left: 0; + + .form-check-input { + margin-right: $form-switch-padding-start * -1; + margin-left: 0; + } + } } .form-check-inline { diff --git a/assets/stylesheets/bootstrap/forms/_form-control.scss b/assets/stylesheets/bootstrap/forms/_form-control.scss index 96423c5..e707c57 100644 --- a/assets/stylesheets/bootstrap/forms/_form-control.scss +++ b/assets/stylesheets/bootstrap/forms/_form-control.scss @@ -59,13 +59,13 @@ opacity: 1; } - // Disabled and read-only inputs + // Disabled inputs // // HTML5 says that controls under a fieldset > legend:first-child won't be // disabled if the fieldset is disabled. Due to implementation difficulty, we // don't honor that edge case; we style them as disabled anyway. - &:disabled, - &[readonly] { + &:disabled { + color: $input-disabled-color; background-color: $input-disabled-bg; border-color: $input-disabled-border-color; // iOS fix for unreadable disabled content; see https://github.com/twbs/bootstrap/issues/11655. @@ -91,25 +91,6 @@ &:hover:not(:disabled):not([readonly])::file-selector-button { background-color: $form-file-button-hover-bg; } - - &::-webkit-file-upload-button { - padding: $input-padding-y $input-padding-x; - margin: (-$input-padding-y) (-$input-padding-x); - margin-inline-end: $input-padding-x; - color: $form-file-button-color; - @include gradient-bg($form-file-button-bg); - pointer-events: none; - border-color: inherit; - border-style: solid; - border-width: 0; - border-inline-end-width: $input-border-width; - border-radius: 0; // stylelint-disable-line property-disallowed-list - @include transition($btn-transition); - } - - &:hover:not(:disabled):not([readonly])::-webkit-file-upload-button { - background-color: $form-file-button-hover-bg; - } } // Readonly controls as plain text @@ -128,6 +109,10 @@ border: solid transparent; border-width: $input-border-width 0; + &:focus { + outline: 0; + } + &.form-control-sm, &.form-control-lg { padding-right: 0; @@ -153,12 +138,6 @@ margin: (-$input-padding-y-sm) (-$input-padding-x-sm); margin-inline-end: $input-padding-x-sm; } - - &::-webkit-file-upload-button { - padding: $input-padding-y-sm $input-padding-x-sm; - margin: (-$input-padding-y-sm) (-$input-padding-x-sm); - margin-inline-end: $input-padding-x-sm; - } } .form-control-lg { @@ -172,12 +151,6 @@ margin: (-$input-padding-y-lg) (-$input-padding-x-lg); margin-inline-end: $input-padding-x-lg; } - - &::-webkit-file-upload-button { - padding: $input-padding-y-lg $input-padding-x-lg; - margin: (-$input-padding-y-lg) (-$input-padding-x-lg); - margin-inline-end: $input-padding-x-lg; - } } // Make sure textareas don't shrink too much when resized @@ -200,7 +173,7 @@ textarea { .form-control-color { width: $form-color-width; - height: auto; // Override fixed browser height + height: $input-height; padding: $input-padding-y; &:not(:disabled):not([readonly]) { @@ -208,12 +181,14 @@ textarea { } &::-moz-color-swatch { - height: if(unit($input-line-height) == "", $input-line-height * 1em, $input-line-height); + border: 0 !important; // stylelint-disable-line declaration-no-important @include border-radius($input-border-radius); } &::-webkit-color-swatch { - height: if(unit($input-line-height) == "", $input-line-height * 1em, $input-line-height); @include border-radius($input-border-radius); } + + &.form-control-sm { height: $input-height-sm; } + &.form-control-lg { height: $input-height-lg; } } diff --git a/assets/stylesheets/bootstrap/forms/_form-select.scss b/assets/stylesheets/bootstrap/forms/_form-select.scss index 153ff6c..78c34b8 100644 --- a/assets/stylesheets/bootstrap/forms/_form-select.scss +++ b/assets/stylesheets/bootstrap/forms/_form-select.scss @@ -7,7 +7,6 @@ display: block; width: 100%; padding: $form-select-padding-y $form-select-indicator-padding $form-select-padding-y $form-select-padding-x; - // stylelint-disable-next-line property-no-vendor-prefix -moz-padding-start: subtract($form-select-padding-x, 3px); // See https://github.com/twbs/bootstrap/issues/32636 font-family: $form-select-font-family; @include font-size($form-select-font-size); diff --git a/assets/stylesheets/bootstrap/forms/_input-group.scss b/assets/stylesheets/bootstrap/forms/_input-group.scss index 1400529..83d52c5 100644 --- a/assets/stylesheets/bootstrap/forms/_input-group.scss +++ b/assets/stylesheets/bootstrap/forms/_input-group.scss @@ -10,7 +10,8 @@ width: 100%; > .form-control, - > .form-select { + > .form-select, + > .form-floating { position: relative; // For focus state's z-index flex: 1 1 auto; width: 1%; @@ -19,7 +20,8 @@ // Bring the "active" form control to the top of surrounding elements > .form-control:focus, - > .form-select:focus { + > .form-select:focus, + > .form-floating:focus-within { z-index: 3; } @@ -96,15 +98,19 @@ // stylelint-disable-next-line no-duplicate-selectors .input-group { &:not(.has-validation) { - > :not(:last-child):not(.dropdown-toggle):not(.dropdown-menu), - > .dropdown-toggle:nth-last-child(n + 3) { + > :not(:last-child):not(.dropdown-toggle):not(.dropdown-menu):not(.form-floating), + > .dropdown-toggle:nth-last-child(n + 3), + > .form-floating:not(:last-child) > .form-control, + > .form-floating:not(:last-child) > .form-select { @include border-end-radius(0); } } &.has-validation { - > :nth-last-child(n + 3):not(.dropdown-toggle):not(.dropdown-menu), - > .dropdown-toggle:nth-last-child(n + 4) { + > :nth-last-child(n + 3):not(.dropdown-toggle):not(.dropdown-menu):not(.form-floating), + > .dropdown-toggle:nth-last-child(n + 4), + > .form-floating:nth-last-child(n + 3) > .form-control, + > .form-floating:nth-last-child(n + 3) > .form-select { @include border-end-radius(0); } } @@ -114,7 +120,9 @@ $validation-messages: $validation-messages + ":not(." + unquote($state) + "-tooltip)" + ":not(." + unquote($state) + "-feedback)"; } - > :not(:first-child):not(.dropdown-menu)#{$validation-messages} { + > :not(:first-child):not(.dropdown-menu):not(.form-floating)#{$validation-messages}, + > .form-floating:not(:first-child) > .form-control, + > .form-floating:not(:first-child) > .form-select { margin-left: -$input-border-width; @include border-start-radius(0); } diff --git a/assets/stylesheets/bootstrap/helpers/_color-bg.scss b/assets/stylesheets/bootstrap/helpers/_color-bg.scss new file mode 100644 index 0000000..b5ce770 --- /dev/null +++ b/assets/stylesheets/bootstrap/helpers/_color-bg.scss @@ -0,0 +1,10 @@ +// stylelint-disable function-name-case + +// All-caps `RGBA()` function used because of this Sass bug: https://github.com/sass/node-sass/issues/2251 +@each $color, $value in $theme-colors { + $color-rgb: to-rgb($value); + .text-bg-#{$color} { + color: color-contrast($value) if($enable-important-utilities, !important, null); + background-color: RGBA($color-rgb, var(--#{$prefix}bg-opacity, 1)) if($enable-important-utilities, !important, null); + } +} diff --git a/assets/stylesheets/bootstrap/helpers/_colored-links.scss b/assets/stylesheets/bootstrap/helpers/_colored-links.scss index 8c167de..1cb4182 100644 --- a/assets/stylesheets/bootstrap/helpers/_colored-links.scss +++ b/assets/stylesheets/bootstrap/helpers/_colored-links.scss @@ -1,11 +1,11 @@ @each $color, $value in $theme-colors { .link-#{$color} { - color: $value; + color: $value !important; // stylelint-disable-line declaration-no-important @if $link-shade-percentage != 0 { &:hover, &:focus { - color: if(color-contrast($value) == $color-contrast-light, shade-color($value, $link-shade-percentage), tint-color($value, $link-shade-percentage)); + color: if(color-contrast($value) == $color-contrast-light, shade-color($value, $link-shade-percentage), tint-color($value, $link-shade-percentage)) !important; // stylelint-disable-line declaration-no-important } } } diff --git a/assets/stylesheets/bootstrap/helpers/_position.scss b/assets/stylesheets/bootstrap/helpers/_position.scss index 31851eb..59103d9 100644 --- a/assets/stylesheets/bootstrap/helpers/_position.scss +++ b/assets/stylesheets/bootstrap/helpers/_position.scss @@ -16,7 +16,7 @@ z-index: $zindex-fixed; } -// Responsive sticky top +// Responsive sticky top and bottom @each $breakpoint in map-keys($grid-breakpoints) { @include media-breakpoint-up($breakpoint) { $infix: breakpoint-infix($breakpoint, $grid-breakpoints); @@ -26,5 +26,11 @@ top: 0; z-index: $zindex-sticky; } + + .sticky#{$infix}-bottom { + position: sticky; + bottom: 0; + z-index: $zindex-sticky; + } } } diff --git a/assets/stylesheets/bootstrap/helpers/_ratio.scss b/assets/stylesheets/bootstrap/helpers/_ratio.scss index 2390ee3..b6a7654 100644 --- a/assets/stylesheets/bootstrap/helpers/_ratio.scss +++ b/assets/stylesheets/bootstrap/helpers/_ratio.scss @@ -6,7 +6,7 @@ &::before { display: block; - padding-top: var(--#{$variable-prefix}aspect-ratio); + padding-top: var(--#{$prefix}aspect-ratio); content: ""; } @@ -21,6 +21,6 @@ @each $key, $ratio in $aspect-ratios { .ratio-#{$key} { - --#{$variable-prefix}aspect-ratio: #{$ratio}; + --#{$prefix}aspect-ratio: #{$ratio}; } } diff --git a/assets/stylesheets/bootstrap/helpers/_vr.scss b/assets/stylesheets/bootstrap/helpers/_vr.scss index 37f8647..9bca099 100644 --- a/assets/stylesheets/bootstrap/helpers/_vr.scss +++ b/assets/stylesheets/bootstrap/helpers/_vr.scss @@ -3,6 +3,6 @@ align-self: stretch; width: 1px; min-height: 1em; - background-color: currentColor; + background-color: currentcolor; opacity: $hr-opacity; } diff --git a/assets/stylesheets/bootstrap/mixins/_alert.scss b/assets/stylesheets/bootstrap/mixins/_alert.scss index f3eb595..231f068 100644 --- a/assets/stylesheets/bootstrap/mixins/_alert.scss +++ b/assets/stylesheets/bootstrap/mixins/_alert.scss @@ -1,8 +1,12 @@ // scss-docs-start alert-variant-mixin @mixin alert-variant($background, $border, $color) { - color: $color; - @include gradient-bg($background); - border-color: $border; + --#{$prefix}alert-color: #{$color}; + --#{$prefix}alert-bg: #{$background}; + --#{$prefix}alert-border-color: #{$border}; + + @if $enable-gradients { + background-image: var(--#{$prefix}gradient); + } .alert-link { color: shade-color($color, 20%); diff --git a/assets/stylesheets/bootstrap/mixins/_banner.scss b/assets/stylesheets/bootstrap/mixins/_banner.scss new file mode 100644 index 0000000..0f14bf1 --- /dev/null +++ b/assets/stylesheets/bootstrap/mixins/_banner.scss @@ -0,0 +1,9 @@ +@mixin bsBanner($file, $suffix:"") { + /*! + * Bootstrap #{$file} v5.2.0 (https://getbootstrap.com/) + * Copyright 2011-2022 The Bootstrap Authors + * Copyright 2011-2022 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) + */ +} + diff --git a/assets/stylesheets/bootstrap/mixins/_breakpoints.scss b/assets/stylesheets/bootstrap/mixins/_breakpoints.scss index cdc8034..286be89 100644 --- a/assets/stylesheets/bootstrap/mixins/_breakpoints.scss +++ b/assets/stylesheets/bootstrap/mixins/_breakpoints.scss @@ -2,7 +2,7 @@ // // Breakpoints are defined as a map of (name: minimum width), order from small to large: // -// (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px) +// (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px, xxl: 1400px) // // The map defined in the `$grid-breakpoints` global variable is used as the `$breakpoints` argument by default. @@ -10,9 +10,9 @@ // // >> breakpoint-next(sm) // md -// >> breakpoint-next(sm, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px)) +// >> breakpoint-next(sm, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px, xxl: 1400px)) // md -// >> breakpoint-next(sm, $breakpoint-names: (xs sm md lg xl)) +// >> breakpoint-next(sm, $breakpoint-names: (xs sm md lg xl xxl)) // md @function breakpoint-next($name, $breakpoints: $grid-breakpoints, $breakpoint-names: map-keys($breakpoints)) { $n: index($breakpoint-names, $name); @@ -24,7 +24,7 @@ // Minimum breakpoint width. Null for the smallest (first) breakpoint. // -// >> breakpoint-min(sm, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px)) +// >> breakpoint-min(sm, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px, xxl: 1400px)) // 576px @function breakpoint-min($name, $breakpoints: $grid-breakpoints) { $min: map-get($breakpoints, $name); @@ -38,7 +38,7 @@ // Uses 0.02px rather than 0.01px to work around a current rounding bug in Safari. // See https://bugs.webkit.org/show_bug.cgi?id=178261 // -// >> breakpoint-max(md, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px)) +// >> breakpoint-max(md, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px, xxl: 1400px)) // 767.98px @function breakpoint-max($name, $breakpoints: $grid-breakpoints) { $max: map-get($breakpoints, $name); @@ -48,9 +48,9 @@ // Returns a blank string if smallest breakpoint, otherwise returns the name with a dash in front. // Useful for making responsive utilities. // -// >> breakpoint-infix(xs, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px)) +// >> breakpoint-infix(xs, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px, xxl: 1400px)) // "" (Returns a blank string) -// >> breakpoint-infix(sm, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px)) +// >> breakpoint-infix(sm, (xs: 0, sm: 576px, md: 768px, lg: 992px, xl: 1200px, xxl: 1400px)) // "-sm" @function breakpoint-infix($name, $breakpoints: $grid-breakpoints) { @return if(breakpoint-min($name, $breakpoints) == null, "", "-#{$name}"); @@ -109,7 +109,7 @@ @mixin media-breakpoint-only($name, $breakpoints: $grid-breakpoints) { $min: breakpoint-min($name, $breakpoints); $next: breakpoint-next($name, $breakpoints); - $max: breakpoint-max($next); + $max: breakpoint-max($next, $breakpoints); @if $min != null and $max != null { @media (min-width: $min) and (max-width: $max) { diff --git a/assets/stylesheets/bootstrap/mixins/_buttons.scss b/assets/stylesheets/bootstrap/mixins/_buttons.scss index b674996..cf087fd 100644 --- a/assets/stylesheets/bootstrap/mixins/_buttons.scss +++ b/assets/stylesheets/bootstrap/mixins/_buttons.scss @@ -18,59 +18,20 @@ $disabled-border: $border, $disabled-color: color-contrast($disabled-background) ) { - color: $color; - @include gradient-bg($background); - border-color: $border; - @include box-shadow($btn-box-shadow); - - &:hover { - color: $hover-color; - @include gradient-bg($hover-background); - border-color: $hover-border; - } - - .btn-check:focus + &, - &:focus { - color: $hover-color; - @include gradient-bg($hover-background); - border-color: $hover-border; - @if $enable-shadows { - @include box-shadow($btn-box-shadow, 0 0 0 $btn-focus-width rgba(mix($color, $border, 15%), .5)); - } @else { - // Avoid using mixin so we can pass custom focus shadow properly - box-shadow: 0 0 0 $btn-focus-width rgba(mix($color, $border, 15%), .5); - } - } - - .btn-check:checked + &, - .btn-check:active + &, - &:active, - &.active, - .show > &.dropdown-toggle { - color: $active-color; - background-color: $active-background; - // Remove CSS gradients if they're enabled - background-image: if($enable-gradients, none, null); - border-color: $active-border; - - &:focus { - @if $enable-shadows { - @include box-shadow($btn-active-box-shadow, 0 0 0 $btn-focus-width rgba(mix($color, $border, 15%), .5)); - } @else { - // Avoid using mixin so we can pass custom focus shadow properly - box-shadow: 0 0 0 $btn-focus-width rgba(mix($color, $border, 15%), .5); - } - } - } - - &:disabled, - &.disabled { - color: $disabled-color; - background-color: $disabled-background; - // Remove CSS gradients if they're enabled - background-image: if($enable-gradients, none, null); - border-color: $disabled-border; - } + --#{$prefix}btn-color: #{$color}; + --#{$prefix}btn-bg: #{$background}; + --#{$prefix}btn-border-color: #{$border}; + --#{$prefix}btn-hover-color: #{$hover-color}; + --#{$prefix}btn-hover-bg: #{$hover-background}; + --#{$prefix}btn-hover-border-color: #{$hover-border}; + --#{$prefix}btn-focus-shadow-rgb: #{to-rgb(mix($color, $border, 15%))}; + --#{$prefix}btn-active-color: #{$active-color}; + --#{$prefix}btn-active-bg: #{$active-background}; + --#{$prefix}btn-active-border-color: #{$active-border}; + --#{$prefix}btn-active-shadow: #{$btn-active-box-shadow}; + --#{$prefix}btn-disabled-color: #{$disabled-color}; + --#{$prefix}btn-disabled-bg: #{$disabled-background}; + --#{$prefix}btn-disabled-border-color: #{$disabled-border}; } // scss-docs-end btn-variant-mixin @@ -82,52 +43,28 @@ $active-border: $color, $active-color: color-contrast($active-background) ) { - color: $color; - border-color: $color; - - &:hover { - color: $color-hover; - background-color: $active-background; - border-color: $active-border; - } - - .btn-check:focus + &, - &:focus { - box-shadow: 0 0 0 $btn-focus-width rgba($color, .5); - } - - .btn-check:checked + &, - .btn-check:active + &, - &:active, - &.active, - &.dropdown-toggle.show { - color: $active-color; - background-color: $active-background; - border-color: $active-border; - - &:focus { - @if $enable-shadows { - @include box-shadow($btn-active-box-shadow, 0 0 0 $btn-focus-width rgba($color, .5)); - } @else { - // Avoid using mixin so we can pass custom focus shadow properly - box-shadow: 0 0 0 $btn-focus-width rgba($color, .5); - } - } - } - - &:disabled, - &.disabled { - color: $color; - background-color: transparent; - } + --#{$prefix}btn-color: #{$color}; + --#{$prefix}btn-border-color: #{$color}; + --#{$prefix}btn-hover-color: #{$color-hover}; + --#{$prefix}btn-hover-bg: #{$active-background}; + --#{$prefix}btn-hover-border-color: #{$active-border}; + --#{$prefix}btn-focus-shadow-rgb: #{to-rgb($color)}; + --#{$prefix}btn-active-color: #{$active-color}; + --#{$prefix}btn-active-bg: #{$active-background}; + --#{$prefix}btn-active-border-color: #{$active-border}; + --#{$prefix}btn-active-shadow: #{$btn-active-box-shadow}; + --#{$prefix}btn-disabled-color: #{$color}; + --#{$prefix}btn-disabled-bg: transparent; + --#{$prefix}btn-disabled-border-color: #{$color}; + --#{$prefix}gradient: none; } // scss-docs-end btn-outline-variant-mixin // scss-docs-start btn-size-mixin @mixin button-size($padding-y, $padding-x, $font-size, $border-radius) { - padding: $padding-y $padding-x; - @include font-size($font-size); - // Manually declare to provide an override to the browser default - @include border-radius($border-radius, 0); + --#{$prefix}btn-padding-y: #{$padding-y}; + --#{$prefix}btn-padding-x: #{$padding-x}; + @include rfs($font-size, --#{$prefix}btn-font-size); + --#{$prefix}btn-border-radius: #{$border-radius}; } // scss-docs-end btn-size-mixin diff --git a/assets/stylesheets/bootstrap/mixins/_container.scss b/assets/stylesheets/bootstrap/mixins/_container.scss index ee6044d..b9f3351 100644 --- a/assets/stylesheets/bootstrap/mixins/_container.scss +++ b/assets/stylesheets/bootstrap/mixins/_container.scss @@ -1,9 +1,11 @@ // Container mixins @mixin make-container($gutter: $container-padding-x) { + --#{$prefix}gutter-x: #{$gutter}; + --#{$prefix}gutter-y: 0; width: 100%; - padding-right: var(--#{$variable-prefix}gutter-x, #{$gutter}); - padding-left: var(--#{$variable-prefix}gutter-x, #{$gutter}); + padding-right: calc(var(--#{$prefix}gutter-x) * .5); // stylelint-disable-line function-disallowed-list + padding-left: calc(var(--#{$prefix}gutter-x) * .5); // stylelint-disable-line function-disallowed-list margin-right: auto; margin-left: auto; } diff --git a/assets/stylesheets/bootstrap/mixins/_forms.scss b/assets/stylesheets/bootstrap/mixins/_forms.scss index dc5bdb0..81cd2e3 100644 --- a/assets/stylesheets/bootstrap/mixins/_forms.scss +++ b/assets/stylesheets/bootstrap/mixins/_forms.scss @@ -104,6 +104,14 @@ } } + .form-control-color { + @include form-validation-state-selector($state) { + @if $enable-validation-icons { + width: add($form-color-width, $input-height-inner); + } + } + } + .form-check-input { @include form-validation-state-selector($state) { border-color: $color; diff --git a/assets/stylesheets/bootstrap/mixins/_gradients.scss b/assets/stylesheets/bootstrap/mixins/_gradients.scss index 44167d1..608e18d 100644 --- a/assets/stylesheets/bootstrap/mixins/_gradients.scss +++ b/assets/stylesheets/bootstrap/mixins/_gradients.scss @@ -5,7 +5,7 @@ background-color: $color; @if $enable-gradients { - background-image: var(--#{$variable-prefix}gradient); + background-image: var(--#{$prefix}gradient); } } // scss-docs-end gradient-bg-mixin diff --git a/assets/stylesheets/bootstrap/mixins/_grid.scss b/assets/stylesheets/bootstrap/mixins/_grid.scss index aea51ab..38e2239 100644 --- a/assets/stylesheets/bootstrap/mixins/_grid.scss +++ b/assets/stylesheets/bootstrap/mixins/_grid.scss @@ -3,17 +3,17 @@ // Generate semantic grid columns with these mixins. @mixin make-row($gutter: $grid-gutter-width) { - --#{$variable-prefix}gutter-x: #{$gutter}; - --#{$variable-prefix}gutter-y: 0; + --#{$prefix}gutter-x: #{$gutter}; + --#{$prefix}gutter-y: 0; display: flex; flex-wrap: wrap; // TODO: Revisit calc order after https://github.com/react-bootstrap/react-bootstrap/issues/6039 is fixed - margin-top: calc(-1 * var(--#{$variable-prefix}gutter-y)); // stylelint-disable-line function-disallowed-list - margin-right: calc(-.5 * var(--#{$variable-prefix}gutter-x)); // stylelint-disable-line function-disallowed-list - margin-left: calc(-.5 * var(--#{$variable-prefix}gutter-x)); // stylelint-disable-line function-disallowed-list + margin-top: calc(-1 * var(--#{$prefix}gutter-y)); // stylelint-disable-line function-disallowed-list + margin-right: calc(-.5 * var(--#{$prefix}gutter-x)); // stylelint-disable-line function-disallowed-list + margin-left: calc(-.5 * var(--#{$prefix}gutter-x)); // stylelint-disable-line function-disallowed-list } -@mixin make-col-ready($gutter: $grid-gutter-width) { +@mixin make-col-ready() { // Add box sizing if only the grid is loaded box-sizing: if(variable-exists(include-column-box-sizing) and $include-column-box-sizing, border-box, null); // Prevent columns from becoming too narrow when at smaller grid tiers by @@ -22,9 +22,9 @@ flex-shrink: 0; width: 100%; max-width: 100%; // Prevent `.col-auto`, `.col` (& responsive variants) from breaking out the grid - padding-right: calc(var(--#{$variable-prefix}gutter-x) * .5); // stylelint-disable-line function-disallowed-list - padding-left: calc(var(--#{$variable-prefix}gutter-x) * .5); // stylelint-disable-line function-disallowed-list - margin-top: var(--#{$variable-prefix}gutter-y); + padding-right: calc(var(--#{$prefix}gutter-x) * .5); // stylelint-disable-line function-disallowed-list + padding-left: calc(var(--#{$prefix}gutter-x) * .5); // stylelint-disable-line function-disallowed-list + margin-top: var(--#{$prefix}gutter-y); } @mixin make-col($size: false, $columns: $grid-columns) { @@ -51,7 +51,7 @@ // Row columns // // Specify on a parent element(e.g., .row) to force immediate children into NN -// numberof columns. Supports wrapping to new lines, but does not do a Masonry +// number of columns. Supports wrapping to new lines, but does not do a Masonry // style grid. @mixin row-cols($count) { > * { @@ -114,12 +114,12 @@ @each $key, $value in $gutters { .g#{$infix}-#{$key}, .gx#{$infix}-#{$key} { - --#{$variable-prefix}gutter-x: #{$value}; + --#{$prefix}gutter-x: #{$value}; } .g#{$infix}-#{$key}, .gy#{$infix}-#{$key} { - --#{$variable-prefix}gutter-y: #{$value}; + --#{$prefix}gutter-y: #{$value}; } } } diff --git a/assets/stylesheets/bootstrap/mixins/_pagination.scss b/assets/stylesheets/bootstrap/mixins/_pagination.scss index 3101b38..0d65796 100644 --- a/assets/stylesheets/bootstrap/mixins/_pagination.scss +++ b/assets/stylesheets/bootstrap/mixins/_pagination.scss @@ -2,30 +2,9 @@ // scss-docs-start pagination-mixin @mixin pagination-size($padding-y, $padding-x, $font-size, $border-radius) { - .page-link { - padding: $padding-y $padding-x; - @include font-size($font-size); - } - - .page-item { - @if $pagination-margin-start == (-$pagination-border-width) { - &:first-child { - .page-link { - @include border-start-radius($border-radius); - } - } - - &:last-child { - .page-link { - @include border-end-radius($border-radius); - } - } - } @else { - //Add border-radius to all pageLinks in case they have left margin - .page-link { - @include border-radius($border-radius); - } - } - } + --#{$prefix}pagination-padding-x: #{$padding-x}; + --#{$prefix}pagination-padding-y: #{$padding-y}; + @include rfs($font-size, --#{$prefix}pagination-font-size); + --#{$prefix}pagination-border-radius: #{$border-radius}; } // scss-docs-end pagination-mixin diff --git a/assets/stylesheets/bootstrap/mixins/_reset-text.scss b/assets/stylesheets/bootstrap/mixins/_reset-text.scss index 354f564..f5bd1af 100644 --- a/assets/stylesheets/bootstrap/mixins/_reset-text.scss +++ b/assets/stylesheets/bootstrap/mixins/_reset-text.scss @@ -11,7 +11,7 @@ text-transform: none; letter-spacing: normal; word-break: normal; - word-spacing: normal; white-space: normal; + word-spacing: normal; line-break: auto; } diff --git a/assets/stylesheets/bootstrap/mixins/_table-variants.scss b/assets/stylesheets/bootstrap/mixins/_table-variants.scss index 9fd0fb0..ae43ec6 100644 --- a/assets/stylesheets/bootstrap/mixins/_table-variants.scss +++ b/assets/stylesheets/bootstrap/mixins/_table-variants.scss @@ -5,17 +5,20 @@ $hover-bg: mix($color, $background, percentage($table-hover-bg-factor)); $striped-bg: mix($color, $background, percentage($table-striped-bg-factor)); $active-bg: mix($color, $background, percentage($table-active-bg-factor)); + $border-color: mix($color, $background, percentage($table-border-factor)); - --#{$variable-prefix}table-bg: #{$background}; - --#{$variable-prefix}table-striped-bg: #{$striped-bg}; - --#{$variable-prefix}table-striped-color: #{color-contrast($striped-bg)}; - --#{$variable-prefix}table-active-bg: #{$active-bg}; - --#{$variable-prefix}table-active-color: #{color-contrast($active-bg)}; - --#{$variable-prefix}table-hover-bg: #{$hover-bg}; - --#{$variable-prefix}table-hover-color: #{color-contrast($hover-bg)}; + --#{$prefix}table-color: #{$color}; + --#{$prefix}table-bg: #{$background}; + --#{$prefix}table-border-color: #{$border-color}; + --#{$prefix}table-striped-bg: #{$striped-bg}; + --#{$prefix}table-striped-color: #{color-contrast($striped-bg)}; + --#{$prefix}table-active-bg: #{$active-bg}; + --#{$prefix}table-active-color: #{color-contrast($active-bg)}; + --#{$prefix}table-hover-bg: #{$hover-bg}; + --#{$prefix}table-hover-color: #{color-contrast($hover-bg)}; - color: $color; - border-color: mix($color, $background, percentage($table-border-factor)); + color: var(--#{$prefix}table-color); + border-color: var(--#{$prefix}table-border-color); } } // scss-docs-end table-variant diff --git a/assets/stylesheets/bootstrap/mixins/_utilities.scss b/assets/stylesheets/bootstrap/mixins/_utilities.scss index e871b42..0eadc50 100644 --- a/assets/stylesheets/bootstrap/mixins/_utilities.scss +++ b/assets/stylesheets/bootstrap/mixins/_utilities.scss @@ -20,6 +20,9 @@ $property-class: if(map-has-key($utility, class), map-get($utility, class), nth($properties, 1)); $property-class: if($property-class == null, "", $property-class); + // Use custom CSS variable name if present, otherwise default to `class` + $css-variable-name: if(map-has-key($utility, css-variable-name), map-get($utility, css-variable-name), map-get($utility, class)); + // State params to generate pseudo-classes $state: if(map-has-key($utility, state), map-get($utility, state), ()); @@ -52,20 +55,20 @@ @if $is-css-var { .#{$property-class + $infix + $property-class-modifier} { - --#{$variable-prefix}#{$property-class}: #{$value}; + --#{$prefix}#{$css-variable-name}: #{$value}; } @each $pseudo in $state { .#{$property-class + $infix + $property-class-modifier}-#{$pseudo}:#{$pseudo} { - --#{$variable-prefix}#{$property-class}: #{$value}; + --#{$prefix}#{$css-variable-name}: #{$value}; } } } @else { .#{$property-class + $infix + $property-class-modifier} { @each $property in $properties { @if $is-local-vars { - @each $local-var, $value in $is-local-vars { - --#{$variable-prefix}#{$local-var}: #{$value}; + @each $local-var, $variable in $is-local-vars { + --#{$prefix}#{$local-var}: #{$variable}; } } #{$property}: $value if($enable-important-utilities, !important, null); @@ -75,6 +78,11 @@ @each $pseudo in $state { .#{$property-class + $infix + $property-class-modifier}-#{$pseudo}:#{$pseudo} { @each $property in $properties { + @if $is-local-vars { + @each $local-var, $variable in $is-local-vars { + --#{$prefix}#{$local-var}: #{$variable}; + } + } #{$property}: $value if($enable-important-utilities, !important, null); } } diff --git a/lib/bootstrap/version.rb b/lib/bootstrap/version.rb index 7093a78..7c35f29 100644 --- a/lib/bootstrap/version.rb +++ b/lib/bootstrap/version.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true module Bootstrap - VERSION = '5.1.3' - BOOTSTRAP_SHA = '1a6fdfae6be09b09eaced8f0e442ca6f7680a61e' + VERSION = '5.2.0' + BOOTSTRAP_SHA = 'edf9c40956d19e6ab3f9151bfe0dfac6be06fa21' end |