1
+ <script lang="ts">
2
+ import type { AppConfig } from ' @nuxt/schema'
3
+ import theme from ' #build/ui/overlay-provider'
4
+ import type { ComponentConfig } from ' ../types/utils'
5
+
6
+ type OverlayProvider = ComponentConfig <typeof theme , AppConfig , ' overlayProvider' >
7
+
8
+ export interface OverlayProviderProps {
9
+ /**
10
+ * Allow the overlay to nicely stack on top of each other.
11
+ * @defaultValue false
12
+ */
13
+ stacked? : boolean
14
+ class? : any
15
+ ui? : OverlayProvider [' slots' ]
16
+ }
17
+ </script >
18
+
1
19
<script setup lang="ts">
2
20
import { computed } from ' vue'
3
21
import { useOverlay , type Overlay } from ' ../composables/useOverlay'
22
+ import { useAppConfig } from ' #imports'
23
+ import { tv } from ' ../utils/tv'
4
24
5
- defineOptions ( {
6
- inheritAttrs : false
25
+ const props = withDefaults ( defineProps < OverlayProviderProps >(), {
26
+ stacked : false
7
27
})
8
28
29
+ const appConfig = useAppConfig () as OverlayProvider [' AppConfig' ]
30
+
31
+ const ui = computed (() => tv ({ extend: tv (theme ), ... (appConfig .ui ?.overlayProvider || {}) })({
32
+ stacked: props .stacked
33
+ }))
34
+
9
35
const { overlays, unmount, close } = useOverlay ()
10
36
11
37
const mountedOverlays = computed (() => overlays .filter ((overlay : Overlay ) => overlay .isMounted ))
@@ -29,13 +55,12 @@ const onClose = (id: symbol, value: any) => {
29
55
v-model:open =" overlay.isOpen"
30
56
:overlay =" index === 0 ? true : false"
31
57
:content =" {
32
- ...$attrs,
33
58
style: {
34
59
'--overlay-count': mountedOverlays.length,
35
- '--overlay-index': index,
36
- ...($attrs as any).style
60
+ '--overlay-index': index
37
61
}
38
62
}"
63
+ :class =" ui.base({ class: [props.ui?.base, props.class] })"
39
64
@close =" (value:any) => onClose(overlay.id, value)"
40
65
@after:leave =" onAfterLeave(overlay.id)"
41
66
/>
0 commit comments