@adatechnology/notification-ui 0.1.0-rc.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 ADDED
@@ -0,0 +1,54 @@
1
+ # @adatechnology/notification-ui
2
+
3
+ UI de notificação em React: sino com contador, inbox paginado e painel de preferências. Em duas
4
+ camadas — **headless** (hooks, sem markup) e **componentes** (o visual pronto).
5
+
6
+ ## Instalação
7
+
8
+ ```bash
9
+ bun add @adatechnology/notification-ui
10
+ ```
11
+
12
+ Peers: `react`, `react-dom`, `@tanstack/react-query`.
13
+
14
+ ## Uso
15
+
16
+ ```tsx
17
+ import { NotificationProvider, NotificationBell } from '@adatechnology/notification-ui'
18
+ import '@adatechnology/notification-ui/styles.css'
19
+
20
+ <NotificationProvider client={notificationClient}>
21
+ <NotificationBell />
22
+ </NotificationProvider>
23
+ ```
24
+
25
+ Componentes: `NotificationBell`, `NotificationList`, `NotificationItem`, `PreferencesPanel`.
26
+
27
+ ## A camada headless é a que importa em produto com marca
28
+
29
+ ```tsx
30
+ import { useNotifications, useUnreadCount, useMarkAsRead } from '@adatechnology/notification-ui/headless'
31
+ ```
32
+
33
+ Hooks sem markup nenhum: `useNotifications` (paginação infinita), `useUnreadCount`,
34
+ `useNotificationStream`, `useMarkAsRead`, `useMarkAllAsRead`, `useDeleteNotification`,
35
+ `usePreferences`, `useUpdatePreferences`.
36
+
37
+ Existe porque componente pronto quase nunca sobrevive ao design system do produto. A alternativa
38
+ usual — aceitar 20 props de estilo — vira um tema pela porta dos fundos que não atende ninguém
39
+ direito. Com os hooks, o host escreve o próprio markup e não reimplementa cache, paginação nem
40
+ reconexão de stream.
41
+
42
+ ## Textos
43
+
44
+ Nada é hardcoded: `resolveMessages` recebe o dicionário do host. O default é pt-BR.
45
+
46
+ ## Estado de servidor
47
+
48
+ Tudo por TanStack Query — nunca `useEffect` + `useState` para carregar da API. O stream do SSE
49
+ invalida as queries em vez de escrever no cache na mão: a origem da verdade continua sendo a API,
50
+ e a tela não diverge se um evento se perder na reconexão.
51
+
52
+ ## Licença
53
+
54
+ MIT © Ada Technology
@@ -0,0 +1,139 @@
1
+ import * as react from 'react';
2
+ import { ReactNode } from 'react';
3
+ import { NotificationClient } from '@adatechnology/notification-client';
4
+ import * as _tanstack_react_query from '@tanstack/react-query';
5
+ import * as _adatechnology_notification_contracts from '@adatechnology/notification-contracts';
6
+ import { NotificationSummary, NotificationPreference } from '@adatechnology/notification-contracts';
7
+
8
+ var ptBR = {
9
+ "bell.label": "Notificações",
10
+ "bell.unreadSuffix": "não lidas",
11
+ "list.title": "Notificações",
12
+ "list.empty": "Nenhuma notificação por aqui.",
13
+ "list.loading": "Carregando…",
14
+ "list.error": "Não foi possível carregar suas notificações.",
15
+ "list.retry": "Tentar de novo",
16
+ "list.loadMore": "Carregar mais",
17
+ "list.markAllAsRead": "Marcar todas como lidas",
18
+ "item.markAsRead": "Marcar como lida",
19
+ "item.delete": "Excluir",
20
+ "item.unread": "Não lida",
21
+ "preferences.title": "Preferências de notificação",
22
+ "preferences.description": "Escolha por onde você quer ser avisado em cada assunto.",
23
+ "preferences.save": "Salvar preferências",
24
+ "preferences.saved": "Preferências salvas.",
25
+ "preferences.error": "Não foi possível salvar. Tente de novo.",
26
+ "preferences.empty": "Nenhuma preferência configurada ainda.",
27
+ "preferences.quietHours": "Silêncio 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
+ /**
37
+ * Copyright (c) 2026 Ada Technology. MIT License.
38
+ *
39
+ * Nenhum texto visível vive em tag ou prop (`web.md` §6). O host sobrescreve chaves pontuais via
40
+ * `messageOverrides` sem precisar fornecer um locale inteiro.
41
+ */
42
+
43
+ type NotificationMessages = typeof ptBR;
44
+ type NotificationLocale = 'pt-BR' | 'en';
45
+ declare const DEFAULT_LOCALE: NotificationLocale;
46
+ declare function resolveMessages(locale: NotificationLocale): NotificationMessages;
47
+
48
+ type NotificationTheme = {
49
+ /** Classe aplicada na raiz de cada componente — é por onde o host injeta os tokens dele. */
50
+ readonly rootClassName?: string;
51
+ readonly components?: Partial<Record<string, string>>;
52
+ };
53
+ type NotificationContextValue = {
54
+ readonly client: NotificationClient;
55
+ readonly messages: NotificationMessages;
56
+ readonly theme: NotificationTheme;
57
+ /** Polling de fallback quando o SSE não está disponível (segundos); `0` desliga. */
58
+ readonly pollIntervalSeconds: number;
59
+ };
60
+ type NotificationProviderProps = {
61
+ readonly client: NotificationClient;
62
+ readonly locale?: NotificationLocale;
63
+ /** Sobrescreve textos pontuais sem trocar o locale inteiro. */
64
+ readonly messageOverrides?: Partial<NotificationMessages>;
65
+ readonly theme?: NotificationTheme;
66
+ readonly pollIntervalSeconds?: number;
67
+ readonly children: ReactNode;
68
+ };
69
+ declare function NotificationProvider({ client, locale, messageOverrides, theme, pollIntervalSeconds, children, }: NotificationProviderProps): react.JSX.Element;
70
+ declare function useNotificationContext(): NotificationContextValue;
71
+
72
+ type ListNotificationsPage = {
73
+ readonly data: readonly NotificationSummary[];
74
+ readonly nextCursor?: string;
75
+ readonly unreadCount: number;
76
+ };
77
+
78
+ type UseNotificationsOptions = {
79
+ readonly category?: string;
80
+ readonly read?: boolean;
81
+ readonly perPage?: number;
82
+ };
83
+ declare function useNotifications(options?: UseNotificationsOptions): _tanstack_react_query.UseInfiniteQueryResult<_tanstack_react_query.InfiniteData<ListNotificationsPage, unknown>, Error>;
84
+ declare function useUnreadCount(): _tanstack_react_query.UseQueryResult<number, Error>;
85
+ declare function useMarkAsRead(): _tanstack_react_query.UseMutationResult<NotificationSummary, Error, string, {
86
+ previousCount: number | undefined;
87
+ id: string;
88
+ }>;
89
+ declare function useMarkAllAsRead(): _tanstack_react_query.UseMutationResult<number, Error, void, unknown>;
90
+ declare function useDeleteNotification(): _tanstack_react_query.UseMutationResult<void, Error, string, unknown>;
91
+ /** Achata as páginas do infinite query — a lista quase sempre quer o array direto. */
92
+ declare function flattenNotificationPages(pages: readonly {
93
+ data: readonly NotificationSummary[];
94
+ }[] | undefined): readonly NotificationSummary[];
95
+
96
+ /**
97
+ * Copyright (c) 2026 Ada Technology. MIT License.
98
+ */
99
+ type UseNotificationStreamOptions = {
100
+ /** Desligado por omissão: abrir SSE é decisão do host, que sabe se o backend expõe a rota. */
101
+ readonly enabled?: boolean;
102
+ readonly onEvent?: (event: {
103
+ event: string;
104
+ data: unknown;
105
+ }) => void;
106
+ };
107
+ /**
108
+ * Liga o SSE do inbox ao cache do TanStack: cada evento invalida as chaves, e o badge e a lista
109
+ * atualizam juntos. `useEffect` aqui é o uso correto do hook — sincronizar com um sistema externo
110
+ * (`react.md`, "useEffect só para sincronizar com sistemas externos"), não transformar dado.
111
+ */
112
+ declare function useNotificationStream(options?: UseNotificationStreamOptions): void;
113
+
114
+ declare function usePreferences(): _tanstack_react_query.UseQueryResult<NoInfer<readonly NotificationPreference[]>, Error>;
115
+ declare function useUpdatePreferences(): _tanstack_react_query.UseMutationResult<readonly NotificationPreference[], Error, readonly NotificationPreference[], unknown>;
116
+ declare function useTemplates(): _tanstack_react_query.UseQueryResult<NoInfer<readonly _adatechnology_notification_contracts.NotificationTemplate[]>, Error>;
117
+
118
+ /**
119
+ * Copyright (c) 2026 Ada Technology. MIT License.
120
+ *
121
+ * Chaves centralizadas: o sino e a lista leem o mesmo `unreadCount`, e uma invalidação precisa
122
+ * atingir os dois. Chave montada inline em cada hook é como badge e lista passam a mostrar
123
+ * números diferentes.
124
+ */
125
+ declare const NOTIFICATION_QUERY_KEYS: {
126
+ readonly all: readonly ["notifications"];
127
+ readonly list: (filters: {
128
+ category?: string;
129
+ read?: boolean;
130
+ }) => readonly ["notifications", "list", {
131
+ category?: string;
132
+ read?: boolean;
133
+ }];
134
+ readonly unreadCount: () => readonly ["notifications", "unread-count"];
135
+ readonly preferences: () => readonly ["notifications", "preferences"];
136
+ readonly templates: () => readonly ["notifications", "templates"];
137
+ };
138
+
139
+ export { DEFAULT_LOCALE, NOTIFICATION_QUERY_KEYS, type NotificationContextValue, type NotificationLocale, type NotificationMessages, NotificationProvider, type NotificationProviderProps, type NotificationTheme, type UseNotificationStreamOptions, type UseNotificationsOptions, flattenNotificationPages, resolveMessages, useDeleteNotification, useMarkAllAsRead, useMarkAsRead, useNotificationContext, useNotificationStream, useNotifications, usePreferences, useTemplates, useUnreadCount, useUpdatePreferences };
@@ -0,0 +1,308 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
3
+
4
+ // src/NotificationProvider.tsx
5
+ import { createContext, useContext, useMemo } from "react";
6
+
7
+ // src/locales/pt-BR.json
8
+ var pt_BR_default = {
9
+ "bell.label": "Notifica\xE7\xF5es",
10
+ "bell.unreadSuffix": "n\xE3o lidas",
11
+ "list.title": "Notifica\xE7\xF5es",
12
+ "list.empty": "Nenhuma notifica\xE7\xE3o por aqui.",
13
+ "list.loading": "Carregando\u2026",
14
+ "list.error": "N\xE3o foi poss\xEDvel carregar suas notifica\xE7\xF5es.",
15
+ "list.retry": "Tentar de novo",
16
+ "list.loadMore": "Carregar mais",
17
+ "list.markAllAsRead": "Marcar todas como lidas",
18
+ "item.markAsRead": "Marcar como lida",
19
+ "item.delete": "Excluir",
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");
291
+ export {
292
+ DEFAULT_LOCALE,
293
+ NOTIFICATION_QUERY_KEYS,
294
+ NotificationProvider,
295
+ flattenNotificationPages,
296
+ resolveMessages,
297
+ useDeleteNotification,
298
+ useMarkAllAsRead,
299
+ useMarkAsRead,
300
+ useNotificationContext,
301
+ useNotificationStream,
302
+ useNotifications,
303
+ usePreferences,
304
+ useTemplates,
305
+ useUnreadCount,
306
+ useUpdatePreferences
307
+ };
308
+ //# sourceMappingURL=headless.js.map
@@ -0,0 +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,c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","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"]}
@@ -0,0 +1,44 @@
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';
2
+ import * as react from 'react';
3
+ import { NotificationSummary } from '@adatechnology/notification-contracts';
4
+ import '@adatechnology/notification-client';
5
+ import '@tanstack/react-query';
6
+
7
+ /**
8
+ * Copyright (c) 2026 Ada Technology. MIT License.
9
+ */
10
+ type NotificationBellProps = {
11
+ readonly onClick?: () => void;
12
+ readonly className?: string;
13
+ /** Acima disso o badge mostra `99+`; um número de 4 dígitos estoura o desenho do badge. */
14
+ readonly maxBadgeCount?: number;
15
+ };
16
+ declare function NotificationBell({ onClick, className, maxBadgeCount }: NotificationBellProps): react.JSX.Element;
17
+
18
+ type NotificationItemProps = {
19
+ readonly notification: NotificationSummary;
20
+ readonly onSelect?: (notification: NotificationSummary) => void;
21
+ readonly className?: string;
22
+ };
23
+ declare function NotificationItem({ notification, onSelect, className }: NotificationItemProps): react.JSX.Element;
24
+
25
+ type NotificationListProps = {
26
+ readonly category?: string;
27
+ readonly onSelect?: (notification: NotificationSummary) => void;
28
+ readonly className?: string;
29
+ /** Slot: o host troca a linha sem reimplementar a lista (regra §4.3, slots e overrides). */
30
+ readonly components?: {
31
+ readonly Item?: typeof NotificationItem;
32
+ };
33
+ };
34
+ declare function NotificationList({ category, onSelect, className, components }: NotificationListProps): react.JSX.Element;
35
+
36
+ /**
37
+ * Copyright (c) 2026 Ada Technology. MIT License.
38
+ */
39
+ type PreferencesPanelProps = {
40
+ readonly className?: string;
41
+ };
42
+ declare function PreferencesPanel({ className }: PreferencesPanelProps): react.JSX.Element;
43
+
44
+ export { NotificationBell, type NotificationBellProps, NotificationItem, type NotificationItemProps, NotificationList, type NotificationListProps, PreferencesPanel, type PreferencesPanelProps };