@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
package/package.json CHANGED
@@ -1,27 +1,27 @@
1
- {
2
- "name": "@istmx/ui",
3
- "version": "0.1.11",
4
- "description": "Add editable ISTMX UI components to your project.",
5
- "type": "module",
6
- "bin": {
7
- "istmx": "bin/istmx.mjs"
8
- },
9
- "files": [
10
- "bin",
11
- "registry"
12
- ],
13
- "engines": {
14
- "node": ">=18"
15
- },
16
- "publishConfig": {
17
- "access": "public"
18
- },
19
- "keywords": [
20
- "istmx",
21
- "ui",
22
- "components",
23
- "cli",
24
- "source-first"
25
- ],
26
- "license": "MIT"
27
- }
1
+ {
2
+ "name": "@istmx/ui",
3
+ "version": "0.1.13",
4
+ "description": "Add editable ISTMX UI components to your project.",
5
+ "type": "module",
6
+ "bin": {
7
+ "istmx": "bin/istmx.mjs"
8
+ },
9
+ "files": [
10
+ "bin",
11
+ "registry"
12
+ ],
13
+ "engines": {
14
+ "node": ">=18"
15
+ },
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "keywords": [
20
+ "istmx",
21
+ "ui",
22
+ "components",
23
+ "cli",
24
+ "source-first"
25
+ ],
26
+ "license": "MIT"
27
+ }
@@ -0,0 +1,186 @@
1
+ 'use client'
2
+
3
+ import * as React from 'react'
4
+ import { AnimatePresence, motion, useReducedMotion, type HTMLMotionProps } from 'motion/react'
5
+ import { cn } from '@/lib/utils'
6
+
7
+ type AccordionValue = string | string[]
8
+
9
+ interface AccordionContextValue {
10
+ type: 'single' | 'multiple'
11
+ value: AccordionValue
12
+ collapsible: boolean
13
+ onItemToggle: (itemValue: string) => void
14
+ }
15
+
16
+ interface AccordionItemContextValue {
17
+ value: string
18
+ open: boolean
19
+ triggerId: string
20
+ contentId: string
21
+ onToggle: () => void
22
+ }
23
+
24
+ const AccordionContext = React.createContext<AccordionContextValue | null>(null)
25
+ const AccordionItemContext = React.createContext<AccordionItemContextValue | null>(null)
26
+
27
+ function useAccordionContext() {
28
+ const context = React.useContext(AccordionContext)
29
+ if (!context) throw new Error('Accordion components must be used inside Accordion.')
30
+ return context
31
+ }
32
+
33
+ function useAccordionItemContext() {
34
+ const context = React.useContext(AccordionItemContext)
35
+ if (!context) throw new Error('AccordionTrigger and AccordionContent must be used inside AccordionItem.')
36
+ return context
37
+ }
38
+
39
+ export interface AccordionProps extends React.HTMLAttributes<HTMLDivElement> {
40
+ type?: 'single' | 'multiple'
41
+ value?: AccordionValue
42
+ defaultValue?: AccordionValue
43
+ collapsible?: boolean
44
+ onValueChange?: (value: AccordionValue) => void
45
+ }
46
+
47
+ const Accordion = React.forwardRef<HTMLDivElement, AccordionProps>(
48
+ ({ className, type = 'single', value, defaultValue = type === 'multiple' ? [] : '', collapsible = false, onValueChange, ...props }, ref) => {
49
+ const [uncontrolledValue, setUncontrolledValue] = React.useState<AccordionValue>(defaultValue)
50
+ const currentValue = value ?? uncontrolledValue
51
+ const handleItemToggle = React.useCallback((itemValue: string) => {
52
+ let nextValue: AccordionValue
53
+ if (type === 'multiple') {
54
+ const values = Array.isArray(currentValue) ? currentValue : currentValue ? [currentValue] : []
55
+ nextValue = values.includes(itemValue) ? values.filter((current) => current !== itemValue) : [...values, itemValue]
56
+ } else {
57
+ const current = Array.isArray(currentValue) ? currentValue[0] : currentValue
58
+ nextValue = current === itemValue && collapsible ? '' : itemValue
59
+ }
60
+ if (value === undefined) setUncontrolledValue(nextValue)
61
+ onValueChange?.(nextValue)
62
+ }, [collapsible, currentValue, onValueChange, type, value])
63
+
64
+ return (
65
+ <AccordionContext.Provider value={{ type, value: currentValue, collapsible, onItemToggle: handleItemToggle }}>
66
+ <div {...props} ref={ref} data-slot="accordion" className={cn('w-full', className)} />
67
+ </AccordionContext.Provider>
68
+ )
69
+ },
70
+ )
71
+
72
+ Accordion.displayName = 'Accordion'
73
+
74
+ export interface AccordionItemProps extends Omit<HTMLMotionProps<'div'>, 'ref'> {
75
+ value: string
76
+ }
77
+
78
+ const AccordionItem = React.forwardRef<HTMLDivElement, AccordionItemProps>(({ value, className, children, ...props }, ref) => {
79
+ const accordion = useAccordionContext()
80
+ const reduceMotion = useReducedMotion()
81
+ const generatedId = React.useId()
82
+ const open = Array.isArray(accordion.value) ? accordion.value.includes(value) : accordion.value === value
83
+
84
+ return (
85
+ <AccordionItemContext.Provider value={{ value, open, triggerId: `${generatedId}-trigger`, contentId: `${generatedId}-content`, onToggle: () => accordion.onItemToggle(value) }}>
86
+ <motion.div
87
+ {...props}
88
+ ref={ref}
89
+ layout={reduceMotion ? false : 'position'}
90
+ transition={reduceMotion ? { duration: 0 } : { type: 'spring', stiffness: 420, damping: 34, mass: 0.7 }}
91
+ data-slot="accordion-item"
92
+ data-state={open ? 'open' : 'closed'}
93
+ className={cn('border-b border-border last:border-b-0', className)}
94
+ >
95
+ {children}
96
+ </motion.div>
97
+ </AccordionItemContext.Provider>
98
+ )
99
+ })
100
+
101
+ AccordionItem.displayName = 'AccordionItem'
102
+
103
+ export interface AccordionTriggerProps extends Omit<HTMLMotionProps<'button'>, 'ref' | 'children'> {
104
+ children?: React.ReactNode
105
+ }
106
+
107
+ const AccordionTrigger = React.forwardRef<HTMLButtonElement, AccordionTriggerProps>(({ className, children, ...props }, ref) => {
108
+ const item = useAccordionItemContext()
109
+ const reduceMotion = useReducedMotion()
110
+
111
+ return (
112
+ <motion.button
113
+ {...props}
114
+ ref={ref}
115
+ type="button"
116
+ id={item.triggerId}
117
+ aria-expanded={item.open}
118
+ aria-controls={item.contentId}
119
+ data-slot="accordion-trigger"
120
+ data-state={item.open ? 'open' : 'closed'}
121
+ onClick={(event) => {
122
+ props.onClick?.(event)
123
+ if (!event.defaultPrevented) item.onToggle()
124
+ }}
125
+ onKeyDown={(event) => {
126
+ props.onKeyDown?.(event)
127
+ if (event.defaultPrevented || !['ArrowDown', 'ArrowUp', 'Home', 'End'].includes(event.key)) return
128
+ const triggers = Array.from(event.currentTarget.closest('[data-slot="accordion"]')?.querySelectorAll<HTMLButtonElement>('[data-slot="accordion-trigger"]') ?? [])
129
+ const index = triggers.indexOf(event.currentTarget)
130
+ if (index < 0 || triggers.length < 2) return
131
+ event.preventDefault()
132
+ const nextIndex = event.key === 'Home'
133
+ ? 0
134
+ : event.key === 'End'
135
+ ? triggers.length - 1
136
+ : (index + (event.key === 'ArrowDown' ? 1 : -1) + triggers.length) % triggers.length
137
+ triggers[nextIndex]?.focus()
138
+ }}
139
+ whileTap={reduceMotion ? undefined : { scale: 0.995 }}
140
+ transition={{ type: 'spring', stiffness: 500, damping: 32 }}
141
+ className={cn('flex min-h-12 w-full items-center justify-between gap-4 py-3 text-left text-sm font-medium text-foreground outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-foreground/70', className)}
142
+ >
143
+ <span>{children}</span>
144
+ <motion.svg aria-hidden="true" viewBox="0 0 20 20" fill="none" className="size-4 shrink-0 text-muted-foreground" animate={{ rotate: item.open ? 180 : 0 }} transition={{ duration: reduceMotion ? 0 : 0.2, ease: 'easeOut' }}>
145
+ <path d="m5 7.5 5 5 5-5" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" />
146
+ </motion.svg>
147
+ </motion.button>
148
+ )
149
+ })
150
+
151
+ AccordionTrigger.displayName = 'AccordionTrigger'
152
+
153
+ export interface AccordionContentProps extends Omit<HTMLMotionProps<'div'>, 'ref' | 'children'> {
154
+ children?: React.ReactNode
155
+ }
156
+
157
+ const AccordionContent = React.forwardRef<HTMLDivElement, AccordionContentProps>(({ className, children, ...props }, ref) => {
158
+ const item = useAccordionItemContext()
159
+ const reduceMotion = useReducedMotion()
160
+
161
+ return (
162
+ <AnimatePresence initial={false}>
163
+ {item.open && (
164
+ <motion.div
165
+ {...props}
166
+ ref={ref}
167
+ id={item.contentId}
168
+ role="region"
169
+ aria-labelledby={item.triggerId}
170
+ data-slot="accordion-content"
171
+ initial={reduceMotion ? { opacity: 1 } : { height: 0, opacity: 0 }}
172
+ animate={{ height: 'auto', opacity: 1 }}
173
+ exit={reduceMotion ? { opacity: 0 } : { height: 0, opacity: 0 }}
174
+ transition={{ duration: reduceMotion ? 0 : 0.24, ease: [0.22, 1, 0.36, 1] }}
175
+ className="overflow-hidden"
176
+ >
177
+ <div className={cn('pb-4 pr-8 text-sm leading-6 text-muted-foreground', className)}>{children}</div>
178
+ </motion.div>
179
+ )}
180
+ </AnimatePresence>
181
+ )
182
+ })
183
+
184
+ AccordionContent.displayName = 'AccordionContent'
185
+
186
+ export { Accordion, AccordionItem, AccordionTrigger, AccordionContent }