mirror of
https://github.com/elk-zone/elk
synced 2024-11-27 22:38:11 +09:00
3c43a1cdd1
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: 三咲智子 Kevin Deng <sxzz@sxzz.moe>
62 lines
1.1 KiB
TypeScript
62 lines
1.1 KiB
TypeScript
export type AriaLive = 'off' | 'polite' | 'assertive'
|
|
export type AriaAnnounceType = 'announce' | 'mute' | 'unmute'
|
|
|
|
const ariaAnnouncer = useEventBus<AriaAnnounceType, string | undefined>(Symbol('aria-announcer'))
|
|
|
|
export function useAriaAnnouncer() {
|
|
const announce = (message: string) => {
|
|
ariaAnnouncer.emit('announce', message)
|
|
}
|
|
|
|
const mute = () => {
|
|
ariaAnnouncer.emit('mute')
|
|
}
|
|
|
|
const unmute = () => {
|
|
ariaAnnouncer.emit('unmute')
|
|
}
|
|
|
|
return { announce, ariaAnnouncer, mute, unmute }
|
|
}
|
|
|
|
export function useAriaLog() {
|
|
let logs = $ref<any[]>([])
|
|
|
|
const announceLogs = (messages: any[]) => {
|
|
logs = messages
|
|
}
|
|
|
|
const appendLogs = (messages: any[]) => {
|
|
logs = logs.concat(messages)
|
|
}
|
|
|
|
const clearLogs = () => {
|
|
logs = []
|
|
}
|
|
|
|
return {
|
|
announceLogs,
|
|
appendLogs,
|
|
clearLogs,
|
|
logs,
|
|
}
|
|
}
|
|
|
|
export function useAriaStatus() {
|
|
let status = $ref<any>('')
|
|
|
|
const announceStatus = (message: any) => {
|
|
status = message
|
|
}
|
|
|
|
const clearStatus = () => {
|
|
status = ''
|
|
}
|
|
|
|
return {
|
|
announceStatus,
|
|
clearStatus,
|
|
status,
|
|
}
|
|
}
|