import { Extensible, ID } from "../../types/index.mjs"; import { ContextTrinity } from "../createTrinity/index.mjs"; import { RegistryContext, RegistryOptions, RegistryTicket, RegistryTicketInput } from "../createRegistry/index.mjs"; import { Plugin } from "../createPlugin/index.mjs"; import { QueueContext } from "../createQueue/index.mjs"; import { NotificationsAdapter } from "./adapters/adapter.mjs"; import "../index.mjs"; //#region src/composables/useNotifications/index.d.ts /** Notification urgency level. Maps to ARIA roles: `'error'`/`'warning'` → `role="alert"`, `'info'`/`'success'` → `role="status"`. Extensible — custom values like `'critical'` are allowed with autocomplete for defaults. */ type NotificationSeverity = Extensible<'info' | 'warning' | 'error' | 'success'>; /** @deprecated Renamed to `NotificationTicketInput` (FooTicketInput/FooTicket pair rule); will be removed at 1.0.0 final. */ type NotificationInput = NotificationTicketInput; /** Input shape for creating a notification via {@link send} or {@link register}. */ interface NotificationTicketInput extends RegistryTicketInput { /** Notification headline. */ subject?: string; /** Extended message body. */ body?: string; /** Urgency level for styling and ARIA role selection. */ severity?: NotificationSeverity; /** Arbitrary payload for routing, filtering, or rendering. */ data?: Record; /** Auto-dismiss duration in ms. Overrides the global default. `undefined` uses the global timeout. */ timeout?: number; } /** * Hydrated notification with lifecycle state and convenience methods. * Returned by {@link send}, {@link register}, and {@link onboard}. */ type NotificationTicket = RegistryTicket & Z & { /** When the notification was created. */ createdAt: Date; /** When the notification was marked as read, or `null` if unread. */ readAt: Date | null; /** When the notification was seen in the viewport, or `null` if unseen. */ seenAt: Date | null; /** When the notification was archived, or `null` if active. */ archivedAt: Date | null; /** Snooze expiry, or `null` if not snoozed. */ snoozedUntil: Date | null; /** Mark as read. Sets `readAt` to now. */ read: () => void; /** Mark as unread. Clears `readAt`. */ unread: () => void; /** Mark as seen. Sets `seenAt` to now. */ seen: () => void; /** Archive. Sets `archivedAt` to now. */ archive: () => void; /** Restore from archive. Clears `archivedAt`. */ unarchive: () => void; /** Snooze until the given time. */ snooze: (until: Date) => void; /** Cancel snooze. Clears `snoozedUntil`. */ wake: () => void; /** Remove from the display queue only. Registry entry is preserved for inbox/history. Use `ticket.unregister()` for full removal. */ dismiss: () => void; }; /** * Context passed to adapter `setup()`. Provides methods for inbound * notification creation and event subscription for outbound sync. */ interface NotificationsAdapterContext = NotificationTicket> { /** Create a notification and enqueue for toast display. Use for real-time inbound items. */ send: (input: Z) => E; /** Create a notification in registry only (no toast). Use for initial/historical items. */ register: (input: Z) => E; /** Subscribe to notification lifecycle events (e.g., `'notification:read'`). The handler receives the affected {@link NotificationTicket}. */ on: (event: string, handler: (data: unknown) => void) => void; /** Unsubscribe from a lifecycle event. */ off: (event: string, handler: (data: unknown) => void) => void; } /** Options for {@link createNotifications}. */ interface NotificationsOptions extends RegistryOptions { /** Default auto-dismiss timeout in ms for the toast queue. @default 3000 */ timeout?: number; } /** Full notification context returned by {@link createNotifications} and {@link useNotifications}. */ interface NotificationsContext = NotificationTicket> extends RegistryContext { /** Create a notification and enqueue for toast display. */ send: (input: Z) => E; /** The toast display queue. Access `queue.values()`, `queue.pause()`, `queue.resume()`. */ queue: QueueContext; /** Mark as read. Emits `notification:read`. */ read: (id: ID) => void; /** Mark as unread. Emits `notification:unread`. */ unread: (id: ID) => void; /** Mark as seen. Emits `notification:seen`. */ seen: (id: ID) => void; /** Archive. Emits `notification:archived`. */ archive: (id: ID) => void; /** Restore from archive. Emits `notification:unarchived`. */ unarchive: (id: ID) => void; /** Snooze until the given time. Emits `notification:snoozed`. */ snooze: (id: ID, until: Date) => void; /** Cancel snooze. Emits `notification:unsnoozed`. */ wake: (id: ID) => void; /** Mark all unread notifications as read. */ readAll: () => void; /** Archive all unarchived notifications. */ archiveAll: () => void; /** Active notifications adapter, when the plugin was installed with one. */ adapter?: NotificationsAdapter; } declare function createNotifications(_options?: NotificationsOptions & { adapter?: NotificationsAdapter; }): NotificationsContext; interface NotificationsPluginOptions extends NotificationsOptions { namespace?: string; adapter?: NotificationsAdapter; /** * Persist notification interaction state to storage and restore it on load. * * @remarks Stores only interaction state — a map of notification id to its * `readAt` / `seenAt` / `archivedAt` / `snoozedUntil` timestamps (ISO * strings, non-null fields only). Notification content is never stored: * notifications are always created by code or an adapter, and the saved * state merges onto them as they register — at restore time or any time * later. Expired snoozes are dropped on restore, and entries whose * notification never re-registers are pruned from the next persist write. * The storage key is the plugin namespace with the `v0:` prefix stripped * (`notifications`). * * Requires stable notification `id`s to associate state across reloads. * * @default false */ persist?: boolean; } /** * Notification management with registry, event system, and optional adapters. * * @see https://0.vuetifyjs.com/composables/plugins/use-notifications * * @example * ```ts * import { createNotificationsPlugin, useNotifications } from '@vuetify/v0' * * // Install as plugin * app.use(createNotificationsPlugin()) * * // Use in components * const notifications = useNotifications() * notifications.send({ subject: 'Saved', severity: 'success' }) * ``` */ declare const createNotificationsContext: <_E extends NotificationsContext> = NotificationsContext>>(_options?: NotificationsPluginOptions | undefined) => ContextTrinity<_E>, createNotificationsPlugin: (_options?: (NotificationsPluginOptions & Pick<{ namespace?: string; persist?: boolean; devtools?: boolean; }, "devtools">) | undefined) => Plugin, useNotifications: <_E extends NotificationsContext> = NotificationsContext>>(namespace?: string) => _E; //#endregion export { NotificationInput, NotificationSeverity, NotificationTicket, NotificationTicketInput, NotificationsAdapterContext, NotificationsContext, NotificationsOptions, NotificationsPluginOptions, createNotifications, createNotificationsContext, createNotificationsPlugin, useNotifications };