@notificationapi/react 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -0
- package/dist/api.d.ts +1 -0
- package/dist/components/Notifications/Inbox.d.ts +17 -0
- package/dist/components/Notifications/InboxHeader.d.ts +3 -0
- package/dist/components/Notifications/Notification.d.ts +10 -0
- package/dist/components/Notifications/NotificationCounter.d.ts +7 -0
- package/dist/components/Notifications/NotificationFeed.d.ts +14 -0
- package/dist/components/Notifications/NotificationLauncher.d.ts +15 -0
- package/dist/components/Notifications/NotificationPopup.d.ts +24 -0
- package/dist/components/Notifications/UnreadBadge.d.ts +18 -0
- package/dist/components/Notifications/index.d.ts +4 -0
- package/dist/components/Preferences/NotificationPreferencesInline.d.ts +2 -0
- package/dist/components/Preferences/NotificationPreferencesPopup.d.ts +6 -0
- package/dist/components/Preferences/PreferenceGroup.d.ts +7 -0
- package/dist/components/Preferences/Preferences.d.ts +5 -0
- package/dist/components/Preferences/index.d.ts +2 -0
- package/dist/components/Provider/index.d.ts +130 -0
- package/dist/main.d.ts +3 -0
- package/dist/react.js +49573 -0
- package/package.json +47 -0
package/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# React + TypeScript + Vite
|
|
2
|
+
|
|
3
|
+
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
|
4
|
+
|
|
5
|
+
Currently, two official plugins are available:
|
|
6
|
+
|
|
7
|
+
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
|
|
8
|
+
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
|
9
|
+
|
|
10
|
+
## Expanding the ESLint configuration
|
|
11
|
+
|
|
12
|
+
If you are developing a production application, we recommend updating the configuration to enable type aware lint rules:
|
|
13
|
+
|
|
14
|
+
- Configure the top-level `parserOptions` property like this:
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
export default {
|
|
18
|
+
// other rules...
|
|
19
|
+
parserOptions: {
|
|
20
|
+
ecmaVersion: 'latest',
|
|
21
|
+
sourceType: 'module',
|
|
22
|
+
project: ['./tsconfig.json', './tsconfig.node.json'],
|
|
23
|
+
tsconfigRootDir: __dirname,
|
|
24
|
+
},
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
- Replace `plugin:@typescript-eslint/recommended` to `plugin:@typescript-eslint/recommended-type-checked` or `plugin:@typescript-eslint/strict-type-checked`
|
|
29
|
+
- Optionally add `plugin:@typescript-eslint/stylistic-type-checked`
|
|
30
|
+
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and add `plugin:react/recommended` & `plugin:react/jsx-runtime` to the `extends` list
|
package/dist/api.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const api: (endpoint: string, method: "GET" | "POST" | "PATCH", resource: string, clientId: string, userId: string, hashedUserId?: string, data?: any) => Promise<any>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ImageShape } from './Notification';
|
|
2
|
+
import { NotificationPopupProps } from './NotificationPopup';
|
|
3
|
+
|
|
4
|
+
export declare enum Pagination {
|
|
5
|
+
INFINITE_SCROLL = "infinite_scroll",
|
|
6
|
+
PAGINATED = "paginated"
|
|
7
|
+
}
|
|
8
|
+
type InboxProps = {
|
|
9
|
+
pagination: keyof typeof Pagination;
|
|
10
|
+
maxHeight: number;
|
|
11
|
+
filter: NotificationPopupProps["filter"];
|
|
12
|
+
imageShape: keyof typeof ImageShape;
|
|
13
|
+
pageSize: number;
|
|
14
|
+
pagePosition: NotificationPopupProps["pagePosition"];
|
|
15
|
+
};
|
|
16
|
+
export declare const Inbox: React.FC<InboxProps>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare enum ImageShape {
|
|
2
|
+
square = "square",
|
|
3
|
+
circle = "circle"
|
|
4
|
+
}
|
|
5
|
+
export declare const Notification: (props: {
|
|
6
|
+
notification: any;
|
|
7
|
+
markAsArchived: (ids: string[] | "ALL") => void;
|
|
8
|
+
markAsClicked: (id: string) => void;
|
|
9
|
+
imageShape: keyof typeof ImageShape;
|
|
10
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { UnreadBadgeProps } from './UnreadBadge';
|
|
3
|
+
|
|
4
|
+
export type NotificationCounterProps = Omit<UnreadBadgeProps, "count"> & {
|
|
5
|
+
counting?: UnreadBadgeProps["count"];
|
|
6
|
+
};
|
|
7
|
+
export declare const NotificationCounter: React.FC<PropsWithChildren<NotificationCounterProps>>;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Pagination } from './Inbox';
|
|
2
|
+
import { ImageShape } from './Notification';
|
|
3
|
+
import { Filter } from './NotificationPopup';
|
|
4
|
+
|
|
5
|
+
export type NotificationFeedProps = {
|
|
6
|
+
imageShape?: keyof typeof ImageShape;
|
|
7
|
+
pagination?: keyof typeof Pagination;
|
|
8
|
+
pageSize?: number;
|
|
9
|
+
pagePosition?: "top" | "bottom";
|
|
10
|
+
infiniteScrollHeight?: number;
|
|
11
|
+
style?: React.CSSProperties;
|
|
12
|
+
filter?: keyof typeof Filter | ((n: any) => boolean);
|
|
13
|
+
};
|
|
14
|
+
export declare const NotificationFeed: React.FC<NotificationFeedProps>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { NotificationPopupProps } from './NotificationPopup';
|
|
2
|
+
|
|
3
|
+
export declare enum Position {
|
|
4
|
+
TOP_LEFT = "top-left",
|
|
5
|
+
TOP_RIGHT = "top-right",
|
|
6
|
+
BOTTOM_LEFT = "bottom-left",
|
|
7
|
+
BOTTOM_RIGHT = "bottom-right"
|
|
8
|
+
}
|
|
9
|
+
type NotificationLaucherProps = NotificationPopupProps & {
|
|
10
|
+
position?: keyof typeof Position;
|
|
11
|
+
offsetX?: number | string;
|
|
12
|
+
offsetY?: number | string;
|
|
13
|
+
};
|
|
14
|
+
export declare const NotificationLauncher: React.FC<NotificationLaucherProps>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Pagination } from './Inbox';
|
|
2
|
+
import { UnreadBadgeProps } from './UnreadBadge';
|
|
3
|
+
import { ImageShape } from './Notification';
|
|
4
|
+
|
|
5
|
+
export declare enum Filter {
|
|
6
|
+
ALL = "ALL",
|
|
7
|
+
UNARCHIVED = "UNARCHIVED"
|
|
8
|
+
}
|
|
9
|
+
export type NotificationPopupProps = {
|
|
10
|
+
buttonIconSize?: number;
|
|
11
|
+
buttonWidth?: number;
|
|
12
|
+
buttonHeight?: number;
|
|
13
|
+
popupWidth?: number | string;
|
|
14
|
+
popupHeight?: number | string;
|
|
15
|
+
imageShape?: keyof typeof ImageShape;
|
|
16
|
+
pagination?: keyof typeof Pagination;
|
|
17
|
+
pageSize?: number;
|
|
18
|
+
pagePosition?: "top" | "bottom";
|
|
19
|
+
style?: React.CSSProperties;
|
|
20
|
+
unreadBadgeProps?: UnreadBadgeProps;
|
|
21
|
+
count?: UnreadBadgeProps["count"];
|
|
22
|
+
filter?: keyof typeof Filter | ((n: any) => boolean);
|
|
23
|
+
};
|
|
24
|
+
export declare const NotificationPopup: React.FC<NotificationPopupProps>;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { PropsWithChildren } from 'react';
|
|
2
|
+
import { NotificationPopupProps } from './NotificationPopup';
|
|
3
|
+
|
|
4
|
+
export type UnreadBadgeProps = {
|
|
5
|
+
color?: "blue" | "purple" | "cyan" | "green" | "magenta" | "pink" | "red" | "orange" | "yellow" | "volcano" | "geekblue" | "lime" | "gold" | undefined;
|
|
6
|
+
overflowCount?: number;
|
|
7
|
+
dot?: boolean;
|
|
8
|
+
showZero?: boolean;
|
|
9
|
+
size?: "default" | "small";
|
|
10
|
+
style?: React.CSSProperties;
|
|
11
|
+
count?: keyof typeof COUNT_TYPE | ((notification: any) => boolean);
|
|
12
|
+
filter?: NotificationPopupProps["filter"];
|
|
13
|
+
};
|
|
14
|
+
export declare enum COUNT_TYPE {
|
|
15
|
+
COUNT_UNOPENED_NOTIFICATIONS = "COUNT_UNOPENED_NOTIFICATIONS",
|
|
16
|
+
COUNT_UNARCHIVED_NOTIFICATIONS = "COUNT_UNARCHIVED_NOTIFICATIONS"
|
|
17
|
+
}
|
|
18
|
+
export declare const UnreadBadge: React.FunctionComponent<PropsWithChildren<UnreadBadgeProps>>;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Channels } from '../Provider';
|
|
2
|
+
|
|
3
|
+
export declare const getChannelLabel: (c: Channels) => string;
|
|
4
|
+
export declare const getChannelIcon: (channel: Channels) => React.ReactElement;
|
|
5
|
+
export declare function Preferences(): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { default as React, PropsWithChildren } from 'react';
|
|
2
|
+
|
|
3
|
+
type Props = {
|
|
4
|
+
clientId: string;
|
|
5
|
+
userId: string;
|
|
6
|
+
apiURL?: string;
|
|
7
|
+
wsURL?: string;
|
|
8
|
+
initialLoadMaxCount?: number;
|
|
9
|
+
initialLoadMaxAge?: Date;
|
|
10
|
+
};
|
|
11
|
+
export declare const NOTIFICATION_ACTIONS: {
|
|
12
|
+
opened: string;
|
|
13
|
+
clicked: string;
|
|
14
|
+
archived: string;
|
|
15
|
+
replied: string;
|
|
16
|
+
actioned1: string;
|
|
17
|
+
actioned2: string;
|
|
18
|
+
};
|
|
19
|
+
export declare enum Channels {
|
|
20
|
+
EMAIL = "EMAIL",
|
|
21
|
+
INAPP_WEB = "INAPP_WEB",
|
|
22
|
+
SMS = "SMS",
|
|
23
|
+
CALL = "CALL",
|
|
24
|
+
PUSH = "PUSH",
|
|
25
|
+
WEB_PUSH = "WEB_PUSH"
|
|
26
|
+
}
|
|
27
|
+
export declare enum DeliveryOptions {
|
|
28
|
+
OFF = "off",
|
|
29
|
+
INSTANT = "instant",
|
|
30
|
+
HOURLY = "hourly",
|
|
31
|
+
DAILY = "daily",
|
|
32
|
+
WEEKLY = "weekly",
|
|
33
|
+
MONTHLY = "monthly"
|
|
34
|
+
}
|
|
35
|
+
export interface Notification {
|
|
36
|
+
envId: string;
|
|
37
|
+
notificationId: string;
|
|
38
|
+
title: string;
|
|
39
|
+
channels: Channels[];
|
|
40
|
+
enabled: boolean;
|
|
41
|
+
deduplication?: {
|
|
42
|
+
duration: number;
|
|
43
|
+
};
|
|
44
|
+
throttling?: {
|
|
45
|
+
max: number;
|
|
46
|
+
period: number;
|
|
47
|
+
unit: "seconds" | "minutes" | "hours" | "days" | "months" | "years";
|
|
48
|
+
forever: boolean;
|
|
49
|
+
scope: ["userId", "notificationId"];
|
|
50
|
+
};
|
|
51
|
+
retention?: number;
|
|
52
|
+
options?: {
|
|
53
|
+
[key in Channels]?: {
|
|
54
|
+
defaultDeliveryOption: DeliveryOptions;
|
|
55
|
+
[DeliveryOptions.OFF]: {
|
|
56
|
+
enabled: boolean;
|
|
57
|
+
};
|
|
58
|
+
[DeliveryOptions.INSTANT]: {
|
|
59
|
+
enabled: boolean;
|
|
60
|
+
};
|
|
61
|
+
[DeliveryOptions.HOURLY]: {
|
|
62
|
+
enabled: boolean;
|
|
63
|
+
};
|
|
64
|
+
[DeliveryOptions.DAILY]: {
|
|
65
|
+
enabled: boolean;
|
|
66
|
+
hour: string;
|
|
67
|
+
};
|
|
68
|
+
[DeliveryOptions.WEEKLY]: {
|
|
69
|
+
enabled: boolean;
|
|
70
|
+
hour: string;
|
|
71
|
+
day: string;
|
|
72
|
+
};
|
|
73
|
+
[DeliveryOptions.MONTHLY]: {
|
|
74
|
+
enabled: boolean;
|
|
75
|
+
hour: string;
|
|
76
|
+
date: "first" | "last";
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
export interface InappNotification {
|
|
82
|
+
id: string;
|
|
83
|
+
seen: boolean;
|
|
84
|
+
title: string;
|
|
85
|
+
redirectURL?: string;
|
|
86
|
+
imageURL?: string;
|
|
87
|
+
date: Date;
|
|
88
|
+
parameters?: Record<string, unknown>;
|
|
89
|
+
expDate?: Date;
|
|
90
|
+
opened?: string;
|
|
91
|
+
clicked?: string;
|
|
92
|
+
archived?: string;
|
|
93
|
+
actioned1?: string;
|
|
94
|
+
actioned2?: string;
|
|
95
|
+
replies?: {
|
|
96
|
+
date: string;
|
|
97
|
+
message: string;
|
|
98
|
+
}[];
|
|
99
|
+
}
|
|
100
|
+
export interface Preferences {
|
|
101
|
+
preferences: {
|
|
102
|
+
notificationId: string;
|
|
103
|
+
channel: Channels;
|
|
104
|
+
delivery: DeliveryOptions;
|
|
105
|
+
subNotificationId?: string;
|
|
106
|
+
}[];
|
|
107
|
+
notifications: {
|
|
108
|
+
notificationId: string;
|
|
109
|
+
title: string;
|
|
110
|
+
channels: Channels[];
|
|
111
|
+
options: Notification["options"];
|
|
112
|
+
}[];
|
|
113
|
+
subNotifications: {
|
|
114
|
+
notificationId: string;
|
|
115
|
+
subNotificationId: string;
|
|
116
|
+
title: string;
|
|
117
|
+
}[];
|
|
118
|
+
}
|
|
119
|
+
export type Context = {
|
|
120
|
+
notifications?: InappNotification[];
|
|
121
|
+
preferences?: Preferences;
|
|
122
|
+
loadNotifications: (initial?: boolean) => void;
|
|
123
|
+
markAsOpened: () => void;
|
|
124
|
+
markAsArchived: (ids: string[] | "ALL") => void;
|
|
125
|
+
markAsClicked: (id: string) => void;
|
|
126
|
+
updateDelivery: (notificationId: string, channel: Channels, delivery: DeliveryOptions, subNotificationId?: string) => void;
|
|
127
|
+
};
|
|
128
|
+
export declare const NotificationAPIContext: React.Context<Context | undefined>;
|
|
129
|
+
export declare const NotificatinAPIProvider: React.FunctionComponent<PropsWithChildren<Props>>;
|
|
130
|
+
export {};
|
package/dist/main.d.ts
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { NotificationFeed, NotificationPopup, NotificationLauncher, NotificationCounter, } from './components/Notifications';
|
|
2
|
+
export { NotificationPreferencesInline, NotificationPreferencesPopup, } from './components/Preferences';
|
|
3
|
+
export { NotificatinAPIProvider } from './components/Provider';
|