import { enableDismissTrigger } from './util/component-functions'
/**
- * ------------------------------------------------------------------------
* Constants
- * ------------------------------------------------------------------------
*/
const NAME = 'alert'
const CLASS_NAME_SHOW = 'show'
/**
- * ------------------------------------------------------------------------
- * Class Definition
- * ------------------------------------------------------------------------
+ * Class definition
*/
class Alert extends BaseComponent {
// Getters
-
static get NAME() {
return NAME
}
// Public
-
close() {
const closeEvent = EventHandler.trigger(this._element, EVENT_CLOSE)
}
// Static
-
static jQueryInterface(config) {
return this.each(function () {
const data = Alert.getOrCreateInstance(this)
}
/**
- * ------------------------------------------------------------------------
- * Data Api implementation
- * ------------------------------------------------------------------------
+ * Data API implementation
*/
enableDismissTrigger(Alert, 'close')
/**
- * ------------------------------------------------------------------------
* jQuery
- * ------------------------------------------------------------------------
- * add .Alert to jQuery only if jQuery is present
*/
defineJQueryPlugin(Alert)
import EventHandler from './dom/event-handler'
/**
- * ------------------------------------------------------------------------
* Constants
- * ------------------------------------------------------------------------
*/
const VERSION = '5.1.3'
+/**
+ * Class definition
+ */
+
class BaseComponent {
constructor(element) {
element = getElement(element)
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)
executeAfterTransition(callback, element, isAnimated)
}
- /** Static */
-
+ // Static
static getInstance(element) {
return Data.get(getElement(element), this.DATA_KEY)
}
}
static get NAME() {
- throw new Error('You have to implement the static method "NAME", for each component!')
+ throw new Error('You have to implement the static method "NAME" for each component!')
}
static get DATA_KEY() {
import BaseComponent from './base-component'
/**
- * ------------------------------------------------------------------------
* Constants
- * ------------------------------------------------------------------------
*/
const NAME = 'button'
const DATA_API_KEY = '.data-api'
const CLASS_NAME_ACTIVE = 'active'
-
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 {
// Getters
-
static get NAME() {
return NAME
}
// Public
-
toggle() {
// Toggle class and sync the `aria-pressed` attribute with the return value of the `.toggle()` method
this._element.setAttribute('aria-pressed', this._element.classList.toggle(CLASS_NAME_ACTIVE))
}
// Static
-
static jQueryInterface(config) {
return this.each(function () {
const data = Button.getOrCreateInstance(this)
}
/**
- * ------------------------------------------------------------------------
- * Data Api implementation
- * ------------------------------------------------------------------------
+ * Data API implementation
*/
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, event => {
})
/**
- * ------------------------------------------------------------------------
* jQuery
- * ------------------------------------------------------------------------
- * add .Button to jQuery only if jQuery is present
*/
defineJQueryPlugin(Button)
import BaseComponent from './base-component'
/**
- * ------------------------------------------------------------------------
* Constants
- * ------------------------------------------------------------------------
*/
const NAME = 'carousel'
const ARROW_RIGHT_KEY = 'ArrowRight'
const TOUCHEVENT_COMPAT_WAIT = 500 // Time for mouse compat events to fire after touch
-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 SELECTOR_DATA_SLIDE = '[data-bs-slide], [data-bs-slide-to]'
const SELECTOR_DATA_RIDE = '[data-bs-ride="carousel"]'
+const KEY_TO_DIRECTION = {
+ [ARROW_LEFT_KEY]: DIRECTION_RIGHT,
+ [ARROW_RIGHT_KEY]: DIRECTION_LEFT
+}
+
+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'
+}
+
/**
- * ------------------------------------------------------------------------
- * Class Definition
- * ------------------------------------------------------------------------
+ * Class definition
*/
+
class Carousel extends BaseComponent {
constructor(element, config) {
super(element)
}
// Getters
-
static get Default() {
return Default
}
}
// Public
-
next() {
this._slide(ORDER_NEXT)
}
}
// Private
-
_getConfig(config) {
config = {
...Default,
}
// Static
-
static carouselInterface(element, config) {
const data = Carousel.getOrCreateInstance(element, config)
}
/**
- * ------------------------------------------------------------------------
- * Data Api implementation
- * ------------------------------------------------------------------------
+ * Data API implementation
*/
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_SLIDE, Carousel.dataApiClickHandler)
})
/**
- * ------------------------------------------------------------------------
* jQuery
- * ------------------------------------------------------------------------
- * add .Carousel to jQuery only if jQuery is present
*/
defineJQueryPlugin(Carousel)
import BaseComponent from './base-component'
/**
- * ------------------------------------------------------------------------
* Constants
- * ------------------------------------------------------------------------
*/
const NAME = '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}`
const SELECTOR_ACTIVES = '.collapse.show, .collapse.collapsing'
const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="collapse"]'
+const Default = {
+ toggle: true,
+ parent: null
+}
+
+const DefaultType = {
+ toggle: 'boolean',
+ parent: '(null|element)'
+}
+
/**
- * ------------------------------------------------------------------------
- * Class Definition
- * ------------------------------------------------------------------------
+ * Class definition
*/
class Collapse extends BaseComponent {
}
// Getters
-
static get Default() {
return Default
}
}
// Public
-
toggle() {
if (this._isShown()) {
this.hide()
}
// Private
-
_getConfig(config) {
config = {
...Default,
}
// Static
-
static jQueryInterface(config) {
return this.each(function () {
const _config = {}
}
/**
- * ------------------------------------------------------------------------
- * Data Api implementation
- * ------------------------------------------------------------------------
+ * Data API implementation
*/
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
})
/**
- * ------------------------------------------------------------------------
* jQuery
- * ------------------------------------------------------------------------
- * add .Collapse to jQuery only if jQuery is present
*/
defineJQueryPlugin(Collapse)
*/
/**
- * ------------------------------------------------------------------------
* Constants
- * ------------------------------------------------------------------------
*/
const elementMap = new Map()
import { getjQuery } from '../util/index'
/**
- * ------------------------------------------------------------------------
* Constants
- * ------------------------------------------------------------------------
*/
const namespaceRegex = /[^.]*(?=\..*)\.|.*/
])
/**
- * ------------------------------------------------------------------------
* Private methods
- * ------------------------------------------------------------------------
*/
function getUidEvent(element, uid) {
function normalizeParams(originalTypeEvent, handler, delegationFn) {
const delegation = typeof handler === 'string'
const originalHandler = delegation ? delegationFn : handler
-
let typeEvent = getTypeEvent(originalTypeEvent)
const isNative = nativeEvents.has(typeEvent)
for (const handlerKey of Object.keys(storeElementEvent)) {
if (handlerKey.includes(namespace)) {
const event = storeElementEvent[handlerKey]
-
removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector)
}
}
if (!inNamespace || originalTypeEvent.includes(handlerKey)) {
const event = storeElementEvent[keyHandlers]
-
removeHandler(element, events, typeEvent, event.originalHandler, event.delegationSelector)
}
}
evt = document.createEvent('HTMLEvents')
evt.initEvent(typeEvent, bubbles, true)
} else {
- evt = new CustomEvent(event, {
- bubbles,
- cancelable: true
- })
+ evt = new CustomEvent(event, { bubbles, cancelable: true })
}
// merge custom information in our event
* --------------------------------------------------------------------------
*/
+import { isDisabled, isVisible } from '../util/index'
+
/**
- * ------------------------------------------------------------------------
* Constants
- * ------------------------------------------------------------------------
*/
-import { isDisabled, isVisible } from '../util/index'
-
const NODE_TEXT = 3
const SelectorEngine = {
},
children(element, selector) {
- return [].concat(...element.children)
- .filter(child => child.matches(selector))
+ return [].concat(...element.children).filter(child => child.matches(selector))
},
parents(element, selector) {
const parents = []
-
let ancestor = element.parentNode
while (ancestor && ancestor.nodeType === Node.ELEMENT_NODE && ancestor.nodeType !== NODE_TEXT) {
*/
import * as Popper from '@popperjs/core'
-
import {
defineJQueryPlugin,
getElement,
import BaseComponent from './base-component'
/**
- * ------------------------------------------------------------------------
* Constants
- * ------------------------------------------------------------------------
*/
const NAME = 'dropdown'
}
/**
- * ------------------------------------------------------------------------
- * Class Definition
- * ------------------------------------------------------------------------
+ * Class definition
*/
class Dropdown extends BaseComponent {
}
// Getters
-
static get Default() {
return Default
}
}
// Public
-
toggle() {
return this._isShown() ? this.hide() : this.show()
}
}
// Private
-
_completeHide(relatedTarget) {
const hideEvent = EventHandler.trigger(this._element, EVENT_HIDE, relatedTarget)
if (hideEvent.defaultPrevented) {
}
// Static
-
static jQueryInterface(config) {
return this.each(function () {
const data = Dropdown.getOrCreateInstance(this, config)
}
/**
- * ------------------------------------------------------------------------
- * Data Api implementation
- * ------------------------------------------------------------------------
+ * Data API implementation
*/
EventHandler.on(document, EVENT_KEYDOWN_DATA_API, SELECTOR_DATA_TOGGLE, Dropdown.dataApiKeydownHandler)
})
/**
- * ------------------------------------------------------------------------
* jQuery
- * ------------------------------------------------------------------------
- * add .Dropdown to jQuery only if jQuery is present
*/
defineJQueryPlugin(Dropdown)
import { enableDismissTrigger } from './util/component-functions'
/**
- * ------------------------------------------------------------------------
* Constants
- * ------------------------------------------------------------------------
*/
const NAME = 'modal'
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 SELECTOR_MODAL_BODY = '.modal-body'
const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="modal"]'
+const Default = {
+ backdrop: true,
+ keyboard: true,
+ focus: true
+}
+
+const DefaultType = {
+ backdrop: '(boolean|string)',
+ keyboard: 'boolean',
+ focus: 'boolean'
+}
+
/**
- * ------------------------------------------------------------------------
- * Class Definition
- * ------------------------------------------------------------------------
+ * Class definition
*/
class Modal extends BaseComponent {
}
// Getters
-
static get Default() {
return Default
}
}
// Public
-
toggle(relatedTarget) {
return this._isShown ? this.hide() : this.show(relatedTarget)
}
}
// Private
-
_initializeBackDrop() {
return new Backdrop({
isVisible: Boolean(this._config.backdrop), // 'static' option will be translated to true, and booleans will keep their value
this._element.focus()
}
- // ----------------------------------------------------------------------
- // the following methods are used to handle overflowing modals
- // ----------------------------------------------------------------------
+ /**
+ * The following methods are used to handle overflowing modals
+ */
_adjustDialog() {
const isModalOverflowing = this._element.scrollHeight > document.documentElement.clientHeight
}
// Static
-
static jQueryInterface(config, relatedTarget) {
return this.each(function () {
const data = Modal.getOrCreateInstance(this, config)
}
/**
- * ------------------------------------------------------------------------
- * Data Api implementation
- * ------------------------------------------------------------------------
+ * Data API implementation
*/
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
enableDismissTrigger(Modal)
/**
- * ------------------------------------------------------------------------
* jQuery
- * ------------------------------------------------------------------------
- * add .Modal to jQuery only if jQuery is present
*/
defineJQueryPlugin(Modal)
import { enableDismissTrigger } from './util/component-functions'
/**
- * ------------------------------------------------------------------------
* Constants
- * ------------------------------------------------------------------------
*/
const NAME = 'offcanvas'
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_BACKDROP = 'offcanvas-backdrop'
const OPEN_SELECTOR = '.offcanvas.show'
const SELECTOR_DATA_TOGGLE = '[data-bs-toggle="offcanvas"]'
+const Default = {
+ backdrop: true,
+ keyboard: true,
+ scroll: false
+}
+
+const DefaultType = {
+ backdrop: 'boolean',
+ keyboard: 'boolean',
+ scroll: 'boolean'
+}
+
/**
- * ------------------------------------------------------------------------
- * Class Definition
- * ------------------------------------------------------------------------
+ * Class definition
*/
class Offcanvas extends BaseComponent {
}
// Getters
-
static get NAME() {
return NAME
}
}
// Public
-
toggle(relatedTarget) {
return this._isShown ? this.hide() : this.show(relatedTarget)
}
}
// Private
-
_getConfig(config) {
config = {
...Default,
}
// Static
-
static jQueryInterface(config) {
return this.each(function () {
const data = Offcanvas.getOrCreateInstance(this, config)
}
/**
- * ------------------------------------------------------------------------
- * Data Api implementation
- * ------------------------------------------------------------------------
+ * Data API implementation
*/
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
})
// avoid conflict when clicking a toggler of an offcanvas, while another is open
- const allReadyOpen = SelectorEngine.findOne(OPEN_SELECTOR)
- if (allReadyOpen && allReadyOpen !== target) {
- Offcanvas.getInstance(allReadyOpen).hide()
+ const alreadyOpen = SelectorEngine.findOne(OPEN_SELECTOR)
+ if (alreadyOpen && alreadyOpen !== target) {
+ Offcanvas.getInstance(alreadyOpen).hide()
}
const data = Offcanvas.getOrCreateInstance(target)
})
enableDismissTrigger(Offcanvas)
+
/**
- * ------------------------------------------------------------------------
* jQuery
- * ------------------------------------------------------------------------
*/
defineJQueryPlugin(Offcanvas)
import Tooltip from './tooltip'
/**
- * ------------------------------------------------------------------------
* Constants
- * ------------------------------------------------------------------------
*/
const NAME = '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,
placement: 'right',
MOUSELEAVE: `mouseleave${EVENT_KEY}`
}
-const SELECTOR_TITLE = '.popover-header'
-const SELECTOR_CONTENT = '.popover-body'
-
/**
- * ------------------------------------------------------------------------
- * Class Definition
- * ------------------------------------------------------------------------
+ * Class definition
*/
class Popover extends Tooltip {
// Getters
-
static get Default() {
return Default
}
}
// Overrides
-
isWithContent() {
return this.getTitle() || this._getContent()
}
}
// Private
-
_getContent() {
return this._resolvePossibleFunction(this._config.content)
}
}
// Static
-
static jQueryInterface(config) {
return this.each(function () {
const data = Popover.getOrCreateInstance(this, config)
}
/**
- * ------------------------------------------------------------------------
* jQuery
- * ------------------------------------------------------------------------
- * add .Popover to jQuery only if jQuery is present
*/
defineJQueryPlugin(Popover)
import BaseComponent from './base-component'
/**
- * ------------------------------------------------------------------------
* Constants
- * ------------------------------------------------------------------------
*/
const NAME = '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_LOAD_DATA_API = `load${EVENT_KEY}${DATA_API_KEY}`
const METHOD_OFFSET = 'offset'
const METHOD_POSITION = 'position'
+const Default = {
+ offset: 10,
+ method: 'auto',
+ target: ''
+}
+
+const DefaultType = {
+ offset: 'number',
+ method: 'string',
+ target: '(string|element)'
+}
+
/**
- * ------------------------------------------------------------------------
- * Class Definition
- * ------------------------------------------------------------------------
+ * Class definition
*/
class ScrollSpy extends BaseComponent {
}
// Getters
-
static get Default() {
return Default
}
}
// Public
-
refresh() {
const autoMethod = this._scrollElement === this._scrollElement.window ?
METHOD_OFFSET :
}
// Private
-
_getConfig(config) {
config = {
...Default,
}
// Static
-
static jQueryInterface(config) {
return this.each(function () {
const data = ScrollSpy.getOrCreateInstance(this, config)
}
/**
- * ------------------------------------------------------------------------
- * Data Api implementation
- * ------------------------------------------------------------------------
+ * Data API implementation
*/
EventHandler.on(window, EVENT_LOAD_DATA_API, () => {
})
/**
- * ------------------------------------------------------------------------
* jQuery
- * ------------------------------------------------------------------------
- * add .ScrollSpy to jQuery only if jQuery is present
*/
defineJQueryPlugin(ScrollSpy)
import BaseComponent from './base-component'
/**
- * ------------------------------------------------------------------------
* Constants
- * ------------------------------------------------------------------------
*/
const NAME = 'tab'
const SELECTOR_DROPDOWN_ACTIVE_CHILD = ':scope > .dropdown-menu .active'
/**
- * ------------------------------------------------------------------------
- * Class Definition
- * ------------------------------------------------------------------------
+ * Class definition
*/
class Tab extends BaseComponent {
// Getters
-
static get NAME() {
return NAME
}
// Public
-
show() {
if ((this._element.parentNode &&
this._element.parentNode.nodeType === Node.ELEMENT_NODE &&
}
const hideEvent = previous ?
- EventHandler.trigger(previous, EVENT_HIDE, {
- relatedTarget: this._element
- }) :
+ EventHandler.trigger(previous, EVENT_HIDE, { relatedTarget: this._element }) :
null
const showEvent = EventHandler.trigger(this._element, EVENT_SHOW, {
this._activate(this._element, listElement)
const complete = () => {
- EventHandler.trigger(previous, EVENT_HIDDEN, {
- relatedTarget: this._element
- })
- EventHandler.trigger(this._element, EVENT_SHOWN, {
- relatedTarget: previous
- })
+ EventHandler.trigger(previous, EVENT_HIDDEN, { relatedTarget: this._element })
+ EventHandler.trigger(this._element, EVENT_SHOWN, { relatedTarget: previous })
}
if (target) {
}
// Private
-
_activate(element, container, callback) {
const activeElements = container && (container.nodeName === 'UL' || container.nodeName === 'OL') ?
SelectorEngine.find(SELECTOR_ACTIVE_UL, container) :
}
// Static
-
static jQueryInterface(config) {
return this.each(function () {
const data = Tab.getOrCreateInstance(this)
}
/**
- * ------------------------------------------------------------------------
- * Data Api implementation
- * ------------------------------------------------------------------------
+ * Data API implementation
*/
EventHandler.on(document, EVENT_CLICK_DATA_API, SELECTOR_DATA_TOGGLE, function (event) {
})
/**
- * ------------------------------------------------------------------------
* jQuery
- * ------------------------------------------------------------------------
- * add .Tab to jQuery only if jQuery is present
*/
defineJQueryPlugin(Tab)
import { enableDismissTrigger } from './util/component-functions'
/**
- * ------------------------------------------------------------------------
* Constants
- * ------------------------------------------------------------------------
*/
const NAME = 'toast'
}
/**
- * ------------------------------------------------------------------------
- * Class Definition
- * ------------------------------------------------------------------------
+ * Class definition
*/
class Toast extends BaseComponent {
}
// Getters
-
static get DefaultType() {
return DefaultType
}
}
// Public
-
show() {
const showEvent = EventHandler.trigger(this._element, EVENT_SHOW)
}
// Private
-
_getConfig(config) {
config = {
...Default,
}
// Static
-
static jQueryInterface(config) {
return this.each(function () {
const data = Toast.getOrCreateInstance(this, config)
}
}
+/**
+ * Data API implementation
+ */
+
enableDismissTrigger(Toast)
/**
- * ------------------------------------------------------------------------
* jQuery
- * ------------------------------------------------------------------------
- * add .Toast to jQuery only if jQuery is present
*/
defineJQueryPlugin(Toast)
*/
import * as Popper from '@popperjs/core'
-
import {
defineJQueryPlugin,
findShadowRoot,
import BaseComponent from './base-component'
/**
- * ------------------------------------------------------------------------
* Constants
- * ------------------------------------------------------------------------
*/
const NAME = 'tooltip'
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 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'
const AttachmentMap = {
AUTO: 'auto',
popperConfig: null
}
+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 Event = {
HIDE: `hide${EVENT_KEY}`,
HIDDEN: `hidden${EVENT_KEY}`,
MOUSELEAVE: `mouseleave${EVENT_KEY}`
}
-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 {
super(element)
- // private
+ // Private
this._isEnabled = true
this._timeout = 0
this._hoverState = ''
}
// Getters
-
static get Default() {
return Default
}
}
// Public
-
enable() {
this._isEnabled = true
}
}
// Protected
-
isWithContent() {
return Boolean(this.getTitle())
}
}
// Private
-
_initializeOnDelegatedTarget(event, context) {
return context || this.constructor.getOrCreateInstance(event.delegateTarget, this._getDelegateConfig())
}
}
/**
- * ------------------------------------------------------------------------
* jQuery
- * ------------------------------------------------------------------------
- * add .Tooltip to jQuery only if jQuery is present
*/
defineJQueryPlugin(Tooltip)
import EventHandler from '../dom/event-handler'
import { execute, executeAfterTransition, getElement, reflow, typeCheckConfig } from './index'
+/**
+ * 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',
isVisible: true, // if false, we use the backdrop helper without adding any element to the dom
rootElement: '(element|string)',
clickCallback: '(function|null)'
}
-const NAME = 'backdrop'
-const CLASS_NAME_FADE = 'fade'
-const CLASS_NAME_SHOW = 'show'
-const EVENT_MOUSEDOWN = `mousedown.bs.${NAME}`
+/**
+ * Class definition
+ */
class Backdrop {
constructor(config) {
this._element = null
}
+ // Public
show(callback) {
if (!this._config.isVisible) {
execute(callback)
})
}
- // Private
+ dispose() {
+ if (!this._isAppended) {
+ return
+ }
+ EventHandler.off(this._element, EVENT_MOUSEDOWN)
+
+ this._element.remove()
+ this._isAppended = false
+ }
+
+ // Private
_getElement() {
if (!this._element) {
const backdrop = document.createElement('div')
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)
}
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'
-}
+/**
+ * Constants
+ */
const NAME = 'focustrap'
const DATA_KEY = 'bs.focustrap'
const TAB_NAV_FORWARD = 'forward'
const TAB_NAV_BACKWARD = 'backward'
+const Default = {
+ trapElement: null, // The element to trap focus inside of
+ autofocus: true
+}
+
+const DefaultType = {
+ trapElement: 'element',
+ autofocus: 'boolean'
+}
+
+/**
+ * Class definition
+ */
+
class FocusTrap {
constructor(config) {
this._config = this._getConfig(config)
this._lastTabNavDirection = null
}
+ // Public
activate() {
const { trapElement, autofocus } = this._config
}
// Private
-
_handleFocusin(event) {
const { target } = event
const { trapElement } = this._config
}
/**
- * --------------------------------------------------------------------------
- * Public Util Api
- * --------------------------------------------------------------------------
+ * Public Util API
*/
const getUID = prefix => {
}
const getElement = obj => {
- if (isElement(obj)) { // it's a jQuery object or a node element
+ // it's a jQuery object or a node element
+ if (isElement(obj)) {
return obj.jquery ? obj[0] : obj
}
* @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
+ element.offsetHeight // eslint-disable-line no-unused-expressions
}
const getjQuery = () => {
}
export {
+ defineJQueryPlugin,
+ execute,
+ executeAfterTransition,
+ findShadowRoot,
getElement,
- getUID,
- getSelectorFromElement,
getElementFromSelector,
+ getjQuery,
+ getNextActiveElement,
+ getSelectorFromElement,
getTransitionDurationFromElement,
- triggerTransitionEnd,
+ getUID,
+ isDisabled,
isElement,
- typeCheckConfig,
+ isRTL,
isVisible,
- isDisabled,
- findShadowRoot,
noop,
- getNextActiveElement,
- reflow,
- getjQuery,
onDOMContentLoaded,
- isRTL,
- defineJQueryPlugin,
- execute,
- executeAfterTransition
+ reflow,
+ triggerTransitionEnd,
+ typeCheckConfig
}
import Manipulator from '../dom/manipulator'
import { isElement } from './index'
+/**
+ * Constants
+ */
+
const SELECTOR_FIXED_CONTENT = '.fixed-top, .fixed-bottom, .is-fixed, .sticky-top'
const SELECTOR_STICKY_CONTENT = '.sticky-top'
+/**
+ * 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
this._setElementAttributes(SELECTOR_STICKY_CONTENT, 'marginRight', calculatedValue => calculatedValue - width)
}
+ reset() {
+ this._resetElementAttributes(this._element, 'overflow')
+ this._resetElementAttributes(this._element, 'paddingRight')
+ this._resetElementAttributes(SELECTOR_FIXED_CONTENT, 'paddingRight')
+ this._resetElementAttributes(SELECTOR_STICKY_CONTENT, 'marginRight')
+ }
+
+ isOverflowing() {
+ return this.getWidth() > 0
+ }
+
+ // Private
_disableOverFlow() {
this._saveInitialAttribute(this._element, 'overflow')
this._element.style.overflow = 'hidden'
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) {
}
}
}
-
- isOverflowing() {
- return this.getWidth() > 0
- }
}
export default ScrollBarHelper
+/**
+ * --------------------------------------------------------------------------
+ * Bootstrap (v5.1.3): util/swipe.js
+ * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
+ * --------------------------------------------------------------------------
+ */
+
import EventHandler from '../dom/event-handler'
import { execute, typeCheckConfig } from './index'
+/**
+ * Constants
+ */
+
const NAME = 'swipe'
const EVENT_KEY = '.bs.swipe'
const EVENT_TOUCHSTART = `touchstart${EVENT_KEY}`
endCallback: '(function|null)'
}
+/**
+ * Class definition
+ */
+
class Swipe {
constructor(element, config) {
this._element = element
this._initEvents()
}
+ // Public
dispose() {
EventHandler.off(this._element, EVENT_KEY)
}
+ // Private
_start(event) {
if (!this._supportPointerEvents) {
this._deltaX = event.touches[0].clientX
return this._supportPointerEvents && (event.pointerType === POINTER_TYPE_PEN || event.pointerType === POINTER_TYPE_TOUCH)
}
+ // Static
static isSupported() {
return 'ontouchstart' in document.documentElement || navigator.maxTouchPoints > 0
}