2022-12-28 23:57:06 +09:00
|
|
|
export type AriaLive = 'off' | 'polite' | 'assertive'
|
|
|
|
export type AriaAnnounceType = 'announce' | 'mute' | 'unmute'
|
2022-12-24 00:08:36 +09:00
|
|
|
|
|
|
|
const ariaAnnouncer = useEventBus<AriaAnnounceType, string | undefined>(Symbol('aria-announcer'))
|
|
|
|
|
2023-03-31 04:01:24 +09:00
|
|
|
export function useAriaAnnouncer() {
|
2022-12-24 00:08:36 +09:00
|
|
|
const announce = (message: string) => {
|
|
|
|
ariaAnnouncer.emit('announce', message)
|
|
|
|
}
|
|
|
|
|
|
|
|
const mute = () => {
|
|
|
|
ariaAnnouncer.emit('mute')
|
|
|
|
}
|
|
|
|
|
|
|
|
const unmute = () => {
|
|
|
|
ariaAnnouncer.emit('unmute')
|
|
|
|
}
|
|
|
|
|
|
|
|
return { announce, ariaAnnouncer, mute, unmute }
|
|
|
|
}
|
|
|
|
|
2023-03-31 04:01:24 +09:00
|
|
|
export function useAriaLog() {
|
2022-12-24 00:08:36 +09:00
|
|
|
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,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-31 04:01:24 +09:00
|
|
|
export function useAriaStatus() {
|
2022-12-24 00:08:36 +09:00
|
|
|
let status = $ref<any>('')
|
|
|
|
|
|
|
|
const announceStatus = (message: any) => {
|
|
|
|
status = message
|
|
|
|
}
|
|
|
|
|
|
|
|
const clearStatus = () => {
|
|
|
|
status = ''
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
announceStatus,
|
|
|
|
clearStatus,
|
|
|
|
status,
|
|
|
|
}
|
|
|
|
}
|