@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,6 +4,386 @@ import { CheckIcon, ChevronRightIcon, CircleIcon } from "lucide-react";
|
|
|
4
4
|
|
|
5
5
|
import { cn } from "@/lib/utils";
|
|
6
6
|
|
|
7
|
+
// ============================================================================
|
|
8
|
+
// INTERNAL DOCUMENTATION TYPES (NOT EXPORTED)
|
|
9
|
+
// These are for TSDoc generation only - components use Radix inferred types
|
|
10
|
+
// ============================================================================
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Props for ContextMenu (Documentation only - NOT used in component implementation)
|
|
14
|
+
* These types are for documentation generation and should not replace Radix inferred types
|
|
15
|
+
*/
|
|
16
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
17
|
+
type ContextMenuDocsProps = {
|
|
18
|
+
/**
|
|
19
|
+
* The reading direction of the context menu when applicable.
|
|
20
|
+
* If omitted, assumes LTR (left-to-right) reading mode.
|
|
21
|
+
* @default "ltr"
|
|
22
|
+
*/
|
|
23
|
+
dir?: "ltr" | "rtl";
|
|
24
|
+
/**
|
|
25
|
+
* Event handler called when the open state of the context menu changes.
|
|
26
|
+
* Receives the new open state as a boolean parameter.
|
|
27
|
+
*/
|
|
28
|
+
onOpenChange?: (open: boolean) => void;
|
|
29
|
+
/**
|
|
30
|
+
* The modality of the context menu. When set to `true`, interaction with
|
|
31
|
+
* outside elements will be disabled and only menu content will be visible
|
|
32
|
+
* to screen readers.
|
|
33
|
+
* @default true
|
|
34
|
+
*/
|
|
35
|
+
modal?: boolean;
|
|
36
|
+
/** The content to render inside the context menu root */
|
|
37
|
+
children?: React.ReactNode;
|
|
38
|
+
} & React.ComponentProps<typeof ContextMenuPrimitive.Root>;
|
|
39
|
+
|
|
40
|
+
/** Props for ContextMenuTrigger (Documentation only) */
|
|
41
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
42
|
+
type ContextMenuTriggerDocsProps = {
|
|
43
|
+
/**
|
|
44
|
+
* Change the default rendered element for the one passed as a child,
|
|
45
|
+
* merging their props and behavior. Useful for composition patterns.
|
|
46
|
+
* @default false
|
|
47
|
+
*/
|
|
48
|
+
asChild?: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* When `true`, prevents the user from interacting with the trigger.
|
|
51
|
+
* The context menu will not open when the trigger is right-clicked.
|
|
52
|
+
* @default false
|
|
53
|
+
*/
|
|
54
|
+
disabled?: boolean;
|
|
55
|
+
/** The element that should trigger the context menu on right-click */
|
|
56
|
+
children: React.ReactNode;
|
|
57
|
+
} & React.ComponentProps<typeof ContextMenuPrimitive.Trigger>;
|
|
58
|
+
|
|
59
|
+
/** Props for ContextMenuContent (Documentation only) */
|
|
60
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
61
|
+
type ContextMenuContentDocsProps = {
|
|
62
|
+
/**
|
|
63
|
+
* Change the default rendered element for the one passed as a child,
|
|
64
|
+
* merging their props and behavior.
|
|
65
|
+
* @default false
|
|
66
|
+
*/
|
|
67
|
+
asChild?: boolean;
|
|
68
|
+
/**
|
|
69
|
+
* When `true`, keyboard navigation will loop from last item to first,
|
|
70
|
+
* and vice versa.
|
|
71
|
+
* @default false
|
|
72
|
+
*/
|
|
73
|
+
loop?: boolean;
|
|
74
|
+
/**
|
|
75
|
+
* Event handler called when focus moves to the trigger after closing.
|
|
76
|
+
* Can be prevented by calling `event.preventDefault`.
|
|
77
|
+
*/
|
|
78
|
+
onCloseAutoFocus?: (event: Event) => void;
|
|
79
|
+
/**
|
|
80
|
+
* Event handler called when the escape key is down.
|
|
81
|
+
* Can be prevented by calling `event.preventDefault`.
|
|
82
|
+
*/
|
|
83
|
+
onEscapeKeyDown?: (event: KeyboardEvent) => void;
|
|
84
|
+
/**
|
|
85
|
+
* When `true`, overrides the side and align preferences to prevent
|
|
86
|
+
* collisions with boundary edges.
|
|
87
|
+
* @default true
|
|
88
|
+
*/
|
|
89
|
+
avoidCollisions?: boolean;
|
|
90
|
+
/**
|
|
91
|
+
* The distance in pixels from the anchor (trigger point).
|
|
92
|
+
* @default 0
|
|
93
|
+
*/
|
|
94
|
+
sideOffset?: number;
|
|
95
|
+
/** Custom CSS class name for styling */
|
|
96
|
+
className?: string;
|
|
97
|
+
/** The menu items, labels, separators, and sub-menus to display */
|
|
98
|
+
children: React.ReactNode;
|
|
99
|
+
} & React.ComponentProps<typeof ContextMenuPrimitive.Content>;
|
|
100
|
+
|
|
101
|
+
/** Props for ContextMenuItem (Documentation only) */
|
|
102
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
103
|
+
type ContextMenuItemDocsProps = {
|
|
104
|
+
/**
|
|
105
|
+
* Change the default rendered element for the one passed as a child,
|
|
106
|
+
* merging their props and behavior.
|
|
107
|
+
* @default false
|
|
108
|
+
*/
|
|
109
|
+
asChild?: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* When `true`, prevents the user from interacting with the item.
|
|
112
|
+
* The item will appear dimmed and be skipped during keyboard navigation.
|
|
113
|
+
*/
|
|
114
|
+
disabled?: boolean;
|
|
115
|
+
/**
|
|
116
|
+
* Event handler called when the user selects an item (via mouse or keyboard).
|
|
117
|
+
* Calling `event.preventDefault` in this handler will prevent the menu from closing.
|
|
118
|
+
*/
|
|
119
|
+
onSelect?: (event: Event) => void;
|
|
120
|
+
/**
|
|
121
|
+
* Optional text used for typeahead purposes. By default, the typeahead behavior
|
|
122
|
+
* will use the `.textContent` of the item. Use this when content is complex,
|
|
123
|
+
* or you have non-textual content inside.
|
|
124
|
+
*/
|
|
125
|
+
textValue?: string;
|
|
126
|
+
/**
|
|
127
|
+
* Whether to indent the item for proper alignment when mixing items with/without icons.
|
|
128
|
+
* Creates consistent visual alignment in mixed-content menus.
|
|
129
|
+
*/
|
|
130
|
+
inset?: boolean;
|
|
131
|
+
/**
|
|
132
|
+
* Visual variant for the menu item appearance and behavior.
|
|
133
|
+
* - `default`: Standard menu item styling for normal actions
|
|
134
|
+
* - `destructive`: Red styling to indicate dangerous/destructive actions
|
|
135
|
+
* @default "default"
|
|
136
|
+
*/
|
|
137
|
+
variant?: "default" | "destructive";
|
|
138
|
+
/** Custom CSS class name for additional styling */
|
|
139
|
+
className?: string;
|
|
140
|
+
/** The content of the menu item (text, icons, shortcuts, etc.) */
|
|
141
|
+
children: React.ReactNode;
|
|
142
|
+
} & React.ComponentProps<typeof ContextMenuPrimitive.Item>;
|
|
143
|
+
|
|
144
|
+
/** Props for ContextMenuCheckboxItem (Documentation only) */
|
|
145
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
146
|
+
type ContextMenuCheckboxItemDocsProps = {
|
|
147
|
+
/**
|
|
148
|
+
* Change the default rendered element for the one passed as a child,
|
|
149
|
+
* merging their props and behavior.
|
|
150
|
+
* @default false
|
|
151
|
+
*/
|
|
152
|
+
asChild?: boolean;
|
|
153
|
+
/**
|
|
154
|
+
* The controlled checked state of the item.
|
|
155
|
+
* - `true`: Item is checked
|
|
156
|
+
* - `false`: Item is unchecked
|
|
157
|
+
* - `"indeterminate"`: Item is in an indeterminate state
|
|
158
|
+
*/
|
|
159
|
+
checked?: boolean | "indeterminate";
|
|
160
|
+
/**
|
|
161
|
+
* Event handler called when the checked state changes.
|
|
162
|
+
* Receives the new checked state as a boolean parameter.
|
|
163
|
+
*/
|
|
164
|
+
onCheckedChange?: (checked: boolean) => void;
|
|
165
|
+
/**
|
|
166
|
+
* When `true`, prevents the user from interacting with the item.
|
|
167
|
+
*/
|
|
168
|
+
disabled?: boolean;
|
|
169
|
+
/**
|
|
170
|
+
* Event handler called when the user selects the item.
|
|
171
|
+
* Called before `onCheckedChange`.
|
|
172
|
+
*/
|
|
173
|
+
onSelect?: (event: Event) => void;
|
|
174
|
+
/**
|
|
175
|
+
* Optional text used for typeahead purposes. By default, the typeahead behavior
|
|
176
|
+
* will use the `.textContent` of the item.
|
|
177
|
+
*/
|
|
178
|
+
textValue?: string;
|
|
179
|
+
/** Custom CSS class name for styling */
|
|
180
|
+
className?: string;
|
|
181
|
+
/** The content of the checkbox item (typically text) */
|
|
182
|
+
children: React.ReactNode;
|
|
183
|
+
} & React.ComponentProps<typeof ContextMenuPrimitive.CheckboxItem>;
|
|
184
|
+
|
|
185
|
+
/** Props for ContextMenuRadioGroup (Documentation only) */
|
|
186
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
187
|
+
type ContextMenuRadioGroupDocsProps = {
|
|
188
|
+
/**
|
|
189
|
+
* The controlled value of the radio group. Should match the `value` prop
|
|
190
|
+
* of the selected ContextMenuRadioItem.
|
|
191
|
+
*/
|
|
192
|
+
value?: string;
|
|
193
|
+
/**
|
|
194
|
+
* Event handler called when the value changes.
|
|
195
|
+
* Receives the new selected value as a string parameter.
|
|
196
|
+
*/
|
|
197
|
+
onValueChange?: (value: string) => void;
|
|
198
|
+
/** Custom CSS class name for styling */
|
|
199
|
+
className?: string;
|
|
200
|
+
/** The radio items to group together */
|
|
201
|
+
children: React.ReactNode;
|
|
202
|
+
} & React.ComponentProps<typeof ContextMenuPrimitive.RadioGroup>;
|
|
203
|
+
|
|
204
|
+
/** Props for ContextMenuRadioItem (Documentation only) */
|
|
205
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
206
|
+
type ContextMenuRadioItemDocsProps = {
|
|
207
|
+
/**
|
|
208
|
+
* The unique value of the item. This will be passed to the `onValueChange`
|
|
209
|
+
* callback of the parent RadioGroup when this item is selected.
|
|
210
|
+
*/
|
|
211
|
+
value: string;
|
|
212
|
+
/**
|
|
213
|
+
* When `true`, prevents the user from interacting with the item.
|
|
214
|
+
*/
|
|
215
|
+
disabled?: boolean;
|
|
216
|
+
/**
|
|
217
|
+
* Event handler called when the user selects the item.
|
|
218
|
+
* Called before the parent RadioGroup's `onValueChange`.
|
|
219
|
+
*/
|
|
220
|
+
onSelect?: (event: Event) => void;
|
|
221
|
+
/**
|
|
222
|
+
* Optional text used for typeahead purposes. By default, the typeahead behavior
|
|
223
|
+
* will use the `.textContent` of the item.
|
|
224
|
+
*/
|
|
225
|
+
textValue?: string;
|
|
226
|
+
/** Custom CSS class name for styling */
|
|
227
|
+
className?: string;
|
|
228
|
+
/** The content of the radio item (typically text) */
|
|
229
|
+
children: React.ReactNode;
|
|
230
|
+
} & React.ComponentProps<typeof ContextMenuPrimitive.RadioItem>;
|
|
231
|
+
|
|
232
|
+
/** Props for ContextMenuLabel (Documentation only) */
|
|
233
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
234
|
+
type ContextMenuLabelDocsProps = {
|
|
235
|
+
/**
|
|
236
|
+
* Change the default rendered element for the one passed as a child,
|
|
237
|
+
* merging their props and behavior.
|
|
238
|
+
* @default false
|
|
239
|
+
*/
|
|
240
|
+
asChild?: boolean;
|
|
241
|
+
/**
|
|
242
|
+
* Whether to indent the label to align with inset items.
|
|
243
|
+
* Use this when you have a mix of items with and without icons.
|
|
244
|
+
*/
|
|
245
|
+
inset?: boolean;
|
|
246
|
+
/** Custom CSS class name for styling */
|
|
247
|
+
className?: string;
|
|
248
|
+
/** The text content of the label */
|
|
249
|
+
children: React.ReactNode;
|
|
250
|
+
} & React.ComponentProps<typeof ContextMenuPrimitive.Label>;
|
|
251
|
+
|
|
252
|
+
/** Props for ContextMenuSeparator (Documentation only) */
|
|
253
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
254
|
+
type ContextMenuSeparatorDocsProps = {
|
|
255
|
+
/**
|
|
256
|
+
* Change the default rendered element for the one passed as a child,
|
|
257
|
+
* merging their props and behavior.
|
|
258
|
+
* @default false
|
|
259
|
+
*/
|
|
260
|
+
asChild?: boolean;
|
|
261
|
+
/** Custom CSS class name for styling */
|
|
262
|
+
className?: string;
|
|
263
|
+
} & React.ComponentProps<typeof ContextMenuPrimitive.Separator>;
|
|
264
|
+
|
|
265
|
+
/** Props for ContextMenuGroup (Documentation only) */
|
|
266
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
267
|
+
type ContextMenuGroupDocsProps = {
|
|
268
|
+
/**
|
|
269
|
+
* Change the default rendered element for the one passed as a child,
|
|
270
|
+
* merging their props and behavior.
|
|
271
|
+
* @default false
|
|
272
|
+
*/
|
|
273
|
+
asChild?: boolean;
|
|
274
|
+
/** Custom CSS class name for styling */
|
|
275
|
+
className?: string;
|
|
276
|
+
/** The items to group together */
|
|
277
|
+
children: React.ReactNode;
|
|
278
|
+
} & React.ComponentProps<typeof ContextMenuPrimitive.Group>;
|
|
279
|
+
|
|
280
|
+
/** Props for ContextMenuPortal (Documentation only) */
|
|
281
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
282
|
+
type ContextMenuPortalDocsProps = {
|
|
283
|
+
/**
|
|
284
|
+
* Specify a container element to portal the content into.
|
|
285
|
+
* If not provided, content will be portaled into the body.
|
|
286
|
+
*/
|
|
287
|
+
container?: HTMLElement;
|
|
288
|
+
/** The content to render in the portal */
|
|
289
|
+
children: React.ReactNode;
|
|
290
|
+
} & React.ComponentProps<typeof ContextMenuPrimitive.Portal>;
|
|
291
|
+
|
|
292
|
+
/** Props for ContextMenuSub (Documentation only) */
|
|
293
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
294
|
+
type ContextMenuSubDocsProps = {
|
|
295
|
+
/**
|
|
296
|
+
* The controlled open state of the sub menu.
|
|
297
|
+
* Must be used in conjunction with `onOpenChange`.
|
|
298
|
+
*/
|
|
299
|
+
open?: boolean;
|
|
300
|
+
/**
|
|
301
|
+
* Event handler called when the open state of the sub menu changes.
|
|
302
|
+
*/
|
|
303
|
+
onOpenChange?: (open: boolean) => void;
|
|
304
|
+
/** The sub-menu trigger and content components */
|
|
305
|
+
children: React.ReactNode;
|
|
306
|
+
} & React.ComponentProps<typeof ContextMenuPrimitive.Sub>;
|
|
307
|
+
|
|
308
|
+
/** Props for ContextMenuSubTrigger (Documentation only) */
|
|
309
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
310
|
+
type ContextMenuSubTriggerDocsProps = {
|
|
311
|
+
/**
|
|
312
|
+
* Change the default rendered element for the one passed as a child,
|
|
313
|
+
* merging their props and behavior.
|
|
314
|
+
* @default false
|
|
315
|
+
*/
|
|
316
|
+
asChild?: boolean;
|
|
317
|
+
/**
|
|
318
|
+
* When `true`, prevents the user from interacting with the item.
|
|
319
|
+
*/
|
|
320
|
+
disabled?: boolean;
|
|
321
|
+
/**
|
|
322
|
+
* Optional text used for typeahead purposes. By default, the typeahead behavior
|
|
323
|
+
* will use the `.textContent` of the item.
|
|
324
|
+
*/
|
|
325
|
+
textValue?: string;
|
|
326
|
+
/**
|
|
327
|
+
* Whether to indent the trigger for proper alignment when mixing items with/without icons.
|
|
328
|
+
*/
|
|
329
|
+
inset?: boolean;
|
|
330
|
+
/** Custom CSS class name for styling */
|
|
331
|
+
className?: string;
|
|
332
|
+
/** The content of the sub-trigger (text, icons, etc.) */
|
|
333
|
+
children: React.ReactNode;
|
|
334
|
+
} & React.ComponentProps<typeof ContextMenuPrimitive.SubTrigger>;
|
|
335
|
+
|
|
336
|
+
/** Props for ContextMenuSubContent (Documentation only) */
|
|
337
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
338
|
+
type ContextMenuSubContentDocsProps = {
|
|
339
|
+
/**
|
|
340
|
+
* Change the default rendered element for the one passed as a child,
|
|
341
|
+
* merging their props and behavior.
|
|
342
|
+
* @default false
|
|
343
|
+
*/
|
|
344
|
+
asChild?: boolean;
|
|
345
|
+
/**
|
|
346
|
+
* When `true`, keyboard navigation will loop from last item to first,
|
|
347
|
+
* and vice versa.
|
|
348
|
+
* @default false
|
|
349
|
+
*/
|
|
350
|
+
loop?: boolean;
|
|
351
|
+
/**
|
|
352
|
+
* Event handler called when focus moves back to the trigger after closing.
|
|
353
|
+
* Can be prevented by calling `event.preventDefault`.
|
|
354
|
+
*/
|
|
355
|
+
onCloseAutoFocus?: (event: Event) => void;
|
|
356
|
+
/**
|
|
357
|
+
* Event handler called when the escape key is down.
|
|
358
|
+
* Can be prevented by calling `event.preventDefault`.
|
|
359
|
+
*/
|
|
360
|
+
onEscapeKeyDown?: (event: KeyboardEvent) => void;
|
|
361
|
+
/**
|
|
362
|
+
* When `true`, overrides the side and align preferences to prevent
|
|
363
|
+
* collisions with boundary edges.
|
|
364
|
+
* @default true
|
|
365
|
+
*/
|
|
366
|
+
avoidCollisions?: boolean;
|
|
367
|
+
/**
|
|
368
|
+
* The distance in pixels from the anchor.
|
|
369
|
+
* @default 0
|
|
370
|
+
*/
|
|
371
|
+
sideOffset?: number;
|
|
372
|
+
/** Custom CSS class name for styling */
|
|
373
|
+
className?: string;
|
|
374
|
+
/** The sub-menu items, separators, and labels */
|
|
375
|
+
children: React.ReactNode;
|
|
376
|
+
} & React.ComponentProps<typeof ContextMenuPrimitive.SubContent>;
|
|
377
|
+
|
|
378
|
+
/** Props for ContextMenuShortcut (Documentation only) */
|
|
379
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
380
|
+
type ContextMenuShortcutDocsProps = {
|
|
381
|
+
/** Custom CSS class name for styling */
|
|
382
|
+
className?: string;
|
|
383
|
+
/** The keyboard shortcut text to display (e.g., "⌘C", "Ctrl+V") */
|
|
384
|
+
children: React.ReactNode;
|
|
385
|
+
} & React.ComponentProps<"span">;
|
|
386
|
+
|
|
7
387
|
/**
|
|
8
388
|
* ContextMenu - A contextual menu that appears on right-click or long-press
|
|
9
389
|
*
|
|
@@ -49,6 +429,30 @@ import { cn } from "@/lib/utils";
|
|
|
49
429
|
* </ContextMenu>
|
|
50
430
|
* ```
|
|
51
431
|
*
|
|
432
|
+
* @example
|
|
433
|
+
* ```tsx
|
|
434
|
+
* // With checkboxes and radio groups
|
|
435
|
+
* <ContextMenu>
|
|
436
|
+
* <ContextMenuTrigger>Settings Menu</ContextMenuTrigger>
|
|
437
|
+
* <ContextMenuContent>
|
|
438
|
+
* <ContextMenuLabel>Preferences</ContextMenuLabel>
|
|
439
|
+
* <ContextMenuSeparator />
|
|
440
|
+
* <ContextMenuCheckboxItem checked={showToolbar} onCheckedChange={setShowToolbar}>
|
|
441
|
+
* Show Toolbar
|
|
442
|
+
* </ContextMenuCheckboxItem>
|
|
443
|
+
* <ContextMenuCheckboxItem checked={showSidebar} onCheckedChange={setShowSidebar}>
|
|
444
|
+
* Show Sidebar
|
|
445
|
+
* </ContextMenuCheckboxItem>
|
|
446
|
+
* <ContextMenuSeparator />
|
|
447
|
+
* <ContextMenuRadioGroup value={theme} onValueChange={setTheme}>
|
|
448
|
+
* <ContextMenuRadioItem value="light">Light Theme</ContextMenuRadioItem>
|
|
449
|
+
* <ContextMenuRadioItem value="dark">Dark Theme</ContextMenuRadioItem>
|
|
450
|
+
* <ContextMenuRadioItem value="system">System Theme</ContextMenuRadioItem>
|
|
451
|
+
* </ContextMenuRadioGroup>
|
|
452
|
+
* </ContextMenuContent>
|
|
453
|
+
* </ContextMenu>
|
|
454
|
+
* ```
|
|
455
|
+
*
|
|
52
456
|
* @accessibility
|
|
53
457
|
* - Triggered by right-click, long-press, or Shift+F10
|
|
54
458
|
* - Full keyboard navigation with arrow keys
|
|
@@ -57,14 +461,19 @@ import { cn } from "@/lib/utils";
|
|
|
57
461
|
* - Tab moves focus outside the menu
|
|
58
462
|
* - Proper ARIA roles and focus management
|
|
59
463
|
* - Screen reader announcements for menu state changes
|
|
464
|
+
* - Supports typeahead navigation by first letter
|
|
465
|
+
* - Focus returns to trigger element when closed
|
|
60
466
|
*
|
|
467
|
+
* @see {@link ContextMenuTrigger} Trigger element component
|
|
468
|
+
* @see {@link ContextMenuContent} Menu content container
|
|
469
|
+
* @see {@link ContextMenuItem} Individual menu items
|
|
61
470
|
* @see {@link https://ui.shadcn.com/docs/components/context-menu} shadcn/ui docs
|
|
62
|
-
* @since 1.0.0
|
|
63
471
|
* @see {@link https://www.radix-ui.com/primitives/docs/components/context-menu} Radix UI docs
|
|
472
|
+
* @since 1.0.0
|
|
64
473
|
*/
|
|
65
|
-
function ContextMenu(
|
|
66
|
-
|
|
67
|
-
|
|
474
|
+
function ContextMenu(
|
|
475
|
+
props: React.ComponentProps<typeof ContextMenuPrimitive.Root>,
|
|
476
|
+
) {
|
|
68
477
|
return <ContextMenuPrimitive.Root data-slot="context-menu" {...props} />;
|
|
69
478
|
}
|
|
70
479
|
|
|
@@ -73,6 +482,7 @@ function ContextMenu({
|
|
|
73
482
|
*
|
|
74
483
|
* Wraps any element to make it respond to right-click or long-press events.
|
|
75
484
|
* The trigger element should provide visual feedback about its interactive nature.
|
|
485
|
+
* Uses the `asChild` pattern to merge props with child elements for composition.
|
|
76
486
|
*
|
|
77
487
|
* @example
|
|
78
488
|
* ```tsx
|
|
@@ -81,11 +491,23 @@ function ContextMenu({
|
|
|
81
491
|
* </ContextMenuTrigger>
|
|
82
492
|
* ```
|
|
83
493
|
*
|
|
84
|
-
* @
|
|
494
|
+
* @example
|
|
495
|
+
* ```tsx
|
|
496
|
+
* // With asChild for direct prop merging
|
|
497
|
+
* <ContextMenuTrigger asChild>
|
|
498
|
+
* <div className="p-4 border rounded cursor-pointer">
|
|
499
|
+
* Right-click target area
|
|
500
|
+
* </div>
|
|
501
|
+
* </ContextMenuTrigger>
|
|
502
|
+
* ```
|
|
503
|
+
*
|
|
504
|
+
* @param asChild - Merges props with child element instead of rendering wrapper
|
|
505
|
+
* @param disabled - Prevents context menu from opening when trigger is activated
|
|
506
|
+
* @param children - The element that should respond to right-click events
|
|
85
507
|
*/
|
|
86
|
-
function ContextMenuTrigger(
|
|
87
|
-
|
|
88
|
-
|
|
508
|
+
function ContextMenuTrigger(
|
|
509
|
+
props: React.ComponentProps<typeof ContextMenuPrimitive.Trigger>,
|
|
510
|
+
) {
|
|
89
511
|
return (
|
|
90
512
|
<ContextMenuPrimitive.Trigger data-slot="context-menu-trigger" {...props} />
|
|
91
513
|
);
|
|
@@ -95,7 +517,8 @@ function ContextMenuTrigger({
|
|
|
95
517
|
* ContextMenuGroup - Logical grouping for menu items
|
|
96
518
|
*
|
|
97
519
|
* Groups related menu items together for better organization and accessibility.
|
|
98
|
-
* Provides semantic structure without visual changes
|
|
520
|
+
* Provides semantic structure without visual changes but improves screen reader
|
|
521
|
+
* navigation by grouping related actions.
|
|
99
522
|
*
|
|
100
523
|
* @example
|
|
101
524
|
* ```tsx
|
|
@@ -105,10 +528,29 @@ function ContextMenuTrigger({
|
|
|
105
528
|
* <ContextMenuItem>Paste</ContextMenuItem>
|
|
106
529
|
* </ContextMenuGroup>
|
|
107
530
|
* ```
|
|
531
|
+
*
|
|
532
|
+
* @example
|
|
533
|
+
* ```tsx
|
|
534
|
+
* // Multiple groups with separators
|
|
535
|
+
* <ContextMenuContent>
|
|
536
|
+
* <ContextMenuGroup>
|
|
537
|
+
* <ContextMenuItem>Undo</ContextMenuItem>
|
|
538
|
+
* <ContextMenuItem>Redo</ContextMenuItem>
|
|
539
|
+
* </ContextMenuGroup>
|
|
540
|
+
* <ContextMenuSeparator />
|
|
541
|
+
* <ContextMenuGroup>
|
|
542
|
+
* <ContextMenuItem>Copy</ContextMenuItem>
|
|
543
|
+
* <ContextMenuItem>Paste</ContextMenuItem>
|
|
544
|
+
* </ContextMenuGroup>
|
|
545
|
+
* </ContextMenuContent>
|
|
546
|
+
* ```
|
|
547
|
+
*
|
|
548
|
+
* @param asChild - Merges props with child element instead of rendering wrapper
|
|
549
|
+
* @param children - The menu items to group together logically
|
|
108
550
|
*/
|
|
109
|
-
function ContextMenuGroup(
|
|
110
|
-
|
|
111
|
-
|
|
551
|
+
function ContextMenuGroup(
|
|
552
|
+
props: React.ComponentProps<typeof ContextMenuPrimitive.Group>,
|
|
553
|
+
) {
|
|
112
554
|
return (
|
|
113
555
|
<ContextMenuPrimitive.Group data-slot="context-menu-group" {...props} />
|
|
114
556
|
);
|
|
@@ -118,7 +560,8 @@ function ContextMenuGroup({
|
|
|
118
560
|
* ContextMenuPortal - Portal container for menu content
|
|
119
561
|
*
|
|
120
562
|
* Renders menu content in a portal to ensure proper layering and positioning.
|
|
121
|
-
*
|
|
563
|
+
* Useful for controlling where menu content is rendered in the DOM tree,
|
|
564
|
+
* especially important for sub-menus and complex layouts.
|
|
122
565
|
*
|
|
123
566
|
* @example
|
|
124
567
|
* ```tsx
|
|
@@ -129,11 +572,22 @@ function ContextMenuGroup({
|
|
|
129
572
|
* </ContextMenuPortal>
|
|
130
573
|
* ```
|
|
131
574
|
*
|
|
132
|
-
* @
|
|
575
|
+
* @example
|
|
576
|
+
* ```tsx
|
|
577
|
+
* // Portal into specific container
|
|
578
|
+
* <ContextMenuPortal container={document.getElementById('menu-container')}>
|
|
579
|
+
* <ContextMenuContent>
|
|
580
|
+
* <ContextMenuItem>Custom Portal Item</ContextMenuItem>
|
|
581
|
+
* </ContextMenuContent>
|
|
582
|
+
* </ContextMenuPortal>
|
|
583
|
+
* ```
|
|
584
|
+
*
|
|
585
|
+
* @param container - Custom container element to portal content into
|
|
586
|
+
* @param children - The menu content to render in the portal
|
|
133
587
|
*/
|
|
134
|
-
function ContextMenuPortal(
|
|
135
|
-
|
|
136
|
-
|
|
588
|
+
function ContextMenuPortal(
|
|
589
|
+
props: React.ComponentProps<typeof ContextMenuPrimitive.Portal>,
|
|
590
|
+
) {
|
|
137
591
|
return (
|
|
138
592
|
<ContextMenuPrimitive.Portal data-slot="context-menu-portal" {...props} />
|
|
139
593
|
);
|
|
@@ -143,7 +597,8 @@ function ContextMenuPortal({
|
|
|
143
597
|
* ContextMenuSub - Container for sub-menu functionality
|
|
144
598
|
*
|
|
145
599
|
* Wraps a sub-menu trigger and its content to create nested menu structures.
|
|
146
|
-
* Enables hierarchical organization of menu items
|
|
600
|
+
* Enables hierarchical organization of menu items with proper state management
|
|
601
|
+
* for opening and closing sub-menus.
|
|
147
602
|
*
|
|
148
603
|
* @example
|
|
149
604
|
* ```tsx
|
|
@@ -155,10 +610,29 @@ function ContextMenuPortal({
|
|
|
155
610
|
* </ContextMenuSubContent>
|
|
156
611
|
* </ContextMenuSub>
|
|
157
612
|
* ```
|
|
613
|
+
*
|
|
614
|
+
* @example
|
|
615
|
+
* ```tsx
|
|
616
|
+
* // Controlled sub-menu
|
|
617
|
+
* const [subOpen, setSubOpen] = useState(false)
|
|
618
|
+
*
|
|
619
|
+
* <ContextMenuSub open={subOpen} onOpenChange={setSubOpen}>
|
|
620
|
+
* <ContextMenuSubTrigger>More Actions</ContextMenuSubTrigger>
|
|
621
|
+
* <ContextMenuSubContent>
|
|
622
|
+
* <ContextMenuItem onClick={() => setSubOpen(false)}>
|
|
623
|
+
* Archive
|
|
624
|
+
* </ContextMenuItem>
|
|
625
|
+
* </ContextMenuSubContent>
|
|
626
|
+
* </ContextMenuSub>
|
|
627
|
+
* ```
|
|
628
|
+
*
|
|
629
|
+
* @param open - Controlled open state of the sub-menu
|
|
630
|
+
* @param onOpenChange - Callback fired when sub-menu open state changes
|
|
631
|
+
* @param children - Sub-menu trigger and content components
|
|
158
632
|
*/
|
|
159
|
-
function ContextMenuSub(
|
|
160
|
-
|
|
161
|
-
|
|
633
|
+
function ContextMenuSub(
|
|
634
|
+
props: React.ComponentProps<typeof ContextMenuPrimitive.Sub>,
|
|
635
|
+
) {
|
|
162
636
|
return <ContextMenuPrimitive.Sub data-slot="context-menu-sub" {...props} />;
|
|
163
637
|
}
|
|
164
638
|
|
|
@@ -166,10 +640,13 @@ function ContextMenuSub({
|
|
|
166
640
|
* ContextMenuRadioGroup - Container for radio button items
|
|
167
641
|
*
|
|
168
642
|
* Groups radio items together to allow single selection from multiple options.
|
|
169
|
-
* Manages the selected state and ensures only one item can be selected.
|
|
643
|
+
* Manages the selected state and ensures only one item can be selected at a time.
|
|
644
|
+
* Provides controlled state management for radio selections within menus.
|
|
170
645
|
*
|
|
171
646
|
* @example
|
|
172
647
|
* ```tsx
|
|
648
|
+
* const [theme, setTheme] = useState("light")
|
|
649
|
+
*
|
|
173
650
|
* <ContextMenuRadioGroup value={theme} onValueChange={setTheme}>
|
|
174
651
|
* <ContextMenuRadioItem value="light">Light</ContextMenuRadioItem>
|
|
175
652
|
* <ContextMenuRadioItem value="dark">Dark</ContextMenuRadioItem>
|
|
@@ -177,12 +654,27 @@ function ContextMenuSub({
|
|
|
177
654
|
* </ContextMenuRadioGroup>
|
|
178
655
|
* ```
|
|
179
656
|
*
|
|
180
|
-
* @
|
|
181
|
-
*
|
|
657
|
+
* @example
|
|
658
|
+
* ```tsx
|
|
659
|
+
* // With label and separator
|
|
660
|
+
* <ContextMenuContent>
|
|
661
|
+
* <ContextMenuLabel>Theme Selection</ContextMenuLabel>
|
|
662
|
+
* <ContextMenuSeparator />
|
|
663
|
+
* <ContextMenuRadioGroup value={currentTheme} onValueChange={handleThemeChange}>
|
|
664
|
+
* <ContextMenuRadioItem value="light">Light Mode</ContextMenuRadioItem>
|
|
665
|
+
* <ContextMenuRadioItem value="dark">Dark Mode</ContextMenuRadioItem>
|
|
666
|
+
* <ContextMenuRadioItem value="auto">Auto</ContextMenuRadioItem>
|
|
667
|
+
* </ContextMenuRadioGroup>
|
|
668
|
+
* </ContextMenuContent>
|
|
669
|
+
* ```
|
|
670
|
+
*
|
|
671
|
+
* @param value - The currently selected value that matches a RadioItem's value
|
|
672
|
+
* @param onValueChange - Callback fired when selection changes, receives new value
|
|
673
|
+
* @param children - ContextMenuRadioItem components to group together
|
|
182
674
|
*/
|
|
183
|
-
function ContextMenuRadioGroup(
|
|
184
|
-
|
|
185
|
-
|
|
675
|
+
function ContextMenuRadioGroup(
|
|
676
|
+
props: React.ComponentProps<typeof ContextMenuPrimitive.RadioGroup>,
|
|
677
|
+
) {
|
|
186
678
|
return (
|
|
187
679
|
<ContextMenuPrimitive.RadioGroup
|
|
188
680
|
data-slot="context-menu-radio-group"
|
|
@@ -195,7 +687,8 @@ function ContextMenuRadioGroup({
|
|
|
195
687
|
* ContextMenuSubTrigger - Trigger element for opening sub-menus
|
|
196
688
|
*
|
|
197
689
|
* Menu item that opens a sub-menu on hover or focus. Automatically includes
|
|
198
|
-
* a chevron icon to indicate the presence of a sub-menu.
|
|
690
|
+
* a chevron icon to indicate the presence of a sub-menu. Supports the same
|
|
691
|
+
* interaction patterns as regular menu items with additional sub-menu behavior.
|
|
199
692
|
*
|
|
200
693
|
* @example
|
|
201
694
|
* ```tsx
|
|
@@ -205,7 +698,21 @@ function ContextMenuRadioGroup({
|
|
|
205
698
|
* </ContextMenuSubTrigger>
|
|
206
699
|
* ```
|
|
207
700
|
*
|
|
208
|
-
* @
|
|
701
|
+
* @example
|
|
702
|
+
* ```tsx
|
|
703
|
+
* // With inset alignment for icon consistency
|
|
704
|
+
* <ContextMenuContent>
|
|
705
|
+
* <ContextMenuItem inset>Regular Item</ContextMenuItem>
|
|
706
|
+
* <ContextMenuSubTrigger inset>
|
|
707
|
+
* More Actions
|
|
708
|
+
* </ContextMenuSubTrigger>
|
|
709
|
+
* </ContextMenuContent>
|
|
710
|
+
* ```
|
|
711
|
+
*
|
|
712
|
+
* @param asChild - Merges props with child element instead of rendering wrapper
|
|
713
|
+
* @param disabled - Prevents interaction and sub-menu opening
|
|
714
|
+
* @param textValue - Custom text for typeahead navigation
|
|
715
|
+
* @param inset - Whether to indent the trigger for proper visual alignment
|
|
209
716
|
* @param children - Content of the trigger (text, icons, etc.)
|
|
210
717
|
*/
|
|
211
718
|
function ContextMenuSubTrigger({
|
|
@@ -214,7 +721,6 @@ function ContextMenuSubTrigger({
|
|
|
214
721
|
children,
|
|
215
722
|
...props
|
|
216
723
|
}: React.ComponentProps<typeof ContextMenuPrimitive.SubTrigger> & {
|
|
217
|
-
/** Whether to indent the trigger for proper alignment */
|
|
218
724
|
inset?: boolean;
|
|
219
725
|
}) {
|
|
220
726
|
return (
|
|
@@ -237,7 +743,8 @@ function ContextMenuSubTrigger({
|
|
|
237
743
|
* ContextMenuSubContent - Container for sub-menu items
|
|
238
744
|
*
|
|
239
745
|
* Contains the items within a sub-menu. Automatically positioned relative
|
|
240
|
-
* to its trigger with collision detection and smooth animations.
|
|
746
|
+
* to its trigger with collision detection and smooth animations. Supports
|
|
747
|
+
* all the same features as main menu content including keyboard navigation.
|
|
241
748
|
*
|
|
242
749
|
* @example
|
|
243
750
|
* ```tsx
|
|
@@ -249,6 +756,26 @@ function ContextMenuSubTrigger({
|
|
|
249
756
|
* </ContextMenuSubContent>
|
|
250
757
|
* ```
|
|
251
758
|
*
|
|
759
|
+
* @example
|
|
760
|
+
* ```tsx
|
|
761
|
+
* // With portal and collision avoidance
|
|
762
|
+
* <ContextMenuSubContent
|
|
763
|
+
* avoidCollisions={true}
|
|
764
|
+
* sideOffset={8}
|
|
765
|
+
* className="min-w-[200px]"
|
|
766
|
+
* >
|
|
767
|
+
* <ContextMenuLabel>Sub Options</ContextMenuLabel>
|
|
768
|
+
* <ContextMenuItem>Action A</ContextMenuItem>
|
|
769
|
+
* <ContextMenuItem>Action B</ContextMenuItem>
|
|
770
|
+
* </ContextMenuSubContent>
|
|
771
|
+
* ```
|
|
772
|
+
*
|
|
773
|
+
* @param asChild - Merges props with child element instead of rendering wrapper
|
|
774
|
+
* @param loop - Enable keyboard navigation looping from last to first item
|
|
775
|
+
* @param onCloseAutoFocus - Handle focus return when sub-menu closes
|
|
776
|
+
* @param onEscapeKeyDown - Handle escape key presses
|
|
777
|
+
* @param avoidCollisions - Prevent collisions with viewport boundaries
|
|
778
|
+
* @param sideOffset - Distance in pixels from the trigger anchor
|
|
252
779
|
* @param className - Additional CSS classes for styling
|
|
253
780
|
* @param children - Sub-menu items, separators, and labels
|
|
254
781
|
*/
|
|
@@ -272,7 +799,8 @@ function ContextMenuSubContent({
|
|
|
272
799
|
* ContextMenuContent - The container for context menu items
|
|
273
800
|
*
|
|
274
801
|
* Contains all menu items, separators, labels, and sub-menus. Automatically
|
|
275
|
-
* positioned relative to the trigger point with collision detection
|
|
802
|
+
* positioned relative to the trigger point with collision detection and smooth
|
|
803
|
+
* animations. Renders in a portal by default for proper layering.
|
|
276
804
|
*
|
|
277
805
|
* @example
|
|
278
806
|
* ```tsx
|
|
@@ -284,8 +812,29 @@ function ContextMenuSubContent({
|
|
|
284
812
|
* </ContextMenuContent>
|
|
285
813
|
* ```
|
|
286
814
|
*
|
|
815
|
+
* @example
|
|
816
|
+
* ```tsx
|
|
817
|
+
* // With event handlers and positioning
|
|
818
|
+
* <ContextMenuContent
|
|
819
|
+
* onCloseAutoFocus={(e) => e.preventDefault()}
|
|
820
|
+
* onEscapeKeyDown={(e) => console.log('Escape pressed')}
|
|
821
|
+
* avoidCollisions={true}
|
|
822
|
+
* sideOffset={4}
|
|
823
|
+
* loop={true}
|
|
824
|
+
* >
|
|
825
|
+
* <ContextMenuItem>Item 1</ContextMenuItem>
|
|
826
|
+
* <ContextMenuItem>Item 2</ContextMenuItem>
|
|
827
|
+
* </ContextMenuContent>
|
|
828
|
+
* ```
|
|
829
|
+
*
|
|
830
|
+
* @param asChild - Merges props with child element instead of rendering wrapper
|
|
831
|
+
* @param loop - Enable keyboard navigation looping from last to first item
|
|
832
|
+
* @param onCloseAutoFocus - Handle focus return when menu closes
|
|
833
|
+
* @param onEscapeKeyDown - Handle escape key presses
|
|
834
|
+
* @param avoidCollisions - Prevent collisions with viewport boundaries
|
|
835
|
+
* @param sideOffset - Distance in pixels from the cursor/trigger point
|
|
287
836
|
* @param className - Additional CSS classes for styling
|
|
288
|
-
* @param children - Menu items,
|
|
837
|
+
* @param children - Menu items, labels, separators, and sub-menus to display
|
|
289
838
|
*/
|
|
290
839
|
function ContextMenuContent({
|
|
291
840
|
className,
|
|
@@ -310,10 +859,11 @@ function ContextMenuContent({
|
|
|
310
859
|
*
|
|
311
860
|
* Individual menu items that users can interact with. Supports different
|
|
312
861
|
* variants for visual hierarchy and includes automatic icon styling.
|
|
862
|
+
* Items can be clicked, selected via keyboard, and support custom styling.
|
|
313
863
|
*
|
|
314
864
|
* @example
|
|
315
865
|
* ```tsx
|
|
316
|
-
* <ContextMenuItem>
|
|
866
|
+
* <ContextMenuItem onSelect={() => console.log('Edit selected')}>
|
|
317
867
|
* <Edit className="mr-2 h-4 w-4" />
|
|
318
868
|
* Edit
|
|
319
869
|
* <ContextMenuShortcut>⌘E</ContextMenuShortcut>
|
|
@@ -322,16 +872,32 @@ function ContextMenuContent({
|
|
|
322
872
|
*
|
|
323
873
|
* @example
|
|
324
874
|
* ```tsx
|
|
325
|
-
* <ContextMenuItem variant="destructive">
|
|
875
|
+
* <ContextMenuItem variant="destructive" onSelect={handleDelete}>
|
|
326
876
|
* <Trash2 className="mr-2 h-4 w-4" />
|
|
327
877
|
* Delete
|
|
328
878
|
* </ContextMenuItem>
|
|
329
879
|
* ```
|
|
330
880
|
*
|
|
331
|
-
* @
|
|
332
|
-
*
|
|
333
|
-
*
|
|
334
|
-
*
|
|
881
|
+
* @example
|
|
882
|
+
* ```tsx
|
|
883
|
+
* // With custom text value for typeahead
|
|
884
|
+
* <ContextMenuItem
|
|
885
|
+
* textValue="Copy to clipboard"
|
|
886
|
+
* onSelect={handleCopy}
|
|
887
|
+
* >
|
|
888
|
+
* <Copy className="mr-2 h-4 w-4" />
|
|
889
|
+
* Copy <span className="text-muted-foreground">to clipboard</span>
|
|
890
|
+
* </ContextMenuItem>
|
|
891
|
+
* ```
|
|
892
|
+
*
|
|
893
|
+
* @param asChild - Merges props with child element instead of rendering wrapper
|
|
894
|
+
* @param disabled - Prevents interaction and dims the item visually
|
|
895
|
+
* @param onSelect - Callback fired when item is selected (via mouse or keyboard)
|
|
896
|
+
* @param textValue - Custom text for typeahead navigation when content is complex
|
|
897
|
+
* @param inset - Whether to indent the item for alignment with icon-based items
|
|
898
|
+
* @param variant - Visual variant ("default" for normal actions, "destructive" for dangerous actions)
|
|
899
|
+
* @param className - Additional CSS classes for custom styling
|
|
900
|
+
* @param children - Content of the menu item (text, icons, shortcuts, etc.)
|
|
335
901
|
*/
|
|
336
902
|
function ContextMenuItem({
|
|
337
903
|
className,
|
|
@@ -339,9 +905,7 @@ function ContextMenuItem({
|
|
|
339
905
|
variant = "default",
|
|
340
906
|
...props
|
|
341
907
|
}: React.ComponentProps<typeof ContextMenuPrimitive.Item> & {
|
|
342
|
-
/** Whether to indent the item for proper alignment */
|
|
343
908
|
inset?: boolean;
|
|
344
|
-
/** Visual variant for the menu item */
|
|
345
909
|
variant?: "default" | "destructive";
|
|
346
910
|
}) {
|
|
347
911
|
return (
|
|
@@ -362,7 +926,8 @@ function ContextMenuItem({
|
|
|
362
926
|
* ContextMenuCheckboxItem - A menu item with checkbox functionality
|
|
363
927
|
*
|
|
364
928
|
* Menu items that can be toggled on/off, useful for binary settings or options.
|
|
365
|
-
* Displays a check mark when selected and supports controlled state management
|
|
929
|
+
* Displays a check mark when selected and supports controlled state management
|
|
930
|
+
* with indeterminate state for partially selected collections.
|
|
366
931
|
*
|
|
367
932
|
* @example
|
|
368
933
|
* ```tsx
|
|
@@ -376,9 +941,35 @@ function ContextMenuItem({
|
|
|
376
941
|
* </ContextMenuCheckboxItem>
|
|
377
942
|
* ```
|
|
378
943
|
*
|
|
379
|
-
* @
|
|
944
|
+
* @example
|
|
945
|
+
* ```tsx
|
|
946
|
+
* // With indeterminate state
|
|
947
|
+
* const [selectedItems, setSelectedItems] = useState(['item1'])
|
|
948
|
+
* const allItems = ['item1', 'item2', 'item3']
|
|
949
|
+
* const checkedState = selectedItems.length === 0
|
|
950
|
+
* ? false
|
|
951
|
+
* : selectedItems.length === allItems.length
|
|
952
|
+
* ? true
|
|
953
|
+
* : "indeterminate"
|
|
954
|
+
*
|
|
955
|
+
* <ContextMenuCheckboxItem
|
|
956
|
+
* checked={checkedState}
|
|
957
|
+
* onCheckedChange={(checked) =>
|
|
958
|
+
* setSelectedItems(checked ? allItems : [])
|
|
959
|
+
* }
|
|
960
|
+
* >
|
|
961
|
+
* Select All
|
|
962
|
+
* </ContextMenuCheckboxItem>
|
|
963
|
+
* ```
|
|
964
|
+
*
|
|
965
|
+
* @param asChild - Merges props with child element instead of rendering wrapper
|
|
966
|
+
* @param checked - The checked state (true, false, or "indeterminate")
|
|
380
967
|
* @param onCheckedChange - Callback fired when the checked state changes
|
|
381
|
-
* @param disabled - Whether the item is disabled
|
|
968
|
+
* @param disabled - Whether the item is disabled and non-interactive
|
|
969
|
+
* @param onSelect - Callback fired when the item is selected (before onCheckedChange)
|
|
970
|
+
* @param textValue - Custom text for typeahead navigation
|
|
971
|
+
* @param className - Additional CSS classes for styling
|
|
972
|
+
* @param children - Content of the checkbox item (typically text)
|
|
382
973
|
*/
|
|
383
974
|
function ContextMenuCheckboxItem({
|
|
384
975
|
className,
|
|
@@ -411,18 +1002,36 @@ function ContextMenuCheckboxItem({
|
|
|
411
1002
|
*
|
|
412
1003
|
* Menu items that allow single selection from a group of options.
|
|
413
1004
|
* Must be used within a ContextMenuRadioGroup for proper functionality.
|
|
1005
|
+
* Displays a filled circle indicator when selected.
|
|
414
1006
|
*
|
|
415
1007
|
* @example
|
|
416
1008
|
* ```tsx
|
|
417
1009
|
* <ContextMenuRadioGroup value={theme} onValueChange={setTheme}>
|
|
418
|
-
* <ContextMenuRadioItem value="light">Light</ContextMenuRadioItem>
|
|
419
|
-
* <ContextMenuRadioItem value="dark">Dark</ContextMenuRadioItem>
|
|
420
|
-
* <ContextMenuRadioItem value="system">System</ContextMenuRadioItem>
|
|
1010
|
+
* <ContextMenuRadioItem value="light">Light Theme</ContextMenuRadioItem>
|
|
1011
|
+
* <ContextMenuRadioItem value="dark">Dark Theme</ContextMenuRadioItem>
|
|
1012
|
+
* <ContextMenuRadioItem value="system">System Theme</ContextMenuRadioItem>
|
|
1013
|
+
* </ContextMenuRadioGroup>
|
|
1014
|
+
* ```
|
|
1015
|
+
*
|
|
1016
|
+
* @example
|
|
1017
|
+
* ```tsx
|
|
1018
|
+
* // With disabled state and custom text
|
|
1019
|
+
* <ContextMenuRadioGroup value={quality} onValueChange={setQuality}>
|
|
1020
|
+
* <ContextMenuRadioItem value="low">Low Quality</ContextMenuRadioItem>
|
|
1021
|
+
* <ContextMenuRadioItem value="medium">Medium Quality</ContextMenuRadioItem>
|
|
1022
|
+
* <ContextMenuRadioItem value="high">High Quality</ContextMenuRadioItem>
|
|
1023
|
+
* <ContextMenuRadioItem value="ultra" disabled>
|
|
1024
|
+
* Ultra Quality (Premium)
|
|
1025
|
+
* </ContextMenuRadioItem>
|
|
421
1026
|
* </ContextMenuRadioGroup>
|
|
422
1027
|
* ```
|
|
423
1028
|
*
|
|
424
|
-
* @param value - The value
|
|
425
|
-
* @param disabled - Whether the item is disabled
|
|
1029
|
+
* @param value - The unique value for this radio item (required)
|
|
1030
|
+
* @param disabled - Whether the item is disabled and non-interactive
|
|
1031
|
+
* @param onSelect - Callback fired when the item is selected (before parent's onValueChange)
|
|
1032
|
+
* @param textValue - Custom text for typeahead navigation
|
|
1033
|
+
* @param className - Additional CSS classes for styling
|
|
1034
|
+
* @param children - Content of the radio item (typically text)
|
|
426
1035
|
*/
|
|
427
1036
|
function ContextMenuRadioItem({
|
|
428
1037
|
className,
|
|
@@ -453,6 +1062,7 @@ function ContextMenuRadioItem({
|
|
|
453
1062
|
*
|
|
454
1063
|
* Used to group related menu items and provide context. Labels are not
|
|
455
1064
|
* focusable and serve as visual section headers within the menu.
|
|
1065
|
+
* Helps organize menu content and improve accessibility.
|
|
456
1066
|
*
|
|
457
1067
|
* @example
|
|
458
1068
|
* ```tsx
|
|
@@ -462,14 +1072,26 @@ function ContextMenuRadioItem({
|
|
|
462
1072
|
* <ContextMenuItem>Save</ContextMenuItem>
|
|
463
1073
|
* ```
|
|
464
1074
|
*
|
|
1075
|
+
* @example
|
|
1076
|
+
* ```tsx
|
|
1077
|
+
* // With inset alignment for consistency
|
|
1078
|
+
* <ContextMenuContent>
|
|
1079
|
+
* <ContextMenuLabel inset>Edit Options</ContextMenuLabel>
|
|
1080
|
+
* <ContextMenuItem inset>Copy</ContextMenuItem>
|
|
1081
|
+
* <ContextMenuItem inset>Paste</ContextMenuItem>
|
|
1082
|
+
* </ContextMenuContent>
|
|
1083
|
+
* ```
|
|
1084
|
+
*
|
|
1085
|
+
* @param asChild - Merges props with child element instead of rendering wrapper
|
|
465
1086
|
* @param inset - Whether to indent the label to align with inset items
|
|
1087
|
+
* @param className - Additional CSS classes for styling
|
|
1088
|
+
* @param children - The text content of the label
|
|
466
1089
|
*/
|
|
467
1090
|
function ContextMenuLabel({
|
|
468
1091
|
className,
|
|
469
1092
|
inset,
|
|
470
1093
|
...props
|
|
471
1094
|
}: React.ComponentProps<typeof ContextMenuPrimitive.Label> & {
|
|
472
|
-
/** Whether to indent the label for proper alignment */
|
|
473
1095
|
inset?: boolean;
|
|
474
1096
|
}) {
|
|
475
1097
|
return (
|
|
@@ -490,6 +1112,7 @@ function ContextMenuLabel({
|
|
|
490
1112
|
*
|
|
491
1113
|
* Creates visual separation between groups of related menu items.
|
|
492
1114
|
* Typically used after labels or to separate different types of actions.
|
|
1115
|
+
* Improves visual hierarchy and content organization in menus.
|
|
493
1116
|
*
|
|
494
1117
|
* @example
|
|
495
1118
|
* ```tsx
|
|
@@ -498,6 +1121,23 @@ function ContextMenuLabel({
|
|
|
498
1121
|
* <ContextMenuSeparator />
|
|
499
1122
|
* <ContextMenuItem variant="destructive">Delete</ContextMenuItem>
|
|
500
1123
|
* ```
|
|
1124
|
+
*
|
|
1125
|
+
* @example
|
|
1126
|
+
* ```tsx
|
|
1127
|
+
* // Organizing menu sections
|
|
1128
|
+
* <ContextMenuContent>
|
|
1129
|
+
* <ContextMenuLabel>Edit</ContextMenuLabel>
|
|
1130
|
+
* <ContextMenuItem>Copy</ContextMenuItem>
|
|
1131
|
+
* <ContextMenuItem>Paste</ContextMenuItem>
|
|
1132
|
+
* <ContextMenuSeparator />
|
|
1133
|
+
* <ContextMenuLabel>View</ContextMenuLabel>
|
|
1134
|
+
* <ContextMenuItem>Zoom In</ContextMenuItem>
|
|
1135
|
+
* <ContextMenuItem>Zoom Out</ContextMenuItem>
|
|
1136
|
+
* </ContextMenuContent>
|
|
1137
|
+
* ```
|
|
1138
|
+
*
|
|
1139
|
+
* @param asChild - Merges props with child element instead of rendering wrapper
|
|
1140
|
+
* @param className - Additional CSS classes for styling
|
|
501
1141
|
*/
|
|
502
1142
|
function ContextMenuSeparator({
|
|
503
1143
|
className,
|
|
@@ -517,6 +1157,7 @@ function ContextMenuSeparator({
|
|
|
517
1157
|
*
|
|
518
1158
|
* Shows keyboard shortcuts aligned to the right side of menu items.
|
|
519
1159
|
* Provides visual indication of available keyboard shortcuts for actions.
|
|
1160
|
+
* Improves discoverability of keyboard navigation options.
|
|
520
1161
|
*
|
|
521
1162
|
* @example
|
|
522
1163
|
* ```tsx
|
|
@@ -526,7 +1167,28 @@ function ContextMenuSeparator({
|
|
|
526
1167
|
* </ContextMenuItem>
|
|
527
1168
|
* ```
|
|
528
1169
|
*
|
|
529
|
-
* @
|
|
1170
|
+
* @example
|
|
1171
|
+
* ```tsx
|
|
1172
|
+
* // Multiple shortcuts for different platforms
|
|
1173
|
+
* <ContextMenuItem>
|
|
1174
|
+
* Save
|
|
1175
|
+
* <ContextMenuShortcut>
|
|
1176
|
+
* {isMac ? '⌘S' : 'Ctrl+S'}
|
|
1177
|
+
* </ContextMenuShortcut>
|
|
1178
|
+
* </ContextMenuItem>
|
|
1179
|
+
* ```
|
|
1180
|
+
*
|
|
1181
|
+
* @example
|
|
1182
|
+
* ```tsx
|
|
1183
|
+
* // Complex shortcuts
|
|
1184
|
+
* <ContextMenuItem>
|
|
1185
|
+
* Find and Replace
|
|
1186
|
+
* <ContextMenuShortcut>⌘⌥F</ContextMenuShortcut>
|
|
1187
|
+
* </ContextMenuItem>
|
|
1188
|
+
* ```
|
|
1189
|
+
*
|
|
1190
|
+
* @param className - Additional CSS classes for styling
|
|
1191
|
+
* @param children - The keyboard shortcut text to display (e.g., "⌘C", "Ctrl+V")
|
|
530
1192
|
*/
|
|
531
1193
|
function ContextMenuShortcut({
|
|
532
1194
|
className,
|
|
@@ -561,3 +1223,6 @@ export {
|
|
|
561
1223
|
ContextMenuSubTrigger,
|
|
562
1224
|
ContextMenuRadioGroup,
|
|
563
1225
|
};
|
|
1226
|
+
|
|
1227
|
+
// NOTE: Internal documentation types are NOT exported
|
|
1228
|
+
// Components use Radix UI inferred types for implementation
|