@papernote/ui 1.11.6 → 1.13.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/dist/components/AdminModal.d.ts.map +1 -1
- package/dist/components/ChatUI.d.ts +59 -0
- package/dist/components/ChatUI.d.ts.map +1 -0
- package/dist/components/InsightsPanelUI.d.ts +56 -0
- package/dist/components/InsightsPanelUI.d.ts.map +1 -0
- package/dist/components/Sidebar.d.ts.map +1 -1
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/index.d.ts +114 -2
- package/dist/index.esm.js +156 -8
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +156 -6
- package/dist/index.js.map +1 -1
- package/dist/styles.css +63 -0
- package/package.json +1 -1
- package/src/components/AdminModal.tsx +1 -0
- package/src/components/ChatUI.tsx +214 -0
- package/src/components/InsightsPanelUI.tsx +244 -0
- package/src/components/Sidebar.tsx +19 -1
- package/src/components/index.ts +6 -0
package/dist/index.esm.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
|
|
2
2
|
import * as React from 'react';
|
|
3
3
|
import React__default, { forwardRef, useState, useRef, useEffect, useId, useCallback, useImperativeHandle, useMemo, Children, isValidElement, cloneElement, Component, createContext as createContext$1, useContext, useLayoutEffect, createElement, useReducer } from 'react';
|
|
4
|
-
import { Loader2, Check, X, EyeOff, Eye, AlertTriangle, CheckCircle, AlertCircle, ChevronDown, Search, Minus, Star, Calendar as Calendar$1, ChevronLeft, ChevronRight, Clock, ChevronUp, Plus, TrendingUp, TrendingDown, Lightbulb, Sparkles, PartyPopper, Flame, Shield, Pencil, User, Users, Activity, Mail, Send, Info, Trash2, HelpCircle, ChevronsLeft, ChevronsRight, Circle, MoreVertical, GripVertical, Upload, Bold, Italic, Underline, List, ListOrdered, Code, Link, ExternalLink, MoreHorizontal, Home, ArrowUp, ArrowDown, RotateCcw, ArrowRight, FileText, Image, File as File$1, Menu as Menu$1, Settings, LogOut, Moon, Sun, Bell, Edit, Trash, Pin, PinOff, Download, Save, ArrowUpDown, Filter, XCircle, BarChart3, MessageSquare } from 'lucide-react';
|
|
4
|
+
import { Loader2, Check, X, EyeOff, Eye, AlertTriangle, CheckCircle, AlertCircle, ChevronDown, Search, Minus, Star, Calendar as Calendar$1, ChevronLeft, ChevronRight, Clock, ChevronUp, Plus, TrendingUp, TrendingDown, Lightbulb, Sparkles, PartyPopper, Flame, Shield, Pencil, User, Users, Activity, Mail, Send, Info, Trash2, HelpCircle, ChevronsLeft, ChevronsRight, Circle, MoreVertical, GripVertical, Upload, Bold, Italic, Underline, List, ListOrdered, Code, Link, ExternalLink, MoreHorizontal, Home, ArrowUp, ArrowDown, RotateCcw, ArrowRight, FileText, Image, File as File$1, Menu as Menu$1, Settings, LogOut, Moon, Sun, Bell, Edit, Trash, Pin, PinOff, Download, Save, ArrowUpDown, Filter, XCircle, BarChart3, MessageSquare, Bot, RefreshCw, BrainCircuit, Target } from 'lucide-react';
|
|
5
5
|
import { createPortal } from 'react-dom';
|
|
6
6
|
import { Link as Link$1, useInRouterContext, useNavigate, useLocation } from 'react-router-dom';
|
|
7
7
|
|
|
@@ -5398,7 +5398,7 @@ function SharedBadge({ sharedWith, variant, size = 'md', maxDisplay = 3, onClick
|
|
|
5398
5398
|
}
|
|
5399
5399
|
|
|
5400
5400
|
// Format relative time
|
|
5401
|
-
function formatRelativeTime$
|
|
5401
|
+
function formatRelativeTime$3(date) {
|
|
5402
5402
|
const now = new Date();
|
|
5403
5403
|
const diffMs = now.getTime() - date.getTime();
|
|
5404
5404
|
const diffMins = Math.floor(diffMs / 60000);
|
|
@@ -5430,11 +5430,11 @@ function ActivityFeed({ activities, maxItems, showTimestamps = true, onLoadMore,
|
|
|
5430
5430
|
if (activities.length === 0) {
|
|
5431
5431
|
return (jsxs("div", { className: `text-center py-8 ${className}`, children: [jsx(Activity, { className: "w-8 h-8 text-ink-300 mx-auto mb-2" }), jsx("p", { className: "text-ink-500 text-sm", children: "No activity yet" })] }));
|
|
5432
5432
|
}
|
|
5433
|
-
return (jsxs("div", { className: `${className}`, role: "feed", "aria-label": "Activity feed", children: [jsx("div", { className: "space-y-4", children: displayedActivities.map((activity, index) => (jsxs("div", { className: "flex gap-3", role: "article", "aria-label": `${activity.user.name} ${activity.action}${activity.target ? ` ${activity.target}` : ''}`, children: [jsxs("div", { className: "flex flex-col items-center", children: [jsx(CollaboratorAvatars, { collaborators: [activity.user], max: 1, size: "sm" }), index < displayedActivities.length - 1 && (jsx("div", { className: "w-0.5 flex-1 bg-paper-200 mt-2" }))] }), jsx("div", { className: "flex-1 min-w-0 pb-4", children: jsxs("div", { className: "flex items-start justify-between gap-2", children: [jsx("div", { className: "flex-1 min-w-0", children: jsxs("p", { className: "text-sm text-ink-700", children: [jsx("span", { className: "font-medium text-ink-800", children: activity.user.name }), ' ', activity.action, activity.target && (jsxs(Fragment, { children: [' ', jsx("span", { className: "font-medium text-ink-800", children: activity.target })] }))] }) }), jsxs("div", { className: "flex items-center gap-2 shrink-0", children: [activity.icon && (jsx("span", { className: "text-ink-400", children: activity.icon })), showTimestamps && (jsx("span", { className: "text-xs text-ink-400 whitespace-nowrap", children: formatRelativeTime$
|
|
5433
|
+
return (jsxs("div", { className: `${className}`, role: "feed", "aria-label": "Activity feed", children: [jsx("div", { className: "space-y-4", children: displayedActivities.map((activity, index) => (jsxs("div", { className: "flex gap-3", role: "article", "aria-label": `${activity.user.name} ${activity.action}${activity.target ? ` ${activity.target}` : ''}`, children: [jsxs("div", { className: "flex flex-col items-center", children: [jsx(CollaboratorAvatars, { collaborators: [activity.user], max: 1, size: "sm" }), index < displayedActivities.length - 1 && (jsx("div", { className: "w-0.5 flex-1 bg-paper-200 mt-2" }))] }), jsx("div", { className: "flex-1 min-w-0 pb-4", children: jsxs("div", { className: "flex items-start justify-between gap-2", children: [jsx("div", { className: "flex-1 min-w-0", children: jsxs("p", { className: "text-sm text-ink-700", children: [jsx("span", { className: "font-medium text-ink-800", children: activity.user.name }), ' ', activity.action, activity.target && (jsxs(Fragment, { children: [' ', jsx("span", { className: "font-medium text-ink-800", children: activity.target })] }))] }) }), jsxs("div", { className: "flex items-center gap-2 shrink-0", children: [activity.icon && (jsx("span", { className: "text-ink-400", children: activity.icon })), showTimestamps && (jsx("span", { className: "text-xs text-ink-400 whitespace-nowrap", children: formatRelativeTime$3(activity.timestamp) }))] })] }) })] }, activity.id))) }), (hasMore || onLoadMore) && (jsx("div", { className: "mt-4 text-center", children: jsx(Button, { variant: "ghost", size: "sm", onClick: onLoadMore, loading: loading, children: loading ? 'Loading...' : 'Load more' }) }))] }));
|
|
5434
5434
|
}
|
|
5435
5435
|
|
|
5436
5436
|
// Format relative time
|
|
5437
|
-
function formatRelativeTime(date) {
|
|
5437
|
+
function formatRelativeTime$2(date) {
|
|
5438
5438
|
const now = new Date();
|
|
5439
5439
|
const diffMs = now.getTime() - date.getTime();
|
|
5440
5440
|
const diffMins = Math.floor(diffMs / 60000);
|
|
@@ -5502,7 +5502,7 @@ function InviteCard({ onInvite, pending = [], loading = false, maxPending = 5, o
|
|
|
5502
5502
|
shadow-card
|
|
5503
5503
|
p-4
|
|
5504
5504
|
${className}
|
|
5505
|
-
`, children: jsxs(Stack, { gap: "md", children: [jsxs(Stack, { direction: "horizontal", gap: "sm", align: "center", children: [jsx("div", { className: "p-2 bg-accent-100 rounded-lg", children: jsx(Mail, { className: "w-5 h-5 text-accent-600" }) }), jsxs("div", { children: [jsx(Text, { weight: "semibold", className: "text-ink-800", children: "Invite People" }), jsx(Text, { size: "sm", className: "text-ink-500", children: "Share access via email" })] })] }), jsx("form", { onSubmit: handleSubmit, children: jsxs(Stack, { direction: "horizontal", gap: "sm", children: [jsx("div", { className: "flex-1", children: jsx(Input, { type: "email", placeholder: "Enter email address", value: email, onChange: (e) => handleEmailChange(e.target.value), validationState: error ? 'error' : undefined, validationMessage: error || undefined, disabled: loading }) }), jsx(Button, { type: "submit", variant: "primary", loading: loading, disabled: !email.trim(), icon: jsx(Send, { className: "w-4 h-4" }), children: "Send" })] }) }), displayedPending.length > 0 && (jsxs(Stack, { gap: "sm", children: [jsxs(Stack, { direction: "horizontal", gap: "xs", align: "center", children: [jsx(Clock, { className: "w-4 h-4 text-ink-400" }), jsxs(Text, { size: "sm", className: "text-ink-500", children: ["Pending invitations (", pending.length, ")"] })] }), jsxs("div", { className: "border border-paper-200 rounded-lg divide-y divide-paper-200", children: [displayedPending.map((invite) => (jsxs("div", { className: "px-3 py-2 flex items-center justify-between", children: [jsxs(Stack, { gap: "xs", children: [jsx(Text, { size: "sm", weight: "medium", className: "text-ink-700", children: invite.email }), jsxs(Text, { size: "xs", className: "text-ink-400", children: ["Sent ", formatRelativeTime(invite.sentAt)] })] }), onCancelInvite && (jsx("button", { onClick: () => onCancelInvite(invite.email), className: "p-1 rounded hover:bg-paper-100 text-ink-400 hover:text-error-500 transition-colors", "aria-label": `Cancel invitation to ${invite.email}`, children: jsx(X, { className: "w-4 h-4" }) }))] }, invite.email))), hasMorePending && (jsx("div", { className: "px-3 py-2 text-center", children: jsxs(Text, { size: "sm", className: "text-ink-400", children: ["+", pending.length - maxPending, " more"] }) }))] })] }))] }) }));
|
|
5505
|
+
`, children: jsxs(Stack, { gap: "md", children: [jsxs(Stack, { direction: "horizontal", gap: "sm", align: "center", children: [jsx("div", { className: "p-2 bg-accent-100 rounded-lg", children: jsx(Mail, { className: "w-5 h-5 text-accent-600" }) }), jsxs("div", { children: [jsx(Text, { weight: "semibold", className: "text-ink-800", children: "Invite People" }), jsx(Text, { size: "sm", className: "text-ink-500", children: "Share access via email" })] })] }), jsx("form", { onSubmit: handleSubmit, children: jsxs(Stack, { direction: "horizontal", gap: "sm", children: [jsx("div", { className: "flex-1", children: jsx(Input, { type: "email", placeholder: "Enter email address", value: email, onChange: (e) => handleEmailChange(e.target.value), validationState: error ? 'error' : undefined, validationMessage: error || undefined, disabled: loading }) }), jsx(Button, { type: "submit", variant: "primary", loading: loading, disabled: !email.trim(), icon: jsx(Send, { className: "w-4 h-4" }), children: "Send" })] }) }), displayedPending.length > 0 && (jsxs(Stack, { gap: "sm", children: [jsxs(Stack, { direction: "horizontal", gap: "xs", align: "center", children: [jsx(Clock, { className: "w-4 h-4 text-ink-400" }), jsxs(Text, { size: "sm", className: "text-ink-500", children: ["Pending invitations (", pending.length, ")"] })] }), jsxs("div", { className: "border border-paper-200 rounded-lg divide-y divide-paper-200", children: [displayedPending.map((invite) => (jsxs("div", { className: "px-3 py-2 flex items-center justify-between", children: [jsxs(Stack, { gap: "xs", children: [jsx(Text, { size: "sm", weight: "medium", className: "text-ink-700", children: invite.email }), jsxs(Text, { size: "xs", className: "text-ink-400", children: ["Sent ", formatRelativeTime$2(invite.sentAt)] })] }), onCancelInvite && (jsx("button", { onClick: () => onCancelInvite(invite.email), className: "p-1 rounded hover:bg-paper-100 text-ink-400 hover:text-error-500 transition-colors", "aria-label": `Cancel invitation to ${invite.email}`, children: jsx(X, { className: "w-4 h-4" }) }))] }, invite.email))), hasMorePending && (jsx("div", { className: "px-3 py-2 text-center", children: jsxs(Text, { size: "sm", className: "text-ink-400", children: ["+", pending.length - maxPending, " more"] }) }))] })] }))] }) }));
|
|
5506
5506
|
}
|
|
5507
5507
|
|
|
5508
5508
|
/**
|
|
@@ -13185,8 +13185,13 @@ function Sidebar({ items, onNavigate, className = '', header, footer, currentPat
|
|
|
13185
13185
|
};
|
|
13186
13186
|
// Sidebar content (shared between desktop and mobile)
|
|
13187
13187
|
const sidebarContent = (jsxs("div", { ref: sidebarRef, className: `flex flex-col h-full bg-white border-r border-paper-300 notebook-binding ${width} ${className}`, children: [mobileOpen !== undefined && (jsxs("div", { className: "flex items-center justify-between px-4 pt-4 md:hidden", children: [jsx("div", { className: "flex-1", children: header }), jsx("button", { onClick: onMobileClose, className: "\n flex items-center justify-center\n w-10 h-10 -mr-2\n text-ink-500 hover:text-ink-700\n hover:bg-paper-100 rounded-full\n transition-colors\n ", "aria-label": "Close sidebar", children: jsx(X, { className: "w-5 h-5" }) })] })), header && mobileOpen === undefined && (jsx("div", { className: "px-6 pt-6 pb-4", children: header })), header && mobileOpen !== undefined && (jsx("div", { className: "px-6 pt-2 pb-4 hidden md:block", children: header })), jsx("nav", { className: "flex-1 px-3 py-2 space-y-1 overflow-y-auto", children: items.map((item) => {
|
|
13188
|
-
// Render separator
|
|
13188
|
+
// Render separator or section header
|
|
13189
13189
|
if (item.separator) {
|
|
13190
|
+
// Section header: separator with a label
|
|
13191
|
+
if (item.label) {
|
|
13192
|
+
return (jsx("div", { className: "mt-6 mb-2 px-3", "data-testid": item.dataAttributes?.['data-testid'] || `sidebar-section-${item.id}`, ...item.dataAttributes, children: jsx("div", { className: "border-t border-paper-300 pt-3", children: jsx("span", { className: "text-[10px] font-semibold uppercase tracking-widest text-ink-400", children: item.label }) }) }, item.id));
|
|
13193
|
+
}
|
|
13194
|
+
// Plain separator: just a line
|
|
13190
13195
|
return (jsx("div", { className: "my-4 border-t border-paper-300", "data-testid": item.dataAttributes?.['data-testid'] || `sidebar-separator-${item.id}`, ...item.dataAttributes }, item.id));
|
|
13191
13196
|
}
|
|
13192
13197
|
// Render nav item
|
|
@@ -61826,7 +61831,7 @@ function AdminModal({ isOpen, onClose, title, subtitle, onSubmit, isSaving = fal
|
|
|
61826
61831
|
};
|
|
61827
61832
|
return (jsx("div", { className: "fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4 admin-modal-overlay", children: jsxs("div", { className: `bg-white rounded-lg w-full ${sizeClasses[size]} flex flex-col overflow-hidden shadow-2xl admin-modal-content`, style: { height: height }, children: [jsx("div", { className: "fixed inset-0 pointer-events-none admin-modal-sidebar-placeholder" }), jsxs("div", { className: "px-6 py-4 border-b", children: [jsx("h3", { className: "text-lg font-semibold", children: title }), subtitle && jsx("p", { className: "text-sm text-gray-500 mt-1", children: subtitle })] }), tabs.length > 1 && (jsx("div", { className: "border-b border-gray-200 bg-white", children: jsx("nav", { className: "-mb-px flex items-center px-6 admin-modal-tabs", "aria-label": "Tabs", children: tabs.map((tab, index) => (jsxs(React__default.Fragment, { children: [jsx("button", { type: "button", onClick: () => onTabChange(tab.id), className: `whitespace-nowrap border-b-2 py-3 px-4 text-sm font-medium transition-colors ${activeTabId === tab.id
|
|
61828
61833
|
? 'border-blue-500 text-blue-600'
|
|
61829
|
-
: 'border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700'}`, "aria-current": activeTabId === tab.id ? 'page' : undefined, children: tab.label }), index < tabs.length - 1 && (jsx("div", { className: "admin-modal-tab-separator" }))] }, tab.id))) }) })), onSubmit ? (jsx("form", { className: "flex-1 overflow-y-auto min-h-0 h-0 px-6 py-6 admin-modal-form", onSubmit: handleFormSubmit, id: formId, children: activeTab?.content || children })) : (jsx("div", { className: "flex-1 overflow-y-auto min-h-0 h-0 px-6 py-6 admin-modal-content-area", children: activeTab?.content || children })), jsxs("div", { className: "px-6 py-4 border-t bg-gray-50 flex justify-between gap-3", children: [jsx("button", { type: "button", onClick: onClose, className: "px-4 py-2 text-sm text-gray-600 hover:text-gray-800", disabled: isSaving, children: "Cancel" }), jsxs("div", { className: "flex gap-3", children: [customFooterActions, onSubmit && (jsx("button", { type: "submit", form: formId, disabled: isSaving, className: "px-4 py-2 text-sm bg-primary-600 text-white rounded hover:bg-primary-700 disabled:opacity-50 disabled:cursor-not-allowed", children: isSaving ? 'Saving...' : 'Save Changes' }))] })] })] }) }));
|
|
61834
|
+
: 'border-transparent text-gray-500 hover:border-gray-300 hover:text-gray-700'}`, "aria-current": activeTabId === tab.id ? 'page' : undefined, children: tab.label }), index < tabs.length - 1 && (jsx("div", { className: "admin-modal-tab-separator" }))] }, tab.id))) }) })), onSubmit ? (jsx("form", { className: "flex-1 overflow-y-auto min-h-0 h-0 px-6 py-6 admin-modal-form", onSubmit: handleFormSubmit, id: formId, noValidate: true, children: activeTab?.content || children })) : (jsx("div", { className: "flex-1 overflow-y-auto min-h-0 h-0 px-6 py-6 admin-modal-content-area", children: activeTab?.content || children })), jsxs("div", { className: "px-6 py-4 border-t bg-gray-50 flex justify-between gap-3", children: [jsx("button", { type: "button", onClick: onClose, className: "px-4 py-2 text-sm text-gray-600 hover:text-gray-800", disabled: isSaving, children: "Cancel" }), jsxs("div", { className: "flex gap-3", children: [customFooterActions, onSubmit && (jsx("button", { type: "submit", form: formId, disabled: isSaving, className: "px-4 py-2 text-sm bg-primary-600 text-white rounded hover:bg-primary-700 disabled:opacity-50 disabled:cursor-not-allowed", children: isSaving ? 'Saving...' : 'Save Changes' }))] })] })] }) }));
|
|
61830
61835
|
}
|
|
61831
61836
|
|
|
61832
61837
|
/**
|
|
@@ -62594,5 +62599,148 @@ function Responsive({ mobile, tablet, desktop, }) {
|
|
|
62594
62599
|
return jsx(Fragment, { children: mobile || tablet || desktop });
|
|
62595
62600
|
}
|
|
62596
62601
|
|
|
62597
|
-
|
|
62602
|
+
function formatRelativeTime$1(date) {
|
|
62603
|
+
const now = new Date();
|
|
62604
|
+
const diffMs = now.getTime() - date.getTime();
|
|
62605
|
+
const diffMins = Math.floor(diffMs / 60000);
|
|
62606
|
+
const diffHours = Math.floor(diffMs / 3600000);
|
|
62607
|
+
const diffDays = Math.floor(diffMs / 86400000);
|
|
62608
|
+
if (diffMins < 1)
|
|
62609
|
+
return 'Just now';
|
|
62610
|
+
if (diffMins < 60)
|
|
62611
|
+
return `${diffMins}m ago`;
|
|
62612
|
+
if (diffHours < 24)
|
|
62613
|
+
return `${diffHours}h ago`;
|
|
62614
|
+
if (diffDays < 7)
|
|
62615
|
+
return `${diffDays}d ago`;
|
|
62616
|
+
return date.toLocaleDateString('en-US', { month: 'short', day: 'numeric' });
|
|
62617
|
+
}
|
|
62618
|
+
/**
|
|
62619
|
+
* ChatUI - Conversational chat interface component.
|
|
62620
|
+
*
|
|
62621
|
+
* Renders a scrollable message thread with user/assistant bubbles,
|
|
62622
|
+
* a typing indicator, an input bar with send button (Enter to send,
|
|
62623
|
+
* Shift+Enter for newline), and optional suggested question chips.
|
|
62624
|
+
*
|
|
62625
|
+
* @example
|
|
62626
|
+
* ```tsx
|
|
62627
|
+
* <ChatUI
|
|
62628
|
+
* messages={messages}
|
|
62629
|
+
* inputValue={input}
|
|
62630
|
+
* isLoading={loading}
|
|
62631
|
+
* onInputChange={setInput}
|
|
62632
|
+
* onSend={handleSend}
|
|
62633
|
+
* suggestedQuestions={['What are my top deals?']}
|
|
62634
|
+
* onSuggestedQuestionClick={handleQuestion}
|
|
62635
|
+
* />
|
|
62636
|
+
* ```
|
|
62637
|
+
*/
|
|
62638
|
+
const ChatUI = forwardRef(({ messages, inputValue, isLoading = false, placeholder = 'Ask a question...', suggestedQuestions = [], onInputChange, onSend, onSuggestedQuestionClick, messagesEndRef, height = '600px', className = '', }, ref) => {
|
|
62639
|
+
const handleKeyDown = (e) => {
|
|
62640
|
+
if (e.key === 'Enter' && !e.shiftKey) {
|
|
62641
|
+
e.preventDefault();
|
|
62642
|
+
if (inputValue.trim()) {
|
|
62643
|
+
onSend();
|
|
62644
|
+
}
|
|
62645
|
+
}
|
|
62646
|
+
};
|
|
62647
|
+
return (jsxs("div", { ref: ref, className: `flex flex-col bg-white rounded-lg border border-paper-200 overflow-hidden ${className}`, style: { height }, children: [jsxs("div", { className: "flex-1 overflow-y-auto p-4 space-y-4", children: [messages.length === 0 && !isLoading && (jsxs("div", { className: "flex flex-col items-center justify-center h-full text-center", children: [jsx(Bot, { className: "w-10 h-10 text-ink-300 mb-3" }), jsx("p", { className: "text-ink-500 text-sm", children: "No messages yet. Start a conversation!" })] })), messages.map((message) => (jsxs("div", { className: `flex gap-3 ${message.role === 'user' ? 'flex-row-reverse' : 'flex-row'}`, children: [jsx("div", { className: `flex-shrink-0 w-8 h-8 rounded-full flex items-center justify-center ${message.role === 'user'
|
|
62648
|
+
? 'bg-primary-100 text-primary-600'
|
|
62649
|
+
: 'bg-paper-200 text-ink-500'}`, children: message.role === 'user' ? (jsx(User, { className: "w-4 h-4" })) : (jsx(Bot, { className: "w-4 h-4" })) }), jsxs("div", { className: `max-w-[75%] rounded-xl px-4 py-2.5 ${message.role === 'user'
|
|
62650
|
+
? 'bg-primary-500 text-white rounded-br-sm'
|
|
62651
|
+
: 'bg-paper-100 text-ink-800 border border-paper-200 rounded-bl-sm'}`, children: [jsx("p", { className: "text-sm whitespace-pre-wrap", children: message.content }), jsx("p", { className: `text-[10px] mt-1 ${message.role === 'user' ? 'text-primary-200' : 'text-ink-400'}`, children: formatRelativeTime$1(message.timestamp) })] })] }, message.id))), isLoading && (jsxs("div", { className: "flex gap-3", children: [jsx("div", { className: "flex-shrink-0 w-8 h-8 rounded-full bg-paper-200 text-ink-500 flex items-center justify-center", children: jsx(Bot, { className: "w-4 h-4" }) }), jsx("div", { className: "bg-paper-100 border border-paper-200 rounded-xl rounded-bl-sm px-4 py-3", children: jsxs("div", { className: "flex gap-1.5", children: [jsx("span", { className: "w-2 h-2 bg-ink-400 rounded-full animate-bounce", style: { animationDelay: '0ms' } }), jsx("span", { className: "w-2 h-2 bg-ink-400 rounded-full animate-bounce", style: { animationDelay: '150ms' } }), jsx("span", { className: "w-2 h-2 bg-ink-400 rounded-full animate-bounce", style: { animationDelay: '300ms' } })] }) })] })), messagesEndRef && jsx("div", { ref: messagesEndRef })] }), suggestedQuestions.length > 0 && messages.length === 0 && (jsx("div", { className: "px-4 pb-2 flex flex-wrap gap-2", children: suggestedQuestions.map((question, index) => (jsx("button", { onClick: () => onSuggestedQuestionClick?.(question), className: "text-xs px-3 py-1.5 rounded-full border border-primary-200 text-primary-700 bg-primary-50 hover:bg-primary-100 transition-colors", children: question }, index))) })), jsx("div", { className: "border-t border-paper-200 p-3 bg-paper-50", children: jsxs("div", { className: "flex items-end gap-2", children: [jsx("textarea", { value: inputValue, onChange: (e) => onInputChange(e.target.value), onKeyDown: handleKeyDown, placeholder: placeholder, rows: 1, className: "flex-1 resize-none rounded-lg border border-paper-300 bg-white px-3 py-2 text-sm text-ink-800 placeholder:text-ink-400 focus:outline-none focus:ring-2 focus:ring-primary-300 focus:border-primary-300" }), jsx("button", { onClick: onSend, disabled: !inputValue.trim() || isLoading, className: "flex-shrink-0 p-2 rounded-lg bg-primary-500 text-white hover:bg-primary-600 disabled:opacity-40 disabled:cursor-not-allowed transition-colors", "aria-label": "Send message", children: jsx(Send, { className: "w-4 h-4" }) })] }) })] }));
|
|
62652
|
+
});
|
|
62653
|
+
ChatUI.displayName = 'ChatUI';
|
|
62654
|
+
|
|
62655
|
+
const FILTER_OPTIONS = [
|
|
62656
|
+
{ key: 'all', label: 'All' },
|
|
62657
|
+
{ key: 'trend', label: 'Trends' },
|
|
62658
|
+
{ key: 'anomaly', label: 'Anomalies' },
|
|
62659
|
+
{ key: 'forecast', label: 'Forecasts' },
|
|
62660
|
+
{ key: 'recommendation', label: 'Recommendations' },
|
|
62661
|
+
];
|
|
62662
|
+
function getTypeIcon(type) {
|
|
62663
|
+
switch (type) {
|
|
62664
|
+
case 'trend':
|
|
62665
|
+
return jsx(TrendingUp, { className: "w-4 h-4 text-green-600" });
|
|
62666
|
+
case 'anomaly':
|
|
62667
|
+
return jsx(AlertTriangle, { className: "w-4 h-4 text-red-600" });
|
|
62668
|
+
case 'forecast':
|
|
62669
|
+
return jsx(Target, { className: "w-4 h-4 text-purple-600" });
|
|
62670
|
+
case 'recommendation':
|
|
62671
|
+
return jsx(Lightbulb, { className: "w-4 h-4 text-amber-600" });
|
|
62672
|
+
}
|
|
62673
|
+
}
|
|
62674
|
+
function getTypeBgColor(type) {
|
|
62675
|
+
switch (type) {
|
|
62676
|
+
case 'trend': return 'bg-green-50';
|
|
62677
|
+
case 'anomaly': return 'bg-red-50';
|
|
62678
|
+
case 'forecast': return 'bg-purple-50';
|
|
62679
|
+
case 'recommendation': return 'bg-amber-50';
|
|
62680
|
+
}
|
|
62681
|
+
}
|
|
62682
|
+
function getConfidenceBadge(confidence) {
|
|
62683
|
+
const pct = Math.round(confidence * 100);
|
|
62684
|
+
let colorClasses;
|
|
62685
|
+
if (confidence >= 0.8) {
|
|
62686
|
+
colorClasses = 'bg-green-100 text-green-700';
|
|
62687
|
+
}
|
|
62688
|
+
else if (confidence >= 0.6) {
|
|
62689
|
+
colorClasses = 'bg-yellow-100 text-yellow-700';
|
|
62690
|
+
}
|
|
62691
|
+
else {
|
|
62692
|
+
colorClasses = 'bg-red-100 text-red-700';
|
|
62693
|
+
}
|
|
62694
|
+
return (jsxs("span", { className: `inline-flex items-center text-[10px] font-medium px-1.5 py-0.5 rounded-full ${colorClasses}`, children: [pct, "%"] }));
|
|
62695
|
+
}
|
|
62696
|
+
function formatRelativeTime(date) {
|
|
62697
|
+
const now = new Date();
|
|
62698
|
+
const diffMs = now.getTime() - date.getTime();
|
|
62699
|
+
const diffMins = Math.floor(diffMs / 60000);
|
|
62700
|
+
const diffHours = Math.floor(diffMs / 3600000);
|
|
62701
|
+
const diffDays = Math.floor(diffMs / 86400000);
|
|
62702
|
+
if (diffMins < 1)
|
|
62703
|
+
return 'Just now';
|
|
62704
|
+
if (diffMins < 60)
|
|
62705
|
+
return `${diffMins}m ago`;
|
|
62706
|
+
if (diffHours < 24)
|
|
62707
|
+
return `${diffHours}h ago`;
|
|
62708
|
+
if (diffDays < 7)
|
|
62709
|
+
return `${diffDays}d ago`;
|
|
62710
|
+
return date.toLocaleDateString('en-US', { month: 'short', day: 'numeric' });
|
|
62711
|
+
}
|
|
62712
|
+
/**
|
|
62713
|
+
* InsightsPanelUI - Structured display of analytics insights.
|
|
62714
|
+
*
|
|
62715
|
+
* Renders a header with title and refresh button, filter chips
|
|
62716
|
+
* (All / Trends / Anomalies / Forecasts / Recommendations), and
|
|
62717
|
+
* insight cards with type icon, title, summary, confidence badge,
|
|
62718
|
+
* and relative timestamp. Includes loading skeleton and empty state.
|
|
62719
|
+
*
|
|
62720
|
+
* @example
|
|
62721
|
+
* ```tsx
|
|
62722
|
+
* <InsightsPanelUI
|
|
62723
|
+
* insights={insights}
|
|
62724
|
+
* isLoading={loading}
|
|
62725
|
+
* filter={activeFilter}
|
|
62726
|
+
* maxInsights={8}
|
|
62727
|
+
* onFilterChange={setFilter}
|
|
62728
|
+
* onRefresh={refreshInsights}
|
|
62729
|
+
* />
|
|
62730
|
+
* ```
|
|
62731
|
+
*/
|
|
62732
|
+
const InsightsPanelUI = forwardRef(({ insights, isLoading = false, filter = 'all', maxInsights, onFilterChange, onRefresh, className = '', }, ref) => {
|
|
62733
|
+
const filtered = filter === 'all'
|
|
62734
|
+
? insights
|
|
62735
|
+
: insights.filter((i) => i.type === filter);
|
|
62736
|
+
const displayed = maxInsights ? filtered.slice(0, maxInsights) : filtered;
|
|
62737
|
+
return (jsxs("div", { ref: ref, className: `bg-white rounded-lg border border-paper-200 ${className}`, children: [jsxs("div", { className: "flex items-center justify-between px-5 py-4 border-b border-paper-200", children: [jsx("h3", { className: "text-lg font-semibold text-ink-900", children: "AI Insights" }), onRefresh && (jsx("button", { onClick: onRefresh, disabled: isLoading, className: "p-1.5 rounded-md text-ink-500 hover:text-ink-700 hover:bg-paper-100 disabled:opacity-40 transition-colors", "aria-label": "Refresh insights", children: jsx(RefreshCw, { className: `w-4 h-4 ${isLoading ? 'animate-spin' : ''}` }) }))] }), onFilterChange && (jsx("div", { className: "px-5 pt-3 pb-1 flex flex-wrap gap-2", children: FILTER_OPTIONS.map((opt) => (jsx("button", { onClick: () => onFilterChange(opt.key), className: `text-xs font-medium px-3 py-1.5 rounded-full transition-colors ${filter === opt.key
|
|
62738
|
+
? 'bg-primary-500 text-white'
|
|
62739
|
+
: 'bg-paper-100 text-ink-600 hover:bg-paper-200'}`, children: opt.label }, opt.key))) })), jsxs("div", { className: "p-5 space-y-3", children: [isLoading && displayed.length === 0 && (jsx("div", { className: "space-y-3", children: [1, 2, 3].map((i) => (jsxs("div", { className: "animate-pulse rounded-lg border border-paper-200 p-4", children: [jsxs("div", { className: "flex items-center gap-3 mb-2", children: [jsx("div", { className: "w-8 h-8 bg-paper-200 rounded-lg" }), jsxs("div", { className: "flex-1", children: [jsx("div", { className: "h-4 bg-paper-200 rounded w-2/3 mb-1" }), jsx("div", { className: "h-3 bg-paper-100 rounded w-1/3" })] })] }), jsx("div", { className: "h-3 bg-paper-100 rounded w-full mb-1" }), jsx("div", { className: "h-3 bg-paper-100 rounded w-4/5" })] }, i))) })), !isLoading && displayed.length === 0 && (jsxs("div", { className: "text-center py-8", children: [jsx(BrainCircuit, { className: "w-10 h-10 text-ink-300 mx-auto mb-3" }), jsx("p", { className: "text-ink-500 text-sm", children: filter === 'all'
|
|
62740
|
+
? 'No insights available yet.'
|
|
62741
|
+
: `No ${filter} insights found.` })] })), displayed.map((insight) => (jsx("div", { className: "rounded-lg border border-paper-200 p-4 hover:shadow-sm transition-shadow", children: jsxs("div", { className: "flex items-start gap-3", children: [jsx("div", { className: `flex-shrink-0 w-8 h-8 rounded-lg flex items-center justify-center ${getTypeBgColor(insight.type)}`, children: getTypeIcon(insight.type) }), jsxs("div", { className: "flex-1 min-w-0", children: [jsxs("div", { className: "flex items-center justify-between gap-2 mb-1", children: [jsx("h4", { className: "text-sm font-medium text-ink-900 truncate", children: insight.title }), getConfidenceBadge(insight.confidence)] }), jsx("p", { className: "text-xs text-ink-600 leading-relaxed", children: insight.summary }), jsx("p", { className: "text-[10px] text-ink-400 mt-1.5", children: formatRelativeTime(insight.timestamp) })] })] }) }, insight.id)))] })] }));
|
|
62742
|
+
});
|
|
62743
|
+
InsightsPanelUI.displayName = 'InsightsPanelUI';
|
|
62744
|
+
|
|
62745
|
+
export { Accordion, AchievementBadge, AchievementUnlock, ActionBar, ActionBarCenter, ActionBarLeft, ActionBarRight, ActionButton, ActionCard, ActivityFeed, AdminModal, Alert, AlertDialog, AnomalyBanner, AppLayout, Autocomplete, Avatar, BREAKPOINTS, Badge, BottomNavigation, BottomNavigationSpacer, BottomSheet, BottomSheetActions, BottomSheetContent, BottomSheetHeader, Box, Breadcrumbs, Button, ButtonGroup, Calendar, Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle, CardView, Carousel, CaseQueueItem, Celebration, ChatUI, Checkbox, CheckboxList, Chip, ChipGroup, CollaboratorAvatars, Collapsible, CollapsibleSection, ColorPicker, Combobox, ComingSoon, CommandPalette, CompactStat, ConfidenceBadge, ConfidenceIndicator, ConfirmDialog, ContextMenu, ControlBar, CurrencyDisplay, CurrencyInput, Dashboard, DashboardContent, DashboardHeader, DataGrid, DataTable, DataTableCardView, DateDisplay, DatePicker, DateRangePicker, DateTimePicker, DesktopOnly, Drawer, DrawerFooter, DropZone, Dropdown, DropdownTrigger, EmptyState, EntityCard, ErrorBoundary, ExpandablePanel, ExpandablePanelContainer, ExpandablePanelSpacer, ExpandableRowButton, ExpandableToolbar, ExpandedRowEditForm, ExportButton, FORMULA_CATEGORIES, FORMULA_DEFINITIONS, FORMULA_NAMES, FieldArray, FileUpload, FilterBar, FilterControls, FilterStatusBanner, FloatingActionButton, Form, FormContext, FormControl, FormWizard, FunnelChart, Grid, GridItem, HelpTooltip, Hide, HorizontalScroll, HoverCard, InfiniteScroll, Input, InsightsPanelUI, InviteCard, KanbanBoard, Layout, Loading, LoadingOverlay, Logo, MarkdownEditor, MaskedInput, MatchIndicator, Menu, MenuDivider, MobileHeader, MobileHeaderSpacer, MobileLayout, MobileOnly, MobileProvider, Modal, ModalFooter, MotivationalMessage, MultiSelect, NotificationBanner, NotificationBar, NotificationBell, NotificationIndicator, NumberInput, Page, PageHeader, PageLayout, PageNavigation, Pagination, PasswordInput, PermissionBadge, PersonaDashboard, PivotTable, Popover, PriorityAlertBanner, ProcessHealthBar, ProcessIndicator, Progress, ProgressCelebration, PullToRefresh, QueryTransparency, RadioGroup, Rating, Responsive, ReviewDecisionCard, RichTextEditor, SLAIndicator, SearchBar, SearchableList, Select, Separator, SharedBadge, Show, Sidebar, SidebarGroup, Skeleton, SkeletonCard$1 as SkeletonCard, SkeletonTable, SkipLink, Slider, SplitPane, Spreadsheet, SpreadsheetReport, Stack, StatCard, StatItem, StatsCardGrid, StatsGrid, StatusBadge, StatusBar, StepIndicator, Stepper, StreakBadge, SuccessCheck, SummaryCard, SwipeActions, SwipeableCard, SwipeableListItem, Switch, SystemActionEntry, Tabs, TabsContent, TabsList, TabsRoot, TabsTrigger, Text, Textarea, ThemeToggle, TimePicker, Timeline, TimezoneSelector, Toast, ToastContainer, Tooltip, Transfer, TreeView, TwoColumnContent, UserProfileButton, VarianceDisplay, addErrorMessage, addInfoMessage, addSuccessMessage, addWarningMessage, calculateColumnWidth, createActionsSection, createFiltersSection, createMultiSheetExcel, createPageControlsSection, createQueryDetailsSection, exportDataTableToExcel, exportToExcel, formatStatisticValue, formatStatistics, getFormula, getFormulasByCategory, getLocalTimezone, isValidTimezone, loadColumnOrder, loadColumnWidths, reorderArray, saveColumnOrder, saveColumnWidths, searchFormulas, statusManager, useBreadcrumbReset, useBreakpoint, useBreakpointValue, useCelebration, useColumnReorder, useColumnResize, useCommandPalette, useConfirmDialog, useDelighters, useFABScroll, useFormContext, useIsDesktop, useIsMobile, useIsTablet, useIsTouchDevice, useMediaQuery, useMobileContext, useOrientation, usePrefersMobile, useResponsiveCallback, useSafeAreaInsets, useViewportSize, withMobileContext };
|
|
62598
62746
|
//# sourceMappingURL=index.esm.js.map
|