@classic-homes/notifications 0.1.32 → 0.1.34
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/core/index.d.ts +70 -3
- package/dist/core/index.js +128 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +128 -1
- package/package.json +1 -1
package/dist/core/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { d as NotificationListParams, c as NotificationsListResponse, b as Notification, k as ChannelsResponse, N as NotificationType, P as PreferencesResponse, U as UpdatePreferenceData, l as UpdatePreferenceResponse, B as BatchPreferenceUpdate, j as BulkPreferenceResponse, D as DeletePreferenceResponse, T as TestNotificationParams, m as TestNotificationResponse, e as NotificationChannel, g as NotificationPreference } from '../types-BSztr7EQ.js';
|
|
2
|
-
export { C as ChannelType, i as NotificationError, f as NotificationFrequency, h as NotificationPreferenceResult
|
|
1
|
+
import { d as NotificationListParams, c as NotificationsListResponse, b as Notification, k as ChannelsResponse, N as NotificationType, P as PreferencesResponse, U as UpdatePreferenceData, l as UpdatePreferenceResponse, B as BatchPreferenceUpdate, j as BulkPreferenceResponse, D as DeletePreferenceResponse, T as TestNotificationParams, m as TestNotificationResponse, e as NotificationChannel, g as NotificationPreference, a as NotificationPriority } from '../types-BSztr7EQ.js';
|
|
2
|
+
export { C as ChannelType, i as NotificationError, f as NotificationFrequency, h as NotificationPreferenceResult } from '../types-BSztr7EQ.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Notifications API
|
|
@@ -160,4 +160,71 @@ declare class NotificationService {
|
|
|
160
160
|
/** Singleton instance of NotificationService */
|
|
161
161
|
declare const notificationService: NotificationService;
|
|
162
162
|
|
|
163
|
-
|
|
163
|
+
/**
|
|
164
|
+
* Notification Utilities
|
|
165
|
+
*
|
|
166
|
+
* Framework-agnostic utility functions for working with notifications.
|
|
167
|
+
* These functions provide consistent formatting and styling helpers.
|
|
168
|
+
*/
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Badge variant type matching the Badge component variants.
|
|
172
|
+
*/
|
|
173
|
+
type BadgeVariant = 'default' | 'secondary' | 'destructive' | 'outline' | 'success' | 'warning' | 'info';
|
|
174
|
+
/**
|
|
175
|
+
* Get the icon name for a notification type.
|
|
176
|
+
* Uses icon names compatible with the Icon component.
|
|
177
|
+
*/
|
|
178
|
+
declare function getNotificationIconName(type: NotificationType): string;
|
|
179
|
+
/**
|
|
180
|
+
* Get the icon color class for a notification type.
|
|
181
|
+
* Returns Tailwind CSS color classes.
|
|
182
|
+
*/
|
|
183
|
+
declare function getNotificationIconColor(type: NotificationType): string;
|
|
184
|
+
/**
|
|
185
|
+
* Get the badge variant for a notification priority.
|
|
186
|
+
*/
|
|
187
|
+
declare function getPriorityBadgeVariant(priority: NotificationPriority): BadgeVariant;
|
|
188
|
+
/**
|
|
189
|
+
* Get the badge variant for a notification type.
|
|
190
|
+
*/
|
|
191
|
+
declare function getTypeBadgeVariant(type: NotificationType): BadgeVariant;
|
|
192
|
+
/**
|
|
193
|
+
* Get the display label for a notification priority.
|
|
194
|
+
*/
|
|
195
|
+
declare function getPriorityLabel(priority: NotificationPriority): string;
|
|
196
|
+
/**
|
|
197
|
+
* Get the display label for a notification type.
|
|
198
|
+
*/
|
|
199
|
+
declare function getTypeLabel(type: NotificationType): string;
|
|
200
|
+
/**
|
|
201
|
+
* Format a timestamp as a relative time string (e.g., "2 hours ago", "yesterday").
|
|
202
|
+
*/
|
|
203
|
+
declare function formatRelativeTime(timestamp: string): string;
|
|
204
|
+
/**
|
|
205
|
+
* Format a timestamp as a full, readable date/time string.
|
|
206
|
+
*/
|
|
207
|
+
declare function formatFullTimestamp(timestamp: string): string;
|
|
208
|
+
/**
|
|
209
|
+
* Format a timestamp for display in notification lists.
|
|
210
|
+
* Shows relative time for recent notifications, full date for older ones.
|
|
211
|
+
*/
|
|
212
|
+
declare function formatNotificationTime(timestamp: string): string;
|
|
213
|
+
/**
|
|
214
|
+
* Sort priority values for comparison (higher priority = lower number).
|
|
215
|
+
*/
|
|
216
|
+
declare function getPrioritySortValue(priority: NotificationPriority): number;
|
|
217
|
+
/**
|
|
218
|
+
* Filter function type for notifications.
|
|
219
|
+
*/
|
|
220
|
+
type NotificationFilter = 'all' | 'unread' | 'read';
|
|
221
|
+
/**
|
|
222
|
+
* Notification counts for filter tabs.
|
|
223
|
+
*/
|
|
224
|
+
interface NotificationCounts {
|
|
225
|
+
all: number;
|
|
226
|
+
unread: number;
|
|
227
|
+
read: number;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
export { type BadgeVariant, BatchPreferenceUpdate, BulkPreferenceResponse, ChannelsResponse, DeletePreferenceResponse, Notification, NotificationChannel, type NotificationCounts, type NotificationFilter, NotificationListParams, NotificationPreference, NotificationPriority, NotificationService, NotificationType, NotificationsListResponse, PreferencesResponse, TestNotificationParams, TestNotificationResponse, UpdatePreferenceData, UpdatePreferenceResponse, formatFullTimestamp, formatNotificationTime, formatRelativeTime, getNotificationIconColor, getNotificationIconName, getPriorityBadgeVariant, getPriorityLabel, getPrioritySortValue, getTypeBadgeVariant, getTypeLabel, notificationService, notificationsApi };
|
package/dist/core/index.js
CHANGED
|
@@ -255,4 +255,131 @@ var NotificationService = class {
|
|
|
255
255
|
};
|
|
256
256
|
var notificationService = new NotificationService();
|
|
257
257
|
|
|
258
|
-
|
|
258
|
+
// src/core/utils.ts
|
|
259
|
+
function getNotificationIconName(type) {
|
|
260
|
+
const iconMap = {
|
|
261
|
+
security: "shield",
|
|
262
|
+
system: "settings",
|
|
263
|
+
feature: "zap",
|
|
264
|
+
update: "refresh",
|
|
265
|
+
alert: "alert-circle",
|
|
266
|
+
info: "info"
|
|
267
|
+
};
|
|
268
|
+
return iconMap[type] ?? "bell";
|
|
269
|
+
}
|
|
270
|
+
function getNotificationIconColor(type) {
|
|
271
|
+
const colorMap = {
|
|
272
|
+
security: "text-red-500",
|
|
273
|
+
system: "text-blue-500",
|
|
274
|
+
feature: "text-purple-500",
|
|
275
|
+
update: "text-green-500",
|
|
276
|
+
alert: "text-yellow-500",
|
|
277
|
+
info: "text-gray-500"
|
|
278
|
+
};
|
|
279
|
+
return colorMap[type] ?? "text-gray-500";
|
|
280
|
+
}
|
|
281
|
+
function getPriorityBadgeVariant(priority) {
|
|
282
|
+
const variantMap = {
|
|
283
|
+
urgent: "destructive",
|
|
284
|
+
high: "warning",
|
|
285
|
+
normal: "secondary",
|
|
286
|
+
low: "outline"
|
|
287
|
+
};
|
|
288
|
+
return variantMap[priority] ?? "secondary";
|
|
289
|
+
}
|
|
290
|
+
function getTypeBadgeVariant(type) {
|
|
291
|
+
const variantMap = {
|
|
292
|
+
security: "destructive",
|
|
293
|
+
system: "info",
|
|
294
|
+
feature: "default",
|
|
295
|
+
update: "success",
|
|
296
|
+
alert: "warning",
|
|
297
|
+
info: "secondary"
|
|
298
|
+
};
|
|
299
|
+
return variantMap[type] ?? "secondary";
|
|
300
|
+
}
|
|
301
|
+
function getPriorityLabel(priority) {
|
|
302
|
+
const labelMap = {
|
|
303
|
+
urgent: "Urgent",
|
|
304
|
+
high: "High",
|
|
305
|
+
normal: "Normal",
|
|
306
|
+
low: "Low"
|
|
307
|
+
};
|
|
308
|
+
return labelMap[priority] ?? priority;
|
|
309
|
+
}
|
|
310
|
+
function getTypeLabel(type) {
|
|
311
|
+
const labelMap = {
|
|
312
|
+
security: "Security",
|
|
313
|
+
system: "System",
|
|
314
|
+
feature: "Feature",
|
|
315
|
+
update: "Update",
|
|
316
|
+
alert: "Alert",
|
|
317
|
+
info: "Info"
|
|
318
|
+
};
|
|
319
|
+
return labelMap[type] ?? type;
|
|
320
|
+
}
|
|
321
|
+
function formatRelativeTime(timestamp) {
|
|
322
|
+
const date = new Date(timestamp);
|
|
323
|
+
const now = /* @__PURE__ */ new Date();
|
|
324
|
+
const diffMs = now.getTime() - date.getTime();
|
|
325
|
+
const diffSecs = Math.floor(diffMs / 1e3);
|
|
326
|
+
const diffMins = Math.floor(diffSecs / 60);
|
|
327
|
+
const diffHours = Math.floor(diffMins / 60);
|
|
328
|
+
const diffDays = Math.floor(diffHours / 24);
|
|
329
|
+
const diffWeeks = Math.floor(diffDays / 7);
|
|
330
|
+
const diffMonths = Math.floor(diffDays / 30);
|
|
331
|
+
if (diffSecs < 60) {
|
|
332
|
+
return "just now";
|
|
333
|
+
} else if (diffMins < 60) {
|
|
334
|
+
return `${diffMins}m ago`;
|
|
335
|
+
} else if (diffHours < 24) {
|
|
336
|
+
return `${diffHours}h ago`;
|
|
337
|
+
} else if (diffDays === 1) {
|
|
338
|
+
return "yesterday";
|
|
339
|
+
} else if (diffDays < 7) {
|
|
340
|
+
return `${diffDays}d ago`;
|
|
341
|
+
} else if (diffWeeks < 4) {
|
|
342
|
+
return `${diffWeeks}w ago`;
|
|
343
|
+
} else if (diffMonths < 12) {
|
|
344
|
+
return `${diffMonths}mo ago`;
|
|
345
|
+
} else {
|
|
346
|
+
const diffYears = Math.floor(diffMonths / 12);
|
|
347
|
+
return `${diffYears}y ago`;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
function formatFullTimestamp(timestamp) {
|
|
351
|
+
const date = new Date(timestamp);
|
|
352
|
+
return date.toLocaleString(void 0, {
|
|
353
|
+
weekday: "short",
|
|
354
|
+
year: "numeric",
|
|
355
|
+
month: "short",
|
|
356
|
+
day: "numeric",
|
|
357
|
+
hour: "numeric",
|
|
358
|
+
minute: "2-digit"
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
function formatNotificationTime(timestamp) {
|
|
362
|
+
const date = new Date(timestamp);
|
|
363
|
+
const now = /* @__PURE__ */ new Date();
|
|
364
|
+
const diffMs = now.getTime() - date.getTime();
|
|
365
|
+
const diffDays = Math.floor(diffMs / (1e3 * 60 * 60 * 24));
|
|
366
|
+
if (diffDays < 7) {
|
|
367
|
+
return formatRelativeTime(timestamp);
|
|
368
|
+
} else {
|
|
369
|
+
return date.toLocaleDateString(void 0, {
|
|
370
|
+
month: "short",
|
|
371
|
+
day: "numeric"
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
function getPrioritySortValue(priority) {
|
|
376
|
+
const sortMap = {
|
|
377
|
+
urgent: 0,
|
|
378
|
+
high: 1,
|
|
379
|
+
normal: 2,
|
|
380
|
+
low: 3
|
|
381
|
+
};
|
|
382
|
+
return sortMap[priority] ?? 2;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
export { NotificationService, formatFullTimestamp, formatNotificationTime, formatRelativeTime, getNotificationIconColor, getNotificationIconName, getPriorityBadgeVariant, getPriorityLabel, getPrioritySortValue, getTypeBadgeVariant, getTypeLabel, notificationService, notificationsApi };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { NotificationService, notificationService, notificationsApi } from './core/index.js';
|
|
1
|
+
export { BadgeVariant, NotificationCounts, NotificationFilter, NotificationService, formatFullTimestamp, formatNotificationTime, formatRelativeTime, getNotificationIconColor, getNotificationIconName, getPriorityBadgeVariant, getPriorityLabel, getPrioritySortValue, getTypeBadgeVariant, getTypeLabel, notificationService, notificationsApi } from './core/index.js';
|
|
2
2
|
export { B as BatchPreferenceUpdate, j as BulkPreferenceResponse, C as ChannelType, k as ChannelsResponse, D as DeletePreferenceResponse, b as Notification, e as NotificationChannel, i as NotificationError, f as NotificationFrequency, d as NotificationListParams, g as NotificationPreference, h as NotificationPreferenceResult, a as NotificationPriority, N as NotificationType, c as NotificationsListResponse, P as PreferencesResponse, T as TestNotificationParams, m as TestNotificationResponse, U as UpdatePreferenceData, l as UpdatePreferenceResponse } from './types-BSztr7EQ.js';
|
|
3
3
|
export { isLoadingNotifications, notificationStore, notifications, unreadCount } from './svelte/index.js';
|
package/dist/index.js
CHANGED
|
@@ -255,6 +255,133 @@ var NotificationService = class {
|
|
|
255
255
|
};
|
|
256
256
|
var notificationService = new NotificationService();
|
|
257
257
|
|
|
258
|
+
// src/core/utils.ts
|
|
259
|
+
function getNotificationIconName(type) {
|
|
260
|
+
const iconMap = {
|
|
261
|
+
security: "shield",
|
|
262
|
+
system: "settings",
|
|
263
|
+
feature: "zap",
|
|
264
|
+
update: "refresh",
|
|
265
|
+
alert: "alert-circle",
|
|
266
|
+
info: "info"
|
|
267
|
+
};
|
|
268
|
+
return iconMap[type] ?? "bell";
|
|
269
|
+
}
|
|
270
|
+
function getNotificationIconColor(type) {
|
|
271
|
+
const colorMap = {
|
|
272
|
+
security: "text-red-500",
|
|
273
|
+
system: "text-blue-500",
|
|
274
|
+
feature: "text-purple-500",
|
|
275
|
+
update: "text-green-500",
|
|
276
|
+
alert: "text-yellow-500",
|
|
277
|
+
info: "text-gray-500"
|
|
278
|
+
};
|
|
279
|
+
return colorMap[type] ?? "text-gray-500";
|
|
280
|
+
}
|
|
281
|
+
function getPriorityBadgeVariant(priority) {
|
|
282
|
+
const variantMap = {
|
|
283
|
+
urgent: "destructive",
|
|
284
|
+
high: "warning",
|
|
285
|
+
normal: "secondary",
|
|
286
|
+
low: "outline"
|
|
287
|
+
};
|
|
288
|
+
return variantMap[priority] ?? "secondary";
|
|
289
|
+
}
|
|
290
|
+
function getTypeBadgeVariant(type) {
|
|
291
|
+
const variantMap = {
|
|
292
|
+
security: "destructive",
|
|
293
|
+
system: "info",
|
|
294
|
+
feature: "default",
|
|
295
|
+
update: "success",
|
|
296
|
+
alert: "warning",
|
|
297
|
+
info: "secondary"
|
|
298
|
+
};
|
|
299
|
+
return variantMap[type] ?? "secondary";
|
|
300
|
+
}
|
|
301
|
+
function getPriorityLabel(priority) {
|
|
302
|
+
const labelMap = {
|
|
303
|
+
urgent: "Urgent",
|
|
304
|
+
high: "High",
|
|
305
|
+
normal: "Normal",
|
|
306
|
+
low: "Low"
|
|
307
|
+
};
|
|
308
|
+
return labelMap[priority] ?? priority;
|
|
309
|
+
}
|
|
310
|
+
function getTypeLabel(type) {
|
|
311
|
+
const labelMap = {
|
|
312
|
+
security: "Security",
|
|
313
|
+
system: "System",
|
|
314
|
+
feature: "Feature",
|
|
315
|
+
update: "Update",
|
|
316
|
+
alert: "Alert",
|
|
317
|
+
info: "Info"
|
|
318
|
+
};
|
|
319
|
+
return labelMap[type] ?? type;
|
|
320
|
+
}
|
|
321
|
+
function formatRelativeTime(timestamp) {
|
|
322
|
+
const date = new Date(timestamp);
|
|
323
|
+
const now = /* @__PURE__ */ new Date();
|
|
324
|
+
const diffMs = now.getTime() - date.getTime();
|
|
325
|
+
const diffSecs = Math.floor(diffMs / 1e3);
|
|
326
|
+
const diffMins = Math.floor(diffSecs / 60);
|
|
327
|
+
const diffHours = Math.floor(diffMins / 60);
|
|
328
|
+
const diffDays = Math.floor(diffHours / 24);
|
|
329
|
+
const diffWeeks = Math.floor(diffDays / 7);
|
|
330
|
+
const diffMonths = Math.floor(diffDays / 30);
|
|
331
|
+
if (diffSecs < 60) {
|
|
332
|
+
return "just now";
|
|
333
|
+
} else if (diffMins < 60) {
|
|
334
|
+
return `${diffMins}m ago`;
|
|
335
|
+
} else if (diffHours < 24) {
|
|
336
|
+
return `${diffHours}h ago`;
|
|
337
|
+
} else if (diffDays === 1) {
|
|
338
|
+
return "yesterday";
|
|
339
|
+
} else if (diffDays < 7) {
|
|
340
|
+
return `${diffDays}d ago`;
|
|
341
|
+
} else if (diffWeeks < 4) {
|
|
342
|
+
return `${diffWeeks}w ago`;
|
|
343
|
+
} else if (diffMonths < 12) {
|
|
344
|
+
return `${diffMonths}mo ago`;
|
|
345
|
+
} else {
|
|
346
|
+
const diffYears = Math.floor(diffMonths / 12);
|
|
347
|
+
return `${diffYears}y ago`;
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
function formatFullTimestamp(timestamp) {
|
|
351
|
+
const date = new Date(timestamp);
|
|
352
|
+
return date.toLocaleString(void 0, {
|
|
353
|
+
weekday: "short",
|
|
354
|
+
year: "numeric",
|
|
355
|
+
month: "short",
|
|
356
|
+
day: "numeric",
|
|
357
|
+
hour: "numeric",
|
|
358
|
+
minute: "2-digit"
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
function formatNotificationTime(timestamp) {
|
|
362
|
+
const date = new Date(timestamp);
|
|
363
|
+
const now = /* @__PURE__ */ new Date();
|
|
364
|
+
const diffMs = now.getTime() - date.getTime();
|
|
365
|
+
const diffDays = Math.floor(diffMs / (1e3 * 60 * 60 * 24));
|
|
366
|
+
if (diffDays < 7) {
|
|
367
|
+
return formatRelativeTime(timestamp);
|
|
368
|
+
} else {
|
|
369
|
+
return date.toLocaleDateString(void 0, {
|
|
370
|
+
month: "short",
|
|
371
|
+
day: "numeric"
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
function getPrioritySortValue(priority) {
|
|
376
|
+
const sortMap = {
|
|
377
|
+
urgent: 0,
|
|
378
|
+
high: 1,
|
|
379
|
+
normal: 2,
|
|
380
|
+
low: 3
|
|
381
|
+
};
|
|
382
|
+
return sortMap[priority] ?? 2;
|
|
383
|
+
}
|
|
384
|
+
|
|
258
385
|
// src/svelte/stores/notifications.svelte.ts
|
|
259
386
|
var NotificationStore = class {
|
|
260
387
|
constructor() {
|
|
@@ -480,4 +607,4 @@ var isLoadingNotifications = {
|
|
|
480
607
|
}
|
|
481
608
|
};
|
|
482
609
|
|
|
483
|
-
export { NotificationService, isLoadingNotifications, notificationService, notificationStore, notifications, notificationsApi, unreadCount };
|
|
610
|
+
export { NotificationService, formatFullTimestamp, formatNotificationTime, formatRelativeTime, getNotificationIconColor, getNotificationIconName, getPriorityBadgeVariant, getPriorityLabel, getPrioritySortValue, getTypeBadgeVariant, getTypeLabel, isLoadingNotifications, notificationService, notificationStore, notifications, notificationsApi, unreadCount };
|