@cellarnode/ui 0.5.0 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (120) hide show
  1. package/dist/chat/chat-toggle-button.d.ts +4 -3
  2. package/dist/chat/chat-toggle-button.d.ts.map +1 -1
  3. package/dist/chat/chat-toggle-button.js +34 -8
  4. package/dist/chat/chat-toggle-button.js.map +1 -1
  5. package/dist/components/classification-select.d.ts.map +1 -1
  6. package/dist/components/classification-select.js +2 -3
  7. package/dist/components/classification-select.js.map +1 -1
  8. package/dist/components/dashboard-stats-grid.d.ts +29 -0
  9. package/dist/components/dashboard-stats-grid.d.ts.map +1 -0
  10. package/dist/components/dashboard-stats-grid.js +62 -0
  11. package/dist/components/dashboard-stats-grid.js.map +1 -0
  12. package/dist/components/period-select.d.ts +10 -0
  13. package/dist/components/period-select.d.ts.map +1 -0
  14. package/dist/components/period-select.js +14 -0
  15. package/dist/components/period-select.js.map +1 -0
  16. package/dist/components/select.d.ts.map +1 -1
  17. package/dist/components/select.js +1 -1
  18. package/dist/components/select.js.map +1 -1
  19. package/dist/globe/globe-canvas.d.ts +31 -9
  20. package/dist/globe/globe-canvas.d.ts.map +1 -1
  21. package/dist/globe/globe-canvas.js +123 -105
  22. package/dist/globe/globe-canvas.js.map +1 -1
  23. package/dist/globe/globe-scene.d.ts +5 -2
  24. package/dist/globe/globe-scene.d.ts.map +1 -1
  25. package/dist/globe/globe-scene.js +37 -13
  26. package/dist/globe/globe-scene.js.map +1 -1
  27. package/dist/globe/globe-view.d.ts +20 -1
  28. package/dist/globe/globe-view.d.ts.map +1 -1
  29. package/dist/globe/globe-view.js +2 -2
  30. package/dist/globe/globe-view.js.map +1 -1
  31. package/dist/globe/index.d.ts +40 -0
  32. package/dist/globe/index.d.ts.map +1 -1
  33. package/dist/globe/index.js +39 -0
  34. package/dist/globe/index.js.map +1 -1
  35. package/dist/index.d.ts +5 -1
  36. package/dist/index.d.ts.map +1 -1
  37. package/dist/index.js +3 -1
  38. package/dist/index.js.map +1 -1
  39. package/dist/lib/semantic-tones.d.ts +1 -0
  40. package/dist/lib/semantic-tones.d.ts.map +1 -1
  41. package/dist/lib/semantic-tones.js +19 -0
  42. package/dist/lib/semantic-tones.js.map +1 -1
  43. package/dist/notifications/constants.d.ts +46 -0
  44. package/dist/notifications/constants.d.ts.map +1 -0
  45. package/dist/notifications/constants.js +89 -0
  46. package/dist/notifications/constants.js.map +1 -0
  47. package/dist/notifications/index.d.ts +21 -0
  48. package/dist/notifications/index.d.ts.map +1 -0
  49. package/dist/notifications/index.js +19 -0
  50. package/dist/notifications/index.js.map +1 -0
  51. package/dist/notifications/notification-badge.d.ts +8 -0
  52. package/dist/notifications/notification-badge.d.ts.map +1 -0
  53. package/dist/notifications/notification-badge.js +9 -0
  54. package/dist/notifications/notification-badge.js.map +1 -0
  55. package/dist/notifications/notification-empty-state.d.ts +8 -0
  56. package/dist/notifications/notification-empty-state.d.ts.map +1 -0
  57. package/dist/notifications/notification-empty-state.js +7 -0
  58. package/dist/notifications/notification-empty-state.js.map +1 -0
  59. package/dist/notifications/notification-item.d.ts +13 -0
  60. package/dist/notifications/notification-item.d.ts.map +1 -0
  61. package/dist/notifications/notification-item.js +95 -0
  62. package/dist/notifications/notification-item.js.map +1 -0
  63. package/dist/notifications/notification-list.d.ts +19 -0
  64. package/dist/notifications/notification-list.d.ts.map +1 -0
  65. package/dist/notifications/notification-list.js +53 -0
  66. package/dist/notifications/notification-list.js.map +1 -0
  67. package/dist/notifications/notification-page.d.ts +6 -0
  68. package/dist/notifications/notification-page.d.ts.map +1 -0
  69. package/dist/notifications/notification-page.js +36 -0
  70. package/dist/notifications/notification-page.js.map +1 -0
  71. package/dist/notifications/notification-provider.d.ts +10 -0
  72. package/dist/notifications/notification-provider.d.ts.map +1 -0
  73. package/dist/notifications/notification-provider.js +14 -0
  74. package/dist/notifications/notification-provider.js.map +1 -0
  75. package/dist/notifications/notification-tray.d.ts +7 -0
  76. package/dist/notifications/notification-tray.d.ts.map +1 -0
  77. package/dist/notifications/notification-tray.js +46 -0
  78. package/dist/notifications/notification-tray.js.map +1 -0
  79. package/dist/notifications/push-prompt-banner.d.ts +15 -0
  80. package/dist/notifications/push-prompt-banner.d.ts.map +1 -0
  81. package/dist/notifications/push-prompt-banner.js +11 -0
  82. package/dist/notifications/push-prompt-banner.js.map +1 -0
  83. package/dist/notifications/types.d.ts +64 -0
  84. package/dist/notifications/types.d.ts.map +1 -0
  85. package/dist/notifications/types.js +2 -0
  86. package/dist/notifications/types.js.map +1 -0
  87. package/dist/notifications/use-notification-socket.d.ts +2 -0
  88. package/dist/notifications/use-notification-socket.d.ts.map +1 -0
  89. package/dist/notifications/use-notification-socket.js +35 -0
  90. package/dist/notifications/use-notification-socket.js.map +1 -0
  91. package/dist/notifications/use-notifications.d.ts +10 -0
  92. package/dist/notifications/use-notifications.d.ts.map +1 -0
  93. package/dist/notifications/use-notifications.js +43 -0
  94. package/dist/notifications/use-notifications.js.map +1 -0
  95. package/dist/notifications/use-push-permission.d.ts +8 -0
  96. package/dist/notifications/use-push-permission.d.ts.map +1 -0
  97. package/dist/notifications/use-push-permission.js +36 -0
  98. package/dist/notifications/use-push-permission.js.map +1 -0
  99. package/dist/notifications/utils.d.ts +20 -0
  100. package/dist/notifications/utils.d.ts.map +1 -0
  101. package/dist/notifications/utils.js +81 -0
  102. package/dist/notifications/utils.js.map +1 -0
  103. package/dist/offer/index.d.ts +6 -0
  104. package/dist/offer/index.d.ts.map +1 -1
  105. package/dist/offer/index.js +3 -0
  106. package/dist/offer/index.js.map +1 -1
  107. package/dist/offer/offer-detail-header.d.ts +12 -0
  108. package/dist/offer/offer-detail-header.d.ts.map +1 -0
  109. package/dist/offer/offer-detail-header.js +11 -0
  110. package/dist/offer/offer-detail-header.js.map +1 -0
  111. package/dist/offer/offer-detail-shell.d.ts +12 -0
  112. package/dist/offer/offer-detail-shell.d.ts.map +1 -0
  113. package/dist/offer/offer-detail-shell.js +13 -0
  114. package/dist/offer/offer-detail-shell.js.map +1 -0
  115. package/dist/offer/offer-detail-tabs.d.ts +14 -0
  116. package/dist/offer/offer-detail-tabs.d.ts.map +1 -0
  117. package/dist/offer/offer-detail-tabs.js +9 -0
  118. package/dist/offer/offer-detail-tabs.js.map +1 -0
  119. package/package.json +16 -36
  120. package/src/theme/tokens.css +29 -0
@@ -0,0 +1,19 @@
1
+ import type { Notification } from "./types";
2
+ export interface NotificationListProps {
3
+ notifications: Notification[];
4
+ isLoading?: boolean;
5
+ onMarkRead?: (id: string) => void;
6
+ onDismiss?: (id: string) => void;
7
+ onNavigate?: (href: string) => void;
8
+ onLoadMore?: () => void;
9
+ hasMore?: boolean;
10
+ showFilters?: boolean;
11
+ showGroups?: boolean;
12
+ compact?: boolean;
13
+ maxItems?: number;
14
+ className?: string;
15
+ emptyTitle?: string;
16
+ emptyDescription?: string;
17
+ }
18
+ export declare function NotificationList({ notifications, isLoading, onMarkRead, onDismiss, onNavigate, onLoadMore, hasMore, showFilters, showGroups, compact, maxItems, className, emptyTitle, emptyDescription, }: NotificationListProps): import("react/jsx-runtime").JSX.Element;
19
+ //# sourceMappingURL=notification-list.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notification-list.d.ts","sourceRoot":"","sources":["../../src/notifications/notification-list.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,YAAY,EAAqB,MAAM,SAAS,CAAC;AAG/D,MAAM,WAAW,qBAAqB;IACpC,aAAa,EAAE,YAAY,EAAE,CAAC;IAC9B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,UAAU,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,SAAS,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;IACjC,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,UAAU,CAAC,EAAE,MAAM,IAAI,CAAC;IACxB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AA6CD,wBAAgB,gBAAgB,CAAC,EAC/B,aAAa,EACb,SAAS,EACT,UAAU,EACV,SAAS,EACT,UAAU,EACV,UAAU,EACV,OAAO,EACP,WAAmB,EACnB,UAAkB,EAClB,OAAe,EACf,QAAQ,EACR,SAAS,EACT,UAAU,EACV,gBAAgB,GACjB,EAAE,qBAAqB,2CAmHvB"}
@@ -0,0 +1,53 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // ui/src/notifications/notification-list.tsx
3
+ import { useState, useMemo } from "react";
4
+ import { AnimatePresence } from "motion/react";
5
+ import { ChevronDown } from "lucide-react";
6
+ import { cn } from "../lib/utils";
7
+ import { NotificationItem } from "./notification-item";
8
+ import { NotificationEmptyState } from "./notification-empty-state";
9
+ import { groupNotifications, filterNotifications } from "./utils";
10
+ import { FILTER_OPTIONS } from "./constants";
11
+ import { useNotificationConfig } from "./notification-provider";
12
+ function GroupHeader({ group, collapsed, onToggle, }) {
13
+ if (group.category === "recent") {
14
+ return (_jsxs("div", { className: "flex items-center gap-3 px-1 pt-4 pb-2", children: [_jsx("span", { className: "text-xs font-semibold uppercase tracking-wider text-muted-foreground/60", children: group.label }), _jsx("div", { className: "h-px flex-1 bg-border/50" })] }));
15
+ }
16
+ return (_jsxs("button", { type: "button", onClick: onToggle, className: "flex w-full items-center gap-3 px-1 pt-6 pb-2", children: [_jsx("span", { className: "text-xs font-semibold uppercase tracking-wider text-muted-foreground/60", children: group.label }), _jsxs("span", { className: "text-[10px] tabular-nums text-muted-foreground/40", children: ["(", group.notifications.length, ")"] }), _jsx("div", { className: "h-px flex-1 bg-border/50" }), _jsx(ChevronDown, { className: cn("size-3.5 text-muted-foreground/40 transition-transform", collapsed && "-rotate-90") })] }));
17
+ }
18
+ export function NotificationList({ notifications, isLoading, onMarkRead, onDismiss, onNavigate, onLoadMore, hasMore, showFilters = false, showGroups = false, compact = false, maxItems, className, emptyTitle, emptyDescription, }) {
19
+ const { resolveRoute, t } = useNotificationConfig();
20
+ const [filter, setFilter] = useState("all");
21
+ const [collapsedGroups, setCollapsedGroups] = useState(new Set());
22
+ const filtered = useMemo(() => filterNotifications(notifications, filter), [notifications, filter]);
23
+ const display = maxItems ? filtered.slice(0, maxItems) : filtered;
24
+ const groups = useMemo(() => {
25
+ if (!showGroups || filter === "unread")
26
+ return null;
27
+ return groupNotifications(display, t);
28
+ }, [display, showGroups, filter, t]);
29
+ const toggleGroup = (category) => {
30
+ setCollapsedGroups((prev) => {
31
+ const next = new Set(prev);
32
+ if (next.has(category))
33
+ next.delete(category);
34
+ else
35
+ next.add(category);
36
+ return next;
37
+ });
38
+ };
39
+ const renderItem = (n, idx) => {
40
+ const href = resolveRoute(n.type, n.data);
41
+ return (_jsx(NotificationItem, { notification: n, onMarkRead: onMarkRead, onDismiss: onDismiss, onNavigate: onNavigate, href: href, index: idx, compact: compact }, n.id));
42
+ };
43
+ if (isLoading) {
44
+ return (_jsx("div", { className: cn("flex items-center justify-center py-12", className), children: _jsx("div", { className: "size-6 rounded-full border-2 border-primary border-t-transparent animate-spin" }) }));
45
+ }
46
+ return (_jsxs("div", { className: cn("flex flex-col", className), children: [showFilters && (_jsx("div", { className: "flex flex-wrap items-center gap-2 px-1 pb-4", children: FILTER_OPTIONS.map((opt) => (_jsx("button", { type: "button", onClick: () => setFilter(opt.key), className: cn("rounded-lg px-3 py-1.5 text-xs font-medium transition-all", filter === opt.key
47
+ ? "bg-linear-to-br from-primary/12 to-primary/5 border border-primary/15 text-primary"
48
+ : "text-muted-foreground hover:text-foreground hover:bg-muted/50"), children: t ? t(opt.labelKey, opt.label) : opt.label }, opt.key))) })), display.length === 0 ? (_jsx(NotificationEmptyState, { title: emptyTitle, description: emptyDescription })) : groups ? (_jsx("div", { className: "flex flex-col gap-1", children: groups.map((group) => {
49
+ const isCollapsed = collapsedGroups.has(group.category);
50
+ return (_jsxs("div", { children: [_jsx(GroupHeader, { group: group, collapsed: isCollapsed, onToggle: () => toggleGroup(group.category) }), !isCollapsed && (_jsx(AnimatePresence, { mode: "popLayout", children: _jsx("div", { className: "flex flex-col gap-2", children: group.notifications.map((n, i) => renderItem(n, i)) }) }))] }, group.category));
51
+ }) })) : (_jsx(AnimatePresence, { mode: "popLayout", children: _jsx("div", { className: "flex flex-col gap-2", children: display.map((n, i) => renderItem(n, i)) }) })), hasMore && onLoadMore && (_jsx("button", { type: "button", onClick: onLoadMore, className: "mt-4 self-center rounded-lg px-4 py-2 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground hover:bg-muted/50", children: t ? t("loadMore", "Load more notifications") : "Load more notifications" }))] }));
52
+ }
53
+ //# sourceMappingURL=notification-list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notification-list.js","sourceRoot":"","sources":["../../src/notifications/notification-list.tsx"],"names":[],"mappings":";AAAA,6CAA6C;AAC7C,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,EAAE,cAAc,EAA2B,MAAM,aAA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AK,EAAE,KAAK,EACZ,SAAS,EAAE,WAAW,EACtB,QAAQ,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,KAAK,CAAC,QAAQ,CAAC,GAC3C,EACD,CAAC,WAAW,IAAI,CACf,KAAC,eAAe,IAAC,IAAI,EAAC,WAAW,YAC/B,cAAK,SAAS,EAAC,qBAAqB,YACjC,KAAK,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAChD,GACU,CACnB,KAZO,KAAK,CAAC,QAAQ,CAalB,CACP,CAAC;gBACJ,CAAC,CAAC,GACE,CACP,CAAC,CAAC,CAAC,CACF,KAAC,eAAe,IAAC,IAAI,EAAC,WAAW,YAC/B,cAAK,SAAS,EAAC,qBAAqB,YACjC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GACpC,GACU,CACnB,EAEA,OAAO,IAAI,UAAU,IAAI,CACxB,iBACE,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,UAAU,EACnB,SAAS,EAAC,2IAA2I,YAEpJ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,EAAE,yBAAyB,CAAC,CAAC,CAAC,CAAC,yBAAyB,GAClE,CACV,IACG,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,6 @@
1
+ export interface NotificationPageProps {
2
+ onNavigate?: (href: string) => void;
3
+ className?: string;
4
+ }
5
+ export declare function NotificationPage({ onNavigate, className }: NotificationPageProps): import("react/jsx-runtime").JSX.Element;
6
+ //# sourceMappingURL=notification-page.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notification-page.d.ts","sourceRoot":"","sources":["../../src/notifications/notification-page.tsx"],"names":[],"mappings":"AASA,MAAM,WAAW,qBAAqB;IACpC,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,gBAAgB,CAAC,EAAE,UAAU,EAAE,SAAS,EAAE,EAAE,qBAAqB,2CAyFhF"}
@@ -0,0 +1,36 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useMemo } from "react";
3
+ import { CheckCheck } from "lucide-react";
4
+ import { cn } from "../lib/utils";
5
+ import { NotificationList } from "./notification-list";
6
+ import { PushPromptBanner } from "./push-prompt-banner";
7
+ import { useNotifications, useUnreadCount, useNotificationActions } from "./use-notifications";
8
+ import { usePushPermission } from "./use-push-permission";
9
+ import { useNotificationConfig } from "./notification-provider";
10
+ export function NotificationPage({ onNavigate, className }) {
11
+ const { t } = useNotificationConfig();
12
+ const { data, isLoading, fetchNextPage, hasNextPage, isFetchingNextPage } = useNotifications();
13
+ const { data: unread } = useUnreadCount();
14
+ const { markRead, markAllRead, dismiss } = useNotificationActions();
15
+ const unreadCount = unread?.count ?? 0;
16
+ const push = usePushPermission(unreadCount);
17
+ const notifications = useMemo(() => {
18
+ if (!data?.pages)
19
+ return [];
20
+ return data.pages.flatMap((p) => p.notifications);
21
+ }, [data]);
22
+ const totalCount = notifications.length;
23
+ return (_jsxs("div", { className: cn("mx-auto w-full max-w-2xl", className), children: [_jsxs("div", { className: "flex items-center justify-between pb-6", children: [_jsxs("div", { children: [_jsx("h1", { className: "text-xl font-bold text-foreground", children: t ? t("page.heading", "Notifications") : "Notifications" }), totalCount > 0 && (_jsxs("p", { className: "mt-1 text-sm text-muted-foreground", children: [t
24
+ ? t("page.countSummary", "{{count}} notifications", { count: totalCount })
25
+ : `${totalCount} notification${totalCount === 1 ? "" : "s"}`, unreadCount > 0 && (_jsx("span", { className: "ml-2 text-primary font-medium", children: t
26
+ ? t("page.unreadCount", "{{count}} unread", { count: unreadCount })
27
+ : `${unreadCount} unread` }))] }))] }), unreadCount > 0 && (_jsxs("button", { type: "button", onClick: () => markAllRead.mutate(), className: "flex items-center gap-1.5 rounded-lg px-3 py-1.5 text-xs font-medium text-primary transition-colors hover:bg-primary/10", children: [_jsx(CheckCheck, { className: "size-3.5" }), t ? t("page.markAllRead", "Mark all read") : "Mark all read"] }))] }), push.shouldShowPrompt && (_jsx("div", { className: "pb-6", children: _jsx(PushPromptBanner, { variant: "rich", onEnable: () => push.requestPermission(), onDismiss: () => push.dismissPrompt(), labels: t
28
+ ? {
29
+ heading: t("push.heading", "Never miss an update"),
30
+ description: t("push.description", "Get instant desktop notifications when producers respond to your offers or new matches are found."),
31
+ enable: t("push.enable", "Enable Notifications"),
32
+ dismiss: t("push.dismiss", "Maybe later"),
33
+ }
34
+ : undefined }) })), _jsx(NotificationList, { notifications: notifications, isLoading: isLoading, onMarkRead: (id) => markRead.mutate(id), onDismiss: (id) => dismiss.mutate(id), onNavigate: onNavigate, onLoadMore: () => fetchNextPage(), hasMore: hasNextPage && !isFetchingNextPage, showFilters: true, showGroups: true })] }));
35
+ }
36
+ //# sourceMappingURL=notification-page.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notification-page.js","sourceRoot":"","sources":["../../src/notifications/notification-page.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC/F,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAOhE,MAAM,UAAU,gBAAg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S,EACpB,UAAU,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,EACvC,SAAS,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,EACrC,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,GAAG,EAAE,CAAC,aAAa,EAAE,EACjC,OAAO,EAAE,WAAW,IAAI,CAAC,kBAAkB,EAC3C,WAAW,QACX,UAAU,SACV,IACE,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { type ReactNode } from "react";
2
+ import type { NotificationConfig } from "./types";
3
+ export declare function useNotificationConfig(): NotificationConfig;
4
+ interface NotificationProviderProps {
5
+ config: NotificationConfig;
6
+ children: ReactNode;
7
+ }
8
+ export declare function NotificationProvider({ config, children }: NotificationProviderProps): import("react/jsx-runtime").JSX.Element;
9
+ export {};
10
+ //# sourceMappingURL=notification-provider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notification-provider.d.ts","sourceRoot":"","sources":["../../src/notifications/notification-provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAClE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAIlD,wBAAgB,qBAAqB,IAAI,kBAAkB,CAM1D;AAED,UAAU,yBAAyB;IACjC,MAAM,EAAE,kBAAkB,CAAC;IAC3B,QAAQ,EAAE,SAAS,CAAC;CACrB;AAED,wBAAgB,oBAAoB,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,EAAE,yBAAyB,2CAMnF"}
@@ -0,0 +1,14 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { createContext, useContext } from "react";
3
+ const NotificationContext = createContext(null);
4
+ export function useNotificationConfig() {
5
+ const ctx = useContext(NotificationContext);
6
+ if (!ctx) {
7
+ throw new Error("useNotificationConfig must be used within a NotificationProvider");
8
+ }
9
+ return ctx;
10
+ }
11
+ export function NotificationProvider({ config, children }) {
12
+ return (_jsx(NotificationContext.Provider, { value: config, children: children }));
13
+ }
14
+ //# sourceMappingURL=notification-provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notification-provider.js","sourceRoot":"","sources":["../../src/notifications/notification-provider.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAkB,MAAM,OAAO,CAAC;AAGlE,MAAM,mBAAmB,GAAG,aAAa,CAA4B,IAAI,CAAC,CAAC;AAE3E,MAAM,UAAU,qBAAqB;IACnC,MAAM,GAAG,GAAG,UAAU,CAAC,mBAAmB,CAAC,CAAC;IAC5C,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAC;IACtF,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAOD,MAAM,UAAU,oBAAoB,CAAC,EAAE,MAAM,EAAE,QAAQ,EAA6B;IAClF,OAAO,CACL,KAAC,mBAAmB,CAAC,QAAQ,IAAC,KAAK,EAAE,MAAM,YACxC,QAAQ,GACoB,CAChC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,7 @@
1
+ export interface NotificationTrayProps {
2
+ buttonClassName?: string;
3
+ viewAllHref?: string;
4
+ onNavigate?: (href: string) => void;
5
+ }
6
+ export declare function NotificationTray({ buttonClassName, viewAllHref, onNavigate, }: NotificationTrayProps): import("react/jsx-runtime").JSX.Element;
7
+ //# sourceMappingURL=notification-tray.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notification-tray.d.ts","sourceRoot":"","sources":["../../src/notifications/notification-tray.tsx"],"names":[],"mappings":"AAwBA,MAAM,WAAW,qBAAqB;IACpC,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACrC;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,eAAe,EACf,WAA8B,EAC9B,UAAU,GACX,EAAE,qBAAqB,2CAiJvB"}
@@ -0,0 +1,46 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { useMemo } from "react";
3
+ import { BellIcon } from "@heroicons/react/24/outline";
4
+ import { CheckCheck } from "lucide-react";
5
+ import { cn } from "../lib/utils";
6
+ import { useIsMobile } from "../hooks/use-mobile";
7
+ import { Popover, PopoverContent, PopoverTrigger, } from "../components/popover";
8
+ import { Sheet, SheetContent, SheetHeader, SheetTitle, SheetTrigger, } from "../components/sheet";
9
+ import { NotificationBadge } from "./notification-badge";
10
+ import { NotificationList } from "./notification-list";
11
+ import { PushPromptBanner } from "./push-prompt-banner";
12
+ import { useNotifications, useUnreadCount, useNotificationActions } from "./use-notifications";
13
+ import { usePushPermission } from "./use-push-permission";
14
+ import { useNotificationConfig } from "./notification-provider";
15
+ export function NotificationTray({ buttonClassName, viewAllHref = "/notifications", onNavigate, }) {
16
+ const isMobile = useIsMobile();
17
+ const { t } = useNotificationConfig();
18
+ const { data, isLoading } = useNotifications();
19
+ const { data: unread } = useUnreadCount();
20
+ const { markRead, markAllRead, dismiss } = useNotificationActions();
21
+ const unreadCount = unread?.count ?? 0;
22
+ const push = usePushPermission(unreadCount);
23
+ const notifications = useMemo(() => {
24
+ if (!data?.pages)
25
+ return [];
26
+ const all = data.pages.flatMap((p) => p.notifications);
27
+ return [...all].sort((a, b) => {
28
+ if (a.isRead !== b.isRead)
29
+ return a.isRead ? 1 : -1;
30
+ return new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime();
31
+ });
32
+ }, [data]);
33
+ const handleMarkRead = (id) => markRead.mutate(id);
34
+ const handleDismiss = (id) => dismiss.mutate(id);
35
+ const handleMarkAllRead = () => markAllRead.mutate();
36
+ const header = (_jsxs("div", { className: "flex items-center justify-between px-4 py-3 border-b border-border/50", children: [_jsxs("div", { children: [_jsx("h3", { className: "text-sm font-semibold text-foreground", children: t ? t("tray.heading", "Notifications") : "Notifications" }), unreadCount > 0 && (_jsx("p", { className: "text-[10px] text-muted-foreground mt-0.5", children: t
37
+ ? t("tray.unreadCount", "{{count}} unread", { count: unreadCount })
38
+ : `${unreadCount} unread` }))] }), unreadCount > 0 && (_jsxs("button", { type: "button", onClick: handleMarkAllRead, className: "flex items-center gap-1 text-[11px] font-medium text-primary transition-opacity hover:opacity-80", children: [_jsx(CheckCheck, { className: "size-3" }), t ? t("tray.markAllRead", "Mark all read") : "Mark all read"] }))] }));
39
+ const footer = (_jsxs("div", { className: "border-t border-border/50 px-4 py-2.5 text-center", children: [push.shouldShowPrompt && (_jsx("div", { className: "mb-2", children: _jsx(PushPromptBanner, { variant: "compact", onEnable: () => push.requestPermission(), onDismiss: () => push.dismissPrompt() }) })), _jsx("button", { type: "button", onClick: () => onNavigate?.(viewAllHref), className: "text-xs font-medium text-primary transition-opacity hover:opacity-80", children: t ? t("tray.viewAll", "View all notifications") : "View all notifications" })] }));
40
+ const bellButton = (_jsxs("span", { className: cn("relative shrink-0 rounded-lg p-2 transition-all", "text-foreground/60 hover:bg-accent/10 hover:text-foreground", "focus:outline-hidden focus:ring-2 focus:ring-accent/50", buttonClassName), children: [_jsx(BellIcon, { className: "size-5", "aria-hidden": "true" }), _jsx(NotificationBadge, { count: unreadCount })] }));
41
+ if (isMobile) {
42
+ return (_jsxs(Sheet, { children: [_jsx(SheetTrigger, { asChild: true, children: _jsx("button", { type: "button", className: buttonClassName, children: bellButton }) }), _jsxs(SheetContent, { side: "right", className: "w-full sm:max-w-md p-0", children: [_jsx(SheetHeader, { className: "sr-only", children: _jsx(SheetTitle, { children: "Notifications" }) }), header, _jsx(NotificationList, { notifications: notifications, isLoading: isLoading, onMarkRead: handleMarkRead, onDismiss: handleDismiss, onNavigate: onNavigate, compact: true, maxItems: 8, className: "flex-1 overflow-y-auto px-2 py-2" }), footer] })] }));
43
+ }
44
+ return (_jsxs(Popover, { children: [_jsx(PopoverTrigger, { asChild: true, children: _jsx("button", { type: "button", children: bellButton }) }), _jsxs(PopoverContent, { align: "end", sideOffset: 8, className: cn("w-96 p-0 overflow-hidden", "bg-card/95 backdrop-blur-lg", "shadow-lg ring-1 ring-border/50", "rounded-2xl"), children: [header, _jsx(NotificationList, { notifications: notifications, isLoading: isLoading, onMarkRead: handleMarkRead, onDismiss: handleDismiss, onNavigate: onNavigate, compact: true, maxItems: 5, className: "max-h-[380px] overflow-y-auto px-2 py-2" }), footer] })] }));
45
+ }
46
+ //# sourceMappingURL=notification-tray.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notification-tray.js","sourceRoot":"","sources":["../../src/notifications/notification-tray.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EACL,OAAO,EACP,cAAc,EACd,cAAc,GACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,KAAK,EACL,YAAY,EACZ,WAAW,EACX,UAAU,EACV,YAAY,GACb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC/F,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AA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,EACX,UAAU,EAAE,CAAC,EACb,SAAS,EAAE,EAAE,CACX,0BAA0B,EAC1B,6BAA6B,EAC7B,iCAAiC,EACjC,aAAa,CACd,aAEA,MAAM,EACP,KAAC,gBAAgB,IACf,aAAa,EAAE,aAAa,EAC5B,SAAS,EAAE,SAAS,EACpB,UAAU,EAAE,cAAc,EAC1B,SAAS,EAAE,aAAa,EACxB,UAAU,EAAE,UAAU,EACtB,OAAO,QACP,QAAQ,EAAE,CAAC,EACX,SAAS,EAAC,yCAAyC,GACnD,EACD,MAAM,IACQ,IACT,CACX,CAAC;AACJ,CAAC"}
@@ -0,0 +1,15 @@
1
+ interface PushPromptBannerProps {
2
+ variant?: "compact" | "rich";
3
+ onEnable: () => void;
4
+ onDismiss: () => void;
5
+ labels?: {
6
+ heading?: string;
7
+ description?: string;
8
+ enable?: string;
9
+ dismiss?: string;
10
+ };
11
+ className?: string;
12
+ }
13
+ export declare function PushPromptBanner({ variant, onEnable, onDismiss, labels, className, }: PushPromptBannerProps): import("react/jsx-runtime").JSX.Element;
14
+ export {};
15
+ //# sourceMappingURL=push-prompt-banner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"push-prompt-banner.d.ts","sourceRoot":"","sources":["../../src/notifications/push-prompt-banner.tsx"],"names":[],"mappings":"AAGA,UAAU,qBAAqB;IAC7B,OAAO,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAC7B,QAAQ,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,MAAM,CAAC,EAAE;QACP,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC;KAClB,CAAC;IACF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,OAAgB,EAChB,QAAQ,EACR,SAAS,EACT,MAAM,EACN,SAAS,GACV,EAAE,qBAAqB,2CAiEvB"}
@@ -0,0 +1,11 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { Bell } from "lucide-react";
3
+ import { cn } from "../lib/utils";
4
+ export function PushPromptBanner({ variant = "rich", onEnable, onDismiss, labels, className, }) {
5
+ if (variant === "compact") {
6
+ return (_jsxs("div", { className: cn("flex items-center gap-2 rounded-xl px-3 py-2", "bg-linear-to-br from-primary/8 to-primary/3", "border border-primary/10", className), children: [_jsx(Bell, { className: "size-3.5 text-primary shrink-0" }), _jsx("span", { className: "flex-1 text-[11px] text-muted-foreground", children: labels?.heading ?? "Enable desktop notifications" }), _jsx("button", { type: "button", onClick: onEnable, className: "shrink-0 rounded-md bg-primary/15 px-2.5 py-1 text-[10px] font-semibold text-primary transition-colors hover:bg-primary/25", children: labels?.enable ?? "Enable" })] }));
7
+ }
8
+ return (_jsxs("div", { className: cn("flex flex-col gap-3 rounded-2xl p-5 sm:flex-row sm:items-center", "bg-linear-to-br from-primary/8 to-primary/3", "border border-primary/10", className), children: [_jsx("div", { className: "flex size-10 shrink-0 items-center justify-center rounded-xl bg-primary/15", children: _jsx(Bell, { className: "size-5 text-primary" }) }), _jsxs("div", { className: "flex-1", children: [_jsx("p", { className: "text-sm font-semibold text-foreground", children: labels?.heading ?? "Never miss an update" }), _jsx("p", { className: "mt-0.5 text-xs text-muted-foreground", children: labels?.description ??
9
+ "Get instant desktop notifications when producers respond to your offers or new matches are found." })] }), _jsxs("div", { className: "flex items-center gap-2 sm:shrink-0", children: [_jsx("button", { type: "button", onClick: onEnable, className: "rounded-lg bg-primary/15 px-4 py-2 text-xs font-semibold text-primary transition-colors hover:bg-primary/25", children: labels?.enable ?? "Enable Notifications" }), _jsx("button", { type: "button", onClick: onDismiss, className: "rounded-lg px-4 py-2 text-xs font-medium text-muted-foreground transition-colors hover:text-foreground", children: labels?.dismiss ?? "Maybe later" })] })] }));
10
+ }
11
+ //# sourceMappingURL=push-prompt-banner.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"push-prompt-banner.js","sourceRoot":"","sources":["../../src/notifications/push-prompt-banner.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACpC,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAC;AAelC,MAAM,UAAU,gBAAgB,CAAC,EAC/B,OAAO,GAAG,MAAM,EAChB,QAAQ,EACR,SAAS,EACT,MAAM,EACN,SAAS,GACa;IACtB,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,CACL,eACE,SAAS,EAAE,EAAE,CACX,8CAA8C,EAC9C,6CAA6C,EAC7C,0BAA0B,EAC1B,SAAS,CACV,aAED,KAAC,IAAI,IAAC,SAAS,EAAC,gCAAgC,GAAG,EACnD,eAAM,SAAS,EAAC,0CAA0C,YACvD,MAAM,EAAE,OAAO,IAAI,8BAA8B,GAC7C,EACP,iBACE,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,QAAQ,EACjB,SAAS,EAAC,4HAA4H,YAErI,MAAM,EAAE,MAAM,IAAI,QAAQ,GACpB,IACL,CACP,CAAC;IACJ,CAAC;IAED,OAAO,CACL,eACE,SAAS,EAAE,EAAE,CACX,iEAAiE,EACjE,6CAA6C,EAC7C,0BAA0B,EAC1B,SAAS,CACV,aAED,cAAK,SAAS,EAAC,4EAA4E,YACzF,KAAC,IAAI,IAAC,SAAS,EAAC,qBAAqB,GAAG,GACpC,EACN,eAAK,SAAS,EAAC,QAAQ,aACrB,YAAG,SAAS,EAAC,uCAAuC,YACjD,MAAM,EAAE,OAAO,IAAI,sBAAsB,GACxC,EACJ,YAAG,SAAS,EAAC,sCAAsC,YAChD,MAAM,EAAE,WAAW;4BAClB,mGAAmG,GACnG,IACA,EACN,eAAK,SAAS,EAAC,qCAAqC,aAClD,iBACE,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,QAAQ,EACjB,SAAS,EAAC,6GAA6G,YAEtH,MAAM,EAAE,MAAM,IAAI,sBAAsB,GAClC,EACT,iBACE,IAAI,EAAC,QAAQ,EACb,OAAO,EAAE,SAAS,EAClB,SAAS,EAAC,wGAAwG,YAEjH,MAAM,EAAE,OAAO,IAAI,aAAa,GAC1B,IACL,IACF,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,64 @@
1
+ /** All 14 backend notification types */
2
+ export type NotificationType = "match" | "tender_new" | "tender_close" | "offer_status_update" | "partnership_request" | "partnership_approved" | "partnership_declined" | "partnership_terminated" | "partnership_expired" | "partnership_expiring_soon" | "beverage_extraction" | "global_announcement" | "news" | "invite";
3
+ /** Notification group categories for smart hybrid grouping */
4
+ export type NotificationCategory = "recent" | "offers" | "matches" | "opportunities" | "partnerships" | "system";
5
+ /** Normalized notification shape consumed by all components */
6
+ export interface Notification {
7
+ id: string;
8
+ type: NotificationType;
9
+ title: string;
10
+ message: string;
11
+ isRead: boolean;
12
+ isDismissed: boolean;
13
+ createdAt: string;
14
+ data?: Record<string, string>;
15
+ }
16
+ /** Paginated list response from the API */
17
+ export interface NotificationListResponse {
18
+ notifications: Notification[];
19
+ nextCursor?: string;
20
+ hasMore: boolean;
21
+ }
22
+ /** API adapter — each dashboard implements this */
23
+ export interface NotificationApi {
24
+ list: (params: {
25
+ cursor?: string;
26
+ limit?: number;
27
+ }) => Promise<NotificationListResponse>;
28
+ unreadCount: () => Promise<{
29
+ count: number;
30
+ }>;
31
+ markRead: (id: string) => Promise<void>;
32
+ markAllRead: () => Promise<void>;
33
+ dismiss: (id: string) => Promise<void>;
34
+ }
35
+ /** Route resolver — maps notification type + data to a navigation href */
36
+ export type RouteResolver = (type: NotificationType, data?: Record<string, string>) => string;
37
+ /** WebSocket subscribe function — returns unsubscribe */
38
+ export type WsSubscribe = (onMessage: (payload: {
39
+ id: string;
40
+ type: string;
41
+ title: string;
42
+ }) => void) => () => void;
43
+ /** Full provider configuration */
44
+ export interface NotificationConfig {
45
+ api: NotificationApi;
46
+ resolveRoute: RouteResolver;
47
+ subscribe?: WsSubscribe;
48
+ /** Translation function — falls back to English labels if not provided */
49
+ t?: (key: string, fallback: string, opts?: Record<string, unknown>) => string;
50
+ }
51
+ /** CTA definition for a notification type */
52
+ export interface NotificationCTA {
53
+ label: string;
54
+ /** i18n key — consumers can override via t() */
55
+ labelKey: string;
56
+ }
57
+ /** Grouped notification sections for smart hybrid layout */
58
+ export interface NotificationGroup {
59
+ category: NotificationCategory;
60
+ label: string;
61
+ labelKey: string;
62
+ notifications: Notification[];
63
+ }
64
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/notifications/types.ts"],"names":[],"mappings":"AAAA,wCAAwC;AACxC,MAAM,MAAM,gBAAgB,GACxB,OAAO,GACP,YAAY,GACZ,cAAc,GACd,qBAAqB,GACrB,qBAAqB,GACrB,sBAAsB,GACtB,sBAAsB,GACtB,wBAAwB,GACxB,qBAAqB,GACrB,2BAA2B,GAC3B,qBAAqB,GACrB,qBAAqB,GACrB,MAAM,GACN,QAAQ,CAAC;AAEb,8DAA8D;AAC9D,MAAM,MAAM,oBAAoB,GAC5B,QAAQ,GACR,QAAQ,GACR,SAAS,GACT,eAAe,GACf,cAAc,GACd,QAAQ,CAAC;AAEb,+DAA+D;AAC/D,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,gBAAgB,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;IAChB,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC/B;AAED,2CAA2C;AAC3C,MAAM,WAAW,wBAAwB;IACvC,aAAa,EAAE,YAAY,EAAE,CAAC;IAC9B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CAC/E;AAED,6CAA6C;AAC7C,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,gDAAgD;IAChD,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,4DAA4D;AAC5D,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,YAAY,EAAE,CAAC;CAC/B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/notifications/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export declare function useNotificationSocket(): void;
2
+ //# sourceMappingURL=use-notification-socket.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-notification-socket.d.ts","sourceRoot":"","sources":["../../src/notifications/use-notification-socket.ts"],"names":[],"mappings":"AAOA,wBAAgB,qBAAqB,SAmCpC"}
@@ -0,0 +1,35 @@
1
+ import { useEffect } from "react";
2
+ import { useQueryClient } from "@tanstack/react-query";
3
+ import { useNotificationConfig } from "./notification-provider";
4
+ const NOTIFICATIONS_KEY = ["notifications"];
5
+ const UNREAD_KEY = ["notifications", "unread"];
6
+ export function useNotificationSocket() {
7
+ const { subscribe, resolveRoute } = useNotificationConfig();
8
+ const qc = useQueryClient();
9
+ useEffect(() => {
10
+ if (!subscribe)
11
+ return;
12
+ const unsub = subscribe((payload) => {
13
+ qc.invalidateQueries({ queryKey: NOTIFICATIONS_KEY });
14
+ qc.invalidateQueries({ queryKey: UNREAD_KEY });
15
+ if (typeof Notification !== "undefined" &&
16
+ Notification.permission === "granted" &&
17
+ document.hidden) {
18
+ const n = new Notification(payload.title, {
19
+ body: payload.title,
20
+ icon: "/favicon.ico",
21
+ tag: payload.id,
22
+ });
23
+ n.onclick = () => {
24
+ window.focus();
25
+ const href = resolveRoute(payload.type);
26
+ if (href && href !== "/notifications") {
27
+ window.location.href = href;
28
+ }
29
+ };
30
+ }
31
+ });
32
+ return unsub;
33
+ }, [subscribe, qc, resolveRoute]);
34
+ }
35
+ //# sourceMappingURL=use-notification-socket.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-notification-socket.js","sourceRoot":"","sources":["../../src/notifications/use-notification-socket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,MAAM,iBAAiB,GAAG,CAAC,eAAe,CAAU,CAAC;AACrD,MAAM,UAAU,GAAG,CAAC,eAAe,EAAE,QAAQ,CAAU,CAAC;AAExD,MAAM,UAAU,qBAAqB;IACnC,MAAM,EAAE,SAAS,EAAE,YAAY,EAAE,GAAG,qBAAqB,EAAE,CAAC;IAC5D,MAAM,EAAE,GAAG,cAAc,EAAE,CAAC;IAE5B,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,CAAC,SAAS;YAAE,OAAO;QAEvB,MAAM,KAAK,GAAG,SAAS,CAAC,CAAC,OAAO,EAAE,EAAE;YAClC,EAAE,CAAC,iBAAiB,CAAC,EAAE,QAAQ,EAAE,iBAAiB,EAAE,CAAC,CAAC;YACtD,EAAE,CAAC,iBAAiB,CAAC,EAAE,QAAQ,EAAE,UAAU,EAAE,CAAC,CAAC;YAE/C,IACE,OAAO,YAAY,KAAK,WAAW;gBACnC,YAAY,CAAC,UAAU,KAAK,SAAS;gBACrC,QAAQ,CAAC,MAAM,EACf,CAAC;gBACD,MAAM,CAAC,GAAG,IAAI,YAAY,CAAC,OAAO,CAAC,KAAK,EAAE;oBACxC,IAAI,EAAE,OAAO,CAAC,KAAK;oBACnB,IAAI,EAAE,cAAc;oBACpB,GAAG,EAAE,OAAO,CAAC,EAAE;iBAChB,CAAC,CAAC;gBACH,CAAC,CAAC,OAAO,GAAG,GAAG,EAAE;oBACf,MAAM,CAAC,KAAK,EAAE,CAAC;oBACf,MAAM,IAAI,GAAG,YAAY,CACvB,OAAO,CAAC,IAA0C,CACnD,CAAC;oBACF,IAAI,IAAI,IAAI,IAAI,KAAK,gBAAgB,EAAE,CAAC;wBACtC,MAAM,CAAC,QAAQ,CAAC,IAAI,GAAG,IAAI,CAAC;oBAC9B,CAAC;gBACH,CAAC,CAAC;YACJ,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,KAAK,CAAC;IACf,CAAC,EAAE,CAAC,SAAS,EAAE,EAAE,EAAE,YAAY,CAAC,CAAC,CAAC;AACpC,CAAC"}
@@ -0,0 +1,10 @@
1
+ export declare function useNotifications(limit?: number): import("@tanstack/react-query").UseInfiniteQueryResult<import("@tanstack/react-query").InfiniteData<import("./types").NotificationListResponse, unknown>, Error>;
2
+ export declare function useUnreadCount(): import("@tanstack/react-query").UseQueryResult<{
3
+ count: number;
4
+ }, Error>;
5
+ export declare function useNotificationActions(): {
6
+ markRead: import("@tanstack/react-query").UseMutationResult<void, Error, string, unknown>;
7
+ markAllRead: import("@tanstack/react-query").UseMutationResult<void, Error, void, unknown>;
8
+ dismiss: import("@tanstack/react-query").UseMutationResult<void, Error, string, unknown>;
9
+ };
10
+ //# sourceMappingURL=use-notifications.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-notifications.d.ts","sourceRoot":"","sources":["../../src/notifications/use-notifications.ts"],"names":[],"mappings":"AAWA,wBAAgB,gBAAgB,CAAC,KAAK,SAAK,oKAS1C;AAED,wBAAgB,cAAc;;UAQ7B;AAED,wBAAgB,sBAAsB;;;;EAyBrC"}
@@ -0,0 +1,43 @@
1
+ import { useInfiniteQuery, useQuery, useMutation, useQueryClient, } from "@tanstack/react-query";
2
+ import { useNotificationConfig } from "./notification-provider";
3
+ const NOTIFICATIONS_KEY = ["notifications"];
4
+ const UNREAD_KEY = ["notifications", "unread"];
5
+ export function useNotifications(limit = 20) {
6
+ const { api } = useNotificationConfig();
7
+ return useInfiniteQuery({
8
+ queryKey: NOTIFICATIONS_KEY,
9
+ queryFn: ({ pageParam }) => api.list({ cursor: pageParam, limit }),
10
+ initialPageParam: undefined,
11
+ getNextPageParam: (last) => (last.hasMore ? last.nextCursor : undefined),
12
+ });
13
+ }
14
+ export function useUnreadCount() {
15
+ const { api } = useNotificationConfig();
16
+ return useQuery({
17
+ queryKey: UNREAD_KEY,
18
+ queryFn: () => api.unreadCount(),
19
+ refetchInterval: 30_000,
20
+ });
21
+ }
22
+ export function useNotificationActions() {
23
+ const { api } = useNotificationConfig();
24
+ const qc = useQueryClient();
25
+ const invalidate = () => {
26
+ qc.invalidateQueries({ queryKey: NOTIFICATIONS_KEY });
27
+ qc.invalidateQueries({ queryKey: UNREAD_KEY });
28
+ };
29
+ const markRead = useMutation({
30
+ mutationFn: (id) => api.markRead(id),
31
+ onSuccess: invalidate,
32
+ });
33
+ const markAllRead = useMutation({
34
+ mutationFn: () => api.markAllRead(),
35
+ onSuccess: invalidate,
36
+ });
37
+ const dismiss = useMutation({
38
+ mutationFn: (id) => api.dismiss(id),
39
+ onSuccess: invalidate,
40
+ });
41
+ return { markRead, markAllRead, dismiss };
42
+ }
43
+ //# sourceMappingURL=use-notifications.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-notifications.js","sourceRoot":"","sources":["../../src/notifications/use-notifications.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,QAAQ,EACR,WAAW,EACX,cAAc,GACf,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,MAAM,iBAAiB,GAAG,CAAC,eAAe,CAAU,CAAC;AACrD,MAAM,UAAU,GAAG,CAAC,eAAe,EAAE,QAAQ,CAAU,CAAC;AAExD,MAAM,UAAU,gBAAgB,CAAC,KAAK,GAAG,EAAE;IACzC,MAA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AAG,EAAE,CAAC,GAAG,CAAC,WAAW,EAAE;QACnC,SAAS,EAAE,UAAU;KACtB,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,WAAW,CAAC;QAC1B,UAAU,EAAE,CAAC,EAAU,EAAE,EAAE,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;QAC3C,SAAS,EAAE,UAAU;KACtB,CAAC,CAAC;IAEH,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC;AAC5C,CAAC"}
@@ -0,0 +1,8 @@
1
+ export interface PushPermissionState {
2
+ permission: NotificationPermission | "unsupported";
3
+ shouldShowPrompt: boolean;
4
+ requestPermission: () => Promise<NotificationPermission>;
5
+ dismissPrompt: () => void;
6
+ }
7
+ export declare function usePushPermission(unreadCount: number): PushPermissionState;
8
+ //# sourceMappingURL=use-push-permission.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-push-permission.d.ts","sourceRoot":"","sources":["../../src/notifications/use-push-permission.ts"],"names":[],"mappings":"AAiBA,MAAM,WAAW,mBAAmB;IAClC,UAAU,EAAE,sBAAsB,GAAG,aAAa,CAAC;IACnD,gBAAgB,EAAE,OAAO,CAAC;IAC1B,iBAAiB,EAAE,MAAM,OAAO,CAAC,sBAAsB,CAAC,CAAC;IACzD,aAAa,EAAE,MAAM,IAAI,CAAC;CAC3B;AAED,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,mBAAmB,CAwB1E"}
@@ -0,0 +1,36 @@
1
+ import { useState, useCallback, useEffect } from "react";
2
+ const DISMISSED_KEY = "cn:push-dismissed-at";
3
+ const COOLDOWN_MS = 30 * 24 * 60 * 60 * 1000; // 30 days
4
+ function getPermission() {
5
+ if (typeof Notification === "undefined")
6
+ return "unsupported";
7
+ return Notification.permission;
8
+ }
9
+ function isDismissedRecently() {
10
+ const raw = localStorage.getItem(DISMISSED_KEY);
11
+ if (!raw)
12
+ return false;
13
+ const ts = Number(raw);
14
+ return Date.now() - ts < COOLDOWN_MS;
15
+ }
16
+ export function usePushPermission(unreadCount) {
17
+ const [permission, setPermission] = useState(getPermission);
18
+ const [dismissed, setDismissed] = useState(isDismissedRecently);
19
+ useEffect(() => {
20
+ setPermission(getPermission());
21
+ }, []);
22
+ const shouldShowPrompt = permission === "default" && unreadCount >= 3 && !dismissed;
23
+ const requestPermission = useCallback(async () => {
24
+ if (typeof Notification === "undefined")
25
+ return "denied";
26
+ const result = await Notification.requestPermission();
27
+ setPermission(result);
28
+ return result;
29
+ }, []);
30
+ const dismissPrompt = useCallback(() => {
31
+ localStorage.setItem(DISMISSED_KEY, String(Date.now()));
32
+ setDismissed(true);
33
+ }, []);
34
+ return { permission, shouldShowPrompt, requestPermission, dismissPrompt };
35
+ }
36
+ //# sourceMappingURL=use-push-permission.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-push-permission.js","sourceRoot":"","sources":["../../src/notifications/use-push-permission.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEzD,MAAM,aAAa,GAAG,sBAAsB,CAAC;AAC7C,MAAM,WAAW,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,UAAU;AAExD,SAAS,aAAa;IACpB,IAAI,OAAO,YAAY,KAAK,WAAW;QAAE,OAAO,aAAa,CAAC;IAC9D,OAAO,YAAY,CAAC,UAAU,CAAC;AACjC,CAAC;AAED,SAAS,mBAAmB;IAC1B,MAAM,GAAG,GAAG,YAAY,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;IAChD,IAAI,CAAC,GAAG;QAAE,OAAO,KAAK,CAAC;IACvB,MAAM,EAAE,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IACvB,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,WAAW,CAAC;AACvC,CAAC;AASD,MAAM,UAAU,iBAAiB,CAAC,WAAmB;IACnD,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAAG,QAAQ,CAAC,aAAa,CAAC,CAAC;IAC5D,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAAC,mBAAmB,CAAC,CAAC;IAEhE,SAAS,CAAC,GAAG,EAAE;QACb,aAAa,CAAC,aAAa,EAAE,CAAC,CAAC;IACjC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,gBAAgB,GACpB,UAAU,KAAK,SAAS,IAAI,WAAW,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC;IAE7D,MAAM,iBAAiB,GAAG,WAAW,CAAC,KAAK,IAAI,EAAE;QAC/C,IAAI,OAAO,YAAY,KAAK,WAAW;YAAE,OAAO,QAAkC,CAAC;QACnF,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,iBAAiB,EAAE,CAAC;QACtD,aAAa,CAAC,MAAM,CAAC,CAAC;QACtB,OAAO,MAAM,CAAC;IAChB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,aAAa,GAAG,WAAW,CAAC,GAAG,EAAE;QACrC,YAAY,CAAC,OAAO,CAAC,aAAa,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;QACxD,YAAY,CAAC,IAAI,CAAC,CAAC;IACrB,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,aAAa,EAAE,CAAC;AAC5E,CAAC"}
@@ -0,0 +1,20 @@
1
+ import type { Notification, NotificationGroup } from "./types";
2
+ import type { NotificationFilter } from "./constants";
3
+ /**
4
+ * Format notification timestamp.
5
+ * <24h: relative ("2 min ago"), same year: "Mar 15", else: "Mar 15, 2025"
6
+ */
7
+ export declare function formatNotificationTime(dateString: string): string;
8
+ /**
9
+ * Smart hybrid grouping:
10
+ * - "Recent" (last 24h) as flat chronological
11
+ * - Older items grouped by category
12
+ * Empty categories are excluded.
13
+ */
14
+ export declare function groupNotifications(notifications: Notification[], t?: (key: string, fallback: string, opts?: Record<string, unknown>) => string): NotificationGroup[];
15
+ /**
16
+ * Client-side filter. "unread" returns flat list; category filters
17
+ * return only matching items; "all" returns everything.
18
+ */
19
+ export declare function filterNotifications(notifications: Notification[], filter: NotificationFilter): Notification[];
20
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/notifications/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EAEZ,iBAAiB,EAElB,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGtD;;;GAGG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAWjE;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,aAAa,EAAE,YAAY,EAAE,EAC7B,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,GAC5E,iBAAiB,EAAE,CAmDrB;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CACjC,aAAa,EAAE,YAAY,EAAE,EAC7B,MAAM,EAAE,kBAAkB,GACzB,YAAY,EAAE,CAMhB"}