@catalystsoftware/ui 1.0.0
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.
- package/README.md +7 -0
- package/components/catalyst-ui/buttons/burger.tsx +207 -0
- package/components/catalyst-ui/core/data-display/timeline.tsx +210 -0
- package/components/catalyst-ui/core/feedback/alert.tsx +491 -0
- package/components/catalyst-ui/core/feedback/spinner-1.tsx +65 -0
- package/components/catalyst-ui/core/feedback/toast.tsx +1857 -0
- package/components/catalyst-ui/core/navigation/menu.tsx +164 -0
- package/components/catalyst-ui/forms/toggle-class.tsx +176 -0
- package/components/catalyst-ui/hooks/use-copy-to-clipboard.tsx +419 -0
- package/components/catalyst-ui/hooks/use-counter.tsx +13 -0
- package/components/catalyst-ui/hooks/use-event-listener.tsx +23 -0
- package/components/catalyst-ui/hooks/use-export-markdown.tsx +47 -0
- package/components/catalyst-ui/hooks/use-focus.tsx +17 -0
- package/components/catalyst-ui/hooks/use-interval.tsx +23 -0
- package/components/catalyst-ui/hooks/use-is-client.tsx +16 -0
- package/components/catalyst-ui/hooks/use-media-query.tsx +19 -0
- package/components/catalyst-ui/hooks/use-mobile.tsx +19 -0
- package/components/catalyst-ui/hooks/use-resize-observer.tsx +81 -0
- package/components/catalyst-ui/hooks/use-timeout.tsx +21 -0
- package/components/catalyst-ui/hooks/use-timer.tsx +209 -0
- package/components/catalyst-ui/hooks/use-toggle.tsx +12 -0
- package/components/catalyst-ui/media/image.tsx +13 -0
- package/components/catalyst-ui/overlays/dual-sidebar.tsx +4142 -0
- package/components/catalyst-ui/overlays/sidebar-original.tsx +726 -0
- package/components/catalyst-ui/primitives/accordion.tsx +250 -0
- package/components/catalyst-ui/primitives/alert-dialog.tsx +126 -0
- package/components/catalyst-ui/primitives/aspect-ratio.tsx +9 -0
- package/components/catalyst-ui/primitives/avatar.tsx +296 -0
- package/components/catalyst-ui/primitives/badge.tsx +57 -0
- package/components/catalyst-ui/primitives/breadcrumb.tsx +101 -0
- package/components/catalyst-ui/primitives/button.tsx +265 -0
- package/components/catalyst-ui/primitives/calendar-v4.tsx +208 -0
- package/components/catalyst-ui/primitives/calendar.tsx +295 -0
- package/components/catalyst-ui/primitives/card.tsx +618 -0
- package/components/catalyst-ui/primitives/carousel.tsx +238 -0
- package/components/catalyst-ui/primitives/chart.tsx +347 -0
- package/components/catalyst-ui/primitives/checkbox.tsx +225 -0
- package/components/catalyst-ui/primitives/collapsible.tsx +212 -0
- package/components/catalyst-ui/primitives/command.tsx +393 -0
- package/components/catalyst-ui/primitives/context-menu.tsx +236 -0
- package/components/catalyst-ui/primitives/dialog.tsx +471 -0
- package/components/catalyst-ui/primitives/drawer.tsx +761 -0
- package/components/catalyst-ui/primitives/dropdown-menu.tsx +290 -0
- package/components/catalyst-ui/primitives/empty.tsx +104 -0
- package/components/catalyst-ui/primitives/field.tsx +244 -0
- package/components/catalyst-ui/primitives/hover-card.tsx +124 -0
- package/components/catalyst-ui/primitives/input-otp.tsx +76 -0
- package/components/catalyst-ui/primitives/input.tsx +64 -0
- package/components/catalyst-ui/primitives/item.tsx +196 -0
- package/components/catalyst-ui/primitives/kbd.tsx +75 -0
- package/components/catalyst-ui/primitives/label.tsx +24 -0
- package/components/catalyst-ui/primitives/navigation-menu.tsx +150 -0
- package/components/catalyst-ui/primitives/pagination.tsx +198 -0
- package/components/catalyst-ui/primitives/popover.tsx +232 -0
- package/components/catalyst-ui/primitives/progress.tsx +34 -0
- package/components/catalyst-ui/primitives/radio-group.tsx +43 -0
- package/components/catalyst-ui/primitives/resizable.tsx +56 -0
- package/components/catalyst-ui/primitives/select.tsx +155 -0
- package/components/catalyst-ui/primitives/separator.tsx +74 -0
- package/components/catalyst-ui/primitives/sheet.tsx +126 -0
- package/components/catalyst-ui/primitives/skeleton.tsx +15 -0
- package/components/catalyst-ui/primitives/slider.tsx +27 -0
- package/components/catalyst-ui/primitives/switch.tsx +187 -0
- package/components/catalyst-ui/primitives/tabs.tsx +335 -0
- package/components/catalyst-ui/primitives/textarea.tsx +24 -0
- package/components/catalyst-ui/primitives/toggle-group.tsx +55 -0
- package/components/catalyst-ui/primitives/toggle.tsx +42 -0
- package/components/catalyst-ui/primitives/tooltip.tsx +116 -0
- package/components/catalyst-ui/utils/basic-auth.tsx +40 -0
- package/components/catalyst-ui/utils/context-storage.tsx +19 -0
- package/components/catalyst-ui/utils/cors-middleware.tsx +71 -0
- package/components/catalyst-ui/utils/deferred-content.tsx +595 -0
- package/components/catalyst-ui/utils/honeypot-middleware.tsx +38 -0
- package/components/catalyst-ui/utils/incId.tsx +75 -0
- package/components/catalyst-ui/utils/jwk-auth.tsx +36 -0
- package/components/catalyst-ui/utils/request-id.tsx +14 -0
- package/components/catalyst-ui/utils/secure-headers.tsx +37 -0
- package/components/catalyst-ui/utils/server-timing.tsx +23 -0
- package/components/catalyst-ui/utils/utils.ts +43 -0
- package/components/catalyst-ui/utils/with-cookie.tsx +43 -0
- package/components/catalyst-ui/x/accordian-x.tsx +428 -0
- package/components/catalyst-ui/x/alert-x.tsx +413 -0
- package/components/catalyst-ui/x/animated-text-x.tsx +2242 -0
- package/components/catalyst-ui/x/avatar-x.tsx +515 -0
- package/components/catalyst-ui/x/badge-x.tsx +670 -0
- package/components/catalyst-ui/x/button-X.tsx +2857 -0
- package/components/catalyst-ui/x/button-group-x.tsx +847 -0
- package/components/catalyst-ui/x/calendar-x.tsx +1910 -0
- package/components/catalyst-ui/x/card-x.tsx +2597 -0
- package/components/catalyst-ui/x/checkbox-x.tsx +656 -0
- package/components/catalyst-ui/x/collapsible-x.tsx +1360 -0
- package/components/catalyst-ui/x/combobox-x.tsx +911 -0
- package/components/catalyst-ui/x/data-table-x.tsx +1753 -0
- package/components/catalyst-ui/x/date-picker-x.tsx +648 -0
- package/components/catalyst-ui/x/dialog-x.tsx +659 -0
- package/components/catalyst-ui/x/dropdown-menu-x.tsx +612 -0
- package/components/catalyst-ui/x/hover-card-x.tsx +375 -0
- package/components/catalyst-ui/x/icon-x.tsx +840 -0
- package/components/catalyst-ui/x/input-mask-x.tsx +981 -0
- package/components/catalyst-ui/x/input-otp-x.tsx +659 -0
- package/components/catalyst-ui/x/loader-x.tsx +1757 -0
- package/components/catalyst-ui/x/pagination-x.tsx +622 -0
- package/components/catalyst-ui/x/popover-x.tsx +744 -0
- package/components/catalyst-ui/x/radio-group-x.tsx +499 -0
- package/components/catalyst-ui/x/select-x.tsx +1127 -0
- package/components/catalyst-ui/x/sheet-x.tsx +668 -0
- package/components/catalyst-ui/x/switch-x.tsx +681 -0
- package/components/catalyst-ui/x/table-x.tsx +574 -0
- package/components/catalyst-ui/x/tabs-x.tsx +839 -0
- package/components/catalyst-ui/x/textarea-x.tsx +1263 -0
- package/components/catalyst-ui/x/tooltip-x.tsx +396 -0
- package/components/catalyst-ui/x/tracker-x.tsx +560 -0
- package/data/bg-data.tsx +901 -0
- package/data/buttons-data.tsx +2327 -0
- package/data/charts-data.tsx +102 -0
- package/data/chat-data.tsx +83 -0
- package/data/code-data.tsx +1040 -0
- package/data/comboboxes-data.tsx +1843 -0
- package/data/command-data.tsx +1381 -0
- package/data/core-data.tsx +15953 -0
- package/data/crm-data.tsx +47 -0
- package/data/data.tsx +159 -0
- package/data/date-and-time-data.tsx +554 -0
- package/data/dependencies.tsx +7 -0
- package/data/ecommerce-data.tsx +1387 -0
- package/data/forms-data.tsx +7890 -0
- package/data/hooks-data.tsx +5487 -0
- package/data/index.ts +34 -0
- package/data/inputs-data.tsx +557 -0
- package/data/interactive-data.tsx +5394 -0
- package/data/lofi-data.tsx +18295 -0
- package/data/marketing-data.tsx +2546 -0
- package/data/media-data.tsx +1510 -0
- package/data/motion-data.tsx +5801 -0
- package/data/overlay-data.tsx +4136 -0
- package/data/pdf-data.tsx +124 -0
- package/data/pos-data.tsx +213 -0
- package/data/postcss.config.js +6 -0
- package/data/primitive-data.tsx +5170 -0
- package/data/prompt-data.tsx +1226 -0
- package/data/requiredLibs.ts +4 -0
- package/data/sandbox-data.tsx +1 -0
- package/data/sidebars-data.tsx +5421 -0
- package/data/stacks-data.tsx +32 -0
- package/data/table-data.tsx +706 -0
- package/data/tailwind.config.js +3830 -0
- package/data/tailwind.config.ngin.js +3830 -0
- package/data/tailwind.css +431 -0
- package/data/tools-data.tsx +6910 -0
- package/data/typography-data.tsx +2050 -0
- package/data/utils-data.tsx +6500 -0
- package/data/x-data.tsx +1171 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +30245 -0
- package/dist/index.js.map +362 -0
- package/package.json +50 -0
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import * as AccordionPrimitive from "@radix-ui/react-accordion"
|
|
3
|
+
import { ChevronDown, Plus } from "lucide-react"
|
|
4
|
+
import { cn } from "~/components/catalyst-ui"
|
|
5
|
+
import { Accordion, AccordionItem, accordionTriggerVariants, TsxSection } from "~/components/catalyst-ui"
|
|
6
|
+
import { Avatar, AvatarImage, AvatarFallback } from "~/components/catalyst-ui"
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* ★ ━━━━━━━━━━━━━━ ☆ ━━━━━━━━━━━━━━ ☆ ━━━━━━━━━━━━━━ AccordionX ━━━━━━━━━━━━━━ ☆ ━━━━━━━━━━━━━━ ☆ ━━━━━━━━━━━━━━ ★
|
|
10
|
+
* ★ ━━━━ ☆ ━━━━ ━━━━ ☆ ━━━━ ★
|
|
11
|
+
* type AccordionXType = 'default' | 'plusMinus' | 'avatar' | 'iconSubtitle' | 'media'
|
|
12
|
+
*
|
|
13
|
+
* ★ ━━━━━━━━━━━━━━ ☆ ━━━━━━━━━━━━━━ ☆ ━━━━━━━━━━━━━ Default ━━━━━━━━━━━━━━ ☆ ━━━━━━━━━━━━━━ ☆ ━━━━━━━━━━━━━━ ★
|
|
14
|
+
* ```jsx
|
|
15
|
+
* <AccordionX type="single" collapsible defaultValue="item-1">
|
|
16
|
+
* {items.map((item, index) => (
|
|
17
|
+
* <AccordionXItem key={index} value={`item-${index + 1}`}>
|
|
18
|
+
* <AccordionXTrigger>{item.title}</AccordionXTrigger>
|
|
19
|
+
* <AccordionXContent>{item.content}</AccordionXContent>
|
|
20
|
+
* </AccordionXItem>
|
|
21
|
+
* ))}
|
|
22
|
+
* </AccordionX>
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* ★ ━━━━━━━━━━━━━━ ☆ ━━━━━━━━━━━━━━ ☆ ━━━━━━━━━━━━━ Plus/Minus Icon ━━━━━━━━━━━━━━ ☆ ━━━━━━━━━━━━━━ ☆ ━━━━━━━━━━━━━━ ★
|
|
26
|
+
* ```jsx
|
|
27
|
+
* <AccordionX accordionType="plusMinus" type="single" collapsible defaultValue="item-1">
|
|
28
|
+
* {items.map((item, index) => (
|
|
29
|
+
* <AccordionXItem key={index} value={`item-${index + 1}`}>
|
|
30
|
+
* <AccordionXTrigger>{item.title}</AccordionXTrigger>
|
|
31
|
+
* <AccordionXContent>{item.content}</AccordionXContent>
|
|
32
|
+
* </AccordionXItem>
|
|
33
|
+
* ))}
|
|
34
|
+
* </AccordionX>
|
|
35
|
+
* ```
|
|
36
|
+
*
|
|
37
|
+
* ★ ━━━━━━━━━━━━━━ ☆ ━━━━━━━━━━━━━━ ☆ ━━━━━━━━━━━━━ Avatar ━━━━━━━━━━━━━━ ☆ ━━━━━━━━━━━━━━ ☆ ━━━━━━━━━━━━━━ ★
|
|
38
|
+
* ```jsx
|
|
39
|
+
* <AccordionX accordionType="avatar" type="single" collapsible defaultValue="item-1">
|
|
40
|
+
* {items.map((item, index) => (
|
|
41
|
+
* <AccordionXItem key={index} value={`item-${index + 1}`}>
|
|
42
|
+
* <AccordionXTrigger
|
|
43
|
+
* name={item.name}
|
|
44
|
+
* email={item.email}
|
|
45
|
+
* avatarImage={item.avatarImage}
|
|
46
|
+
* />
|
|
47
|
+
* <AccordionXContent>{item.content}</AccordionXContent>
|
|
48
|
+
* </AccordionXItem>
|
|
49
|
+
* ))}
|
|
50
|
+
* </AccordionX>
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* ★ ━━━━━━━━━━━━━━ ☆ ━━━━━━━━━━━━━━ ☆ ━━━━━━━━━━━━━ Icon with Subtitle ━━━━━━━━━━━━━━ ☆ ━━━━━━━━━━━━━━ ☆ ━━━━━━━━━━━━━━ ★
|
|
54
|
+
* ```jsx
|
|
55
|
+
* <AccordionX accordionType="iconSubtitle" type="single" collapsible defaultValue="item-1">
|
|
56
|
+
* {items.map((item, index) => (
|
|
57
|
+
* <AccordionXItem key={index} value={`item-${index + 1}`}>
|
|
58
|
+
* <AccordionXTrigger subtitle={item.subtitle}>
|
|
59
|
+
* {item.title}
|
|
60
|
+
* </AccordionXTrigger>
|
|
61
|
+
* <AccordionXContent>{item.content}</AccordionXContent>
|
|
62
|
+
* </AccordionXItem>
|
|
63
|
+
* ))}
|
|
64
|
+
* </AccordionX>
|
|
65
|
+
* ```
|
|
66
|
+
*
|
|
67
|
+
* ★ ━━━━━━━━━━━━━━ ☆ ━━━━━━━━━━━━━━ ☆ ━━━━━━━━━━━━━ Props ━━━━━━━━━━━━━━ ☆ ━━━━━━━━━━━━━━ ☆ ━━━━━━━━━━━━━━ ★
|
|
68
|
+
* - AccordionX Props:
|
|
69
|
+
* - `accordionType`: 'default' | 'plusMinus' | 'avatar' | 'iconSubtitle' | 'media'
|
|
70
|
+
* - `type`: 'single' | 'multiple' - Accordion behavior
|
|
71
|
+
* - `collapsible`: boolean - Allow all items to be closed
|
|
72
|
+
* - `defaultValue`: string - Default open item(s)
|
|
73
|
+
* - `value`: string - Controlled open item(s)
|
|
74
|
+
* - `onValueChange`: (value: string) => void - Callback when value changes
|
|
75
|
+
*
|
|
76
|
+
* - AccordionXItem Props:
|
|
77
|
+
* - `value`: string - Unique value for the item
|
|
78
|
+
* - `disabled`: boolean - Whether the item is disabled
|
|
79
|
+
*
|
|
80
|
+
* - AccordionXTrigger Props:
|
|
81
|
+
* - `children`: ReactNode - Trigger content
|
|
82
|
+
* - `subtitle`: string - Subtitle text (for iconSubtitle type)
|
|
83
|
+
* - `name`: string - User name (for avatar type)
|
|
84
|
+
* - `email`: string - User email (for avatar type)
|
|
85
|
+
* - `avatarImage`: string - Avatar image URL (for avatar type)
|
|
86
|
+
*
|
|
87
|
+
* - AccordionXContent Props:
|
|
88
|
+
* - `children`: ReactNode - Content to display when expanded
|
|
89
|
+
*
|
|
90
|
+
* ★ ━━━━━━━━━━━━━━ ☆ ━━━━━━━━━━━━━━ ☆ ━━━━━━━━━━━━━ Data Structure ━━━━━━━━━━━━━━ ☆ ━━━━━━━━━━━━━━ ☆ ━━━━━━━━━━━━━━ ★
|
|
91
|
+
* ```typescript
|
|
92
|
+
* interface AccordionItem {
|
|
93
|
+
* title: string;
|
|
94
|
+
* content: string;
|
|
95
|
+
* name?: string;
|
|
96
|
+
* email?: string;
|
|
97
|
+
* subtitle?: string;
|
|
98
|
+
* avatarImage?: string;
|
|
99
|
+
* media?: string;
|
|
100
|
+
* }
|
|
101
|
+
* ```
|
|
102
|
+
*
|
|
103
|
+
* ★ ━━━━━━━━━━━━━━ ☆ ━━━━━━━━━━━━━━ ☆ ━━━━━━━━━━━━━ Example Items Array ━━━━━━━━━━━━━━ ☆ ━━━━━━━━━━━━━━ ☆ ━━━━━━━━━━━━━━ ★
|
|
104
|
+
* ```javascript
|
|
105
|
+
* const items = [
|
|
106
|
+
* {
|
|
107
|
+
* title: 'How do I track my order?',
|
|
108
|
+
* content: 'You can track your order by logging into your account.',
|
|
109
|
+
* name: 'John Doe',
|
|
110
|
+
* email: 'john@example.com',
|
|
111
|
+
* subtitle: 'Basic Plan',
|
|
112
|
+
* avatarImage: 'https://github.com/shadcn.png',
|
|
113
|
+
* media: 'https://images.unsplash.com/photo-1618005182384-a83a8bd57fbe?w=800&auto=format&fit=crop'
|
|
114
|
+
* },
|
|
115
|
+
* // ... more items
|
|
116
|
+
* ]
|
|
117
|
+
* ```
|
|
118
|
+
*
|
|
119
|
+
*/
|
|
120
|
+
|
|
121
|
+
type AccordionContextType = {
|
|
122
|
+
variant?: VariantProps<typeof accordionVariants>["variant"]
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const AccordionContext = React.createContext<AccordionContextType>({
|
|
126
|
+
variant: "default",
|
|
127
|
+
})
|
|
128
|
+
|
|
129
|
+
const useAccordionContext = () => {
|
|
130
|
+
const context = React.useContext(AccordionContext)
|
|
131
|
+
if (!context) {
|
|
132
|
+
throw new Error("Accordion components must be used within Accordion")
|
|
133
|
+
}
|
|
134
|
+
return context
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
type AccordionType = 'default' | 'leftIcon' | 'plusMinus' | 'expandIcon' | 'avatar' | 'iconSubtitle'
|
|
138
|
+
|
|
139
|
+
const AccordionXContext = React.createContext<AccordionType>('default')
|
|
140
|
+
|
|
141
|
+
export function AccordionX({ accordion = 'default', variant, ...props }: any) {
|
|
142
|
+
const contextValue: AlertContextValue = { variant, accordion }
|
|
143
|
+
return (
|
|
144
|
+
<AccordionXContext.Provider value={contextValue}>
|
|
145
|
+
<Accordion {...props} />
|
|
146
|
+
</AccordionXContext.Provider>
|
|
147
|
+
)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export function AccordionXItem({ ...props }: any) {
|
|
151
|
+
const { variant, accordion } = useAccordionContext()
|
|
152
|
+
switch (accordion) {
|
|
153
|
+
default:
|
|
154
|
+
return <AccordionItem {...props} />
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export function AccordionXTrigger({children, ...props }: any) {
|
|
159
|
+
const { variant, accordion } = useAccordionContext()
|
|
160
|
+
const Icon = props.icon
|
|
161
|
+
switch (accordion) {
|
|
162
|
+
case 'leftIcon':
|
|
163
|
+
return (
|
|
164
|
+
<AccordionPrimitive.Header className="flex">
|
|
165
|
+
<AccordionPrimitive.Trigger
|
|
166
|
+
className={cn(accordionTriggerVariants({ variant }), "justify-start [&>svg]:order-first", props.className)}
|
|
167
|
+
{...props}
|
|
168
|
+
>
|
|
169
|
+
<span className='flex items-center gap-4'>
|
|
170
|
+
{Icon && <Icon className='text-muted-foreground size-4 shrink-0' />}
|
|
171
|
+
<span>{children}</span>
|
|
172
|
+
</span>
|
|
173
|
+
<ChevronDown className="h-4 w-4 shrink-0 transition-transform duration-200" />
|
|
174
|
+
</AccordionPrimitive.Trigger>
|
|
175
|
+
</AccordionPrimitive.Header>
|
|
176
|
+
)
|
|
177
|
+
|
|
178
|
+
case 'plusMinus':
|
|
179
|
+
return (
|
|
180
|
+
<AccordionPrimitive.Header className="flex">
|
|
181
|
+
<AccordionPrimitive.Trigger
|
|
182
|
+
className={cn(
|
|
183
|
+
accordionTriggerVariants({
|
|
184
|
+
|
|
185
|
+
}),
|
|
186
|
+
"focus-visible:border-ring focus-visible:ring-ring/50 rounded-md outline-none focus-visible:ring-[3px] [&>svg>path:last-child]:origin-center [&>svg>path:last-child]:transition-all [&>svg>path:last-child]:duration-200 [&[data-state=open]>svg]:rotate-180 [&[data-state=open]>svg>path:last-child]:rotate-90 [&[data-state=open]>svg>path:last-child]:opacity-0",
|
|
187
|
+
props.className
|
|
188
|
+
)}
|
|
189
|
+
{...props}
|
|
190
|
+
>
|
|
191
|
+
{children}
|
|
192
|
+
<Plus className="text-muted-foreground pointer-events-none size-4 shrink-0 transition-transform duration-200" />
|
|
193
|
+
</AccordionPrimitive.Trigger>
|
|
194
|
+
</AccordionPrimitive.Header>
|
|
195
|
+
)
|
|
196
|
+
|
|
197
|
+
case 'expandIcon':
|
|
198
|
+
return (
|
|
199
|
+
<AccordionPrimitive.Header className="flex">
|
|
200
|
+
<AccordionPrimitive.Trigger
|
|
201
|
+
className={cn(
|
|
202
|
+
accordionTriggerVariants({ variant }),
|
|
203
|
+
"focus-visible:border-ring focus-visible:ring-ring/50 items-start rounded-md outline-none focus-visible:ring-[3px] [&[data-state=open]>svg]:rotate-45",
|
|
204
|
+
props.className
|
|
205
|
+
)}
|
|
206
|
+
{...props}
|
|
207
|
+
>
|
|
208
|
+
<span className="flex items-center gap-4">
|
|
209
|
+
{Icon && <Icon className="size-4 shrink-0" />}
|
|
210
|
+
<span>{children}</span>
|
|
211
|
+
</span>
|
|
212
|
+
<Plus className="text-muted-foreground pointer-events-none size-4 shrink-0 transition-transform duration-200" />
|
|
213
|
+
</AccordionPrimitive.Trigger>
|
|
214
|
+
</AccordionPrimitive.Header>
|
|
215
|
+
)
|
|
216
|
+
|
|
217
|
+
case 'avatar':
|
|
218
|
+
return (
|
|
219
|
+
<AccordionPrimitive.Header className="flex">
|
|
220
|
+
<AccordionPrimitive.Trigger
|
|
221
|
+
className={cn(accordionTriggerVariants({ variant }), "items-center hover:no-underline", props.className)}
|
|
222
|
+
{...props}
|
|
223
|
+
>
|
|
224
|
+
<span className='flex items-center gap-4'>
|
|
225
|
+
<Avatar className='size-10.5 rounded-sm'>
|
|
226
|
+
<AvatarImage src={props.avatar} alt={props.name} className='rounded-sm' />
|
|
227
|
+
<AvatarFallback className='rounded-sm text-xs'>
|
|
228
|
+
{props.name?.split(/\s/).reduce((response: string, word: string) => (response += word.slice(0, 1)), '')}
|
|
229
|
+
</AvatarFallback>
|
|
230
|
+
</Avatar>
|
|
231
|
+
<span className='flex flex-col space-y-0.5'>
|
|
232
|
+
<span>{props.name}</span>
|
|
233
|
+
<span className='text-muted-foreground font-normal'>{props.email}</span>
|
|
234
|
+
</span>
|
|
235
|
+
</span>
|
|
236
|
+
<ChevronDown className="h-4 w-4 shrink-0 transition-transform duration-200" />
|
|
237
|
+
</AccordionPrimitive.Trigger>
|
|
238
|
+
</AccordionPrimitive.Header>
|
|
239
|
+
)
|
|
240
|
+
|
|
241
|
+
case 'iconSubtitle':
|
|
242
|
+
return (
|
|
243
|
+
<AccordionPrimitive.Header className="flex">
|
|
244
|
+
<AccordionPrimitive.Trigger
|
|
245
|
+
className={cn(
|
|
246
|
+
accordionTriggerVariants({ variant }),
|
|
247
|
+
"focus-visible:border-ring focus-visible:ring-ring/50 rounded-md outline-none focus-visible:ring-[3px] [&>svg>path:last-child]:origin-center [&>svg>path:last-child]:transition-all [&>svg>path:last-child]:duration-200 [&[data-state=open]>svg]:rotate-180 [&[data-state=open]>svg>path:last-child]:rotate-90 [&[data-state=open]>svg>path:last-child]:opacity-0",
|
|
248
|
+
props.className
|
|
249
|
+
)}
|
|
250
|
+
{...props}
|
|
251
|
+
>
|
|
252
|
+
<span className='flex items-center gap-4'>
|
|
253
|
+
<span
|
|
254
|
+
className='flex size-10 shrink-0 items-center justify-center rounded-full border'
|
|
255
|
+
aria-hidden='true'
|
|
256
|
+
>
|
|
257
|
+
{Icon && <Icon className='size-4' />}
|
|
258
|
+
</span>
|
|
259
|
+
<span className='flex flex-col space-y-0.5'>
|
|
260
|
+
{children}
|
|
261
|
+
<span className='text-muted-foreground font-normal'>{props.subtitle}</span>
|
|
262
|
+
</span>
|
|
263
|
+
</span>
|
|
264
|
+
<Plus className='text-muted-foreground pointer-events-none size-4 shrink-0 transition-transform duration-200' />
|
|
265
|
+
</AccordionPrimitive.Trigger>
|
|
266
|
+
</AccordionPrimitive.Header>
|
|
267
|
+
)
|
|
268
|
+
|
|
269
|
+
default:
|
|
270
|
+
return (
|
|
271
|
+
<AccordionPrimitive.Header className="flex">
|
|
272
|
+
<AccordionPrimitive.Trigger
|
|
273
|
+
className={cn(accordionTriggerVariants({ variant }), props.className)}
|
|
274
|
+
{...props}
|
|
275
|
+
>
|
|
276
|
+
{children}
|
|
277
|
+
<ChevronDown className="h-4 w-4 shrink-0 transition-transform duration-200" />
|
|
278
|
+
</AccordionPrimitive.Trigger>
|
|
279
|
+
</AccordionPrimitive.Header>
|
|
280
|
+
)
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
export function AccordionXContent({ ...props }: any) {
|
|
285
|
+
const accordionType = React.useContext(AccordionXContext)
|
|
286
|
+
|
|
287
|
+
switch (accordionType) {
|
|
288
|
+
case 'media':
|
|
289
|
+
return (
|
|
290
|
+
<AccordionContent {...props}>
|
|
291
|
+
<div className="space-y-4">
|
|
292
|
+
<p className='text-muted-foreground'>{props.children}</p>
|
|
293
|
+
<img src={media} alt="" className='w-full rounded-md' />
|
|
294
|
+
</div>
|
|
295
|
+
</AccordionContent>
|
|
296
|
+
)
|
|
297
|
+
default:
|
|
298
|
+
return <AccordionContent {...props} />
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
export function AccordionXDemo() {
|
|
303
|
+
const items = [
|
|
304
|
+
{
|
|
305
|
+
title: 'How do I track my order?',
|
|
306
|
+
content: 'You can track your order by logging into your account.',
|
|
307
|
+
name: 'John Doe',
|
|
308
|
+
email: 'john@example.com',
|
|
309
|
+
subtitle: 'Basic Plan',
|
|
310
|
+
avatarImage: 'https://github.com/shadcn.png',
|
|
311
|
+
media: 'https://images.unsplash.com/photo-1618005182384-a83a8bd57fbe?w=800&auto=format&fit=crop'
|
|
312
|
+
},
|
|
313
|
+
{
|
|
314
|
+
title: 'What is your return policy?',
|
|
315
|
+
content: 'We offer a 30-day return policy for most items.',
|
|
316
|
+
name: 'Jane Smith',
|
|
317
|
+
email: 'jane@example.com',
|
|
318
|
+
subtitle: 'Pro Plan',
|
|
319
|
+
avatarImage: 'https://github.com/vercel.png',
|
|
320
|
+
media: 'https://images.unsplash.com/photo-1618556450994-a6a128ef0d9d?w=800&auto=format&fit=crop'
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
title: 'How can I contact customer support?',
|
|
324
|
+
content: 'Our customer support team is available 24/7.',
|
|
325
|
+
name: 'Bob Johnson',
|
|
326
|
+
email: 'bob@example.com',
|
|
327
|
+
subtitle: 'Enterprise Plan',
|
|
328
|
+
avatarImage: 'https://github.com/nextjs.png',
|
|
329
|
+
media: 'https://images.unsplash.com/photo-1618005198919-d3d4b5a92ead?w=800&auto=format&fit=crop'
|
|
330
|
+
}
|
|
331
|
+
]
|
|
332
|
+
|
|
333
|
+
return (
|
|
334
|
+
<div className="space-y-12 p-6 max-w-3xl mx-auto">
|
|
335
|
+
<div>
|
|
336
|
+
<h3 className="text-lg font-semibold mb-4">Default</h3>
|
|
337
|
+
<AccordionX type="single" collapsible defaultValue="item-1">
|
|
338
|
+
{items.map((item, index) => (
|
|
339
|
+
<AccordionXItem key={index} value={`item-${index + 1}`}>
|
|
340
|
+
<AccordionXTrigger>{item.title}</AccordionXTrigger>
|
|
341
|
+
<AccordionXContent>{item.content}</AccordionXContent>
|
|
342
|
+
</AccordionXItem>
|
|
343
|
+
))}
|
|
344
|
+
</AccordionX>
|
|
345
|
+
<TsxSection
|
|
346
|
+
title="AccordionX"
|
|
347
|
+
code={`<AccordionX type="single" collapsible defaultValue="item-1">
|
|
348
|
+
{items.map((item, index) => (
|
|
349
|
+
<AccordionXItem key={index} value={\`item-\${index + 1}\`}>
|
|
350
|
+
<AccordionXTrigger>{item.title}</AccordionXTrigger>
|
|
351
|
+
<AccordionXContent>{item.content}</AccordionXContent>
|
|
352
|
+
</AccordionXItem>
|
|
353
|
+
))}
|
|
354
|
+
</AccordionX>`}
|
|
355
|
+
/>
|
|
356
|
+
</div>
|
|
357
|
+
|
|
358
|
+
<div>
|
|
359
|
+
<h3 className="text-lg font-semibold mb-4">Plus/Minus Icon</h3>
|
|
360
|
+
<AccordionX accordionType="plusMinus" type="single" collapsible defaultValue="item-1">
|
|
361
|
+
{items.map((item, index) => (
|
|
362
|
+
<AccordionXItem key={index} value={`item-${index + 1}`}>
|
|
363
|
+
<AccordionXTrigger>{item.title}</AccordionXTrigger>
|
|
364
|
+
<AccordionXContent>{item.content}</AccordionXContent>
|
|
365
|
+
</AccordionXItem>
|
|
366
|
+
))}
|
|
367
|
+
</AccordionX>
|
|
368
|
+
<TsxSection
|
|
369
|
+
title="AccordionX"
|
|
370
|
+
code={` <AccordionX accordionType="plusMinus" type="single" collapsible defaultValue="item-1">
|
|
371
|
+
{items.map((item, index) => (
|
|
372
|
+
<AccordionXItem key={index} value={\`item-\${index + 1}\`}>
|
|
373
|
+
<AccordionXTrigger>{item.title}</AccordionXTrigger>
|
|
374
|
+
<AccordionXContent>{item.content}</AccordionXContent>
|
|
375
|
+
</AccordionXItem>
|
|
376
|
+
))}
|
|
377
|
+
</AccordionX>`}
|
|
378
|
+
/>
|
|
379
|
+
</div>
|
|
380
|
+
|
|
381
|
+
<div>
|
|
382
|
+
<h3 className="text-lg font-semibold mb-4">Avatar</h3>
|
|
383
|
+
<AccordionX accordionType="avatar" type="single" collapsible defaultValue="item-1">
|
|
384
|
+
{items.map((item, index) => (
|
|
385
|
+
<AccordionXItem key={index} value={`item-${index + 1}`}>
|
|
386
|
+
<AccordionXTrigger name={item.name} email={item.email} avatarImage={item.avatarImage} />
|
|
387
|
+
<AccordionXContent>{item.content}</AccordionXContent>
|
|
388
|
+
</AccordionXItem>
|
|
389
|
+
))}
|
|
390
|
+
</AccordionX>
|
|
391
|
+
<TsxSection
|
|
392
|
+
title="AccordionX"
|
|
393
|
+
code={`<AccordionX accordionType="avatar" type="single" collapsible defaultValue="item-1">
|
|
394
|
+
{items.map((item, index) => (
|
|
395
|
+
<AccordionXItem key={index} value={\`item-\${index + 1}\`}>
|
|
396
|
+
<AccordionXTrigger name={item.name} email={item.email} avatarImage={item.avatarImage} />
|
|
397
|
+
<AccordionXContent>{item.content}</AccordionXContent>
|
|
398
|
+
</AccordionXItem>
|
|
399
|
+
))}
|
|
400
|
+
</AccordionX>`}
|
|
401
|
+
/>
|
|
402
|
+
</div>
|
|
403
|
+
|
|
404
|
+
<div>
|
|
405
|
+
<h3 className="text-lg font-semibold mb-4">Icon with Subtitle</h3>
|
|
406
|
+
<AccordionX accordionType="iconSubtitle" type="single" collapsible defaultValue="item-1">
|
|
407
|
+
{items.map((item, index) => (
|
|
408
|
+
<AccordionXItem key={index} value={`item-${index + 1}`}>
|
|
409
|
+
<AccordionXTrigger subtitle={item.subtitle}>{item.title}</AccordionXTrigger>
|
|
410
|
+
<AccordionXContent>{item.content}</AccordionXContent>
|
|
411
|
+
</AccordionXItem>
|
|
412
|
+
))}
|
|
413
|
+
</AccordionX>
|
|
414
|
+
<TsxSection
|
|
415
|
+
title="AccordionX"
|
|
416
|
+
code={`<AccordionX accordionType="iconSubtitle" type="single" collapsible defaultValue="item-1">
|
|
417
|
+
{items.map((item, index) => (
|
|
418
|
+
<AccordionXItem key={index} value={\`item-\${index + 1}\`}>
|
|
419
|
+
<AccordionXTrigger subtitle={item.subtitle}>{item.title}</AccordionXTrigger>
|
|
420
|
+
<AccordionXContent>{item.content}</AccordionXContent>
|
|
421
|
+
</AccordionXItem>
|
|
422
|
+
))}
|
|
423
|
+
</AccordionX>`}
|
|
424
|
+
/>
|
|
425
|
+
</div>
|
|
426
|
+
</div>
|
|
427
|
+
)
|
|
428
|
+
}
|