stream-chat-react
Version:
React components to create chat conversations or livestream style chat
63 lines • 3.25 kB
TypeScript
import type { Notification, NotificationAction, NotificationSeverity } from 'stream-chat';
import { type NotificationTargetPanel } from '../notificationTarget';
/** Tag used for full-width system banners (e.g. connection status). Excluded from `NotificationList` by default. */
export declare const SYSTEM_NOTIFICATION_TAG: "system";
export declare const hasSystemNotificationTag: (notification: Notification) => boolean;
export type NotificationIncidentDescriptor = {
/** Where the incident happened (e.g. api, browser, validation, permission). */
domain: string;
/** Entity being operated on (e.g. message, poll, location, attachment). */
entity: string;
/** Attempted operation (e.g. send, end, share, upload). */
operation: string;
/** Status of the operation (e.g. failed, success, blocked). */
status?: string;
};
export type AddNotificationParams = {
/** Optional interactive actions rendered by the notification component. */
actions?: NotificationAction[];
/** Arbitrary context metadata stored in `origin.context`. */
context?: Record<string, unknown>;
/** Duration in milliseconds after which the notification auto-dismisses. */
duration?: number;
/** Logical source emitting the notification (e.g. component or feature name). */
emitter: string;
/** Underlying error object attached as `options.originalError`. */
error?: Error;
/** Human-readable notification message. */
message: string;
/** Notification severity visualized by the UI. */
severity?: NotificationSeverity;
/** Additional tags appended to target panel tags. */
tags?: string[];
/** Explicit target panels; when provided, inferred panel is ignored. */
targetPanels?: NotificationTargetPanel[];
/** Structured descriptor of the incident this notification reports on. */
incident?: NotificationIncidentDescriptor;
/**
* Optional machine-readable notification type identifier (domain:entity:operation:status).
* Used by notification consumers to route behavior, including translation lookup
* via notification-type registries.
* When omitted, `type` is generated from `incident` if `incident` is provided.
*/
type?: string;
};
/**
* Same shape as {@link AddNotificationParams} except `targetPanels` is omitted — system
* banners are global and do not receive `target:*` panel tags (they are filtered by the
* `system` tag for `NotificationList` vs banner UIs).
*/
export type AddSystemNotificationParams = Omit<AddNotificationParams, 'targetPanels'>;
export type AddNotification = (params: AddNotificationParams) => void;
/** Returns the notification id (for removal / timeouts). */
export type AddSystemNotification = (params: AddSystemNotificationParams) => string;
export type RemoveNotification = (id: string) => void;
export type StartNotificationTimeout = (id: string) => void;
export type NotificationApi = {
addNotification: AddNotification;
addSystemNotification: AddSystemNotification;
removeNotification: RemoveNotification;
startNotificationTimeout: StartNotificationTimeout;
};
export declare const useNotificationApi: () => NotificationApi;
//# sourceMappingURL=useNotificationApi.d.ts.map