|
37 | 37 | class="alert-dismiss-icon"
|
38 | 38 | :size="KUI_ICON_SIZE_40"
|
39 | 39 | tabindex="0"
|
40 |
| - @click="$emit('dismiss')" |
| 40 | + @click="emit('dismiss')" |
41 | 41 | @keydown.space.prevent
|
42 |
| - @keyup.enter="$emit('dismiss')" |
43 |
| - @keyup.space="$emit('dismiss')" |
| 42 | + @keyup.enter="emit('dismiss')" |
| 43 | + @keyup.space="emit('dismiss')" |
44 | 44 | />
|
45 | 45 | </div>
|
46 | 46 | </template>
|
47 | 47 |
|
48 | 48 | <script setup lang="ts">
|
49 | 49 | import { computed } from 'vue'
|
50 |
| -import type { PropType } from 'vue' |
51 |
| -import type { AlertAppearance } from '@/types' |
52 | 50 | import { AlertAppearances } from '@/types'
|
| 51 | +import type { AlertEmits, AlertProps , AlertSlots } from '@/types' |
53 | 52 | import { InfoIcon, CheckCircleIcon, WarningIcon, DangerIcon, CloseIcon } from '@kong/icons'
|
54 | 53 | import { KUI_ICON_SIZE_40 } from '@kong/design-tokens'
|
55 | 54 |
|
56 | 55 | type AlertIcon = typeof InfoIcon // all icons are the same type so we can use any of them
|
57 | 56 |
|
58 |
| -const props = defineProps({ |
59 |
| - title: { |
60 |
| - type: String, |
61 |
| - default: '', |
62 |
| - }, |
63 |
| - message: { |
64 |
| - type: String, |
65 |
| - default: '', |
66 |
| - }, |
67 |
| - appearance: { |
68 |
| - type: String as PropType<AlertAppearance>, |
69 |
| - default: 'info', |
70 |
| - validator: (value: AlertAppearance): boolean => { |
71 |
| - return Object.values(AlertAppearances).includes(value) |
72 |
| - }, |
73 |
| - }, |
74 |
| - showIcon: { |
75 |
| - type: Boolean, |
76 |
| - default: false, |
77 |
| - }, |
78 |
| - dismissible: { |
79 |
| - type: Boolean, |
80 |
| - default: false, |
81 |
| - }, |
82 |
| -}) |
83 |
| -
|
84 |
| -defineEmits(['dismiss']) |
| 57 | +const { |
| 58 | + title = '', |
| 59 | + message = '', |
| 60 | + appearance = AlertAppearances.info, |
| 61 | + showIcon, |
| 62 | + dismissible, |
| 63 | +} = defineProps<AlertProps>() |
| 64 | +const emit = defineEmits<AlertEmits>() |
| 65 | +defineSlots<AlertSlots>() |
85 | 66 |
|
86 | 67 | const getAlertIcon = computed((): AlertIcon => {
|
87 |
| - switch (props.appearance) { |
| 68 | + switch (appearance) { |
88 | 69 | case AlertAppearances.info:
|
89 | 70 | return InfoIcon
|
90 | 71 | case AlertAppearances.success:
|
|
0 commit comments