diff --git a/react-notification-system-redux/index.d.ts b/react-notification-system-redux/index.d.ts new file mode 100644 index 0000000000..da071f6142 --- /dev/null +++ b/react-notification-system-redux/index.d.ts @@ -0,0 +1,39 @@ +// Type definitions for react-notification-system-redux 1.0 +// Project: https://github.com/gor181/react-notification-system-redux +// Definitions by: Karol Janyst +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import { Component } from "react"; +import { Action } from "redux"; +import { Attributes, Notification } from "react-notification-system"; + +export as namespace Notifications; + +export = Notifications; + +declare class Notifications extends Component {} + +declare namespace Notifications { + + export type NotificationsState = Notification[]; + + export type NotificationLevel = "error" | "warning" | "info" | "success"; + + export type NotificationsReducer = (state: NotificationsState, action: A) => NotificationsState; + + export type NotificationShow = (opts?: Notification) => Action; + + export interface NotificationsProps extends Attributes { + notifications?: Notification[]; + } + + export const reducer: NotificationsReducer; + + export const show: (opts?: Notification, level?: NotificationLevel) => Action; + export const error: NotificationShow; + export const hide: (opts?: Notification | string | number) => Action; + export const info: NotificationShow; + export const success: NotificationShow; + export const warning: NotificationShow; +} + diff --git a/react-notification-system-redux/package.json b/react-notification-system-redux/package.json new file mode 100644 index 0000000000..e52256ea90 --- /dev/null +++ b/react-notification-system-redux/package.json @@ -0,0 +1,5 @@ +{ + "dependencies": { + "redux": "^3.6.0" + } +} \ No newline at end of file diff --git a/react-notification-system-redux/react-notification-system-redux-tests.tsx b/react-notification-system-redux/react-notification-system-redux-tests.tsx new file mode 100644 index 0000000000..030d7a06b7 --- /dev/null +++ b/react-notification-system-redux/react-notification-system-redux-tests.tsx @@ -0,0 +1,33 @@ +import * as React from "react"; +import { createStore, Store } from "redux"; +import { Notification } from "react-notification-system"; +import * as Notifications from "react-notification-system-redux"; +import { reducer, show, hide, info, error, warning, success, NotificationLevel } from "react-notification-system-redux"; + +class Test extends React.Component { + + private test () { + const notification: Notification = { + message : "Test" + }; + info(notification); + error(notification); + warning(notification); + success(notification); + show(notification, "info"); + show(notification, "error"); + show(notification, "warning"); + show(notification, "success"); + hide(notification); + hide("uid"); + hide(123); + } + + public render () { + const notifications: Notification[] = []; + return (); + } + +} + +const store: Store = createStore(reducer) diff --git a/react-notification-system-redux/tsconfig.json b/react-notification-system-redux/tsconfig.json new file mode 100644 index 0000000000..a57c172ff2 --- /dev/null +++ b/react-notification-system-redux/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true, + "jsx": "react" + }, + "files": [ + "index.d.ts", + "react-notification-system-redux-tests.tsx" + ] +} diff --git a/react-notification-system-redux/tslint.json b/react-notification-system-redux/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/react-notification-system-redux/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" }