@istmx/ui 0.1.12 → 0.1.13
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/LICENSE +21 -21
- package/README.md +533 -469
- package/bin/istmx.mjs +481 -318
- package/package.json +27 -27
- package/registry/accordion.tsx +186 -0
- package/registry/ai-chat-block/ai-chat-block.tsx +456 -460
- package/registry/ai-chat-block/ai-chat-input.tsx +694 -694
- package/registry/ai-chat-block/attachment.tsx +466 -466
- package/registry/ai-chat-block/chat-code-block.tsx +50 -50
- package/registry/ai-chat-block/chat-composer.tsx +51 -51
- package/registry/ai-chat-block/chat-logo.tsx +18 -18
- package/registry/ai-chat-block/chat-message.tsx +161 -161
- package/registry/ai-chat-block/chat-sidebar.tsx +273 -273
- package/registry/ai-chat-block/chat-user-avatar.tsx +9 -9
- package/registry/ai-chat-block/code-highlighter.tsx +342 -357
- package/registry/ai-chat-block/default-attachments.tsx +42 -42
- package/registry/ai-chat-block/index.ts +30 -30
- package/registry/ai-chat-block/message-content.tsx +287 -287
- package/registry/ai-chat-block/message-list.tsx +93 -93
- package/registry/ai-chat-block/send-button.tsx +102 -102
- package/registry/ai-chat-block/types.ts +70 -71
- package/registry/ai-chat-block/utils.ts +6 -6
- package/registry/ai-chat-block/voice-button.tsx +66 -66
- package/registry/alert-dialog.tsx +229 -0
- package/registry/alert.tsx +188 -0
- package/registry/animated-text.tsx +228 -225
- package/registry/aspect-ratio.tsx +32 -0
- package/registry/avatar-group.tsx +66 -0
- package/registry/avatar.tsx +121 -0
- package/registry/badge.tsx +52 -0
- package/registry/bento-grid.tsx +438 -433
- package/registry/button.tsx +156 -237
- package/registry/carousel.tsx +184 -0
- package/registry/dock-navigation.tsx +200 -198
- package/registry/drift-canvas.tsx +383 -0
- package/registry/drift-wall.tsx +361 -0
- package/registry/flex-carousel.tsx +1430 -0
- package/registry/guided-gallery.tsx +1506 -0
- package/registry/image-accordion.tsx +306 -302
- package/registry/image-trail.tsx +126 -121
- package/registry/infinite-image-canvas.tsx +268 -263
- package/registry/input-otp.tsx +332 -0
- package/registry/list-card.tsx +130 -0
- package/registry/mobile-menu-dock.tsx +216 -211
- package/registry/morph-slider.tsx +756 -0
- package/registry/pixel-cat.tsx +972 -1020
- package/registry/scroll-canvas-cards.tsx +643 -640
- package/registry/scroll-parallax-hero.tsx +566 -565
- package/registry/scroll-story-cards.tsx +443 -438
- package/registry/slider.tsx +163 -0
- package/registry/spotlight-grid.tsx +226 -0
- package/registry/streaming-text.tsx +269 -278
- package/registry/text-reveal.tsx +311 -307
- package/registry/user-avatar.tsx +99 -0
- package/registry/utils.ts +6 -6
|
@@ -1,93 +1,93 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import { useEffect, useRef } from 'react'
|
|
4
|
-
import type { ReactNode } from 'react'
|
|
5
|
-
import { cn } from './utils'
|
|
6
|
-
import { AnimatePresence, motion, useReducedMotion } from 'motion/react'
|
|
7
|
-
import type { ChatTurn } from './types'
|
|
8
|
-
import ChatMessage from './chat-message'
|
|
9
|
-
import ChatLogo from './chat-logo'
|
|
10
|
-
|
|
11
|
-
export type MessageListProps = {
|
|
12
|
-
messages: readonly ChatTurn[]
|
|
13
|
-
userName: string
|
|
14
|
-
assistantName: string
|
|
15
|
-
userAvatar?: ReactNode
|
|
16
|
-
assistantAvatar?: ReactNode
|
|
17
|
-
onRetry?: (turnId: string) => void
|
|
18
|
-
retryDisabled?: boolean
|
|
19
|
-
emptyMessage?: string
|
|
20
|
-
className?: string
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export default function MessageList({
|
|
24
|
-
messages,
|
|
25
|
-
userName,
|
|
26
|
-
assistantName,
|
|
27
|
-
userAvatar,
|
|
28
|
-
assistantAvatar,
|
|
29
|
-
onRetry,
|
|
30
|
-
retryDisabled,
|
|
31
|
-
emptyMessage = 'Start a conversation. Your messages will appear here.',
|
|
32
|
-
className,
|
|
33
|
-
}: MessageListProps) {
|
|
34
|
-
const logRef = useRef<HTMLDivElement>(null)
|
|
35
|
-
const wasAtBottom = useRef(true)
|
|
36
|
-
const previousCount = useRef(messages.length)
|
|
37
|
-
const reduceMotion = useReducedMotion()
|
|
38
|
-
|
|
39
|
-
useEffect(() => {
|
|
40
|
-
const log = logRef.current
|
|
41
|
-
if (!log) return
|
|
42
|
-
const newMessageAdded = messages.length > previousCount.current
|
|
43
|
-
previousCount.current = messages.length
|
|
44
|
-
if (wasAtBottom.current || newMessageAdded) log.scrollTop = log.scrollHeight
|
|
45
|
-
}, [messages])
|
|
46
|
-
|
|
47
|
-
return (
|
|
48
|
-
<div
|
|
49
|
-
role="log"
|
|
50
|
-
ref={logRef}
|
|
51
|
-
onScroll={(event) => {
|
|
52
|
-
const log = event.currentTarget
|
|
53
|
-
wasAtBottom.current = log.scrollHeight - log.scrollTop - log.clientHeight < 48
|
|
54
|
-
}}
|
|
55
|
-
aria-label="Chat conversation"
|
|
56
|
-
aria-relevant="additions text"
|
|
57
|
-
className={cn('[scrollbar-width:none] [&::-webkit-scrollbar]:hidden min-h-0 flex-1 overflow-y-auto overscroll-contain px-3 py-4 sm:px-5 sm:py-5', className)}
|
|
58
|
-
>
|
|
59
|
-
{messages.length ? (
|
|
60
|
-
<div className="space-y-5 sm:space-y-6">
|
|
61
|
-
<AnimatePresence initial={false}>
|
|
62
|
-
{messages.map((turn) => (
|
|
63
|
-
<ChatMessage
|
|
64
|
-
key={turn.id}
|
|
65
|
-
turn={turn}
|
|
66
|
-
userName={userName}
|
|
67
|
-
assistantName={assistantName}
|
|
68
|
-
userAvatar={userAvatar}
|
|
69
|
-
assistantAvatar={assistantAvatar}
|
|
70
|
-
onRetry={turn.status === 'error' && onRetry ? () => onRetry(turn.id) : undefined}
|
|
71
|
-
retryDisabled={retryDisabled}
|
|
72
|
-
/>
|
|
73
|
-
))}
|
|
74
|
-
</AnimatePresence>
|
|
75
|
-
<div aria-hidden="true" />
|
|
76
|
-
</div>
|
|
77
|
-
) : (
|
|
78
|
-
<motion.div
|
|
79
|
-
initial={{ opacity: 0 }}
|
|
80
|
-
animate={{ opacity: 1 }}
|
|
81
|
-
transition={{ duration: reduceMotion ? 0 : 0.3 }}
|
|
82
|
-
className="flex min-h-48 flex-col items-center justify-center px-4 text-center sm:min-h-56"
|
|
83
|
-
>
|
|
84
|
-
<span className="bg-[var(--chat-accent,var(--foreground))]/10 text-[var(--chat-accent,var(--foreground))] mb-3 flex size-10 items-center justify-center rounded-2xl">
|
|
85
|
-
<ChatLogo className="size-5" />
|
|
86
|
-
</span>
|
|
87
|
-
<p className="font-display text-sm font-medium">Start a conversation</p>
|
|
88
|
-
<p className="text-muted mt-1 max-w-sm text-xs leading-5">{emptyMessage}</p>
|
|
89
|
-
</motion.div>
|
|
90
|
-
)}
|
|
91
|
-
</div>
|
|
92
|
-
)
|
|
93
|
-
}
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { useEffect, useRef } from 'react'
|
|
4
|
+
import type { ReactNode } from 'react'
|
|
5
|
+
import { cn } from './utils'
|
|
6
|
+
import { AnimatePresence, motion, useReducedMotion } from 'motion/react'
|
|
7
|
+
import type { ChatTurn } from './types'
|
|
8
|
+
import ChatMessage from './chat-message'
|
|
9
|
+
import ChatLogo from './chat-logo'
|
|
10
|
+
|
|
11
|
+
export type MessageListProps = {
|
|
12
|
+
messages: readonly ChatTurn[]
|
|
13
|
+
userName: string
|
|
14
|
+
assistantName: string
|
|
15
|
+
userAvatar?: ReactNode
|
|
16
|
+
assistantAvatar?: ReactNode
|
|
17
|
+
onRetry?: (turnId: string) => void
|
|
18
|
+
retryDisabled?: boolean
|
|
19
|
+
emptyMessage?: string
|
|
20
|
+
className?: string
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default function MessageList({
|
|
24
|
+
messages,
|
|
25
|
+
userName,
|
|
26
|
+
assistantName,
|
|
27
|
+
userAvatar,
|
|
28
|
+
assistantAvatar,
|
|
29
|
+
onRetry,
|
|
30
|
+
retryDisabled,
|
|
31
|
+
emptyMessage = 'Start a conversation. Your messages will appear here.',
|
|
32
|
+
className,
|
|
33
|
+
}: MessageListProps) {
|
|
34
|
+
const logRef = useRef<HTMLDivElement>(null)
|
|
35
|
+
const wasAtBottom = useRef(true)
|
|
36
|
+
const previousCount = useRef(messages.length)
|
|
37
|
+
const reduceMotion = useReducedMotion()
|
|
38
|
+
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
const log = logRef.current
|
|
41
|
+
if (!log) return
|
|
42
|
+
const newMessageAdded = messages.length > previousCount.current
|
|
43
|
+
previousCount.current = messages.length
|
|
44
|
+
if (wasAtBottom.current || newMessageAdded) log.scrollTop = log.scrollHeight
|
|
45
|
+
}, [messages])
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<div
|
|
49
|
+
role="log"
|
|
50
|
+
ref={logRef}
|
|
51
|
+
onScroll={(event) => {
|
|
52
|
+
const log = event.currentTarget
|
|
53
|
+
wasAtBottom.current = log.scrollHeight - log.scrollTop - log.clientHeight < 48
|
|
54
|
+
}}
|
|
55
|
+
aria-label="Chat conversation"
|
|
56
|
+
aria-relevant="additions text"
|
|
57
|
+
className={cn('[scrollbar-width:none] [&::-webkit-scrollbar]:hidden min-h-0 flex-1 overflow-y-auto overscroll-contain px-3 py-4 sm:px-5 sm:py-5', className)}
|
|
58
|
+
>
|
|
59
|
+
{messages.length ? (
|
|
60
|
+
<div className="space-y-5 sm:space-y-6">
|
|
61
|
+
<AnimatePresence initial={false}>
|
|
62
|
+
{messages.map((turn) => (
|
|
63
|
+
<ChatMessage
|
|
64
|
+
key={turn.id}
|
|
65
|
+
turn={turn}
|
|
66
|
+
userName={userName}
|
|
67
|
+
assistantName={assistantName}
|
|
68
|
+
userAvatar={userAvatar}
|
|
69
|
+
assistantAvatar={assistantAvatar}
|
|
70
|
+
onRetry={turn.status === 'error' && onRetry ? () => onRetry(turn.id) : undefined}
|
|
71
|
+
retryDisabled={retryDisabled}
|
|
72
|
+
/>
|
|
73
|
+
))}
|
|
74
|
+
</AnimatePresence>
|
|
75
|
+
<div aria-hidden="true" />
|
|
76
|
+
</div>
|
|
77
|
+
) : (
|
|
78
|
+
<motion.div
|
|
79
|
+
initial={{ opacity: 0 }}
|
|
80
|
+
animate={{ opacity: 1 }}
|
|
81
|
+
transition={{ duration: reduceMotion ? 0 : 0.3 }}
|
|
82
|
+
className="flex min-h-48 flex-col items-center justify-center px-4 text-center sm:min-h-56"
|
|
83
|
+
>
|
|
84
|
+
<span className="bg-[var(--chat-accent,var(--foreground))]/10 text-[var(--chat-accent,var(--foreground))] mb-3 flex size-10 items-center justify-center rounded-2xl">
|
|
85
|
+
<ChatLogo className="size-5" />
|
|
86
|
+
</span>
|
|
87
|
+
<p className="font-display text-sm font-medium">Start a conversation</p>
|
|
88
|
+
<p className="text-muted mt-1 max-w-sm text-xs leading-5">{emptyMessage}</p>
|
|
89
|
+
</motion.div>
|
|
90
|
+
)}
|
|
91
|
+
</div>
|
|
92
|
+
)
|
|
93
|
+
}
|
|
@@ -1,102 +1,102 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
AnimatePresence,
|
|
5
|
-
motion,
|
|
6
|
-
useAnimationControls,
|
|
7
|
-
useReducedMotion,
|
|
8
|
-
} from 'motion/react'
|
|
9
|
-
import { IconArrowUp, IconCheck, IconLoader, IconPlayerStop } from '@tabler/icons-react'
|
|
10
|
-
|
|
11
|
-
export type SendButtonProps = {
|
|
12
|
-
state: 'idle' | 'ready' | 'sending' | 'sent'
|
|
13
|
-
disabled?: boolean
|
|
14
|
-
label?: string
|
|
15
|
-
shakeControls?: ReturnType<typeof useAnimationControls>
|
|
16
|
-
onClick: () => void
|
|
17
|
-
onStop?: () => void
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export default function SendButton({
|
|
21
|
-
state,
|
|
22
|
-
disabled = false,
|
|
23
|
-
label = 'Send message',
|
|
24
|
-
shakeControls,
|
|
25
|
-
onClick,
|
|
26
|
-
onStop,
|
|
27
|
-
}: SendButtonProps) {
|
|
28
|
-
const reduceMotion = useReducedMotion()
|
|
29
|
-
const active = state === 'ready' || state === 'sent'
|
|
30
|
-
const canStop = state === 'sending' && Boolean(onStop)
|
|
31
|
-
|
|
32
|
-
return (
|
|
33
|
-
<motion.button
|
|
34
|
-
type="button"
|
|
35
|
-
onClick={canStop ? onStop : onClick}
|
|
36
|
-
aria-label={canStop ? 'Stop generating response' : state === 'sending' ? 'Sending message' : label}
|
|
37
|
-
title={canStop ? 'Stop generating' : label}
|
|
38
|
-
aria-disabled={disabled || (!active && !canStop)}
|
|
39
|
-
disabled={disabled || (!active && !canStop)}
|
|
40
|
-
animate={shakeControls}
|
|
41
|
-
whileTap={reduceMotion || (!active && !canStop) ? undefined : { scale: 0.9 }}
|
|
42
|
-
whileHover={reduceMotion || state !== 'ready' ? undefined : { y: -1 }}
|
|
43
|
-
className={`focus-visible:outline-foreground relative flex size-8 shrink-0 items-center justify-center rounded-xl border transition-[color,background-color,border-color,box-shadow] duration-200 focus-visible:outline-2 focus-visible:outline-offset-2 disabled:cursor-not-allowed disabled:opacity-60 sm:size-9 ${
|
|
44
|
-
canStop
|
|
45
|
-
? 'border-[var(--chat-accent,var(--foreground))] bg-[var(--chat-accent,var(--foreground))] text-white hover:opacity-85'
|
|
46
|
-
: active
|
|
47
|
-
? 'border-[var(--chat-accent,var(--foreground))] bg-[var(--chat-accent,var(--foreground))] text-white hover:shadow-[0_10px_26px_-12px_var(--chat-accent,var(--foreground))]'
|
|
48
|
-
: 'border-border/70 bg-surface/40 text-muted/60'
|
|
49
|
-
}`}
|
|
50
|
-
>
|
|
51
|
-
<AnimatePresence mode="wait" initial={false}>
|
|
52
|
-
{state === 'sending' && canStop ? (
|
|
53
|
-
<motion.span
|
|
54
|
-
key="stop"
|
|
55
|
-
initial={{ opacity: 0, scale: 0.7 }}
|
|
56
|
-
animate={{ opacity: 1, scale: 1 }}
|
|
57
|
-
exit={{ opacity: 0, scale: 0.7 }}
|
|
58
|
-
className="flex items-center justify-center"
|
|
59
|
-
>
|
|
60
|
-
<IconPlayerStop size={13} fill="currentColor" aria-hidden="true" />
|
|
61
|
-
</motion.span>
|
|
62
|
-
) : state === 'sending' ? (
|
|
63
|
-
<motion.span
|
|
64
|
-
key="sending"
|
|
65
|
-
initial={{ opacity: 0, scale: 0.7 }}
|
|
66
|
-
animate={{ opacity: 1, scale: 1 }}
|
|
67
|
-
exit={{ opacity: 0, scale: 0.7 }}
|
|
68
|
-
className="flex items-center justify-center"
|
|
69
|
-
>
|
|
70
|
-
<IconLoader
|
|
71
|
-
size={16}
|
|
72
|
-
stroke={1.8}
|
|
73
|
-
aria-hidden="true"
|
|
74
|
-
className="motion-safe:animate-spin"
|
|
75
|
-
/>
|
|
76
|
-
</motion.span>
|
|
77
|
-
) : state === 'sent' ? (
|
|
78
|
-
<motion.span
|
|
79
|
-
key="sent"
|
|
80
|
-
initial={reduceMotion ? { opacity: 0 } : { opacity: 0, scale: 0.5 }}
|
|
81
|
-
animate={{ opacity: 1, scale: 1 }}
|
|
82
|
-
exit={reduceMotion ? { opacity: 0 } : { opacity: 0, scale: 0.5 }}
|
|
83
|
-
transition={reduceMotion ? { duration: 0 } : { type: 'spring', stiffness: 520, damping: 24 }}
|
|
84
|
-
className="flex items-center justify-center"
|
|
85
|
-
>
|
|
86
|
-
<IconCheck size={17} stroke={2} aria-hidden="true" />
|
|
87
|
-
</motion.span>
|
|
88
|
-
) : (
|
|
89
|
-
<motion.span
|
|
90
|
-
key="idle"
|
|
91
|
-
initial={reduceMotion ? { opacity: 0 } : { opacity: 0, y: 5 }}
|
|
92
|
-
animate={{ opacity: 1, y: 0 }}
|
|
93
|
-
exit={reduceMotion ? { opacity: 0 } : { opacity: 0, y: -5 }}
|
|
94
|
-
className="flex items-center justify-center"
|
|
95
|
-
>
|
|
96
|
-
<IconArrowUp size={17} stroke={1.9} aria-hidden="true" />
|
|
97
|
-
</motion.span>
|
|
98
|
-
)}
|
|
99
|
-
</AnimatePresence>
|
|
100
|
-
</motion.button>
|
|
101
|
-
)
|
|
102
|
-
}
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
AnimatePresence,
|
|
5
|
+
motion,
|
|
6
|
+
useAnimationControls,
|
|
7
|
+
useReducedMotion,
|
|
8
|
+
} from 'motion/react'
|
|
9
|
+
import { IconArrowUp, IconCheck, IconLoader, IconPlayerStop } from '@tabler/icons-react'
|
|
10
|
+
|
|
11
|
+
export type SendButtonProps = {
|
|
12
|
+
state: 'idle' | 'ready' | 'sending' | 'sent'
|
|
13
|
+
disabled?: boolean
|
|
14
|
+
label?: string
|
|
15
|
+
shakeControls?: ReturnType<typeof useAnimationControls>
|
|
16
|
+
onClick: () => void
|
|
17
|
+
onStop?: () => void
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default function SendButton({
|
|
21
|
+
state,
|
|
22
|
+
disabled = false,
|
|
23
|
+
label = 'Send message',
|
|
24
|
+
shakeControls,
|
|
25
|
+
onClick,
|
|
26
|
+
onStop,
|
|
27
|
+
}: SendButtonProps) {
|
|
28
|
+
const reduceMotion = useReducedMotion()
|
|
29
|
+
const active = state === 'ready' || state === 'sent'
|
|
30
|
+
const canStop = state === 'sending' && Boolean(onStop)
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<motion.button
|
|
34
|
+
type="button"
|
|
35
|
+
onClick={canStop ? onStop : onClick}
|
|
36
|
+
aria-label={canStop ? 'Stop generating response' : state === 'sending' ? 'Sending message' : label}
|
|
37
|
+
title={canStop ? 'Stop generating' : label}
|
|
38
|
+
aria-disabled={disabled || (!active && !canStop)}
|
|
39
|
+
disabled={disabled || (!active && !canStop)}
|
|
40
|
+
animate={shakeControls}
|
|
41
|
+
whileTap={reduceMotion || (!active && !canStop) ? undefined : { scale: 0.9 }}
|
|
42
|
+
whileHover={reduceMotion || state !== 'ready' ? undefined : { y: -1 }}
|
|
43
|
+
className={`focus-visible:outline-foreground relative flex size-8 shrink-0 items-center justify-center rounded-xl border transition-[color,background-color,border-color,box-shadow] duration-200 focus-visible:outline-2 focus-visible:outline-offset-2 disabled:cursor-not-allowed disabled:opacity-60 sm:size-9 ${
|
|
44
|
+
canStop
|
|
45
|
+
? 'border-[var(--chat-accent,var(--foreground))] bg-[var(--chat-accent,var(--foreground))] text-white hover:opacity-85'
|
|
46
|
+
: active
|
|
47
|
+
? 'border-[var(--chat-accent,var(--foreground))] bg-[var(--chat-accent,var(--foreground))] text-white hover:shadow-[0_10px_26px_-12px_var(--chat-accent,var(--foreground))]'
|
|
48
|
+
: 'border-border/70 bg-surface/40 text-muted/60'
|
|
49
|
+
}`}
|
|
50
|
+
>
|
|
51
|
+
<AnimatePresence mode="wait" initial={false}>
|
|
52
|
+
{state === 'sending' && canStop ? (
|
|
53
|
+
<motion.span
|
|
54
|
+
key="stop"
|
|
55
|
+
initial={{ opacity: 0, scale: 0.7 }}
|
|
56
|
+
animate={{ opacity: 1, scale: 1 }}
|
|
57
|
+
exit={{ opacity: 0, scale: 0.7 }}
|
|
58
|
+
className="flex items-center justify-center"
|
|
59
|
+
>
|
|
60
|
+
<IconPlayerStop size={13} fill="currentColor" aria-hidden="true" />
|
|
61
|
+
</motion.span>
|
|
62
|
+
) : state === 'sending' ? (
|
|
63
|
+
<motion.span
|
|
64
|
+
key="sending"
|
|
65
|
+
initial={{ opacity: 0, scale: 0.7 }}
|
|
66
|
+
animate={{ opacity: 1, scale: 1 }}
|
|
67
|
+
exit={{ opacity: 0, scale: 0.7 }}
|
|
68
|
+
className="flex items-center justify-center"
|
|
69
|
+
>
|
|
70
|
+
<IconLoader
|
|
71
|
+
size={16}
|
|
72
|
+
stroke={1.8}
|
|
73
|
+
aria-hidden="true"
|
|
74
|
+
className="motion-safe:animate-spin"
|
|
75
|
+
/>
|
|
76
|
+
</motion.span>
|
|
77
|
+
) : state === 'sent' ? (
|
|
78
|
+
<motion.span
|
|
79
|
+
key="sent"
|
|
80
|
+
initial={reduceMotion ? { opacity: 0 } : { opacity: 0, scale: 0.5 }}
|
|
81
|
+
animate={{ opacity: 1, scale: 1 }}
|
|
82
|
+
exit={reduceMotion ? { opacity: 0 } : { opacity: 0, scale: 0.5 }}
|
|
83
|
+
transition={reduceMotion ? { duration: 0 } : { type: 'spring', stiffness: 520, damping: 24 }}
|
|
84
|
+
className="flex items-center justify-center"
|
|
85
|
+
>
|
|
86
|
+
<IconCheck size={17} stroke={2} aria-hidden="true" />
|
|
87
|
+
</motion.span>
|
|
88
|
+
) : (
|
|
89
|
+
<motion.span
|
|
90
|
+
key="idle"
|
|
91
|
+
initial={reduceMotion ? { opacity: 0 } : { opacity: 0, y: 5 }}
|
|
92
|
+
animate={{ opacity: 1, y: 0 }}
|
|
93
|
+
exit={reduceMotion ? { opacity: 0 } : { opacity: 0, y: -5 }}
|
|
94
|
+
className="flex items-center justify-center"
|
|
95
|
+
>
|
|
96
|
+
<IconArrowUp size={17} stroke={1.9} aria-hidden="true" />
|
|
97
|
+
</motion.span>
|
|
98
|
+
)}
|
|
99
|
+
</AnimatePresence>
|
|
100
|
+
</motion.button>
|
|
101
|
+
)
|
|
102
|
+
}
|
|
@@ -1,71 +1,70 @@
|
|
|
1
|
-
import type { ReactNode } from 'react'
|
|
2
|
-
|
|
3
|
-
export type ChatAttachmentKind = 'image' | 'video' | 'audio' | 'file'
|
|
4
|
-
|
|
5
|
-
export type ChatAttachment = {
|
|
6
|
-
id: string
|
|
7
|
-
name: string
|
|
8
|
-
kind: ChatAttachmentKind
|
|
9
|
-
size: number
|
|
10
|
-
file: File
|
|
11
|
-
url?: string
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export type AttachmentOption = {
|
|
15
|
-
id: string
|
|
16
|
-
label: string
|
|
17
|
-
description?: string
|
|
18
|
-
icon?: ReactNode
|
|
19
|
-
accept: string
|
|
20
|
-
multiple?: boolean
|
|
21
|
-
capture?: 'user' | 'environment'
|
|
22
|
-
disabled?: boolean
|
|
23
|
-
onSelect?: () => void
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export type ChatTurn = {
|
|
27
|
-
id: string
|
|
28
|
-
role: 'user' | 'assistant'
|
|
29
|
-
content: string
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
1
|
+
import type { ReactNode } from 'react'
|
|
2
|
+
|
|
3
|
+
export type ChatAttachmentKind = 'image' | 'video' | 'audio' | 'file'
|
|
4
|
+
|
|
5
|
+
export type ChatAttachment = {
|
|
6
|
+
id: string
|
|
7
|
+
name: string
|
|
8
|
+
kind: ChatAttachmentKind
|
|
9
|
+
size: number
|
|
10
|
+
file: File
|
|
11
|
+
url?: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type AttachmentOption = {
|
|
15
|
+
id: string
|
|
16
|
+
label: string
|
|
17
|
+
description?: string
|
|
18
|
+
icon?: ReactNode
|
|
19
|
+
accept: string
|
|
20
|
+
multiple?: boolean
|
|
21
|
+
capture?: 'user' | 'environment'
|
|
22
|
+
disabled?: boolean
|
|
23
|
+
onSelect?: () => void
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export type ChatTurn = {
|
|
27
|
+
id: string
|
|
28
|
+
role: 'user' | 'assistant'
|
|
29
|
+
content: string
|
|
30
|
+
streamingDelta?: string
|
|
31
|
+
attachments?: ChatAttachment[]
|
|
32
|
+
status?: 'streaming' | 'complete' | 'error'
|
|
33
|
+
error?: {
|
|
34
|
+
message: string
|
|
35
|
+
retryAfterMs?: number
|
|
36
|
+
retryAt?: number
|
|
37
|
+
}
|
|
38
|
+
thinking?: string
|
|
39
|
+
thinkingStatus?: 'thinking' | 'complete'
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type ChatThread = {
|
|
43
|
+
id: string
|
|
44
|
+
title: string
|
|
45
|
+
messages: readonly ChatTurn[]
|
|
46
|
+
pinned?: boolean
|
|
47
|
+
archived?: boolean
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export type ChatRequest = {
|
|
51
|
+
message: string
|
|
52
|
+
attachments: readonly ChatAttachment[]
|
|
53
|
+
signal: AbortSignal
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export type ChatStreamChunk =
|
|
57
|
+
| string
|
|
58
|
+
| {
|
|
59
|
+
content?: unknown
|
|
60
|
+
text?: unknown
|
|
61
|
+
delta?: unknown
|
|
62
|
+
type?: 'text-delta' | 'thinking-delta' | 'reasoning-delta'
|
|
63
|
+
}
|
|
64
|
+
| readonly unknown[]
|
|
65
|
+
|
|
66
|
+
export type ChatResponse = string | AsyncIterable<ChatStreamChunk>
|
|
67
|
+
|
|
68
|
+
export type ChatSendError = Error & {
|
|
69
|
+
retryAfterMs?: number
|
|
70
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { clsx, type ClassValue } from 'clsx'
|
|
2
|
-
import { twMerge } from 'tailwind-merge'
|
|
3
|
-
|
|
4
|
-
export function cn(...inputs: ClassValue[]) {
|
|
5
|
-
return twMerge(clsx(inputs))
|
|
6
|
-
}
|
|
1
|
+
import { clsx, type ClassValue } from 'clsx'
|
|
2
|
+
import { twMerge } from 'tailwind-merge'
|
|
3
|
+
|
|
4
|
+
export function cn(...inputs: ClassValue[]) {
|
|
5
|
+
return twMerge(clsx(inputs))
|
|
6
|
+
}
|