@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
|
@@ -3,88 +3,251 @@ import * as React from "react";
|
|
|
3
3
|
import { cn } from "@/lib/utils";
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Props for Input component (Documentation only - NOT used in component implementation)
|
|
7
|
+
* These types are for documentation generation and should not replace HTML input inferred types
|
|
8
|
+
*/
|
|
9
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
10
|
+
type InputDocsProps = {
|
|
11
|
+
/** The type of input field to render - supports all HTML input types @default "text" */
|
|
12
|
+
type?: React.HTMLInputTypeAttribute;
|
|
13
|
+
/** Placeholder text displayed when the input is empty */
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
/** Current value of the input (controlled component) */
|
|
16
|
+
value?: string | ReadonlyArray<string> | number;
|
|
17
|
+
/** Default value for uncontrolled usage */
|
|
18
|
+
defaultValue?: string | ReadonlyArray<string> | number;
|
|
19
|
+
/** Whether the input is disabled and non-interactive @default false */
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
/** Whether the input is required for form validation @default false */
|
|
22
|
+
required?: boolean;
|
|
23
|
+
/** Whether the input is read-only (visible but not editable) @default false */
|
|
24
|
+
readOnly?: boolean;
|
|
25
|
+
/** Unique identifier for the input element (important for accessibility) */
|
|
26
|
+
id?: string;
|
|
27
|
+
/** Name attribute for form submission and validation */
|
|
28
|
+
name?: string;
|
|
29
|
+
/** Auto-complete hint for browsers to improve form filling experience */
|
|
30
|
+
autoComplete?: string;
|
|
31
|
+
/** Whether to focus this input when the component mounts @default false */
|
|
32
|
+
autoFocus?: boolean;
|
|
33
|
+
/** Maximum number of characters allowed in text inputs */
|
|
34
|
+
maxLength?: number;
|
|
35
|
+
/** Minimum number of characters required in text inputs */
|
|
36
|
+
minLength?: number;
|
|
37
|
+
/** Pattern attribute for client-side validation using regular expressions */
|
|
38
|
+
pattern?: string;
|
|
39
|
+
/** Minimum value for numeric input types (number, range, date, etc.) */
|
|
40
|
+
min?: string | number;
|
|
41
|
+
/** Maximum value for numeric input types (number, range, date, etc.) */
|
|
42
|
+
max?: string | number;
|
|
43
|
+
/** Step value for numeric inputs (affects increment/decrement behavior) */
|
|
44
|
+
step?: string | number;
|
|
45
|
+
/** Callback fired when the input value changes */
|
|
46
|
+
onChange?: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
47
|
+
/** Callback fired when the input receives focus */
|
|
48
|
+
onFocus?: (event: React.FocusEvent<HTMLInputElement>) => void;
|
|
49
|
+
/** Callback fired when the input loses focus */
|
|
50
|
+
onBlur?: (event: React.FocusEvent<HTMLInputElement>) => void;
|
|
51
|
+
/** Callback fired when a key is pressed down */
|
|
52
|
+
onKeyDown?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
53
|
+
/** Callback fired when a key is pressed up */
|
|
54
|
+
onKeyUp?: (event: React.KeyboardEvent<HTMLInputElement>) => void;
|
|
55
|
+
/** Indicates whether the input has a validation error @default false */
|
|
56
|
+
"aria-invalid"?: boolean | "false" | "true" | "grammar" | "spelling";
|
|
57
|
+
/** Describes the input for screen readers and assistive technology */
|
|
58
|
+
"aria-describedby"?: string;
|
|
59
|
+
/** Labels the input for screen readers (use with Label component's htmlFor) */
|
|
60
|
+
"aria-labelledby"?: string;
|
|
61
|
+
/** Provides an accessible label when no visible label is present */
|
|
62
|
+
"aria-label"?: string;
|
|
63
|
+
/** Whether the input is required (for screen readers) */
|
|
64
|
+
"aria-required"?: boolean | "false" | "true";
|
|
65
|
+
/** Additional CSS classes for custom styling */
|
|
66
|
+
className?: string;
|
|
67
|
+
} & React.InputHTMLAttributes<HTMLInputElement>;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Input - Versatile form input component for text, email, password, and other input types
|
|
7
71
|
*
|
|
8
|
-
* A flexible input component
|
|
9
|
-
* and
|
|
10
|
-
*
|
|
72
|
+
* A flexible and accessible input component built on native HTML input elements with enhanced
|
|
73
|
+
* styling and form integration capabilities. Supports all HTML input types including text, email,
|
|
74
|
+
* password, number, file, date, and more. Features consistent design tokens, error states, focus
|
|
75
|
+
* management, and seamless integration with form libraries like React Hook Form.
|
|
11
76
|
*
|
|
12
77
|
* @example
|
|
13
78
|
* ```tsx
|
|
14
|
-
* // Basic
|
|
15
|
-
* <Input type="
|
|
79
|
+
* // Basic text input
|
|
80
|
+
* <Input type="text" placeholder="Enter your name" />
|
|
16
81
|
* ```
|
|
17
82
|
*
|
|
18
83
|
* @example
|
|
19
84
|
* ```tsx
|
|
20
|
-
* //
|
|
21
|
-
* <
|
|
22
|
-
*
|
|
23
|
-
*
|
|
85
|
+
* // Email input with validation
|
|
86
|
+
* <Input
|
|
87
|
+
* type="email"
|
|
88
|
+
* placeholder="your@email.com"
|
|
89
|
+
* required
|
|
90
|
+
* aria-describedby="email-error"
|
|
91
|
+
* />
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* ```tsx
|
|
96
|
+
* // Password input with toggle visibility
|
|
97
|
+
* <div className="relative">
|
|
98
|
+
* <Input
|
|
99
|
+
* type="password"
|
|
100
|
+
* placeholder="Enter password"
|
|
101
|
+
* autoComplete="current-password"
|
|
102
|
+
* />
|
|
103
|
+
* <Button
|
|
104
|
+
* type="button"
|
|
105
|
+
* variant="ghost"
|
|
106
|
+
* size="sm"
|
|
107
|
+
* className="absolute right-0 top-0 h-full px-3"
|
|
108
|
+
* >
|
|
109
|
+
* <Eye className="h-4 w-4" />
|
|
110
|
+
* </Button>
|
|
24
111
|
* </div>
|
|
25
112
|
* ```
|
|
26
113
|
*
|
|
27
114
|
* @example
|
|
28
115
|
* ```tsx
|
|
116
|
+
* // Number input with min/max constraints
|
|
117
|
+
* <Input
|
|
118
|
+
* type="number"
|
|
119
|
+
* placeholder="Age"
|
|
120
|
+
* min={0}
|
|
121
|
+
* max={120}
|
|
122
|
+
* step={1}
|
|
123
|
+
* />
|
|
124
|
+
* ```
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* ```tsx
|
|
29
128
|
* // File input with proper labeling
|
|
30
129
|
* <div className="grid w-full max-w-sm items-center gap-1.5">
|
|
31
|
-
* <Label htmlFor="picture">Picture</Label>
|
|
32
|
-
* <Input
|
|
130
|
+
* <Label htmlFor="picture">Profile Picture</Label>
|
|
131
|
+
* <Input
|
|
132
|
+
* id="picture"
|
|
133
|
+
* type="file"
|
|
134
|
+
* accept="image/*"
|
|
135
|
+
* aria-describedby="file-help"
|
|
136
|
+
* />
|
|
137
|
+
* <p id="file-help" className="text-sm text-muted-foreground">
|
|
138
|
+
* Upload a PNG, JPG or GIF (max 5MB)
|
|
139
|
+
* </p>
|
|
33
140
|
* </div>
|
|
34
141
|
* ```
|
|
35
142
|
*
|
|
36
143
|
* @example
|
|
37
144
|
* ```tsx
|
|
38
|
-
* //
|
|
39
|
-
* <
|
|
145
|
+
* // Search input with icon
|
|
146
|
+
* <div className="relative">
|
|
147
|
+
* <Search className="absolute left-2 top-1/2 h-4 w-4 -translate-y-1/2 transform text-muted-foreground" />
|
|
148
|
+
* <Input
|
|
149
|
+
* type="search"
|
|
150
|
+
* placeholder="Search..."
|
|
151
|
+
* className="pl-8"
|
|
152
|
+
* />
|
|
153
|
+
* </div>
|
|
40
154
|
* ```
|
|
41
155
|
*
|
|
42
156
|
* @example
|
|
43
157
|
* ```tsx
|
|
44
|
-
* // Input with
|
|
45
|
-
* <div className="
|
|
46
|
-
* <
|
|
47
|
-
* <
|
|
158
|
+
* // Input with error state
|
|
159
|
+
* <div className="space-y-2">
|
|
160
|
+
* <Label htmlFor="email">Email</Label>
|
|
161
|
+
* <Input
|
|
162
|
+
* id="email"
|
|
163
|
+
* type="email"
|
|
164
|
+
* aria-invalid={true}
|
|
165
|
+
* aria-describedby="email-error"
|
|
166
|
+
* />
|
|
167
|
+
* <p id="email-error" className="text-sm text-destructive">
|
|
168
|
+
* Please enter a valid email address
|
|
169
|
+
* </p>
|
|
48
170
|
* </div>
|
|
49
171
|
* ```
|
|
50
172
|
*
|
|
51
173
|
* @example
|
|
52
174
|
* ```tsx
|
|
53
175
|
* // Form integration with React Hook Form
|
|
54
|
-
* const
|
|
176
|
+
* const { register, formState: { errors } } = useForm();
|
|
55
177
|
*
|
|
56
|
-
* <
|
|
57
|
-
* <
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* <FormControl>
|
|
64
|
-
* <Input placeholder="shadcn" {...field} />
|
|
65
|
-
* </FormControl>
|
|
66
|
-
* <FormMessage />
|
|
67
|
-
* </FormItem>
|
|
68
|
-
* )}
|
|
178
|
+
* <div className="space-y-2">
|
|
179
|
+
* <Label htmlFor="username">Username</Label>
|
|
180
|
+
* <Input
|
|
181
|
+
* id="username"
|
|
182
|
+
* {...register("username", { required: "Username is required" })}
|
|
183
|
+
* aria-invalid={!!errors.username}
|
|
184
|
+
* aria-describedby={errors.username ? "username-error" : undefined}
|
|
69
185
|
* />
|
|
70
|
-
*
|
|
186
|
+
* {errors.username && (
|
|
187
|
+
* <p id="username-error" className="text-sm text-destructive">
|
|
188
|
+
* {errors.username.message}
|
|
189
|
+
* </p>
|
|
190
|
+
* )}
|
|
191
|
+
* </div>
|
|
71
192
|
* ```
|
|
72
193
|
*
|
|
73
|
-
* @
|
|
74
|
-
*
|
|
75
|
-
*
|
|
194
|
+
* @example
|
|
195
|
+
* ```tsx
|
|
196
|
+
* // Input with button (subscription form)
|
|
197
|
+
* <div className="flex w-full max-w-sm items-center space-x-2">
|
|
198
|
+
* <Input
|
|
199
|
+
* type="email"
|
|
200
|
+
* placeholder="Enter your email"
|
|
201
|
+
* aria-label="Email for newsletter"
|
|
202
|
+
* />
|
|
203
|
+
* <Button type="submit">Subscribe</Button>
|
|
204
|
+
* </div>
|
|
205
|
+
* ```
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* ```tsx
|
|
209
|
+
* // Disabled input with explanation
|
|
210
|
+
* <div className="space-y-2">
|
|
211
|
+
* <Label htmlFor="readonly-field">System Generated ID</Label>
|
|
212
|
+
* <Input
|
|
213
|
+
* id="readonly-field"
|
|
214
|
+
* value="SYS-12345"
|
|
215
|
+
* disabled
|
|
216
|
+
* aria-describedby="readonly-help"
|
|
217
|
+
* />
|
|
218
|
+
* <p id="readonly-help" className="text-sm text-muted-foreground">
|
|
219
|
+
* This value is automatically generated and cannot be edited
|
|
220
|
+
* </p>
|
|
221
|
+
* </div>
|
|
222
|
+
* ```
|
|
76
223
|
*
|
|
77
224
|
* @accessibility
|
|
78
|
-
* -
|
|
79
|
-
* -
|
|
225
|
+
* - Provides proper focus management with visible focus ring (focus-visible:ring-ring/50)
|
|
226
|
+
* - Supports all ARIA attributes including aria-invalid for error state indication
|
|
80
227
|
* - Compatible with screen readers and assistive technologies
|
|
81
|
-
* -
|
|
82
|
-
* - Disabled state prevents interaction and
|
|
228
|
+
* - Maintains proper tab order and keyboard navigation patterns
|
|
229
|
+
* - Disabled state prevents interaction and is announced to screen readers
|
|
230
|
+
* - File inputs provide accessible file selection with proper labeling
|
|
231
|
+
* - Error states are properly associated with inputs via aria-describedby
|
|
232
|
+
* - Required fields can be marked with aria-required for screen reader users
|
|
233
|
+
* - Placeholder text provides input guidance but doesn't replace proper labels
|
|
234
|
+
* - Text selection has optimized contrast with custom selection colors
|
|
235
|
+
*
|
|
236
|
+
* @styling
|
|
237
|
+
* - Uses consistent design tokens from the design system
|
|
238
|
+
* - Adaptive height (h-9) with responsive text sizing (md:text-sm)
|
|
239
|
+
* - Smooth transitions for focus states and interactions
|
|
240
|
+
* - Custom file input styling that matches the design system
|
|
241
|
+
* - Error state styling with destructive border and focus ring colors
|
|
242
|
+
* - Dark mode support with semi-transparent background (dark:bg-input/30)
|
|
243
|
+
* - Proper spacing and typography hierarchy for form layouts
|
|
83
244
|
*
|
|
84
|
-
* @see {@link https://ui.shadcn.com/docs/components/input}
|
|
85
|
-
* @see {@link
|
|
86
|
-
* @see {@link
|
|
87
|
-
* @see {@link
|
|
245
|
+
* @see {@link https://ui.shadcn.com/docs/components/input} shadcn/ui Input documentation
|
|
246
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input} MDN Input element reference
|
|
247
|
+
* @see {@link Label} For accessible input labels and proper association
|
|
248
|
+
* @see {@link Button} Often used alongside inputs in forms and search interfaces
|
|
249
|
+
* @see {@link Form} Complete form integration with validation and error handling
|
|
250
|
+
* @see {@link Textarea} For multi-line text input needs
|
|
88
251
|
* @since 1.0.0
|
|
89
252
|
*/
|
|
90
253
|
function Input({ className, type, ...props }: React.ComponentProps<"input">) {
|
|
@@ -3,6 +3,104 @@ import * as LabelPrimitive from "@radix-ui/react-label";
|
|
|
3
3
|
|
|
4
4
|
import { cn } from "@/lib/utils";
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Props for Label (Documentation only - NOT used in component implementation)
|
|
8
|
+
* These types are for documentation generation and should not replace Radix inferred types
|
|
9
|
+
*/
|
|
10
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
11
|
+
type LabelDocsProps = {
|
|
12
|
+
/**
|
|
13
|
+
* Additional CSS classes to apply to the label element.
|
|
14
|
+
* Merged with default styling using cn() utility.
|
|
15
|
+
* @example className="text-lg font-bold"
|
|
16
|
+
*/
|
|
17
|
+
className?: string;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* The id of the form control this label is associated with.
|
|
21
|
+
* Creates semantic association between label and control for accessibility.
|
|
22
|
+
* When clicked, will focus the associated form element.
|
|
23
|
+
* @example htmlFor="email-input"
|
|
24
|
+
*/
|
|
25
|
+
htmlFor?: string;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The content to display inside the label.
|
|
29
|
+
* Can be text, React elements, or other components.
|
|
30
|
+
* @example children="Email Address"
|
|
31
|
+
*/
|
|
32
|
+
children?: React.ReactNode;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* When true, merges props and behavior with the child element instead of rendering a label.
|
|
36
|
+
* Useful for composition with other components while maintaining label semantics.
|
|
37
|
+
* @default false
|
|
38
|
+
* @example <Label asChild><Text>Custom Label</Text></Label>
|
|
39
|
+
*/
|
|
40
|
+
asChild?: boolean;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Event handler called when the label is clicked.
|
|
44
|
+
* The associated form control will also receive focus automatically.
|
|
45
|
+
* @param event - The mouse event
|
|
46
|
+
*/
|
|
47
|
+
onClick?: React.MouseEventHandler<HTMLLabelElement>;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Event handler called when a key is pressed while the label has focus.
|
|
51
|
+
* @param event - The keyboard event
|
|
52
|
+
*/
|
|
53
|
+
onKeyDown?: React.KeyboardEventHandler<HTMLLabelElement>;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Unique identifier for the label element.
|
|
57
|
+
* Different from htmlFor, which references the associated control's id.
|
|
58
|
+
* @example id="username-label"
|
|
59
|
+
*/
|
|
60
|
+
id?: string;
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Inline styles to apply to the label element.
|
|
64
|
+
* @example style={{ color: 'red', fontWeight: 'bold' }}
|
|
65
|
+
*/
|
|
66
|
+
style?: React.CSSProperties;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* The tab index of the label element.
|
|
70
|
+
* Generally not needed as labels are not typically focusable.
|
|
71
|
+
* @default undefined
|
|
72
|
+
*/
|
|
73
|
+
tabIndex?: number;
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
* ARIA label for the element when the content is not descriptive enough.
|
|
77
|
+
* Provides accessible name when children contain only icons or symbols.
|
|
78
|
+
* @example aria-label="Required field"
|
|
79
|
+
*/
|
|
80
|
+
"aria-label"?: string;
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* References to other elements that describe this label.
|
|
84
|
+
* Space-separated list of element IDs.
|
|
85
|
+
* @example aria-describedby="help-text error-message"
|
|
86
|
+
*/
|
|
87
|
+
"aria-describedby"?: string;
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Indicates if the associated form control has an error.
|
|
91
|
+
* Used by screen readers to announce validation state.
|
|
92
|
+
* @example aria-invalid={hasError}
|
|
93
|
+
*/
|
|
94
|
+
"aria-invalid"?: boolean;
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Indicates if the associated form control is required.
|
|
98
|
+
* Announces to screen readers that the field must be filled.
|
|
99
|
+
* @example aria-required={true}
|
|
100
|
+
*/
|
|
101
|
+
"aria-required"?: boolean;
|
|
102
|
+
} & React.HTMLAttributes<HTMLLabelElement>;
|
|
103
|
+
|
|
6
104
|
/**
|
|
7
105
|
* Label component for form controls with full accessibility support
|
|
8
106
|
*
|
|
@@ -83,14 +181,6 @@ import { cn } from "@/lib/utils";
|
|
|
83
181
|
* @see {@link https://www.w3.org/WAI/tutorials/forms/labels/} - W3C Label best practices
|
|
84
182
|
* @since 1.0.0
|
|
85
183
|
*/
|
|
86
|
-
/**
|
|
87
|
-
* Label component props extending Radix UI Label Root props
|
|
88
|
-
*
|
|
89
|
-
* @param className - Additional CSS classes to apply to the label
|
|
90
|
-
* @param htmlFor - The id of the form element this label is associated with
|
|
91
|
-
* @param children - The label content (text, elements, or components)
|
|
92
|
-
* @param ...props - All other props are forwarded to the underlying Radix Label component
|
|
93
|
-
*/
|
|
94
184
|
function Label({
|
|
95
185
|
className,
|
|
96
186
|
...props
|