From 3dacedf0dc0f6c539dfb2751232d25a868752d54 Mon Sep 17 00:00:00 2001 From: Aleksandar Ivanov Date: Tue, 20 Sep 2016 11:33:29 +0300 Subject: [PATCH 01/11] Create index.d.ts --- react-redux-toastr/index.d.ts | 105 ++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 react-redux-toastr/index.d.ts diff --git a/react-redux-toastr/index.d.ts b/react-redux-toastr/index.d.ts new file mode 100644 index 0000000000..fb3dabfa61 --- /dev/null +++ b/react-redux-toastr/index.d.ts @@ -0,0 +1,105 @@ +// Type definitions for react-redux-toastr 3.7.0 +// Project: https://github.com/diegoddox/react-redux-toastr +// Definitions by: Aleksandar Ivanov https://github.com/Smiche +// 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) => any + } + + /** + * 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; +} From 60b8d4769542d602022d0a7c521ac69ae7aff4ea Mon Sep 17 00:00:00 2001 From: Aleksandar Ivanov Date: Tue, 20 Sep 2016 11:34:07 +0300 Subject: [PATCH 02/11] Create library-tests.ts --- react-redux-toastr/library-tests.ts | 51 +++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 react-redux-toastr/library-tests.ts diff --git a/react-redux-toastr/library-tests.ts b/react-redux-toastr/library-tests.ts new file mode 100644 index 0000000000..427823b7c1 --- /dev/null +++ b/react-redux-toastr/library-tests.ts @@ -0,0 +1,51 @@ +/// +/// +/// +/// +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); + + class Test extends React.Component{ + private toastr; + constructor() { + super() + this.toastr = bindActionCreators(actions, this.props.dispatch); + this.toastr.clean(); + this.toastr.success("hi"); + } + + } + + + var TestComponent = connect(mapStateToProps, mapDispatchToProps)(Test); + function mapDispatchToProps(dispatch) { + return { + actions: bindActionCreators(actions, dispatch) + }; + } + + function mapStateToProps(state) { + return {}; + } + + 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(); From a982c80d5537adbb10e61630436b6f33970c180c Mon Sep 17 00:00:00 2001 From: Aleksandar Ivanov Date: Tue, 20 Sep 2016 12:45:34 +0300 Subject: [PATCH 03/11] Delete index.d.ts --- react-redux-toastr/index.d.ts | 105 ---------------------------------- 1 file changed, 105 deletions(-) delete mode 100644 react-redux-toastr/index.d.ts diff --git a/react-redux-toastr/index.d.ts b/react-redux-toastr/index.d.ts deleted file mode 100644 index fb3dabfa61..0000000000 --- a/react-redux-toastr/index.d.ts +++ /dev/null @@ -1,105 +0,0 @@ -// Type definitions for react-redux-toastr 3.7.0 -// Project: https://github.com/diegoddox/react-redux-toastr -// Definitions by: Aleksandar Ivanov https://github.com/Smiche -// 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) => any - } - - /** - * 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; -} From 02935de0ccd7821fcbea1e5b091f13b29d7df5f2 Mon Sep 17 00:00:00 2001 From: Aleksandar Ivanov Date: Tue, 20 Sep 2016 12:46:14 +0300 Subject: [PATCH 04/11] Update library-tests.ts --- react-redux-toastr/library-tests.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/react-redux-toastr/library-tests.ts b/react-redux-toastr/library-tests.ts index 427823b7c1..3abfc668d4 100644 --- a/react-redux-toastr/library-tests.ts +++ b/react-redux-toastr/library-tests.ts @@ -1,7 +1,7 @@ -/// -/// -/// -/// +/// +/// +/// +/// import {toastr, reducer as toastrReducer, actions} from 'react-redux-toastr'; import ReduxToastr from 'react-redux-toastr'; import * as React from 'react'; From 2837bdcd4b3e0ed0a326a6c28215709c345498a4 Mon Sep 17 00:00:00 2001 From: Aleksandar Ivanov Date: Tue, 20 Sep 2016 12:46:40 +0300 Subject: [PATCH 05/11] Rename library-tests.ts to react-redux-toastr-tests.ts --- .../{library-tests.ts => react-redux-toastr-tests.ts} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename react-redux-toastr/{library-tests.ts => react-redux-toastr-tests.ts} (100%) diff --git a/react-redux-toastr/library-tests.ts b/react-redux-toastr/react-redux-toastr-tests.ts similarity index 100% rename from react-redux-toastr/library-tests.ts rename to react-redux-toastr/react-redux-toastr-tests.ts From 18780a108d295a2a41ab690bc5747c33d9131931 Mon Sep 17 00:00:00 2001 From: Aleksandar Ivanov Date: Tue, 20 Sep 2016 12:47:05 +0300 Subject: [PATCH 06/11] Create react-redux-toastr.d.ts --- react-redux-toastr/react-redux-toastr.d.ts | 108 +++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 react-redux-toastr/react-redux-toastr.d.ts 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..b10d430065 --- /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 https://github.com/Smiche +// 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) => any + } + + /** + * 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; +} From e6e922c65ae7c97eee8adcb36acd1e9bcaae189d Mon Sep 17 00:00:00 2001 From: Aleksandar Ivanov Date: Tue, 20 Sep 2016 12:55:37 +0300 Subject: [PATCH 07/11] Update react-redux-toastr-tests.ts --- .../react-redux-toastr-tests.ts | 25 +------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/react-redux-toastr/react-redux-toastr-tests.ts b/react-redux-toastr/react-redux-toastr-tests.ts index 3abfc668d4..bd0426face 100644 --- a/react-redux-toastr/react-redux-toastr-tests.ts +++ b/react-redux-toastr/react-redux-toastr-tests.ts @@ -1,6 +1,6 @@ /// /// -/// +/// /// import {toastr, reducer as toastrReducer, actions} from 'react-redux-toastr'; import ReduxToastr from 'react-redux-toastr'; @@ -16,29 +16,6 @@ function test() { var providerFactory = React.createFactory(Provider); var root = providerFactory({ store: store }, element); - class Test extends React.Component{ - private toastr; - constructor() { - super() - this.toastr = bindActionCreators(actions, this.props.dispatch); - this.toastr.clean(); - this.toastr.success("hi"); - } - - } - - - var TestComponent = connect(mapStateToProps, mapDispatchToProps)(Test); - function mapDispatchToProps(dispatch) { - return { - actions: bindActionCreators(actions, dispatch) - }; - } - - function mapStateToProps(state) { - return {}; - } - function callback() { } toastr.clean(); From 42e0076772967425975dc40fcec076b7c06e1d9d Mon Sep 17 00:00:00 2001 From: Aleksandar Ivanov Date: Tue, 20 Sep 2016 12:58:24 +0300 Subject: [PATCH 08/11] Update react-redux-toastr.d.ts --- react-redux-toastr/react-redux-toastr.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/react-redux-toastr/react-redux-toastr.d.ts b/react-redux-toastr/react-redux-toastr.d.ts index b10d430065..cef006ab20 100644 --- a/react-redux-toastr/react-redux-toastr.d.ts +++ b/react-redux-toastr/react-redux-toastr.d.ts @@ -1,6 +1,6 @@ // Type definitions for react-redux-toastr 3.7.0 // Project: https://github.com/diegoddox/react-redux-toastr -// Definitions by: Aleksandar Ivanov https://github.com/Smiche +// Definitions by: Aleksandar Ivanov // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /// From be207d84a7df0bd0e3047fd60e447996ab707b04 Mon Sep 17 00:00:00 2001 From: Aleksandar Ivanov Date: Tue, 20 Sep 2016 18:03:49 +0300 Subject: [PATCH 09/11] Update react-redux-toastr.d.ts --- react-redux-toastr/react-redux-toastr.d.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/react-redux-toastr/react-redux-toastr.d.ts b/react-redux-toastr/react-redux-toastr.d.ts index cef006ab20..380dd3ad61 100644 --- a/react-redux-toastr/react-redux-toastr.d.ts +++ b/react-redux-toastr/react-redux-toastr.d.ts @@ -48,13 +48,13 @@ declare module "react-redux-toastr" { removeOnHover?: boolean, removeOnClick?: boolean, component?: R.Component, - onShowComplete?: () => void, - onHideComplete?: () => void + onShowComplete?: (): void; + onHideComplete?: (): void; } interface ToastrConfirmOptions { - onOk: () => void, - onCancel: () => void + onOk: (): void; + onCancel: (): void; } interface ToastrEmitter { @@ -62,19 +62,19 @@ declare module "react-redux-toastr" { * 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, + 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, + clean: (): void; /** * Hook confirmation toastr with callback. */ - confirm: (message: string, options: ToastrConfirmOptions) => any + confirm: (message: string, options: ToastrConfirmOptions): void; } /** From f11138f44326f40a9c676758ef2bf0164fa94a41 Mon Sep 17 00:00:00 2001 From: Aleksandar Ivanov Date: Tue, 20 Sep 2016 18:15:54 +0300 Subject: [PATCH 10/11] Update react-redux-toastr.d.ts --- react-redux-toastr/react-redux-toastr.d.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/react-redux-toastr/react-redux-toastr.d.ts b/react-redux-toastr/react-redux-toastr.d.ts index 380dd3ad61..21c72e093a 100644 --- a/react-redux-toastr/react-redux-toastr.d.ts +++ b/react-redux-toastr/react-redux-toastr.d.ts @@ -48,8 +48,8 @@ declare module "react-redux-toastr" { removeOnHover?: boolean, removeOnClick?: boolean, component?: R.Component, - onShowComplete?: (): void; - onHideComplete?: (): void; + onShowComplete?(): void; + onHideComplete?(): void; } interface ToastrConfirmOptions { @@ -62,19 +62,19 @@ declare module "react-redux-toastr" { * 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; + 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; + clean(): void; /** * Hook confirmation toastr with callback. */ - confirm: (message: string, options: ToastrConfirmOptions): void; + confirm(message: string, options: ToastrConfirmOptions): void; } /** From 41e5e3d1782f6ded0a0bfdc22f2032550c966ca3 Mon Sep 17 00:00:00 2001 From: Aleksandar Ivanov Date: Tue, 20 Sep 2016 18:16:27 +0300 Subject: [PATCH 11/11] Update react-redux-toastr.d.ts --- react-redux-toastr/react-redux-toastr.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/react-redux-toastr/react-redux-toastr.d.ts b/react-redux-toastr/react-redux-toastr.d.ts index 21c72e093a..1b628455aa 100644 --- a/react-redux-toastr/react-redux-toastr.d.ts +++ b/react-redux-toastr/react-redux-toastr.d.ts @@ -53,8 +53,8 @@ declare module "react-redux-toastr" { } interface ToastrConfirmOptions { - onOk: (): void; - onCancel: (): void; + onOk(): void; + onCancel(): void; } interface ToastrEmitter {