@codeswayam/ui 1.2.1 → 1.3.0
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 +727 -173
- package/dist/components/brand/BrandFooterSection.d.ts +8 -0
- package/dist/components/brand/BrandFooterSection.d.ts.map +1 -0
- package/dist/components/brand/BrandFooterSection.js +97 -0
- package/dist/components/brand/BrandNav.d.ts +17 -0
- package/dist/components/brand/BrandNav.d.ts.map +1 -0
- package/dist/components/brand/BrandNav.js +64 -0
- package/dist/components/neural/AICreditBadge.d.ts +9 -0
- package/dist/components/neural/AICreditBadge.d.ts.map +1 -0
- package/dist/components/neural/AICreditBadge.js +31 -0
- package/dist/components/neural/AIImageGeneratorModal.d.ts +9 -0
- package/dist/components/neural/AIImageGeneratorModal.d.ts.map +1 -0
- package/dist/components/neural/AIImageGeneratorModal.js +66 -0
- package/dist/components/neural/AIPromptPlayground.d.ts +10 -0
- package/dist/components/neural/AIPromptPlayground.d.ts.map +1 -0
- package/dist/components/neural/AIPromptPlayground.js +66 -0
- package/dist/components/neural/KnowledgeBasePicker.d.ts +18 -0
- package/dist/components/neural/KnowledgeBasePicker.d.ts.map +1 -0
- package/dist/components/neural/KnowledgeBasePicker.js +42 -0
- package/dist/components/neural/WorkflowPicker.d.ts +18 -0
- package/dist/components/neural/WorkflowPicker.d.ts.map +1 -0
- package/dist/components/neural/WorkflowPicker.js +46 -0
- package/dist/components/neural/index.d.ts +11 -0
- package/dist/components/neural/index.d.ts.map +1 -0
- package/dist/components/neural/index.js +5 -0
- package/dist/components/saas/NotificationBell.d.ts +12 -0
- package/dist/components/saas/NotificationBell.d.ts.map +1 -0
- package/dist/components/saas/NotificationBell.js +52 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utils/useNotifications.d.ts +24 -0
- package/dist/utils/useNotifications.d.ts.map +1 -0
- package/dist/utils/useNotifications.js +71 -0
- package/dist/utils/useWebPush.d.ts +14 -0
- package/dist/utils/useWebPush.d.ts.map +1 -0
- package/dist/utils/useWebPush.js +110 -0
- package/package.json +1 -1
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface NotificationBellProps {
|
|
2
|
+
apiUrl?: string;
|
|
3
|
+
onNavigate?: (url: string) => void;
|
|
4
|
+
onOpenSettings?: () => void;
|
|
5
|
+
className?: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Universal Notification Bell Component for SaaS applications.
|
|
9
|
+
* Renders an unread badge counter and a notification feed dropdown.
|
|
10
|
+
*/
|
|
11
|
+
export declare function NotificationBell({ apiUrl, onNavigate, onOpenSettings, className, }: NotificationBellProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
//# sourceMappingURL=NotificationBell.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NotificationBell.d.ts","sourceRoot":"","sources":["../../../src/components/saas/NotificationBell.tsx"],"names":[],"mappings":"AAqBA,MAAM,WAAW,qBAAqB;IACpC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;IACnC,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AA6BD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,MAAM,EACN,UAAU,EACV,cAAc,EACd,SAAS,GACV,EAAE,qBAAqB,2CAoIvB"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Bell, CheckCheck, CreditCard, ShieldAlert, Sparkles, Tag, Settings, Info, } from "lucide-react";
|
|
4
|
+
import { DropdownMenu, DropdownMenuContent, DropdownMenuTrigger, } from "../base/dropdown-menu";
|
|
5
|
+
import { useNotifications } from "../../utils/useNotifications";
|
|
6
|
+
import { cn } from "../../utils/cn";
|
|
7
|
+
function getCategoryIcon(category) {
|
|
8
|
+
switch (category) {
|
|
9
|
+
case "billing":
|
|
10
|
+
return _jsx(CreditCard, { size: 14, className: "text-violet-600" });
|
|
11
|
+
case "security":
|
|
12
|
+
return _jsx(ShieldAlert, { size: 14, className: "text-red-600" });
|
|
13
|
+
case "updates":
|
|
14
|
+
return _jsx(Sparkles, { size: 14, className: "text-blue-600" });
|
|
15
|
+
case "marketing":
|
|
16
|
+
return _jsx(Tag, { size: 14, className: "text-amber-600" });
|
|
17
|
+
default:
|
|
18
|
+
return _jsx(Info, { size: 14, className: "text-gray-600" });
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function formatTimeAgo(dateStr) {
|
|
22
|
+
const diff = Date.now() - new Date(dateStr).getTime();
|
|
23
|
+
const mins = Math.floor(diff / (1000 * 60));
|
|
24
|
+
if (mins < 1)
|
|
25
|
+
return "Just now";
|
|
26
|
+
if (mins < 60)
|
|
27
|
+
return `${mins}m ago`;
|
|
28
|
+
const hours = Math.floor(mins / 60);
|
|
29
|
+
if (hours < 24)
|
|
30
|
+
return `${hours}h ago`;
|
|
31
|
+
const days = Math.floor(hours / 24);
|
|
32
|
+
if (days < 7)
|
|
33
|
+
return `${days}d ago`;
|
|
34
|
+
return new Date(dateStr).toLocaleDateString();
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Universal Notification Bell Component for SaaS applications.
|
|
38
|
+
* Renders an unread badge counter and a notification feed dropdown.
|
|
39
|
+
*/
|
|
40
|
+
export function NotificationBell({ apiUrl, onNavigate, onOpenSettings, className, }) {
|
|
41
|
+
const { notifications, unreadCount, markAsRead, markAllAsRead } = useNotifications({ apiUrl });
|
|
42
|
+
return (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs("button", { "aria-label": "Open notifications", className: cn("relative p-2 rounded-xl text-gray-600 hover:text-gray-900 hover:bg-gray-100 transition-colors cursor-pointer outline-none", className), children: [_jsx(Bell, { size: 18 }), unreadCount > 0 && (_jsx("span", { className: "absolute top-1 right-1 flex h-4 min-w-[16px] px-1 items-center justify-center rounded-full bg-violet-600 text-[10px] font-bold text-white shadow-sm ring-2 ring-background animate-in zoom-in-50", children: unreadCount > 99 ? "99+" : unreadCount }))] }) }), _jsxs(DropdownMenuContent, { align: "end", className: "w-80 sm:w-96 max-h-[480px] p-0 rounded-2xl shadow-2xl border border-gray-100 overflow-hidden z-50 bg-white", children: [_jsxs("div", { className: "flex items-center justify-between px-4 py-3 border-b border-gray-100 bg-gray-50/70", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { className: "text-sm font-bold text-gray-900", children: "Notifications" }), unreadCount > 0 && (_jsxs("span", { className: "bg-violet-100 text-violet-700 text-[10px] font-bold px-1.5 py-0.5 rounded-full", children: [unreadCount, " new"] }))] }), _jsxs("div", { className: "flex items-center gap-1", children: [unreadCount > 0 && (_jsxs("button", { type: "button", onClick: markAllAsRead, title: "Mark all as read", className: "flex items-center gap-1 text-[11px] font-semibold text-violet-700 hover:text-violet-900 px-2 py-1 rounded-md hover:bg-violet-50 transition-colors cursor-pointer", children: [_jsx(CheckCheck, { size: 13 }), "Mark all read"] })), onOpenSettings && (_jsx("button", { type: "button", onClick: onOpenSettings, title: "Notification Settings", className: "p-1 rounded-md text-gray-400 hover:text-gray-600 hover:bg-gray-100 transition-colors cursor-pointer", children: _jsx(Settings, { size: 14 }) }))] })] }), _jsx("div", { className: "overflow-y-auto max-h-[360px] divide-y divide-gray-50", children: notifications.length === 0 ? (_jsxs("div", { className: "py-12 text-center text-gray-400 space-y-2", children: [_jsx(Bell, { size: 32, strokeWidth: 1.5, className: "mx-auto text-gray-300" }), _jsx("p", { className: "text-xs font-medium text-gray-500", children: "No notifications yet" }), _jsx("p", { className: "text-[11px] text-gray-400", children: "You're completely caught up! \u2728" })] })) : (notifications.map((item) => {
|
|
43
|
+
const isUnread = !item.isRead;
|
|
44
|
+
return (_jsxs("div", { onClick: () => {
|
|
45
|
+
if (isUnread)
|
|
46
|
+
markAsRead(item.id);
|
|
47
|
+
if (item.actionUrl && onNavigate) {
|
|
48
|
+
onNavigate(item.actionUrl);
|
|
49
|
+
}
|
|
50
|
+
}, className: cn("flex items-start gap-3 p-3.5 transition-colors cursor-pointer text-left", isUnread ? "bg-violet-50/40 hover:bg-violet-50/70" : "bg-white hover:bg-gray-50/80"), children: [_jsx("div", { className: "mt-0.5 shrink-0 p-1.5 rounded-lg bg-gray-100 border border-gray-200/60", children: getCategoryIcon(item.category) }), _jsxs("div", { className: "flex-1 min-w-0 space-y-0.5", children: [_jsxs("div", { className: "flex items-center justify-between gap-1", children: [_jsx("p", { className: cn("text-xs font-semibold truncate", isUnread ? "text-gray-900 font-bold" : "text-gray-700"), children: item.title }), _jsx("span", { className: "text-[10px] text-gray-400 shrink-0", children: formatTimeAgo(item.createdAt) })] }), _jsx("p", { className: "text-[11px] text-gray-600 line-clamp-2 leading-relaxed", children: item.message })] }), isUnread && (_jsx("span", { className: "w-1.5 h-1.5 rounded-full bg-violet-600 shrink-0 mt-2" }))] }, item.id));
|
|
51
|
+
})) }), onOpenSettings && (_jsx("div", { className: "p-2 border-t border-gray-100 bg-gray-50/50 text-center", children: _jsx("button", { type: "button", onClick: onOpenSettings, className: "text-[11px] font-semibold text-gray-500 hover:text-violet-700 transition-colors cursor-pointer", children: "Configure Notification Preferences \u2192" }) }))] })] }));
|
|
52
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -7,9 +7,12 @@ export * from "./components/base/label";
|
|
|
7
7
|
export * from "./components/base/avatar";
|
|
8
8
|
export * from "./components/base/dropdown-menu";
|
|
9
9
|
export * from "./components/saas/user-menu";
|
|
10
|
+
export * from "./components/saas/NotificationBell";
|
|
10
11
|
export * from "./components/saas/status-badge";
|
|
11
12
|
export * from "./components/layout/GlobalNavbar";
|
|
12
13
|
export * from "./components/layout/GlobalFooter";
|
|
14
|
+
export * from "./components/brand/BrandNav";
|
|
15
|
+
export * from "./components/brand/BrandFooterSection";
|
|
13
16
|
export * from "./components/data/DataTable";
|
|
14
17
|
export * from "./components/data/TableToolbar";
|
|
15
18
|
export * from "./components/data/EmptyState";
|
|
@@ -19,5 +22,8 @@ export * from "./components/display/CopyButton";
|
|
|
19
22
|
export * from "./components/feedback/ErrorState";
|
|
20
23
|
export * from "./components/feedback/ConfirmDialog";
|
|
21
24
|
export * from "./components/feedback/Skeleton";
|
|
25
|
+
export * from "./components/neural";
|
|
22
26
|
export { cn } from "./utils/cn";
|
|
27
|
+
export * from "./utils/useNotifications";
|
|
28
|
+
export * from "./utils/useWebPush";
|
|
23
29
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iCAAiC,CAAC;AAGhD,cAAc,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,yBAAyB,CAAC;AACxC,cAAc,0BAA0B,CAAC;AACzC,cAAc,iCAAiC,CAAC;AAGhD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oCAAoC,CAAC;AAEnD,cAAc,gCAAgC,CAAC;AAG/C,cAAc,kCAAkC,CAAC;AACjD,cAAc,kCAAkC,CAAC;AAGjD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,uCAAuC,CAAC;AAItD,cAAc,6BAA6B,CAAC;AAE5C,cAAc,gCAAgC,CAAC;AAE/C,cAAc,8BAA8B,CAAC;AAI7C,cAAc,iCAAiC,CAAC;AAEhD,cAAc,+BAA+B,CAAC;AAE9C,cAAc,iCAAiC,CAAC;AAIhD,cAAc,kCAAkC,CAAC;AAEjD,cAAc,qCAAqC,CAAC;AAEpD,cAAc,gCAAgC,CAAC;AAG/C,cAAc,qBAAqB,CAAC;AAGpC,OAAO,EAAE,EAAE,EAAE,MAAM,YAAY,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,oBAAoB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -9,11 +9,15 @@ export * from "./components/base/avatar";
|
|
|
9
9
|
export * from "./components/base/dropdown-menu";
|
|
10
10
|
// ─── SaaS Components ─────────────────────────────────────────────────────────
|
|
11
11
|
export * from "./components/saas/user-menu";
|
|
12
|
+
export * from "./components/saas/NotificationBell";
|
|
12
13
|
// StatusBadge, PriorityBadge, RoleBadge, StatusType, PriorityType, RoleType
|
|
13
14
|
export * from "./components/saas/status-badge";
|
|
14
15
|
// ─── Layout Components ───────────────────────────────────────────────────────
|
|
15
16
|
export * from "./components/layout/GlobalNavbar";
|
|
16
17
|
export * from "./components/layout/GlobalFooter";
|
|
18
|
+
// ─── Brand Mesh Components ────────────────────────────────────────────────────
|
|
19
|
+
export * from "./components/brand/BrandNav";
|
|
20
|
+
export * from "./components/brand/BrandFooterSection";
|
|
17
21
|
// ─── Data Components ─────────────────────────────────────────────────────────
|
|
18
22
|
// DataTable — sortable, paginated, column-visibility-aware table
|
|
19
23
|
export * from "./components/data/DataTable";
|
|
@@ -35,5 +39,9 @@ export * from "./components/feedback/ErrorState";
|
|
|
35
39
|
export * from "./components/feedback/ConfirmDialog";
|
|
36
40
|
// Skeleton, SkeletonText, SkeletonAvatar, SkeletonStatCard, SkeletonTable, SkeletonUserRow
|
|
37
41
|
export * from "./components/feedback/Skeleton";
|
|
42
|
+
// ─── Neural AI Components ───────────────────────────────────────────────────
|
|
43
|
+
export * from "./components/neural";
|
|
38
44
|
// ─── Utils ───────────────────────────────────────────────────────────────────
|
|
39
45
|
export { cn } from "./utils/cn";
|
|
46
|
+
export * from "./utils/useNotifications";
|
|
47
|
+
export * from "./utils/useWebPush";
|