export type NoticeType = 'success' | 'error' | 'warning' | 'info' export interface Notice { id: number text: string type: NoticeType } let nextId = 1 /** Short-lived messages shown at the top of every page. */ export function useNotices() { const list = useState('notices', () => []) function dismiss(id: number) { list.value = list.value.filter((n) => n.id !== id) } function push(text: string, type: NoticeType = 'info') { const id = nextId++ list.value = [...list.value, { id, text, type }] setTimeout(() => dismiss(id), 6000) } return { list, push, dismiss } }