{"version":3,"file":"use-focus-trap.js","sources":["../../../../../../../packages/components/popper/src/composables/use-focus-trap.ts"],"sourcesContent":["import { ref } from 'vue'\n\nimport type { SetupContext } from 'vue'\nimport type { PopperContentEmits, PopperContentProps } from '../content'\n\nexport const usePopperContentFocusTrap = (\n props: PopperContentProps,\n emit: SetupContext['emit']\n) => {\n const trapped = ref(false)\n const focusStartRef = ref<'container' | 'first' | HTMLElement>()\n\n const onFocusAfterTrapped = () => {\n emit('focus')\n }\n\n const onFocusAfterReleased = (event: CustomEvent) => {\n if (event.detail?.focusReason !== 'pointer') {\n focusStartRef.value = 'first'\n emit('blur')\n }\n }\n\n const onFocusInTrap = (event: FocusEvent) => {\n if (props.visible && !trapped.value) {\n if (event.target) {\n focusStartRef.value = event.target as typeof focusStartRef.value\n }\n trapped.value = true\n }\n }\n\n const onFocusoutPrevented = (event: CustomEvent) => {\n if (!props.trapping) {\n if (event.detail.focusReason === 'pointer') {\n event.preventDefault()\n }\n trapped.value = false\n }\n }\n\n const onReleaseRequested = () => {\n trapped.value = false\n emit('close')\n }\n\n return {\n focusStartRef,\n trapped,\n\n onFocusAfterReleased,\n onFocusAfterTrapped,\n onFocusInTrap,\n onFocusoutPrevented,\n onReleaseRequested,\n }\n}\n\nexport type UsePopperContentFocusTrapReturn = ReturnType<\n typeof usePopperContentFocusTrap\n>\n"],"names":["ref"],"mappings":";;;;;;AACY,MAAC,yBAAyB,GAAG,CAAC,KAAK,EAAE,IAAI,KAAK;AAC1D,EAAE,MAAM,OAAO,GAAGA,OAAG,CAAC,KAAK,CAAC,CAAC;AAC7B,EAAE,MAAM,aAAa,GAAGA,OAAG,EAAE,CAAC;AAC9B,EAAE,MAAM,mBAAmB,GAAG,MAAM;AACpC,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC;AAClB,GAAG,CAAC;AACJ,EAAE,MAAM,oBAAoB,GAAG,CAAC,KAAK,KAAK;AAC1C,IAAI,IAAI,EAAE,CAAC;AACX,IAAI,IAAI,CAAC,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