claude-web/node_modules/primevue/focustrap/index.mjs.map

1 line
14 KiB
Plaintext
Raw Normal View History

2026-02-23 02:23:38 +00:00
{"version":3,"file":"index.mjs","sources":["../../src/focustrap/BaseFocusTrap.js","../../src/focustrap/FocusTrap.js"],"sourcesContent":["import BaseDirective from '@primevue/core/basedirective';\nimport FocusTrapStyle from 'primevue/focustrap/style';\n\nconst BaseFocusTrap = BaseDirective.extend({\n style: FocusTrapStyle\n});\n\nexport default BaseFocusTrap;\n","import { createElement, focus, getFirstFocusableElement, getLastFocusableElement, isFocusableElement } from '@primeuix/utils/dom';\nimport { isNotEmpty } from '@primeuix/utils/object';\nimport BaseFocusTrap from './BaseFocusTrap';\n\nconst FocusTrap = BaseFocusTrap.extend('focustrap', {\n mounted(el, binding) {\n const { disabled } = binding.value || {};\n\n if (!disabled) {\n this.createHiddenFocusableElements(el, binding);\n this.bind(el, binding);\n this.autoElementFocus(el, binding);\n }\n\n el.setAttribute('data-pd-focustrap', true);\n\n this.$el = el;\n },\n updated(el, binding) {\n const { disabled } = binding.value || {};\n\n disabled && this.unbind(el);\n },\n unmounted(el) {\n this.unbind(el);\n },\n methods: {\n getComputedSelector(selector) {\n return `:not(.p-hidden-focusable):not([data-p-hidden-focusable=\"true\"])${selector ?? ''}`;\n },\n bind(el, binding) {\n const { onFocusIn, onFocusOut } = binding.value || {};\n\n el.$_pfocustrap_mutationobserver = new MutationObserver((mutationList) => {\n mutationList.forEach((mutation) => {\n if (mutation.type === 'childList' && !el.contains(document.activeElement)) {\n const findNextFocusableElement = (_el) => {\n const focusableElement = isFocusableElement(_el)\n ? isFocusableElement(_el, this.getComputedSelector(el.$_pfocustrap_focusableselector))\n ? _el\n : getFirstFocusableElement(el, this.getComputedSelector(el.$_pfocustrap_focusableselector))\n : getFirstFocusableElement(_el);\n\n return isNotEmpty(focusableElement) ? focusableElement : _el.nextSibling && findNextFocusableElement(_el.nextSibling);\n };\n\n focus(findNextFocusableElement(mutation.nextSibling));\n }\n });\n });\n\n el.$_pfocustrap_mutationobserver.disconnect();\n el.$_pfocustrap_mutationobserver.observe(el, {\n childList: true\n });\n\n el.$_pfocustrap_focusinlistener = (event) => onFocusIn && onFocusIn(event);\n el.$_pfocustrap_focusoutlistener = (event) => onFocusOut && onFocusOut(event);\n\n el.addEventListener('focusin', el.$_pfocustrap_focusinlistener);\n el.addEventListener('focusout', el.$_pfocustrap_focusoutlistener);\n },\n unbind(el) {\n el.$_pfocustrap_mutationobserver && el.$_pfocustrap_mutationobserver.disconnect();\n el.$_pfocustrap_focusinlistener && el.removeEventListener('focusin', el.$_pfocustrap_focusinlistener) && (el.$_pfocustrap_focusinlistener = null);\n el.$_pfocustrap_focusoutlistener && el.removeEventListener('focusout', el.$_pfocustrap_focusoutlistener) && (el.$_pfocustrap_focusoutlistener = null);\n },\n autoFocus(options) {\n this.autoElementFocus(this.$el, { value: { ...options, autoFocus: true } });\n },\n autoElementFocus(el, binding) {\n const { autoFocusSelector = '', firstFocusableSelector = '', autoFocus = false } = binding.value || {};\n let focusableElement = getFirstFocusableElement(el, `[autofocus]${this.getComputedSelector(autoFocusSelector)}`);\n\n autoFocus && !focusableElement && (focusableElement = getFirstFocusableElement(el, this.getComputedSelector(firstFocusableSelector)));\n