@istmx/ui 0.1.8 → 0.1.10

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 (32) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +115 -1
  3. package/bin/istmx.mjs +53 -12
  4. package/package.json +2 -2
  5. package/registry/ai-chat-block/ai-chat-block.tsx +460 -0
  6. package/registry/ai-chat-block/ai-chat-input.tsx +690 -0
  7. package/registry/ai-chat-block/attachment.tsx +605 -0
  8. package/registry/ai-chat-block/chat-code-block.tsx +50 -0
  9. package/registry/ai-chat-block/chat-composer.tsx +51 -0
  10. package/registry/ai-chat-block/chat-logo.tsx +18 -0
  11. package/registry/ai-chat-block/chat-message.tsx +161 -0
  12. package/registry/ai-chat-block/chat-sidebar.tsx +273 -0
  13. package/registry/ai-chat-block/chat-user-avatar.tsx +9 -0
  14. package/registry/ai-chat-block/code-highlighter.tsx +357 -0
  15. package/registry/ai-chat-block/default-attachments.tsx +42 -0
  16. package/registry/ai-chat-block/index.ts +16 -0
  17. package/registry/ai-chat-block/message-content.tsx +287 -0
  18. package/registry/ai-chat-block/message-list.tsx +93 -0
  19. package/registry/ai-chat-block/send-button.tsx +102 -0
  20. package/registry/ai-chat-block/types.ts +71 -0
  21. package/registry/ai-chat-block/utils.ts +6 -0
  22. package/registry/ai-chat-block/voice-button.tsx +66 -0
  23. package/registry/ai-chat-input/ai-chat-input.tsx +690 -0
  24. package/registry/ai-chat-input/attachment.tsx +605 -0
  25. package/registry/ai-chat-input/send-button.tsx +102 -0
  26. package/registry/ai-chat-input/types.ts +71 -0
  27. package/registry/ai-chat-input/utils.ts +6 -0
  28. package/registry/ai-chat-input/voice-button.tsx +66 -0
  29. package/registry/button.tsx +4 -7
  30. package/registry/streaming-text.tsx +278 -0
  31. package/registry/text-reveal.tsx +307 -0
  32. package/registry/image-effects-card.tsx +0 -197
@@ -0,0 +1,18 @@
1
+ export default function ChatLogo({ className = '' }: { className?: string }) {
2
+ return (
3
+ <svg
4
+ xmlns="http://www.w3.org/2000/svg"
5
+ viewBox="0 0 512 512"
6
+ fill="none"
7
+ aria-label="istmX"
8
+ className={className}
9
+ >
10
+ <g fill="currentColor">
11
+ <path d="M118 132L238 132L304 211L247 269L191 205L151 247V334H118V132Z" />
12
+ <path d="M129 401L157 350L362 145L408 100L382 164L334 219L276 277L407 407H302L225 329L129 401Z" />
13
+ <path d="M273 151H320L296 198L273 151Z" />
14
+ <path d="M224 365H271L247 319L224 365Z" />
15
+ </g>
16
+ </svg>
17
+ )
18
+ }
@@ -0,0 +1,161 @@
1
+ 'use client'
2
+
3
+ import { memo, useState } from 'react'
4
+ import type { ReactNode } from 'react'
5
+ import { AnimatePresence, motion, useReducedMotion } from 'motion/react'
6
+ import { IconUser, IconX } from '@tabler/icons-react'
7
+ import type { ChatAttachment, ChatTurn } from './types'
8
+ import MessageContent from './message-content'
9
+ import ChatLogo from './chat-logo'
10
+ import { AttachmentPreview } from './attachment'
11
+
12
+ function formatBytes(size: number) {
13
+ if (size < 1024) return `${size} B`
14
+ if (size < 1024 * 1024) return `${Math.round(size / 1024)} KB`
15
+ return `${(size / (1024 * 1024)).toFixed(1)} MB`
16
+ }
17
+
18
+ function MessageFiles({ files }: { files: readonly ChatAttachment[] }) {
19
+ return (
20
+ <ul className="mt-2 flex flex-wrap gap-2">
21
+ {files.map((file) => (
22
+ <li
23
+ key={file.id}
24
+ className="border-border/70 bg-background/70 flex max-w-[15rem] items-center gap-2 rounded-xl border p-1.5"
25
+ >
26
+ <AttachmentPreview file={file.file} name={file.name} kind={file.kind} thumbnailClassName="size-12 rounded-lg" />
27
+ <span className="min-w-0 pr-2">
28
+ <span className="block truncate text-xs font-medium">{file.name}</span>
29
+ <span className="text-muted mt-0.5 block font-mono text-[9px] uppercase">
30
+ {formatBytes(file.size)}
31
+ </span>
32
+ </span>
33
+ </li>
34
+ ))}
35
+ </ul>
36
+ )
37
+ }
38
+
39
+ export type ChatMessageProps = {
40
+ turn: ChatTurn
41
+ userName: string
42
+ assistantName: string
43
+ userAvatar?: ReactNode
44
+ assistantAvatar?: ReactNode
45
+ onRetry?: () => void
46
+ retryDisabled?: boolean
47
+ }
48
+
49
+ function ChatMessage({
50
+ turn,
51
+ userName,
52
+ assistantName,
53
+ userAvatar,
54
+ assistantAvatar,
55
+ onRetry,
56
+ retryDisabled,
57
+ }: ChatMessageProps) {
58
+ const reduceMotion = useReducedMotion()
59
+ const [manualThinkingOpen, setManualThinkingOpen] = useState<boolean | null>(null)
60
+ const user = turn.role === 'user'
61
+ const name = user ? userName : assistantName
62
+ const avatar = user ? userAvatar : assistantAvatar
63
+
64
+ const thinkingOpen = manualThinkingOpen ?? turn.status === 'streaming'
65
+
66
+ return (
67
+ <motion.article
68
+ layout={!reduceMotion && turn.status !== 'streaming'}
69
+ initial={reduceMotion ? { opacity: 0 } : { opacity: 0, y: 10 }}
70
+ animate={{ opacity: 1, y: 0 }}
71
+ transition={reduceMotion ? { duration: 0.1 } : { duration: 0.24, ease: 'easeOut' }}
72
+ aria-label={`${name} message`}
73
+ className={`flex items-start gap-2.5 sm:gap-3 ${user ? 'flex-row-reverse' : ''}`}
74
+ >
75
+ <span
76
+ aria-hidden="true"
77
+ className={`border-border/70 flex size-8 shrink-0 items-center justify-center overflow-hidden rounded-full border ${user ? 'bg-surface/70 text-muted' : 'bg-[var(--chat-accent,var(--foreground))] text-white'}`}
78
+ >
79
+ {avatar ??
80
+ (user ? (
81
+ <IconUser size={15} stroke={1.7} />
82
+ ) : (
83
+ <ChatLogo className="size-4" />
84
+ ))}
85
+ </span>
86
+
87
+ <div className={`min-w-0 max-w-[min(88%,44rem)] ${user ? 'items-end' : 'items-start'} flex flex-col`}>
88
+ <span className={`text-muted mb-1 px-1 text-[10px] ${user ? 'text-right' : ''}`}>
89
+ {name}
90
+ </span>
91
+ {turn.content || !user ? (
92
+ <div className={`min-w-0 ${user ? 'rounded-2xl rounded-tr-md border border-[var(--chat-accent)]/80 bg-[var(--chat-accent)] px-3.5 py-2.5 text-white shadow-sm sm:px-4 sm:py-3' : 'w-full px-0 py-0 text-foreground'}`}>
93
+ {!user && (turn.thinking || turn.status === 'streaming') ? (
94
+ <div className="mb-2 max-w-full">
95
+ <button type="button" aria-expanded={thinkingOpen} onClick={() => setManualThinkingOpen(!thinkingOpen)} className="text-muted hover:text-foreground w-fit cursor-pointer text-left text-[11px] transition-colors">
96
+ <span className="inline-flex items-center gap-1.5">
97
+ {turn.thinkingStatus === 'thinking' ? (
98
+ <span className="bg-[var(--chat-accent)] size-1.5 animate-pulse rounded-full" />
99
+ ) : null}
100
+ {turn.thinkingStatus === 'thinking' ? 'Thinking…' : 'Thought process'}
101
+ </span>
102
+ </button>
103
+ {thinkingOpen && turn.thinking ? <p className="text-muted mt-2 whitespace-pre-wrap text-xs leading-5">{turn.thinking}</p> : null}
104
+ </div>
105
+ ) : null}
106
+ {turn.content ? (
107
+ <MessageContent
108
+ content={turn.content}
109
+ streaming={turn.status === 'streaming'}
110
+ streamingDelta={turn.streamingDelta}
111
+ />
112
+ ) : turn.status === 'streaming' ? (
113
+ <MessageContent content="" streaming />
114
+ ) : null}
115
+ {!user && turn.attachments?.length ? (
116
+ <MessageFiles files={turn.attachments} />
117
+ ) : null}
118
+ </div>
119
+ ) : null}
120
+ {user && turn.attachments?.length ? (
121
+ <div className="mt-2 flex w-full justify-end">
122
+ <MessageFiles files={turn.attachments} />
123
+ </div>
124
+ ) : null}
125
+ <AnimatePresence>
126
+ {turn.status === 'error' && turn.error ? (
127
+ <motion.div
128
+ initial={{ opacity: 0, height: 0, y: 5 }}
129
+ animate={{ opacity: 1, height: 'auto', y: 0 }}
130
+ exit={{ opacity: 0, height: 0 }}
131
+ className="border-rose-500/30 bg-rose-500/5 mt-2 flex max-w-full items-start gap-2 rounded-xl border px-3 py-2.5 text-xs text-rose-200"
132
+ role="alert"
133
+ >
134
+ <IconX size={14} stroke={1.8} className="mt-0.5 shrink-0" aria-hidden="true" />
135
+ <span className="min-w-0 flex-1 leading-5">
136
+ {turn.error.message}
137
+ {turn.error.retryAfterMs ? (
138
+ <span className="text-rose-200/70 mt-0.5 block font-mono text-[10px]">
139
+ Retry after {Math.ceil(turn.error.retryAfterMs / 1000)}s
140
+ </span>
141
+ ) : null}
142
+ </span>
143
+ {onRetry ? (
144
+ <button
145
+ type="button"
146
+ onClick={onRetry}
147
+ disabled={retryDisabled}
148
+ className="shrink-0 cursor-pointer rounded-md px-2 py-1 font-medium text-rose-100 underline underline-offset-2 disabled:cursor-not-allowed disabled:opacity-45"
149
+ >
150
+ Retry
151
+ </button>
152
+ ) : null}
153
+ </motion.div>
154
+ ) : null}
155
+ </AnimatePresence>
156
+ </div>
157
+ </motion.article>
158
+ )
159
+ }
160
+
161
+ export default memo(ChatMessage)
@@ -0,0 +1,273 @@
1
+ 'use client'
2
+
3
+ import {
4
+ IconArchive,
5
+ IconDots,
6
+ IconMessageCircle,
7
+ IconMessageCircleFilled,
8
+ IconPin,
9
+ IconPlus,
10
+ IconRestore,
11
+ IconTrash,
12
+ IconX,
13
+ } from '@tabler/icons-react'
14
+ import type { ReactNode } from 'react'
15
+ import { useEffect, useRef, useState } from 'react'
16
+ import { createPortal } from 'react-dom'
17
+ import { AnimatePresence, motion, useReducedMotion } from 'motion/react'
18
+ import { IconLayoutSidebarLeftCollapse, IconLayoutSidebarLeftExpand } from '@tabler/icons-react'
19
+ import { cn } from './utils'
20
+ import ChatUserAvatar from './chat-user-avatar'
21
+ import ChatLogo from './chat-logo'
22
+
23
+ export type ChatSidebarItem = {
24
+ id: string
25
+ title: string
26
+ pinned?: boolean
27
+ archived?: boolean
28
+ }
29
+
30
+ export type ChatSidebarProps = {
31
+ items: readonly ChatSidebarItem[]
32
+ activeId: string
33
+ userName: string
34
+ userAvatar?: ReactNode
35
+ mobileOpen: boolean
36
+ desktopHidden: boolean
37
+ onToggleDesktop: () => void
38
+ onCloseMobile: () => void
39
+ onNewChat: () => void
40
+ onSelect: (id: string) => void
41
+ onPin: (id: string) => void
42
+ onArchive: (id: string) => void
43
+ onDelete: (id: string) => void
44
+ }
45
+
46
+ export default function ChatSidebar({
47
+ items,
48
+ activeId,
49
+ userName,
50
+ userAvatar,
51
+ mobileOpen,
52
+ desktopHidden,
53
+ onToggleDesktop,
54
+ onCloseMobile,
55
+ onNewChat,
56
+ onSelect,
57
+ onPin,
58
+ onArchive,
59
+ onDelete,
60
+ }: ChatSidebarProps) {
61
+ const [openMenuId, setOpenMenuId] = useState<string | null>(null)
62
+ const [showArchived, setShowArchived] = useState(false)
63
+ const [deleteTarget, setDeleteTarget] = useState<ChatSidebarItem | null>(null)
64
+ const confirmDeleteRef = useRef<HTMLButtonElement>(null)
65
+ const reduceMotion = useReducedMotion()
66
+ const activeItems = items.filter((item) => !item.archived)
67
+ const pinnedItems = activeItems.filter((item) => item.pinned)
68
+ const recentItems = activeItems.filter((item) => !item.pinned)
69
+ const archivedItems = items.filter((item) => item.archived)
70
+
71
+ useEffect(() => {
72
+ if (!deleteTarget) return
73
+ confirmDeleteRef.current?.focus()
74
+ const onKeyDown = (event: KeyboardEvent) => {
75
+ if (event.key === 'Escape') setDeleteTarget(null)
76
+ }
77
+ document.addEventListener('keydown', onKeyDown)
78
+ return () => document.removeEventListener('keydown', onKeyDown)
79
+ }, [deleteTarget])
80
+
81
+ function renderItem(item: ChatSidebarItem) {
82
+ const menuOpen = openMenuId === item.id
83
+ const isActive = activeId === item.id
84
+ return (
85
+ <li key={item.id} className="group relative">
86
+ <button
87
+ type="button"
88
+ onClick={() => {
89
+ onSelect(item.id)
90
+ onCloseMobile()
91
+ setOpenMenuId(null)
92
+ }}
93
+ title={item.title}
94
+ aria-current={activeId === item.id ? 'page' : undefined}
95
+ className={cn(
96
+ 'flex h-9 w-full cursor-pointer items-center gap-2 rounded-lg border px-2.5 pr-9 text-left text-xs transition-colors',
97
+ isActive ? 'border-[var(--chat-accent)]/25 bg-surface/65 text-foreground shadow-sm' : 'border-transparent text-muted hover:border-border/50 hover:bg-surface/40 hover:text-foreground',
98
+ item.archived && 'opacity-70',
99
+ )}
100
+ >
101
+ {item.pinned ? <IconPin size={14} stroke={1.7} className="shrink-0" aria-hidden="true" /> : isActive ? <IconMessageCircleFilled size={15} className="text-[var(--chat-accent)] shrink-0" aria-hidden="true" /> : <IconMessageCircle size={15} stroke={1.6} className="shrink-0" aria-hidden="true" />}
102
+ <span className="min-w-0 flex-1 truncate">{item.title}</span>
103
+ </button>
104
+ <button
105
+ type="button"
106
+ aria-label={`Options for ${item.title}`}
107
+ aria-haspopup="menu"
108
+ aria-expanded={menuOpen}
109
+ title="Chat options"
110
+ onClick={() => setOpenMenuId(menuOpen ? null : item.id)}
111
+ className={cn(
112
+ 'text-muted hover:bg-surface hover:text-foreground absolute right-1 top-1 flex size-7 cursor-pointer items-center justify-center rounded-md opacity-100 transition-opacity sm:opacity-0 sm:group-hover:opacity-100 sm:focus-visible:opacity-100',
113
+ )}
114
+ >
115
+ <IconDots size={16} stroke={1.8} aria-hidden="true" />
116
+ </button>
117
+ {menuOpen ? (
118
+ <div role="menu" aria-label={`${item.title} actions`} className="border-border/70 bg-background absolute right-1 top-9 z-40 min-w-40 rounded-xl border p-1 shadow-xl">
119
+ {!item.archived ? (
120
+ <>
121
+ <button role="menuitem" type="button" onClick={() => { onPin(item.id); setOpenMenuId(null) }} className="text-muted hover:bg-surface hover:text-foreground flex h-8 w-full cursor-pointer items-center gap-2 rounded-lg px-2.5 text-left text-xs">
122
+ <IconPin size={14} aria-hidden="true" />{item.pinned ? 'Unpin chat' : 'Pin chat'}
123
+ </button>
124
+ <button role="menuitem" type="button" onClick={() => { onArchive(item.id); setOpenMenuId(null) }} className="text-muted hover:bg-surface hover:text-foreground flex h-8 w-full cursor-pointer items-center gap-2 rounded-lg px-2.5 text-left text-xs">
125
+ <IconArchive size={14} aria-hidden="true" />Archive chat
126
+ </button>
127
+ </>
128
+ ) : (
129
+ <button role="menuitem" type="button" onClick={() => { onArchive(item.id); setOpenMenuId(null) }} className="text-muted hover:bg-surface hover:text-foreground flex h-8 w-full cursor-pointer items-center gap-2 rounded-lg px-2.5 text-left text-xs">
130
+ <IconRestore size={14} aria-hidden="true" />Restore chat
131
+ </button>
132
+ )}
133
+ <button role="menuitem" type="button" onClick={() => { setDeleteTarget(item); setOpenMenuId(null) }} className="text-rose-400 hover:bg-rose-500/10 flex h-8 w-full cursor-pointer items-center gap-2 rounded-lg px-2.5 text-left text-xs">
134
+ <IconTrash size={14} aria-hidden="true" />Delete chat
135
+ </button>
136
+ </div>
137
+ ) : null}
138
+ </li>
139
+ )
140
+ }
141
+
142
+ return (
143
+ <>
144
+ <button
145
+ type="button"
146
+ aria-label="Close chat history"
147
+ aria-hidden={!mobileOpen}
148
+ tabIndex={mobileOpen ? 0 : -1}
149
+ onClick={onCloseMobile}
150
+ className={cn(
151
+ 'absolute inset-0 z-20 flex cursor-default bg-black/45 opacity-0 transition-opacity duration-300 ease-out motion-reduce:transition-none md:hidden',
152
+ mobileOpen ? 'visible opacity-100' : 'invisible pointer-events-none',
153
+ )}
154
+ />
155
+ <aside
156
+ aria-label="Chat history"
157
+ className={cn(
158
+ 'border-border/70 bg-background absolute inset-y-0 left-0 z-30 flex w-[min(17rem,84vw)] flex-col overflow-hidden border-r shadow-2xl transition-[transform,width,visibility,opacity] duration-300 ease-[cubic-bezier(0.22,1,0.36,1)] motion-reduce:transition-none md:relative md:inset-auto md:z-auto md:w-60 md:shrink-0 md:translate-x-0 md:bg-surface/10 md:shadow-none',
159
+ mobileOpen ? 'visible translate-x-0' : 'invisible -translate-x-full md:visible',
160
+ desktopHidden && 'md:w-14',
161
+ )}
162
+ >
163
+ <div className={cn('border-border/50 flex h-14 shrink-0 items-center gap-2 border-b px-3', desktopHidden && 'md:justify-center md:px-1')}>
164
+ <span className={cn('bg-[var(--chat-accent)] text-white flex size-8 shrink-0 items-center justify-center rounded-xl p-1.5', desktopHidden && 'md:hidden')}>
165
+ <ChatLogo className="size-full" />
166
+ </span>
167
+ <span className={cn('font-display min-w-0 flex-1 truncate text-xs font-semibold', desktopHidden && 'md:hidden')}>istmX chat</span>
168
+ <button type="button" onClick={onToggleDesktop} aria-label={desktopHidden ? 'Expand chat sidebar' : 'Collapse chat sidebar'} title={desktopHidden ? 'Expand sidebar' : 'Collapse sidebar'} className="text-muted hover:text-foreground hidden size-8 shrink-0 cursor-pointer items-center justify-center rounded-lg transition-colors md:flex">
169
+ {desktopHidden ? <IconLayoutSidebarLeftExpand size={17} stroke={1.7} /> : <IconLayoutSidebarLeftCollapse size={17} stroke={1.7} />}
170
+ </button>
171
+ <button type="button" onClick={onCloseMobile} aria-label="Close chat sidebar" className="text-muted hover:text-foreground ml-auto flex size-8 cursor-pointer items-center justify-center rounded-lg md:hidden">
172
+ <IconX size={16} stroke={1.8} />
173
+ </button>
174
+ </div>
175
+
176
+ <div className={cn('px-2 pb-3', desktopHidden && 'md:hidden')}>
177
+ <button
178
+ type="button"
179
+ onClick={onNewChat}
180
+ title="New chat"
181
+ className={cn(
182
+ 'border-border/70 text-foreground hover:bg-surface/50 flex h-9 w-full cursor-pointer items-center gap-2 rounded-xl border px-2.5 text-left text-xs transition-colors',
183
+ )}
184
+ >
185
+ <IconPlus size={16} stroke={1.8} aria-hidden="true" />
186
+ <span>New chat</span>
187
+ </button>
188
+ </div>
189
+
190
+ <nav aria-label="Chat history" className={cn('[scrollbar-width:none] [&::-webkit-scrollbar]:hidden min-h-0 flex-1 overflow-y-auto overscroll-contain px-2 pb-3', desktopHidden && 'md:hidden')}>
191
+ {pinnedItems.length ? (
192
+ <section className="mb-3">
193
+ <h3 className="text-muted px-2 pb-1.5 pt-1 font-mono text-[9px] tracking-[0.14em] uppercase">Pinned</h3>
194
+ <ul className="space-y-0.5">{pinnedItems.map(renderItem)}</ul>
195
+ </section>
196
+ ) : null}
197
+ <section>
198
+ <h3 className="text-muted px-2 pb-1.5 pt-1 font-mono text-[9px] tracking-[0.14em] uppercase">Recent chats</h3>
199
+ <ul className="space-y-0.5">{recentItems.map(renderItem)}</ul>
200
+ </section>
201
+ {archivedItems.length ? (
202
+ <section className="mt-3">
203
+ <button type="button" aria-expanded={showArchived} onClick={() => setShowArchived((show) => !show)} className="text-muted hover:text-foreground flex h-8 w-full cursor-pointer items-center gap-2 px-2 text-left font-mono text-[9px] tracking-[0.14em] uppercase">
204
+ <IconArchive size={14} aria-hidden="true" />
205
+ <span>Archived · {archivedItems.length}</span>
206
+ </button>
207
+ {showArchived ? <ul className="space-y-0.5">{archivedItems.map(renderItem)}</ul> : null}
208
+ </section>
209
+ ) : null}
210
+ </nav>
211
+
212
+ <div className={cn('border-border/60 mt-auto flex min-h-14 items-center gap-2.5 border-t px-3 py-2.5', desktopHidden && 'md:justify-center md:px-1')}>
213
+ <span className="border-border/60 bg-background relative flex size-8 shrink-0 items-center justify-center overflow-hidden rounded-full border">
214
+ {userAvatar ?? <ChatUserAvatar />}
215
+ </span>
216
+ <span className={cn('min-w-0 flex-1', desktopHidden && 'md:hidden')}>
217
+ <span className="text-foreground block truncate text-xs font-medium">{userName}</span>
218
+ <span className="text-muted mt-0.5 block truncate text-[10px]">Preview account</span>
219
+ </span>
220
+ </div>
221
+ </aside>
222
+ {typeof document !== 'undefined' ? createPortal(
223
+ <AnimatePresence>
224
+ {deleteTarget ? (
225
+ <motion.div
226
+ className="fixed inset-0 z-[600] flex items-center justify-center p-4"
227
+ initial={{ opacity: 0 }}
228
+ animate={{ opacity: 1 }}
229
+ exit={{ opacity: 0 }}
230
+ transition={{ duration: reduceMotion ? 0 : 0.16 }}
231
+ onMouseDown={(event) => {
232
+ if (event.target === event.currentTarget) setDeleteTarget(null)
233
+ }}
234
+ >
235
+ <div className="absolute inset-0 bg-black/65 backdrop-blur-sm" aria-hidden="true" />
236
+ <motion.section
237
+ role="alertdialog"
238
+ aria-modal="true"
239
+ aria-labelledby="delete-chat-title"
240
+ aria-describedby="delete-chat-description"
241
+ className="border-border/70 bg-background relative z-10 w-full max-w-sm rounded-2xl border p-5 shadow-2xl"
242
+ initial={reduceMotion ? { scale: 1 } : { opacity: 0, y: 10, scale: 0.97 }}
243
+ animate={{ opacity: 1, y: 0, scale: 1 }}
244
+ exit={reduceMotion ? { opacity: 0 } : { opacity: 0, y: 6, scale: 0.98 }}
245
+ transition={reduceMotion ? { duration: 0 } : { type: 'spring', stiffness: 380, damping: 30 }}
246
+ >
247
+ <h2 id="delete-chat-title" className="font-display text-base font-semibold">Delete this chat?</h2>
248
+ <p id="delete-chat-description" className="text-muted mt-2 text-sm leading-5">
249
+ “{deleteTarget.title}” will be permanently deleted. This can’t be undone.
250
+ </p>
251
+ <div className="mt-5 flex justify-end gap-2">
252
+ <button type="button" onClick={() => setDeleteTarget(null)} className="border-border/70 text-muted hover:bg-surface hover:text-foreground h-9 cursor-pointer rounded-lg border px-3 text-xs font-medium transition-colors">Cancel</button>
253
+ <button
254
+ ref={confirmDeleteRef}
255
+ type="button"
256
+ onClick={() => {
257
+ onDelete(deleteTarget.id)
258
+ setDeleteTarget(null)
259
+ }}
260
+ className="bg-rose-500 text-white hover:bg-rose-400 h-9 cursor-pointer rounded-lg px-3 text-xs font-semibold transition-colors"
261
+ >
262
+ Delete chat
263
+ </button>
264
+ </div>
265
+ </motion.section>
266
+ </motion.div>
267
+ ) : null}
268
+ </AnimatePresence>,
269
+ document.body,
270
+ ) : null}
271
+ </>
272
+ )
273
+ }
@@ -0,0 +1,9 @@
1
+ import { IconUser } from '@tabler/icons-react'
2
+
3
+ export default function ChatUserAvatar({ className = '' }: { className?: string }) {
4
+ return (
5
+ <span className={`bg-surface text-muted relative inline-flex size-full shrink-0 items-center justify-center overflow-hidden rounded-full ${className}`}>
6
+ <IconUser size={15} stroke={1.7} aria-hidden="true" />
7
+ </span>
8
+ )
9
+ }