@istmx/ui 0.1.11 → 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 -463
  3. package/bin/istmx.mjs +481 -314
  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 -0
  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
@@ -1,198 +1,200 @@
1
- 'use client'
2
-
3
- import {
4
- motion,
5
- useMotionValue,
6
- useReducedMotion,
7
- useSpring,
8
- useTransform,
9
- } from 'motion/react'
10
- import type { MotionValue } from 'motion/react'
11
- import type { CSSProperties, PointerEvent, ReactNode } from 'react'
12
- import { cn } from '@/lib/utils'
13
-
14
- export type DockNavigationItem = {
15
- label: string
16
- href: string
17
- icon: ReactNode
18
- active?: boolean
19
- external?: boolean
20
- }
21
-
22
- export type DockNavigationProps = {
23
- items: DockNavigationItem[]
24
- label?: string
25
- className?: string
26
- itemClassName?: string
27
- iconClassName?: string
28
- glow?: false | DockNavigationGlow
29
- }
30
-
31
- export type DockNavigationGlow = {
32
- color?: string
33
- opacity?: number
34
- blur?: number
35
- }
36
-
37
- function DockItem({
38
- item,
39
- index,
40
- pointerX,
41
- iconClassName,
42
- itemClassName,
43
- glowEnabled,
44
- }: {
45
- item: DockNavigationItem
46
- index: number
47
- pointerX: MotionValue<number>
48
- iconClassName?: string
49
- itemClassName?: string
50
- glowEnabled: boolean
51
- }) {
52
- const reduceMotion = useReducedMotion()
53
- const center = 30 + index * 52
54
- const scale = useTransform(
55
- pointerX,
56
- [center - 84, center - 42, center, center + 42, center + 84],
57
- [1, 1.08, 1.36, 1.08, 1],
58
- )
59
- const smoothScale = useSpring(scale, {
60
- stiffness: 360,
61
- damping: 15,
62
- mass: 0.38,
63
- })
64
- const lift = useTransform(
65
- pointerX,
66
- [center - 84, center - 42, center, center + 42, center + 84],
67
- [0, -4, -13, -4, 0],
68
- )
69
- const smoothLift = useSpring(lift, {
70
- stiffness: 340,
71
- damping: 15,
72
- mass: 0.38,
73
- })
74
- const tooltipY = useTransform(
75
- () => smoothLift.get() - (smoothScale.get() - 1) * 24,
76
- )
77
- const isExternal = item.external ?? /^https?:\/\//.test(item.href)
78
- const content = (
79
- <>
80
- {glowEnabled ? (
81
- <span
82
- aria-hidden="true"
83
- className={cn(
84
- 'pointer-events-none absolute z-0 size-14 rounded-full bg-[radial-gradient(ellipse_at_center,var(--dock-glow-color)_0%,transparent_72%)] opacity-0 blur-[var(--dock-glow-blur)] transition-opacity duration-300 group-hover/dock:opacity-[var(--dock-glow-opacity)] group-focus-visible/dock:opacity-[var(--dock-glow-opacity)]',
85
- item.active && 'opacity-[var(--dock-glow-opacity)]',
86
- )}
87
- />
88
- ) : null}
89
- <motion.span
90
- style={{
91
- scale: reduceMotion ? 1 : smoothScale,
92
- y: reduceMotion ? 0 : smoothLift,
93
- }}
94
- whileTap={reduceMotion ? undefined : { rotate: -3 }}
95
- className={cn(
96
- 'border-border/70 bg-background text-muted group-hover/dock:border-foreground/55 group-hover/dock:bg-surface/70 group-hover/dock:text-foreground group-focus-visible/dock:border-foreground/55 group-focus-visible/dock:text-foreground relative isolate flex size-11 origin-bottom items-center justify-center overflow-hidden rounded-lg border transition-[border-color,background-color,color]',
97
- item.active && 'border-foreground/60 bg-surface/70 text-foreground',
98
- iconClassName,
99
- )}
100
- >
101
- <span
102
- aria-hidden="true"
103
- className="pointer-events-none absolute inset-0 z-0 rounded-[inherit] bg-[linear-gradient(145deg,rgba(255,255,255,0.13)_0%,transparent_48%,rgba(0,0,0,0.06)_100%)] opacity-0 transition-opacity duration-200 group-hover/dock:opacity-100 group-focus-visible/dock:opacity-100"
104
- />
105
- <span className="relative z-10">{item.icon}</span>
106
- {item.active ? (
107
- <motion.span
108
- layoutId="dock-navigation-active-dot"
109
- className="bg-foreground absolute -bottom-1.5 size-1 rounded-full"
110
- transition={
111
- reduceMotion
112
- ? { duration: 0 }
113
- : { type: 'spring', stiffness: 460, damping: 34 }
114
- }
115
- />
116
- ) : null}
117
- </motion.span>
118
- <motion.span
119
- style={{ y: reduceMotion ? 0 : tooltipY }}
120
- className="border-border/70 bg-background text-foreground pointer-events-none absolute -top-10 left-1/2 -translate-x-1/2 translate-y-1 rounded-md border px-2 py-1 font-mono text-[9px] whitespace-nowrap opacity-0 transition-opacity duration-150 group-hover/dock:translate-y-0 group-hover/dock:opacity-100 group-focus-visible/dock:translate-y-0 group-focus-visible/dock:opacity-100"
121
- >
122
- {item.label}
123
- </motion.span>
124
- </>
125
- )
126
-
127
- const linkClassName = cn(
128
- 'group/dock relative flex size-11 cursor-pointer items-center justify-center rounded-lg outline-none',
129
- itemClassName,
130
- )
131
-
132
- return (
133
- <li className="relative flex size-11 items-center justify-center">
134
- <a
135
- href={item.href}
136
- target={isExternal ? '_blank' : undefined}
137
- rel={isExternal ? 'noreferrer' : undefined}
138
- aria-label={item.label}
139
- aria-current={item.active ? 'page' : undefined}
140
- className={linkClassName}
141
- >
142
- {content}
143
- </a>
144
- </li>
145
- )
146
- }
147
-
148
- export default function DockNavigation({
149
- items,
150
- label = 'Primary navigation',
151
- className,
152
- itemClassName,
153
- iconClassName,
154
- glow = {},
155
- }: DockNavigationProps) {
156
- const pointerX = useMotionValue(-1000)
157
- const reduceMotion = useReducedMotion()
158
- const glowOptions = typeof glow === 'object' ? glow : {}
159
- const glowStyle = {
160
- '--dock-glow-color': glowOptions.color ?? 'var(--foreground)',
161
- '--dock-glow-opacity': Math.min(1, Math.max(0, glowOptions.opacity ?? 0.2)),
162
- '--dock-glow-blur': `${Math.max(0, glowOptions.blur ?? 10)}px`,
163
- } as CSSProperties
164
-
165
- function updatePointer(event: PointerEvent<HTMLDivElement>) {
166
- if (event.pointerType === 'touch' || reduceMotion) return
167
- const bounds = event.currentTarget.getBoundingClientRect()
168
- pointerX.set(event.clientX - bounds.left)
169
- }
170
-
171
- return (
172
- <nav aria-label={label}>
173
- <div
174
- onPointerMove={updatePointer}
175
- onPointerLeave={() => pointerX.set(-1000)}
176
- style={glowStyle}
177
- className={cn(
178
- 'border-border/70 bg-background/95 inline-flex rounded-xl border p-2',
179
- className,
180
- )}
181
- >
182
- <ul className="flex items-end gap-2">
183
- {items.map((item, index) => (
184
- <DockItem
185
- key={`${item.href}-${item.label}`}
186
- item={item}
187
- index={index}
188
- pointerX={pointerX}
189
- iconClassName={iconClassName}
190
- itemClassName={itemClassName}
191
- glowEnabled={glow !== false}
192
- />
193
- ))}
194
- </ul>
195
- </div>
196
- </nav>
197
- )
198
- }
1
+ 'use client'
2
+
3
+ import {
4
+ motion,
5
+ useMotionValue,
6
+ useReducedMotion,
7
+ useSpring,
8
+ useTransform,
9
+ } from 'motion/react'
10
+ import type { MotionValue } from 'motion/react'
11
+ import { forwardRef, type CSSProperties, type PointerEvent, type ReactNode } from 'react'
12
+ import { cn } from '@/lib/utils'
13
+
14
+ export type DockNavigationItem = {
15
+ label: string
16
+ href: string
17
+ icon: ReactNode
18
+ active?: boolean
19
+ external?: boolean
20
+ }
21
+
22
+ export type DockNavigationProps = {
23
+ items: DockNavigationItem[]
24
+ label?: string
25
+ className?: string
26
+ itemClassName?: string
27
+ iconClassName?: string
28
+ glow?: false | DockNavigationGlow
29
+ }
30
+
31
+ export type DockNavigationGlow = {
32
+ color?: string
33
+ opacity?: number
34
+ blur?: number
35
+ }
36
+
37
+ function DockItem({
38
+ item,
39
+ index,
40
+ pointerX,
41
+ iconClassName,
42
+ itemClassName,
43
+ glowEnabled,
44
+ }: {
45
+ item: DockNavigationItem
46
+ index: number
47
+ pointerX: MotionValue<number>
48
+ iconClassName?: string
49
+ itemClassName?: string
50
+ glowEnabled: boolean
51
+ }) {
52
+ const reduceMotion = useReducedMotion()
53
+ const center = 30 + index * 52
54
+ const scale = useTransform(
55
+ pointerX,
56
+ [center - 84, center - 42, center, center + 42, center + 84],
57
+ [1, 1.08, 1.36, 1.08, 1],
58
+ )
59
+ const smoothScale = useSpring(scale, {
60
+ stiffness: 360,
61
+ damping: 15,
62
+ mass: 0.38,
63
+ })
64
+ const lift = useTransform(
65
+ pointerX,
66
+ [center - 84, center - 42, center, center + 42, center + 84],
67
+ [0, -4, -13, -4, 0],
68
+ )
69
+ const smoothLift = useSpring(lift, {
70
+ stiffness: 340,
71
+ damping: 15,
72
+ mass: 0.38,
73
+ })
74
+ const tooltipY = useTransform(
75
+ () => smoothLift.get() - (smoothScale.get() - 1) * 24,
76
+ )
77
+ const isExternal = item.external ?? /^https?:\/\//.test(item.href)
78
+ const content = (
79
+ <>
80
+ {glowEnabled ? (
81
+ <span
82
+ aria-hidden="true"
83
+ className={cn(
84
+ 'pointer-events-none absolute z-0 size-14 rounded-full bg-[radial-gradient(ellipse_at_center,var(--dock-glow-color)_0%,transparent_72%)] opacity-0 blur-[var(--dock-glow-blur)] transition-opacity duration-300 group-hover/dock:opacity-[var(--dock-glow-opacity)] group-focus-visible/dock:opacity-[var(--dock-glow-opacity)]',
85
+ item.active && 'opacity-[var(--dock-glow-opacity)]',
86
+ )}
87
+ />
88
+ ) : null}
89
+ <motion.span
90
+ style={{
91
+ scale: reduceMotion ? 1 : smoothScale,
92
+ y: reduceMotion ? 0 : smoothLift,
93
+ }}
94
+ whileTap={reduceMotion ? undefined : { rotate: -3 }}
95
+ className={cn(
96
+ 'border-border/70 bg-background text-muted group-hover/dock:border-foreground/55 group-hover/dock:bg-surface/70 group-hover/dock:text-foreground group-focus-visible/dock:border-foreground/55 group-focus-visible/dock:text-foreground relative isolate flex size-11 origin-bottom items-center justify-center overflow-hidden rounded-lg border transition-[border-color,background-color,color]',
97
+ item.active && 'border-foreground/60 bg-surface/70 text-foreground',
98
+ iconClassName,
99
+ )}
100
+ >
101
+ <span
102
+ aria-hidden="true"
103
+ className="pointer-events-none absolute inset-0 z-0 rounded-[inherit] bg-[linear-gradient(145deg,rgba(255,255,255,0.13)_0%,transparent_48%,rgba(0,0,0,0.06)_100%)] opacity-0 transition-opacity duration-200 group-hover/dock:opacity-100 group-focus-visible/dock:opacity-100"
104
+ />
105
+ <span className="relative z-10">{item.icon}</span>
106
+ {item.active ? (
107
+ <motion.span
108
+ layoutId="dock-navigation-active-dot"
109
+ className="bg-foreground absolute -bottom-1.5 size-1 rounded-full"
110
+ transition={
111
+ reduceMotion
112
+ ? { duration: 0 }
113
+ : { type: 'spring', stiffness: 460, damping: 34 }
114
+ }
115
+ />
116
+ ) : null}
117
+ </motion.span>
118
+ <motion.span
119
+ style={{ y: reduceMotion ? 0 : tooltipY }}
120
+ className="border-border/70 bg-background text-foreground pointer-events-none absolute -top-10 left-1/2 -translate-x-1/2 translate-y-1 rounded-md border px-2 py-1 font-mono text-[9px] whitespace-nowrap opacity-0 transition-opacity duration-150 group-hover/dock:translate-y-0 group-hover/dock:opacity-100 group-focus-visible/dock:translate-y-0 group-focus-visible/dock:opacity-100"
121
+ >
122
+ {item.label}
123
+ </motion.span>
124
+ </>
125
+ )
126
+
127
+ const linkClassName = cn(
128
+ 'group/dock relative flex size-11 cursor-pointer items-center justify-center rounded-lg outline-none',
129
+ itemClassName,
130
+ )
131
+
132
+ return (
133
+ <li className="relative flex size-11 items-center justify-center">
134
+ <a
135
+ href={item.href}
136
+ target={isExternal ? '_blank' : undefined}
137
+ rel={isExternal ? 'noreferrer' : undefined}
138
+ aria-label={item.label}
139
+ aria-current={item.active ? 'page' : undefined}
140
+ className={linkClassName}
141
+ >
142
+ {content}
143
+ </a>
144
+ </li>
145
+ )
146
+ }
147
+
148
+ export const DockNavigation = forwardRef<HTMLElement, DockNavigationProps>(function DockNavigation({
149
+ items,
150
+ label = 'Primary navigation',
151
+ className,
152
+ itemClassName,
153
+ iconClassName,
154
+ glow = {},
155
+ }, ref) {
156
+ const pointerX = useMotionValue(-1000)
157
+ const reduceMotion = useReducedMotion()
158
+ const glowOptions = typeof glow === 'object' ? glow : {}
159
+ const glowStyle = {
160
+ '--dock-glow-color': glowOptions.color ?? 'var(--foreground)',
161
+ '--dock-glow-opacity': Math.min(1, Math.max(0, glowOptions.opacity ?? 0.2)),
162
+ '--dock-glow-blur': `${Math.max(0, glowOptions.blur ?? 10)}px`,
163
+ } as CSSProperties
164
+
165
+ function updatePointer(event: PointerEvent<HTMLDivElement>) {
166
+ if (event.pointerType === 'touch' || reduceMotion) return
167
+ const bounds = event.currentTarget.getBoundingClientRect()
168
+ pointerX.set(event.clientX - bounds.left)
169
+ }
170
+
171
+ return (
172
+ <nav ref={ref} aria-label={label}>
173
+ <div
174
+ onPointerMove={updatePointer}
175
+ onPointerLeave={() => pointerX.set(-1000)}
176
+ style={glowStyle}
177
+ className={cn(
178
+ 'border-border/70 bg-background/95 inline-flex rounded-xl border p-2',
179
+ className,
180
+ )}
181
+ >
182
+ <ul className="flex items-end gap-2">
183
+ {items.map((item, index) => (
184
+ <DockItem
185
+ key={`${item.href}-${item.label}`}
186
+ item={item}
187
+ index={index}
188
+ pointerX={pointerX}
189
+ iconClassName={iconClassName}
190
+ itemClassName={itemClassName}
191
+ glowEnabled={glow !== false}
192
+ />
193
+ ))}
194
+ </ul>
195
+ </div>
196
+ </nav>
197
+ )
198
+ })
199
+
200
+ DockNavigation.displayName = 'DockNavigation'