@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
|
@@ -4,16 +4,166 @@ import { Drawer as DrawerPrimitive } from "vaul";
|
|
|
4
4
|
import { cn } from "@/lib/utils";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* Drawer component
|
|
7
|
+
* Props for the root Drawer component (Documentation only - NOT used in component implementation)
|
|
8
|
+
* These types are for documentation generation and should not replace Vaul inferred types
|
|
9
|
+
*/
|
|
10
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
11
|
+
type DrawerDocsProps = {
|
|
12
|
+
/** Initial open state when not controlling the drawer @default false */
|
|
13
|
+
defaultOpen?: boolean;
|
|
14
|
+
/** Controlled open state - when provided, drawer becomes controlled */
|
|
15
|
+
open?: boolean;
|
|
16
|
+
/** Callback fired when the drawer open state changes */
|
|
17
|
+
onOpenChange?: (open: boolean) => void;
|
|
18
|
+
/** Whether the drawer should be modal, preventing interaction with background elements @default true */
|
|
19
|
+
modal?: boolean;
|
|
20
|
+
/** Container element to portal the drawer into @default document.body */
|
|
21
|
+
container?: HTMLElement;
|
|
22
|
+
/** Direction from which the drawer slides in @default "bottom" */
|
|
23
|
+
direction?: "top" | "bottom" | "left" | "right";
|
|
24
|
+
/** Callback fired after open or close animation completes */
|
|
25
|
+
onAnimationEnd?: (open: boolean) => void;
|
|
26
|
+
/** Whether the drawer can be dismissed via drag gestures or outside clicks @default true */
|
|
27
|
+
dismissible?: boolean;
|
|
28
|
+
/** When true, only the handle area can be used for dragging @default false */
|
|
29
|
+
handleOnly?: boolean;
|
|
30
|
+
/** Whether to automatically reposition input elements when drawer opens @default true */
|
|
31
|
+
repositionInputs?: boolean;
|
|
32
|
+
/** Array of snap points as percentages (0-100) or pixel values for drawer height */
|
|
33
|
+
snapPoints?: (number | string)[];
|
|
34
|
+
/** Controlled active snap point index */
|
|
35
|
+
activeSnapPoint?: number;
|
|
36
|
+
/** Callback to handle snap point changes */
|
|
37
|
+
setActiveSnapPoint?: (snapPoint: number) => void;
|
|
38
|
+
/** Index at which overlay starts fading when using snap points */
|
|
39
|
+
fadeFromIndex?: number;
|
|
40
|
+
/** Disables velocity-based snap point skipping, ensuring sequential navigation @default false */
|
|
41
|
+
snapToSequentialPoint?: boolean;
|
|
42
|
+
/** Children components to render within the drawer context */
|
|
43
|
+
children?: React.ReactNode;
|
|
44
|
+
} & React.ComponentProps<typeof DrawerPrimitive.Root>;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Props for DrawerTrigger component (Documentation only - NOT used in component implementation)
|
|
48
|
+
* These types are for documentation generation and should not replace Vaul inferred types
|
|
49
|
+
*/
|
|
50
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
51
|
+
type DrawerTriggerDocsProps = {
|
|
52
|
+
/** Render as a child element instead of the default button @default false */
|
|
53
|
+
asChild?: boolean;
|
|
54
|
+
/** Content to render as the trigger */
|
|
55
|
+
children?: React.ReactNode;
|
|
56
|
+
} & React.ComponentProps<typeof DrawerPrimitive.Trigger>;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Props for DrawerPortal component (Documentation only - NOT used in component implementation)
|
|
60
|
+
* These types are for documentation generation and should not replace Vaul inferred types
|
|
61
|
+
*/
|
|
62
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
63
|
+
type DrawerPortalDocsProps = {
|
|
64
|
+
/** Container element to render the portal into @default document.body */
|
|
65
|
+
container?: HTMLElement;
|
|
66
|
+
/** Content to render in the portal */
|
|
67
|
+
children?: React.ReactNode;
|
|
68
|
+
} & React.ComponentProps<typeof DrawerPrimitive.Portal>;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Props for DrawerClose component (Documentation only - NOT used in component implementation)
|
|
72
|
+
* These types are for documentation generation and should not replace Vaul inferred types
|
|
73
|
+
*/
|
|
74
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
75
|
+
type DrawerCloseDocsProps = {
|
|
76
|
+
/** Render as a child element instead of the default button @default false */
|
|
77
|
+
asChild?: boolean;
|
|
78
|
+
/** Content to render as the close trigger */
|
|
79
|
+
children?: React.ReactNode;
|
|
80
|
+
} & React.ComponentProps<typeof DrawerPrimitive.Close>;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Props for DrawerOverlay component (Documentation only - NOT used in component implementation)
|
|
84
|
+
* These types are for documentation generation and should not replace Vaul inferred types
|
|
85
|
+
*/
|
|
86
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
87
|
+
type DrawerOverlayDocsProps = {
|
|
88
|
+
/** Additional CSS classes to apply to the overlay */
|
|
89
|
+
className?: string;
|
|
90
|
+
} & React.ComponentProps<typeof DrawerPrimitive.Overlay>;
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Props for DrawerContent component (Documentation only - NOT used in component implementation)
|
|
94
|
+
* These types are for documentation generation and should not replace Vaul inferred types
|
|
95
|
+
*/
|
|
96
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
97
|
+
type DrawerContentDocsProps = {
|
|
98
|
+
/** Additional CSS classes to apply to the content container */
|
|
99
|
+
className?: string;
|
|
100
|
+
/** Content to render inside the drawer */
|
|
101
|
+
children?: React.ReactNode;
|
|
102
|
+
} & React.ComponentProps<typeof DrawerPrimitive.Content>;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Props for DrawerHeader component (Documentation only - NOT used in component implementation)
|
|
106
|
+
* These types are for documentation generation and should not replace HTML div attributes
|
|
107
|
+
*/
|
|
108
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
109
|
+
type DrawerHeaderDocsProps = {
|
|
110
|
+
/** Additional CSS classes to apply to the header */
|
|
111
|
+
className?: string;
|
|
112
|
+
/** Header content, typically DrawerTitle and DrawerDescription */
|
|
113
|
+
children?: React.ReactNode;
|
|
114
|
+
} & React.HTMLAttributes<HTMLDivElement>;
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Props for DrawerFooter component (Documentation only - NOT used in component implementation)
|
|
118
|
+
* These types are for documentation generation and should not replace HTML div attributes
|
|
119
|
+
*/
|
|
120
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
121
|
+
type DrawerFooterDocsProps = {
|
|
122
|
+
/** Additional CSS classes to apply to the footer */
|
|
123
|
+
className?: string;
|
|
124
|
+
/** Footer content, typically action buttons and DrawerClose */
|
|
125
|
+
children?: React.ReactNode;
|
|
126
|
+
} & React.HTMLAttributes<HTMLDivElement>;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Props for DrawerTitle component (Documentation only - NOT used in component implementation)
|
|
130
|
+
* These types are for documentation generation and should not replace Vaul inferred types
|
|
131
|
+
*/
|
|
132
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
133
|
+
type DrawerTitleDocsProps = {
|
|
134
|
+
/** Additional CSS classes to apply to the title */
|
|
135
|
+
className?: string;
|
|
136
|
+
/** Title text content */
|
|
137
|
+
children?: React.ReactNode;
|
|
138
|
+
} & React.ComponentProps<typeof DrawerPrimitive.Title>;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Props for DrawerDescription component (Documentation only - NOT used in component implementation)
|
|
142
|
+
* These types are for documentation generation and should not replace Vaul inferred types
|
|
143
|
+
*/
|
|
144
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
145
|
+
type DrawerDescriptionDocsProps = {
|
|
146
|
+
/** Additional CSS classes to apply to the description */
|
|
147
|
+
className?: string;
|
|
148
|
+
/** Description text content */
|
|
149
|
+
children?: React.ReactNode;
|
|
150
|
+
} & React.ComponentProps<typeof DrawerPrimitive.Description>;
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Drawer - Mobile-optimized sliding panel component
|
|
8
154
|
*
|
|
9
155
|
* A flexible drawer component built on Vaul that creates sliding panel interfaces
|
|
10
156
|
* from screen edges. Designed primarily for mobile experiences with touch gestures,
|
|
11
157
|
* swipe-to-dismiss functionality, and natural drag interactions. Supports multiple
|
|
12
|
-
* directions (top, bottom, left, right) and responsive behavior
|
|
158
|
+
* directions (top, bottom, left, right) with snap points and responsive behavior.
|
|
159
|
+
*
|
|
160
|
+
* Built on Vaul library which provides excellent performance, accessibility, and
|
|
161
|
+
* natural touch interactions. The drawer automatically handles focus management,
|
|
162
|
+
* scroll locking, and ARIA attributes for screen readers.
|
|
13
163
|
*
|
|
14
164
|
* @example
|
|
15
165
|
* ```tsx
|
|
16
|
-
* // Basic
|
|
166
|
+
* // Basic drawer with trigger and content
|
|
17
167
|
* <Drawer>
|
|
18
168
|
* <DrawerTrigger asChild>
|
|
19
169
|
* <Button>Open Settings</Button>
|
|
@@ -26,7 +176,7 @@ import { cn } from "@/lib/utils";
|
|
|
26
176
|
* </DrawerDescription>
|
|
27
177
|
* </DrawerHeader>
|
|
28
178
|
* <div className="p-4">
|
|
29
|
-
* Content goes here
|
|
179
|
+
* <p>Content goes here</p>
|
|
30
180
|
* </div>
|
|
31
181
|
* <DrawerFooter>
|
|
32
182
|
* <Button>Save</Button>
|
|
@@ -55,73 +205,209 @@ import { cn } from "@/lib/utils";
|
|
|
55
205
|
* </Drawer>
|
|
56
206
|
* ```
|
|
57
207
|
*
|
|
208
|
+
* @example
|
|
209
|
+
* ```tsx
|
|
210
|
+
* // Drawer with snap points for multiple heights
|
|
211
|
+
* <Drawer snapPoints={[0.4, 0.8]} fadeFromIndex={0}>
|
|
212
|
+
* <DrawerTrigger asChild>
|
|
213
|
+
* <Button>Open with Snap Points</Button>
|
|
214
|
+
* </DrawerTrigger>
|
|
215
|
+
* <DrawerContent>
|
|
216
|
+
* <DrawerHeader>
|
|
217
|
+
* <DrawerTitle>Expandable Drawer</DrawerTitle>
|
|
218
|
+
* <DrawerDescription>
|
|
219
|
+
* Drag to resize between 40% and 80% heights
|
|
220
|
+
* </DrawerDescription>
|
|
221
|
+
* </DrawerHeader>
|
|
222
|
+
* <div className="flex-1 p-4">
|
|
223
|
+
* <p>Content that can be viewed at different heights</p>
|
|
224
|
+
* </div>
|
|
225
|
+
* </DrawerContent>
|
|
226
|
+
* </Drawer>
|
|
227
|
+
* ```
|
|
228
|
+
*
|
|
229
|
+
* @example
|
|
230
|
+
* ```tsx
|
|
231
|
+
* // Side drawer from left or right
|
|
232
|
+
* <Drawer direction="right">
|
|
233
|
+
* <DrawerTrigger asChild>
|
|
234
|
+
* <Button>Open Side Panel</Button>
|
|
235
|
+
* </DrawerTrigger>
|
|
236
|
+
* <DrawerContent>
|
|
237
|
+
* <DrawerHeader>
|
|
238
|
+
* <DrawerTitle>Side Navigation</DrawerTitle>
|
|
239
|
+
* </DrawerHeader>
|
|
240
|
+
* <div className="flex-1 p-4">
|
|
241
|
+
* <nav>Navigation items here</nav>
|
|
242
|
+
* </div>
|
|
243
|
+
* </DrawerContent>
|
|
244
|
+
* </Drawer>
|
|
245
|
+
* ```
|
|
246
|
+
*
|
|
58
247
|
* @accessibility
|
|
59
|
-
* - Focus management with focus trap when open
|
|
60
|
-
* - Keyboard navigation with Escape to close
|
|
248
|
+
* - Focus management with focus trap when drawer is open
|
|
249
|
+
* - Keyboard navigation with Escape key to close
|
|
61
250
|
* - Screen reader announcements for state changes
|
|
62
|
-
* - Touch gestures for swipe-to-dismiss
|
|
63
|
-
* - Backdrop click to close
|
|
64
|
-
* - ARIA attributes for modal behavior
|
|
65
|
-
* - Scroll lock
|
|
251
|
+
* - Touch gestures for intuitive swipe-to-dismiss
|
|
252
|
+
* - Backdrop click to close (when dismissible)
|
|
253
|
+
* - ARIA attributes for proper modal behavior
|
|
254
|
+
* - Scroll lock prevents background scrolling
|
|
255
|
+
* - DrawerTitle required for accessibility
|
|
256
|
+
* - Sequential keyboard navigation within drawer content
|
|
66
257
|
*
|
|
258
|
+
* @see {@link https://vaul.emilkowal.ski} Vaul drawer library documentation
|
|
67
259
|
* @see {@link https://ui.shadcn.com/docs/components/drawer} shadcn/ui Drawer documentation
|
|
68
|
-
* @since 1.0.0
|
|
69
260
|
* @see {@link Dialog} For modal overlays without slide animation
|
|
70
261
|
* @see {@link Sheet} For desktop-optimized side panels
|
|
262
|
+
* @since 1.0.0
|
|
71
263
|
*/
|
|
72
|
-
|
|
73
|
-
* Root drawer component that manages the drawer state and context
|
|
74
|
-
*
|
|
75
|
-
* @param props - All props from Vaul's Drawer.Root component
|
|
76
|
-
* @param props.open - Whether the drawer is open (controlled mode)
|
|
77
|
-
* @param props.onOpenChange - Callback when drawer open state changes
|
|
78
|
-
* @param props.direction - Direction from which drawer slides ("bottom" | "top" | "left" | "right")
|
|
79
|
-
* @param props.modal - Whether drawer should be modal (default: true)
|
|
80
|
-
* @param props.dismissible - Whether drawer can be dismissed by dragging (default: true)
|
|
81
|
-
*/
|
|
82
|
-
function Drawer({
|
|
83
|
-
...props
|
|
84
|
-
}: React.ComponentProps<typeof DrawerPrimitive.Root>) {
|
|
264
|
+
function Drawer(props: React.ComponentProps<typeof DrawerPrimitive.Root>) {
|
|
85
265
|
return <DrawerPrimitive.Root data-slot="drawer" {...props} />;
|
|
86
266
|
}
|
|
87
267
|
|
|
88
268
|
/**
|
|
89
|
-
*
|
|
269
|
+
* DrawerTrigger - Interactive element that opens the drawer
|
|
270
|
+
*
|
|
271
|
+
* The trigger element that users interact with to open the drawer. By default
|
|
272
|
+
* renders as a button, but can be composed with other elements using asChild.
|
|
273
|
+
* Supports all standard button attributes and event handlers.
|
|
274
|
+
*
|
|
275
|
+
* @example
|
|
276
|
+
* ```tsx
|
|
277
|
+
* // Default button trigger
|
|
278
|
+
* <DrawerTrigger>Open Drawer</DrawerTrigger>
|
|
279
|
+
* ```
|
|
280
|
+
*
|
|
281
|
+
* @example
|
|
282
|
+
* ```tsx
|
|
283
|
+
* // Composed with custom button component
|
|
284
|
+
* <DrawerTrigger asChild>
|
|
285
|
+
* <Button variant="outline">Open Settings</Button>
|
|
286
|
+
* </DrawerTrigger>
|
|
287
|
+
* ```
|
|
90
288
|
*
|
|
91
|
-
* @
|
|
289
|
+
* @accessibility
|
|
290
|
+
* - Announces drawer state to screen readers
|
|
291
|
+
* - Receives keyboard focus
|
|
292
|
+
* - Activates on Space and Enter keys
|
|
293
|
+
*
|
|
294
|
+
* @see {@link https://vaul.emilkowal.ski/api} Vaul Trigger API
|
|
92
295
|
*/
|
|
93
|
-
function DrawerTrigger(
|
|
94
|
-
|
|
95
|
-
|
|
296
|
+
function DrawerTrigger(
|
|
297
|
+
props: React.ComponentProps<typeof DrawerPrimitive.Trigger>,
|
|
298
|
+
) {
|
|
96
299
|
return <DrawerPrimitive.Trigger data-slot="drawer-trigger" {...props} />;
|
|
97
300
|
}
|
|
98
301
|
|
|
99
302
|
/**
|
|
100
|
-
* Portal component for rendering drawer
|
|
303
|
+
* DrawerPortal - Portal component for rendering drawer outside DOM hierarchy
|
|
304
|
+
*
|
|
305
|
+
* Renders the drawer content into a different part of the DOM tree, typically
|
|
306
|
+
* document.body, to ensure proper stacking context and avoid z-index issues.
|
|
307
|
+
* Automatically used by DrawerContent but can be used manually for custom layouts.
|
|
308
|
+
*
|
|
309
|
+
* @example
|
|
310
|
+
* ```tsx
|
|
311
|
+
* // Custom portal container
|
|
312
|
+
* const portalContainer = document.getElementById('drawer-root')
|
|
313
|
+
*
|
|
314
|
+
* <DrawerPortal container={portalContainer}>
|
|
315
|
+
* <DrawerOverlay />
|
|
316
|
+
* <DrawerContent>
|
|
317
|
+
* Drawer content
|
|
318
|
+
* </DrawerContent>
|
|
319
|
+
* </DrawerPortal>
|
|
320
|
+
* ```
|
|
101
321
|
*
|
|
102
|
-
* @
|
|
322
|
+
* @accessibility
|
|
323
|
+
* - Maintains proper focus management across portal boundaries
|
|
324
|
+
* - Preserves screen reader navigation context
|
|
325
|
+
*
|
|
326
|
+
* @see {@link https://vaul.emilkowal.ski/api} Vaul Portal API
|
|
103
327
|
*/
|
|
104
|
-
function DrawerPortal(
|
|
105
|
-
|
|
106
|
-
|
|
328
|
+
function DrawerPortal(
|
|
329
|
+
props: React.ComponentProps<typeof DrawerPrimitive.Portal>,
|
|
330
|
+
) {
|
|
107
331
|
return <DrawerPrimitive.Portal data-slot="drawer-portal" {...props} />;
|
|
108
332
|
}
|
|
109
333
|
|
|
110
334
|
/**
|
|
111
|
-
*
|
|
335
|
+
* DrawerClose - Interactive element that closes the drawer
|
|
336
|
+
*
|
|
337
|
+
* Trigger element that closes the drawer when activated. Can be placed anywhere
|
|
338
|
+
* within the drawer content. By default renders as a button but can be composed
|
|
339
|
+
* with other elements using asChild. Multiple close triggers can exist within
|
|
340
|
+
* a single drawer.
|
|
341
|
+
*
|
|
342
|
+
* @example
|
|
343
|
+
* ```tsx
|
|
344
|
+
* // Default close button
|
|
345
|
+
* <DrawerClose>Close</DrawerClose>
|
|
346
|
+
* ```
|
|
347
|
+
*
|
|
348
|
+
* @example
|
|
349
|
+
* ```tsx
|
|
350
|
+
* // Composed with custom button
|
|
351
|
+
* <DrawerClose asChild>
|
|
352
|
+
* <Button variant="ghost">Cancel</Button>
|
|
353
|
+
* </DrawerClose>
|
|
354
|
+
* ```
|
|
112
355
|
*
|
|
113
|
-
* @
|
|
356
|
+
* @example
|
|
357
|
+
* ```tsx
|
|
358
|
+
* // Icon-only close button
|
|
359
|
+
* <DrawerClose asChild>
|
|
360
|
+
* <Button size="icon" variant="ghost">
|
|
361
|
+
* <X className="h-4 w-4" />
|
|
362
|
+
* </Button>
|
|
363
|
+
* </DrawerClose>
|
|
364
|
+
* ```
|
|
365
|
+
*
|
|
366
|
+
* @accessibility
|
|
367
|
+
* - Receives keyboard focus
|
|
368
|
+
* - Activates on Space and Enter keys
|
|
369
|
+
* - Announces close action to screen readers
|
|
370
|
+
*
|
|
371
|
+
* @see {@link https://vaul.emilkowal.ski/api} Vaul Close API
|
|
114
372
|
*/
|
|
115
|
-
function DrawerClose(
|
|
116
|
-
|
|
117
|
-
|
|
373
|
+
function DrawerClose(
|
|
374
|
+
props: React.ComponentProps<typeof DrawerPrimitive.Close>,
|
|
375
|
+
) {
|
|
118
376
|
return <DrawerPrimitive.Close data-slot="drawer-close" {...props} />;
|
|
119
377
|
}
|
|
120
378
|
|
|
121
379
|
/**
|
|
122
|
-
*
|
|
380
|
+
* DrawerOverlay - Semi-transparent backdrop behind the drawer
|
|
381
|
+
*
|
|
382
|
+
* Creates a semi-transparent overlay that covers the entire viewport behind
|
|
383
|
+
* the drawer content. Provides visual separation and can be clicked to close
|
|
384
|
+
* the drawer (when dismissible is true). Automatically fades in/out with
|
|
385
|
+
* smooth animations.
|
|
386
|
+
*
|
|
387
|
+
* @example
|
|
388
|
+
* ```tsx
|
|
389
|
+
* // Default overlay with standard opacity
|
|
390
|
+
* <DrawerOverlay />
|
|
391
|
+
* ```
|
|
123
392
|
*
|
|
124
|
-
* @
|
|
393
|
+
* @example
|
|
394
|
+
* ```tsx
|
|
395
|
+
* // Custom overlay with different opacity
|
|
396
|
+
* <DrawerOverlay className="bg-black/30" />
|
|
397
|
+
* ```
|
|
398
|
+
*
|
|
399
|
+
* @example
|
|
400
|
+
* ```tsx
|
|
401
|
+
* // Overlay with blur effect
|
|
402
|
+
* <DrawerOverlay className="bg-black/20 backdrop-blur-sm" />
|
|
403
|
+
* ```
|
|
404
|
+
*
|
|
405
|
+
* @accessibility
|
|
406
|
+
* - Click target for closing drawer (when dismissible)
|
|
407
|
+
* - Prevents interaction with background content
|
|
408
|
+
* - Does not interfere with screen reader navigation
|
|
409
|
+
*
|
|
410
|
+
* @see {@link https://vaul.emilkowal.ski/api} Vaul Overlay API
|
|
125
411
|
*/
|
|
126
412
|
function DrawerOverlay({
|
|
127
413
|
className,
|
|
@@ -140,16 +426,52 @@ function DrawerOverlay({
|
|
|
140
426
|
}
|
|
141
427
|
|
|
142
428
|
/**
|
|
143
|
-
* Main
|
|
429
|
+
* DrawerContent - Main container for drawer content with responsive positioning
|
|
430
|
+
*
|
|
431
|
+
* The primary content container that holds all drawer elements. Automatically
|
|
432
|
+
* handles portal rendering, overlay display, and responsive positioning based
|
|
433
|
+
* on the drawer direction. Includes a drag handle for bottom drawers and
|
|
434
|
+
* responsive styling for all four directions.
|
|
144
435
|
*
|
|
145
|
-
*
|
|
146
|
-
*
|
|
147
|
-
*
|
|
148
|
-
* - left: Slides in from left edge
|
|
149
|
-
* - right: Slides in from right edge
|
|
436
|
+
* Supports flexible layouts with proper spacing for headers, content areas,
|
|
437
|
+
* and footers. Automatically constrains height/width based on direction and
|
|
438
|
+
* viewport size.
|
|
150
439
|
*
|
|
151
|
-
* @
|
|
152
|
-
*
|
|
440
|
+
* @example
|
|
441
|
+
* ```tsx
|
|
442
|
+
* // Basic content structure
|
|
443
|
+
* <DrawerContent>
|
|
444
|
+
* <DrawerHeader>
|
|
445
|
+
* <DrawerTitle>Title</DrawerTitle>
|
|
446
|
+
* <DrawerDescription>Description</DrawerDescription>
|
|
447
|
+
* </DrawerHeader>
|
|
448
|
+
* <div className="p-4">
|
|
449
|
+
* Main content area
|
|
450
|
+
* </div>
|
|
451
|
+
* <DrawerFooter>
|
|
452
|
+
* <Button>Action</Button>
|
|
453
|
+
* </DrawerFooter>
|
|
454
|
+
* </DrawerContent>
|
|
455
|
+
* ```
|
|
456
|
+
*
|
|
457
|
+
* @example
|
|
458
|
+
* ```tsx
|
|
459
|
+
* // Custom styled content
|
|
460
|
+
* <DrawerContent className="max-w-md mx-auto">
|
|
461
|
+
* <div className="flex-1 overflow-y-auto p-6">
|
|
462
|
+
* <h2>Custom Layout</h2>
|
|
463
|
+
* <p>Scrollable content area</p>
|
|
464
|
+
* </div>
|
|
465
|
+
* </DrawerContent>
|
|
466
|
+
* ```
|
|
467
|
+
*
|
|
468
|
+
* @accessibility
|
|
469
|
+
* - Focus trap keeps focus within drawer content
|
|
470
|
+
* - Proper ARIA modal attributes
|
|
471
|
+
* - Sequential keyboard navigation
|
|
472
|
+
* - Screen reader content announcements
|
|
473
|
+
*
|
|
474
|
+
* @see {@link https://vaul.emilkowal.ski/api} Vaul Content API
|
|
153
475
|
*/
|
|
154
476
|
function DrawerContent({
|
|
155
477
|
className,
|
|
@@ -179,14 +501,56 @@ function DrawerContent({
|
|
|
179
501
|
}
|
|
180
502
|
|
|
181
503
|
/**
|
|
182
|
-
* Header section
|
|
504
|
+
* DrawerHeader - Header section containing title and description
|
|
183
505
|
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
506
|
+
* Standardized header area for drawer content with proper spacing and responsive
|
|
507
|
+
* text alignment. Centers text for bottom/top drawers on mobile and left-aligns
|
|
508
|
+
* on larger screens. Should contain DrawerTitle and optionally DrawerDescription
|
|
509
|
+
* for accessibility compliance.
|
|
510
|
+
*
|
|
511
|
+
* @example
|
|
512
|
+
* ```tsx
|
|
513
|
+
* // Standard header with title and description
|
|
514
|
+
* <DrawerHeader>
|
|
515
|
+
* <DrawerTitle>Settings</DrawerTitle>
|
|
516
|
+
* <DrawerDescription>
|
|
517
|
+
* Manage your account preferences and settings
|
|
518
|
+
* </DrawerDescription>
|
|
519
|
+
* </DrawerHeader>
|
|
520
|
+
* ```
|
|
521
|
+
*
|
|
522
|
+
* @example
|
|
523
|
+
* ```tsx
|
|
524
|
+
* // Title-only header
|
|
525
|
+
* <DrawerHeader>
|
|
526
|
+
* <DrawerTitle>Notifications</DrawerTitle>
|
|
527
|
+
* </DrawerHeader>
|
|
528
|
+
* ```
|
|
529
|
+
*
|
|
530
|
+
* @example
|
|
531
|
+
* ```tsx
|
|
532
|
+
* // Custom header with additional content
|
|
533
|
+
* <DrawerHeader className="border-b">
|
|
534
|
+
* <DrawerTitle>Profile</DrawerTitle>
|
|
535
|
+
* <DrawerDescription>Update your profile information</DrawerDescription>
|
|
536
|
+
* <div className="mt-2">
|
|
537
|
+
* <Badge variant="outline">Pro User</Badge>
|
|
538
|
+
* </div>
|
|
539
|
+
* </DrawerHeader>
|
|
540
|
+
* ```
|
|
541
|
+
*
|
|
542
|
+
* @accessibility
|
|
543
|
+
* - Should contain DrawerTitle for screen reader identification
|
|
544
|
+
* - Optional DrawerDescription provides additional context
|
|
545
|
+
* - Proper heading hierarchy maintained
|
|
186
546
|
*
|
|
187
|
-
* @
|
|
547
|
+
* @see {@link DrawerTitle} For accessible drawer titles
|
|
548
|
+
* @see {@link DrawerDescription} For additional context
|
|
188
549
|
*/
|
|
189
|
-
function DrawerHeader({
|
|
550
|
+
function DrawerHeader({
|
|
551
|
+
className,
|
|
552
|
+
...props
|
|
553
|
+
}: React.HTMLAttributes<HTMLDivElement>) {
|
|
190
554
|
return (
|
|
191
555
|
<div
|
|
192
556
|
data-slot="drawer-header"
|
|
@@ -200,14 +564,63 @@ function DrawerHeader({ className, ...props }: React.ComponentProps<"div">) {
|
|
|
200
564
|
}
|
|
201
565
|
|
|
202
566
|
/**
|
|
203
|
-
* Footer section
|
|
567
|
+
* DrawerFooter - Footer section for action buttons and controls
|
|
568
|
+
*
|
|
569
|
+
* Standardized footer area positioned at the bottom of the drawer with automatic
|
|
570
|
+
* top margin to push content down. Typically contains primary actions, secondary
|
|
571
|
+
* actions, and DrawerClose triggers. Uses flexbox column layout with consistent
|
|
572
|
+
* spacing between elements.
|
|
573
|
+
*
|
|
574
|
+
* @example
|
|
575
|
+
* ```tsx
|
|
576
|
+
* // Standard footer with primary and secondary actions
|
|
577
|
+
* <DrawerFooter>
|
|
578
|
+
* <Button>Save Changes</Button>
|
|
579
|
+
* <DrawerClose asChild>
|
|
580
|
+
* <Button variant="outline">Cancel</Button>
|
|
581
|
+
* </DrawerClose>
|
|
582
|
+
* </DrawerFooter>
|
|
583
|
+
* ```
|
|
204
584
|
*
|
|
205
|
-
*
|
|
206
|
-
*
|
|
585
|
+
* @example
|
|
586
|
+
* ```tsx
|
|
587
|
+
* // Footer with multiple action groups
|
|
588
|
+
* <DrawerFooter>
|
|
589
|
+
* <div className="flex gap-2">
|
|
590
|
+
* <Button className="flex-1">Save</Button>
|
|
591
|
+
* <Button variant="outline" className="flex-1">Save as Draft</Button>
|
|
592
|
+
* </div>
|
|
593
|
+
* <DrawerClose asChild>
|
|
594
|
+
* <Button variant="ghost" size="sm">Cancel</Button>
|
|
595
|
+
* </DrawerClose>
|
|
596
|
+
* </DrawerFooter>
|
|
597
|
+
* ```
|
|
207
598
|
*
|
|
208
|
-
* @
|
|
599
|
+
* @example
|
|
600
|
+
* ```tsx
|
|
601
|
+
* // Footer with text and actions
|
|
602
|
+
* <DrawerFooter>
|
|
603
|
+
* <p className="text-sm text-muted-foreground text-center">
|
|
604
|
+
* Changes will be saved automatically
|
|
605
|
+
* </p>
|
|
606
|
+
* <DrawerClose asChild>
|
|
607
|
+
* <Button>Done</Button>
|
|
608
|
+
* </DrawerClose>
|
|
609
|
+
* </DrawerFooter>
|
|
610
|
+
* ```
|
|
611
|
+
*
|
|
612
|
+
* @accessibility
|
|
613
|
+
* - Action buttons receive proper focus order
|
|
614
|
+
* - Primary actions should be visually prominent
|
|
615
|
+
* - Close actions clearly labeled for screen readers
|
|
616
|
+
*
|
|
617
|
+
* @see {@link DrawerClose} For close action triggers
|
|
618
|
+
* @see {@link Button} For consistent action button styling
|
|
209
619
|
*/
|
|
210
|
-
function DrawerFooter({
|
|
620
|
+
function DrawerFooter({
|
|
621
|
+
className,
|
|
622
|
+
...props
|
|
623
|
+
}: React.HTMLAttributes<HTMLDivElement>) {
|
|
211
624
|
return (
|
|
212
625
|
<div
|
|
213
626
|
data-slot="drawer-footer"
|
|
@@ -218,12 +631,44 @@ function DrawerFooter({ className, ...props }: React.ComponentProps<"div">) {
|
|
|
218
631
|
}
|
|
219
632
|
|
|
220
633
|
/**
|
|
221
|
-
* Accessible title element for the drawer
|
|
634
|
+
* DrawerTitle - Accessible title element for the drawer
|
|
635
|
+
*
|
|
636
|
+
* Required accessibility element that announces the drawer's purpose to screen
|
|
637
|
+
* readers and provides a clear heading for the content. Should be included in
|
|
638
|
+
* every drawer for proper accessibility compliance. Automatically styled with
|
|
639
|
+
* appropriate font weight and color.
|
|
640
|
+
*
|
|
641
|
+
* @example
|
|
642
|
+
* ```tsx
|
|
643
|
+
* // Standard drawer title
|
|
644
|
+
* <DrawerTitle>Account Settings</DrawerTitle>
|
|
645
|
+
* ```
|
|
222
646
|
*
|
|
223
|
-
*
|
|
224
|
-
*
|
|
647
|
+
* @example
|
|
648
|
+
* ```tsx
|
|
649
|
+
* // Custom styled title
|
|
650
|
+
* <DrawerTitle className="text-lg font-bold text-primary">
|
|
651
|
+
* Welcome Back!
|
|
652
|
+
* </DrawerTitle>
|
|
653
|
+
* ```
|
|
654
|
+
*
|
|
655
|
+
* @example
|
|
656
|
+
* ```tsx
|
|
657
|
+
* // Title with dynamic content
|
|
658
|
+
* <DrawerTitle>
|
|
659
|
+
* {isEditing ? "Edit Profile" : "View Profile"}
|
|
660
|
+
* </DrawerTitle>
|
|
661
|
+
* ```
|
|
662
|
+
*
|
|
663
|
+
* @accessibility
|
|
664
|
+
* - REQUIRED for screen reader accessibility
|
|
665
|
+
* - Announces drawer content purpose
|
|
666
|
+
* - Provides semantic heading structure
|
|
667
|
+
* - Should be descriptive and concise
|
|
668
|
+
* - Automatically receives proper ARIA attributes
|
|
225
669
|
*
|
|
226
|
-
* @
|
|
670
|
+
* @see {@link https://vaul.emilkowal.ski/api} Vaul Title API
|
|
671
|
+
* @see {@link DrawerDescription} For additional context
|
|
227
672
|
*/
|
|
228
673
|
function DrawerTitle({
|
|
229
674
|
className,
|
|
@@ -239,12 +684,46 @@ function DrawerTitle({
|
|
|
239
684
|
}
|
|
240
685
|
|
|
241
686
|
/**
|
|
242
|
-
* Optional description
|
|
687
|
+
* DrawerDescription - Optional description providing additional context
|
|
243
688
|
*
|
|
244
|
-
*
|
|
245
|
-
*
|
|
689
|
+
* Supplementary text element that provides additional information about the
|
|
690
|
+
* drawer's content, purpose, or instructions. Enhances accessibility by giving
|
|
691
|
+
* users more context about what they'll find in the drawer. Styled with muted
|
|
692
|
+
* colors and smaller text to maintain visual hierarchy.
|
|
693
|
+
*
|
|
694
|
+
* @example
|
|
695
|
+
* ```tsx
|
|
696
|
+
* // Basic description
|
|
697
|
+
* <DrawerDescription>
|
|
698
|
+
* Manage your account preferences and privacy settings
|
|
699
|
+
* </DrawerDescription>
|
|
700
|
+
* ```
|
|
701
|
+
*
|
|
702
|
+
* @example
|
|
703
|
+
* ```tsx
|
|
704
|
+
* // Description with instructions
|
|
705
|
+
* <DrawerDescription>
|
|
706
|
+
* Select the options below to customize your experience.
|
|
707
|
+
* Changes will be saved automatically.
|
|
708
|
+
* </DrawerDescription>
|
|
709
|
+
* ```
|
|
710
|
+
*
|
|
711
|
+
* @example
|
|
712
|
+
* ```tsx
|
|
713
|
+
* // Custom styled description
|
|
714
|
+
* <DrawerDescription className="text-xs text-orange-600">
|
|
715
|
+
* Warning: These changes cannot be undone
|
|
716
|
+
* </DrawerDescription>
|
|
717
|
+
* ```
|
|
718
|
+
*
|
|
719
|
+
* @accessibility
|
|
720
|
+
* - Provides additional context for screen readers
|
|
721
|
+
* - Automatically linked to DrawerTitle via ARIA
|
|
722
|
+
* - Should be concise and informative
|
|
723
|
+
* - Enhances understanding of drawer purpose
|
|
246
724
|
*
|
|
247
|
-
* @
|
|
725
|
+
* @see {@link https://vaul.emilkowal.ski/api} Vaul Description API
|
|
726
|
+
* @see {@link DrawerTitle} For primary drawer identification
|
|
248
727
|
*/
|
|
249
728
|
function DrawerDescription({
|
|
250
729
|
className,
|