mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-12 11:51:10 +08:00
* react-redux-toastr: unify code style * react-redux-toastr: Change React.Component types to use state and props * react-redux-toastr: change to named imports * react-redux-toastr: remove module declaration * react-redux-toastr: add union types for known strings * react-redux-toastr: rename ToastrConfirmOptions to ConfirmToastrOptions for unified style, refine properties * react-redux-toastr: Add interfaces for all of the Toastr option objects * react-redux-toastr: Refactor some variables to alphabetical order * react-redux-toastr: Add interfaces to toastrs in reducer state, add toastr action payload, toastr reducer state * react-redux-toastr: Rename ToastOptions to ToastrOptions to unify style * react-redux-toastr: Rename ToastrOptions to ReduxToastrProps and rewrite properties * react-redux-toastr: Slight refactor of ReduxToastrProps * react-redux-toastr: Remove confirmOptions interface * react-redux-toastr: Remove duplicate ConfirmToastrOptions interface * react-redux-toastr: Rewrite ToastrEmitter, modify tests to comply with version 7.0.0 * react-redux-toastr: rewrite action creators, start using ToastrState * react-redux-toastr: Slight refactor, alphabetize stuff * react-redux-toastr: remove unused Component state and props * react-redux-toastr: fix TS version * Fix version number for TypeScript
130 lines
4.1 KiB
TypeScript
130 lines
4.1 KiB
TypeScript
// Type definitions for react-redux-toastr 7.0.0
|
|
// Project: https://github.com/diegoddox/react-redux-toastr
|
|
// Definitions by: Aleksandar Ivanov <https://github.com/Smiche>
|
|
// Artyom Stukans <https://github.com/artyomsv>
|
|
// Mika Kuitunen <https://github.com/kulmajaba>
|
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
// TypeScript Version: 2.3
|
|
|
|
import { Component } from 'react';
|
|
import { Action, ActionCreator, Reducer } from 'redux';
|
|
|
|
export type iconType = 'success' | 'info' | 'warning' | 'error';
|
|
export type positionType = 'top-left' | 'top-center' | 'top-right' | 'bottom-left' | 'bottom-ceter' | 'bottom-right';
|
|
export type toastType = 'success' | 'info' | 'warning' | 'light' | 'error' | 'confirm' | 'message';
|
|
export type transitionInType = 'bounceIn' | 'bounceInDown' | 'fadeIn';
|
|
export type transitionOutType = 'bounceOut' | 'bounceOutUp' | 'fadeOut';
|
|
|
|
interface BasicToastrOptions {
|
|
attention?: boolean;
|
|
className?: string;
|
|
component?: Component;
|
|
icon?: Component;
|
|
onCloseButtonClick?: () => void;
|
|
onHideComplete?: () => void;
|
|
onShowComplete?: () => void;
|
|
progressBar?: boolean;
|
|
removeOnHover?: boolean;
|
|
showCloseButton?: boolean;
|
|
timeOut?: number;
|
|
transitionIn?: transitionInType;
|
|
transitionOut?: transitionOutType;
|
|
}
|
|
|
|
interface LightToastrOptions {
|
|
attention?: boolean;
|
|
className?: string;
|
|
component?: Component;
|
|
icon?: iconType | Component;
|
|
onCloseButtonClick?: () => void;
|
|
onHideComplete?: () => void;
|
|
onShowComplete?: () => void;
|
|
progressBar?: boolean;
|
|
removeOnHover?: boolean;
|
|
showCloseButton?: boolean;
|
|
status?: iconType;
|
|
timeOut?: number;
|
|
transitionIn?: transitionInType;
|
|
transitionOut?: transitionOutType;
|
|
}
|
|
|
|
interface ConfirmToastrOptions {
|
|
disableCancel?: boolean;
|
|
onCancel?: () => void;
|
|
onOk?: () => void;
|
|
}
|
|
|
|
interface ConfirmToastrCustomOptions {
|
|
component: Component;
|
|
}
|
|
|
|
export interface Toastr {
|
|
id: string;
|
|
message?: string;
|
|
options: BasicToastrOptions | LightToastrOptions;
|
|
position: positionType;
|
|
title?: string;
|
|
type: toastType;
|
|
}
|
|
|
|
export interface AddToastPayload {
|
|
id?: string;
|
|
message?: string;
|
|
options?: BasicToastrOptions | LightToastrOptions;
|
|
position?: positionType;
|
|
title?: string;
|
|
type: toastType;
|
|
}
|
|
|
|
export interface ToastrState {
|
|
confirm?: {
|
|
id: string;
|
|
message: string;
|
|
options: ConfirmToastrOptions | ConfirmToastrCustomOptions;
|
|
show: boolean;
|
|
};
|
|
toastrs: Toastr[];
|
|
}
|
|
|
|
interface ReduxToastrProps {
|
|
confirmOptions?: {
|
|
cancelText: string;
|
|
okText: string;
|
|
};
|
|
newestOnTop?: boolean;
|
|
options?: any; // This is currently not used, waiting for response from the package author to remove
|
|
position?: positionType
|
|
preventDuplicates?: boolean;
|
|
progressBar?: boolean;
|
|
timeOut?: number;
|
|
toastr?: ToastrState;
|
|
transitionIn?: transitionInType;
|
|
transitionOut?: transitionOutType;
|
|
}
|
|
|
|
interface ToastrEmitter {
|
|
clean: () => void;
|
|
confirm: (message: string, options: ConfirmToastrOptions) => void;
|
|
error: (title: string, message: string, options?: BasicToastrOptions) => void;
|
|
info: (title: string, message: string, options?: BasicToastrOptions) => void;
|
|
light: (title: string, message: string, options?: LightToastrOptions) => void;
|
|
message: (title: string, message: string, options?: BasicToastrOptions) => void;
|
|
removeByType: (type: string) => void;
|
|
success: (title: string, message: string, options?: BasicToastrOptions) => void;
|
|
warning: (title: string, message: string, options?: BasicToastrOptions) => void;
|
|
}
|
|
|
|
interface ToastrActionCreators {
|
|
add: (toastr: AddToastPayload) => Action;
|
|
clean: () => Action;
|
|
hideConfirm: () => Action;
|
|
remove: (id: string) => Action;
|
|
removeByType: (type: toastType) => Action;
|
|
showConfirm: (confirm: ConfirmToastrOptions | ConfirmToastrCustomOptions) => Action;
|
|
}
|
|
|
|
export default class ReduxToastr extends Component<ReduxToastrProps> {}
|
|
export const actions: ToastrActionCreators;
|
|
export const reducer: Reducer<ToastrState>;
|
|
export const toastr: ToastrEmitter;
|