@adatechnology/notification-ui 0.1.0-rc.1 → 0.1.0-rc.2
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/dist/chunk-FNUYTJ36.js +394 -0
- package/dist/chunk-FNUYTJ36.js.map +1 -0
- package/dist/headless.d.ts +92 -10
- package/dist/headless.js +22 -291
- package/dist/headless.js.map +1 -1
- package/dist/index.d.ts +69 -3
- package/dist/index.js +367 -458
- package/dist/index.js.map +1 -1
- package/dist/styles.css +258 -1
- package/dist/styles.css.map +1 -1
- package/package.json +3 -3
package/dist/headless.js
CHANGED
|
@@ -1,293 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"item.unread": "N\xE3o lida",
|
|
21
|
-
"preferences.title": "Prefer\xEAncias de notifica\xE7\xE3o",
|
|
22
|
-
"preferences.description": "Escolha por onde voc\xEA quer ser avisado em cada assunto.",
|
|
23
|
-
"preferences.save": "Salvar prefer\xEAncias",
|
|
24
|
-
"preferences.saved": "Prefer\xEAncias salvas.",
|
|
25
|
-
"preferences.error": "N\xE3o foi poss\xEDvel salvar. Tente de novo.",
|
|
26
|
-
"preferences.empty": "Nenhuma prefer\xEAncia configurada ainda.",
|
|
27
|
-
"preferences.quietHours": "Sil\xEAncio entre",
|
|
28
|
-
"preferences.quietHoursTo": "e",
|
|
29
|
-
"channel.inbox": "No app",
|
|
30
|
-
"channel.push": "Push",
|
|
31
|
-
"channel.email": "E-mail",
|
|
32
|
-
"channel.whatsapp": "WhatsApp",
|
|
33
|
-
"channel.sms": "SMS"
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
// src/locales/en.json
|
|
37
|
-
var en_default = {
|
|
38
|
-
"bell.label": "Notifications",
|
|
39
|
-
"bell.unreadSuffix": "unread",
|
|
40
|
-
"list.title": "Notifications",
|
|
41
|
-
"list.empty": "Nothing here yet.",
|
|
42
|
-
"list.loading": "Loading\u2026",
|
|
43
|
-
"list.error": "We couldn't load your notifications.",
|
|
44
|
-
"list.retry": "Try again",
|
|
45
|
-
"list.loadMore": "Load more",
|
|
46
|
-
"list.markAllAsRead": "Mark all as read",
|
|
47
|
-
"item.markAsRead": "Mark as read",
|
|
48
|
-
"item.delete": "Delete",
|
|
49
|
-
"item.unread": "Unread",
|
|
50
|
-
"preferences.title": "Notification preferences",
|
|
51
|
-
"preferences.description": "Choose how you want to be notified about each topic.",
|
|
52
|
-
"preferences.save": "Save preferences",
|
|
53
|
-
"preferences.saved": "Preferences saved.",
|
|
54
|
-
"preferences.error": "Couldn't save. Try again.",
|
|
55
|
-
"preferences.empty": "No preferences configured yet.",
|
|
56
|
-
"preferences.quietHours": "Quiet between",
|
|
57
|
-
"preferences.quietHoursTo": "and",
|
|
58
|
-
"channel.inbox": "In app",
|
|
59
|
-
"channel.push": "Push",
|
|
60
|
-
"channel.email": "Email",
|
|
61
|
-
"channel.whatsapp": "WhatsApp",
|
|
62
|
-
"channel.sms": "SMS"
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
// src/locales/index.ts
|
|
66
|
-
var DEFAULT_LOCALE = "pt-BR";
|
|
67
|
-
var MESSAGES_BY_LOCALE = {
|
|
68
|
-
"pt-BR": pt_BR_default,
|
|
69
|
-
en: en_default
|
|
70
|
-
};
|
|
71
|
-
function resolveMessages(locale) {
|
|
72
|
-
return MESSAGES_BY_LOCALE[locale] ?? MESSAGES_BY_LOCALE[DEFAULT_LOCALE];
|
|
73
|
-
}
|
|
74
|
-
__name(resolveMessages, "resolveMessages");
|
|
75
|
-
|
|
76
|
-
// src/NotificationProvider.tsx
|
|
77
|
-
var NotificationContext = /* @__PURE__ */ createContext(null);
|
|
78
|
-
function NotificationProvider({ client, locale = DEFAULT_LOCALE, messageOverrides, theme = {}, pollIntervalSeconds = 60, children }) {
|
|
79
|
-
const value = useMemo(() => ({
|
|
80
|
-
client,
|
|
81
|
-
messages: {
|
|
82
|
-
...resolveMessages(locale),
|
|
83
|
-
...messageOverrides
|
|
84
|
-
},
|
|
85
|
-
theme,
|
|
86
|
-
pollIntervalSeconds
|
|
87
|
-
}), [
|
|
88
|
-
client,
|
|
89
|
-
locale,
|
|
90
|
-
messageOverrides,
|
|
91
|
-
theme,
|
|
92
|
-
pollIntervalSeconds
|
|
93
|
-
]);
|
|
94
|
-
return /* @__PURE__ */ React.createElement(NotificationContext.Provider, {
|
|
95
|
-
value
|
|
96
|
-
}, children);
|
|
97
|
-
}
|
|
98
|
-
__name(NotificationProvider, "NotificationProvider");
|
|
99
|
-
function useNotificationContext() {
|
|
100
|
-
const context = useContext(NotificationContext);
|
|
101
|
-
if (!context) throw new Error("notification-ui: componente usado fora de <NotificationProvider>");
|
|
102
|
-
return context;
|
|
103
|
-
}
|
|
104
|
-
__name(useNotificationContext, "useNotificationContext");
|
|
105
|
-
|
|
106
|
-
// src/hooks/useNotifications.ts
|
|
107
|
-
import { useInfiniteQuery, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
|
108
|
-
|
|
109
|
-
// src/hooks/queryKeys.ts
|
|
110
|
-
var NOTIFICATION_QUERY_KEYS = {
|
|
111
|
-
all: [
|
|
112
|
-
"notifications"
|
|
113
|
-
],
|
|
114
|
-
list: /* @__PURE__ */ __name((filters) => [
|
|
115
|
-
"notifications",
|
|
116
|
-
"list",
|
|
117
|
-
filters
|
|
118
|
-
], "list"),
|
|
119
|
-
unreadCount: /* @__PURE__ */ __name(() => [
|
|
120
|
-
"notifications",
|
|
121
|
-
"unread-count"
|
|
122
|
-
], "unreadCount"),
|
|
123
|
-
preferences: /* @__PURE__ */ __name(() => [
|
|
124
|
-
"notifications",
|
|
125
|
-
"preferences"
|
|
126
|
-
], "preferences"),
|
|
127
|
-
templates: /* @__PURE__ */ __name(() => [
|
|
128
|
-
"notifications",
|
|
129
|
-
"templates"
|
|
130
|
-
], "templates")
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
// src/hooks/useNotifications.ts
|
|
134
|
-
function useNotifications(options = {}) {
|
|
135
|
-
const { client } = useNotificationContext();
|
|
136
|
-
return useInfiniteQuery({
|
|
137
|
-
queryKey: NOTIFICATION_QUERY_KEYS.list({
|
|
138
|
-
category: options.category,
|
|
139
|
-
read: options.read
|
|
140
|
-
}),
|
|
141
|
-
initialPageParam: void 0,
|
|
142
|
-
queryFn: /* @__PURE__ */ __name(({ pageParam }) => client.listNotifications({
|
|
143
|
-
category: options.category,
|
|
144
|
-
read: options.read,
|
|
145
|
-
cursor: pageParam,
|
|
146
|
-
perPage: options.perPage
|
|
147
|
-
}), "queryFn"),
|
|
148
|
-
getNextPageParam: /* @__PURE__ */ __name((lastPage) => lastPage.nextCursor, "getNextPageParam")
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
__name(useNotifications, "useNotifications");
|
|
152
|
-
function useUnreadCount() {
|
|
153
|
-
const { client, pollIntervalSeconds } = useNotificationContext();
|
|
154
|
-
return useQuery({
|
|
155
|
-
queryKey: NOTIFICATION_QUERY_KEYS.unreadCount(),
|
|
156
|
-
queryFn: /* @__PURE__ */ __name(() => client.countUnread(), "queryFn"),
|
|
157
|
-
// Polling é o fallback de quem não ligou o SSE. Com o stream ativo,
|
|
158
|
-
// `useNotificationStream` invalida esta chave e o refetch acontece na hora.
|
|
159
|
-
refetchInterval: pollIntervalSeconds > 0 ? pollIntervalSeconds * 1e3 : false
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
__name(useUnreadCount, "useUnreadCount");
|
|
163
|
-
function useMarkAsRead() {
|
|
164
|
-
const { client } = useNotificationContext();
|
|
165
|
-
const queryClient = useQueryClient();
|
|
166
|
-
return useMutation({
|
|
167
|
-
mutationFn: /* @__PURE__ */ __name((id) => client.markAsRead(id), "mutationFn"),
|
|
168
|
-
async onMutate(id) {
|
|
169
|
-
await queryClient.cancelQueries({
|
|
170
|
-
queryKey: NOTIFICATION_QUERY_KEYS.all
|
|
171
|
-
});
|
|
172
|
-
const previousCount = queryClient.getQueryData(NOTIFICATION_QUERY_KEYS.unreadCount());
|
|
173
|
-
queryClient.setQueryData(NOTIFICATION_QUERY_KEYS.unreadCount(), (current) => current === void 0 ? current : Math.max(0, current - 1));
|
|
174
|
-
return {
|
|
175
|
-
previousCount,
|
|
176
|
-
id
|
|
177
|
-
};
|
|
178
|
-
},
|
|
179
|
-
onError(_error, _id, context) {
|
|
180
|
-
if (context?.previousCount !== void 0) {
|
|
181
|
-
queryClient.setQueryData(NOTIFICATION_QUERY_KEYS.unreadCount(), context.previousCount);
|
|
182
|
-
}
|
|
183
|
-
},
|
|
184
|
-
onSettled() {
|
|
185
|
-
void queryClient.invalidateQueries({
|
|
186
|
-
queryKey: NOTIFICATION_QUERY_KEYS.all
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
__name(useMarkAsRead, "useMarkAsRead");
|
|
192
|
-
function useMarkAllAsRead() {
|
|
193
|
-
const { client } = useNotificationContext();
|
|
194
|
-
const queryClient = useQueryClient();
|
|
195
|
-
return useMutation({
|
|
196
|
-
mutationFn: /* @__PURE__ */ __name(() => client.markAllAsRead(), "mutationFn"),
|
|
197
|
-
onSettled() {
|
|
198
|
-
void queryClient.invalidateQueries({
|
|
199
|
-
queryKey: NOTIFICATION_QUERY_KEYS.all
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
__name(useMarkAllAsRead, "useMarkAllAsRead");
|
|
205
|
-
function useDeleteNotification() {
|
|
206
|
-
const { client } = useNotificationContext();
|
|
207
|
-
const queryClient = useQueryClient();
|
|
208
|
-
return useMutation({
|
|
209
|
-
mutationFn: /* @__PURE__ */ __name((id) => client.deleteNotification(id), "mutationFn"),
|
|
210
|
-
onSettled() {
|
|
211
|
-
void queryClient.invalidateQueries({
|
|
212
|
-
queryKey: NOTIFICATION_QUERY_KEYS.all
|
|
213
|
-
});
|
|
214
|
-
}
|
|
215
|
-
});
|
|
216
|
-
}
|
|
217
|
-
__name(useDeleteNotification, "useDeleteNotification");
|
|
218
|
-
function flattenNotificationPages(pages) {
|
|
219
|
-
return pages?.flatMap((page) => page.data) ?? [];
|
|
220
|
-
}
|
|
221
|
-
__name(flattenNotificationPages, "flattenNotificationPages");
|
|
222
|
-
|
|
223
|
-
// src/hooks/useNotificationStream.ts
|
|
224
|
-
import { useEffect } from "react";
|
|
225
|
-
import { useQueryClient as useQueryClient2 } from "@tanstack/react-query";
|
|
226
|
-
import { subscribeToNotificationStream } from "@adatechnology/notification-client";
|
|
227
|
-
function useNotificationStream(options = {}) {
|
|
228
|
-
const { client } = useNotificationContext();
|
|
229
|
-
const queryClient = useQueryClient2();
|
|
230
|
-
const enabled = options.enabled ?? false;
|
|
231
|
-
const onEvent = options.onEvent;
|
|
232
|
-
useEffect(() => {
|
|
233
|
-
if (!enabled) return;
|
|
234
|
-
let subscription;
|
|
235
|
-
let cancelled = false;
|
|
236
|
-
void client.resolveStreamRequest().then(({ url, headers }) => {
|
|
237
|
-
if (cancelled) return;
|
|
238
|
-
subscription = subscribeToNotificationStream({
|
|
239
|
-
url,
|
|
240
|
-
headers,
|
|
241
|
-
onEvent: /* @__PURE__ */ __name((event) => {
|
|
242
|
-
onEvent?.(event);
|
|
243
|
-
void queryClient.invalidateQueries({
|
|
244
|
-
queryKey: NOTIFICATION_QUERY_KEYS.all
|
|
245
|
-
});
|
|
246
|
-
}, "onEvent")
|
|
247
|
-
});
|
|
248
|
-
});
|
|
249
|
-
return () => {
|
|
250
|
-
cancelled = true;
|
|
251
|
-
subscription?.close();
|
|
252
|
-
};
|
|
253
|
-
}, [
|
|
254
|
-
client,
|
|
255
|
-
queryClient,
|
|
256
|
-
enabled,
|
|
257
|
-
onEvent
|
|
258
|
-
]);
|
|
259
|
-
}
|
|
260
|
-
__name(useNotificationStream, "useNotificationStream");
|
|
261
|
-
|
|
262
|
-
// src/hooks/usePreferences.ts
|
|
263
|
-
import { useMutation as useMutation2, useQuery as useQuery2, useQueryClient as useQueryClient3 } from "@tanstack/react-query";
|
|
264
|
-
function usePreferences() {
|
|
265
|
-
const { client } = useNotificationContext();
|
|
266
|
-
return useQuery2({
|
|
267
|
-
queryKey: NOTIFICATION_QUERY_KEYS.preferences(),
|
|
268
|
-
queryFn: /* @__PURE__ */ __name(() => client.getPreferences(), "queryFn")
|
|
269
|
-
});
|
|
270
|
-
}
|
|
271
|
-
__name(usePreferences, "usePreferences");
|
|
272
|
-
function useUpdatePreferences() {
|
|
273
|
-
const { client } = useNotificationContext();
|
|
274
|
-
const queryClient = useQueryClient3();
|
|
275
|
-
return useMutation2({
|
|
276
|
-
mutationFn: /* @__PURE__ */ __name((preferences) => client.updatePreferences(preferences), "mutationFn"),
|
|
277
|
-
onSuccess(saved) {
|
|
278
|
-
queryClient.setQueryData(NOTIFICATION_QUERY_KEYS.preferences(), saved);
|
|
279
|
-
}
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
__name(useUpdatePreferences, "useUpdatePreferences");
|
|
283
|
-
function useTemplates() {
|
|
284
|
-
const { client } = useNotificationContext();
|
|
285
|
-
return useQuery2({
|
|
286
|
-
queryKey: NOTIFICATION_QUERY_KEYS.templates(),
|
|
287
|
-
queryFn: /* @__PURE__ */ __name(() => client.listTemplates(), "queryFn")
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
__name(useTemplates, "useTemplates");
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_LOCALE,
|
|
3
|
+
NOTIFICATION_QUERY_KEYS,
|
|
4
|
+
NotificationProvider,
|
|
5
|
+
flattenNotificationPages,
|
|
6
|
+
resolveMessages,
|
|
7
|
+
useDeleteNotification,
|
|
8
|
+
useMarkAllAsRead,
|
|
9
|
+
useMarkAsRead,
|
|
10
|
+
useNotificationContext,
|
|
11
|
+
useNotificationStream,
|
|
12
|
+
useNotifications,
|
|
13
|
+
usePreferences,
|
|
14
|
+
useTemplateEditor,
|
|
15
|
+
useTemplates,
|
|
16
|
+
useUnreadCount,
|
|
17
|
+
useUpdatePreferences,
|
|
18
|
+
useUpsertTemplate
|
|
19
|
+
} from "./chunk-FNUYTJ36.js";
|
|
291
20
|
export {
|
|
292
21
|
DEFAULT_LOCALE,
|
|
293
22
|
NOTIFICATION_QUERY_KEYS,
|
|
@@ -301,8 +30,10 @@ export {
|
|
|
301
30
|
useNotificationStream,
|
|
302
31
|
useNotifications,
|
|
303
32
|
usePreferences,
|
|
33
|
+
useTemplateEditor,
|
|
304
34
|
useTemplates,
|
|
305
35
|
useUnreadCount,
|
|
306
|
-
useUpdatePreferences
|
|
36
|
+
useUpdatePreferences,
|
|
37
|
+
useUpsertTemplate
|
|
307
38
|
};
|
|
308
39
|
//# sourceMappingURL=headless.js.map
|
package/dist/headless.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/NotificationProvider.tsx","../src/locales/pt-BR.json","../src/locales/en.json","../src/locales/index.ts","../src/hooks/useNotifications.ts","../src/hooks/queryKeys.ts","../src/hooks/useNotificationStream.ts","../src/hooks/usePreferences.ts"],"sourcesContent":["/**\n * Copyright (c) 2026 Ada Technology. MIT License.\n *\n * Provider do pacote. **Não instancia `QueryClient`** — usa o do host (regra de módulos\n * plugáveis §4.2). Instanciar o próprio criaria dois caches na mesma página: a inbox invalidaria\n * um, e a tela do produto continuaria lendo o outro.\n */\n\nimport { createContext, useContext, useMemo, type ReactNode } from 'react'\nimport type { NotificationClient } from '@adatechnology/notification-client'\n\nimport { DEFAULT_LOCALE, resolveMessages, type NotificationLocale, type NotificationMessages } from './locales'\n\nexport type NotificationTheme = {\n /** Classe aplicada na raiz de cada componente — é por onde o host injeta os tokens dele. */\n readonly rootClassName?: string\n readonly components?: Partial<Record<string, string>>\n}\n\nexport type NotificationContextValue = {\n readonly client: NotificationClient\n readonly messages: NotificationMessages\n readonly theme: NotificationTheme\n /** Polling de fallback quando o SSE não está disponível (segundos); `0` desliga. */\n readonly pollIntervalSeconds: number\n}\n\nconst NotificationContext = createContext<NotificationContextValue | null>(null)\n\nexport type NotificationProviderProps = {\n readonly client: NotificationClient\n readonly locale?: NotificationLocale\n /** Sobrescreve textos pontuais sem trocar o locale inteiro. */\n readonly messageOverrides?: Partial<NotificationMessages>\n readonly theme?: NotificationTheme\n readonly pollIntervalSeconds?: number\n readonly children: ReactNode\n}\n\nexport function NotificationProvider({\n client,\n locale = DEFAULT_LOCALE,\n messageOverrides,\n theme = {},\n pollIntervalSeconds = 60,\n children,\n}: NotificationProviderProps) {\n const value = useMemo<NotificationContextValue>(\n () => ({\n client,\n messages: { ...resolveMessages(locale), ...messageOverrides },\n theme,\n pollIntervalSeconds,\n }),\n [client, locale, messageOverrides, theme, pollIntervalSeconds],\n )\n\n return <NotificationContext.Provider value={value}>{children}</NotificationContext.Provider>\n}\n\nexport function useNotificationContext(): NotificationContextValue {\n const context = useContext(NotificationContext)\n if (!context) throw new Error('notification-ui: componente usado fora de <NotificationProvider>')\n return context\n}\n","{\n \"bell.label\": \"Notificações\",\n \"bell.unreadSuffix\": \"não lidas\",\n \"list.title\": \"Notificações\",\n \"list.empty\": \"Nenhuma notificação por aqui.\",\n \"list.loading\": \"Carregando…\",\n \"list.error\": \"Não foi possível carregar suas notificações.\",\n \"list.retry\": \"Tentar de novo\",\n \"list.loadMore\": \"Carregar mais\",\n \"list.markAllAsRead\": \"Marcar todas como lidas\",\n \"item.markAsRead\": \"Marcar como lida\",\n \"item.delete\": \"Excluir\",\n \"item.unread\": \"Não lida\",\n \"preferences.title\": \"Preferências de notificação\",\n \"preferences.description\": \"Escolha por onde você quer ser avisado em cada assunto.\",\n \"preferences.save\": \"Salvar preferências\",\n \"preferences.saved\": \"Preferências salvas.\",\n \"preferences.error\": \"Não foi possível salvar. Tente de novo.\",\n \"preferences.empty\": \"Nenhuma preferência configurada ainda.\",\n \"preferences.quietHours\": \"Silêncio entre\",\n \"preferences.quietHoursTo\": \"e\",\n \"channel.inbox\": \"No app\",\n \"channel.push\": \"Push\",\n \"channel.email\": \"E-mail\",\n \"channel.whatsapp\": \"WhatsApp\",\n \"channel.sms\": \"SMS\"\n}\n","{\n \"bell.label\": \"Notifications\",\n \"bell.unreadSuffix\": \"unread\",\n \"list.title\": \"Notifications\",\n \"list.empty\": \"Nothing here yet.\",\n \"list.loading\": \"Loading…\",\n \"list.error\": \"We couldn't load your notifications.\",\n \"list.retry\": \"Try again\",\n \"list.loadMore\": \"Load more\",\n \"list.markAllAsRead\": \"Mark all as read\",\n \"item.markAsRead\": \"Mark as read\",\n \"item.delete\": \"Delete\",\n \"item.unread\": \"Unread\",\n \"preferences.title\": \"Notification preferences\",\n \"preferences.description\": \"Choose how you want to be notified about each topic.\",\n \"preferences.save\": \"Save preferences\",\n \"preferences.saved\": \"Preferences saved.\",\n \"preferences.error\": \"Couldn't save. Try again.\",\n \"preferences.empty\": \"No preferences configured yet.\",\n \"preferences.quietHours\": \"Quiet between\",\n \"preferences.quietHoursTo\": \"and\",\n \"channel.inbox\": \"In app\",\n \"channel.push\": \"Push\",\n \"channel.email\": \"Email\",\n \"channel.whatsapp\": \"WhatsApp\",\n \"channel.sms\": \"SMS\"\n}\n","/**\n * Copyright (c) 2026 Ada Technology. MIT License.\n *\n * Nenhum texto visível vive em tag ou prop (`web.md` §6). O host sobrescreve chaves pontuais via\n * `messageOverrides` sem precisar fornecer um locale inteiro.\n */\n\nimport ptBR from './pt-BR.json'\nimport en from './en.json'\n\nexport type NotificationMessages = typeof ptBR\nexport type NotificationLocale = 'pt-BR' | 'en'\n\nexport const DEFAULT_LOCALE: NotificationLocale = 'pt-BR'\n\nconst MESSAGES_BY_LOCALE: Record<NotificationLocale, NotificationMessages> = {\n 'pt-BR': ptBR,\n en: en as NotificationMessages,\n}\n\nexport function resolveMessages(locale: NotificationLocale): NotificationMessages {\n return MESSAGES_BY_LOCALE[locale] ?? MESSAGES_BY_LOCALE[DEFAULT_LOCALE]\n}\n","/**\n * Copyright (c) 2026 Ada Technology. MIT License.\n *\n * Camada headless — a válvula de escape do item 4 da §4 da regra de módulos plugáveis: quando a\n * tela default não serve, o produto monta a própria sobre estes mesmos hooks e continua herdando\n * upgrades de lógica.\n */\n\nimport { useInfiniteQuery, useMutation, useQuery, useQueryClient } from '@tanstack/react-query'\nimport type { NotificationSummary } from '@adatechnology/notification-contracts'\n\nimport { useNotificationContext } from '../NotificationProvider'\nimport { NOTIFICATION_QUERY_KEYS } from './queryKeys'\n\nexport type UseNotificationsOptions = {\n readonly category?: string\n readonly read?: boolean\n readonly perPage?: number\n}\n\nexport function useNotifications(options: UseNotificationsOptions = {}) {\n const { client } = useNotificationContext()\n\n return useInfiniteQuery({\n queryKey: NOTIFICATION_QUERY_KEYS.list({ category: options.category, read: options.read }),\n initialPageParam: undefined as string | undefined,\n queryFn: ({ pageParam }) =>\n client.listNotifications({\n category: options.category,\n read: options.read,\n cursor: pageParam,\n perPage: options.perPage,\n }),\n getNextPageParam: (lastPage) => lastPage.nextCursor,\n })\n}\n\nexport function useUnreadCount() {\n const { client, pollIntervalSeconds } = useNotificationContext()\n\n return useQuery({\n queryKey: NOTIFICATION_QUERY_KEYS.unreadCount(),\n queryFn: () => client.countUnread(),\n // Polling é o fallback de quem não ligou o SSE. Com o stream ativo,\n // `useNotificationStream` invalida esta chave e o refetch acontece na hora.\n refetchInterval: pollIntervalSeconds > 0 ? pollIntervalSeconds * 1000 : false,\n })\n}\n\nexport function useMarkAsRead() {\n const { client } = useNotificationContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n mutationFn: (id: string) => client.markAsRead(id),\n async onMutate(id: string) {\n // Atualização otimista: marcar como lida é ação de um clique, e esperar o round-trip para\n // o badge cair faz a interface parecer travada.\n await queryClient.cancelQueries({ queryKey: NOTIFICATION_QUERY_KEYS.all })\n const previousCount = queryClient.getQueryData<number>(NOTIFICATION_QUERY_KEYS.unreadCount())\n\n queryClient.setQueryData<number>(NOTIFICATION_QUERY_KEYS.unreadCount(), (current) =>\n current === undefined ? current : Math.max(0, current - 1),\n )\n return { previousCount, id }\n },\n onError(_error, _id, context) {\n // Rollback: sem isto o badge ficaria mentindo até o próximo refetch.\n if (context?.previousCount !== undefined) {\n queryClient.setQueryData(NOTIFICATION_QUERY_KEYS.unreadCount(), context.previousCount)\n }\n },\n onSettled() {\n void queryClient.invalidateQueries({ queryKey: NOTIFICATION_QUERY_KEYS.all })\n },\n })\n}\n\nexport function useMarkAllAsRead() {\n const { client } = useNotificationContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n mutationFn: () => client.markAllAsRead(),\n onSettled() {\n void queryClient.invalidateQueries({ queryKey: NOTIFICATION_QUERY_KEYS.all })\n },\n })\n}\n\nexport function useDeleteNotification() {\n const { client } = useNotificationContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n mutationFn: (id: string) => client.deleteNotification(id),\n onSettled() {\n void queryClient.invalidateQueries({ queryKey: NOTIFICATION_QUERY_KEYS.all })\n },\n })\n}\n\n/** Achata as páginas do infinite query — a lista quase sempre quer o array direto. */\nexport function flattenNotificationPages(\n pages: readonly { data: readonly NotificationSummary[] }[] | undefined,\n): readonly NotificationSummary[] {\n return pages?.flatMap((page) => page.data) ?? []\n}\n","/**\n * Copyright (c) 2026 Ada Technology. MIT License.\n *\n * Chaves centralizadas: o sino e a lista leem o mesmo `unreadCount`, e uma invalidação precisa\n * atingir os dois. Chave montada inline em cada hook é como badge e lista passam a mostrar\n * números diferentes.\n */\n\nexport const NOTIFICATION_QUERY_KEYS = {\n all: ['notifications'] as const,\n list: (filters: { category?: string; read?: boolean }) => ['notifications', 'list', filters] as const,\n unreadCount: () => ['notifications', 'unread-count'] as const,\n preferences: () => ['notifications', 'preferences'] as const,\n templates: () => ['notifications', 'templates'] as const,\n} as const\n","/**\n * Copyright (c) 2026 Ada Technology. MIT License.\n */\n\nimport { useEffect } from 'react'\nimport { useQueryClient } from '@tanstack/react-query'\nimport { subscribeToNotificationStream } from '@adatechnology/notification-client'\n\nimport { useNotificationContext } from '../NotificationProvider'\nimport { NOTIFICATION_QUERY_KEYS } from './queryKeys'\n\nexport type UseNotificationStreamOptions = {\n /** Desligado por omissão: abrir SSE é decisão do host, que sabe se o backend expõe a rota. */\n readonly enabled?: boolean\n readonly onEvent?: (event: { event: string; data: unknown }) => void\n}\n\n/**\n * Liga o SSE do inbox ao cache do TanStack: cada evento invalida as chaves, e o badge e a lista\n * atualizam juntos. `useEffect` aqui é o uso correto do hook — sincronizar com um sistema externo\n * (`react.md`, \"useEffect só para sincronizar com sistemas externos\"), não transformar dado.\n */\nexport function useNotificationStream(options: UseNotificationStreamOptions = {}): void {\n const { client } = useNotificationContext()\n const queryClient = useQueryClient()\n const enabled = options.enabled ?? false\n const onEvent = options.onEvent\n\n useEffect(() => {\n if (!enabled) return\n\n let subscription: { close(): void } | undefined\n let cancelled = false\n\n void client.resolveStreamRequest().then(({ url, headers }) => {\n // A resolução do token é assíncrona; se o componente desmontou nesse meio-tempo, não abre\n // conexão nenhuma — senão sobraria um stream órfão a cada navegação rápida.\n if (cancelled) return\n\n subscription = subscribeToNotificationStream({\n url,\n headers,\n onEvent: (event) => {\n onEvent?.(event)\n void queryClient.invalidateQueries({ queryKey: NOTIFICATION_QUERY_KEYS.all })\n },\n })\n })\n\n return () => {\n cancelled = true\n subscription?.close()\n }\n }, [client, queryClient, enabled, onEvent])\n}\n","/**\n * Copyright (c) 2026 Ada Technology. MIT License.\n */\n\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'\nimport type { NotificationPreference } from '@adatechnology/notification-contracts'\n\nimport { useNotificationContext } from '../NotificationProvider'\nimport { NOTIFICATION_QUERY_KEYS } from './queryKeys'\n\nexport function usePreferences() {\n const { client } = useNotificationContext()\n\n return useQuery({\n queryKey: NOTIFICATION_QUERY_KEYS.preferences(),\n queryFn: () => client.getPreferences(),\n })\n}\n\nexport function useUpdatePreferences() {\n const { client } = useNotificationContext()\n const queryClient = useQueryClient()\n\n return useMutation({\n mutationFn: (preferences: readonly NotificationPreference[]) => client.updatePreferences(preferences),\n onSuccess(saved) {\n // A resposta já é o estado persistido — usar direto evita um refetch e o piscar do painel\n // entre o valor otimista e o confirmado.\n queryClient.setQueryData(NOTIFICATION_QUERY_KEYS.preferences(), saved)\n },\n })\n}\n\nexport function useTemplates() {\n const { client } = useNotificationContext()\n\n return useQuery({\n queryKey: NOTIFICATION_QUERY_KEYS.templates(),\n queryFn: () => client.listTemplates(),\n })\n}\n"],"mappings":";;;;AAQA,SAASA,eAAeC,YAAYC,eAA+B;;;ACRnE;AAAA,EACE,cAAc;AAAA,EACd,qBAAqB;AAAA,EACrB,cAAc;AAAA,EACd,cAAc;AAAA,EACd,gBAAgB;AAAA,EAChB,cAAc;AAAA,EACd,cAAc;AAAA,EACd,iBAAiB;AAAA,EACjB,sBAAsB;AAAA,EACtB,mBAAmB;AAAA,EACnB,eAAe;AAAA,EACf,eAAe;AAAA,EACf,qBAAqB;AAAA,EACrB,2BAA2B;AAAA,EAC3B,oBAAoB;AAAA,EACpB,qBAAqB;AAAA,EACrB,qBAAqB;AAAA,EACrB,qBAAqB;AAAA,EACrB,0BAA0B;AAAA,EAC1B,4BAA4B;AAAA,EAC5B,iBAAiB;AAAA,EACjB,gBAAgB;AAAA,EAChB,iBAAiB;AAAA,EACjB,oBAAoB;AAAA,EACpB,eAAe;AACjB;;;AC1BA;AAAA,EACE,cAAc;AAAA,EACd,qBAAqB;AAAA,EACrB,cAAc;AAAA,EACd,cAAc;AAAA,EACd,gBAAgB;AAAA,EAChB,cAAc;AAAA,EACd,cAAc;AAAA,EACd,iBAAiB;AAAA,EACjB,sBAAsB;AAAA,EACtB,mBAAmB;AAAA,EACnB,eAAe;AAAA,EACf,eAAe;AAAA,EACf,qBAAqB;AAAA,EACrB,2BAA2B;AAAA,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O,MAAE;AAGvD,UAAIJ,UAAW;AAEfD,qBAAeM,8BAA8B;QAC3CF;QACAC;QACAP,SAAS,wBAACS,UAAAA;AACRT,oBAAUS,KAAAA;AACV,eAAKZ,YAAYa,kBAAkB;YAAEC,UAAUC,wBAAwBC;UAAI,CAAA;QAC7E,GAHS;MAIX,CAAA;IACF,CAAA;AAEA,WAAO,MAAA;AACLV,kBAAY;AACZD,oBAAcY,MAAAA;IAChB;EACF,GAAG;IAACnB;IAAQE;IAAaE;IAASC;GAAQ;AAC5C;AAhCgBP;;;AClBhB,SAASsB,eAAAA,cAAaC,YAAAA,WAAUC,kBAAAA,uBAAsB;AAM/C,SAASC,iBAAAA;AACd,QAAM,EAAEC,OAAM,IAAKC,uBAAAA;AAEnB,SAAOC,UAAS;IACdC,UAAUC,wBAAwBC,YAAW;IAC7CC,SAAS,6BAAMN,OAAOO,eAAc,GAA3B;EACX,CAAA;AACF;AAPgBR;AAST,SAASS,uBAAAA;AACd,QAAM,EAAER,OAAM,IAAKC,uBAAAA;AACnB,QAAMQ,cAAcC,gBAAAA;AAEpB,SAAOC,aAAY;IACjBC,YAAY,wBAACP,gBAAmDL,OAAOa,kBAAkBR,WAAAA,GAA7E;IACZS,UAAUC,OAAK;AAGbN,kBAAYO,aAAaZ,wBAAwBC,YAAW,GAAIU,KAAAA;IAClE;EACF,CAAA;AACF;AAZgBP;AAcT,SAASS,eAAAA;AACd,QAAM,EAAEjB,OAAM,IAAKC,uBAAAA;AAEnB,SAAOC,UAAS;IACdC,UAAUC,wBAAwBc,UAAS;IAC3CZ,SAAS,6BAAMN,OAAOmB,cAAa,GAA1B;EACX,CAAA;AACF;AAPgBF;","names":["createContext","useContext","useMemo","DEFAULT_LOCALE","MESSAGES_BY_LOCALE","ptBR","en","resolveMessages","locale","NotificationContext","createContext","NotificationProvider","client","locale","DEFAULT_LOCALE","messageOverrides","theme","pollIntervalSeconds","children","value","useMemo","messages","resolveMessages","Provider","useNotificationContext","context","useContext","Error","useInfiniteQuery","useMutation","useQuery","useQueryClient","NOTIFICATION_QUERY_KEYS","all","list","filters","unreadCount","preferences","templates","useNotifications","options","client","useNotificationContext","useInfiniteQuery","queryKey","NOTIFICATION_QUERY_KEYS","list","category","read","initialPageParam","undefined","queryFn","pageParam","listNotifications","cursor","perPage","getNextPageParam","lastPage","nextCursor","useUnreadCount","pollIntervalSeconds","useQuery","unreadCount","countUnread","refetchInterval","useMarkAsRead","queryClient","useQueryClient","useMutation","mutationFn","id","markAsRead","onMutate","cancelQueries","all","previousCount","getQueryData","setQueryData","current","Math","max","onError","_error","_id","context","onSettled","invalidateQueries","useMarkAllAsRead","markAllAsRead","useDeleteNotification","deleteNotification","flattenNotificationPages","pages","flatMap","page","data","useEffect","useQueryClient","subscribeToNotificationStream","useNotificationStream","options","client","useNotificationContext","queryClient","useQueryClient","enabled","onEvent","useEffect","subscription","cancelled","resolveStreamRequest","then","url","headers","subscribeToNotificationStream","event","invalidateQueries","queryKey","NOTIFICATION_QUERY_KEYS","all","close","useMutation","useQuery","useQueryClient","usePreferences","client","useNotificationContext","useQuery","queryKey","NOTIFICATION_QUERY_KEYS","preferences","queryFn","getPreferences","useUpdatePreferences","queryClient","useQueryClient","useMutation","mutationFn","updatePreferences","onSuccess","saved","setQueryData","useTemplates","templates","listTemplates"]}
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
export { DEFAULT_LOCALE, NOTIFICATION_QUERY_KEYS, NotificationContextValue, NotificationLocale, NotificationMessages, NotificationProvider, NotificationProviderProps, NotificationTheme, UseNotificationStreamOptions, UseNotificationsOptions, flattenNotificationPages, resolveMessages, useDeleteNotification, useMarkAllAsRead, useMarkAsRead, useNotificationContext, useNotificationStream, useNotifications, usePreferences, useTemplates, useUnreadCount, useUpdatePreferences } from './headless.js';
|
|
1
|
+
export { DEFAULT_LOCALE, NOTIFICATION_QUERY_KEYS, NotificationContextValue, NotificationLocale, NotificationMessages, NotificationProvider, NotificationProviderProps, NotificationTheme, TemplateDraft, UseNotificationStreamOptions, UseNotificationsOptions, UseTemplateEditorParams, UseTemplateEditorResult, flattenNotificationPages, resolveMessages, useDeleteNotification, useMarkAllAsRead, useMarkAsRead, useNotificationContext, useNotificationStream, useNotifications, usePreferences, useTemplateEditor, useTemplates, useUnreadCount, useUpdatePreferences, useUpsertTemplate } from './headless.js';
|
|
2
2
|
import * as react from 'react';
|
|
3
|
-
import {
|
|
3
|
+
import { ReactNode } from 'react';
|
|
4
|
+
import { NotificationSummary, NotificationTemplate } from '@adatechnology/notification-contracts';
|
|
4
5
|
import '@adatechnology/notification-client';
|
|
5
6
|
import '@tanstack/react-query';
|
|
6
7
|
|
|
@@ -41,4 +42,69 @@ type PreferencesPanelProps = {
|
|
|
41
42
|
};
|
|
42
43
|
declare function PreferencesPanel({ className }: PreferencesPanelProps): react.JSX.Element;
|
|
43
44
|
|
|
44
|
-
|
|
45
|
+
type NotificationsWorkspaceProps = {
|
|
46
|
+
/** Sobrescreve textos pontuais sem trocar o locale inteiro. */
|
|
47
|
+
readonly labels?: Partial<Record<string, string>>;
|
|
48
|
+
/** Filtra a inbox por assunto. Ausente, mostra tudo. */
|
|
49
|
+
readonly category?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Coluna de preferências ao lado da inbox.
|
|
52
|
+
*
|
|
53
|
+
* Ligada por padrão porque é o caso comum; um produto que gerencia preferência noutra tela passa
|
|
54
|
+
* `false` e fica só com a inbox, em largura cheia.
|
|
55
|
+
*/
|
|
56
|
+
readonly showPreferences?: boolean;
|
|
57
|
+
/** Ausente, o link de configuração não aparece — o produto pode não ter essa tela. */
|
|
58
|
+
readonly settingsHref?: string | undefined;
|
|
59
|
+
/** Clique numa notificação. Ausente, a linha não é clicável. */
|
|
60
|
+
readonly onSelectNotification?: (notification: NotificationSummary) => void;
|
|
61
|
+
/** Ações do produto no cabeçalho, ao lado do link de configuração. */
|
|
62
|
+
readonly renderHeaderActions?: () => ReactNode;
|
|
63
|
+
/** Aviso ou filtro do produto, entre o cabeçalho e a lista. */
|
|
64
|
+
readonly renderAboveList?: () => ReactNode;
|
|
65
|
+
/** Substitui o vazio padrão — útil quando o produto sabe explicar por que está vazio. */
|
|
66
|
+
readonly renderEmpty?: () => ReactNode;
|
|
67
|
+
readonly className?: string;
|
|
68
|
+
};
|
|
69
|
+
declare function NotificationsWorkspace({ labels: labelsOverride, category, showPreferences, settingsHref, onSelectNotification, renderHeaderActions, renderAboveList, renderEmpty, className, }: NotificationsWorkspaceProps): react.JSX.Element;
|
|
70
|
+
|
|
71
|
+
type NotificationChannelOption = {
|
|
72
|
+
readonly id: string;
|
|
73
|
+
readonly label: string;
|
|
74
|
+
/** O custo do canal, em uma linha. É o que faz alguém decidir em vez de chutar. */
|
|
75
|
+
readonly hint?: string;
|
|
76
|
+
};
|
|
77
|
+
type NotificationCategoryOption = {
|
|
78
|
+
readonly id: string;
|
|
79
|
+
readonly label: string;
|
|
80
|
+
readonly hint?: string;
|
|
81
|
+
};
|
|
82
|
+
type NotificationSettingsWorkspaceProps = {
|
|
83
|
+
readonly labels?: Partial<Record<string, string>>;
|
|
84
|
+
/** Os canais que ESTE produto oferece — o pacote despacha em cinco e não opina sobre quais usar. */
|
|
85
|
+
readonly channels: readonly NotificationChannelOption[];
|
|
86
|
+
/** Os assuntos que este produto dispara. */
|
|
87
|
+
readonly categories: readonly NotificationCategoryOption[];
|
|
88
|
+
/**
|
|
89
|
+
* Valores de exemplo do preview, por assunto do template. Ausente, o preview mostra campo vazio —
|
|
90
|
+
* que é honesto, mas menos útil para quem está escrevendo o texto.
|
|
91
|
+
*/
|
|
92
|
+
readonly previewPayload?: Readonly<Record<string, unknown>>;
|
|
93
|
+
/** Traduz `order.status.preparing` no rótulo que o produto usa. Ausente, mostra a chave crua. */
|
|
94
|
+
readonly templateLabelOf?: (template: NotificationTemplate) => string;
|
|
95
|
+
/**
|
|
96
|
+
* Campo extra por canal — é onde entra o nome do template aprovado na Meta, que só o WhatsApp tem.
|
|
97
|
+
* Ausente, nenhum campo extra aparece.
|
|
98
|
+
*/
|
|
99
|
+
readonly renderChannelFields?: (params: {
|
|
100
|
+
readonly channel: string;
|
|
101
|
+
readonly value: string;
|
|
102
|
+
readonly onChange: (value: string) => void;
|
|
103
|
+
}) => ReactNode;
|
|
104
|
+
/** Ações do produto no cabeçalho. */
|
|
105
|
+
readonly renderHeaderActions?: () => ReactNode;
|
|
106
|
+
readonly className?: string;
|
|
107
|
+
};
|
|
108
|
+
declare function NotificationSettingsWorkspace({ labels: labelsOverride, channels, categories, previewPayload, templateLabelOf, renderChannelFields, renderHeaderActions, className, }: NotificationSettingsWorkspaceProps): react.JSX.Element;
|
|
109
|
+
|
|
110
|
+
export { NotificationBell, type NotificationBellProps, type NotificationCategoryOption, type NotificationChannelOption, NotificationItem, type NotificationItemProps, NotificationList, type NotificationListProps, NotificationSettingsWorkspace, type NotificationSettingsWorkspaceProps, NotificationsWorkspace, type NotificationsWorkspaceProps, PreferencesPanel, type PreferencesPanelProps };
|