@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,121 @@
1
+ 'use client'
2
+
3
+ import * as React from 'react'
4
+ import { AnimatePresence, motion, useReducedMotion, type HTMLMotionProps } from 'motion/react'
5
+ import Image, { type ImageProps } from 'next/image'
6
+ import { cn } from '@/lib/utils'
7
+
8
+ const avatarSizes = {
9
+ sm: 'size-8 text-xs',
10
+ md: 'size-10 text-sm',
11
+ lg: 'size-12 text-base',
12
+ xl: 'size-16 text-lg',
13
+ '2xl': 'size-24 text-2xl',
14
+ } as const
15
+
16
+ export type AvatarSize = keyof typeof avatarSizes
17
+
18
+ interface AvatarContextValue {
19
+ imageStatus: 'loading' | 'loaded' | 'error'
20
+ setImageStatus: (status: AvatarContextValue['imageStatus']) => void
21
+ }
22
+
23
+ const AvatarContext = React.createContext<AvatarContextValue | null>(null)
24
+
25
+ function useAvatarContext() {
26
+ const context = React.useContext(AvatarContext)
27
+ if (!context) throw new Error('AvatarImage and AvatarFallback must be used inside Avatar.')
28
+ return context
29
+ }
30
+
31
+ export interface AvatarProps extends Omit<HTMLMotionProps<'span'>, 'ref'> {
32
+ size?: AvatarSize
33
+ children?: React.ReactNode
34
+ }
35
+
36
+ const Avatar = React.forwardRef<HTMLSpanElement, AvatarProps>(({ className, size = 'md', children, ...props }, ref) => {
37
+ const reduceMotion = useReducedMotion()
38
+ const [imageStatus, setImageStatus] = React.useState<AvatarContextValue['imageStatus']>('loading')
39
+ const context = React.useMemo(() => ({ imageStatus, setImageStatus }), [imageStatus])
40
+
41
+ return (
42
+ <AvatarContext.Provider value={context}>
43
+ <motion.span
44
+ {...props}
45
+ ref={ref}
46
+ layout={reduceMotion ? false : true}
47
+ whileHover={reduceMotion ? undefined : { scale: 1.045, y: -2 }}
48
+ transition={reduceMotion ? { duration: 0 } : { type: 'spring', stiffness: 420, damping: 32 }}
49
+ data-slot="avatar"
50
+ className={cn('relative inline-flex shrink-0 overflow-hidden rounded-full border-2 border-foreground/25 bg-muted align-middle text-foreground transition-colors hover:border-foreground/50', avatarSizes[size], className)}
51
+ >
52
+ {children}
53
+ </motion.span>
54
+ </AvatarContext.Provider>
55
+ )
56
+ })
57
+
58
+ Avatar.displayName = 'Avatar'
59
+
60
+ export type AvatarImageProps = Omit<ImageProps, 'fill' | 'width' | 'height'>
61
+
62
+ const AvatarImage = React.forwardRef<HTMLImageElement, AvatarImageProps>(({ className, alt, onLoad, onError, sizes, ...props }, ref) => {
63
+ const context = useAvatarContext()
64
+ const reduceMotion = useReducedMotion()
65
+
66
+ return (
67
+ <motion.span
68
+ data-slot="avatar-image"
69
+ animate={{ opacity: context.imageStatus === 'error' ? 0 : 1 }}
70
+ transition={{ duration: reduceMotion ? 0 : 0.18, ease: 'easeOut' }}
71
+ className="absolute inset-0"
72
+ >
73
+ <Image
74
+ {...props}
75
+ ref={ref}
76
+ alt={alt}
77
+ fill
78
+ sizes={sizes ?? '96px'}
79
+ onLoad={(event) => {
80
+ context.setImageStatus('loaded')
81
+ onLoad?.(event)
82
+ }}
83
+ onError={(event) => {
84
+ context.setImageStatus('error')
85
+ onError?.(event)
86
+ }}
87
+ className={cn('object-cover object-center', className)}
88
+ />
89
+ </motion.span>
90
+ )
91
+ })
92
+
93
+ AvatarImage.displayName = 'AvatarImage'
94
+
95
+ export type AvatarFallbackProps = Omit<HTMLMotionProps<'span'>, 'ref'>
96
+
97
+ const AvatarFallback = React.forwardRef<HTMLSpanElement, AvatarFallbackProps>(({ className, ...props }, ref) => {
98
+ const context = useAvatarContext()
99
+ const reduceMotion = useReducedMotion()
100
+
101
+ return (
102
+ <AnimatePresence initial={false}>
103
+ {context.imageStatus !== 'loaded' && (
104
+ <motion.span
105
+ {...props}
106
+ ref={ref}
107
+ data-slot="avatar-fallback"
108
+ initial={reduceMotion ? false : { opacity: 0, scale: 0.9 }}
109
+ animate={{ opacity: 1, scale: 1 }}
110
+ exit={reduceMotion ? undefined : { opacity: 0, scale: 0.92 }}
111
+ transition={{ duration: reduceMotion ? 0 : 0.16, ease: 'easeOut' }}
112
+ className={cn('absolute inset-0 grid place-items-center bg-muted font-grotesk font-semibold text-muted-foreground', className)}
113
+ />
114
+ )}
115
+ </AnimatePresence>
116
+ )
117
+ })
118
+
119
+ AvatarFallback.displayName = 'AvatarFallback'
120
+
121
+ export { Avatar, AvatarImage, AvatarFallback }
@@ -0,0 +1,52 @@
1
+ 'use client'
2
+
3
+ import * as React from 'react'
4
+ import { motion, useReducedMotion, type HTMLMotionProps } from 'motion/react'
5
+ import { cn } from '@/lib/utils'
6
+
7
+ const badgeVariants = {
8
+ default: 'border-transparent bg-foreground text-background',
9
+ secondary: 'border-border bg-muted text-foreground',
10
+ outline: 'border-border bg-transparent text-foreground',
11
+ success: 'border-[color-mix(in_oklab,var(--status-success)_32%,var(--border))] bg-[color-mix(in_oklab,var(--status-success-soft)_72%,var(--background))] text-[var(--status-success-strong)]',
12
+ warning: 'border-[color-mix(in_oklab,var(--status-warning)_32%,var(--border))] bg-[color-mix(in_oklab,var(--status-warning-soft)_72%,var(--background))] text-[var(--status-warning-strong)]',
13
+ destructive: 'border-[color-mix(in_oklab,var(--status-error)_32%,var(--border))] bg-[color-mix(in_oklab,var(--status-error-soft)_72%,var(--background))] text-[var(--status-error-strong)]',
14
+ } as const
15
+
16
+ const badgeSizes = {
17
+ sm: 'min-h-5 px-2 text-[10px]',
18
+ md: 'min-h-6 px-2.5 text-xs',
19
+ lg: 'min-h-7 px-3 text-sm',
20
+ } as const
21
+
22
+ export type BadgeVariant = keyof typeof badgeVariants
23
+ export type BadgeSize = keyof typeof badgeSizes
24
+
25
+ export interface BadgeProps extends Omit<HTMLMotionProps<'span'>, 'ref'> {
26
+ variant?: BadgeVariant
27
+ size?: BadgeSize
28
+ }
29
+
30
+ const Badge = React.forwardRef<HTMLSpanElement, BadgeProps>(
31
+ ({ className, variant = 'default', size = 'md', ...props }, ref) => {
32
+ const reduceMotion = useReducedMotion()
33
+
34
+ return (
35
+ <motion.span
36
+ {...props}
37
+ ref={ref}
38
+ layout={reduceMotion ? false : 'position'}
39
+ transition={reduceMotion ? { duration: 0 } : { type: 'spring', stiffness: 440, damping: 32 }}
40
+ data-slot="badge"
41
+ data-variant={variant}
42
+ data-size={size}
43
+ whileHover={reduceMotion ? undefined : { y: -1 }}
44
+ className={cn('inline-flex w-fit items-center justify-center whitespace-nowrap rounded-full border font-medium leading-none', badgeSizes[size], badgeVariants[variant], className)}
45
+ />
46
+ )
47
+ },
48
+ )
49
+
50
+ Badge.displayName = 'Badge'
51
+
52
+ export { Badge, badgeVariants, badgeSizes }