diff --git a/src/runtime/components/overlays/Notification.vue b/src/runtime/components/overlays/Notification.vue index 4b36f1f9..cce894f1 100644 --- a/src/runtime/components/overlays/Notification.vue +++ b/src/runtime/components/overlays/Notification.vue @@ -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>, + type: Object as PropType>, default: null }, close: { - type: Object as PropType>, + type: Object as PropType>, default: () => appConfig.ui.notification.default.close }, timeout: { @@ -89,7 +89,7 @@ export default defineComponent({ default: 5000 }, actions: { - type: Array as PropType, + type: Array as PropType, default: () => [] }, callback: { @@ -162,7 +162,7 @@ export default defineComponent({ emit('close') } - function onAction (action: ToastNotificationAction) { + function onAction (action: NotificationAction) { if (timer) { timer.stop() } diff --git a/src/runtime/components/overlays/Notifications.vue b/src/runtime/components/overlays/Notifications.vue index da5330fd..f903ba09 100644 --- a/src/runtime/components/overlays/Notifications.vue +++ b/src/runtime/components/overlays/Notifications.vue @@ -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>(() => defu({}, props.ui, appConfig.ui.notifications)) const toast = useToast() - const notifications = useState('notifications', () => []) + const notifications = useState('notifications', () => []) return { // eslint-disable-next-line vue/no-dupe-keys diff --git a/src/runtime/composables/useCopyToClipboard.ts b/src/runtime/composables/useCopyToClipboard.ts index 328a1de7..1dfa8bb7 100644 --- a/src/runtime/composables/useCopyToClipboard.ts +++ b/src/runtime/composables/useCopyToClipboard.ts @@ -1,8 +1,8 @@ import { useClipboard } from '@vueuse/core' -import type { ToastNotification } from '../types/toast' +import type { Notification } from '../types/notification' import { useToast } from './useToast' -export function useCopyToClipboard (options: Partial = {}) { +export function useCopyToClipboard (options: Partial = {}) { const { copy: copyToClipboard, isSupported } = useClipboard() const toast = useToast() diff --git a/src/runtime/composables/useToast.ts b/src/runtime/composables/useToast.ts index 2023eb8d..c77dd3f1 100644 --- a/src/runtime/composables/useToast.ts +++ b/src/runtime/composables/useToast.ts @@ -1,25 +1,25 @@ -import type { ToastNotification } from '../types' +import type { Notification } from '../types' import { useState } from '#imports' export function useToast () { - const notifications = useState('notifications', () => []) + const notifications = useState('notifications', () => []) - function add (notification: Partial) { + function add (notification: Partial) { const body = { id: new Date().getTime().toString(), ...notification } - const index = notifications.value.findIndex((n: ToastNotification) => n.id === body.id) + const index = notifications.value.findIndex((n: Notification) => n.id === body.id) if (index === -1) { - notifications.value.push(body as ToastNotification) + notifications.value.push(body as Notification) } return body } function remove (id: string) { - notifications.value = notifications.value.filter((n: ToastNotification) => n.id !== id) + notifications.value = notifications.value.filter((n: Notification) => n.id !== id) } return { diff --git a/src/runtime/types/index.d.ts b/src/runtime/types/index.d.ts index d3c7248f..6b52b251 100644 --- a/src/runtime/types/index.d.ts +++ b/src/runtime/types/index.d.ts @@ -1,5 +1,5 @@ export * from './avatar' export * from './clipboard' export * from './command-palette' +export * from './notification' export * from './popper' -export * from './toast' diff --git a/src/runtime/types/notification.d.ts b/src/runtime/types/notification.d.ts new file mode 100644 index 00000000..ad4dbcf8 --- /dev/null +++ b/src/runtime/types/notification.d.ts @@ -0,0 +1,23 @@ +import type { Avatar } from './avatar' +import type { Button } from './button' +import appConfig from '#build/app.config' + +export interface NotificationAction extends Partial