@notificationapi/react 1.0.1 → 1.0.3

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.
@@ -5895,7 +5895,8 @@ const kc = di.div`
5895
5895
  style: {
5896
5896
  marginRight: 8,
5897
5897
  marginLeft: 12
5898
- }
5898
+ },
5899
+ variant: t.imageShape === "circle" ? "circular" : "rounded"
5899
5900
  }
5900
5901
  ) }),
5901
5902
  /* @__PURE__ */ ut(
@@ -12,5 +12,6 @@ export type InboxProps = {
12
12
  notificationRenderer: ((notification: InAppNotification[]) => React.ReactNode) | undefined;
13
13
  header?: InboxHeaderProps;
14
14
  empty?: React.ReactNode;
15
+ imageShape?: 'circle' | 'square';
15
16
  };
16
17
  export declare const Inbox: React.FC<InboxProps>;
@@ -6,5 +6,6 @@ export type NotificationProps = {
6
6
  markAsArchived: (ids: string[] | 'ALL') => void;
7
7
  markAsClicked: (ids: string[]) => void;
8
8
  renderer?: (notification: InAppNotification[]) => ReactNode;
9
+ imageShape?: 'circle' | 'square';
9
10
  };
10
11
  export declare const Notification: (props: NotificationProps) => import("react/jsx-runtime").JSX.Element;
@@ -14,5 +14,6 @@ export type NotificationFeedProps = {
14
14
  notification?: NotificationProps['renderer'];
15
15
  };
16
16
  header?: InboxHeaderProps;
17
+ imageShape?: 'circle' | 'square';
17
18
  };
18
19
  export declare const NotificationFeed: React.FC<NotificationFeedProps>;
@@ -1,5 +1,5 @@
1
1
  import { jsx as n, jsxs as l } from "react/jsx-runtime";
2
- import { useState as g, useContext as m, useEffect as h } from "react";
2
+ import { useState as d, useContext as m, useEffect as h } from "react";
3
3
  import { I as u } from "../../assets/Inbox.js";
4
4
  import { NotificationAPIContext as p } from "../Provider/context.js";
5
5
  import { N as x } from "../../assets/NotificationPreferencesPopup.js";
@@ -10,18 +10,18 @@ import { D as C } from "../../assets/Divider.js";
10
10
  const H = b(/* @__PURE__ */ n("path", {
11
11
  d: "M11.99 2C6.47 2 2 6.48 2 12s4.47 10 9.99 10C17.52 22 22 17.52 22 12S17.52 2 11.99 2m6.93 6h-2.95c-.32-1.25-.78-2.45-1.38-3.56 1.84.63 3.37 1.91 4.33 3.56M12 4.04c.83 1.2 1.48 2.53 1.91 3.96h-3.82c.43-1.43 1.08-2.76 1.91-3.96M4.26 14C4.1 13.36 4 12.69 4 12s.1-1.36.26-2h3.38c-.08.66-.14 1.32-.14 2s.06 1.34.14 2zm.82 2h2.95c.32 1.25.78 2.45 1.38 3.56-1.84-.63-3.37-1.9-4.33-3.56m2.95-8H5.08c.96-1.66 2.49-2.93 4.33-3.56C8.81 5.55 8.35 6.75 8.03 8M12 19.96c-.83-1.2-1.48-2.53-1.91-3.96h3.82c-.43 1.43-1.08 2.76-1.91 3.96M14.34 14H9.66c-.09-.66-.16-1.32-.16-2s.07-1.35.16-2h4.68c.09.65.16 1.32.16 2s-.07 1.34-.16 2m.25 5.56c.6-1.11 1.06-2.31 1.38-3.56h2.95c-.96 1.65-2.49 2.93-4.33 3.56M16.36 14c.08-.66.14-1.32.14-2s-.06-1.34-.14-2h3.38c.16.64.26 1.31.26 2s-.1 1.36-.26 2z"
12
12
  }), "Language"), N = (e) => {
13
- var o, a, c, s;
14
- const [f, r] = g(!1), t = m(p);
13
+ var a, o, c, s;
14
+ const [f, r] = d(!1), i = m(p);
15
15
  if (h(() => {
16
- if (!t) return;
17
- t.markAsOpened();
18
- const d = setInterval(() => {
19
- t.markAsOpened();
16
+ if (!i) return;
17
+ i.markAsOpened();
18
+ const g = setInterval(() => {
19
+ i.markAsOpened();
20
20
  }, 5e3);
21
- return () => clearInterval(d);
22
- }, [t]), !t)
21
+ return () => clearInterval(g);
22
+ }, [i]), !i)
23
23
  return null;
24
- const i = {
24
+ const t = {
25
25
  pagination: e.pagination || "INFINITE_SCROLL",
26
26
  pageSize: e.pageSize || 5,
27
27
  pagePosition: e.pagePosition || "top",
@@ -29,13 +29,14 @@ const H = b(/* @__PURE__ */ n("path", {
29
29
  filter: e.filter || S.ALL,
30
30
  infiniteScrollHeight: e.infiniteScrollHeight ? e.infiniteScrollHeight : window.innerHeight * 0.75,
31
31
  renderers: {
32
- notification: (o = e.renderers) == null ? void 0 : o.notification
32
+ notification: (a = e.renderers) == null ? void 0 : a.notification
33
33
  },
34
34
  header: {
35
- title: (a = e.header) == null ? void 0 : a.title,
36
- button1ClickHandler: ((c = e.header) == null ? void 0 : c.button1ClickHandler) ?? t.markAsArchived,
35
+ title: (o = e.header) == null ? void 0 : o.title,
36
+ button1ClickHandler: ((c = e.header) == null ? void 0 : c.button1ClickHandler) ?? i.markAsArchived,
37
37
  button2ClickHandler: ((s = e.header) == null ? void 0 : s.button2ClickHandler) ?? (() => r(!0))
38
- }
38
+ },
39
+ imageShape: e.imageShape || "circle"
39
40
  };
40
41
  return /* @__PURE__ */ l(
41
42
  "div",
@@ -52,16 +53,17 @@ const H = b(/* @__PURE__ */ n("path", {
52
53
  /* @__PURE__ */ n(
53
54
  u,
54
55
  {
55
- maxHeight: i.infiniteScrollHeight,
56
- pagination: i.pagination,
57
- filter: i.filter,
58
- pageSize: i.pageSize,
59
- pagePosition: i.pagePosition,
60
- notificationRenderer: i.renderers.notification,
61
- header: i.header
56
+ maxHeight: t.infiniteScrollHeight,
57
+ pagination: t.pagination,
58
+ filter: t.filter,
59
+ pageSize: t.pageSize,
60
+ pagePosition: t.pagePosition,
61
+ notificationRenderer: t.renderers.notification,
62
+ header: t.header,
63
+ imageShape: t.imageShape
62
64
  }
63
65
  ),
64
- t.webPushOptInMessage && localStorage.getItem("hideWebPushOptInMessage") !== "true" && /* @__PURE__ */ l("div", { children: [
66
+ i.webPushOptInMessage && localStorage.getItem("hideWebPushOptInMessage") !== "true" && /* @__PURE__ */ l("div", { children: [
65
67
  /* @__PURE__ */ n(C, { style: { margin: "10px 0" } }),
66
68
  /* @__PURE__ */ n(
67
69
  I,
@@ -1,22 +1,22 @@
1
1
  import { jsx as o, jsxs as a } from "react/jsx-runtime";
2
- import { useState as c, useContext as b } from "react";
3
- import { I as P } from "../../assets/Inbox.js";
4
- import { UnreadBadge as x } from "./UnreadBadge.js";
5
- import { NotificationAPIContext as C } from "../Provider/context.js";
6
- import { N as O } from "../../assets/NotificationPreferencesPopup.js";
7
- import { W as S, L as y } from "../../assets/WebPushOptInMessage.js";
8
- import { N } from "../../assets/channelUtils.js";
9
- import { I as z } from "../../assets/IconButton.js";
10
- import { P as k } from "../../assets/Popover.js";
11
- import { D as A } from "../../assets/Divider.js";
12
- const D = (e) => {
13
- var d, f, u, h;
14
- const [g, l] = c(!1), [i, s] = c(!1), n = b(C), [m, p] = c(null);
15
- if (!n)
2
+ import { useState as c, useContext as C } from "react";
3
+ import { I as S } from "../../assets/Inbox.js";
4
+ import { UnreadBadge as y } from "./UnreadBadge.js";
5
+ import { NotificationAPIContext as z } from "../Provider/context.js";
6
+ import { N } from "../../assets/NotificationPreferencesPopup.js";
7
+ import { W as k, L as v } from "../../assets/WebPushOptInMessage.js";
8
+ import { N as A } from "../../assets/channelUtils.js";
9
+ import { I as H } from "../../assets/IconButton.js";
10
+ import { P as L } from "../../assets/Popover.js";
11
+ import { D as T } from "../../assets/Divider.js";
12
+ const j = (e) => {
13
+ var d, f, u, h, g, p, m, I;
14
+ const [P, l] = c(!1), [n, s] = c(!1), i = C(z), [b, O] = c(null);
15
+ if (!i)
16
16
  return null;
17
17
  const t = {
18
18
  buttonIcon: e.buttonIcon || /* @__PURE__ */ o(
19
- N,
19
+ A,
20
20
  {
21
21
  style: {
22
22
  fontSize: e.buttonIconSize || 20,
@@ -45,14 +45,20 @@ const D = (e) => {
45
45
  filter: e.filter || "ALL",
46
46
  header: {
47
47
  title: (d = e.header) == null ? void 0 : d.title,
48
- button1ClickHandler: ((f = e.header) == null ? void 0 : f.button1ClickHandler) ?? n.markAsArchived,
48
+ button1ClickHandler: ((f = e.header) == null ? void 0 : f.button1ClickHandler) ?? i.markAsArchived,
49
49
  button2ClickHandler: ((u = e.header) == null ? void 0 : u.button2ClickHandler) ?? (() => l(!0))
50
50
  },
51
51
  renderers: {
52
52
  notification: (h = e.renderers) == null ? void 0 : h.notification
53
+ },
54
+ popoverPosition: {
55
+ anchorOrigin: {
56
+ vertical: ((p = (g = e.popoverPosition) == null ? void 0 : g.anchorOrigin) == null ? void 0 : p.vertical) ?? "top",
57
+ horizontal: ((I = (m = e.popoverPosition) == null ? void 0 : m.anchorOrigin) == null ? void 0 : I.horizontal) ?? "left"
58
+ }
53
59
  }
54
- }, I = (r) => {
55
- s(!i), p(r == null ? void 0 : r.currentTarget), i && n.markAsOpened();
60
+ }, x = (r) => {
61
+ s(!n), O(r == null ? void 0 : r.currentTarget), n && i.markAsOpened();
56
62
  };
57
63
  return /* @__PURE__ */ a(
58
64
  "div",
@@ -70,14 +76,14 @@ const D = (e) => {
70
76
  style: {
71
77
  display: "inline-block"
72
78
  },
73
- children: /* @__PURE__ */ o(x, { ...e.unreadBadgeProps, count: t.count, children: /* @__PURE__ */ o(z, { style: t.buttonStyles, onClick: I, children: t.buttonIcon }) })
79
+ children: /* @__PURE__ */ o(y, { ...e.unreadBadgeProps, count: t.count, children: /* @__PURE__ */ o(H, { style: t.buttonStyles, onClick: x, children: t.buttonIcon }) })
74
80
  }
75
81
  ),
76
82
  /* @__PURE__ */ a(
77
- k,
83
+ L,
78
84
  {
79
- open: i,
80
- anchorEl: m,
85
+ open: n,
86
+ anchorEl: b,
81
87
  anchorReference: "anchorEl",
82
88
  anchorOrigin: {
83
89
  horizontal: "center",
@@ -99,7 +105,7 @@ const D = (e) => {
99
105
  },
100
106
  children: [
101
107
  /* @__PURE__ */ o(
102
- P,
108
+ S,
103
109
  {
104
110
  maxHeight: 500,
105
111
  pagination: t.pagination,
@@ -110,13 +116,13 @@ const D = (e) => {
110
116
  header: t.header
111
117
  }
112
118
  ),
113
- n.webPushOptInMessage && localStorage.getItem("hideWebPushOptInMessage") !== "true" && /* @__PURE__ */ a("div", { children: [
114
- /* @__PURE__ */ o(A, { style: { margin: "10px 0" } }),
119
+ i.webPushOptInMessage && localStorage.getItem("hideWebPushOptInMessage") !== "true" && /* @__PURE__ */ a("div", { children: [
120
+ /* @__PURE__ */ o(T, { style: { margin: "10px 0" } }),
115
121
  /* @__PURE__ */ o(
116
- S,
122
+ k,
117
123
  {
118
124
  hideAfterInteraction: !0,
119
- icon: /* @__PURE__ */ o(y, { type: "text", style: { marginLeft: "9px" } }),
125
+ icon: /* @__PURE__ */ o(v, { type: "text", style: { marginLeft: "9px" } }),
120
126
  alertContainerStyle: { maxWidth: "345px" }
121
127
  }
122
128
  )
@@ -125,9 +131,9 @@ const D = (e) => {
125
131
  }
126
132
  ),
127
133
  /* @__PURE__ */ o(
128
- O,
134
+ N,
129
135
  {
130
- open: g,
136
+ open: P,
131
137
  onClose: () => l(!1)
132
138
  }
133
139
  )
@@ -136,5 +142,5 @@ const D = (e) => {
136
142
  );
137
143
  };
138
144
  export {
139
- D as NotificationLauncher
145
+ j as NotificationLauncher
140
146
  };
@@ -23,5 +23,11 @@ export type NotificationPopupProps = {
23
23
  notification?: NotificationProps['renderer'];
24
24
  };
25
25
  header?: InboxHeaderProps;
26
+ popoverPosition?: {
27
+ anchorOrigin?: {
28
+ vertical: 'top' | 'center' | 'bottom';
29
+ horizontal: 'left' | 'center' | 'right';
30
+ };
31
+ };
26
32
  };
27
33
  export declare const NotificationPopup: React.FC<NotificationPopupProps>;
@@ -1,23 +1,23 @@
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";
7
- import { Filter as x } from "./interface.js";
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)
1
+ import { jsx as o, jsxs as r, Fragment as C } from "react/jsx-runtime";
2
+ import { useState as m, useContext as O } from "react";
3
+ import { I as S } from "../../assets/Inbox.js";
4
+ import { UnreadBadge as x } from "./UnreadBadge.js";
5
+ import { NotificationAPIContext as N } from "../Provider/context.js";
6
+ import { N as v } from "../../assets/NotificationPreferencesPopup.js";
7
+ import { Filter as z } from "./interface.js";
8
+ import { W as y } from "../../assets/WebPushOptInMessage.js";
9
+ import { N as k } from "../../assets/channelUtils.js";
10
+ import { I as H } from "../../assets/IconButton.js";
11
+ import { P as A } from "../../assets/Popover.js";
12
+ import { D as B } from "../../assets/Divider.js";
13
+ const j = (e) => {
14
+ var c, d, u, h, s, p, g, f;
15
+ const [I, a] = m(!1), [n, l] = m(null), i = O(N);
16
+ if (!i)
17
17
  return null;
18
18
  const t = {
19
- buttonIcon: e.buttonIcon || /* @__PURE__ */ n(
20
- O,
19
+ buttonIcon: e.buttonIcon || /* @__PURE__ */ o(
20
+ k,
21
21
  {
22
22
  style: {
23
23
  fontSize: e.buttonIconSize || 20,
@@ -36,46 +36,52 @@ const R = (e) => {
36
36
  iconColor: e.iconColor || "#000000",
37
37
  pagination: e.pagination || "INFINITE_SCROLL",
38
38
  pageSize: e.pageSize || 10,
39
- pagePosition: e.pagePosition || "top",
39
+ pagePosition: e.pagePosition || "bottom",
40
40
  popupZIndex: e.popupZIndex || 1030,
41
41
  unreadBadgeProps: e.unreadBadgeProps ?? {},
42
42
  count: e.count || "COUNT_UNOPENED_NOTIFICATIONS",
43
- filter: e.filter || x.ALL,
43
+ filter: e.filter || z.ALL,
44
44
  header: {
45
- title: (d = e.header) == null ? void 0 : d.title,
46
- button1ClickHandler: ((c = e.header) == null ? void 0 : c.button1ClickHandler) ?? o.markAsArchived,
45
+ title: (c = e.header) == null ? void 0 : c.title,
46
+ button1ClickHandler: ((d = e.header) == null ? void 0 : d.button1ClickHandler) ?? i.markAsArchived,
47
47
  button2ClickHandler: ((u = e.header) == null ? void 0 : u.button2ClickHandler) ?? (() => a(!0))
48
48
  },
49
49
  renderers: {
50
- notification: (s = e.renderers) == null ? void 0 : s.notification
50
+ notification: (h = e.renderers) == null ? void 0 : h.notification
51
+ },
52
+ popoverPosition: {
53
+ anchorOrigin: {
54
+ vertical: ((p = (s = e.popoverPosition) == null ? void 0 : s.anchorOrigin) == null ? void 0 : p.vertical) ?? "top",
55
+ horizontal: ((f = (g = e.popoverPosition) == null ? void 0 : g.anchorOrigin) == null ? void 0 : f.horizontal) ?? "left"
56
+ }
51
57
  }
52
- }, h = (g) => {
53
- l(g.currentTarget), o.markAsOpened();
58
+ }, P = (b) => {
59
+ l(b.currentTarget), i.markAsOpened();
54
60
  };
55
- return /* @__PURE__ */ r(m, { children: [
56
- /* @__PURE__ */ n(
61
+ return /* @__PURE__ */ r(C, { children: [
62
+ /* @__PURE__ */ o(
57
63
  "div",
58
64
  {
59
65
  style: {
60
66
  display: "inline-block"
61
67
  },
62
- children: /* @__PURE__ */ n(
63
- b,
68
+ children: /* @__PURE__ */ o(
69
+ x,
64
70
  {
65
71
  ...e.unreadBadgeProps,
66
72
  count: t.count,
67
73
  filter: t.filter,
68
- children: /* @__PURE__ */ n(y, { onClick: h, style: t.buttonStyles, children: t.buttonIcon })
74
+ children: /* @__PURE__ */ o(H, { onClick: P, style: t.buttonStyles, children: t.buttonIcon })
69
75
  }
70
76
  )
71
77
  }
72
78
  ),
73
- /* @__PURE__ */ n(
74
- k,
79
+ /* @__PURE__ */ o(
80
+ A,
75
81
  {
76
- open: !!i,
82
+ open: !!n,
77
83
  onClose: () => l(null),
78
- anchorEl: i,
84
+ anchorEl: n,
79
85
  slotProps: {
80
86
  paper: {
81
87
  style: {
@@ -83,18 +89,20 @@ const R = (e) => {
83
89
  }
84
90
  }
85
91
  },
86
- "aria-hidden": !i,
92
+ "aria-hidden": !n,
93
+ anchorOrigin: t.popoverPosition.anchorOrigin,
87
94
  children: /* @__PURE__ */ r(
88
95
  "div",
89
96
  {
90
97
  style: {
91
98
  width: t.popupWidth,
92
99
  padding: "0 16px",
93
- zIndex: e.popupZIndex
100
+ zIndex: e.popupZIndex,
101
+ height: t.popupHeight
94
102
  },
95
103
  children: [
96
- /* @__PURE__ */ n(
97
- P,
104
+ /* @__PURE__ */ o(
105
+ S,
98
106
  {
99
107
  maxHeight: t.popupHeight - 73,
100
108
  pagination: t.pagination,
@@ -105,24 +113,24 @@ const R = (e) => {
105
113
  header: t.header
106
114
  }
107
115
  ),
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 })
116
+ i.webPushOptInMessage && localStorage.getItem("hideWebPushOptInMessage") !== "true" && /* @__PURE__ */ r("div", { children: [
117
+ /* @__PURE__ */ o(B, { style: { margin: "10px 0" } }),
118
+ /* @__PURE__ */ o(y, { hideAfterInteraction: !0 })
111
119
  ] })
112
120
  ]
113
121
  }
114
122
  )
115
123
  }
116
124
  ),
117
- /* @__PURE__ */ n(
118
- S,
125
+ /* @__PURE__ */ o(
126
+ v,
119
127
  {
120
- open: f,
128
+ open: I,
121
129
  onClose: () => a(!1)
122
130
  }
123
131
  )
124
132
  ] });
125
133
  };
126
134
  export {
127
- R as NotificationPopup
135
+ j as NotificationPopup
128
136
  };
@@ -15,5 +15,7 @@ export type UnreadBadgeProps = {
15
15
  bottom?: number;
16
16
  left?: number;
17
17
  };
18
+ fontColor?: string;
19
+ bubbleColor?: string;
18
20
  };
19
21
  export declare const UnreadBadge: React.FunctionComponent<PropsWithChildren<UnreadBadgeProps>>;
@@ -1,11 +1,11 @@
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";
1
+ import { jsx as c } from "react/jsx-runtime";
2
+ import { useContext as d } from "react";
3
+ import { NotificationAPIContext as a } from "../Provider/context.js";
4
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(
5
+ const b = (t) => {
6
+ var r, i, l, f;
7
+ const o = d(a);
8
+ return /* @__PURE__ */ c(
9
9
  u,
10
10
  {
11
11
  overlap: "circular",
@@ -15,13 +15,18 @@ const C = (t) => {
15
15
  max: t.max,
16
16
  variant: t.dot ? "dot" : "standard",
17
17
  showZero: t.showZero,
18
- color: "error",
18
+ sx: {
19
+ "& .MuiBadge-badge": {
20
+ backgroundColor: t.bubbleColor || "#d32f2f",
21
+ color: t.fontColor || "#FFF"
22
+ }
23
+ },
19
24
  slotProps: {
20
25
  badge: {
21
26
  style: {
22
27
  top: (r = t.offset) == null ? void 0 : r.top,
23
28
  right: (i = t.offset) == null ? void 0 : i.right,
24
- bottom: (c = t.offset) == null ? void 0 : c.bottom,
29
+ bottom: (l = t.offset) == null ? void 0 : l.bottom,
25
30
  left: (f = t.offset) == null ? void 0 : f.left
26
31
  }
27
32
  }
@@ -31,5 +36,5 @@ const C = (t) => {
31
36
  );
32
37
  };
33
38
  export {
34
- C as UnreadBadge
39
+ b as UnreadBadge
35
40
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@notificationapi/react",
3
3
  "private": false,
4
- "version": "1.0.1",
4
+ "version": "1.0.3",
5
5
  "type": "module",
6
6
  "browserslist": [
7
7
  "last 2 versions",
@@ -43,7 +43,7 @@
43
43
  "glob": "^10.4.1",
44
44
  "prettier": "^3.3.3",
45
45
  "typescript": "^5.2.2",
46
- "vite": "^5.2.0",
46
+ "vite": "^5.4.14",
47
47
  "vite-plugin-dts": "^3.9.1",
48
48
  "vite-plugin-lib-inject-css": "^2.1.1"
49
49
  },