chore(Notification): improve types

This commit is contained in:
Benjamin Canac
2023-05-23 15:24:32 +02:00
parent 6d3309c42d
commit 45ba3b26da
7 changed files with 41 additions and 35 deletions

View File

@@ -42,9 +42,9 @@ import UIcon from '../elements/Icon.vue'
import UAvatar from '../elements/Avatar.vue'
import UButton from '../elements/Button.vue'
import { useTimer } from '../../composables/useTimer'
import type { ToastNotificationAction } from '../../types'
import type { Avatar as AvatarType } from '../../types/avatar'
import type { Button as ButtonType } from '../../types/button'
import type { NotificationAction } from '../../types'
import type { Avatar} from '../../types/avatar'
import type { Button } from '../../types/button'
import { classNames } from '../../utils'
import { useAppConfig } from '#imports'
// TODO: Remove
@@ -77,11 +77,11 @@ export default defineComponent({
default: null
},
avatar: {
type: Object as PropType<Partial<AvatarType>>,
type: Object as PropType<Partial<Avatar>>,
default: null
},
close: {
type: Object as PropType<Partial<ButtonType>>,
type: Object as PropType<Partial<Button>>,
default: () => appConfig.ui.notification.default.close
},
timeout: {
@@ -89,7 +89,7 @@ export default defineComponent({
default: 5000
},
actions: {
type: Array as PropType<ToastNotificationAction[]>,
type: Array as PropType<NotificationAction[]>,
default: () => []
},
callback: {
@@ -162,7 +162,7 @@ export default defineComponent({
emit('close')
}
function onAction (action: ToastNotificationAction) {
function onAction (action: NotificationAction) {
if (timer) {
timer.stop()
}

View File

@@ -17,7 +17,7 @@
import { computed, defineComponent } from 'vue'
import type { PropType } from 'vue'
import { defu } from 'defu'
import type { ToastNotification } from '../../types'
import type { Notification } from '../../types'
import { useToast } from '../../composables/useToast'
import UNotification from './Notification.vue'
import { useState, useAppConfig } from '#imports'
@@ -44,7 +44,7 @@ export default defineComponent({
const ui = computed<Partial<typeof appConfig.ui.notifications>>(() => defu({}, props.ui, appConfig.ui.notifications))
const toast = useToast()
const notifications = useState<ToastNotification[]>('notifications', () => [])
const notifications = useState<Notification[]>('notifications', () => [])
return {
// eslint-disable-next-line vue/no-dupe-keys