reka-ui
Version:
Vue port for Radix UI Primitives.
1 lines • 2.85 kB
Source Map (JSON)
{"version":3,"file":"DialogContentNonModal.cjs","sources":["../../src/Dialog/DialogContentNonModal.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport { ref } from 'vue'\nimport { injectDialogRootContext } from './DialogRoot.vue'\nimport DialogContentImpl, { type DialogContentImplEmits, type DialogContentImplProps } from './DialogContentImpl.vue'\nimport { useEmitAsProps, useForwardExpose } from '@/shared'\n\nconst props = defineProps<DialogContentImplProps>()\nconst emits = defineEmits<DialogContentImplEmits>()\n\nconst emitsAsProps = useEmitAsProps(emits)\nuseForwardExpose()\n\nconst rootContext = injectDialogRootContext()\nconst hasInteractedOutsideRef = ref(false)\nconst hasPointerDownOutsideRef = ref(false)\n</script>\n\n<template>\n <DialogContentImpl\n v-bind=\"{ ...props, ...emitsAsProps }\"\n :trap-focus=\"false\"\n :disable-outside-pointer-events=\"false\"\n @close-auto-focus=\"\n (event) => {\n if (!event.defaultPrevented) {\n if (!hasInteractedOutsideRef) rootContext.triggerElement.value?.focus();\n // Always prevent auto focus because we either focus manually or want user agent focus\n event.preventDefault();\n }\n\n hasInteractedOutsideRef = false;\n hasPointerDownOutsideRef = false;\n }\n \"\n @interact-outside=\"(event) => {\n if (!event.defaultPrevented) {\n hasInteractedOutsideRef = true;\n if (event.detail.originalEvent.type === 'pointerdown') {\n hasPointerDownOutsideRef = true;\n }\n }\n\n // Prevent dismissing when clicking the trigger.\n // As the trigger is already setup to close, without doing so would\n // cause it to close and immediately open.\n const target = event.target as HTMLElement;\n const targetIsTrigger = rootContext.triggerElement.value?.contains(target);\n if (targetIsTrigger) event.preventDefault();\n\n // On Safari if the trigger is inside a container with tabIndex={0}, when clicked\n // we will get the pointer down outside event on the trigger, but then a subsequent\n // focus outside event on the container, we ignore any focus outside event when we've\n // already had a pointer down outside event.\n if (event.detail.originalEvent.type === 'focusin' && hasPointerDownOutsideRef) {\n event.preventDefault();\n }\n }\"\n >\n <slot />\n </DialogContentImpl>\n</template>\n"],"names":["useEmitAsProps","useForwardExpose","injectDialogRootContext","ref"],"mappings":";;;;;;;;;;;;;;;;;;;AAMA,IAAA,MAAM,KAAQ,GAAA,OAAA;AACd,IAAA,MAAM,KAAQ,GAAA,MAAA;AAEd,IAAM,MAAA,YAAA,GAAeA,qCAAe,KAAK,CAAA;AACzC,IAAiBC,wCAAA,EAAA;AAEjB,IAAA,MAAM,cAAcC,yCAAwB,EAAA;AAC5C,IAAM,MAAA,uBAAA,GAA0BC,QAAI,KAAK,CAAA;AACzC,IAAM,MAAA,wBAAA,GAA2BA,QAAI,KAAK,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}