analytica-frontend-lib 1.1.35 → 1.1.37

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.
@@ -0,0 +1,402 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { ReactNode } from 'react';
3
+
4
+ /**
5
+ * Types for notification system
6
+ */
7
+ /**
8
+ * Notification type enum
9
+ */
10
+ type NotificationType = 'ACTIVITY' | 'TRAIL' | 'GOAL' | 'ANNOUNCEMENT' | 'GENERAL';
11
+ /**
12
+ * Entity type for navigation
13
+ */
14
+ declare enum NotificationEntityType {
15
+ ACTIVITY = "ACTIVITY",
16
+ TRAIL = "TRAIL",
17
+ GOAL = "GOAL"
18
+ }
19
+ /**
20
+ * Notification interface
21
+ */
22
+ interface Notification {
23
+ /**
24
+ * Unique identifier for the notification
25
+ */
26
+ id: string;
27
+ /**
28
+ * Notification title
29
+ */
30
+ title: string;
31
+ /**
32
+ * Notification message content
33
+ */
34
+ message: string;
35
+ /**
36
+ * Type of notification
37
+ */
38
+ type: NotificationType;
39
+ /**
40
+ * Whether the notification has been read
41
+ */
42
+ isRead: boolean;
43
+ /**
44
+ * When the notification was created
45
+ */
46
+ createdAt: Date;
47
+ /**
48
+ * Type of entity this notification refers to (optional)
49
+ */
50
+ entityType?: NotificationEntityType | null;
51
+ /**
52
+ * ID of the entity this notification refers to (optional)
53
+ */
54
+ entityId?: string | null;
55
+ /**
56
+ * Sender information (optional)
57
+ */
58
+ sender?: {
59
+ id: string;
60
+ user: {
61
+ id: string;
62
+ name: string;
63
+ email: string;
64
+ };
65
+ } | null;
66
+ /**
67
+ * Activity information (optional)
68
+ */
69
+ activity?: {
70
+ id: string;
71
+ title: string;
72
+ type: string;
73
+ } | null;
74
+ /**
75
+ * Goal information (optional)
76
+ */
77
+ goal?: {
78
+ id: string;
79
+ title: string;
80
+ } | null;
81
+ }
82
+ /**
83
+ * Backend notification response from API
84
+ */
85
+ interface BackendNotification {
86
+ id: string;
87
+ senderUserInstitutionId: string | null;
88
+ receiverUserInstitutionId: string;
89
+ title: string;
90
+ description: string;
91
+ entityType: string | null;
92
+ entityId: string | null;
93
+ read: boolean;
94
+ createdAt: string;
95
+ updatedAt: string;
96
+ sender?: {
97
+ id: string;
98
+ user: {
99
+ id: string;
100
+ name: string;
101
+ email: string;
102
+ };
103
+ } | null;
104
+ activity?: {
105
+ id: string;
106
+ title: string;
107
+ type: string;
108
+ } | null;
109
+ goal?: {
110
+ id: string;
111
+ title: string;
112
+ } | null;
113
+ }
114
+ /**
115
+ * API response for fetching notifications from backend
116
+ */
117
+ interface BackendNotificationsResponse {
118
+ notifications: BackendNotification[];
119
+ pagination: {
120
+ page: number;
121
+ limit: number;
122
+ total: number;
123
+ totalPages: number;
124
+ };
125
+ }
126
+ /**
127
+ * API response for fetching notifications (frontend format)
128
+ */
129
+ interface NotificationsResponse {
130
+ /**
131
+ * List of notifications
132
+ */
133
+ notifications: Notification[];
134
+ /**
135
+ * Total count of notifications
136
+ */
137
+ totalCount: number;
138
+ /**
139
+ * Count of unread notifications
140
+ */
141
+ unreadCount: number;
142
+ /**
143
+ * Whether there are more notifications to load
144
+ */
145
+ hasMore: boolean;
146
+ }
147
+ /**
148
+ * Parameters for fetching notifications
149
+ */
150
+ interface FetchNotificationsParams {
151
+ /**
152
+ * Page number for pagination
153
+ */
154
+ page?: number;
155
+ /**
156
+ * Number of items per page
157
+ */
158
+ limit?: number;
159
+ /**
160
+ * Filter by read status
161
+ */
162
+ read?: boolean;
163
+ /**
164
+ * Filter by entity type
165
+ */
166
+ entityType?: string;
167
+ }
168
+ /**
169
+ * Notification grouped by time period
170
+ */
171
+ interface NotificationGroup {
172
+ /**
173
+ * Group label (e.g., "Hoje", "Última semana")
174
+ */
175
+ label: string;
176
+ /**
177
+ * Notifications in this group
178
+ */
179
+ notifications: Notification[];
180
+ }
181
+ /**
182
+ * API client interface for dependency injection
183
+ */
184
+ interface NotificationApiClient {
185
+ get: <T>(url: string, config?: {
186
+ params?: Record<string, unknown>;
187
+ }) => Promise<{
188
+ data: T;
189
+ }>;
190
+ patch: <T>(url: string, data?: Record<string, unknown>) => Promise<{
191
+ data: T;
192
+ }>;
193
+ delete: <T>(url: string) => Promise<{
194
+ data: T;
195
+ }>;
196
+ }
197
+
198
+ interface NotificationItem extends Omit<Notification, 'createdAt'> {
199
+ time: string;
200
+ createdAt: string | Date;
201
+ }
202
+ interface BaseNotificationProps {
203
+ /**
204
+ * Additional CSS classes
205
+ */
206
+ className?: string;
207
+ /**
208
+ * Empty state image path
209
+ */
210
+ emptyStateImage?: string;
211
+ /**
212
+ * Empty state title
213
+ */
214
+ emptyStateTitle?: string;
215
+ /**
216
+ * Empty state description
217
+ */
218
+ emptyStateDescription?: string;
219
+ }
220
+ interface SingleNotificationCardMode extends BaseNotificationProps {
221
+ /**
222
+ * Component mode - single card
223
+ */
224
+ mode: 'single';
225
+ /**
226
+ * The notification title
227
+ */
228
+ title: string;
229
+ /**
230
+ * The notification message content
231
+ */
232
+ message: string;
233
+ /**
234
+ * Time displayed (e.g., "Há 3h", "12 Fev")
235
+ */
236
+ time: string;
237
+ /**
238
+ * Whether the notification has been read
239
+ */
240
+ isRead: boolean;
241
+ /**
242
+ * Callback when user marks notification as read
243
+ */
244
+ onMarkAsRead: () => void;
245
+ /**
246
+ * Callback when user deletes notification
247
+ */
248
+ onDelete: () => void;
249
+ /**
250
+ * Optional callback for navigation action
251
+ */
252
+ onNavigate?: () => void;
253
+ /**
254
+ * Label for the action button (only shown if onNavigate is provided)
255
+ */
256
+ actionLabel?: string;
257
+ }
258
+ interface NotificationListMode extends BaseNotificationProps {
259
+ /**
260
+ * Component mode - list
261
+ */
262
+ mode: 'list';
263
+ /**
264
+ * Array of notifications for list mode
265
+ */
266
+ notifications?: NotificationItem[];
267
+ /**
268
+ * Array of grouped notifications
269
+ */
270
+ groupedNotifications?: NotificationGroup[];
271
+ /**
272
+ * Loading state for list mode
273
+ */
274
+ loading?: boolean;
275
+ /**
276
+ * Error state for list mode
277
+ */
278
+ error?: string | null;
279
+ /**
280
+ * Callback for retry when error occurs
281
+ */
282
+ onRetry?: () => void;
283
+ /**
284
+ * Callback when user marks a notification as read in list mode
285
+ */
286
+ onMarkAsReadById?: (id: string) => void;
287
+ /**
288
+ * Callback when user deletes a notification in list mode
289
+ */
290
+ onDeleteById?: (id: string) => void;
291
+ /**
292
+ * Callback when user navigates from a notification in list mode
293
+ */
294
+ onNavigateById?: (entityType?: NotificationEntityType, entityId?: string) => void;
295
+ /**
296
+ * Function to get action label for a notification
297
+ */
298
+ getActionLabel?: (entityType?: NotificationEntityType) => string | undefined;
299
+ /**
300
+ * Custom empty state component
301
+ */
302
+ renderEmpty?: () => ReactNode;
303
+ }
304
+ interface NotificationCenterMode extends BaseNotificationProps {
305
+ /**
306
+ * Component mode - center
307
+ */
308
+ mode: 'center';
309
+ /**
310
+ * Array of grouped notifications
311
+ */
312
+ groupedNotifications?: NotificationGroup[];
313
+ /**
314
+ * Loading state for center mode
315
+ */
316
+ loading?: boolean;
317
+ /**
318
+ * Error state for center mode
319
+ */
320
+ error?: string | null;
321
+ /**
322
+ * Callback for retry when error occurs
323
+ */
324
+ onRetry?: () => void;
325
+ /**
326
+ * Whether center mode is currently active (controls dropdown/modal visibility)
327
+ */
328
+ isActive?: boolean;
329
+ /**
330
+ * Callback when center mode is toggled
331
+ */
332
+ onToggleActive?: () => void;
333
+ /**
334
+ * Number of unread notifications for badge display
335
+ */
336
+ unreadCount?: number;
337
+ /**
338
+ * Callback when all notifications should be marked as read
339
+ */
340
+ onMarkAllAsRead?: () => void;
341
+ /**
342
+ * Callback to fetch notifications (called when center opens)
343
+ */
344
+ onFetchNotifications?: () => void;
345
+ /**
346
+ * Callback when user marks a notification as read in center mode
347
+ */
348
+ onMarkAsReadById?: (id: string) => void;
349
+ /**
350
+ * Callback when user deletes a notification in center mode
351
+ */
352
+ onDeleteById?: (id: string) => void;
353
+ /**
354
+ * Callback when user navigates from a notification in center mode
355
+ */
356
+ onNavigateById?: (entityType?: NotificationEntityType, entityId?: string) => void;
357
+ /**
358
+ * Function to get action label for a notification
359
+ */
360
+ getActionLabel?: (entityType?: NotificationEntityType) => string | undefined;
361
+ }
362
+ type NotificationCardProps = SingleNotificationCardMode | NotificationListMode | NotificationCenterMode;
363
+ interface LegacyNotificationCardProps extends BaseNotificationProps {
364
+ title?: string;
365
+ message?: string;
366
+ time?: string;
367
+ isRead?: boolean;
368
+ onMarkAsRead?: () => void;
369
+ onDelete?: () => void;
370
+ onNavigate?: () => void;
371
+ actionLabel?: string;
372
+ notifications?: NotificationItem[];
373
+ groupedNotifications?: NotificationGroup[];
374
+ loading?: boolean;
375
+ error?: string | null;
376
+ onRetry?: () => void;
377
+ onMarkAsReadById?: (id: string) => void;
378
+ onDeleteById?: (id: string) => void;
379
+ onNavigateById?: (entityType?: NotificationEntityType, entityId?: string) => void;
380
+ getActionLabel?: (entityType?: NotificationEntityType) => string | undefined;
381
+ renderEmpty?: () => ReactNode;
382
+ variant?: 'card' | 'center';
383
+ isActive?: boolean;
384
+ onToggleActive?: () => void;
385
+ unreadCount?: number;
386
+ onMarkAllAsRead?: () => void;
387
+ onFetchNotifications?: () => void;
388
+ }
389
+ /**
390
+ * NotificationCard component - can display single notification, list of notifications, or center mode
391
+ *
392
+ * @param props - The notification card properties
393
+ * @returns JSX element representing the notification card, list, or center
394
+ */
395
+ declare const NotificationCard: (props: NotificationCardProps) => react_jsx_runtime.JSX.Element;
396
+ /**
397
+ * Legacy NotificationCard component for backward compatibility
398
+ * Automatically detects mode based on provided props
399
+ */
400
+ declare const LegacyNotificationCard: (props: LegacyNotificationCardProps) => react_jsx_runtime.JSX.Element;
401
+
402
+ export { type BackendNotification as B, type FetchNotificationsParams as F, type LegacyNotificationCardProps as L, type NotificationApiClient as N, type Notification as a, type NotificationGroup as b, NotificationCard as c, type NotificationItem as d, NotificationEntityType as e, type NotificationType as f, type BackendNotificationsResponse as g, type NotificationsResponse as h, type NotificationCardProps as i, LegacyNotificationCard as j };