@notificationapi/react 0.0.37 → 1.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.
Files changed (72) hide show
  1. package/dist/assets/Badge.js +456 -0
  2. package/dist/assets/Box.js +57 -0
  3. package/dist/assets/ButtonBase.js +1224 -0
  4. package/dist/assets/DefaultPropsProvider.js +4368 -0
  5. package/dist/assets/Divider.js +343 -0
  6. package/dist/assets/IconButton.js +225 -0
  7. package/dist/assets/Inbox.js +3051 -0
  8. package/dist/assets/InboxHeader.js +2338 -0
  9. package/dist/assets/Notification.js +5349 -7150
  10. package/dist/assets/NotificationPreferencesPopup.js +1694 -0
  11. package/dist/assets/Paper.js +154 -0
  12. package/dist/assets/Popover.js +451 -0
  13. package/dist/assets/Portal.js +110 -0
  14. package/dist/assets/PreferenceInput.js +1545 -1366
  15. package/dist/assets/Typography.js +292 -0
  16. package/dist/assets/WebPushOptInMessage.js +794 -407
  17. package/dist/assets/channelUtils.js +33 -65
  18. package/dist/assets/createSimplePaletteValueFilter.js +17 -0
  19. package/dist/assets/createSvgIcon.js +248 -0
  20. package/dist/assets/integerPropType.js +31 -0
  21. package/dist/assets/resolveComponentProps.js +93 -0
  22. package/dist/assets/style.css +1 -0
  23. package/dist/assets/useSlotProps.js +24 -0
  24. package/dist/assets/useTheme.js +10 -0
  25. package/dist/assets/useTheme2.js +16 -0
  26. package/dist/assets/utils.js +743 -0
  27. package/dist/components/Notifications/DefaultEmpty.d.ts +3 -0
  28. package/dist/components/Notifications/DefaultEmpty.js +7 -0
  29. package/dist/components/Notifications/Inbox.d.ts +4 -4
  30. package/dist/components/Notifications/Inbox.js +9 -6450
  31. package/dist/components/Notifications/InboxHeader.d.ts +1 -1
  32. package/dist/components/Notifications/InboxHeader.js +7 -53
  33. package/dist/components/Notifications/Notification.d.ts +3 -4
  34. package/dist/components/Notifications/Notification.js +6 -5
  35. package/dist/components/Notifications/NotificationCounter.js +16 -6
  36. package/dist/components/Notifications/NotificationFeed.d.ts +1 -2
  37. package/dist/components/Notifications/NotificationFeed.js +41 -38
  38. package/dist/components/Notifications/NotificationLauncher.d.ts +1 -0
  39. package/dist/components/Notifications/NotificationLauncher.js +100 -114
  40. package/dist/components/Notifications/NotificationPopup.d.ts +3 -4
  41. package/dist/components/Notifications/NotificationPopup.js +86 -88
  42. package/dist/components/Notifications/UnreadBadge.d.ts +7 -4
  43. package/dist/components/Notifications/UnreadBadge.js +28 -20
  44. package/dist/components/Notifications/interface.d.ts +0 -4
  45. package/dist/components/Notifications/interface.js +4 -5
  46. package/dist/components/Preferences/NotificationPreferencesInline.js +14 -14
  47. package/dist/components/Preferences/NotificationPreferencesPopup.js +7 -2068
  48. package/dist/components/Preferences/PreferenceInput.js +4 -3
  49. package/dist/components/Preferences/Preferences.js +1042 -547
  50. package/dist/components/Preferences/channelUtils.js +3 -4
  51. package/dist/components/Preferences/index.js +1 -1
  52. package/dist/components/Provider/context.d.ts +27 -0
  53. package/dist/components/Provider/context.js +7 -0
  54. package/dist/components/Provider/index.d.ts +2 -25
  55. package/dist/components/Provider/index.js +22 -24
  56. package/dist/components/WebPush/WebPushOptInMessage.js +3 -4
  57. package/dist/main.d.ts +1 -0
  58. package/dist/main.js +4 -4
  59. package/package.json +14 -12
  60. package/dist/assets/AntdIcon.js +0 -200
  61. package/dist/assets/CloseOutlined.js +0 -13
  62. package/dist/assets/PurePanel.js +0 -59
  63. package/dist/assets/RightOutlined.js +0 -13
  64. package/dist/assets/button.js +0 -1660
  65. package/dist/assets/colors.js +0 -36
  66. package/dist/assets/compact-item.js +0 -860
  67. package/dist/assets/index.js +0 -271
  68. package/dist/assets/index2.js +0 -647
  69. package/dist/assets/index3.js +0 -7527
  70. package/dist/assets/pickAttrs.js +0 -42
  71. package/dist/assets/presets.js +0 -810
  72. package/dist/assets/reactNode.js +0 -20821
@@ -1,36 +1,38 @@
1
- import { jsx as i, jsxs as o, Fragment as l } from "react/jsx-runtime";
2
- import { Inbox as f } from "./Inbox.js";
3
- import { UnreadBadge as m } from "./UnreadBadge.js";
4
- import { NotificationAPIContext as p } from "../Provider/index.js";
5
- import { useState as b, useContext as s } from "react";
6
- import { NotificationPreferencesPopup as I } from "../Preferences/NotificationPreferencesPopup.js";
7
- import { D as P } from "../../assets/PreferenceInput.js";
8
- import { W as S } from "../../assets/WebPushOptInMessage.js";
1
+ import { jsx as n, jsxs as r, Fragment as m } from "react/jsx-runtime";
2
+ import { useState as p, useContext as I } from "react";
3
+ import { I as P } from "../../assets/Inbox.js";
4
+ import { UnreadBadge as b } from "./UnreadBadge.js";
5
+ import { NotificationAPIContext as C } from "../Provider/context.js";
6
+ import { N as S } from "../../assets/NotificationPreferencesPopup.js";
9
7
  import { Filter as x } from "./interface.js";
10
- import { R as C } from "../../assets/channelUtils.js";
11
- import { P as W } from "../../assets/index.js";
12
- import { B as O } from "../../assets/button.js";
13
- const T = (e) => {
14
- var a, d, c, u;
15
- const [h, r] = b(!1), n = s(p);
16
- if (!n)
8
+ import { W as N } from "../../assets/WebPushOptInMessage.js";
9
+ import { N as O } from "../../assets/channelUtils.js";
10
+ import { I as y } from "../../assets/IconButton.js";
11
+ import { P as k } from "../../assets/Popover.js";
12
+ import { D as z } from "../../assets/Divider.js";
13
+ const R = (e) => {
14
+ var d, c, u, s;
15
+ const [f, a] = p(!1), [i, l] = p(null), o = I(C);
16
+ if (!o)
17
17
  return null;
18
18
  const t = {
19
- buttonIcon: e.buttonIcon || /* @__PURE__ */ i(
20
- C,
19
+ buttonIcon: e.buttonIcon || /* @__PURE__ */ n(
20
+ O,
21
21
  {
22
22
  style: {
23
- fontSize: e.buttonIconSize || (e.buttonWidth ? e.buttonWidth / 2 : 20),
23
+ fontSize: e.buttonIconSize || 20,
24
24
  color: e.iconColor || "#000000"
25
25
  }
26
26
  }
27
27
  ),
28
- buttonWidth: e.buttonWidth || 40,
29
- buttonHeight: e.buttonHeight || 40,
28
+ buttonStyles: {
29
+ width: 40,
30
+ height: 40,
31
+ ...e.buttonStyles
32
+ },
30
33
  popupWidth: e.popupWidth || 400,
31
34
  popupHeight: e.popupHeight || 600,
32
- buttonIconSize: e.buttonIconSize || (e.buttonWidth ? e.buttonWidth / 2 : 20),
33
- imageShape: e.imageShape || "circle",
35
+ buttonIconSize: e.buttonIconSize || 20,
34
36
  iconColor: e.iconColor || "#000000",
35
37
  pagination: e.pagination || "INFINITE_SCROLL",
36
38
  pageSize: e.pageSize || 10,
@@ -40,91 +42,87 @@ const T = (e) => {
40
42
  count: e.count || "COUNT_UNOPENED_NOTIFICATIONS",
41
43
  filter: e.filter || x.ALL,
42
44
  header: {
43
- title: (a = e.header) == null ? void 0 : a.title,
44
- button1ClickHandler: ((d = e.header) == null ? void 0 : d.button1ClickHandler) ?? n.markAsArchived,
45
- button2ClickHandler: ((c = e.header) == null ? void 0 : c.button2ClickHandler) ?? (() => r(!0))
45
+ title: (d = e.header) == null ? void 0 : d.title,
46
+ button1ClickHandler: ((c = e.header) == null ? void 0 : c.button1ClickHandler) ?? o.markAsArchived,
47
+ button2ClickHandler: ((u = e.header) == null ? void 0 : u.button2ClickHandler) ?? (() => a(!0))
46
48
  },
47
49
  renderers: {
48
- notification: (u = e.renderers) == null ? void 0 : u.notification
50
+ notification: (s = e.renderers) == null ? void 0 : s.notification
49
51
  }
52
+ }, h = (g) => {
53
+ l(g.currentTarget), o.markAsOpened();
50
54
  };
51
- return /* @__PURE__ */ o(l, { children: [
52
- /* @__PURE__ */ i(
53
- W,
55
+ return /* @__PURE__ */ r(m, { children: [
56
+ /* @__PURE__ */ n(
57
+ "div",
54
58
  {
55
- autoAdjustOverflow: !0,
56
- trigger: "click",
57
- content: /* @__PURE__ */ o(l, { children: [
58
- /* @__PURE__ */ i(
59
- f,
60
- {
61
- maxHeight: t.popupHeight - 73,
62
- pagination: t.pagination,
63
- filter: t.filter,
64
- imageShape: t.imageShape,
65
- pageSize: t.pageSize,
66
- pagePosition: t.pagePosition,
67
- notificationRenderer: t.renderers.notification,
68
- header: t.header
69
- }
70
- ),
71
- n.webPushOptInMessage && localStorage.getItem("hideWebPushOptInMessage") !== "true" && /* @__PURE__ */ o("div", { children: [
72
- /* @__PURE__ */ i(P, { style: { margin: "10px 0" } }),
73
- /* @__PURE__ */ i(S, { hideAfterInteraction: !0 })
74
- ] })
75
- ] }),
76
- onOpenChange: (g) => {
77
- g && n.markAsOpened();
59
+ style: {
60
+ display: "inline-block"
78
61
  },
79
- arrow: !1,
80
- overlayStyle: {
81
- padding: "0 16px",
82
- width: t.popupWidth
62
+ children: /* @__PURE__ */ n(
63
+ b,
64
+ {
65
+ ...e.unreadBadgeProps,
66
+ count: t.count,
67
+ filter: t.filter,
68
+ children: /* @__PURE__ */ n(y, { onClick: h, style: t.buttonStyles, children: t.buttonIcon })
69
+ }
70
+ )
71
+ }
72
+ ),
73
+ /* @__PURE__ */ n(
74
+ k,
75
+ {
76
+ open: !!i,
77
+ onClose: () => l(null),
78
+ anchorEl: i,
79
+ slotProps: {
80
+ paper: {
81
+ style: {
82
+ borderRadius: 8
83
+ }
84
+ }
83
85
  },
84
- zIndex: e.popupZIndex,
85
- children: /* @__PURE__ */ i(
86
+ "aria-hidden": !i,
87
+ children: /* @__PURE__ */ r(
86
88
  "div",
87
89
  {
88
90
  style: {
89
- display: "inline-block"
91
+ width: t.popupWidth,
92
+ padding: "0 16px",
93
+ zIndex: e.popupZIndex
90
94
  },
91
- children: /* @__PURE__ */ i(
92
- m,
93
- {
94
- ...e.unreadBadgeProps,
95
- style: {
96
- top: 5,
97
- right: 5
98
- },
99
- count: t.count,
100
- filter: t.filter,
101
- children: /* @__PURE__ */ i(
102
- O,
103
- {
104
- icon: t.buttonIcon,
105
- style: {
106
- width: t.buttonWidth,
107
- height: t.buttonHeight
108
- },
109
- shape: "circle",
110
- type: "text"
111
- }
112
- )
113
- }
114
- )
95
+ children: [
96
+ /* @__PURE__ */ n(
97
+ P,
98
+ {
99
+ maxHeight: t.popupHeight - 73,
100
+ pagination: t.pagination,
101
+ filter: t.filter,
102
+ pageSize: t.pageSize,
103
+ pagePosition: t.pagePosition,
104
+ notificationRenderer: t.renderers.notification,
105
+ header: t.header
106
+ }
107
+ ),
108
+ o.webPushOptInMessage && localStorage.getItem("hideWebPushOptInMessage") !== "true" && /* @__PURE__ */ r("div", { children: [
109
+ /* @__PURE__ */ n(z, { style: { margin: "10px 0" } }),
110
+ /* @__PURE__ */ n(N, { hideAfterInteraction: !0 })
111
+ ] })
112
+ ]
115
113
  }
116
114
  )
117
115
  }
118
116
  ),
119
- /* @__PURE__ */ i(
120
- I,
117
+ /* @__PURE__ */ n(
118
+ S,
121
119
  {
122
- open: h,
123
- onClose: () => r(!1)
120
+ open: f,
121
+ onClose: () => a(!1)
124
122
  }
125
123
  )
126
124
  ] });
127
125
  };
128
126
  export {
129
- T as NotificationPopup
127
+ R as NotificationPopup
130
128
  };
@@ -4,13 +4,16 @@ import { InAppNotification } from '@notificationapi/core/dist/interfaces';
4
4
  import { COUNT_TYPE } from './interface';
5
5
 
6
6
  export type UnreadBadgeProps = {
7
- color?: 'blue' | 'purple' | 'cyan' | 'green' | 'magenta' | 'pink' | 'red' | 'orange' | 'yellow' | 'volcano' | 'geekblue' | 'lime' | 'gold' | undefined;
8
- overflowCount?: number;
9
7
  dot?: boolean;
10
8
  showZero?: boolean;
11
- size?: 'default' | 'small';
12
- style?: React.CSSProperties;
9
+ max?: number;
13
10
  count?: keyof typeof COUNT_TYPE | ((notification: InAppNotification) => boolean);
14
11
  filter?: NotificationPopupProps['filter'];
12
+ offset?: {
13
+ top?: number;
14
+ right?: number;
15
+ bottom?: number;
16
+ left?: number;
17
+ };
15
18
  };
16
19
  export declare const UnreadBadge: React.FunctionComponent<PropsWithChildren<UnreadBadgeProps>>;
@@ -1,27 +1,35 @@
1
- import { jsx as i } from "react/jsx-runtime";
2
- import { useContext as r } from "react";
3
- import { NotificationAPIContext as c } from "../Provider/index.js";
4
- import { B as l } from "../../assets/index2.js";
5
- const h = (e) => {
6
- const o = r(c);
7
- return /* @__PURE__ */ i(
8
- l,
1
+ import { jsx as l } from "react/jsx-runtime";
2
+ import { useContext as a } from "react";
3
+ import { NotificationAPIContext as d } from "../Provider/context.js";
4
+ import { B as u } from "../../assets/Badge.js";
5
+ const C = (t) => {
6
+ var r, i, c, f;
7
+ const o = a(d);
8
+ return /* @__PURE__ */ l(
9
+ u,
9
10
  {
10
- count: ((n) => e.count === "COUNT_UNOPENED_NOTIFICATIONS" || e.count === void 0 ? n.filter((t) => !t.opened && !t.seen).length : e.count === "COUNT_UNARCHIVED_NOTIFICATIONS" ? n.filter(
11
- (t) => !t.archived && !t.clicked && !t.replies && !t.actioned1 && !t.actioned2
12
- ).length : n.filter(e.count).length)((o == null ? void 0 : o.notifications) || []),
13
- color: e.color,
14
- overflowCount: e.overflowCount,
15
- dot: e.dot,
16
- showZero: e.showZero,
17
- size: e.size,
18
- style: {
19
- ...e.style
11
+ overlap: "circular",
12
+ badgeContent: ((n) => t.count === "COUNT_UNOPENED_NOTIFICATIONS" || t.count === void 0 ? n.filter((e) => !e.opened && !e.seen).length : t.count === "COUNT_UNARCHIVED_NOTIFICATIONS" ? n.filter(
13
+ (e) => !e.archived && !e.clicked && !e.replies && !e.actioned1 && !e.actioned2
14
+ ).length : n.filter(t.count).length)((o == null ? void 0 : o.notifications) || []),
15
+ max: t.max,
16
+ variant: t.dot ? "dot" : "standard",
17
+ showZero: t.showZero,
18
+ color: "error",
19
+ slotProps: {
20
+ badge: {
21
+ style: {
22
+ top: (r = t.offset) == null ? void 0 : r.top,
23
+ right: (i = t.offset) == null ? void 0 : i.right,
24
+ bottom: (c = t.offset) == null ? void 0 : c.bottom,
25
+ left: (f = t.offset) == null ? void 0 : f.left
26
+ }
27
+ }
20
28
  },
21
- children: e.children
29
+ children: t.children
22
30
  }
23
31
  );
24
32
  };
25
33
  export {
26
- h as UnreadBadge
34
+ C as UnreadBadge
27
35
  };
@@ -2,10 +2,6 @@ export declare enum Pagination {
2
2
  INFINITE_SCROLL = "infinite_scroll",
3
3
  PAGINATED = "paginated"
4
4
  }
5
- export declare enum ImageShape {
6
- square = "square",
7
- circle = "circle"
8
- }
9
5
  export declare enum Filter {
10
6
  ALL = "ALL",
11
7
  UNARCHIVED = "UNARCHIVED"
@@ -1,4 +1,4 @@
1
- var N = /* @__PURE__ */ ((I) => (I.INFINITE_SCROLL = "infinite_scroll", I.PAGINATED = "paginated", I))(N || {}), r = /* @__PURE__ */ ((I) => (I.square = "square", I.circle = "circle", I))(r || {}), T = /* @__PURE__ */ ((I) => (I.ALL = "ALL", I.UNARCHIVED = "UNARCHIVED", I))(T || {}), A = /* @__PURE__ */ ((I) => (I.EMAIL = "EMAIL", I.INAPP_WEB = "INAPP_WEB", I.SMS = "SMS", I.CALL = "CALL", I.PUSH = "PUSH", I.WEB_PUSH = "WEB_PUSH", I))(A || {}), O = /* @__PURE__ */ ((I) => (I.OFF = "off", I.INSTANT = "instant", I.HOURLY = "hourly", I.DAILY = "daily", I.WEEKLY = "weekly", I.MONTHLY = "monthly", I))(O || {}), E = /* @__PURE__ */ ((I) => (I.COUNT_UNOPENED_NOTIFICATIONS = "COUNT_UNOPENED_NOTIFICATIONS", I.COUNT_UNARCHIVED_NOTIFICATIONS = "COUNT_UNARCHIVED_NOTIFICATIONS", I))(E || {}), t = /* @__PURE__ */ ((I) => (I.TOP_LEFT = "top-left", I.TOP_RIGHT = "top-right", I.BOTTOM_LEFT = "bottom-left", I.BOTTOM_RIGHT = "bottom-right", I))(t || {});
1
+ var N = /* @__PURE__ */ ((I) => (I.INFINITE_SCROLL = "infinite_scroll", I.PAGINATED = "paginated", I))(N || {}), T = /* @__PURE__ */ ((I) => (I.ALL = "ALL", I.UNARCHIVED = "UNARCHIVED", I))(T || {}), A = /* @__PURE__ */ ((I) => (I.EMAIL = "EMAIL", I.INAPP_WEB = "INAPP_WEB", I.SMS = "SMS", I.CALL = "CALL", I.PUSH = "PUSH", I.WEB_PUSH = "WEB_PUSH", I))(A || {}), r = /* @__PURE__ */ ((I) => (I.OFF = "off", I.INSTANT = "instant", I.HOURLY = "hourly", I.DAILY = "daily", I.WEEKLY = "weekly", I.MONTHLY = "monthly", I))(r || {}), O = /* @__PURE__ */ ((I) => (I.COUNT_UNOPENED_NOTIFICATIONS = "COUNT_UNOPENED_NOTIFICATIONS", I.COUNT_UNARCHIVED_NOTIFICATIONS = "COUNT_UNARCHIVED_NOTIFICATIONS", I))(O || {}), E = /* @__PURE__ */ ((I) => (I.TOP_LEFT = "top-left", I.TOP_RIGHT = "top-right", I.BOTTOM_LEFT = "bottom-left", I.BOTTOM_RIGHT = "bottom-right", I))(E || {});
2
2
  const L = {
3
3
  opened: "opened",
4
4
  clicked: "clicked",
@@ -8,12 +8,11 @@ const L = {
8
8
  actioned2: "actioned2"
9
9
  };
10
10
  export {
11
- E as COUNT_TYPE,
11
+ O as COUNT_TYPE,
12
12
  A as Channels,
13
- O as DeliveryOptions,
13
+ r as DeliveryOptions,
14
14
  T as Filter,
15
- r as ImageShape,
16
15
  L as NOTIFICATION_ACTIONS,
17
16
  N as Pagination,
18
- t as Position
17
+ E as Position
19
18
  };
@@ -1,18 +1,18 @@
1
- import { jsxs as n, Fragment as r, jsx as t } from "react/jsx-runtime";
2
- import { Preferences as i } from "./Preferences.js";
3
- import { W as o } from "../../assets/WebPushOptInMessage.js";
4
- import { useContext as s } from "react";
5
- import { NotificationAPIContext as f } from "../Provider/index.js";
6
- import { D as a } from "../../assets/PreferenceInput.js";
7
- function I(m) {
8
- const e = s(f);
9
- return e ? /* @__PURE__ */ n(r, { children: [
10
- /* @__PURE__ */ t(i, {}),
1
+ import { jsxs as r, jsx as t } from "react/jsx-runtime";
2
+ import { useContext as i } from "react";
3
+ import { Preferences as n } from "./Preferences.js";
4
+ import { NotificationAPIContext as o } from "../Provider/context.js";
5
+ import { W as s } from "../../assets/WebPushOptInMessage.js";
6
+ import { D as f } from "../../assets/Divider.js";
7
+ function u(l) {
8
+ const e = i(o);
9
+ return e ? /* @__PURE__ */ r("div", { style: { borderRadius: 8, border: "1px solid #dcdcdc" }, children: [
10
+ /* @__PURE__ */ t(n, {}),
11
11
  " ",
12
- e.webPushOptInMessage && /* @__PURE__ */ n("div", { children: [
13
- /* @__PURE__ */ t(a, { style: { margin: "10px 0" } }),
12
+ e.webPushOptInMessage && /* @__PURE__ */ r("div", { children: [
13
+ /* @__PURE__ */ t(f, { style: { margin: "10px 0" } }),
14
14
  /* @__PURE__ */ t(
15
- o,
15
+ s,
16
16
  {
17
17
  hideAfterInteraction: !1,
18
18
  descriptionStyle: {
@@ -38,5 +38,5 @@ function I(m) {
38
38
  ] }) : null;
39
39
  }
40
40
  export {
41
- I as NotificationPreferencesInline
41
+ u as NotificationPreferencesInline
42
42
  };