react-notifications-types
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

TypeScript Definitions for React-Notifications

This package provides TypeScript type definitions for the react-notifications library, enhancing the development experience by offering type checking and IntelliSense support in TypeScript projects.

Installation

To install the type definitions, you can use npm or yarn. Run one of the following commands:

npm install @types/react-notifications

or

yarn add @types/react-notifications

Usage

After installation, the type definitions can be used by simply importing react-notifications in your TypeScript files. TypeScript will automatically recognize the types based on your project's configuration.

Example:

import { NotificationManager } from 'react-notifications';

NotificationManager.info('Info message', 'Title here');

Type definitions

export interface Notification {
    title: string;
    message: string;
    level: 'success' | 'error' | 'warning' | 'info';
    position?: 'tc' | 'tr' | 'tl' | 'bc' | 'br' | 'bl' | 'cc';
    autoDismiss?: number;
    dismissible?: boolean;
    action?: NotificationAction;
}

export interface NotificationAction {
    label: string;
    callback: () => void;
}

export interface NotificationsProps {
    notifications: Notification[];
    onRequestHide?: (notification: Notification) => void;
}
export interface Notification {
    title: string;
    message: string;
    level: 'success' | 'error' | 'warning' | 'info';
    position?: 'tc' | 'tr' | 'tl' | 'bc' | 'br' | 'bl' | 'cc';
    autoDismiss?: number;
    dismissible?: boolean;
    action?: NotificationAction;
}

export interface NotificationAction {
    label: string;
    callback: () => void;
}

export interface NotificationsProps {
    notifications: Notification[];
    onRequestHide?: (notification: Notification) => void;
}

export class NotificationContainer extends React.Component<NotificationsProps> {}

export class NotificationManager {
    static create(notification: Notification): void;
    static remove(notificationId: number): void;
    static info(message: string, title?: string, timeOut?: number, onClick?: () => void, priority?: boolean): void;
    static success(message: string, title?: string, timeOut?: number, onClick?: () => void, priority?: boolean): void;
    static error(message: string, title?: string, timeOut?: number, onClick?: () => void, priority?: boolean): void;
    static warning(message: string, title?: string, timeOut?: number, onClick?: () => void, priority?: boolean): void;
}

Contributing

Contributions are always welcome! If you would like to improve the react-notifications-types definitions, please feel free to fork the repository, make your changes, and submit a pull request.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

Support

If you have any issues or feature requests, please open an issue on GitHub.

Notes:

  • Adjust the username and repository URL: Replace @yourusername/react-notifications-types and GitHub URLs with your actual npm username and repository details.
  • LICENSE.md Link: Ensure you provide a valid link to your LICENSE file, typically by adding a LICENSE file in your GitHub repository.
  • Issue Tracking: Customize the support and contribution guidelines according to how you plan to manage the project.

Package Sidebar

Install

npm i react-notifications-types

Weekly Downloads

0

Version

1.0.0

License

MIT

Unpacked Size

7.83 kB

Total Files

9

Last publish

Collaborators

  • thalesgsn