diff options
Diffstat (limited to 'vendor/twbs/bootstrap/js/src/util')
-rw-r--r-- | vendor/twbs/bootstrap/js/src/util/backdrop.js | 9 | ||||
-rw-r--r-- | vendor/twbs/bootstrap/js/src/util/component-functions.js | 34 | ||||
-rw-r--r-- | vendor/twbs/bootstrap/js/src/util/focustrap.js | 109 | ||||
-rw-r--r-- | vendor/twbs/bootstrap/js/src/util/index.js | 19 | ||||
-rw-r--r-- | vendor/twbs/bootstrap/js/src/util/sanitizer.js | 2 | ||||
-rw-r--r-- | vendor/twbs/bootstrap/js/src/util/scrollbar.js | 2 |
6 files changed, 11 insertions, 164 deletions
diff --git a/vendor/twbs/bootstrap/js/src/util/backdrop.js b/vendor/twbs/bootstrap/js/src/util/backdrop.js index e98d80707..7ba7b4c43 100644 --- a/vendor/twbs/bootstrap/js/src/util/backdrop.js +++ b/vendor/twbs/bootstrap/js/src/util/backdrop.js @@ -1,6 +1,6 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.1): util/backdrop.js + * Bootstrap (v5.0.2): util/backdrop.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) * -------------------------------------------------------------------------- */ @@ -9,7 +9,6 @@ import EventHandler from '../dom/event-handler' import { execute, executeAfterTransition, getElement, reflow, typeCheckConfig } from './index' const Default = { - 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 @@ -17,13 +16,13 @@ const Default = { } const DefaultType = { - className: 'string', isVisible: 'boolean', isAnimated: 'boolean', rootElement: '(element|string)', clickCallback: '(function|null)' } const NAME = 'backdrop' +const CLASS_NAME_BACKDROP = 'modal-backdrop' const CLASS_NAME_FADE = 'fade' const CLASS_NAME_SHOW = 'show' @@ -74,7 +73,7 @@ class Backdrop { _getElement() { if (!this._element) { const backdrop = document.createElement('div') - backdrop.className = this._config.className + backdrop.className = CLASS_NAME_BACKDROP if (this._config.isAnimated) { backdrop.classList.add(CLASS_NAME_FADE) } @@ -102,7 +101,7 @@ class Backdrop { return } - this._config.rootElement.append(this._getElement()) + this._config.rootElement.appendChild(this._getElement()) EventHandler.on(this._getElement(), EVENT_MOUSEDOWN, () => { execute(this._config.clickCallback) diff --git a/vendor/twbs/bootstrap/js/src/util/component-functions.js b/vendor/twbs/bootstrap/js/src/util/component-functions.js deleted file mode 100644 index ff9d87ee6..000000000 --- a/vendor/twbs/bootstrap/js/src/util/component-functions.js +++ /dev/null @@ -1,34 +0,0 @@ -/** - * -------------------------------------------------------------------------- - * Bootstrap (v5.1.1): util/component-functions.js - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) - * -------------------------------------------------------------------------- - */ - -import EventHandler from '../dom/event-handler' -import { getElementFromSelector, isDisabled } from './index' - -const enableDismissTrigger = (component, method = 'hide') => { - const clickEvent = `click.dismiss${component.EVENT_KEY}` - const name = component.NAME - - EventHandler.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]() - }) -} - -export { - enableDismissTrigger -} diff --git a/vendor/twbs/bootstrap/js/src/util/focustrap.js b/vendor/twbs/bootstrap/js/src/util/focustrap.js deleted file mode 100644 index ca6f8273f..000000000 --- a/vendor/twbs/bootstrap/js/src/util/focustrap.js +++ /dev/null @@ -1,109 +0,0 @@ -/** - * -------------------------------------------------------------------------- - * Bootstrap (v5.1.1): util/focustrap.js - * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) - * -------------------------------------------------------------------------- - */ - -import EventHandler from '../dom/event-handler' -import SelectorEngine from '../dom/selector-engine' -import { typeCheckConfig } from './index' - -const Default = { - trapElement: null, // The element to trap focus inside of - autofocus: true -} - -const DefaultType = { - trapElement: 'element', - autofocus: 'boolean' -} - -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' - -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.off(document, EVENT_KEY) // guard against infinite focus loop - EventHandler.on(document, EVENT_FOCUSIN, event => this._handleFocusin(event)) - EventHandler.on(document, EVENT_KEYDOWN_TAB, event => this._handleKeydown(event)) - - this._isActive = true - } - - deactivate() { - if (!this._isActive) { - return - } - - this._isActive = false - EventHandler.off(document, EVENT_KEY) - } - - // Private - - _handleFocusin(event) { - const { target } = event - const { trapElement } = this._config - - if ( - target === document || - target === trapElement || - trapElement.contains(target) - ) { - return - } - - const elements = SelectorEngine.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, - ...(typeof config === 'object' ? config : {}) - } - typeCheckConfig(NAME, config, DefaultType) - return config - } -} - -export default FocusTrap diff --git a/vendor/twbs/bootstrap/js/src/util/index.js b/vendor/twbs/bootstrap/js/src/util/index.js index a4ad9c941..7c317b016 100644 --- a/vendor/twbs/bootstrap/js/src/util/index.js +++ b/vendor/twbs/bootstrap/js/src/util/index.js @@ -1,6 +1,8 @@ +import SelectorEngine from '../dom/selector-engine' + /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.1): util/index.js + * Bootstrap (v5.0.2): util/index.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ @@ -118,7 +120,7 @@ const getElement = obj => { } if (typeof obj === 'string' && obj.length > 0) { - return document.querySelector(obj) + return SelectorEngine.findOne(obj) } return null @@ -187,18 +189,7 @@ const findShadowRoot = element => { 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 => { - // eslint-disable-next-line no-unused-expressions - element.offsetHeight -} +const reflow = element => element.offsetHeight const getjQuery = () => { const { jQuery } = window diff --git a/vendor/twbs/bootstrap/js/src/util/sanitizer.js b/vendor/twbs/bootstrap/js/src/util/sanitizer.js index 467dbf96a..49f66417d 100644 --- a/vendor/twbs/bootstrap/js/src/util/sanitizer.js +++ b/vendor/twbs/bootstrap/js/src/util/sanitizer.js @@ -1,6 +1,6 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.1): util/sanitizer.js + * Bootstrap (v5.0.2): util/sanitizer.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ diff --git a/vendor/twbs/bootstrap/js/src/util/scrollbar.js b/vendor/twbs/bootstrap/js/src/util/scrollbar.js index 73c28254e..fad9766ac 100644 --- a/vendor/twbs/bootstrap/js/src/util/scrollbar.js +++ b/vendor/twbs/bootstrap/js/src/util/scrollbar.js @@ -1,6 +1,6 @@ /** * -------------------------------------------------------------------------- - * Bootstrap (v5.1.1): util/scrollBar.js + * Bootstrap (v5.0.2): util/scrollBar.js * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ |