/
githubmirror
/
tabler
Обзор
Документация
Войти
/
githubmirror
/
tabler
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
core/js/src/bootstrap/util/component-functions.ts
39 строк
1 KB
Paweł Kuna
Unify workspace lint, format, and type-check quality gates (#2732)
30 июл 2026, 20:36
Не верифицирован
30 июл 2026, 20:36
6db32ea
Код
Авторство
О чём код?
/** * -------------------------------------------------------------------------- * Bootstrap util/component-functions.ts * Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE) * -------------------------------------------------------------------------- */ import EventHandler from '../dom/event-handler.js' import SelectorEngine from '../dom/selector-engine.js' import { isDisabled } from './index' interface DismissibleComponent { EVENT_KEY: string NAME: string // eslint-disable-next-line @typescript-eslint/no-explicit-any getOrCreateInstance(element: HTMLElement | string | null): any } const enableDismissTrigger = (component: DismissibleComponent, method = 'hide'): void => { const clickEvent = `click.dismiss${component.EVENT_KEY}` const name = component.NAME EventHandler.on(document, clickEvent, `[data-bs-dismiss="${name}"], [data-tblr-dismiss="${name}"]`, function (this: HTMLElement, event: Event) { if (['A', 'AREA'].includes(this.tagName)) { event.preventDefault() } if (isDisabled(this)) { return } const target = SelectorEngine.getElementFromSelector(this) || this.closest(`.${name}`) const instance = component.getOrCreateInstance(target) instance[method]() }) } export { enableDismissTrigger }