Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@types/react-alert

Package Overview
Dependencies
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/react-alert - npm Package Compare versions

Comparing version 5.2.1 to 7.0.0

151

react-alert/index.d.ts

@@ -1,20 +0,24 @@

// Type definitions for react-alert 5.2
// Type definitions for react-alert 7.0
// Project: https://github.com/schiehll/react-alert
// Definitions by: Yue Yang <https://github.com/g1eny0ung>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.8
import * as React from 'react';
// The 7.x definition also applies to [6.x, 5.x].
//
// Some points to note:
//
// 1. `alert.removeAll()` has been added since `6.x`.
export type AlertPosition =
import { CSSProperties, ReactNode, ComponentType, Component, Context } from 'react';
export type AlertPositionV4 =
| 'top left'
| 'top center'
| 'top right'
| 'middle left'
| 'middle'
| 'middle right'
| 'bottom left'
| 'bottom center'
| 'bottom right';
export type AlertPosition = AlertPositionV4 | 'middle left' | 'middle' | 'middle right';
export type AlertType = 'info' | 'success' | 'error';
export type AlertTransition = 'fade' | 'scale';
export interface Positions {

@@ -31,7 +35,2 @@ TOP_LEFT: 'top left';

}
export const positions: Positions;
export type AlertType = 'info' | 'success' | 'error';
export interface Types {

@@ -42,7 +41,2 @@ INFO: 'info';

}
export const types: Types;
export type AlertTransition = 'fade' | 'scale';
export interface Transitions {

@@ -53,100 +47,115 @@ FADE: 'fade';

export const positions: Positions;
export const types: Types;
export const transitions: Transitions;
export interface AlertProviderProps extends React.HTMLAttributes<HTMLDivElement> {
export interface AlertOptions {
/**
* The margin of each alert
* The margin of each alert.
*
* Default value: '10px'
* Default: '10px'
*/
offset?: string | undefined;
/**
* The position of the alerts in the page
* The position of the alerts in the page.
*
* Default value: 'top center'
* Default: positions.TOP_CENTER
*/
position?: AlertPosition | undefined;
/**
* Timeout to alert remove itself, if set to 0 it never removes itself
* Timeout to alert remove itself, if set to 0 it never removes itself.
*
* Default value: 0
* Default: 0
*/
timeout?: number | undefined;
/**
* The default alert type used when calling this.props.alert.show
* The default alert type used when calling this.props.alert.show.
*
* Default value: 'info'
* Default: types.INFO
*/
type?: AlertType | undefined;
/**
* The transition animation
* The transition animation.
*
* Default value: 'fade'
* Default: transitions.FADE
*/
transition?: AlertTransition | undefined;
/**
* The style of the alert container
* Style to be applied in the alerts container.
*
* Default z-index value: 100
* Default: {
* zIndex: 100,
* }
*/
containerStyle?: React.CSSProperties | undefined;
containerStyle?: CSSProperties | undefined;
}
export interface AlertInstance {
id: number;
/**
* The alert component for each message
* The alert message.
*/
template: React.ComponentType<AlertComponentPropsWithStyle>;
message: ReactNode;
options: AlertOptions;
/**
* Custom context to separate alerts.
* A function that closes the alert.
*/
context?: React.Context<AlertManager | undefined> | undefined;
close: () => void;
}
export interface AlertComponentProps {
id: string;
message: React.ReactNode;
options: AlertCustomOptionsWithType;
close(): void;
export interface AlertTemplateProps extends Omit<AlertInstance, 'id'> {
/**
* The style contains only the margin given as offset.
*/
style: { margin: string };
}
export interface AlertComponentPropsWithStyle extends AlertComponentProps {
style: React.CSSProperties;
export interface AlertProviderProps extends AlertOptions {
/**
* The alert template to be used.
*/
template: React.ComponentType<AlertTemplateProps>;
context?: Context<AlertContainer> | undefined;
}
export class Provider extends React.Component<AlertProviderProps> {}
export class Provider extends Component<AlertProviderProps> {}
export interface AlertCustomOptions {
export interface AlertCustomOptions extends AlertOptions {
/**
* Custom timeout just for this one alert
* Callback that will be executed after this alert open.
*/
timeout?: number | undefined;
onOpen?: () => void | undefined;
/**
* Callback that will be executed after this alert open
* Callback that will be executed after this alert is removed.
*/
onOpen?(): void;
/**
* Callback that will be executed after this alert is removed
*/
onClose?(): void;
onClose?: () => void | undefined;
}
export interface AlertCustomOptionsWithType extends AlertCustomOptions {
type?: AlertType | undefined;
export interface AlertContainerFactory<T> {
show(message?: ReactNode, options?: T): AlertInstance;
info(message?: ReactNode, options?: T): AlertInstance;
success(message?: ReactNode, options?: T): AlertInstance;
error(message?: ReactNode, options?: T): AlertInstance;
remove(alert: AlertInstance): void;
removeAll(): void;
}
export type AlertContainer = AlertContainerFactory<AlertCustomOptions>;
export interface AlertManager {
root?: HTMLElement | undefined;
alerts: AlertComponentProps[];
show(
message?: React.ReactNode,
options?: AlertCustomOptionsWithType
): AlertComponentProps;
remove(alert: AlertComponentProps): void;
success(message?: React.ReactNode, options?: AlertCustomOptions): AlertComponentProps;
error(message?: React.ReactNode, options?: AlertCustomOptions): AlertComponentProps;
info(message?: React.ReactNode, options?: AlertCustomOptions): AlertComponentProps;
export interface InjectedAlertProps {
alert: AlertContainer;
}
export function withAlert<P extends InjectedAlertProps = InjectedAlertProps>(
context?: Context<P['alert']>,
): (c: ComponentType<P>) => ComponentType<Omit<P, 'alert'>>;
export function withAlert<P extends { alert: AlertManager }>(context?: React.Context<AlertManager | undefined>):
(c: React.ComponentType<P>) =>
React.ComponentType<Pick<P, Exclude<keyof P, 'alert'>>>;
export function useAlert(context?: React.Context<AlertManager | undefined>): AlertManager;
export function useAlert<T extends AlertContainer = AlertContainer>(context?: Context<T>): T;
{
"name": "@types/react-alert",
"version": "5.2.1",
"version": "7.0.0",
"description": "TypeScript definitions for react-alert",

@@ -25,4 +25,4 @@ "homepage": "https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/react-alert",

},
"typesPublisherContentHash": "9f7811f07b7e389f3c470406302ab4c739dea5aee254d0b6cc81fd92b3da5d36",
"typeScriptVersion": "3.6"
"typesPublisherContentHash": "32ef2bbf205bf2d73a62671f12a8eca114b575cc3f2cf6b5b8450daa300c1d6b",
"typeScriptVersion": "3.9"
}

@@ -11,3 +11,3 @@ # Installation

### Additional Details
* Last updated: Thu, 08 Jul 2021 20:20:23 GMT
* Last updated: Fri, 04 Mar 2022 14:31:44 GMT
* Dependencies: [@types/react](https://npmjs.com/package/@types/react)

@@ -14,0 +14,0 @@ * Global values: none

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc