fyne-on/components/aria/AriaLog.vue

39 lines
767 B
Vue
Raw Normal View History

2022-12-23 16:08:36 +01:00
<script setup lang="ts">
import type { AriaLive } from '~/composables/aria'
2022-12-23 16:08:36 +01:00
const {
ariaLive = 'polite',
heading = 'h2',
messageKey = (message: any) => message,
} = defineProps<{
2022-12-23 16:08:36 +01:00
ariaLive?: AriaLive
heading?: 'h2' | 'h3' | 'h4' | 'h5' | 'h6'
title: string
messageKey?: (message: any) => any
}>()
2022-12-23 16:08:36 +01:00
const { announceLogs, appendLogs, clearLogs, logs } = useAriaLog()
defineExpose({
announceLogs,
appendLogs,
clearLogs,
})
</script>
<template>
<slot />
<div sr-only role="log" :aria-live="ariaLive">
<component :is="heading">
{{ title }}
</component>
<ul>
<li v-for="log in logs" :key="messageKey(log)">
<slot name="log" :log="log">
{{ log }}
</slot>
</li>
</ul>
</div>
</template>