@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,17 +1,233 @@
|
|
|
1
1
|
import { useTheme } from "@/hooks/use-theme";
|
|
2
2
|
import { Toaster as Sonner, type ToasterProps, toast } from "sonner";
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* Props for Toaster (Documentation only - NOT used in component implementation)
|
|
6
|
+
* These types are for documentation generation and should not replace sonner library inferred types
|
|
7
|
+
*
|
|
8
|
+
* Toast notification container configuration that extends the base ToasterProps from the sonner library
|
|
9
|
+
* with enhanced theming integration. All props are optional and have sensible defaults for most use cases.
|
|
10
|
+
*/
|
|
11
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
12
|
+
type ToasterDocsProps = {
|
|
13
|
+
/**
|
|
14
|
+
* Controls whether to invert toast colors for better contrast
|
|
15
|
+
* Useful when the container background differs significantly from the expected theme
|
|
16
|
+
* @default false
|
|
17
|
+
*/
|
|
18
|
+
invert?: boolean;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Theme mode for toast styling
|
|
22
|
+
* Automatically synced with application theme via useTheme hook when not specified
|
|
23
|
+
* @default "system" (auto-detected from useTheme)
|
|
24
|
+
*/
|
|
25
|
+
theme?: "light" | "dark" | "system";
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Position of toasts on the screen
|
|
29
|
+
* Determines where new toasts appear and how they stack
|
|
30
|
+
* @default "bottom-right"
|
|
31
|
+
*/
|
|
32
|
+
position?:
|
|
33
|
+
| "top-left"
|
|
34
|
+
| "top-right"
|
|
35
|
+
| "bottom-left"
|
|
36
|
+
| "bottom-right"
|
|
37
|
+
| "top-center"
|
|
38
|
+
| "bottom-center";
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Keyboard shortcut to focus the toast region
|
|
42
|
+
* Array of key modifiers and key codes for accessibility
|
|
43
|
+
* @default ["altKey", "KeyT"]
|
|
44
|
+
*/
|
|
45
|
+
hotkey?: string[];
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Enable enhanced colors for different toast types
|
|
49
|
+
* Provides more vibrant and distinct colors for success, error, warning, and info toasts
|
|
50
|
+
* @default false
|
|
51
|
+
*/
|
|
52
|
+
richColors?: boolean;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Expand toasts by default to show full content
|
|
56
|
+
* When true, toasts don't require hover to show full text
|
|
57
|
+
* @default false
|
|
58
|
+
*/
|
|
59
|
+
expand?: boolean;
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Default duration in milliseconds before auto-dismiss
|
|
63
|
+
* Individual toasts can override this value
|
|
64
|
+
* @default 4000
|
|
65
|
+
*/
|
|
66
|
+
duration?: number;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Spacing between toasts in pixels
|
|
70
|
+
* Controls the visual separation between stacked toasts
|
|
71
|
+
* @default 14
|
|
72
|
+
*/
|
|
73
|
+
gap?: number;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* Maximum number of toasts visible simultaneously
|
|
77
|
+
* Older toasts are automatically dismissed when limit is reached
|
|
78
|
+
* @default 3
|
|
79
|
+
*/
|
|
80
|
+
visibleToasts?: number;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Show close button on each toast
|
|
84
|
+
* Provides manual dismiss option for users
|
|
85
|
+
* @default false
|
|
86
|
+
*/
|
|
87
|
+
closeButton?: boolean;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Default options applied to all toasts
|
|
91
|
+
* Individual toast calls can override these defaults
|
|
92
|
+
*/
|
|
93
|
+
toastOptions?: {
|
|
94
|
+
/** Additional CSS classes for toast elements */
|
|
95
|
+
className?: string;
|
|
96
|
+
/** Show close button for individual toasts @default false */
|
|
97
|
+
closeButton?: boolean;
|
|
98
|
+
/** CSS classes for description text */
|
|
99
|
+
descriptionClassName?: string;
|
|
100
|
+
/** Inline styles for toast container */
|
|
101
|
+
style?: React.CSSProperties;
|
|
102
|
+
/** Styles for cancel button */
|
|
103
|
+
cancelButtonStyle?: React.CSSProperties;
|
|
104
|
+
/** Styles for action button */
|
|
105
|
+
actionButtonStyle?: React.CSSProperties;
|
|
106
|
+
/** Duration before auto-dismiss in milliseconds */
|
|
107
|
+
duration?: number;
|
|
108
|
+
/** Remove default styling to allow full custom styling @default false */
|
|
109
|
+
unstyled?: boolean;
|
|
110
|
+
/** CSS class overrides for specific toast elements */
|
|
111
|
+
classNames?: {
|
|
112
|
+
toast?: string;
|
|
113
|
+
title?: string;
|
|
114
|
+
description?: string;
|
|
115
|
+
loader?: string;
|
|
116
|
+
closeButton?: string;
|
|
117
|
+
cancelButton?: string;
|
|
118
|
+
actionButton?: string;
|
|
119
|
+
success?: string;
|
|
120
|
+
error?: string;
|
|
121
|
+
info?: string;
|
|
122
|
+
warning?: string;
|
|
123
|
+
loading?: string;
|
|
124
|
+
default?: string;
|
|
125
|
+
content?: string;
|
|
126
|
+
icon?: string;
|
|
127
|
+
};
|
|
128
|
+
/** Accessible label for close button */
|
|
129
|
+
closeButtonAriaLabel?: string;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Additional CSS classes for the toast container
|
|
134
|
+
* Applied to the root toaster element
|
|
135
|
+
*/
|
|
136
|
+
className?: string;
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Additional inline styles for the toast container
|
|
140
|
+
* Applied to the root toaster element
|
|
141
|
+
*/
|
|
142
|
+
style?: React.CSSProperties;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Offset from viewport edges
|
|
146
|
+
* Can be a number (pixels), string with units, or object with directional offsets
|
|
147
|
+
* @default 32
|
|
148
|
+
*/
|
|
149
|
+
offset?:
|
|
150
|
+
| string
|
|
151
|
+
| number
|
|
152
|
+
| {
|
|
153
|
+
top?: string | number;
|
|
154
|
+
right?: string | number;
|
|
155
|
+
bottom?: string | number;
|
|
156
|
+
left?: string | number;
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Offset specifically for mobile viewports
|
|
161
|
+
* Overrides offset on mobile devices for better UX
|
|
162
|
+
*/
|
|
163
|
+
mobileOffset?:
|
|
164
|
+
| string
|
|
165
|
+
| number
|
|
166
|
+
| {
|
|
167
|
+
top?: string | number;
|
|
168
|
+
right?: string | number;
|
|
169
|
+
bottom?: string | number;
|
|
170
|
+
left?: string | number;
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Text direction for toast content
|
|
175
|
+
* Controls layout direction for RTL languages
|
|
176
|
+
* @default "ltr"
|
|
177
|
+
*/
|
|
178
|
+
dir?: "rtl" | "ltr" | "auto";
|
|
179
|
+
|
|
180
|
+
/**
|
|
181
|
+
* Allowed swipe directions for dismissing toasts
|
|
182
|
+
* Controls which gestures can dismiss toasts on touch devices
|
|
183
|
+
* @default ["right"] for left positions, ["left"] for right positions
|
|
184
|
+
*/
|
|
185
|
+
swipeDirections?: ("top" | "right" | "bottom" | "left")[];
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Custom icons for different toast types
|
|
189
|
+
* Override default icons with your own components
|
|
190
|
+
*/
|
|
191
|
+
icons?: {
|
|
192
|
+
success?: React.ReactNode;
|
|
193
|
+
info?: React.ReactNode;
|
|
194
|
+
warning?: React.ReactNode;
|
|
195
|
+
error?: React.ReactNode;
|
|
196
|
+
loading?: React.ReactNode;
|
|
197
|
+
close?: React.ReactNode;
|
|
198
|
+
};
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* Accessible label for the toast container region
|
|
202
|
+
* Announced to screen readers when toasts appear
|
|
203
|
+
* @default "Notifications"
|
|
204
|
+
*/
|
|
205
|
+
containerAriaLabel?: string;
|
|
206
|
+
} & ToasterProps;
|
|
207
|
+
|
|
4
208
|
/**
|
|
5
209
|
* Toast notification container component built on Sonner
|
|
6
210
|
*
|
|
7
|
-
*
|
|
8
|
-
* with
|
|
9
|
-
*
|
|
10
|
-
*
|
|
211
|
+
* A feature-rich toast component that provides beautiful, accessible notifications
|
|
212
|
+
* with seamless theme integration and extensive customization options. Built on the
|
|
213
|
+
* popular Sonner library with enhanced theming that automatically synchronizes with
|
|
214
|
+
* the application's theme system using the useTheme hook.
|
|
11
215
|
*
|
|
12
|
-
*
|
|
216
|
+
* This component serves as the central toast container and should be placed once in
|
|
217
|
+
* your application root. It manages the display, positioning, and lifecycle of all
|
|
218
|
+
* toast notifications throughout your application.
|
|
219
|
+
*
|
|
220
|
+
* **Key Features:**
|
|
221
|
+
* - **Automatic theme synchronization** - Integrates with useTheme for consistent styling
|
|
222
|
+
* - **Flexible positioning** - Six different positions with smart stacking
|
|
223
|
+
* - **Rich accessibility** - Full keyboard navigation and screen reader support
|
|
224
|
+
* - **Promise integration** - Built-in loading/success/error states for async operations
|
|
225
|
+
* - **Gesture support** - Touch-friendly swipe-to-dismiss with configurable directions
|
|
226
|
+
* - **Performance optimized** - Efficient rendering with configurable limits
|
|
227
|
+
* - **Customizable styling** - Comprehensive theming and custom icon support
|
|
228
|
+
*
|
|
229
|
+
* @example Basic setup in root layout
|
|
13
230
|
* ```tsx
|
|
14
|
-
* // Add to your app root layout
|
|
15
231
|
* import { Toaster } from '@neynar/ui/components/ui/sonner';
|
|
16
232
|
*
|
|
17
233
|
* export default function RootLayout({ children }) {
|
|
@@ -26,76 +242,138 @@ import { Toaster as Sonner, type ToasterProps, toast } from "sonner";
|
|
|
26
242
|
* }
|
|
27
243
|
* ```
|
|
28
244
|
*
|
|
29
|
-
* @example
|
|
245
|
+
* @example Basic toast usage from anywhere in your app
|
|
30
246
|
* ```tsx
|
|
31
|
-
*
|
|
32
|
-
* import { toast } from 'sonner';
|
|
247
|
+
* import { toast } from '@neynar/ui/components/ui/sonner';
|
|
33
248
|
*
|
|
34
249
|
* // Simple notification
|
|
35
250
|
* toast('Cast published successfully');
|
|
36
251
|
*
|
|
37
|
-
* // Success variant
|
|
252
|
+
* // Success variant with icon
|
|
38
253
|
* toast.success('Profile updated');
|
|
39
254
|
*
|
|
40
|
-
* //
|
|
255
|
+
* // Rich toast with description and action
|
|
41
256
|
* toast('Event created', {
|
|
42
257
|
* description: 'Sunday, December 03, 2023 at 9:00 AM',
|
|
43
258
|
* action: {
|
|
44
259
|
* label: 'Undo',
|
|
45
|
-
* onClick: () =>
|
|
260
|
+
* onClick: () => handleUndo()
|
|
46
261
|
* }
|
|
47
262
|
* });
|
|
263
|
+
*
|
|
264
|
+
* // Error with custom styling
|
|
265
|
+
* toast.error('Upload failed', {
|
|
266
|
+
* description: 'File size must be less than 10MB',
|
|
267
|
+
* className: 'error-toast'
|
|
268
|
+
* });
|
|
48
269
|
* ```
|
|
49
270
|
*
|
|
50
|
-
* @example
|
|
271
|
+
* @example Promise-based toasts for async operations
|
|
51
272
|
* ```tsx
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
273
|
+
* import { toast } from '@neynar/ui/components/ui/sonner';
|
|
274
|
+
*
|
|
275
|
+
* // Automatically handles loading/success/error states
|
|
276
|
+
* toast.promise(saveUserProfile(data), {
|
|
277
|
+
* loading: 'Saving profile changes...',
|
|
278
|
+
* success: (result) => `Profile updated for ${result.username}`,
|
|
279
|
+
* error: 'Failed to save profile changes'
|
|
280
|
+
* });
|
|
281
|
+
*
|
|
282
|
+
* // With custom duration and retry action
|
|
283
|
+
* toast.promise(uploadFile(file), {
|
|
284
|
+
* loading: 'Uploading file...',
|
|
285
|
+
* success: 'File uploaded successfully',
|
|
286
|
+
* error: (error) => ({
|
|
287
|
+
* message: 'Upload failed',
|
|
288
|
+
* description: error.message,
|
|
289
|
+
* action: {
|
|
290
|
+
* label: 'Retry',
|
|
291
|
+
* onClick: () => uploadFile(file)
|
|
292
|
+
* }
|
|
293
|
+
* })
|
|
57
294
|
* });
|
|
58
295
|
* ```
|
|
59
296
|
*
|
|
60
|
-
* @example
|
|
297
|
+
* @example Custom positioned toaster with enhanced styling
|
|
61
298
|
* ```tsx
|
|
62
|
-
* // Custom configuration
|
|
63
299
|
* <Toaster
|
|
64
300
|
* position="top-center"
|
|
65
301
|
* expand={true}
|
|
66
302
|
* richColors
|
|
67
303
|
* duration={5000}
|
|
68
304
|
* closeButton
|
|
305
|
+
* visibleToasts={5}
|
|
306
|
+
* gap={16}
|
|
307
|
+
* offset={64}
|
|
69
308
|
* />
|
|
70
309
|
* ```
|
|
71
310
|
*
|
|
72
|
-
* @
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
* @
|
|
85
|
-
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
311
|
+
* @example RTL support and mobile optimization
|
|
312
|
+
* ```tsx
|
|
313
|
+
* <Toaster
|
|
314
|
+
* dir="rtl"
|
|
315
|
+
* position="top-right"
|
|
316
|
+
* offset={{ top: 20, right: 20 }}
|
|
317
|
+
* mobileOffset={{ top: 10, right: 10 }}
|
|
318
|
+
* swipeDirections={["left", "top"]}
|
|
319
|
+
* containerAriaLabel="إشعارات"
|
|
320
|
+
* />
|
|
321
|
+
* ```
|
|
322
|
+
*
|
|
323
|
+
* @example Custom icons and advanced configuration
|
|
324
|
+
* ```tsx
|
|
325
|
+
* <Toaster
|
|
326
|
+
* richColors
|
|
327
|
+
* icons={{
|
|
328
|
+
* success: <CheckCircleIcon />,
|
|
329
|
+
* error: <XCircleIcon />,
|
|
330
|
+
* warning: <ExclamationTriangleIcon />,
|
|
331
|
+
* info: <InformationCircleIcon />,
|
|
332
|
+
* loading: <SpinnerIcon />
|
|
333
|
+
* }}
|
|
334
|
+
* toastOptions={{
|
|
335
|
+
* classNames: {
|
|
336
|
+
* toast: 'group toast group-[.toaster]:bg-background',
|
|
337
|
+
* description: 'group-[.toast]:text-muted-foreground',
|
|
338
|
+
* actionButton: 'group-[.toast]:bg-primary',
|
|
339
|
+
* cancelButton: 'group-[.toast]:bg-muted'
|
|
340
|
+
* },
|
|
341
|
+
* closeButtonAriaLabel: 'Close notification'
|
|
342
|
+
* }}
|
|
343
|
+
* />
|
|
344
|
+
* ```
|
|
345
|
+
*
|
|
346
|
+
* @example Keyboard shortcuts and accessibility
|
|
347
|
+
* ```tsx
|
|
348
|
+
* <Toaster
|
|
349
|
+
* hotkey={["ctrlKey", "KeyN"]} // Ctrl+N to focus toasts
|
|
350
|
+
* closeButton
|
|
351
|
+
* containerAriaLabel="Application notifications"
|
|
352
|
+
* toastOptions={{
|
|
353
|
+
* closeButtonAriaLabel: "Dismiss notification",
|
|
354
|
+
* duration: 6000 // Longer duration for accessibility
|
|
355
|
+
* }}
|
|
356
|
+
* />
|
|
357
|
+
* ```
|
|
358
|
+
*
|
|
359
|
+
* @param props - Configuration options for the toast container. All props are optional with sensible defaults.
|
|
88
360
|
*
|
|
89
361
|
* @accessibility
|
|
90
|
-
* - Toasts are announced to screen readers
|
|
91
|
-
* - Keyboard
|
|
92
|
-
* -
|
|
93
|
-
* -
|
|
94
|
-
* -
|
|
95
|
-
* -
|
|
96
|
-
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
362
|
+
* - **ARIA Live Region**: Toasts are announced to screen readers automatically
|
|
363
|
+
* - **Keyboard Navigation**: Configurable hotkey to focus toast region (default Alt+T)
|
|
364
|
+
* - **Focus Management**: Interactive elements within toasts receive proper focus
|
|
365
|
+
* - **Screen Reader Support**: Toast content is properly announced with role and aria-label
|
|
366
|
+
* - **Close Button Accessibility**: When enabled, includes accessible close buttons
|
|
367
|
+
* - **Motion Preferences**: Respects user's prefers-reduced-motion for animations
|
|
368
|
+
* - **High Contrast**: Compatible with high contrast modes and custom color schemes
|
|
369
|
+
* - **Touch Accessibility**: Swipe gestures work with assistive touch technologies
|
|
370
|
+
* - **Keyboard Dismissal**: Escape key can dismiss toasts when focused
|
|
371
|
+
* - **Semantic Markup**: Uses appropriate ARIA roles and properties for toast region
|
|
372
|
+
*
|
|
373
|
+
* @see {@link https://ui.shadcn.com/docs/components/sonner} shadcn/ui Sonner documentation
|
|
374
|
+
* @see {@link https://sonner.emilkowal.ski/} Official Sonner library documentation
|
|
375
|
+
* @see {@link useTheme} Theme hook for understanding automatic theme integration
|
|
376
|
+
* @see {@link toast} Toast function for creating notifications
|
|
99
377
|
* @since 1.0.0
|
|
100
378
|
*/
|
|
101
379
|
function Toaster({ ...props }: ToasterProps) {
|
|
@@ -117,4 +395,254 @@ function Toaster({ ...props }: ToasterProps) {
|
|
|
117
395
|
);
|
|
118
396
|
}
|
|
119
397
|
|
|
120
|
-
|
|
398
|
+
/**
|
|
399
|
+
* Props for toast function (Documentation only - NOT used in function implementation)
|
|
400
|
+
* These types are for documentation generation and should not replace sonner library inferred types
|
|
401
|
+
*
|
|
402
|
+
* Configuration options for the toast() function and its variants. Extended from ExternalToast
|
|
403
|
+
* interface provided by the sonner library for comprehensive type coverage.
|
|
404
|
+
*/
|
|
405
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
406
|
+
type ToastFunctionDocsProps = {
|
|
407
|
+
/** Secondary text displayed below the main message */
|
|
408
|
+
description?: string | React.ReactNode;
|
|
409
|
+
/** Duration in milliseconds before auto-dismiss @default 4000 */
|
|
410
|
+
duration?: number;
|
|
411
|
+
/** Custom icon to display instead of default type icon */
|
|
412
|
+
icon?: React.ReactNode;
|
|
413
|
+
/** Primary action button configuration */
|
|
414
|
+
action?: {
|
|
415
|
+
/** Button text or React element */
|
|
416
|
+
label: React.ReactNode;
|
|
417
|
+
/** Click handler for the action button @param event - Mouse click event */
|
|
418
|
+
onClick: (event: MouseEvent) => void;
|
|
419
|
+
};
|
|
420
|
+
/** Cancel/dismiss button configuration */
|
|
421
|
+
cancel?: {
|
|
422
|
+
/** Button text or React element */
|
|
423
|
+
label: React.ReactNode;
|
|
424
|
+
/** Click handler for the cancel button @param event - Mouse click event */
|
|
425
|
+
onClick?: (event: MouseEvent) => void;
|
|
426
|
+
};
|
|
427
|
+
/** Unique identifier for programmatic control */
|
|
428
|
+
id?: string | number;
|
|
429
|
+
/** Additional CSS classes for toast styling */
|
|
430
|
+
className?: string;
|
|
431
|
+
/** Inline styles for toast container */
|
|
432
|
+
style?: React.CSSProperties;
|
|
433
|
+
/** Show close button on this toast @default false */
|
|
434
|
+
closeButton?: boolean;
|
|
435
|
+
/** Whether toast can be dismissed by user interaction @default true */
|
|
436
|
+
dismissible?: boolean;
|
|
437
|
+
/** Callback when toast is dismissed @param toast - Toast object */
|
|
438
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
439
|
+
onDismiss?: (toast: any) => void;
|
|
440
|
+
/** Callback when toast auto-closes @param toast - Toast object */
|
|
441
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
442
|
+
onAutoClose?: (toast: any) => void;
|
|
443
|
+
/** Remove default styling for complete customization @default false */
|
|
444
|
+
unstyled?: boolean;
|
|
445
|
+
/** CSS class overrides for specific toast elements */
|
|
446
|
+
classNames?: {
|
|
447
|
+
toast?: string;
|
|
448
|
+
title?: string;
|
|
449
|
+
description?: string;
|
|
450
|
+
loader?: string;
|
|
451
|
+
closeButton?: string;
|
|
452
|
+
cancelButton?: string;
|
|
453
|
+
actionButton?: string;
|
|
454
|
+
success?: string;
|
|
455
|
+
error?: string;
|
|
456
|
+
info?: string;
|
|
457
|
+
warning?: string;
|
|
458
|
+
loading?: string;
|
|
459
|
+
default?: string;
|
|
460
|
+
};
|
|
461
|
+
/** Inline styles for specific toast elements */
|
|
462
|
+
styles?: {
|
|
463
|
+
toast?: React.CSSProperties;
|
|
464
|
+
title?: React.CSSProperties;
|
|
465
|
+
description?: React.CSSProperties;
|
|
466
|
+
loader?: React.CSSProperties;
|
|
467
|
+
closeButton?: React.CSSProperties;
|
|
468
|
+
cancelButton?: React.CSSProperties;
|
|
469
|
+
actionButton?: React.CSSProperties;
|
|
470
|
+
};
|
|
471
|
+
/** Position override for this specific toast */
|
|
472
|
+
position?:
|
|
473
|
+
| "top-left"
|
|
474
|
+
| "top-right"
|
|
475
|
+
| "bottom-left"
|
|
476
|
+
| "bottom-right"
|
|
477
|
+
| "top-center"
|
|
478
|
+
| "bottom-center";
|
|
479
|
+
/** Enable rich colors for this toast @default false */
|
|
480
|
+
richColors?: boolean;
|
|
481
|
+
/** Text direction for this toast @default "ltr" */
|
|
482
|
+
dir?: "rtl" | "ltr" | "auto";
|
|
483
|
+
/** Accessible label for close button @default "Close toast" */
|
|
484
|
+
closeButtonAriaLabel?: string;
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
/**
|
|
488
|
+
* Toast function with comprehensive methods for creating notifications
|
|
489
|
+
*
|
|
490
|
+
* A powerful toast API that supports multiple notification types, promise handling,
|
|
491
|
+
* and extensive customization. Re-exported from the sonner library with enhanced
|
|
492
|
+
* type safety and documentation for seamless integration with @neynar/ui.
|
|
493
|
+
*
|
|
494
|
+
* **Available Methods:**
|
|
495
|
+
* - `toast(message)` - Basic notification
|
|
496
|
+
* - `toast.success(message)` - Success notification with green styling
|
|
497
|
+
* - `toast.error(message)` - Error notification with red styling
|
|
498
|
+
* - `toast.warning(message)` - Warning notification with yellow styling
|
|
499
|
+
* - `toast.info(message)` - Info notification with blue styling
|
|
500
|
+
* - `toast.loading(message)` - Loading notification with spinner
|
|
501
|
+
* - `toast.promise(promise, states)` - Promise-based notifications with loading/success/error
|
|
502
|
+
* - `toast.custom(jsx)` - Fully custom toast with JSX content
|
|
503
|
+
* - `toast.dismiss(id)` - Programmatically dismiss specific toast
|
|
504
|
+
* - `toast.message(message)` - Alias for basic toast
|
|
505
|
+
*
|
|
506
|
+
* **Common Options (ExternalToast):**
|
|
507
|
+
* ```typescript
|
|
508
|
+
* {
|
|
509
|
+
* description?: string | React.ReactNode,
|
|
510
|
+
* duration?: number,
|
|
511
|
+
* icon?: React.ReactNode,
|
|
512
|
+
* action?: {
|
|
513
|
+
* label: React.ReactNode,
|
|
514
|
+
* onClick: (event: MouseEvent) => void
|
|
515
|
+
* },
|
|
516
|
+
* cancel?: {
|
|
517
|
+
* label: React.ReactNode,
|
|
518
|
+
* onClick: (event: MouseEvent) => void
|
|
519
|
+
* },
|
|
520
|
+
* id?: string | number,
|
|
521
|
+
* className?: string,
|
|
522
|
+
* style?: CSSProperties,
|
|
523
|
+
* closeButton?: boolean,
|
|
524
|
+
* dismissible?: boolean,
|
|
525
|
+
* onDismiss?: (toast) => void,
|
|
526
|
+
* onAutoClose?: (toast) => void
|
|
527
|
+
* }
|
|
528
|
+
* ```
|
|
529
|
+
*
|
|
530
|
+
* @example Basic notifications
|
|
531
|
+
* ```tsx
|
|
532
|
+
* // Simple message
|
|
533
|
+
* toast('User logged in');
|
|
534
|
+
*
|
|
535
|
+
* // With description
|
|
536
|
+
* toast('New message', {
|
|
537
|
+
* description: 'You have a new direct message from @alice'
|
|
538
|
+
* });
|
|
539
|
+
*
|
|
540
|
+
* // Typed notifications
|
|
541
|
+
* toast.success('Profile saved');
|
|
542
|
+
* toast.error('Failed to upload image');
|
|
543
|
+
* toast.warning('Storage space is running low');
|
|
544
|
+
* toast.info('New features available');
|
|
545
|
+
* ```
|
|
546
|
+
*
|
|
547
|
+
* @example Advanced notifications with actions
|
|
548
|
+
* ```tsx
|
|
549
|
+
* // With action button
|
|
550
|
+
* toast('Cast scheduled', {
|
|
551
|
+
* description: 'Will be published in 1 hour',
|
|
552
|
+
* action: {
|
|
553
|
+
* label: 'Cancel',
|
|
554
|
+
* onClick: () => cancelScheduledCast()
|
|
555
|
+
* }
|
|
556
|
+
* });
|
|
557
|
+
*
|
|
558
|
+
* // With both action and cancel
|
|
559
|
+
* toast('Delete account?', {
|
|
560
|
+
* description: 'This action cannot be undone',
|
|
561
|
+
* action: {
|
|
562
|
+
* label: 'Delete',
|
|
563
|
+
* onClick: () => deleteAccount()
|
|
564
|
+
* },
|
|
565
|
+
* cancel: {
|
|
566
|
+
* label: 'Cancel',
|
|
567
|
+
* onClick: () => console.log('Cancelled')
|
|
568
|
+
* }
|
|
569
|
+
* });
|
|
570
|
+
* ```
|
|
571
|
+
*
|
|
572
|
+
* @example Promise-based notifications
|
|
573
|
+
* ```tsx
|
|
574
|
+
* // Basic promise handling
|
|
575
|
+
* toast.promise(uploadFile(file), {
|
|
576
|
+
* loading: 'Uploading...',
|
|
577
|
+
* success: 'Upload complete!',
|
|
578
|
+
* error: 'Upload failed'
|
|
579
|
+
* });
|
|
580
|
+
*
|
|
581
|
+
* // Dynamic success message based on result
|
|
582
|
+
* toast.promise(createUser(userData), {
|
|
583
|
+
* loading: 'Creating account...',
|
|
584
|
+
* success: (user) => `Welcome ${user.name}!`,
|
|
585
|
+
* error: (error) => `Failed: ${error.message}`
|
|
586
|
+
* });
|
|
587
|
+
*
|
|
588
|
+
* // With custom options per state
|
|
589
|
+
* toast.promise(processData(), {
|
|
590
|
+
* loading: 'Processing data...',
|
|
591
|
+
* success: (result) => ({
|
|
592
|
+
* message: 'Processing complete',
|
|
593
|
+
* description: `Processed ${result.count} items`,
|
|
594
|
+
* action: {
|
|
595
|
+
* label: 'View Results',
|
|
596
|
+
* onClick: () => showResults(result)
|
|
597
|
+
* }
|
|
598
|
+
* }),
|
|
599
|
+
* error: 'Processing failed'
|
|
600
|
+
* });
|
|
601
|
+
* ```
|
|
602
|
+
*
|
|
603
|
+
* @example Custom styling and behavior
|
|
604
|
+
* ```tsx
|
|
605
|
+
* // Custom duration and styling
|
|
606
|
+
* toast('Custom toast', {
|
|
607
|
+
* duration: 10000,
|
|
608
|
+
* className: 'my-custom-toast',
|
|
609
|
+
* style: { backgroundColor: '#ff6b6b' },
|
|
610
|
+
* icon: <CustomIcon />
|
|
611
|
+
* });
|
|
612
|
+
*
|
|
613
|
+
* // Non-dismissible toast (manual dismiss only)
|
|
614
|
+
* const toastId = toast('Important notice', {
|
|
615
|
+
* dismissible: false,
|
|
616
|
+
* duration: Infinity,
|
|
617
|
+
* action: {
|
|
618
|
+
* label: 'Acknowledge',
|
|
619
|
+
* onClick: () => toast.dismiss(toastId)
|
|
620
|
+
* }
|
|
621
|
+
* });
|
|
622
|
+
* ```
|
|
623
|
+
*
|
|
624
|
+
* @example Programmatic control
|
|
625
|
+
* ```tsx
|
|
626
|
+
* // Store toast ID for later control
|
|
627
|
+
* const loadingToast = toast.loading('Processing...');
|
|
628
|
+
*
|
|
629
|
+
* // Update the same toast
|
|
630
|
+
* setTimeout(() => {
|
|
631
|
+
* toast.success('Process complete!', { id: loadingToast });
|
|
632
|
+
* }, 2000);
|
|
633
|
+
*
|
|
634
|
+
* // Dismiss specific toast
|
|
635
|
+
* toast.dismiss(loadingToast);
|
|
636
|
+
*
|
|
637
|
+
* // Dismiss all toasts
|
|
638
|
+
* toast.dismiss();
|
|
639
|
+
* ```
|
|
640
|
+
*
|
|
641
|
+
* @returns The toast ID that can be used for programmatic control
|
|
642
|
+
*
|
|
643
|
+
* @see {@link Toaster} Toast container component that must be rendered in your app
|
|
644
|
+
* @see {@link https://sonner.emilkowal.ski/toast} Complete toast API documentation
|
|
645
|
+
*/
|
|
646
|
+
const toastFunction: typeof toast = toast;
|
|
647
|
+
|
|
648
|
+
export { Toaster, toastFunction as toast };
|