@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.
Files changed (55) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +533 -469
  3. package/bin/istmx.mjs +481 -318
  4. package/package.json +27 -27
  5. package/registry/accordion.tsx +186 -0
  6. package/registry/ai-chat-block/ai-chat-block.tsx +456 -460
  7. package/registry/ai-chat-block/ai-chat-input.tsx +694 -694
  8. package/registry/ai-chat-block/attachment.tsx +466 -466
  9. package/registry/ai-chat-block/chat-code-block.tsx +50 -50
  10. package/registry/ai-chat-block/chat-composer.tsx +51 -51
  11. package/registry/ai-chat-block/chat-logo.tsx +18 -18
  12. package/registry/ai-chat-block/chat-message.tsx +161 -161
  13. package/registry/ai-chat-block/chat-sidebar.tsx +273 -273
  14. package/registry/ai-chat-block/chat-user-avatar.tsx +9 -9
  15. package/registry/ai-chat-block/code-highlighter.tsx +342 -357
  16. package/registry/ai-chat-block/default-attachments.tsx +42 -42
  17. package/registry/ai-chat-block/index.ts +30 -30
  18. package/registry/ai-chat-block/message-content.tsx +287 -287
  19. package/registry/ai-chat-block/message-list.tsx +93 -93
  20. package/registry/ai-chat-block/send-button.tsx +102 -102
  21. package/registry/ai-chat-block/types.ts +70 -71
  22. package/registry/ai-chat-block/utils.ts +6 -6
  23. package/registry/ai-chat-block/voice-button.tsx +66 -66
  24. package/registry/alert-dialog.tsx +229 -0
  25. package/registry/alert.tsx +188 -0
  26. package/registry/animated-text.tsx +228 -225
  27. package/registry/aspect-ratio.tsx +32 -0
  28. package/registry/avatar-group.tsx +66 -0
  29. package/registry/avatar.tsx +121 -0
  30. package/registry/badge.tsx +52 -0
  31. package/registry/bento-grid.tsx +438 -433
  32. package/registry/button.tsx +156 -237
  33. package/registry/carousel.tsx +184 -0
  34. package/registry/dock-navigation.tsx +200 -198
  35. package/registry/drift-canvas.tsx +383 -0
  36. package/registry/drift-wall.tsx +361 -0
  37. package/registry/flex-carousel.tsx +1430 -0
  38. package/registry/guided-gallery.tsx +1506 -0
  39. package/registry/image-accordion.tsx +306 -302
  40. package/registry/image-trail.tsx +126 -121
  41. package/registry/infinite-image-canvas.tsx +268 -263
  42. package/registry/input-otp.tsx +332 -0
  43. package/registry/list-card.tsx +130 -0
  44. package/registry/mobile-menu-dock.tsx +216 -211
  45. package/registry/morph-slider.tsx +756 -0
  46. package/registry/pixel-cat.tsx +972 -1020
  47. package/registry/scroll-canvas-cards.tsx +643 -640
  48. package/registry/scroll-parallax-hero.tsx +566 -565
  49. package/registry/scroll-story-cards.tsx +443 -438
  50. package/registry/slider.tsx +163 -0
  51. package/registry/spotlight-grid.tsx +226 -0
  52. package/registry/streaming-text.tsx +269 -278
  53. package/registry/text-reveal.tsx +311 -307
  54. package/registry/user-avatar.tsx +99 -0
  55. package/registry/utils.ts +6 -6
@@ -0,0 +1,332 @@
1
+ 'use client'
2
+
3
+ import * as React from 'react'
4
+ import { OTPInput, OTPInputContext } from 'input-otp'
5
+ import { AnimatePresence, motion, useReducedMotion } from 'motion/react'
6
+ import { IconMinus } from '@tabler/icons-react'
7
+
8
+ import { cn } from '@/lib/utils'
9
+
10
+ type Sweep = { id: number; from: number; to: number; tone: 'paste' | 'success' }
11
+
12
+ type InputOTPStatus = {
13
+ invalid: boolean
14
+ success: boolean
15
+ sweep: Sweep | null
16
+ landing: boolean
17
+ }
18
+
19
+ const InputOTPStatusContext = React.createContext<InputOTPStatus>({
20
+ invalid: false,
21
+ success: false,
22
+ sweep: null,
23
+ landing: false,
24
+ })
25
+
26
+ const SWEEP_TIMING = {
27
+ paste: { duration: 0.4, stagger: 0.045 },
28
+ success: { duration: 0.42, stagger: 0.048 },
29
+ } as const
30
+
31
+ const RING_TRAVEL = 0.42
32
+
33
+ const DIGIT_SPRING = { type: 'spring' as const, duration: 0.3, bounce: 0.2 }
34
+
35
+ const DIGITS = '^[0-9\\u0660-\\u0669\\u06f0-\\u06f9]+$'
36
+
37
+ type RingBox = { x: number; y: number; width: number; height: number }
38
+
39
+ function InputOTP({
40
+ className,
41
+ containerClassName,
42
+ 'aria-invalid': ariaInvalid,
43
+ value,
44
+ onChange,
45
+ success = false,
46
+ maxLength,
47
+ children,
48
+ ...props
49
+ }: Omit<React.ComponentProps<typeof OTPInput>, 'render' | 'children'> & {
50
+ children?: React.ReactNode
51
+ containerClassName?: string
52
+ success?: boolean
53
+ }) {
54
+ const invalid = ariaInvalid === true || ariaInvalid === 'true'
55
+ const reduceMotion = useReducedMotion()
56
+ const [sweep, setSweep] = React.useState<Sweep | null>(null)
57
+ const sweepId = React.useRef(0)
58
+
59
+ const startSweep = (from: number, to: number, tone: Sweep['tone']) => {
60
+ sweepId.current += 1
61
+ setSweep({ id: sweepId.current, from, to, tone })
62
+ }
63
+
64
+ const prevLength = React.useRef(typeof value === 'string' ? value.length : 0)
65
+
66
+ const handleChange = (next: string) => {
67
+ if (!reduceMotion && next.length - prevLength.current > 1) {
68
+ startSweep(prevLength.current, next.length, 'paste')
69
+ }
70
+ prevLength.current = next.length
71
+ onChange?.(next)
72
+ }
73
+
74
+ React.useEffect(() => {
75
+ if (!success || reduceMotion) return
76
+ startSweep(0, maxLength, 'success')
77
+ }, [success, reduceMotion, maxLength])
78
+
79
+ const [landing, setLanding] = React.useState(false)
80
+ React.useEffect(() => {
81
+ if (!sweep) return
82
+ const { stagger, duration } = SWEEP_TIMING[sweep.tone]
83
+ const total = (sweep.to - sweep.from) * stagger + duration
84
+ const timer = setTimeout(() => {
85
+ setSweep(null)
86
+ if (sweep.tone === 'success') setLanding(true)
87
+ }, total * 1000)
88
+ return () => clearTimeout(timer)
89
+ }, [sweep])
90
+
91
+ React.useEffect(() => {
92
+ if (!landing) return
93
+ const timer = setTimeout(() => setLanding(false), 500)
94
+ return () => clearTimeout(timer)
95
+ }, [landing])
96
+
97
+ return (
98
+ <InputOTPStatusContext.Provider value={{ invalid, success, sweep, landing }}>
99
+ <OTPInput
100
+ data-slot="input-otp"
101
+ maxLength={maxLength}
102
+ pattern={DIGITS}
103
+ inputMode="numeric"
104
+ value={value}
105
+ onChange={handleChange}
106
+ containerClassName={cn(
107
+ 'relative flex items-center has-disabled:opacity-50',
108
+ containerClassName,
109
+ )}
110
+ className={cn('disabled:cursor-not-allowed', className)}
111
+ {...props}
112
+ >
113
+ <TravelingRing />
114
+ {children}
115
+ </OTPInput>
116
+ </InputOTPStatusContext.Provider>
117
+ )
118
+ }
119
+
120
+ function InputOTPGroup({
121
+ className,
122
+ children,
123
+ ...props
124
+ }: React.ComponentProps<'div'>) {
125
+ return (
126
+ <div
127
+ data-slot="input-otp-group"
128
+ className={cn('flex items-center', className)}
129
+ {...props}
130
+ >
131
+ {children}
132
+ </div>
133
+ )
134
+ }
135
+
136
+ function TravelingRing() {
137
+ const reduceMotion = useReducedMotion()
138
+ const { invalid } = React.useContext(InputOTPStatusContext)
139
+ const context = React.useContext(OTPInputContext)
140
+ const markerRef = React.useRef<HTMLSpanElement | null>(null)
141
+ const [ring, setRing] = React.useState<RingBox | null>(null)
142
+ const [isVisible, setIsVisible] = React.useState(false)
143
+
144
+ const activeIndex = context?.slots ? context.slots.findIndex((s) => s?.isActive) : -1
145
+
146
+ React.useEffect(() => {
147
+ if (activeIndex < 0) {
148
+ setIsVisible(false)
149
+ return
150
+ }
151
+
152
+ const container = markerRef.current?.closest('[data-slot="input-otp"]') || markerRef.current?.parentElement
153
+ if (!container) return
154
+
155
+ const slotElements = container.querySelectorAll<HTMLElement>('[data-slot="input-otp-slot"]')
156
+ const target = slotElements[activeIndex]
157
+ if (!target) return
158
+
159
+ const containerRect = container.getBoundingClientRect()
160
+ const targetRect = target.getBoundingClientRect()
161
+
162
+ setRing({
163
+ x: targetRect.left - containerRect.left - 2,
164
+ y: targetRect.top - containerRect.top - 2,
165
+ width: targetRect.width + 4,
166
+ height: targetRect.height + 4,
167
+ })
168
+ setIsVisible(true)
169
+ }, [activeIndex])
170
+
171
+ return (
172
+ <>
173
+ <span ref={markerRef} className="absolute w-0 h-0 overflow-hidden" />
174
+ {isVisible && ring && (
175
+ <motion.span
176
+ className={cn(
177
+ 'pointer-events-none absolute z-10 rounded-[14px] border-2',
178
+ invalid
179
+ ? 'border-red-500 shadow-[0_0_0_2px_rgba(239,68,68,0.15)]'
180
+ : 'border-foreground shadow-[0_0_0_2px_rgba(0,0,0,0.06)] dark:shadow-[0_0_0_2px_rgba(255,255,255,0.08)]'
181
+ )}
182
+ initial={false}
183
+ animate={{
184
+ x: ring.x,
185
+ y: ring.y,
186
+ width: ring.width,
187
+ height: ring.height,
188
+ }}
189
+ transition={
190
+ reduceMotion
191
+ ? { duration: 0 }
192
+ : {
193
+ type: 'spring',
194
+ duration: RING_TRAVEL,
195
+ bounce: 0.15,
196
+ }
197
+ }
198
+ />
199
+ )}
200
+ </>
201
+ )
202
+ }
203
+
204
+ function InputOTPSlot({
205
+ index,
206
+ className,
207
+ ...props
208
+ }: React.ComponentProps<'div'> & { index: number }) {
209
+ const { invalid, success, sweep, landing } = React.useContext(InputOTPStatusContext)
210
+ const context = React.useContext(OTPInputContext)
211
+ const reduceMotion = useReducedMotion()
212
+ const slot = context?.slots?.[index]
213
+ const char = slot?.char ?? null
214
+ const isActive = slot?.isActive ?? false
215
+ const hasFakeCaret = slot?.hasFakeCaret ?? false
216
+ const prevChar = React.useRef(char)
217
+
218
+ const isNewDigit = char !== null && prevChar.current === null
219
+ React.useEffect(() => {
220
+ prevChar.current = char
221
+ }, [char])
222
+
223
+ const sweepDelay = React.useMemo(() => {
224
+ if (!sweep) return null
225
+ if (index < sweep.from || index >= sweep.to) return null
226
+ const timing = SWEEP_TIMING[sweep.tone]
227
+ return (index - sweep.from) * timing.stagger
228
+ }, [sweep, index])
229
+
230
+ const successDelay = landing ? index * 0.05 : 0
231
+
232
+ return (
233
+ <div
234
+ data-slot="input-otp-slot"
235
+ className={cn(
236
+ 'relative flex h-14 w-12 items-center justify-center rounded-xl border-2 bg-background font-mono text-xl font-bold transition-colors duration-150',
237
+ !isActive && !invalid && !success && 'border-border',
238
+ isActive && !invalid && 'border-transparent',
239
+ invalid && 'border-red-500/50 bg-red-500/5',
240
+ success && !invalid && 'border-green-500/50 bg-green-500/5',
241
+ className,
242
+ )}
243
+ {...props}
244
+ >
245
+ {sweepDelay !== null && (
246
+ <motion.span
247
+ className={cn(
248
+ 'pointer-events-none absolute inset-0 rounded-[10px]',
249
+ sweep?.tone === 'paste'
250
+ ? 'shadow-[inset_0_0_0_2px_rgba(9,9,11,0.1)] dark:shadow-[inset_0_0_0_2px_rgba(250,250,250,0.1)]'
251
+ : 'shadow-[inset_0_0_0_2px_rgba(34,197,94,0.3)]',
252
+ )}
253
+ initial={{ opacity: 0 }}
254
+ animate={{ opacity: [0, 0.8, 0] }}
255
+ transition={{
256
+ duration: SWEEP_TIMING[sweep!.tone].duration,
257
+ delay: sweepDelay,
258
+ ease: 'easeOut',
259
+ }}
260
+ />
261
+ )}
262
+
263
+ <AnimatePresence mode="popLayout">
264
+ {char !== null ? (
265
+ <motion.span
266
+ key={`${index}-${char}`}
267
+ className={cn(
268
+ 'inline-flex items-center justify-center',
269
+ invalid ? 'text-red-500 dark:text-red-400' : success ? 'text-green-600 dark:text-green-400' : 'text-foreground',
270
+ )}
271
+ initial={
272
+ isNewDigit && !reduceMotion
273
+ ? { opacity: 0, y: 6, rotateX: -35, filter: 'blur(2px)' }
274
+ : false
275
+ }
276
+ animate={{
277
+ opacity: 1,
278
+ y: landing ? [0, -4, 0] : 0,
279
+ rotateX: 0,
280
+ filter: 'blur(0px)',
281
+ }}
282
+ exit={{ opacity: 0, y: -6, filter: 'blur(2px)' }}
283
+ transition={
284
+ landing
285
+ ? { y: { duration: 0.3, delay: successDelay, ease: [0.34, 1.56, 0.64, 1] } }
286
+ : DIGIT_SPRING
287
+ }
288
+ style={{ perspective: '100px' }}
289
+ >
290
+ {char}
291
+ </motion.span>
292
+ ) : hasFakeCaret ? (
293
+ <motion.span
294
+ key="caret"
295
+ className={cn(
296
+ 'inline-block h-6 w-[2px] rounded-full',
297
+ invalid ? 'bg-red-500' : 'bg-foreground',
298
+ )}
299
+ animate={{ opacity: [1, 1, 0, 0] }}
300
+ transition={{
301
+ duration: 1,
302
+ repeat: Infinity,
303
+ times: [0, 0.5, 0.5, 1],
304
+ }}
305
+ />
306
+ ) : null}
307
+ </AnimatePresence>
308
+ </div>
309
+ )
310
+ }
311
+
312
+ function InputOTPSeparator({ className, ...props }: React.ComponentProps<'div'>) {
313
+ return (
314
+ <div
315
+ data-slot="input-otp-separator"
316
+ role="separator"
317
+ className={cn('flex items-center justify-center px-1 text-secondary', className)}
318
+ {...props}
319
+ >
320
+ <IconMinus className="h-4 w-4" />
321
+ </div>
322
+ )
323
+ }
324
+
325
+ export {
326
+ InputOTP,
327
+ InputOTPGroup,
328
+ InputOTPSlot,
329
+ InputOTPSeparator,
330
+ InputOTPStatusContext,
331
+ }
332
+ export type { InputOTPStatus }
@@ -0,0 +1,130 @@
1
+ 'use client'
2
+
3
+ import * as React from 'react'
4
+ import { motion, useReducedMotion } from 'motion/react'
5
+ import { cn } from '@/lib/utils'
6
+
7
+ export interface ListCardProps {
8
+ icon?: React.ReactNode
9
+ title: React.ReactNode
10
+ description?: React.ReactNode
11
+ meta?: React.ReactNode
12
+ onClick?: (event: React.MouseEvent<HTMLDivElement>) => void
13
+ className?: string
14
+ iconClassName?: string
15
+ titleClassName?: string
16
+ descriptionClassName?: string
17
+ metaClassName?: string
18
+ }
19
+
20
+ export const ListCard = React.forwardRef<HTMLDivElement, ListCardProps>(
21
+ (
22
+ {
23
+ icon,
24
+ title,
25
+ description,
26
+ meta,
27
+ onClick,
28
+ className,
29
+ iconClassName,
30
+ titleClassName,
31
+ descriptionClassName,
32
+ metaClassName,
33
+ },
34
+ ref
35
+ ) => {
36
+ const shouldReduceMotion = useReducedMotion()
37
+ const [isHovered, setIsHovered] = React.useState(false)
38
+
39
+ return (
40
+ <motion.div
41
+ ref={ref}
42
+ onClick={onClick}
43
+ onMouseEnter={() => setIsHovered(true)}
44
+ onMouseLeave={() => setIsHovered(false)}
45
+ whileHover={shouldReduceMotion ? undefined : { y: -1 }}
46
+ whileTap={shouldReduceMotion ? undefined : { scale: 0.995 }}
47
+ transition={{ type: 'spring', stiffness: 400, damping: 28 }}
48
+ className={cn(
49
+ 'group relative flex items-center justify-between gap-4 p-3.5 sm:px-4 sm:py-3.5 rounded-2xl border border-border bg-surface transition-colors duration-150 shadow-2xs',
50
+ onClick && 'cursor-pointer',
51
+ className
52
+ )}
53
+ >
54
+ {isHovered && !shouldReduceMotion && (
55
+ <motion.span
56
+ layoutId="list-hover-pill"
57
+ className="absolute inset-0 rounded-2xl bg-muted/60 -z-10"
58
+ transition={{ type: 'spring', stiffness: 380, damping: 30 }}
59
+ />
60
+ )}
61
+
62
+ <div className="flex items-center gap-3.5 min-w-0 flex-1">
63
+ {icon && (
64
+ <div
65
+ className={cn(
66
+ 'h-10 w-10 rounded-xl border border-border bg-muted/50 flex items-center justify-center shrink-0 text-foreground transition-transform duration-200 group-hover:scale-105',
67
+ iconClassName
68
+ )}
69
+ >
70
+ {icon}
71
+ </div>
72
+ )}
73
+
74
+ <div className="min-w-0 flex-1 space-y-0.5">
75
+ <h4
76
+ className={cn(
77
+ 'font-grotesk font-semibold text-sm sm:text-base text-foreground tracking-tight truncate',
78
+ titleClassName
79
+ )}
80
+ >
81
+ {title}
82
+ </h4>
83
+ {description && (
84
+ <p
85
+ className={cn(
86
+ 'text-xs sm:text-[13px] text-secondary leading-relaxed line-clamp-1',
87
+ descriptionClassName
88
+ )}
89
+ >
90
+ {description}
91
+ </p>
92
+ )}
93
+ </div>
94
+ </div>
95
+
96
+ {meta && (
97
+ <div
98
+ className={cn(
99
+ 'font-mono text-xs sm:text-[13px] text-muted-foreground whitespace-nowrap shrink-0 group-hover:text-foreground transition-colors font-medium pl-2',
100
+ metaClassName
101
+ )}
102
+ >
103
+ {meta}
104
+ </div>
105
+ )}
106
+ </motion.div>
107
+ )
108
+ }
109
+ )
110
+
111
+ ListCard.displayName = 'ListCard'
112
+
113
+ export interface ListGroupProps extends React.HTMLAttributes<HTMLDivElement> {
114
+ children: React.ReactNode
115
+ className?: string
116
+ }
117
+
118
+ export function ListGroup({ children, className, ...props }: ListGroupProps) {
119
+ return (
120
+ <div
121
+ className={cn(
122
+ 'rounded-3xl border border-border bg-surface/50 p-2 sm:p-2.5 space-y-2 shadow-2xs backdrop-blur-xs',
123
+ className
124
+ )}
125
+ {...props}
126
+ >
127
+ {children}
128
+ </div>
129
+ )
130
+ }