diff --git a/react-redux-toastr/react-redux-toastr-tests.ts b/react-redux-toastr/react-redux-toastr-tests.ts new file mode 100644 index 0000000000..bd0426face --- /dev/null +++ b/react-redux-toastr/react-redux-toastr-tests.ts @@ -0,0 +1,28 @@ +/// +/// +/// +/// +import {toastr, reducer as toastrReducer, actions} from 'react-redux-toastr'; +import ReduxToastr from 'react-redux-toastr'; +import * as React from 'react'; +import * as ReactDOM from 'react-dom'; +import {createStore, combineReducers, bindActionCreators} from 'redux'; +import { Provider, connect } from 'react-redux'; + +function test() { + const store = createStore(combineReducers({ toastr: toastrReducer })); + var toastrFactory = React.createFactory(ReduxToastr); + var element = toastrFactory({ timeOut: 1000, newestOnTop: false }); + var providerFactory = React.createFactory(Provider); + var root = providerFactory({ store: store }, element); + + function callback() { } + + toastr.clean(); + toastr.confirm("Test", { onOk: callback, onCancel: callback }); + toastr.error("Error", "Error message"); + toastr.info("Info", "Info test", { timeOut: 1000, removeOnHover: true, removeOnClick: true, onShowComplete: callback }); + toastr.success("Test", "Test message", { component: new React.Component() }); +} + +test(); diff --git a/react-redux-toastr/react-redux-toastr.d.ts b/react-redux-toastr/react-redux-toastr.d.ts new file mode 100644 index 0000000000..1b628455aa --- /dev/null +++ b/react-redux-toastr/react-redux-toastr.d.ts @@ -0,0 +1,108 @@ +// Type definitions for react-redux-toastr 3.7.0 +// Project: https://github.com/diegoddox/react-redux-toastr +// Definitions by: Aleksandar Ivanov +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// +/// +declare module "react-redux-toastr" { + import R = __React; + import _Redux = Redux; + + interface ToastrOptions { + /** + * Timeout in miliseconds. + */ + timeOut?: number, + /** + * Show newest on top or bottom. + */ + newestOnTop?: boolean, + /** + * Position of the toastr: top-left, top-center, top-right, bottom-left, bottom-center and bottom-right + */ + position?: string, + confirmText?: ConfirmText + } + + interface ConfirmText { + okText: string, + cancelText: string + } + + /** + * Toastr react component. + */ + export default class ReduxToastr extends R.Component{ } + + interface EmitterOptions { + /** + * Notification popup icon. + * icon-close-round, icon-information-circle, icon-check-1, icon-exclamation-triangle, icon-exclamation-alert + */ + icon?: string, + /** + * Timeout in miliseconds. + */ + timeOut?: number, + removeOnHover?: boolean, + removeOnClick?: boolean, + component?: R.Component, + onShowComplete?(): void; + onHideComplete?(): void; + } + + interface ToastrConfirmOptions { + onOk(): void; + onCancel(): void; + } + + interface ToastrEmitter { + /** + * Used to provide a large amount of information. + * It will not close unless a timeOut is provided. + */ + message(title: string, message: string, options?: EmitterOptions): void; + info(title: string, message: string, options?: EmitterOptions): void; + success(title: string, message: string, options?: EmitterOptions): void; + warning(title: string, message: string, options?: EmitterOptions): void; + error(title: string, message: string, options?: EmitterOptions): void; + /** + * Clear all notifications + */ + clean(): void; + /** + * Hook confirmation toastr with callback. + */ + confirm(message: string, options: ToastrConfirmOptions): void; + } + + /** + * Possible actions to dispatch. + */ + interface Actions { + addToastrAction: Redux.Action, + clean: Redux.Action, + remove: Redux.Action, + success: Redux.Action, + info: Redux.Action, + warning: Redux.Action, + error: Redux.Action, + showConfirm: Redux.Action, + hideConfirm: Redux.Action + } + + /** + * Action creator for toastr. + */ + export var actions: Redux.ActionCreator; + /** + * Reducer for the toastr state. + * Combine with your reducers. + */ + export var reducer: Redux.Reducer; + /** + * Used to issue toastr notifications. + */ + export var toastr: ToastrEmitter; +}