@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,307 +1,311 @@
1
- 'use client'
2
-
3
- import { motion, useReducedMotion, useTransform } from 'motion/react'
4
- import type { MotionValue } from 'motion/react'
5
- import { cn } from '@/lib/utils'
6
-
7
- export type TextRevealProps = {
8
- text: string
9
- className?: string
10
- characterStagger?: number
11
- lineStagger?: number
12
- duration?: number
13
- waveDistance?: number
14
- waveOvershoot?: number
15
- sidewaysDistance?: number
16
- blurAmount?: number
17
- opacityFrom?: number
18
- opacityPeak?: number
19
- scaleFrom?: number
20
- scalePeak?: number
21
- scrollProgress?: MotionValue<number>
22
- once?: boolean
23
- viewportAmount?: number
24
- }
25
-
26
- function ScrollRevealCharacter({
27
- character,
28
- progress,
29
- start,
30
- end,
31
- waveDistance,
32
- waveOvershoot,
33
- sidewaysDistance,
34
- blurAmount,
35
- opacityFrom,
36
- opacityPeak,
37
- scaleFrom,
38
- scalePeak,
39
- }: {
40
- character: string
41
- progress: MotionValue<number>
42
- start: number
43
- end: number
44
- waveDistance: number
45
- waveOvershoot: number
46
- sidewaysDistance: number
47
- blurAmount: number
48
- opacityFrom: number
49
- opacityPeak: number
50
- scaleFrom: number
51
- scalePeak: number
52
- }) {
53
- const characterProgress = useTransform(progress, [start, end], [0, 1])
54
- const opacity = useTransform(
55
- characterProgress,
56
- [0, 0.55, 1],
57
- [opacityFrom, opacityPeak, 1],
58
- )
59
- const y = useTransform(
60
- characterProgress,
61
- [0, 0.55, 1],
62
- [waveDistance, -waveOvershoot, 0],
63
- )
64
- const x = useTransform(
65
- characterProgress,
66
- [0, 0.55, 1],
67
- [-sidewaysDistance, sidewaysDistance * 0.5, 0],
68
- )
69
- const scale = useTransform(
70
- characterProgress,
71
- [0, 0.55, 1],
72
- [scaleFrom, scalePeak, 1],
73
- )
74
- const filter = useTransform(
75
- characterProgress,
76
- [0, 0.55, 1],
77
- [`blur(${blurAmount}px)`, `blur(${blurAmount * 0.35}px)`, 'blur(0px)'],
78
- )
79
-
80
- return (
81
- <motion.span
82
- style={{ opacity, x, y, scale, filter }}
83
- className="inline-block whitespace-pre"
84
- >
85
- {character}
86
- </motion.span>
87
- )
88
- }
89
-
90
- export function TextReveal({
91
- text,
92
- className,
93
- characterStagger = 0.024,
94
- lineStagger = 0.24,
95
- duration = 0.7,
96
- waveDistance = 5,
97
- waveOvershoot = waveDistance * 0.75,
98
- sidewaysDistance = waveDistance * 0.12,
99
- blurAmount = 7,
100
- opacityFrom = 0.08,
101
- opacityPeak = 0.72,
102
- scaleFrom = 0.96,
103
- scalePeak = 1.025,
104
- scrollProgress,
105
- once = true,
106
- viewportAmount = 0.4,
107
- }: TextRevealProps) {
108
- const shouldReduceMotion = useReducedMotion()
109
- const lines = text.split('\n')
110
- const stagger = Math.max(0, characterStagger)
111
- const lineDelay = Math.max(0, lineStagger)
112
- const animationDuration = Math.max(0, duration)
113
- const wave = Math.max(0, waveDistance)
114
- const wavePeak = Math.max(0, waveOvershoot)
115
- const sideways = Math.max(0, sidewaysDistance)
116
- const blur = Math.max(0, blurAmount)
117
- const startOpacity = Math.min(1, Math.max(0, opacityFrom))
118
- const middleOpacity = Math.min(1, Math.max(startOpacity, opacityPeak))
119
- const startScale = Math.max(0.01, scaleFrom)
120
- const middleScale = Math.max(0.01, scalePeak)
121
- const lineStartDelays: number[] = []
122
- let nextLineDelay = 0
123
-
124
- for (const line of lines) {
125
- lineStartDelays.push(nextLineDelay)
126
- nextLineDelay +=
127
- Math.max(0, Array.from(line).length - 1) * stagger +
128
- animationDuration +
129
- lineDelay
130
- }
131
-
132
- const characterCount = lines.reduce(
133
- (total, line) => total + Array.from(line).length,
134
- 0,
135
- )
136
- const scrollCharacterWeight = Math.max(stagger, 0.001)
137
- const scrollLineWeight = Math.max(0, lineDelay)
138
- const totalScrollWeight =
139
- characterCount * scrollCharacterWeight +
140
- Math.max(0, lines.length - 1) * scrollLineWeight
141
- let scrollWeight = 0
142
-
143
- if (scrollProgress && !shouldReduceMotion) {
144
- return (
145
- <p className={cn('text-foreground', className)}>
146
- <span className="sr-only">{text.replace(/\n/g, ' ')}</span>
147
- {lines.map((line, lineIndex) => {
148
- const words = line.match(/\s+|\S+/gu) ?? []
149
- const content = words.map((word, wordIndex) => {
150
- if (/^\s+$/u.test(word)) {
151
- scrollWeight += Array.from(word).length * scrollCharacterWeight
152
- return (
153
- <span
154
- key={`${wordIndex}-${word}`}
155
- className="whitespace-pre-wrap"
156
- >
157
- {word}
158
- </span>
159
- )
160
- }
161
-
162
- const characters = Array.from(word).map((character) => {
163
- const start = scrollWeight / totalScrollWeight
164
- scrollWeight += scrollCharacterWeight
165
- const end = scrollWeight / totalScrollWeight
166
-
167
- return (
168
- <ScrollRevealCharacter
169
- key={`${start}-${character}`}
170
- character={character}
171
- progress={scrollProgress}
172
- start={start}
173
- end={end}
174
- waveDistance={wave}
175
- waveOvershoot={wavePeak}
176
- sidewaysDistance={sideways}
177
- blurAmount={blur}
178
- opacityFrom={startOpacity}
179
- opacityPeak={middleOpacity}
180
- scaleFrom={startScale}
181
- scalePeak={middleScale}
182
- />
183
- )
184
- })
185
-
186
- return (
187
- <span
188
- key={`${wordIndex}-${word}`}
189
- className="inline-block whitespace-nowrap"
190
- >
191
- {characters}
192
- </span>
193
- )
194
- })
195
-
196
- if (lineIndex < lines.length - 1) {
197
- scrollWeight += scrollLineWeight
198
- }
199
-
200
- return (
201
- <span
202
- key={`${lineIndex}-${line}`}
203
- aria-hidden="true"
204
- className="block"
205
- >
206
- {content}
207
- </span>
208
- )
209
- })}
210
- </p>
211
- )
212
- }
213
-
214
- return (
215
- <motion.p
216
- initial={shouldReduceMotion ? false : 'hidden'}
217
- whileInView="visible"
218
- viewport={{ once, amount: Math.min(1, Math.max(0, viewportAmount)) }}
219
- className={cn('text-foreground', className)}
220
- >
221
- <span className="sr-only">{text.replace(/\n/g, ' ')}</span>
222
- {lines.map((line, lineIndex) => {
223
- let characterIndex = 0
224
- const words = line.match(/\s+|\S+/gu) ?? []
225
-
226
- return (
227
- <span
228
- key={`${lineIndex}-${line}`}
229
- aria-hidden="true"
230
- className="block"
231
- >
232
- {words.map((word, wordIndex) => {
233
- if (/^\s+$/u.test(word)) {
234
- characterIndex += Array.from(word).length
235
- return (
236
- <span
237
- key={`${wordIndex}-${word}`}
238
- className="whitespace-pre-wrap"
239
- >
240
- {word}
241
- </span>
242
- )
243
- }
244
-
245
- const characters = Array.from(word).map((character) => {
246
- const delay =
247
- lineStartDelays[lineIndex] + characterIndex * stagger
248
- characterIndex += 1
249
-
250
- return (
251
- <motion.span
252
- key={`${characterIndex}-${character}`}
253
- custom={delay}
254
- variants={{
255
- hidden: {
256
- opacity: startOpacity,
257
- y: wave,
258
- x: -sideways,
259
- scale: startScale,
260
- filter: `blur(${blur}px)`,
261
- },
262
- visible: shouldReduceMotion
263
- ? {
264
- opacity: 1,
265
- y: 0,
266
- x: 0,
267
- scale: 1,
268
- filter: 'blur(0px)',
269
- transition: { duration: 0 },
270
- }
271
- : (staggerDelay: number) => ({
272
- opacity: 1,
273
- y: [wave, -wavePeak, 0],
274
- x: [-sideways, sideways * 0.5, 0],
275
- scale: [startScale, middleScale, 1],
276
- filter: ['blur(' + blur + 'px)', 'blur(0px)'],
277
- transition: {
278
- duration: animationDuration,
279
- delay: staggerDelay,
280
- ease: 'easeOut',
281
- },
282
- }),
283
- }}
284
- className="inline-block whitespace-pre"
285
- >
286
- {character}
287
- </motion.span>
288
- )
289
- })
290
-
291
- return (
292
- <span
293
- key={`${wordIndex}-${word}`}
294
- className="inline-block whitespace-nowrap"
295
- >
296
- {characters}
297
- </span>
298
- )
299
- })}
300
- </span>
301
- )
302
- })}
303
- </motion.p>
304
- )
305
- }
306
-
307
- export default TextReveal
1
+ 'use client'
2
+
3
+ import { forwardRef } from 'react'
4
+ import { motion, useReducedMotion, useTransform } from 'motion/react'
5
+ import type { MotionValue } from 'motion/react'
6
+ import { cn } from '@/lib/utils'
7
+
8
+ export type TextRevealProps = {
9
+ text: string
10
+ className?: string
11
+ characterStagger?: number
12
+ lineStagger?: number
13
+ duration?: number
14
+ waveDistance?: number
15
+ waveOvershoot?: number
16
+ sidewaysDistance?: number
17
+ blurAmount?: number
18
+ opacityFrom?: number
19
+ opacityPeak?: number
20
+ scaleFrom?: number
21
+ scalePeak?: number
22
+ scrollProgress?: MotionValue<number>
23
+ once?: boolean
24
+ viewportAmount?: number
25
+ }
26
+
27
+ function ScrollRevealCharacter({
28
+ character,
29
+ progress,
30
+ start,
31
+ end,
32
+ waveDistance,
33
+ waveOvershoot,
34
+ sidewaysDistance,
35
+ blurAmount,
36
+ opacityFrom,
37
+ opacityPeak,
38
+ scaleFrom,
39
+ scalePeak,
40
+ }: {
41
+ character: string
42
+ progress: MotionValue<number>
43
+ start: number
44
+ end: number
45
+ waveDistance: number
46
+ waveOvershoot: number
47
+ sidewaysDistance: number
48
+ blurAmount: number
49
+ opacityFrom: number
50
+ opacityPeak: number
51
+ scaleFrom: number
52
+ scalePeak: number
53
+ }) {
54
+ const characterProgress = useTransform(progress, [start, end], [0, 1])
55
+ const opacity = useTransform(
56
+ characterProgress,
57
+ [0, 0.55, 1],
58
+ [opacityFrom, opacityPeak, 1],
59
+ )
60
+ const y = useTransform(
61
+ characterProgress,
62
+ [0, 0.55, 1],
63
+ [waveDistance, -waveOvershoot, 0],
64
+ )
65
+ const x = useTransform(
66
+ characterProgress,
67
+ [0, 0.55, 1],
68
+ [-sidewaysDistance, sidewaysDistance * 0.5, 0],
69
+ )
70
+ const scale = useTransform(
71
+ characterProgress,
72
+ [0, 0.55, 1],
73
+ [scaleFrom, scalePeak, 1],
74
+ )
75
+ const filter = useTransform(
76
+ characterProgress,
77
+ [0, 0.55, 1],
78
+ [`blur(${blurAmount}px)`, `blur(${blurAmount * 0.35}px)`, 'blur(0px)'],
79
+ )
80
+
81
+ return (
82
+ <motion.span
83
+ style={{ opacity, x, y, scale, filter }}
84
+ className="inline-block whitespace-pre"
85
+ >
86
+ {character}
87
+ </motion.span>
88
+ )
89
+ }
90
+
91
+ export const TextReveal = forwardRef<HTMLParagraphElement, TextRevealProps>(function TextReveal({
92
+ text,
93
+ className,
94
+ characterStagger = 0.024,
95
+ lineStagger = 0.24,
96
+ duration = 0.7,
97
+ waveDistance = 5,
98
+ waveOvershoot = waveDistance * 0.75,
99
+ sidewaysDistance = waveDistance * 0.12,
100
+ blurAmount = 7,
101
+ opacityFrom = 0.08,
102
+ opacityPeak = 0.72,
103
+ scaleFrom = 0.96,
104
+ scalePeak = 1.025,
105
+ scrollProgress,
106
+ once = true,
107
+ viewportAmount = 0.4,
108
+ }, ref) {
109
+ const shouldReduceMotion = useReducedMotion()
110
+ const lines = text.split('\n')
111
+ const stagger = Math.max(0, characterStagger)
112
+ const lineDelay = Math.max(0, lineStagger)
113
+ const animationDuration = Math.max(0, duration)
114
+ const wave = Math.max(0, waveDistance)
115
+ const wavePeak = Math.max(0, waveOvershoot)
116
+ const sideways = Math.max(0, sidewaysDistance)
117
+ const blur = Math.max(0, blurAmount)
118
+ const startOpacity = Math.min(1, Math.max(0, opacityFrom))
119
+ const middleOpacity = Math.min(1, Math.max(startOpacity, opacityPeak))
120
+ const startScale = Math.max(0.01, scaleFrom)
121
+ const middleScale = Math.max(0.01, scalePeak)
122
+ const lineStartDelays: number[] = []
123
+ let nextLineDelay = 0
124
+
125
+ for (const line of lines) {
126
+ lineStartDelays.push(nextLineDelay)
127
+ nextLineDelay +=
128
+ Math.max(0, Array.from(line).length - 1) * stagger +
129
+ animationDuration +
130
+ lineDelay
131
+ }
132
+
133
+ const characterCount = lines.reduce(
134
+ (total, line) => total + Array.from(line).length,
135
+ 0,
136
+ )
137
+ const scrollCharacterWeight = Math.max(stagger, 0.001)
138
+ const scrollLineWeight = Math.max(0, lineDelay)
139
+ const totalScrollWeight =
140
+ characterCount * scrollCharacterWeight +
141
+ Math.max(0, lines.length - 1) * scrollLineWeight
142
+ let scrollWeight = 0
143
+
144
+ if (scrollProgress && !shouldReduceMotion) {
145
+ return (
146
+ <p ref={ref} className={cn('text-foreground', className)}>
147
+ <span className="sr-only">{text.replace(/\n/g, ' ')}</span>
148
+ {lines.map((line, lineIndex) => {
149
+ const words = line.match(/\s+|\S+/gu) ?? []
150
+ const content = words.map((word, wordIndex) => {
151
+ if (/^\s+$/u.test(word)) {
152
+ scrollWeight += Array.from(word).length * scrollCharacterWeight
153
+ return (
154
+ <span
155
+ key={`${wordIndex}-${word}`}
156
+ className="whitespace-pre-wrap"
157
+ >
158
+ {word}
159
+ </span>
160
+ )
161
+ }
162
+
163
+ const characters = Array.from(word).map((character) => {
164
+ const start = scrollWeight / totalScrollWeight
165
+ scrollWeight += scrollCharacterWeight
166
+ const end = scrollWeight / totalScrollWeight
167
+
168
+ return (
169
+ <ScrollRevealCharacter
170
+ key={`${start}-${character}`}
171
+ character={character}
172
+ progress={scrollProgress}
173
+ start={start}
174
+ end={end}
175
+ waveDistance={wave}
176
+ waveOvershoot={wavePeak}
177
+ sidewaysDistance={sideways}
178
+ blurAmount={blur}
179
+ opacityFrom={startOpacity}
180
+ opacityPeak={middleOpacity}
181
+ scaleFrom={startScale}
182
+ scalePeak={middleScale}
183
+ />
184
+ )
185
+ })
186
+
187
+ return (
188
+ <span
189
+ key={`${wordIndex}-${word}`}
190
+ className="inline-block whitespace-nowrap"
191
+ >
192
+ {characters}
193
+ </span>
194
+ )
195
+ })
196
+
197
+ if (lineIndex < lines.length - 1) {
198
+ scrollWeight += scrollLineWeight
199
+ }
200
+
201
+ return (
202
+ <span
203
+ key={`${lineIndex}-${line}`}
204
+ aria-hidden="true"
205
+ className="block"
206
+ >
207
+ {content}
208
+ </span>
209
+ )
210
+ })}
211
+ </p>
212
+ )
213
+ }
214
+
215
+ return (
216
+ <motion.p
217
+ ref={ref}
218
+ initial={shouldReduceMotion ? false : 'hidden'}
219
+ whileInView="visible"
220
+ viewport={{ once, amount: Math.min(1, Math.max(0, viewportAmount)) }}
221
+ className={cn('text-foreground', className)}
222
+ >
223
+ <span className="sr-only">{text.replace(/\n/g, ' ')}</span>
224
+ {lines.map((line, lineIndex) => {
225
+ let characterIndex = 0
226
+ const words = line.match(/\s+|\S+/gu) ?? []
227
+
228
+ return (
229
+ <span
230
+ key={`${lineIndex}-${line}`}
231
+ aria-hidden="true"
232
+ className="block"
233
+ >
234
+ {words.map((word, wordIndex) => {
235
+ if (/^\s+$/u.test(word)) {
236
+ characterIndex += Array.from(word).length
237
+ return (
238
+ <span
239
+ key={`${wordIndex}-${word}`}
240
+ className="whitespace-pre-wrap"
241
+ >
242
+ {word}
243
+ </span>
244
+ )
245
+ }
246
+
247
+ const characters = Array.from(word).map((character) => {
248
+ const delay =
249
+ lineStartDelays[lineIndex] + characterIndex * stagger
250
+ characterIndex += 1
251
+
252
+ return (
253
+ <motion.span
254
+ key={`${characterIndex}-${character}`}
255
+ custom={delay}
256
+ variants={{
257
+ hidden: {
258
+ opacity: startOpacity,
259
+ y: wave,
260
+ x: -sideways,
261
+ scale: startScale,
262
+ filter: `blur(${blur}px)`,
263
+ },
264
+ visible: shouldReduceMotion
265
+ ? {
266
+ opacity: 1,
267
+ y: 0,
268
+ x: 0,
269
+ scale: 1,
270
+ filter: 'blur(0px)',
271
+ transition: { duration: 0 },
272
+ }
273
+ : (staggerDelay: number) => ({
274
+ opacity: 1,
275
+ y: [wave, -wavePeak, 0],
276
+ x: [-sideways, sideways * 0.5, 0],
277
+ scale: [startScale, middleScale, 1],
278
+ filter: ['blur(' + blur + 'px)', 'blur(0px)'],
279
+ transition: {
280
+ duration: animationDuration,
281
+ delay: staggerDelay,
282
+ ease: 'easeOut',
283
+ },
284
+ }),
285
+ }}
286
+ className="inline-block whitespace-pre"
287
+ >
288
+ {character}
289
+ </motion.span>
290
+ )
291
+ })
292
+
293
+ return (
294
+ <span
295
+ key={`${wordIndex}-${word}`}
296
+ className="inline-block whitespace-nowrap"
297
+ >
298
+ {characters}
299
+ </span>
300
+ )
301
+ })}
302
+ </span>
303
+ )
304
+ })}
305
+ </motion.p>
306
+ )
307
+ })
308
+
309
+ TextReveal.displayName = 'TextReveal'
310
+
311
+ export default TextReveal