@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
|
@@ -77,6 +77,227 @@ export type ChartConfig = {
|
|
|
77
77
|
);
|
|
78
78
|
};
|
|
79
79
|
|
|
80
|
+
/**
|
|
81
|
+
* Props for ChartContainer component (Documentation only - NOT used in component implementation)
|
|
82
|
+
* These types are for documentation generation and should not replace inferred types
|
|
83
|
+
*/
|
|
84
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
85
|
+
type ChartContainerDocsProps = {
|
|
86
|
+
/** Chart configuration defining series labels, colors, and icons */
|
|
87
|
+
config: ChartConfig;
|
|
88
|
+
/** Recharts component(s) to render within the responsive container */
|
|
89
|
+
children: React.ComponentProps<
|
|
90
|
+
typeof RechartsPrimitive.ResponsiveContainer
|
|
91
|
+
>["children"];
|
|
92
|
+
/** Unique identifier for the chart instance @default Generated unique ID */
|
|
93
|
+
id?: string;
|
|
94
|
+
/** Additional CSS classes for styling */
|
|
95
|
+
className?: string;
|
|
96
|
+
/** Inline styles for the container */
|
|
97
|
+
style?: React.CSSProperties;
|
|
98
|
+
/** ARIA label for accessibility */
|
|
99
|
+
"aria-label"?: string;
|
|
100
|
+
/** ARIA description for accessibility */
|
|
101
|
+
"aria-describedby"?: string;
|
|
102
|
+
} & Omit<React.ComponentProps<"div">, "children">;
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Props for ChartTooltip component (Documentation only - NOT used in component implementation)
|
|
106
|
+
* These types are for documentation generation and should not replace Recharts inferred types
|
|
107
|
+
*/
|
|
108
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
109
|
+
type ChartTooltipDocsProps = {
|
|
110
|
+
/** Custom content component for tooltip display */
|
|
111
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
112
|
+
content?: React.ComponentType<any> | React.ReactElement;
|
|
113
|
+
/** Whether the tooltip is currently active/visible @default false */
|
|
114
|
+
active?: boolean;
|
|
115
|
+
/** Array of data objects to display in tooltip */
|
|
116
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
117
|
+
payload?: any[];
|
|
118
|
+
/** Label value for current tooltip position (typically x-axis value) */
|
|
119
|
+
label?: string | number;
|
|
120
|
+
/** Function to format tooltip content */
|
|
121
|
+
formatter?: (
|
|
122
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
123
|
+
value: any,
|
|
124
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
125
|
+
name: any,
|
|
126
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
127
|
+
props: any,
|
|
128
|
+
) => [React.ReactNode, React.ReactNode] | React.ReactNode;
|
|
129
|
+
/** Function to format the tooltip label */
|
|
130
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
131
|
+
labelFormatter?: (label: any, payload: any[]) => React.ReactNode;
|
|
132
|
+
/** Custom cursor component or cursor configuration @default true */
|
|
133
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
134
|
+
cursor?: boolean | React.ComponentType<any> | React.ReactElement | object;
|
|
135
|
+
/** Custom position for tooltip placement */
|
|
136
|
+
position?: { x?: number; y?: number };
|
|
137
|
+
/** Distance from cursor/data point @default 10 */
|
|
138
|
+
offset?: number;
|
|
139
|
+
/** Whether tooltip shares data across all series @default Varies by chart type */
|
|
140
|
+
shared?: boolean;
|
|
141
|
+
/** Portal element to render tooltip outside chart container */
|
|
142
|
+
portal?: HTMLElement;
|
|
143
|
+
/** Wrapper styling for tooltip container */
|
|
144
|
+
wrapperStyle?: React.CSSProperties;
|
|
145
|
+
/** CSS class name for tooltip wrapper */
|
|
146
|
+
wrapperClassName?: string;
|
|
147
|
+
/** Animation duration in milliseconds @default 400 */
|
|
148
|
+
animationDuration?: number;
|
|
149
|
+
/** Animation easing function @default "ease" */
|
|
150
|
+
animationEasing?: string;
|
|
151
|
+
/** Whether tooltip is allowed to escape chart boundaries @default false */
|
|
152
|
+
allowEscapeViewBox?: { x?: boolean; y?: boolean };
|
|
153
|
+
/** Separator character between name and value @default " : " */
|
|
154
|
+
separator?: string;
|
|
155
|
+
/** Whether to use HTML for tooltip content @default false */
|
|
156
|
+
useTranslate3d?: boolean;
|
|
157
|
+
/** Custom coordinate for tooltip positioning */
|
|
158
|
+
coordinate?: { x?: number; y?: number };
|
|
159
|
+
/** Filter function for payload items */
|
|
160
|
+
filterNull?: boolean;
|
|
161
|
+
/** Custom item sorting function */
|
|
162
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
163
|
+
itemSorter?: (item: any) => number;
|
|
164
|
+
/** Style for individual tooltip items */
|
|
165
|
+
itemStyle?: React.CSSProperties;
|
|
166
|
+
/** Style for tooltip labels */
|
|
167
|
+
labelStyle?: React.CSSProperties;
|
|
168
|
+
/** Style for tooltip content wrapper */
|
|
169
|
+
contentStyle?: React.CSSProperties;
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Props for ChartTooltipContent component (Documentation only - NOT used in component implementation)
|
|
174
|
+
* These types are for documentation generation and should not replace inferred types
|
|
175
|
+
*/
|
|
176
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
177
|
+
type ChartTooltipContentDocsProps = {
|
|
178
|
+
/** Whether to hide the label section of the tooltip @default false */
|
|
179
|
+
hideLabel?: boolean;
|
|
180
|
+
/** Whether to hide the color indicator for each data series @default false */
|
|
181
|
+
hideIndicator?: boolean;
|
|
182
|
+
/** Style of the color indicator shown for each series @default "dot" */
|
|
183
|
+
indicator?: "line" | "dot" | "dashed";
|
|
184
|
+
/** Key to use for extracting the name from payload data */
|
|
185
|
+
nameKey?: string;
|
|
186
|
+
/** Key to use for extracting the label from payload data */
|
|
187
|
+
labelKey?: string;
|
|
188
|
+
/** Whether the tooltip is currently active/visible */
|
|
189
|
+
active?: boolean;
|
|
190
|
+
/** Array of data objects to display in tooltip */
|
|
191
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
192
|
+
payload?: any[];
|
|
193
|
+
/** Additional CSS classes for styling */
|
|
194
|
+
className?: string;
|
|
195
|
+
/** Label value for current tooltip position */
|
|
196
|
+
label?: string | number;
|
|
197
|
+
/** Function to format tooltip content */
|
|
198
|
+
formatter?: (
|
|
199
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
200
|
+
value: any,
|
|
201
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
202
|
+
name: any,
|
|
203
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
204
|
+
props: any,
|
|
205
|
+
) => [React.ReactNode, React.ReactNode] | React.ReactNode;
|
|
206
|
+
/** Function to format the tooltip label */
|
|
207
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
208
|
+
labelFormatter?: (label: any, payload: any[]) => React.ReactNode;
|
|
209
|
+
/** CSS class name for label styling */
|
|
210
|
+
labelClassName?: string;
|
|
211
|
+
/** Color override for indicators */
|
|
212
|
+
color?: string;
|
|
213
|
+
} & React.ComponentProps<"div">;
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* Props for ChartLegend component (Documentation only - NOT used in component implementation)
|
|
217
|
+
* These types are for documentation generation and should not replace Recharts inferred types
|
|
218
|
+
*/
|
|
219
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
220
|
+
type ChartLegendDocsProps = {
|
|
221
|
+
/** Custom content component for legend display */
|
|
222
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
223
|
+
content?: React.ComponentType<any> | React.ReactElement;
|
|
224
|
+
/** Array of legend items to display */
|
|
225
|
+
payload?: Array<{
|
|
226
|
+
value: string;
|
|
227
|
+
type?: string;
|
|
228
|
+
color?: string;
|
|
229
|
+
dataKey?: string;
|
|
230
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
231
|
+
payload?: any;
|
|
232
|
+
}>;
|
|
233
|
+
/** Horizontal alignment of legend @default "center" */
|
|
234
|
+
align?: "left" | "center" | "right";
|
|
235
|
+
/** Vertical alignment of legend @default "bottom" */
|
|
236
|
+
verticalAlign?: "top" | "middle" | "bottom";
|
|
237
|
+
/** Height reserved for legend in pixels */
|
|
238
|
+
height?: number;
|
|
239
|
+
/** Width reserved for legend in pixels */
|
|
240
|
+
width?: number;
|
|
241
|
+
/** Wrapper styling for legend container */
|
|
242
|
+
wrapperStyle?: React.CSSProperties;
|
|
243
|
+
/** CSS class name for legend wrapper */
|
|
244
|
+
wrapperClassName?: string;
|
|
245
|
+
/** Layout direction for legend items @default "horizontal" */
|
|
246
|
+
layout?: "horizontal" | "vertical";
|
|
247
|
+
/** Size of legend icons in pixels @default 14 */
|
|
248
|
+
iconSize?: number;
|
|
249
|
+
/** Type of legend icons @default "rect" */
|
|
250
|
+
iconType?:
|
|
251
|
+
| "line"
|
|
252
|
+
| "rect"
|
|
253
|
+
| "circle"
|
|
254
|
+
| "cross"
|
|
255
|
+
| "diamond"
|
|
256
|
+
| "square"
|
|
257
|
+
| "star"
|
|
258
|
+
| "triangle"
|
|
259
|
+
| "wye";
|
|
260
|
+
/** Margin around legend container */
|
|
261
|
+
margin?: { top?: number; right?: number; bottom?: number; left?: number };
|
|
262
|
+
/** Click handler for legend items */
|
|
263
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
264
|
+
onClick?: (data: any, index: number, event: React.MouseEvent) => void;
|
|
265
|
+
/** Mouse enter handler for legend items */
|
|
266
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
267
|
+
onMouseEnter?: (data: any, index: number, event: React.MouseEvent) => void;
|
|
268
|
+
/** Mouse leave handler for legend items */
|
|
269
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
270
|
+
onMouseLeave?: (data: any, index: number, event: React.MouseEvent) => void;
|
|
271
|
+
/** Function to format legend content */
|
|
272
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
273
|
+
formatter?: (value: any, entry: any, index: number) => React.ReactNode;
|
|
274
|
+
};
|
|
275
|
+
|
|
276
|
+
/**
|
|
277
|
+
* Props for ChartLegendContent component (Documentation only - NOT used in component implementation)
|
|
278
|
+
* These types are for documentation generation and should not replace inferred types
|
|
279
|
+
*/
|
|
280
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
281
|
+
type ChartLegendContentDocsProps = {
|
|
282
|
+
/** Whether to hide series icons from the chart configuration @default false */
|
|
283
|
+
hideIcon?: boolean;
|
|
284
|
+
/** Key to use for extracting the name from payload data */
|
|
285
|
+
nameKey?: string;
|
|
286
|
+
/** Array of legend items to display */
|
|
287
|
+
payload?: Array<{
|
|
288
|
+
value: string;
|
|
289
|
+
type?: string;
|
|
290
|
+
color?: string;
|
|
291
|
+
dataKey?: string;
|
|
292
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
293
|
+
payload?: any;
|
|
294
|
+
}>;
|
|
295
|
+
/** Vertical alignment for automatic padding adjustment @default "bottom" */
|
|
296
|
+
verticalAlign?: "top" | "middle" | "bottom";
|
|
297
|
+
/** Additional CSS classes for styling */
|
|
298
|
+
className?: string;
|
|
299
|
+
} & React.ComponentProps<"div">;
|
|
300
|
+
|
|
80
301
|
type ChartContextProps = {
|
|
81
302
|
config: ChartConfig;
|
|
82
303
|
};
|
|
@@ -557,7 +778,7 @@ function ChartTooltipContent({
|
|
|
557
778
|
!hideIndicator && (
|
|
558
779
|
<div
|
|
559
780
|
className={cn(
|
|
560
|
-
"shrink-0 rounded-[2px] border-
|
|
781
|
+
"shrink-0 rounded-[2px] border-border bg-background",
|
|
561
782
|
{
|
|
562
783
|
"h-2.5 w-2.5": indicator === "dot",
|
|
563
784
|
"w-1": indicator === "line",
|
|
@@ -4,6 +4,72 @@ import { CheckIcon } from "lucide-react";
|
|
|
4
4
|
|
|
5
5
|
import { cn } from "@/lib/utils";
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Props for Checkbox component (Documentation only - NOT used in component implementation)
|
|
9
|
+
* These types are for documentation generation and should not replace Radix inferred types
|
|
10
|
+
*/
|
|
11
|
+
// eslint-disable-next-line unused-imports/no-unused-vars
|
|
12
|
+
type CheckboxDocsProps = {
|
|
13
|
+
/** Additional CSS classes to apply to the checkbox */
|
|
14
|
+
className?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Change the default rendered element for the one passed as a child,
|
|
17
|
+
* merging their props and behavior. Enables composition patterns.
|
|
18
|
+
* @default false
|
|
19
|
+
*/
|
|
20
|
+
asChild?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* The controlled checked state of the checkbox.
|
|
23
|
+
* Can be true (checked), false (unchecked), or "indeterminate" (partial selection).
|
|
24
|
+
* Use with onCheckedChange for controlled behavior.
|
|
25
|
+
*/
|
|
26
|
+
checked?: boolean | "indeterminate";
|
|
27
|
+
/**
|
|
28
|
+
* The checked state of the checkbox when it is initially rendered.
|
|
29
|
+
* Use when you do not need to control the checked state.
|
|
30
|
+
* Can be true, false, or "indeterminate" for initial state.
|
|
31
|
+
*/
|
|
32
|
+
defaultChecked?: boolean | "indeterminate";
|
|
33
|
+
/**
|
|
34
|
+
* Event handler called when the checked state of the checkbox changes.
|
|
35
|
+
* Receives the new checked state as a parameter.
|
|
36
|
+
*/
|
|
37
|
+
onCheckedChange?: (checked: boolean | "indeterminate") => void;
|
|
38
|
+
/**
|
|
39
|
+
* When true, prevents the user from interacting with the checkbox.
|
|
40
|
+
* The checkbox will be rendered with disabled styling and cannot receive focus.
|
|
41
|
+
*/
|
|
42
|
+
disabled?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* When true, indicates that the user must check the checkbox before form submission.
|
|
45
|
+
* This adds HTML5 form validation and appropriate ARIA attributes.
|
|
46
|
+
*/
|
|
47
|
+
required?: boolean;
|
|
48
|
+
/**
|
|
49
|
+
* The name of the checkbox field. Submitted with its owning form as part of form data.
|
|
50
|
+
* Essential for form handling and server-side processing.
|
|
51
|
+
*/
|
|
52
|
+
name?: string;
|
|
53
|
+
/**
|
|
54
|
+
* The value given as data when submitted with a name in a form.
|
|
55
|
+
* @default "on"
|
|
56
|
+
*/
|
|
57
|
+
value?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Unique identifier for the checkbox. Should be used with Label htmlFor prop
|
|
60
|
+
* for proper accessibility and click handling.
|
|
61
|
+
*/
|
|
62
|
+
id?: string;
|
|
63
|
+
/** ARIA label for accessibility when no visible label is present */
|
|
64
|
+
"aria-label"?: string;
|
|
65
|
+
/** ID of an element that labels this checkbox for screen readers */
|
|
66
|
+
"aria-labelledby"?: string;
|
|
67
|
+
/** ID of an element that describes this checkbox for additional context */
|
|
68
|
+
"aria-describedby"?: string;
|
|
69
|
+
/** Indicates whether the checkbox has a validation error for screen readers */
|
|
70
|
+
"aria-invalid"?: boolean | "false" | "true" | "grammar" | "spelling";
|
|
71
|
+
} & React.HTMLAttributes<HTMLButtonElement>;
|
|
72
|
+
|
|
7
73
|
/**
|
|
8
74
|
* A versatile checkbox component for binary and multi-selection interfaces
|
|
9
75
|
*
|
|
@@ -12,7 +78,11 @@ import { cn } from "@/lib/utils";
|
|
|
12
78
|
* and comprehensive form integration. Features consistent styling with the design
|
|
13
79
|
* system and proper keyboard navigation.
|
|
14
80
|
*
|
|
15
|
-
*
|
|
81
|
+
* The component automatically renders a hidden input element when used within a form
|
|
82
|
+
* to ensure proper form submission and native validation support. Supports three states:
|
|
83
|
+
* checked (true), unchecked (false), and indeterminate for partial selections.
|
|
84
|
+
*
|
|
85
|
+
* @example Basic usage with Label
|
|
16
86
|
* ```tsx
|
|
17
87
|
* <div className="flex items-center space-x-2">
|
|
18
88
|
* <Checkbox id="terms" />
|
|
@@ -37,55 +107,123 @@ import { cn } from "@/lib/utils";
|
|
|
37
107
|
* @example Indeterminate state for parent-child relationships
|
|
38
108
|
* ```tsx
|
|
39
109
|
* const [parentState, setParentState] = useState("indeterminate");
|
|
110
|
+
* const [childStates, setChildStates] = useState([true, false, true]);
|
|
40
111
|
*
|
|
41
|
-
* <
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
112
|
+
* <div className="space-y-2">
|
|
113
|
+
* <div className="flex items-center space-x-2">
|
|
114
|
+
* <Checkbox
|
|
115
|
+
* id="parent"
|
|
116
|
+
* checked={parentState}
|
|
117
|
+
* onCheckedChange={(checked) => {
|
|
118
|
+
* setParentState(checked);
|
|
119
|
+
* if (checked === true) {
|
|
120
|
+
* setChildStates([true, true, true]);
|
|
121
|
+
* } else if (checked === false) {
|
|
122
|
+
* setChildStates([false, false, false]);
|
|
123
|
+
* }
|
|
124
|
+
* }}
|
|
125
|
+
* />
|
|
126
|
+
* <Label htmlFor="parent">Select all options</Label>
|
|
127
|
+
* </div>
|
|
128
|
+
* {childStates.map((childChecked, index) => (
|
|
129
|
+
* <div key={index} className="flex items-center space-x-2 ml-6">
|
|
130
|
+
* <Checkbox
|
|
131
|
+
* id={`child-${index}`}
|
|
132
|
+
* checked={childChecked}
|
|
133
|
+
* onCheckedChange={(checked) => {
|
|
134
|
+
* const newStates = [...childStates];
|
|
135
|
+
* newStates[index] = checked;
|
|
136
|
+
* setChildStates(newStates);
|
|
137
|
+
* // Update parent based on child states
|
|
138
|
+
* const checkedCount = newStates.filter(Boolean).length;
|
|
139
|
+
* if (checkedCount === 0) setParentState(false);
|
|
140
|
+
* else if (checkedCount === newStates.length) setParentState(true);
|
|
141
|
+
* else setParentState("indeterminate");
|
|
142
|
+
* }}
|
|
143
|
+
* />
|
|
144
|
+
* <Label htmlFor={`child-${index}`}>Option {index + 1}</Label>
|
|
145
|
+
* </div>
|
|
146
|
+
* ))}
|
|
147
|
+
* </div>
|
|
48
148
|
* ```
|
|
49
149
|
*
|
|
50
150
|
* @example Form integration with multiple selections
|
|
51
151
|
* ```tsx
|
|
52
152
|
* const [preferences, setPreferences] = useState([]);
|
|
153
|
+
* const options = [
|
|
154
|
+
* { id: "email", label: "Email notifications", value: "email" },
|
|
155
|
+
* { id: "sms", label: "SMS notifications", value: "sms" },
|
|
156
|
+
* { id: "push", label: "Push notifications", value: "push" }
|
|
157
|
+
* ];
|
|
53
158
|
*
|
|
54
|
-
* {
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
*
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
159
|
+
* <form onSubmit={(e) => {
|
|
160
|
+
* e.preventDefault();
|
|
161
|
+
* const formData = new FormData(e.currentTarget);
|
|
162
|
+
* console.log(formData.getAll("preferences"));
|
|
163
|
+
* }}>
|
|
164
|
+
* <fieldset className="space-y-3">
|
|
165
|
+
* <legend className="text-sm font-medium">Notification Preferences</legend>
|
|
166
|
+
* {options.map((option) => (
|
|
167
|
+
* <div key={option.id} className="flex items-center space-x-2">
|
|
168
|
+
* <Checkbox
|
|
169
|
+
* id={option.id}
|
|
170
|
+
* name="preferences"
|
|
171
|
+
* value={option.value}
|
|
172
|
+
* checked={preferences.includes(option.id)}
|
|
173
|
+
* onCheckedChange={(checked) => {
|
|
174
|
+
* setPreferences(prev =>
|
|
175
|
+
* checked
|
|
176
|
+
* ? [...prev, option.id]
|
|
177
|
+
* : prev.filter(id => id !== option.id)
|
|
178
|
+
* );
|
|
179
|
+
* }}
|
|
180
|
+
* />
|
|
181
|
+
* <Label htmlFor={option.id}>{option.label}</Label>
|
|
182
|
+
* </div>
|
|
183
|
+
* ))}
|
|
184
|
+
* </fieldset>
|
|
185
|
+
* <button type="submit" className="mt-4">Save Preferences</button>
|
|
186
|
+
* </form>
|
|
187
|
+
* ```
|
|
188
|
+
*
|
|
189
|
+
* @example Disabled states
|
|
190
|
+
* ```tsx
|
|
191
|
+
* <div className="space-y-3">
|
|
192
|
+
* <div className="flex items-center space-x-2">
|
|
193
|
+
* <Checkbox id="disabled-unchecked" disabled />
|
|
194
|
+
* <Label htmlFor="disabled-unchecked" className="text-muted-foreground">
|
|
195
|
+
* Disabled unchecked
|
|
196
|
+
* </Label>
|
|
197
|
+
* </div>
|
|
198
|
+
* <div className="flex items-center space-x-2">
|
|
199
|
+
* <Checkbox id="disabled-checked" disabled defaultChecked />
|
|
200
|
+
* <Label htmlFor="disabled-checked" className="text-muted-foreground">
|
|
201
|
+
* Disabled checked
|
|
202
|
+
* </Label>
|
|
70
203
|
* </div>
|
|
71
|
-
*
|
|
204
|
+
* <div className="flex items-center space-x-2">
|
|
205
|
+
* <Checkbox id="disabled-indeterminate" disabled checked="indeterminate" />
|
|
206
|
+
* <Label htmlFor="disabled-indeterminate" className="text-muted-foreground">
|
|
207
|
+
* Disabled indeterminate
|
|
208
|
+
* </Label>
|
|
209
|
+
* </div>
|
|
210
|
+
* </div>
|
|
72
211
|
* ```
|
|
73
212
|
*
|
|
74
|
-
* @
|
|
75
|
-
*
|
|
213
|
+
* @accessibility
|
|
214
|
+
* - **Keyboard Navigation**: Space key toggles the checkbox state
|
|
215
|
+
* - **Screen Readers**: Properly announces state changes and supports required/invalid states
|
|
216
|
+
* - **Focus Management**: Receives focus and shows focus indicators
|
|
217
|
+
* - **Form Integration**: Automatically includes hidden input for form submission
|
|
218
|
+
* - **ARIA Support**: Uses proper ARIA states for checked/unchecked/indeterminate
|
|
219
|
+
* - **Labeling**: Should always be associated with a Label component using htmlFor and id
|
|
220
|
+
*
|
|
221
|
+
* @see {@link https://www.radix-ui.com/primitives/docs/components/checkbox} Radix UI Checkbox primitive
|
|
222
|
+
* @see {@link https://ui.shadcn.com/docs/components/checkbox} shadcn/ui design patterns
|
|
76
223
|
* @see {@link Label} for accessible labeling
|
|
77
|
-
* @see {@link Switch} for boolean toggles
|
|
224
|
+
* @see {@link Switch} for boolean toggles with different semantics
|
|
78
225
|
* @see {@link RadioGroup} for single selection scenarios
|
|
79
|
-
*
|
|
80
|
-
* @param className - Additional CSS classes to apply to the checkbox
|
|
81
|
-
* @param checked - Controlled checked state (boolean | "indeterminate")
|
|
82
|
-
* @param defaultChecked - Default checked state for uncontrolled usage
|
|
83
|
-
* @param onCheckedChange - Callback when the checked state changes
|
|
84
|
-
* @param disabled - Whether the checkbox is disabled
|
|
85
|
-
* @param required - Whether the checkbox is required for form validation
|
|
86
|
-
* @param name - Form field name for form submission
|
|
87
|
-
* @param value - Form field value for form submission
|
|
88
|
-
* @param id - Unique identifier, used with Label htmlFor attribute
|
|
226
|
+
* @since 1.0.0
|
|
89
227
|
*/
|
|
90
228
|
function Checkbox({
|
|
91
229
|
className,
|