mirror of
https://github.com/ArthurDanjou/ui.git
synced 2026-01-23 00:15:05 +01:00
fix(components): refactor types after @nuxt/module-builder upgrade (#3855)
This commit is contained in:
@@ -1,15 +1,11 @@
|
||||
<script lang="ts">
|
||||
import type { DialogRootProps, DialogRootEmits, DialogContentProps, DialogContentEmits } from 'reka-ui'
|
||||
import type { AppConfig } from '@nuxt/schema'
|
||||
import _appConfig from '#build/app.config'
|
||||
import theme from '#build/ui/modal'
|
||||
import { tv } from '../utils/tv'
|
||||
import type { ButtonProps } from '../types'
|
||||
import type { EmitsToProps } from '../types/utils'
|
||||
import type { EmitsToProps, ComponentConfig } from '../types/utils'
|
||||
|
||||
const appConfigModal = _appConfig as AppConfig & { ui: { modal: Partial<typeof theme> } }
|
||||
|
||||
const modal = tv({ extend: tv(theme), ...(appConfigModal.ui?.modal || {}) })
|
||||
type Modal = ComponentConfig<typeof theme, AppConfig, 'modal'>
|
||||
|
||||
export interface ModalProps extends DialogRootProps {
|
||||
title?: string
|
||||
@@ -54,7 +50,7 @@ export interface ModalProps extends DialogRootProps {
|
||||
*/
|
||||
dismissible?: boolean
|
||||
class?: any
|
||||
ui?: Partial<typeof modal.slots>
|
||||
ui?: Modal['slots']
|
||||
}
|
||||
|
||||
export interface ModalEmits extends DialogRootEmits {
|
||||
@@ -67,7 +63,7 @@ export interface ModalSlots {
|
||||
header(props?: {}): any
|
||||
title(props?: {}): any
|
||||
description(props?: {}): any
|
||||
close(props: { ui: ReturnType<typeof modal> }): any
|
||||
close(props: { ui: { [K in keyof Required<Modal['slots']>]: (props?: Record<string, any>) => string } }): any
|
||||
body(props?: {}): any
|
||||
footer(props?: {}): any
|
||||
}
|
||||
@@ -79,6 +75,7 @@ import { DialogRoot, DialogTrigger, DialogPortal, DialogOverlay, DialogContent,
|
||||
import { reactivePick } from '@vueuse/core'
|
||||
import { useAppConfig } from '#imports'
|
||||
import { useLocale } from '../composables/useLocale'
|
||||
import { tv } from '../utils/tv'
|
||||
import UButton from './Button.vue'
|
||||
|
||||
const props = withDefaults(defineProps<ModalProps>(), {
|
||||
@@ -93,7 +90,7 @@ const emits = defineEmits<ModalEmits>()
|
||||
const slots = defineSlots<ModalSlots>()
|
||||
|
||||
const { t } = useLocale()
|
||||
const appConfig = useAppConfig()
|
||||
const appConfig = useAppConfig() as Modal['AppConfig']
|
||||
|
||||
const rootProps = useForwardPropsEmits(reactivePick(props, 'open', 'defaultOpen', 'modal'), emits)
|
||||
const contentProps = toRef(() => props.content)
|
||||
@@ -114,7 +111,7 @@ const contentEvents = computed(() => {
|
||||
return events
|
||||
})
|
||||
|
||||
const ui = computed(() => modal({
|
||||
const ui = computed(() => tv({ extend: tv(theme), ...(appConfig.ui?.modal || {}) })({
|
||||
transition: props.transition,
|
||||
fullscreen: props.fullscreen
|
||||
}))
|
||||
|
||||
Reference in New Issue
Block a user