1+ // Copyright (c) Gridiron Survivor.
2+ // Licensed under the MIT License.
3+
14'use client' ;
25
3- import * as React from 'react' ;
6+ import { HTMLAttributes , JSX , forwardRef , ElementRef , ComponentPropsWithoutRef } from 'react' ;
47import * as AlertDialogPrimitive from '@radix-ui/react-alert-dialog' ;
58
69import { cn } from '@/lib/utils' ;
@@ -12,9 +15,15 @@ const AlertDialogTrigger = AlertDialogPrimitive.Trigger;
1215
1316const AlertDialogPortal = AlertDialogPrimitive . Portal ;
1417
15- const AlertDialogOverlay = React . forwardRef <
16- React . ElementRef < typeof AlertDialogPrimitive . Overlay > ,
17- React . ComponentPropsWithoutRef < typeof AlertDialogPrimitive . Overlay >
18+ /**
19+ * A custom overlay for use in the AlertDialog Component.
20+ * @param {object } props - Props for the component.
21+ * @param {string } props.className - Additional CSS classes for custom styling.
22+ * @returns {JSX.Element } - The rendered AlertDialogOverlay element.
23+ */
24+ const AlertDialogOverlay = forwardRef <
25+ ElementRef < typeof AlertDialogPrimitive . Overlay > ,
26+ ComponentPropsWithoutRef < typeof AlertDialogPrimitive . Overlay >
1827> ( ( { className, ...props } , ref ) => (
1928 < AlertDialogPrimitive . Overlay
2029 className = { cn (
@@ -27,9 +36,15 @@ const AlertDialogOverlay = React.forwardRef<
2736) ) ;
2837AlertDialogOverlay . displayName = AlertDialogPrimitive . Overlay . displayName ;
2938
30- const AlertDialogContent = React . forwardRef <
31- React . ElementRef < typeof AlertDialogPrimitive . Content > ,
32- React . ComponentPropsWithoutRef < typeof AlertDialogPrimitive . Content >
39+ /**
40+ * Contains content to be rendered when the AlertDialog component is open.
41+ * @param {object } props - Props for the component.
42+ * @param {string } props.className - Additional CSS classes for custom styling.
43+ * @returns {JSX.Element } - The rendered AlertDialogContent element.
44+ */
45+ const AlertDialogContent = forwardRef <
46+ ElementRef < typeof AlertDialogPrimitive . Content > ,
47+ ComponentPropsWithoutRef < typeof AlertDialogPrimitive . Content >
3348> ( ( { className, ...props } , ref ) => (
3449 < AlertDialogPortal >
3550 < AlertDialogOverlay />
@@ -45,10 +60,16 @@ const AlertDialogContent = React.forwardRef<
4560) ) ;
4661AlertDialogContent . displayName = AlertDialogPrimitive . Content . displayName ;
4762
63+ /**
64+ * A custom header for use in the AlertDialog Component.
65+ * @param {HTMLAttributes<HTMLDivElement> } props - Props for function.
66+ * @param {string } props.className - Additional CSS classes for custom styling.
67+ * @returns {JSX.Element } - The rendered AlertDialogHeader element.
68+ */
4869const AlertDialogHeader = ( {
4970 className,
5071 ...props
51- } : React . HTMLAttributes < HTMLDivElement > ) => (
72+ } : HTMLAttributes < HTMLDivElement > ) : JSX . Element => (
5273 < div
5374 className = { cn (
5475 'flex flex-col space-y-2 text-center sm:text-left' ,
@@ -59,10 +80,16 @@ const AlertDialogHeader = ({
5980) ;
6081AlertDialogHeader . displayName = 'AlertDialogHeader' ;
6182
83+ /**
84+ * A custom footer for use in the AlertDialogFooter Component.
85+ * @param {HTMLAttributes<HTMLDivElement> } props - Props for function.
86+ * @param {string } props.className - Additional CSS classes for custom styling.
87+ * @returns {JSX.Element } - The rendered AlertDialogFooter element.
88+ */
6289const AlertDialogFooter = ( {
6390 className,
6491 ...props
65- } : React . HTMLAttributes < HTMLDivElement > ) => (
92+ } : HTMLAttributes < HTMLDivElement > ) : JSX . Element => (
6693 < div
6794 className = { cn (
6895 'flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2' ,
@@ -73,9 +100,15 @@ const AlertDialogFooter = ({
73100) ;
74101AlertDialogFooter . displayName = 'AlertDialogFooter' ;
75102
76- const AlertDialogTitle = React . forwardRef <
77- React . ElementRef < typeof AlertDialogPrimitive . Title > ,
78- React . ComponentPropsWithoutRef < typeof AlertDialogPrimitive . Title >
103+ /**
104+ * An accessible title announced when the AlertDialog component is opened.
105+ * @param {object } props - Props for the component.
106+ * @param {string } props.className - Additional CSS classes for custom styling.
107+ * @returns {JSX.Element } - The rendered AlertDialogTitle element.
108+ */
109+ const AlertDialogTitle = forwardRef <
110+ ElementRef < typeof AlertDialogPrimitive . Title > ,
111+ ComponentPropsWithoutRef < typeof AlertDialogPrimitive . Title >
79112> ( ( { className, ...props } , ref ) => (
80113 < AlertDialogPrimitive . Title
81114 ref = { ref }
@@ -85,9 +118,15 @@ const AlertDialogTitle = React.forwardRef<
85118) ) ;
86119AlertDialogTitle . displayName = AlertDialogPrimitive . Title . displayName ;
87120
88- const AlertDialogDescription = React . forwardRef <
89- React . ElementRef < typeof AlertDialogPrimitive . Description > ,
90- React . ComponentPropsWithoutRef < typeof AlertDialogPrimitive . Description >
121+ /**
122+ * An accessible description announced when the AlertDialog component is opened.
123+ * @param {object } props - Props for the component.
124+ * @param {string } props.className - Additional CSS classes for custom styling.
125+ * @returns {JSX.Element } - The rendered AlertDialogDescription element.
126+ */
127+ const AlertDialogDescription = forwardRef <
128+ ElementRef < typeof AlertDialogPrimitive . Description > ,
129+ ComponentPropsWithoutRef < typeof AlertDialogPrimitive . Description >
91130> ( ( { className, ...props } , ref ) => (
92131 < AlertDialogPrimitive . Description
93132 ref = { ref }
@@ -98,9 +137,15 @@ const AlertDialogDescription = React.forwardRef<
98137AlertDialogDescription . displayName =
99138 AlertDialogPrimitive . Description . displayName ;
100139
101- const AlertDialogAction = React . forwardRef <
102- React . ElementRef < typeof AlertDialogPrimitive . Action > ,
103- React . ComponentPropsWithoutRef < typeof AlertDialogPrimitive . Action >
140+ /**
141+ * A button that closes the AlertDialog component. Should be distinguished visually from the Cancel button.
142+ * @param {object } props - Props for the component.
143+ * @param {string } props.className - Additional CSS classes for custom styling.
144+ * @returns {JSX.Element } - The rendered AlertDialogAction element.
145+ */
146+ const AlertDialogAction = forwardRef <
147+ ElementRef < typeof AlertDialogPrimitive . Action > ,
148+ ComponentPropsWithoutRef < typeof AlertDialogPrimitive . Action >
104149> ( ( { className, ...props } , ref ) => (
105150 < AlertDialogPrimitive . Action
106151 ref = { ref }
@@ -110,9 +155,15 @@ const AlertDialogAction = React.forwardRef<
110155) ) ;
111156AlertDialogAction . displayName = AlertDialogPrimitive . Action . displayName ;
112157
113- const AlertDialogCancel = React . forwardRef <
114- React . ElementRef < typeof AlertDialogPrimitive . Cancel > ,
115- React . ComponentPropsWithoutRef < typeof AlertDialogPrimitive . Cancel >
158+ /**
159+ * A button that closes the AlertDialog component. Should be distinguished visually from the Action button.
160+ * @param {object } props - Props for the component.
161+ * @param {string } props.className - Additional CSS classes for custom styling.
162+ * @returns {JSX.Element } - The rendered AlertDialogCancel element.
163+ */
164+ const AlertDialogCancel = forwardRef <
165+ ElementRef < typeof AlertDialogPrimitive . Cancel > ,
166+ ComponentPropsWithoutRef < typeof AlertDialogPrimitive . Cancel >
116167> ( ( { className, ...props } , ref ) => (
117168 < AlertDialogPrimitive . Cancel
118169 ref = { ref }
0 commit comments