Skip to content

Commit 97df1cb

Browse files
committed
chore: add JSDoc for Dialog, RadioGroup, Separator, and Slider components
1 parent 4e9fc55 commit 97df1cb

File tree

4 files changed

+87
-0
lines changed

4 files changed

+87
-0
lines changed

packages/shadcn/src/components/ui/dialog.tsx

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,37 @@ import { X } from 'lucide-react';
55
import { ComponentPropsWithoutRef, ElementRef, forwardRef, HTMLAttributes } from 'react';
66
import { cn } from '../../lib/utils';
77

8+
/**
9+
* The root Dialog component that manages the state and accessibility of the dialog
10+
* @see https://ui.shadcn.com/docs/components/dialog
11+
* @returns A Dialog root component
12+
*/
813
const Dialog = Root;
914

15+
/**
16+
* The button that opens the dialog when clicked
17+
* @returns A button component that triggers the dialog
18+
*/
1019
const DialogTrigger = Trigger;
1120

21+
/**
22+
* Portal component that renders the dialog content in a portal
23+
* @returns A portal component for dialog content
24+
*/
1225
const DialogPortal = Portal;
1326

27+
/**
28+
* Button component for closing the dialog
29+
* @returns A close button component
30+
*/
1431
const DialogClose = Close;
1532

33+
/**
34+
* The overlay that covers the screen behind the dialog
35+
* @param props - Props for the overlay component including className and ref
36+
* @param props.className - Additional CSS classes to apply to the dialog overlay
37+
* @returns A semi-transparent overlay component
38+
*/
1639
const DialogOverlay = forwardRef<ElementRef<typeof Overlay>, ComponentPropsWithoutRef<typeof Overlay>>(
1740
({ className, ...props }, ref) => (
1841
<Overlay
@@ -27,6 +50,12 @@ const DialogOverlay = forwardRef<ElementRef<typeof Overlay>, ComponentPropsWitho
2750
);
2851
DialogOverlay.displayName = Overlay.displayName;
2952

53+
/**
54+
* The main content container of the dialog
55+
* @param props - Props for the content component including className, children and ref
56+
* @param props.className - Additional CSS classes to apply to the dialog content
57+
* @returns A dialog content container component
58+
*/
3059
const DialogContent = forwardRef<ElementRef<typeof Content>, ComponentPropsWithoutRef<typeof Content>>(
3160
({ className, children, ...props }, ref) => (
3261
<DialogPortal>
@@ -50,11 +79,23 @@ const DialogContent = forwardRef<ElementRef<typeof Content>, ComponentPropsWitho
5079
);
5180
DialogContent.displayName = Content.displayName;
5281

82+
/**
83+
* Container for the dialog header content
84+
* @param props - HTML div element attributes including className
85+
* @param props.className - Additional CSS classes to apply to the dialog header
86+
* @returns A header container component
87+
*/
5388
const DialogHeader = ({ className, ...props }: HTMLAttributes<HTMLDivElement>) => (
5489
<div className={cn('flex flex-col space-y-1.5 text-center sm:text-start', className)} {...props} />
5590
);
5691
DialogHeader.displayName = 'DialogHeader';
5792

93+
/**
94+
* Container for the dialog footer content
95+
* @param props - HTML div element attributes including className
96+
* @param props.className - Additional CSS classes to apply to the dialog footer
97+
* @returns A footer container component
98+
*/
5899
const DialogFooter = ({ className, ...props }: HTMLAttributes<HTMLDivElement>) => (
59100
<div
60101
className={cn('flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2 rtl:space-x-reverse', className)}
@@ -63,13 +104,25 @@ const DialogFooter = ({ className, ...props }: HTMLAttributes<HTMLDivElement>) =
63104
);
64105
DialogFooter.displayName = 'DialogFooter';
65106

107+
/**
108+
* The title component of the dialog
109+
* @param props - Props for the title component including className and ref
110+
* @param props.className - Additional CSS classes to apply to the dialog title
111+
* @returns A title component for the dialog
112+
*/
66113
const DialogTitle = forwardRef<ElementRef<typeof Title>, ComponentPropsWithoutRef<typeof Title>>(
67114
({ className, ...props }, ref) => (
68115
<Title ref={ref} className={cn('text-lg font-semibold leading-none tracking-tight', className)} {...props} />
69116
)
70117
);
71118
DialogTitle.displayName = Title.displayName;
72119

120+
/**
121+
* The description component of the dialog
122+
* @param props - Props for the description component including className and ref
123+
* @param props.className - Additional CSS classes to apply to the dialog description
124+
* @returns A description component for the dialog
125+
*/
73126
const DialogDescription = forwardRef<ElementRef<typeof Description>, ComponentPropsWithoutRef<typeof Description>>(
74127
({ className, ...props }, ref) => (
75128
<Description ref={ref} className={cn('text-sm text-muted-foreground', className)} {...props} />

packages/shadcn/src/components/ui/radio-group.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ import { ComponentPropsWithoutRef, ElementRef, forwardRef } from 'react';
66

77
import { cn } from '../../lib/utils';
88

9+
/**
10+
* A radio group component for selecting a single option from a list
11+
*
12+
* @param props - The props for the RadioGroup component
13+
* @param props.className - Additional CSS classes to apply to the radio group
14+
* @param ref - The forwarded ref for the radio group element
15+
* @returns A radio group container element
16+
*/
917
const RadioGroup = forwardRef<
1018
ElementRef<typeof RadioGroupPrimitive.Root>,
1119
ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Root>
@@ -14,6 +22,14 @@ const RadioGroup = forwardRef<
1422
});
1523
RadioGroup.displayName = RadioGroupPrimitive.Root.displayName;
1624

25+
/**
26+
* An individual radio item within a RadioGroup
27+
*
28+
* @param props - The props for the RadioGroupItem component
29+
* @param props.className - Additional CSS classes to apply to the radio item
30+
* @param ref - The forwarded ref for the radio item element
31+
* @returns A styled radio input element
32+
*/
1733
const RadioGroupItem = forwardRef<
1834
ElementRef<typeof RadioGroupPrimitive.Item>,
1935
ComponentPropsWithoutRef<typeof RadioGroupPrimitive.Item>

packages/shadcn/src/components/ui/separator.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,16 @@ import { ComponentPropsWithoutRef, ElementRef, forwardRef } from 'react';
55

66
import { cn } from '../../lib/utils';
77

8+
/**
9+
* A separator component for visually dividing content
10+
*
11+
* @param props - The props for the Separator component
12+
* @param props.className - Additional CSS classes to apply to the separator
13+
* @param props.orientation - The orientation of the separator ('horizontal' | 'vertical')
14+
* @param props.decorative - Whether the separator is decorative or semantic
15+
* @param ref - The forwarded ref for the separator element
16+
* @returns A styled separator element
17+
*/
818
const Separator = forwardRef<ElementRef<typeof Root>, ComponentPropsWithoutRef<typeof Root>>(
919
({ className, orientation = 'horizontal', decorative = true, ...props }, ref) => (
1020
<Root

packages/shadcn/src/components/ui/slider.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ import { ComponentPropsWithoutRef, ElementRef, forwardRef } from 'react';
55

66
import { cn } from '../../lib/utils';
77

8+
/**
9+
* A slider component for selecting a numeric value within a range
10+
*
11+
* @param props - The props for the Slider component
12+
* @param props.className - Additional CSS classes to apply to the slider
13+
* @param ref - The forwarded ref for the slider element
14+
* @returns A slider input element with track and thumb
15+
*/
816
const Slider = forwardRef<ElementRef<typeof Root>, ComponentPropsWithoutRef<typeof Root>>(
917
({ className, ...props }, ref) => (
1018
<Root ref={ref} className={cn('relative flex w-full touch-none select-none items-center', className)} {...props}>

0 commit comments

Comments
 (0)