@ttoss/react-notifications 2.4.11 → 2.4.13

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 (2) hide show
  1. package/dist/esm/index.js +70 -74
  2. package/package.json +6 -6
package/dist/esm/index.js CHANGED
@@ -1,4 +1,9 @@
1
1
  /** Powered by @ttoss/config. https://ttoss.dev/docs/modules/packages/config/ */
2
+ var __defProp = Object.defineProperty;
3
+ var __name = (target, value) => __defProp(target, "name", {
4
+ value,
5
+ configurable: true
6
+ });
2
7
 
3
8
  // src/NotificationsBox.tsx
4
9
  import { NotificationCard } from "@ttoss/components/NotificationCard";
@@ -7,27 +12,25 @@ import { Stack } from "@ttoss/ui";
7
12
  // src/Provider.tsx
8
13
  import { toast, ToastContainer } from "@ttoss/components/Toast";
9
14
  import { Flex, InfiniteLinearProgress } from "@ttoss/ui";
10
- import * as React from "react";
15
+ import * as React2 from "react";
11
16
 
12
17
  // src/NotificationsHeader.tsx
13
- import { jsx } from "react/jsx-runtime";
14
- var NotificationsHeader = () => {
18
+ var NotificationsHeader = /* @__PURE__ */__name(() => {
15
19
  const {
16
20
  notifications
17
21
  } = useNotifications();
18
22
  const headerNotifications = notifications?.filter(notification => {
19
23
  return notification.viewType === "header";
20
24
  });
21
- return /* @__PURE__ */jsx(NotificationsBox, {
25
+ return /* @__PURE__ */React.createElement(NotificationsBox, {
22
26
  notifications: headerNotifications
23
27
  });
24
- };
28
+ }, "NotificationsHeader");
25
29
 
26
30
  // src/NotificationsModal.tsx
27
31
  import { Modal } from "@ttoss/components/Modal";
28
32
  import { CloseButton } from "@ttoss/ui";
29
- import { jsx as jsx2, jsxs } from "react/jsx-runtime";
30
- var NotificationsModal = () => {
33
+ var NotificationsModal = /* @__PURE__ */__name(() => {
31
34
  const {
32
35
  notifications,
33
36
  clearNotifications,
@@ -40,7 +43,7 @@ var NotificationsModal = () => {
40
43
  return notification.viewType === "modal";
41
44
  });
42
45
  const isOpen = !!modalNotifications && modalNotifications.length > 0;
43
- return /* @__PURE__ */jsxs(Modal, {
46
+ return /* @__PURE__ */React.createElement(Modal, {
44
47
  isOpen,
45
48
  style: {
46
49
  content: {
@@ -50,51 +53,49 @@ var NotificationsModal = () => {
50
53
  alignItems: "center",
51
54
  gap: "4"
52
55
  }
56
+ }
57
+ }, /* @__PURE__ */React.createElement(CloseButton, {
58
+ "aria-label": "Close",
59
+ sx: {
60
+ alignSelf: "flex-end"
53
61
  },
54
- children: [/* @__PURE__ */jsx2(CloseButton, {
55
- "aria-label": "Close",
56
- sx: {
57
- alignSelf: "flex-end"
58
- },
59
- onClick: () => {
60
- clearNotifications();
61
- }
62
- }), /* @__PURE__ */jsx2(NotificationsBox, {
63
- notifications: modalNotifications
64
- })]
65
- });
66
- };
62
+ onClick: /* @__PURE__ */__name(() => {
63
+ clearNotifications();
64
+ }, "onClick")
65
+ }), /* @__PURE__ */React.createElement(NotificationsBox, {
66
+ notifications: modalNotifications
67
+ }));
68
+ }, "NotificationsModal");
67
69
 
68
70
  // src/Provider.tsx
69
- import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
70
- var NotificationsContext = React.createContext({
71
+ var NotificationsContext = /* @__PURE__ */React2.createContext({
71
72
  isLoading: false,
72
- setLoading: () => {
73
+ setLoading: /* @__PURE__ */__name(() => {
73
74
  return void 0;
74
- },
75
+ }, "setLoading"),
75
76
  defaultViewType: "box",
76
- addNotification: () => {
77
+ addNotification: /* @__PURE__ */__name(() => {
77
78
  return void 0;
78
- },
79
- removeNotification: () => {
79
+ }, "addNotification"),
80
+ removeNotification: /* @__PURE__ */__name(() => {
80
81
  return void 0;
81
- },
82
- clearNotifications: () => {
82
+ }, "removeNotification"),
83
+ clearNotifications: /* @__PURE__ */__name(() => {
83
84
  return void 0;
84
- }
85
+ }, "clearNotifications")
85
86
  });
86
- var NotificationsProvider = props => {
87
- const [isLoading, setLoading] = React.useState(false);
88
- const [notifications, setNotifications] = React.useState();
89
- const prefix = React.useId();
90
- const removeNotification = React.useCallback(id => {
87
+ var NotificationsProvider = /* @__PURE__ */__name(props => {
88
+ const [isLoading, setLoading] = React2.useState(false);
89
+ const [notifications, setNotifications] = React2.useState();
90
+ const prefix = React2.useId();
91
+ const removeNotification = React2.useCallback(id => {
91
92
  setNotifications(prevNotifications => {
92
93
  return prevNotifications?.filter(notification => {
93
94
  return notification.id !== id;
94
95
  });
95
96
  });
96
97
  }, []);
97
- const addNotification = React.useCallback(notification => {
98
+ const addNotification = React2.useCallback(notification => {
98
99
  const newNotifications = (Array.isArray(notification) ? notification : [notification]).map(notification2 => {
99
100
  const id = notification2.id || `${prefix}-${Math.random()}`;
100
101
  return {
@@ -119,10 +120,10 @@ var NotificationsProvider = props => {
119
120
  toast(notification2.message, {
120
121
  ...notification2.toast,
121
122
  type: notification2.type,
122
- onClose: () => {
123
+ onClose: /* @__PURE__ */__name(() => {
123
124
  removeNotification(notification2.id);
124
125
  notification2.toast?.onClose?.();
125
- }
126
+ }, "onClose")
126
127
  });
127
128
  });
128
129
  setNotifications((prevNotifications = []) => {
@@ -143,14 +144,14 @@ var NotificationsProvider = props => {
143
144
  return [...oldNotifications, ...nonToastNewNotifications];
144
145
  });
145
146
  }, [prefix, props.defaultViewType, removeNotification]);
146
- const clearNotifications = React.useCallback(() => {
147
+ const clearNotifications = React2.useCallback(() => {
147
148
  setNotifications(prevNotifications => {
148
149
  return prevNotifications?.filter(notification => {
149
150
  return notification.persist === true;
150
151
  });
151
152
  });
152
153
  }, []);
153
- return /* @__PURE__ */jsxs2(NotificationsContext.Provider, {
154
+ return /* @__PURE__ */React2.createElement(NotificationsContext.Provider, {
154
155
  value: {
155
156
  isLoading,
156
157
  setLoading,
@@ -159,26 +160,21 @@ var NotificationsProvider = props => {
159
160
  removeNotification,
160
161
  clearNotifications,
161
162
  defaultViewType: props.defaultViewType || "box"
162
- },
163
- children: [/* @__PURE__ */jsx3(ToastContainer, {
164
- ...props.toast
165
- }), /* @__PURE__ */jsx3(NotificationsModal, {}), isLoading && /* @__PURE__ */jsx3(Flex, {
166
- sx: {
167
- position: "absolute",
168
- width: "100%",
169
- top: 0
170
- },
171
- children: /* @__PURE__ */jsx3(InfiniteLinearProgress, {})
172
- }), /* @__PURE__ */jsx3(NotificationsHeader, {}), props.children]
173
- });
174
- };
175
- var useNotifications = () => {
176
- return React.useContext(NotificationsContext);
177
- };
163
+ }
164
+ }, /* @__PURE__ */React2.createElement(ToastContainer, props.toast), /* @__PURE__ */React2.createElement(NotificationsModal, null), isLoading && /* @__PURE__ */React2.createElement(Flex, {
165
+ sx: {
166
+ position: "absolute",
167
+ width: "100%",
168
+ top: 0
169
+ }
170
+ }, /* @__PURE__ */React2.createElement(InfiniteLinearProgress, null)), /* @__PURE__ */React2.createElement(NotificationsHeader, null), props.children);
171
+ }, "NotificationsProvider");
172
+ var useNotifications = /* @__PURE__ */__name(() => {
173
+ return React2.useContext(NotificationsContext);
174
+ }, "useNotifications");
178
175
 
179
176
  // src/NotificationsBox.tsx
180
- import { jsx as jsx4 } from "react/jsx-runtime";
181
- var NotificationsBox = props => {
177
+ var NotificationsBox = /* @__PURE__ */__name(props => {
182
178
  const {
183
179
  notifications,
184
180
  removeNotification,
@@ -200,23 +196,23 @@ var NotificationsBox = props => {
200
196
  if (!hasBoxNotifications) {
201
197
  return null;
202
198
  }
203
- return /* @__PURE__ */jsx4(Stack, {
199
+ return /* @__PURE__ */React.createElement(Stack, {
204
200
  sx: {
205
201
  width: "full",
206
202
  gap: "1"
207
- },
208
- children: boxNotifications.map(notification => {
209
- return /* @__PURE__ */jsx4(NotificationCard, {
210
- type: notification.type,
211
- title: notification.title,
212
- message: notification.message,
213
- onClose: () => {
214
- if (notification.id) {
215
- removeNotification(notification.id);
216
- }
203
+ }
204
+ }, boxNotifications.map(notification => {
205
+ return /* @__PURE__ */React.createElement(NotificationCard, {
206
+ key: notification.id,
207
+ type: notification.type,
208
+ title: notification.title,
209
+ message: notification.message,
210
+ onClose: /* @__PURE__ */__name(() => {
211
+ if (notification.id) {
212
+ removeNotification(notification.id);
217
213
  }
218
- }, notification.id);
219
- })
220
- });
221
- };
214
+ }, "onClose")
215
+ });
216
+ }));
217
+ }, "NotificationsBox");
222
218
  export { NotificationsBox, NotificationsProvider, toast, useNotifications };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ttoss/react-notifications",
3
- "version": "2.4.11",
3
+ "version": "2.4.13",
4
4
  "description": "ttoss notifications module for React apps.",
5
5
  "license": "MIT",
6
6
  "author": "ttoss",
@@ -25,20 +25,20 @@
25
25
  "sideEffects": false,
26
26
  "peerDependencies": {
27
27
  "react": ">=16.8.0",
28
- "@ttoss/components": "^2.4.0",
28
+ "@ttoss/react-icons": "^0.4.15",
29
29
  "@ttoss/ui": "^5.10.0",
30
- "@ttoss/react-icons": "^0.4.15"
30
+ "@ttoss/components": "^2.4.2"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/react": "^19.1.8",
34
34
  "jest": "^30.0.4",
35
35
  "react": "^19.1.0",
36
36
  "tsup": "^8.5.0",
37
- "@ttoss/components": "^2.4.0",
37
+ "@ttoss/components": "^2.4.2",
38
38
  "@ttoss/config": "^1.35.6",
39
+ "@ttoss/react-icons": "^0.4.15",
39
40
  "@ttoss/test-utils": "^2.1.26",
40
- "@ttoss/ui": "^5.10.0",
41
- "@ttoss/react-icons": "^0.4.15"
41
+ "@ttoss/ui": "^5.10.0"
42
42
  },
43
43
  "keywords": [
44
44
  "React",