Line data Source code
1 16 : <script setup lang="ts">
2 : import type { DialogContentEmits, DialogContentProps } from 'reka-ui'
3 : import { DialogContent, useForwardPropsEmits } from 'reka-ui'
4 : import type { HTMLAttributes } from 'vue'
5 :
6 : import { cn } from '@comfyorg/tailwind-utils'
7 :
8 : import type { DialogContentSize, DialogContentSurface } from './dialog.variants'
9 : import { dialogContentVariants } from './dialog.variants'
10 :
11 3130 : const {
12 : class: customClass = '',
13 : maximized = false,
14 : size,
15 : surface,
16 : ...restProps
17 : } = defineProps<
18 : DialogContentProps & {
19 : class?: HTMLAttributes['class']
20 : maximized?: boolean
21 : size?: DialogContentSize
22 : surface?: DialogContentSurface
23 : }
24 : >()
25 :
26 : const emits = defineEmits<DialogContentEmits>()
27 3130 : const forwarded = useForwardPropsEmits(restProps, emits)
28 :
29 826 : function focusAutofocusTarget(event: Event) {
30 826 : if (event.defaultPrevented || !(event.target instanceof HTMLElement)) return
31 820 : const target = event.target.querySelector<HTMLElement>('[autofocus]')
32 820 : if (!target) return
33 367 : target.focus()
34 367 : if (document.activeElement === target) event.preventDefault()
35 : }
36 3130 : </script>
37 :
38 : <template>
39 5905 : <DialogContent
40 : v-bind="forwarded"
41 : data-reka-dialog-content
42 : :data-maximized="maximized || undefined"
43 : :class="
44 : cn(
45 : dialogContentVariants({ maximized, size, surface }),
46 : customClass,
47 : maximized &&
48 : 'top-2 left-2 size-auto max-h-none max-w-none sm:max-w-none'
49 : )
50 : "
51 : @open-auto-focus="focusAutofocusTarget"
52 : @focus="focusAutofocusTarget"
53 : >
54 : <slot />
55 : </DialogContent>
56 : </template>
|