@neynar/ui 0.1.1 → 0.1.2
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/dist/components/ui/accordion.d.ts +1 -25
- package/dist/components/ui/accordion.d.ts.map +1 -1
- package/dist/components/ui/alert-dialog.d.ts +240 -46
- package/dist/components/ui/alert-dialog.d.ts.map +1 -1
- package/dist/components/ui/alert.d.ts +73 -11
- package/dist/components/ui/alert.d.ts.map +1 -1
- package/dist/components/ui/aspect-ratio.d.ts +44 -10
- package/dist/components/ui/aspect-ratio.d.ts.map +1 -1
- package/dist/components/ui/avatar.d.ts +117 -33
- package/dist/components/ui/avatar.d.ts.map +1 -1
- package/dist/components/ui/badge.d.ts +50 -71
- package/dist/components/ui/badge.d.ts.map +1 -1
- package/dist/components/ui/breadcrumb.d.ts +231 -49
- package/dist/components/ui/breadcrumb.d.ts.map +1 -1
- package/dist/components/ui/button.d.ts +189 -71
- package/dist/components/ui/button.d.ts.map +1 -1
- package/dist/components/ui/calendar.d.ts +197 -40
- package/dist/components/ui/calendar.d.ts.map +1 -1
- package/dist/components/ui/card.d.ts +7 -22
- package/dist/components/ui/card.d.ts.map +1 -1
- package/dist/components/ui/carousel.d.ts +369 -99
- package/dist/components/ui/carousel.d.ts.map +1 -1
- package/dist/components/ui/chart.d.ts.map +1 -1
- package/dist/components/ui/checkbox.d.ts +110 -38
- package/dist/components/ui/checkbox.d.ts.map +1 -1
- package/dist/components/ui/collapsible.d.ts +246 -61
- package/dist/components/ui/collapsible.d.ts.map +1 -1
- package/dist/components/ui/combobox.d.ts +207 -159
- package/dist/components/ui/combobox.d.ts.map +1 -1
- package/dist/components/ui/command.d.ts +336 -67
- package/dist/components/ui/command.d.ts.map +1 -1
- package/dist/components/ui/container.d.ts +159 -64
- package/dist/components/ui/container.d.ts.map +1 -1
- package/dist/components/ui/context-menu.d.ts +321 -39
- package/dist/components/ui/context-menu.d.ts.map +1 -1
- package/dist/components/ui/date-picker.d.ts +113 -86
- package/dist/components/ui/date-picker.d.ts.map +1 -1
- package/dist/components/ui/dialog.d.ts +106 -25
- package/dist/components/ui/dialog.d.ts.map +1 -1
- package/dist/components/ui/drawer.d.ts +388 -59
- package/dist/components/ui/drawer.d.ts.map +1 -1
- package/dist/components/ui/dropdown-menu.d.ts +521 -74
- package/dist/components/ui/dropdown-menu.d.ts.map +1 -1
- package/dist/components/ui/empty-state.d.ts +148 -76
- package/dist/components/ui/empty-state.d.ts.map +1 -1
- package/dist/components/ui/hover-card.d.ts +253 -34
- package/dist/components/ui/hover-card.d.ts.map +1 -1
- package/dist/components/ui/input.d.ts +143 -44
- package/dist/components/ui/input.d.ts.map +1 -1
- package/dist/components/ui/label.d.ts +0 -8
- package/dist/components/ui/label.d.ts.map +1 -1
- package/dist/components/ui/menubar.d.ts +288 -46
- package/dist/components/ui/menubar.d.ts.map +1 -1
- package/dist/components/ui/navigation-menu.d.ts +444 -127
- package/dist/components/ui/navigation-menu.d.ts.map +1 -1
- package/dist/components/ui/pagination.d.ts +342 -66
- package/dist/components/ui/pagination.d.ts.map +1 -1
- package/dist/components/ui/popover.d.ts +0 -8
- package/dist/components/ui/popover.d.ts.map +1 -1
- package/dist/components/ui/progress.d.ts +88 -30
- package/dist/components/ui/progress.d.ts.map +1 -1
- package/dist/components/ui/radio-group.d.ts +189 -45
- package/dist/components/ui/radio-group.d.ts.map +1 -1
- package/dist/components/ui/resizable.d.ts +178 -62
- package/dist/components/ui/resizable.d.ts.map +1 -1
- package/dist/components/ui/scroll-area.d.ts +180 -21
- package/dist/components/ui/scroll-area.d.ts.map +1 -1
- package/dist/components/ui/select.d.ts +382 -60
- package/dist/components/ui/select.d.ts.map +1 -1
- package/dist/components/ui/separator.d.ts +52 -39
- package/dist/components/ui/separator.d.ts.map +1 -1
- package/dist/components/ui/sheet.d.ts +144 -27
- package/dist/components/ui/sheet.d.ts.map +1 -1
- package/dist/components/ui/sidebar.d.ts +81 -31
- package/dist/components/ui/sidebar.d.ts.map +1 -1
- package/dist/components/ui/skeleton.d.ts +94 -32
- package/dist/components/ui/skeleton.d.ts.map +1 -1
- package/dist/components/ui/slider.d.ts +37 -31
- package/dist/components/ui/slider.d.ts.map +1 -1
- package/dist/components/ui/sonner.d.ts +280 -46
- package/dist/components/ui/sonner.d.ts.map +1 -1
- package/dist/components/ui/stack.d.ts +289 -148
- package/dist/components/ui/stack.d.ts.map +1 -1
- package/dist/components/ui/stories/aspect-ratio.stories.d.ts +1 -2
- package/dist/components/ui/stories/aspect-ratio.stories.d.ts.map +1 -1
- package/dist/components/ui/stories/container.stories.d.ts +2 -3
- package/dist/components/ui/stories/container.stories.d.ts.map +1 -1
- package/dist/components/ui/stories/empty-state.stories.d.ts +2 -2
- package/dist/components/ui/stories/scroll-area.stories.d.ts +1 -2
- package/dist/components/ui/stories/scroll-area.stories.d.ts.map +1 -1
- package/dist/components/ui/stories/stack.stories.d.ts +1 -1
- package/dist/components/ui/stories/text-field.stories.d.ts +7 -1
- package/dist/components/ui/stories/text-field.stories.d.ts.map +1 -1
- package/dist/components/ui/switch.d.ts +44 -38
- package/dist/components/ui/switch.d.ts.map +1 -1
- package/dist/components/ui/table.d.ts +33 -0
- package/dist/components/ui/table.d.ts.map +1 -1
- package/dist/components/ui/tabs.d.ts +4 -22
- package/dist/components/ui/tabs.d.ts.map +1 -1
- package/dist/components/ui/text-field.d.ts +170 -84
- package/dist/components/ui/text-field.d.ts.map +1 -1
- package/dist/components/ui/textarea.d.ts +106 -29
- package/dist/components/ui/textarea.d.ts.map +1 -1
- package/dist/components/ui/theme-toggle.d.ts +190 -65
- package/dist/components/ui/theme-toggle.d.ts.map +1 -1
- package/dist/components/ui/theme.d.ts +107 -23
- package/dist/components/ui/theme.d.ts.map +1 -1
- package/dist/components/ui/toggle-group.d.ts +143 -67
- package/dist/components/ui/toggle-group.d.ts.map +1 -1
- package/dist/components/ui/toggle.d.ts +118 -30
- package/dist/components/ui/toggle.d.ts.map +1 -1
- package/dist/components/ui/tooltip.d.ts +152 -28
- package/dist/components/ui/tooltip.d.ts.map +1 -1
- package/dist/components/ui/typography.d.ts +452 -134
- package/dist/components/ui/typography.d.ts.map +1 -1
- package/dist/index.js +9388 -8281
- package/dist/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/llms.txt +173 -3
- package/package.json +5 -2
- package/src/components/ui/accordion.tsx +112 -27
- package/src/components/ui/alert-dialog.tsx +401 -46
- package/src/components/ui/alert.tsx +114 -11
- package/src/components/ui/aspect-ratio.tsx +69 -14
- package/src/components/ui/avatar.tsx +179 -33
- package/src/components/ui/badge.tsx +74 -75
- package/src/components/ui/breadcrumb.tsx +335 -50
- package/src/components/ui/button.tsx +198 -90
- package/src/components/ui/calendar.tsx +867 -43
- package/src/components/ui/card.tsx +140 -33
- package/src/components/ui/carousel.tsx +529 -98
- package/src/components/ui/chart.tsx +222 -1
- package/src/components/ui/checkbox.tsx +176 -38
- package/src/components/ui/collapsible.tsx +321 -67
- package/src/components/ui/combobox.tsx +284 -83
- package/src/components/ui/command.tsx +527 -67
- package/src/components/ui/container.tsx +217 -65
- package/src/components/ui/context-menu.tsx +716 -51
- package/src/components/ui/date-picker.tsx +228 -38
- package/src/components/ui/dialog.tsx +270 -33
- package/src/components/ui/drawer.tsx +546 -67
- package/src/components/ui/dropdown-menu.tsx +657 -74
- package/src/components/ui/empty-state.tsx +241 -82
- package/src/components/ui/hover-card.tsx +328 -39
- package/src/components/ui/input.tsx +207 -44
- package/src/components/ui/label.tsx +98 -8
- package/src/components/ui/menubar.tsx +587 -54
- package/src/components/ui/navigation-menu.tsx +557 -128
- package/src/components/ui/pagination.tsx +561 -79
- package/src/components/ui/popover.tsx +119 -8
- package/src/components/ui/progress.tsx +131 -29
- package/src/components/ui/radio-group.tsx +260 -51
- package/src/components/ui/resizable.tsx +289 -63
- package/src/components/ui/scroll-area.tsx +377 -66
- package/src/components/ui/select.tsx +545 -60
- package/src/components/ui/separator.tsx +146 -40
- package/src/components/ui/sheet.tsx +348 -31
- package/src/components/ui/sidebar.tsx +471 -29
- package/src/components/ui/skeleton.tsx +114 -32
- package/src/components/ui/slider.tsx +77 -31
- package/src/components/ui/sonner.tsx +574 -46
- package/src/components/ui/stack.tsx +423 -101
- package/src/components/ui/switch.tsx +78 -39
- package/src/components/ui/table.tsx +170 -4
- package/src/components/ui/tabs.tsx +108 -22
- package/src/components/ui/text-field.tsx +226 -81
- package/src/components/ui/textarea.tsx +180 -29
- package/src/components/ui/theme-toggle.tsx +313 -65
- package/src/components/ui/theme.tsx +117 -23
- package/src/components/ui/toggle-group.tsx +280 -69
- package/src/components/ui/toggle.tsx +124 -35
- package/src/components/ui/tooltip.tsx +239 -29
- package/src/components/ui/typography.tsx +1115 -165
|
@@ -1,29 +1,105 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import * as CollapsiblePrimitive from "@radix-ui/react-collapsible";
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Props for Collapsible root container (Documentation only - NOT used in component implementation)
|
|
6
|
+
* These types are for documentation generation and should not replace Radix inferred types
|
|
7
|
+
*/
|
|
8
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
9
|
+
type CollapsibleDocsProps = {
|
|
10
|
+
/**
|
|
11
|
+
* Change the default rendered element for the one passed as a child, merging their props and behavior.
|
|
12
|
+
* @default false
|
|
13
|
+
*/
|
|
14
|
+
asChild?: boolean;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The open state of the collapsible when it is initially rendered. Use when you do not need to control its open state.
|
|
18
|
+
* @default undefined
|
|
19
|
+
*/
|
|
20
|
+
defaultOpen?: boolean;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* The controlled open state of the collapsible. Must be used in conjunction with onOpenChange.
|
|
24
|
+
* @default undefined
|
|
25
|
+
*/
|
|
26
|
+
open?: boolean;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Event handler called when the open state of the collapsible changes.
|
|
30
|
+
* @param open - The new open state
|
|
31
|
+
*/
|
|
32
|
+
onOpenChange?: (open: boolean) => void;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* When true, prevents the user from interacting with the collapsible.
|
|
36
|
+
* @default undefined
|
|
37
|
+
*/
|
|
38
|
+
disabled?: boolean;
|
|
39
|
+
} & React.ComponentProps<"div">;
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Props for CollapsibleTrigger (Documentation only - NOT used in component implementation)
|
|
43
|
+
* These types are for documentation generation and should not replace Radix inferred types
|
|
44
|
+
*/
|
|
45
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
46
|
+
type CollapsibleTriggerDocsProps = {
|
|
47
|
+
/**
|
|
48
|
+
* Change the default rendered element for the one passed as a child, merging their props and behavior.
|
|
49
|
+
* @default false
|
|
50
|
+
*/
|
|
51
|
+
asChild?: boolean;
|
|
52
|
+
} & React.ComponentProps<"button">;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Props for CollapsibleContent (Documentation only - NOT used in component implementation)
|
|
56
|
+
* These types are for documentation generation and should not replace Radix inferred types
|
|
57
|
+
*/
|
|
58
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
59
|
+
type CollapsibleContentDocsProps = {
|
|
60
|
+
/**
|
|
61
|
+
* Change the default rendered element for the one passed as a child, merging their props and behavior.
|
|
62
|
+
* @default false
|
|
63
|
+
*/
|
|
64
|
+
asChild?: boolean;
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Used to force mounting when more control is needed. Useful when controlling animation with React animation libraries.
|
|
68
|
+
* @default undefined
|
|
69
|
+
*/
|
|
70
|
+
forceMount?: boolean;
|
|
71
|
+
} & React.ComponentProps<"div">;
|
|
72
|
+
|
|
4
73
|
/**
|
|
5
74
|
* An interactive component which expands/collapses a panel
|
|
6
75
|
*
|
|
7
|
-
* A flexible container component built on Radix UI primitives that allows users to
|
|
76
|
+
* A flexible container component built on Radix UI Collapsible primitives that allows users to
|
|
8
77
|
* toggle the visibility of content sections. Unlike Accordion, Collapsible provides
|
|
9
|
-
* more flexibility without enforcing specific visual structures
|
|
10
|
-
* expandable details, settings panels,
|
|
78
|
+
* more flexibility without enforcing specific visual structures or mutual exclusivity.
|
|
79
|
+
* Perfect for FAQ sections, expandable details, settings panels, sidebar navigation,
|
|
80
|
+
* and any content that should be conditionally visible.
|
|
81
|
+
*
|
|
82
|
+
* Built on `@radix-ui/react-collapsible` with enhanced TypeScript support and
|
|
83
|
+
* comprehensive prop documentation.
|
|
11
84
|
*
|
|
12
85
|
* @component
|
|
13
86
|
* @example
|
|
14
87
|
* ```tsx
|
|
15
|
-
* // Basic controlled collapsible
|
|
88
|
+
* // Basic controlled collapsible with state management
|
|
16
89
|
* const [isOpen, setIsOpen] = React.useState(false)
|
|
17
90
|
*
|
|
18
91
|
* <Collapsible open={isOpen} onOpenChange={setIsOpen}>
|
|
19
92
|
* <CollapsibleTrigger asChild>
|
|
20
|
-
* <Button variant="outline">
|
|
93
|
+
* <Button variant="outline" className="w-full justify-between">
|
|
21
94
|
* Can I use this in my project?
|
|
22
|
-
* <ChevronDown className=
|
|
95
|
+
* <ChevronDown className={cn(
|
|
96
|
+
* "h-4 w-4 transition-transform duration-200",
|
|
97
|
+
* isOpen && "rotate-180"
|
|
98
|
+
* )} />
|
|
23
99
|
* </Button>
|
|
24
100
|
* </CollapsibleTrigger>
|
|
25
|
-
* <CollapsibleContent>
|
|
26
|
-
* <div className="p-4 border rounded-md bg-muted/50">
|
|
101
|
+
* <CollapsibleContent className="overflow-hidden data-[state=closed]:animate-collapsible-up data-[state=open]:animate-collapsible-down">
|
|
102
|
+
* <div className="p-4 border rounded-md bg-muted/50 mt-2">
|
|
27
103
|
* Yes. Free to use for personal and commercial projects.
|
|
28
104
|
* No attribution required.
|
|
29
105
|
* </div>
|
|
@@ -33,14 +109,14 @@ import * as CollapsiblePrimitive from "@radix-ui/react-collapsible";
|
|
|
33
109
|
*
|
|
34
110
|
* @example
|
|
35
111
|
* ```tsx
|
|
36
|
-
* // Uncontrolled collapsible with
|
|
37
|
-
* <Collapsible className="w-full space-y-2">
|
|
112
|
+
* // Uncontrolled collapsible with default state
|
|
113
|
+
* <Collapsible defaultOpen={true} className="w-full space-y-2">
|
|
38
114
|
* <div className="flex items-center justify-between">
|
|
39
115
|
* <h4 className="text-sm font-semibold">@radix-ui/primitives</h4>
|
|
40
116
|
* <CollapsibleTrigger asChild>
|
|
41
117
|
* <Button variant="ghost" size="sm">
|
|
42
|
-
* <ChevronDown className="h-4 w-4" />
|
|
43
|
-
* <span className="sr-only">Toggle</span>
|
|
118
|
+
* <ChevronDown className="h-4 w-4 transition-transform duration-200 group-data-[state=open]/collapsible:rotate-180" />
|
|
119
|
+
* <span className="sr-only">Toggle package list</span>
|
|
44
120
|
* </Button>
|
|
45
121
|
* </CollapsibleTrigger>
|
|
46
122
|
* </div>
|
|
@@ -48,41 +124,75 @@ import * as CollapsiblePrimitive from "@radix-ui/react-collapsible";
|
|
|
48
124
|
* <div className="rounded-md border px-4 py-2 text-sm shadow-sm">
|
|
49
125
|
* @radix-ui/react-collapsible
|
|
50
126
|
* </div>
|
|
127
|
+
* <div className="rounded-md border px-4 py-2 text-sm shadow-sm">
|
|
128
|
+
* @radix-ui/react-accordion
|
|
129
|
+
* </div>
|
|
51
130
|
* </CollapsibleContent>
|
|
52
131
|
* </Collapsible>
|
|
53
132
|
* ```
|
|
54
133
|
*
|
|
55
134
|
* @example
|
|
56
135
|
* ```tsx
|
|
57
|
-
* // FAQ-style implementation
|
|
58
|
-
* <Collapsible>
|
|
59
|
-
* <CollapsibleTrigger className="flex w-full items-center justify-between py-4 text-sm font-medium transition-all hover:underline">
|
|
136
|
+
* // FAQ-style implementation with custom animations
|
|
137
|
+
* <Collapsible className="group" data-orientation="vertical">
|
|
138
|
+
* <CollapsibleTrigger className="flex w-full items-center justify-between py-4 text-sm font-medium transition-all hover:underline focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring">
|
|
60
139
|
* How do I get started?
|
|
61
|
-
* <ChevronDown className="h-4 w-4 shrink-0 transition-transform duration-200" />
|
|
140
|
+
* <ChevronDown className="h-4 w-4 shrink-0 transition-transform duration-200 group-data-[state=open]:rotate-180" />
|
|
62
141
|
* </CollapsibleTrigger>
|
|
63
|
-
* <CollapsibleContent className="overflow-hidden text-sm transition-all">
|
|
142
|
+
* <CollapsibleContent className="overflow-hidden text-sm transition-all data-[state=closed]:animate-collapsible-up data-[state=open]:animate-collapsible-down">
|
|
64
143
|
* <div className="pb-4 pt-0">
|
|
65
|
-
* Getting started is easy! Simply follow our quick setup guide
|
|
144
|
+
* Getting started is easy! Simply follow our quick setup guide,
|
|
145
|
+
* install the required dependencies, and begin building your application.
|
|
146
|
+
* Check out our documentation for detailed instructions.
|
|
147
|
+
* </div>
|
|
148
|
+
* </CollapsibleContent>
|
|
149
|
+
* </Collapsible>
|
|
150
|
+
* ```
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```tsx
|
|
154
|
+
* // Disabled collapsible state
|
|
155
|
+
* <Collapsible disabled className="opacity-50 cursor-not-allowed">
|
|
156
|
+
* <CollapsibleTrigger className="flex w-full items-center justify-between py-4 text-sm font-medium">
|
|
157
|
+
* This section is temporarily unavailable
|
|
158
|
+
* <ChevronDown className="h-4 w-4" />
|
|
159
|
+
* </CollapsibleTrigger>
|
|
160
|
+
* <CollapsibleContent>
|
|
161
|
+
* <div className="pb-4 pt-0 text-sm text-muted-foreground">
|
|
162
|
+
* This content is currently disabled and cannot be accessed.
|
|
66
163
|
* </div>
|
|
67
164
|
* </CollapsibleContent>
|
|
68
165
|
* </Collapsible>
|
|
69
166
|
* ```
|
|
70
167
|
*
|
|
71
168
|
* @accessibility
|
|
72
|
-
* -
|
|
73
|
-
* - ARIA expanded state
|
|
74
|
-
* -
|
|
75
|
-
* - Focus
|
|
76
|
-
* -
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
169
|
+
* - **Keyboard Navigation**: Space and Enter keys toggle the collapsed state
|
|
170
|
+
* - **ARIA States**: `aria-expanded` automatically reflects current state (true/false)
|
|
171
|
+
* - **ARIA Controls**: `aria-controls` automatically connects trigger to content panel
|
|
172
|
+
* - **Focus Management**: Proper focus handling and focus-visible indicators
|
|
173
|
+
* - **Screen Reader Support**: Content properly hidden/announced based on state
|
|
174
|
+
* - **Disabled States**: Supports disabled prop with appropriate ARIA attributes
|
|
175
|
+
* - **Role Management**: Trigger has `button` role, content has proper labeling
|
|
176
|
+
* - **State Announcements**: State changes properly announced to assistive technology
|
|
177
|
+
*
|
|
178
|
+
* **Data Attributes for Styling:**
|
|
179
|
+
* - `[data-state="open"|"closed"]` - Reflects current expanded state
|
|
180
|
+
* - `[data-disabled]` - Present when disabled prop is true
|
|
181
|
+
*
|
|
182
|
+
* **CSS Variables for Animation:**
|
|
183
|
+
* - `--radix-collapsible-content-width` - Natural width of content
|
|
184
|
+
* - `--radix-collapsible-content-height` - Natural height of content for smooth animations
|
|
185
|
+
*
|
|
186
|
+
* @see {@link https://www.radix-ui.com/primitives/docs/components/collapsible} Radix UI Collapsible Documentation
|
|
187
|
+
* @see {@link https://ui.shadcn.com/docs/components/collapsible} shadcn/ui Design Patterns
|
|
188
|
+
* @see {@link CollapsibleTrigger} Interactive button element to toggle visibility
|
|
189
|
+
* @see {@link CollapsibleContent} Content container with automatic height animations
|
|
190
|
+
* @see {@link https://www.w3.org/WAI/ARIA/apg/patterns/disclosure/} WAI-ARIA Disclosure Pattern
|
|
81
191
|
* @since 1.0.0
|
|
82
192
|
*/
|
|
83
|
-
function Collapsible(
|
|
84
|
-
|
|
85
|
-
|
|
193
|
+
function Collapsible(
|
|
194
|
+
props: React.ComponentProps<typeof CollapsiblePrimitive.Root>,
|
|
195
|
+
) {
|
|
86
196
|
return <CollapsiblePrimitive.Root data-slot="collapsible" {...props} />;
|
|
87
197
|
}
|
|
88
198
|
|
|
@@ -90,50 +200,98 @@ function Collapsible({
|
|
|
90
200
|
* Interactive trigger element that toggles collapsible content visibility
|
|
91
201
|
*
|
|
92
202
|
* The clickable element that controls the expanded/collapsed state of the associated
|
|
93
|
-
* CollapsibleContent.
|
|
94
|
-
*
|
|
203
|
+
* CollapsibleContent. Built on Radix UI CollapsibleTrigger primitive with automatic
|
|
204
|
+
* ARIA management and keyboard support. Supports the asChild prop for composition
|
|
205
|
+
* with custom button components or other interactive elements.
|
|
206
|
+
*
|
|
207
|
+
* **Key Features:**
|
|
208
|
+
* - Automatic `aria-expanded` state management
|
|
209
|
+
* - Built-in keyboard navigation (Space/Enter)
|
|
210
|
+
* - Flexible composition via `asChild` pattern
|
|
211
|
+
* - Seamless integration with any interactive element
|
|
95
212
|
*
|
|
96
213
|
* @component
|
|
97
214
|
* @example
|
|
98
215
|
* ```tsx
|
|
99
|
-
* // Simple text trigger
|
|
100
|
-
* <CollapsibleTrigger>
|
|
216
|
+
* // Simple text trigger with default button styling
|
|
217
|
+
* <CollapsibleTrigger className="font-medium hover:underline">
|
|
101
218
|
* Can I use this in my project?
|
|
102
219
|
* </CollapsibleTrigger>
|
|
103
220
|
* ```
|
|
104
221
|
*
|
|
105
222
|
* @example
|
|
106
223
|
* ```tsx
|
|
107
|
-
* // Composed with Button component
|
|
224
|
+
* // Composed with Button component for consistent styling
|
|
108
225
|
* <CollapsibleTrigger asChild>
|
|
109
226
|
* <Button variant="outline" className="w-full justify-between">
|
|
110
227
|
* Advanced Settings
|
|
111
|
-
* <ChevronDown className="h-4 w-4" />
|
|
228
|
+
* <ChevronDown className="h-4 w-4 transition-transform duration-200 group-data-[state=open]:rotate-180" />
|
|
112
229
|
* </Button>
|
|
113
230
|
* </CollapsibleTrigger>
|
|
114
231
|
* ```
|
|
115
232
|
*
|
|
116
233
|
* @example
|
|
117
234
|
* ```tsx
|
|
118
|
-
* // Custom styled trigger
|
|
119
|
-
* <CollapsibleTrigger className="flex w-full items-center justify-between py-4 text-left text-sm font-medium transition-all hover:underline">
|
|
235
|
+
* // Custom styled trigger with icon animation
|
|
236
|
+
* <CollapsibleTrigger className="flex w-full items-center justify-between py-4 text-left text-sm font-medium transition-all hover:underline focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring">
|
|
120
237
|
* How does it work?
|
|
121
|
-
* <ChevronDown className="h-4 w-4 shrink-0 transition-transform duration-200" />
|
|
238
|
+
* <ChevronDown className="h-4 w-4 shrink-0 transition-transform duration-200 data-[state=open]:rotate-180" />
|
|
239
|
+
* </CollapsibleTrigger>
|
|
240
|
+
* ```
|
|
241
|
+
*
|
|
242
|
+
* @example
|
|
243
|
+
* ```tsx
|
|
244
|
+
* // Trigger composed with icon button
|
|
245
|
+
* <CollapsibleTrigger asChild>
|
|
246
|
+
* <Button variant="ghost" size="sm" className="h-8 w-8 p-0">
|
|
247
|
+
* <MoreHorizontal className="h-4 w-4" />
|
|
248
|
+
* <span className="sr-only">Toggle options</span>
|
|
249
|
+
* </Button>
|
|
250
|
+
* </CollapsibleTrigger>
|
|
251
|
+
* ```
|
|
252
|
+
*
|
|
253
|
+
* @example
|
|
254
|
+
* ```tsx
|
|
255
|
+
* // Trigger with custom element using asChild
|
|
256
|
+
* <CollapsibleTrigger asChild>
|
|
257
|
+
* <div
|
|
258
|
+
* role="button"
|
|
259
|
+
* tabIndex={0}
|
|
260
|
+
* className="flex items-center gap-2 p-2 rounded cursor-pointer hover:bg-accent"
|
|
261
|
+
* >
|
|
262
|
+
* <FolderIcon className="h-4 w-4" />
|
|
263
|
+
* <span>Project Files</span>
|
|
264
|
+
* <ChevronRight className="h-3 w-3 transition-transform data-[state=open]:rotate-90" />
|
|
265
|
+
* </div>
|
|
122
266
|
* </CollapsibleTrigger>
|
|
123
267
|
* ```
|
|
124
268
|
*
|
|
125
269
|
* @accessibility
|
|
126
|
-
* - Keyboard
|
|
127
|
-
* - aria-expanded attribute reflects current
|
|
128
|
-
* - aria-controls connects trigger to its content panel
|
|
129
|
-
* - Role
|
|
130
|
-
* - Focus
|
|
270
|
+
* - **Keyboard Navigation**: Space and Enter keys activate the trigger
|
|
271
|
+
* - **ARIA Expanded**: `aria-expanded` attribute automatically reflects current state (true/false)
|
|
272
|
+
* - **ARIA Controls**: `aria-controls` automatically connects trigger to its content panel ID
|
|
273
|
+
* - **Role Management**: Has `button` role for screen reader compatibility
|
|
274
|
+
* - **Focus Management**: Proper focus handling with focus-visible indicators
|
|
275
|
+
* - **Disabled State**: When parent Collapsible is disabled, trigger becomes non-interactive
|
|
276
|
+
* - **Screen Reader Announcements**: State changes properly announced to assistive technology
|
|
277
|
+
*
|
|
278
|
+
* **Data Attributes:**
|
|
279
|
+
* - `[data-state="open"|"closed"]` - Reflects current expanded state for styling
|
|
280
|
+
* - `[data-disabled]` - Present when the trigger is disabled
|
|
131
281
|
*
|
|
282
|
+
* @param asChild - When true, merges props onto immediate child instead of rendering button
|
|
283
|
+
* @param className - Additional CSS classes for styling
|
|
284
|
+
* @param onClick - Custom click handler (called after internal toggle logic)
|
|
285
|
+
* @param onKeyDown - Custom keyboard handler (Space/Enter keys handled internally)
|
|
286
|
+
*
|
|
287
|
+
* @see {@link https://www.radix-ui.com/primitives/docs/components/collapsible#trigger} Radix UI CollapsibleTrigger API
|
|
288
|
+
* @see {@link Collapsible} Parent container component
|
|
289
|
+
* @see {@link CollapsibleContent} Content container that this trigger controls
|
|
132
290
|
* @since 1.0.0
|
|
133
291
|
*/
|
|
134
|
-
function CollapsibleTrigger(
|
|
135
|
-
|
|
136
|
-
|
|
292
|
+
function CollapsibleTrigger(
|
|
293
|
+
props: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleTrigger>,
|
|
294
|
+
) {
|
|
137
295
|
return (
|
|
138
296
|
<CollapsiblePrimitive.CollapsibleTrigger
|
|
139
297
|
data-slot="collapsible-trigger"
|
|
@@ -146,15 +304,23 @@ function CollapsibleTrigger({
|
|
|
146
304
|
* Content container that can be expanded or collapsed
|
|
147
305
|
*
|
|
148
306
|
* The panel containing content that is shown or hidden based on the collapsible state.
|
|
149
|
-
*
|
|
150
|
-
* when toggling between expanded
|
|
307
|
+
* Built on Radix UI CollapsibleContent primitive with automatic height animations,
|
|
308
|
+
* accessibility attributes, and smooth transitions when toggling between expanded
|
|
309
|
+
* and collapsed states.
|
|
310
|
+
*
|
|
311
|
+
* **Key Features:**
|
|
312
|
+
* - Automatic height animations using CSS variables
|
|
313
|
+
* - Proper accessibility tree management (hidden when collapsed)
|
|
314
|
+
* - CSS data attributes for custom styling and animations
|
|
315
|
+
* - Support for forceMount to keep content in DOM when collapsed
|
|
316
|
+
* - Seamless composition via asChild pattern
|
|
151
317
|
*
|
|
152
318
|
* @component
|
|
153
319
|
* @example
|
|
154
320
|
* ```tsx
|
|
155
|
-
* // Basic content panel
|
|
156
|
-
* <CollapsibleContent>
|
|
157
|
-
* <div className="rounded-md border px-4 py-2 text-sm">
|
|
321
|
+
* // Basic content panel with simple styling
|
|
322
|
+
* <CollapsibleContent className="pt-2">
|
|
323
|
+
* <div className="rounded-md border px-4 py-2 text-sm bg-muted/50">
|
|
158
324
|
* Yes. Free to use for personal and commercial projects.
|
|
159
325
|
* No attribution required.
|
|
160
326
|
* </div>
|
|
@@ -163,12 +329,15 @@ function CollapsibleTrigger({
|
|
|
163
329
|
*
|
|
164
330
|
* @example
|
|
165
331
|
* ```tsx
|
|
166
|
-
* // Content with
|
|
167
|
-
* <CollapsibleContent className="space-y-2">
|
|
168
|
-
* <div className="rounded-md border px-4 py-3 font-mono text-sm">
|
|
332
|
+
* // Content with multiple elements and spacing
|
|
333
|
+
* <CollapsibleContent className="space-y-2 pt-2">
|
|
334
|
+
* <div className="rounded-md border px-4 py-3 font-mono text-sm shadow-sm">
|
|
169
335
|
* @radix-ui/react-collapsible
|
|
170
336
|
* </div>
|
|
171
|
-
* <div className="rounded-md border px-4 py-3 font-mono text-sm">
|
|
337
|
+
* <div className="rounded-md border px-4 py-3 font-mono text-sm shadow-sm">
|
|
338
|
+
* @radix-ui/react-accordion
|
|
339
|
+
* </div>
|
|
340
|
+
* <div className="rounded-md border px-4 py-3 font-mono text-sm shadow-sm">
|
|
172
341
|
* @radix-ui/react-dialog
|
|
173
342
|
* </div>
|
|
174
343
|
* </CollapsibleContent>
|
|
@@ -176,26 +345,111 @@ function CollapsibleTrigger({
|
|
|
176
345
|
*
|
|
177
346
|
* @example
|
|
178
347
|
* ```tsx
|
|
179
|
-
* // Content with
|
|
348
|
+
* // Content with custom animations using CSS variables
|
|
180
349
|
* <CollapsibleContent className="overflow-hidden text-sm transition-all data-[state=closed]:animate-collapsible-up data-[state=open]:animate-collapsible-down">
|
|
181
|
-
* <div className="pb-4 pt-0">
|
|
182
|
-
* Content with
|
|
350
|
+
* <div className="pb-4 pt-0 px-1">
|
|
351
|
+
* Content with smooth height animations. The CSS variables
|
|
352
|
+
* --radix-collapsible-content-height and --radix-collapsible-content-width
|
|
353
|
+
* are available for custom animation implementations.
|
|
354
|
+
* </div>
|
|
355
|
+
* </CollapsibleContent>
|
|
356
|
+
* ```
|
|
357
|
+
*
|
|
358
|
+
* @example
|
|
359
|
+
* ```tsx
|
|
360
|
+
* // Force mounted content (stays in DOM when collapsed)
|
|
361
|
+
* <CollapsibleContent forceMount className="data-[state=closed]:hidden">
|
|
362
|
+
* <div className="p-4 text-sm">
|
|
363
|
+
* This content remains in the DOM even when collapsed,
|
|
364
|
+
* useful for maintaining form state or for SSR consistency.
|
|
365
|
+
* </div>
|
|
366
|
+
* </CollapsibleContent>
|
|
367
|
+
* ```
|
|
368
|
+
*
|
|
369
|
+
* @example
|
|
370
|
+
* ```tsx
|
|
371
|
+
* // Content with asChild composition
|
|
372
|
+
* <CollapsibleContent asChild>
|
|
373
|
+
* <motion.div
|
|
374
|
+
* initial={{ height: 0 }}
|
|
375
|
+
* animate={{ height: "auto" }}
|
|
376
|
+
* exit={{ height: 0 }}
|
|
377
|
+
* className="overflow-hidden"
|
|
378
|
+
* >
|
|
379
|
+
* <div className="p-4">
|
|
380
|
+
* Content with custom Framer Motion animations
|
|
381
|
+
* </div>
|
|
382
|
+
* </motion.div>
|
|
383
|
+
* </CollapsibleContent>
|
|
384
|
+
* ```
|
|
385
|
+
*
|
|
386
|
+
* @example
|
|
387
|
+
* ```tsx
|
|
388
|
+
* // Content with complex nested structure
|
|
389
|
+
* <CollapsibleContent className="overflow-hidden">
|
|
390
|
+
* <div className="border-t pt-4 mt-2">
|
|
391
|
+
* <div className="grid grid-cols-2 gap-4">
|
|
392
|
+
* <div className="space-y-2">
|
|
393
|
+
* <h4 className="font-medium">Documentation</h4>
|
|
394
|
+
* <ul className="text-sm space-y-1 text-muted-foreground">
|
|
395
|
+
* <li>Getting Started</li>
|
|
396
|
+
* <li>Installation</li>
|
|
397
|
+
* <li>Configuration</li>
|
|
398
|
+
* </ul>
|
|
399
|
+
* </div>
|
|
400
|
+
* <div className="space-y-2">
|
|
401
|
+
* <h4 className="font-medium">Examples</h4>
|
|
402
|
+
* <ul className="text-sm space-y-1 text-muted-foreground">
|
|
403
|
+
* <li>Basic Usage</li>
|
|
404
|
+
* <li>Advanced Patterns</li>
|
|
405
|
+
* <li>Custom Styling</li>
|
|
406
|
+
* </ul>
|
|
407
|
+
* </div>
|
|
408
|
+
* </div>
|
|
183
409
|
* </div>
|
|
184
410
|
* </CollapsibleContent>
|
|
185
411
|
* ```
|
|
186
412
|
*
|
|
187
413
|
* @accessibility
|
|
188
|
-
* - Automatically hidden from accessibility tree when collapsed
|
|
189
|
-
* -
|
|
190
|
-
* -
|
|
191
|
-
* -
|
|
192
|
-
* -
|
|
414
|
+
* - **Screen Reader Management**: Automatically hidden from accessibility tree when collapsed
|
|
415
|
+
* - **ARIA Association**: Properly associated with trigger via `aria-controls` relationship
|
|
416
|
+
* - **Content Announcements**: Content changes announced by screen readers when expanded
|
|
417
|
+
* - **Height Animations**: Smooth height transitions with CSS variables for natural motion
|
|
418
|
+
* - **Focus Management**: Focus properly managed when content becomes visible/hidden
|
|
419
|
+
* - **Disabled State**: Content appropriately disabled when parent Collapsible is disabled
|
|
420
|
+
*
|
|
421
|
+
* **Data Attributes for Styling:**
|
|
422
|
+
* - `[data-state="open"|"closed"]` - Reflects current expanded state
|
|
423
|
+
* - `[data-disabled]` - Present when the parent collapsible is disabled
|
|
424
|
+
*
|
|
425
|
+
* **CSS Variables for Animation:**
|
|
426
|
+
* - `--radix-collapsible-content-width` - The natural width of the content
|
|
427
|
+
* - `--radix-collapsible-content-height` - The natural height for smooth animations
|
|
428
|
+
*
|
|
429
|
+
* **Animation Classes:**
|
|
430
|
+
* Use data-state attributes to apply conditional animations:
|
|
431
|
+
* ```css
|
|
432
|
+
* .CollapsibleContent[data-state="open"] {
|
|
433
|
+
* animation: slideDown 300ms ease-out;
|
|
434
|
+
* }
|
|
435
|
+
* .CollapsibleContent[data-state="closed"] {
|
|
436
|
+
* animation: slideUp 300ms ease-out;
|
|
437
|
+
* }
|
|
438
|
+
* ```
|
|
439
|
+
*
|
|
440
|
+
* @param asChild - When true, merges props onto immediate child instead of rendering div
|
|
441
|
+
* @param forceMount - When true, forces content to stay in DOM even when collapsed
|
|
442
|
+
* @param className - Additional CSS classes for styling and animations
|
|
443
|
+
* @param children - The content to be shown/hidden
|
|
193
444
|
*
|
|
445
|
+
* @see {@link https://www.radix-ui.com/primitives/docs/components/collapsible#content} Radix UI CollapsibleContent API
|
|
446
|
+
* @see {@link Collapsible} Parent container component
|
|
447
|
+
* @see {@link CollapsibleTrigger} Trigger component that controls this content
|
|
194
448
|
* @since 1.0.0
|
|
195
449
|
*/
|
|
196
|
-
function CollapsibleContent(
|
|
197
|
-
|
|
198
|
-
|
|
450
|
+
function CollapsibleContent(
|
|
451
|
+
props: React.ComponentProps<typeof CollapsiblePrimitive.CollapsibleContent>,
|
|
452
|
+
) {
|
|
199
453
|
return (
|
|
200
454
|
<CollapsiblePrimitive.CollapsibleContent
|
|
201
455
|
data-slot="collapsible-content"
|