diff --git a/src/runtime/components/elements/Alert.vue b/src/runtime/components/elements/Alert.vue index 07d20ccc..db330330 100644 --- a/src/runtime/components/elements/Alert.vue +++ b/src/runtime/components/elements/Alert.vue @@ -17,12 +17,12 @@

- +
@@ -39,7 +39,7 @@ import UIcon from '../elements/Icon.vue' import UAvatar from '../elements/Avatar.vue' import UButton from '../elements/Button.vue' import { useUI } from '../../composables/useUI' -import type { Avatar, Button, AlertColor, AlertVariant, Strategy } from '../../types' +import type { Avatar, Button, AlertColor, AlertVariant, AlertAction, Strategy } from '../../types' import { mergeConfig } from '../../utils' // @ts-expect-error import appConfig from '#build/app.config' @@ -76,7 +76,7 @@ export default defineComponent({ default: () => config.default.closeButton as unknown as Button }, actions: { - type: Array as PropType<(Button & { click?: Function })[]>, + type: Array as PropType, default: () => [] }, color: { @@ -121,11 +121,18 @@ export default defineComponent({ ), props.class) }) + function onAction (action: AlertAction) { + if (action.click) { + action.click() + } + } + return { // eslint-disable-next-line vue/no-dupe-keys ui, attrs, alertClass, + onAction, twMerge } } diff --git a/src/runtime/types/alert.d.ts b/src/runtime/types/alert.d.ts index bf9c717c..59ef02a8 100644 --- a/src/runtime/types/alert.d.ts +++ b/src/runtime/types/alert.d.ts @@ -1,7 +1,12 @@ import { alert } from '../ui.config' import type { NestedKeyOf, ExtractDeepKey, ExtractDeepObject } from '.' +import type { Button } from './button' import colors from '#ui-colors' import type { AppConfig } from 'nuxt/schema' export type AlertColor = keyof typeof alert.color | ExtractDeepKey | typeof colors[number] export type AlertVariant = keyof typeof alert.variant | ExtractDeepKey | NestedKeyOf | NestedKeyOf> + +export interface AlertAction extends Button { + click?: Function +}