UNPKG

questro

Version:

A lightweight, modular gamification library for React with unique visual components. Features combo meters, daily challenges, achievement toasts, and progress rings. Add points, badges, quests, leaderboards, levels/XP, streaks, and notifications with zero

115 lines (108 loc) 4.56 kB
import * as react_jsx_runtime from 'react/jsx-runtime'; import React from 'react'; type NotificationType = 'success' | 'info' | 'warning' | 'error' | 'levelup' | 'achievement'; type NotificationPosition = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right'; type Notification = { id: string; type: NotificationType; title: string; message?: string; icon?: string; duration?: number; dismissible?: boolean; action?: { label: string; onClick: () => void; }; timestamp: number; read?: boolean; }; type NotificationConfig = { position?: NotificationPosition; maxNotifications?: number; defaultDuration?: number; animations?: boolean; sound?: boolean; soundUrl?: string; }; type NotificationInput = Omit<Notification, 'id' | 'timestamp'>; type NotificationsState = { notifications: Notification[]; lastUpdated: number; }; type NotificationsContextValue = { notifications: Notification[]; unreadCount: number; show: (notification: NotificationInput) => string; dismiss: (id: string) => void; dismissAll: () => void; markAsRead: (id: string) => void; success: (title: string, message?: string, icon?: string) => string; error: (title: string, message?: string, icon?: string) => string; info: (title: string, message?: string, icon?: string) => string; warning: (title: string, message?: string, icon?: string) => string; levelUp: (level: number) => string; badgeUnlocked: (badgeName: string, badgeIcon?: string) => string; questCompleted: (questName: string, points: number) => string; streakMilestone: (streak: number) => string; streakWarning: (hoursLeft: number) => string; }; type NotificationsProviderProps = { children: React.ReactNode; config?: NotificationConfig; }; declare function NotificationsProvider({ children, config }: NotificationsProviderProps): react_jsx_runtime.JSX.Element; declare function useNotifications(): NotificationsContextValue; declare class NotificationsService { private state; private config; private listeners; private timeouts; constructor(config?: NotificationConfig, initialState?: NotificationsState); private createInitialState; show(input: NotificationInput): string; dismiss(id: string): void; dismissAll(): void; markAsRead(id: string): void; getNotifications(): Notification[]; getVisibleNotifications(): Notification[]; getUnreadCount(): number; getState(): NotificationsState; subscribe(listener: () => void): () => void; destroy(): void; private playSound; private notifyListeners; success(title: string, message?: string, icon?: string): string; error(title: string, message?: string, icon?: string): string; info(title: string, message?: string, icon?: string): string; warning(title: string, message?: string, icon?: string): string; levelUp(level: number): string; badgeUnlocked(badgeName: string, badgeIcon?: string): string; questCompleted(questName: string, points: number): string; streakMilestone(streak: number): string; streakWarning(hoursLeft: number): string; } type ToastProps = { notification: Notification; onDismiss: () => void; className?: string; children?: (data: { notification: Notification; onDismiss: () => void; }) => React.ReactNode; }; declare function Toast({ notification, onDismiss, className, children }: ToastProps): react_jsx_runtime.JSX.Element; type ToastPosition = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-center' | 'bottom-right'; type NotificationContainerProps = { position?: ToastPosition; maxVisible?: number; className?: string; renderToast?: (notification: Notification, onDismiss: () => void) => React.ReactNode; children?: (data: { notifications: Notification[]; dismiss: (id: string) => void; position: ToastPosition; }) => React.ReactNode; }; declare function NotificationContainer({ position, maxVisible, className, renderToast, children, }: NotificationContainerProps): react_jsx_runtime.JSX.Element; export { type Notification, type NotificationConfig, NotificationContainer, type NotificationContainerProps, type NotificationInput, type NotificationPosition, type NotificationType, NotificationsProvider, type NotificationsProviderProps, NotificationsService, type NotificationsState, Toast, type ToastPosition, type ToastProps, useNotifications };