analytica-frontend-lib
Version:
Repositório público dos componentes utilizados nas plataformas da Analytica Ensino
218 lines • 6.43 kB
TypeScript
import { ReactNode } from 'react';
import type { Notification, NotificationGroup, NotificationEntityType } from '../../types/notifications';
export interface NotificationItem extends Omit<Notification, 'createdAt'> {
time: string;
createdAt: string | Date;
}
interface BaseNotificationProps {
/**
* Additional CSS classes
*/
className?: string;
/**
* Empty state image path
*/
emptyStateImage?: string;
/**
* Empty state title
*/
emptyStateTitle?: string;
/**
* Empty state description
*/
emptyStateDescription?: string;
}
interface SingleNotificationCardMode extends BaseNotificationProps {
/**
* Component mode - single card
*/
mode: 'single';
/**
* The notification title
*/
title: string;
/**
* The notification message content
*/
message: string;
/**
* Time displayed (e.g., "Há 3h", "12 Fev")
*/
time: string;
/**
* Whether the notification has been read
*/
isRead: boolean;
/**
* Callback when user marks notification as read
*/
onMarkAsRead: () => void;
/**
* Callback when user deletes notification
*/
onDelete: () => void;
/**
* Optional callback for navigation action
*/
onNavigate?: () => void;
/**
* Label for the action button (only shown if onNavigate is provided)
*/
actionLabel?: string;
}
interface NotificationListMode extends BaseNotificationProps {
/**
* Component mode - list
*/
mode: 'list';
/**
* Array of notifications for list mode
*/
notifications?: NotificationItem[];
/**
* Array of grouped notifications
*/
groupedNotifications?: NotificationGroup[];
/**
* Loading state for list mode
*/
loading?: boolean;
/**
* Error state for list mode
*/
error?: string | null;
/**
* Callback for retry when error occurs
*/
onRetry?: () => void;
/**
* Callback when user marks a notification as read in list mode
*/
onMarkAsReadById?: (id: string) => void;
/**
* Callback when user deletes a notification in list mode
*/
onDeleteById?: (id: string) => void;
/**
* Callback when user navigates from a notification in list mode
*/
onNavigateById?: (entityType?: NotificationEntityType, entityId?: string) => void;
/**
* Callback when user clicks on a global notification
*/
onGlobalNotificationClick?: (notification: Notification) => void;
/**
* Function to get action label for a notification
*/
getActionLabel?: (entityType?: NotificationEntityType) => string | undefined;
/**
* Custom empty state component
*/
renderEmpty?: () => ReactNode;
}
interface NotificationCenterMode extends BaseNotificationProps {
/**
* Component mode - center
*/
mode: 'center';
/**
* Array of grouped notifications
*/
groupedNotifications?: NotificationGroup[];
/**
* Loading state for center mode
*/
loading?: boolean;
/**
* Error state for center mode
*/
error?: string | null;
/**
* Callback for retry when error occurs
*/
onRetry?: () => void;
/**
* Whether center mode is currently active (controls dropdown/modal visibility)
*/
isActive?: boolean;
/**
* Callback when center mode is toggled
*/
onToggleActive?: () => void;
/**
* Number of unread notifications for badge display
*/
unreadCount?: number;
/**
* Callback when all notifications should be marked as read
*/
onMarkAllAsRead?: () => void;
/**
* Callback to fetch notifications (called when center opens)
*/
onFetchNotifications?: () => void;
/**
* Callback when user marks a notification as read in center mode
*/
onMarkAsReadById?: (id: string) => void;
/**
* Callback when user deletes a notification in center mode
*/
onDeleteById?: (id: string) => void;
/**
* Callback when user navigates from a notification in center mode
*/
onNavigateById?: (entityType?: NotificationEntityType, entityId?: string) => void;
/**
* Function to get action label for a notification
*/
getActionLabel?: (entityType?: NotificationEntityType) => string | undefined;
/**
* Callback when dropdown open state changes (for synchronization with parent)
*/
onOpenChange?: (open: boolean) => void;
}
export type NotificationCardProps = SingleNotificationCardMode | NotificationListMode | NotificationCenterMode;
export interface LegacyNotificationCardProps extends BaseNotificationProps {
title?: string;
message?: string;
time?: string;
isRead?: boolean;
onMarkAsRead?: () => void;
onDelete?: () => void;
onNavigate?: () => void;
actionLabel?: string;
notifications?: NotificationItem[];
groupedNotifications?: NotificationGroup[];
loading?: boolean;
error?: string | null;
onRetry?: () => void;
onMarkAsReadById?: (id: string) => void;
onDeleteById?: (id: string) => void;
onNavigateById?: (entityType?: NotificationEntityType, entityId?: string) => void;
onGlobalNotificationClick?: (notification: Notification) => void;
getActionLabel?: (entityType?: NotificationEntityType) => string | undefined;
renderEmpty?: () => ReactNode;
variant?: 'card' | 'center';
isActive?: boolean;
onToggleActive?: () => void;
unreadCount?: number;
onMarkAllAsRead?: () => void;
onFetchNotifications?: () => void;
onOpenChange?: (open: boolean) => void;
}
/**
* NotificationCard component - can display single notification, list of notifications, or center mode
*
* @param props - The notification card properties
* @returns JSX element representing the notification card, list, or center
*/
declare const NotificationCard: (props: NotificationCardProps) => import("react/jsx-runtime").JSX.Element;
/**
* Legacy NotificationCard component for backward compatibility
* Automatically detects mode based on provided props
*/
export declare const LegacyNotificationCard: (props: LegacyNotificationCardProps) => import("react/jsx-runtime").JSX.Element;
export default NotificationCard;
export type { NotificationGroup };
//# sourceMappingURL=NotificationCard.d.ts.map