From 361ec0b1eb17647696656c6a6d4cddd5b9348b45 Mon Sep 17 00:00:00 2001 From: Dries Augustyns Date: Mon, 4 May 2026 21:08:14 +0200 Subject: [PATCH] refactor: convert forwardRef components to function components for consistency --- apps/web/src/components/ActivityFeed.tsx | 2 +- apps/web/src/components/ActivityItem.tsx | 5 +- apps/web/src/components/ApiKeyDisplay.tsx | 4 +- apps/web/src/components/BillingLimits.tsx | 12 +- .../components/EmailEditor/EmailEditor.tsx | 1 - apps/web/src/components/EmailSettings.tsx | 14 +- .../lib/contexts/ActiveProjectProvider.tsx | 4 +- apps/web/src/pages/campaigns/[id].tsx | 65 +++-- apps/web/src/pages/settings/index.tsx | 38 +-- apps/web/src/pages/templates/[id].tsx | 22 +- apps/web/src/pages/workflows/[id].tsx | 83 +++--- packages/ui/src/components/atoms/Alert.tsx | 30 +- packages/ui/src/components/atoms/Button.tsx | 14 +- packages/ui/src/components/atoms/Card.tsx | 50 ++-- packages/ui/src/components/atoms/Chart.tsx | 59 ++-- packages/ui/src/components/atoms/Checkbox.tsx | 33 ++- packages/ui/src/components/atoms/Command.tsx | 144 +++++----- packages/ui/src/components/atoms/Dialog.tsx | 92 +++--- .../ui/src/components/atoms/DropdownMenu.tsx | 262 ++++++++++-------- packages/ui/src/components/atoms/Form.tsx | 87 +++--- packages/ui/src/components/atoms/Input.tsx | 4 +- packages/ui/src/components/atoms/Kbd.tsx | 8 +- packages/ui/src/components/atoms/Label.tsx | 13 +- packages/ui/src/components/atoms/Popover.tsx | 39 +-- packages/ui/src/components/atoms/Progress.tsx | 10 +- .../ui/src/components/atoms/RadioGroup.tsx | 14 +- packages/ui/src/components/atoms/Select.tsx | 262 +++++++++--------- .../ui/src/components/atoms/Separator.tsx | 37 +-- packages/ui/src/components/atoms/Switch.tsx | 33 ++- packages/ui/src/components/atoms/Table.tsx | 62 ++--- packages/ui/src/components/atoms/Tabs.tsx | 75 +++-- packages/ui/src/components/atoms/Textarea.tsx | 6 +- packages/ui/src/components/atoms/Tooltip.tsx | 32 ++- .../components/molecules/ConfirmDialog.tsx | 6 +- .../components/molecules/StickySaveBar.tsx | 136 ++++----- 35 files changed, 869 insertions(+), 889 deletions(-) diff --git a/apps/web/src/components/ActivityFeed.tsx b/apps/web/src/components/ActivityFeed.tsx index 59849fd..e02a8e2 100644 --- a/apps/web/src/components/ActivityFeed.tsx +++ b/apps/web/src/components/ActivityFeed.tsx @@ -241,7 +241,7 @@ export function ActivityFeed({typeFilter, dateRangeDays = 30, contactId}: Activi
{upcomingActivities.map((activity, index) => (
- + {index < upcomingActivities.length - 1 &&
}
))} diff --git a/apps/web/src/components/ActivityItem.tsx b/apps/web/src/components/ActivityItem.tsx index dbd5aca..c817bda 100644 --- a/apps/web/src/components/ActivityItem.tsx +++ b/apps/web/src/components/ActivityItem.tsx @@ -110,7 +110,7 @@ function isEmailActivity(type: string): boolean { interface ActivityItemProps { activity: Activity; - isUpcoming?: boolean; + status?: 'upcoming' | 'completed'; } interface ActivityConfig { @@ -342,11 +342,12 @@ function getActivityConfig(activity: Activity): ActivityConfig { } } -export const ActivityItem = memo(function ActivityItem({activity, isUpcoming = false}: ActivityItemProps) { +export const ActivityItem = memo(function ActivityItem({activity, status = 'completed'}: ActivityItemProps) { const [showPreviewModal, setShowPreviewModal] = useState(false); const config = getActivityConfig(activity); const Icon = config.icon; const timestamp = new Date(activity.timestamp); + const isUpcoming = status === 'upcoming'; const relativeTime = isUpcoming ? getUpcomingTime(timestamp) : getRelativeTime(timestamp); return ( diff --git a/apps/web/src/components/ApiKeyDisplay.tsx b/apps/web/src/components/ApiKeyDisplay.tsx index 5cc98b7..aaffc52 100644 --- a/apps/web/src/components/ApiKeyDisplay.tsx +++ b/apps/web/src/components/ApiKeyDisplay.tsx @@ -9,7 +9,6 @@ interface ApiKeyDisplayProps { description?: string; isSecret?: boolean; onRegenerate?: () => Promise; - showRegenerate?: boolean; } export function ApiKeyDisplay({ @@ -18,7 +17,6 @@ export function ApiKeyDisplay({ description, isSecret = false, onRegenerate, - showRegenerate = false, }: ApiKeyDisplayProps) { const [showKey, setShowKey] = useState(!isSecret); const [copied, setCopied] = useState(false); @@ -101,7 +99,7 @@ export function ApiKeyDisplay({ )} - {showRegenerate && onRegenerate && ( + {onRegenerate && ( - setIsTestEmailDialogOpen(true)} className="py-3 cursor-pointer"> + setDialog({type: 'testEmail', sending: false})} className="py-3 cursor-pointer">
@@ -406,7 +410,7 @@ export default function CampaignDetailsPage() {
- setShowSendDialog(true)} className="py-3 cursor-pointer"> + setDialog({type: 'send'})} className="py-3 cursor-pointer">
@@ -417,7 +421,7 @@ export default function CampaignDetailsPage() {
- setIsScheduleDialogOpen(true)} className="py-3 cursor-pointer"> + setDialog({type: 'schedule'})} className="py-3 cursor-pointer">
@@ -531,7 +535,6 @@ export default function CampaignDetailsPage() { onFromNameChange={value => setEditedCampaign({...editedCampaign, fromName: value})} onReplyToChange={value => setEditedCampaign({...editedCampaign, replyTo: value})} fromNamePlaceholder={activeProject?.name || 'Your Company'} - showFromNameHelpText layout="vertical" /> @@ -658,7 +661,7 @@ export default function CampaignDetailsPage() { {/* Test Email Dialog */} - + !open && setDialog({type: 'none'})}> Send Test Email @@ -695,21 +698,25 @@ export default function CampaignDetailsPage() { type="button" variant="outline" onClick={() => { - setIsTestEmailDialogOpen(false); + setDialog({type: 'none'}); setTestEmailAddress(''); }} > Cancel - {/* Schedule Dialog */} - + !open && setDialog({type: 'none'})}> Schedule Campaign @@ -801,7 +808,7 @@ export default function CampaignDetailsPage() { type="button" variant="outline" onClick={() => { - setIsScheduleDialogOpen(false); + setDialog({type: 'none'}); setScheduledDateTime(''); }} > @@ -816,11 +823,11 @@ export default function CampaignDetailsPage() { {/* Sticky Save Bar */} - + !open && setDialog({type: 'none'})} onConfirm={handleSend} title="Send Campaign" description="Are you sure you want to send this campaign now? This action cannot be undone." @@ -829,8 +836,8 @@ export default function CampaignDetailsPage() { /> !open && setDialog({type: 'none'})} onConfirm={handleDelete} title="Delete Campaign" description="Are you sure you want to delete this draft campaign? This action cannot be undone." @@ -864,7 +871,7 @@ export default function CampaignDetailsPage() { {/* Actions */} {(c.status === CampaignStatus.SCHEDULED || c.status === CampaignStatus.SENDING) && (
-
!open && setDialog({type: 'none'})} onConfirm={handleCancel} title="Cancel Campaign" description="Are you sure you want to cancel this campaign?" diff --git a/apps/web/src/pages/settings/index.tsx b/apps/web/src/pages/settings/index.tsx index f93e107..47497b6 100644 --- a/apps/web/src/pages/settings/index.tsx +++ b/apps/web/src/pages/settings/index.tsx @@ -92,11 +92,11 @@ export default function Settings() { const {data: user} = useUser(); const [successMessage, setSuccessMessage] = useState(null); const [errorMessage, setErrorMessage] = useState(null); - const [showRegenerateDialog, setShowRegenerateDialog] = useState(false); - const [showDeleteDialog, setShowDeleteDialog] = useState(false); - const [showResetDialog, setShowResetDialog] = useState(false); const [deleteConfirmText, setDeleteConfirmText] = useState(''); const [resetConfirmText, setResetConfirmText] = useState(''); + + type SettingsDialog = {type: 'none'} | {type: 'regenerate'} | {type: 'delete'} | {type: 'reset'}; + const [dialog, setDialog] = useState({type: 'none'}); const [isLoadingBilling, setIsLoadingBilling] = useState(false); const [selectedCurrency, setSelectedCurrency] = useState('auto'); const [showCurrencySelector, setShowCurrencySelector] = useState(false); @@ -235,18 +235,18 @@ export default function Settings() { await projectsMutate(); setSuccessMessage('API keys regenerated successfully'); - setShowRegenerateDialog(false); + setDialog({type: 'none'}); // Clear success message after 3 seconds setTimeout(() => setSuccessMessage(null), 3000); } catch (error) { setErrorMessage(error instanceof Error ? error.message : 'Failed to regenerate API keys'); - setShowRegenerateDialog(false); + setDialog({type: 'none'}); } }; const promptRegenerateKeys = () => { - setShowRegenerateDialog(true); + setDialog({type: 'regenerate'}); }; const handleStartSubscription = async (currency: string = 'auto') => { @@ -314,7 +314,7 @@ export default function Settings() { await network.fetch('POST', `/users/@me/projects/${activeProject.id}/reset`); setSuccessMessage('Project reset successfully. All data has been cleared.'); - setShowResetDialog(false); + setDialog({type: 'none'}); setResetConfirmText(''); // Refresh the page to reload data @@ -323,7 +323,7 @@ export default function Settings() { }, 1500); } catch (error) { setErrorMessage(error instanceof Error ? error.message : 'Failed to reset project'); - setShowResetDialog(false); + setDialog({type: 'none'}); setResetConfirmText(''); } }; @@ -338,7 +338,7 @@ export default function Settings() { await network.fetch('DELETE', `/users/@me/projects/${activeProject.id}`); setSuccessMessage('Project deleted successfully. Redirecting...'); - setShowDeleteDialog(false); + setDialog({type: 'none'}); setDeleteConfirmText(''); // Refresh projects list and redirect to dashboard @@ -350,7 +350,7 @@ export default function Settings() { }, 1500); } catch (error) { setErrorMessage(error instanceof Error ? error.message : 'Failed to delete project'); - setShowDeleteDialog(false); + setDialog({type: 'none'}); setDeleteConfirmText(''); } }; @@ -587,7 +587,7 @@ export default function Settings() { API keys, domains, billing information
-
@@ -614,7 +614,7 @@ export default function Settings() {
{/* Regenerate Keys Confirmation Dialog */} - + !open && setDialog({type: 'none'})}> @@ -833,7 +833,7 @@ export default function Settings() { - {/* Reset Project Confirmation Dialog */} - + !open && setDialog({type: 'none'})}>
@@ -876,7 +876,7 @@ export default function Settings() {
{/* Delete Project Confirmation Dialog */} - + !open && setDialog({type: 'none'})}>
@@ -934,7 +934,7 @@ export default function Settings() {
-
{activeExecutionsCount > 0 && ( - )} @@ -616,8 +618,8 @@ export default function WorkflowEditorPage() { @@ -639,37 +641,38 @@ export default function WorkflowEditorPage() { <> !open && setDialog({type: 'none'})} onSave={handleUpdateSettings} /> - {editingStep && ( + {dialog.type === 'editStep' && ( !open && setEditingStep(null)} + open={true} + onOpenChange={open => !open && setDialog({type: 'none'})} onSuccess={() => mutate()} /> )} {/* Cancel Single Execution Confirmation */} !open && setExecutionToCancel(null)} + open={dialog.type === 'cancelOne'} + onOpenChange={open => !open && setDialog({type: 'none'})} onConfirm={() => { - if (executionToCancel) { - return handleCancelExecution(executionToCancel); + if (dialog.type === 'cancelOne') { + return handleCancelExecution(dialog.executionId); } }} title="Cancel Execution" description={ - executionToCancel && executionsData?.executions ? ( + dialog.type === 'cancelOne' && executionsData?.executions ? (

Are you sure you want to cancel the workflow execution for{' '} - {executionsData.executions.find(e => e.id === executionToCancel)?.contact.email || 'this contact'} + {executionsData.executions.find(e => e.id === dialog.executionId)?.contact.email || + 'this contact'} ?

@@ -685,13 +688,13 @@ export default function WorkflowEditorPage() { confirmText="Cancel Execution" cancelText="Keep Running" variant="destructive" - isLoading={isCancelling} + status={dialog.type === 'cancelOne' && dialog.cancelling ? 'loading' : 'idle'} /> {/* Cancel All Executions Confirmation */} !open && setDialog({type: 'none'})} onConfirm={handleCancelAllExecutions} title="Cancel All Active Executions" description={ @@ -709,13 +712,13 @@ export default function WorkflowEditorPage() { confirmText={`Cancel ${activeExecutionsCount} Execution${activeExecutionsCount !== 1 ? 's' : ''}`} cancelText="Keep Running" variant="destructive" - isLoading={isCancelling} + status={dialog.type === 'cancelAll' && dialog.cancelling ? 'loading' : 'idle'} /> {/* Delete Workflow Confirmation */} !open && setDialog({type: 'none'})} onConfirm={handleDelete} title="Delete Workflow" description="Are you sure you want to delete this workflow? This action cannot be undone." diff --git a/packages/ui/src/components/atoms/Alert.tsx b/packages/ui/src/components/atoms/Alert.tsx index a1aa27d..24f1ea3 100644 --- a/packages/ui/src/components/atoms/Alert.tsx +++ b/packages/ui/src/components/atoms/Alert.tsx @@ -19,26 +19,24 @@ const alertVariants = cva( }, ); -const Alert = React.forwardRef< - HTMLDivElement, - React.HTMLAttributes & VariantProps ->(({className, variant, ...props}, ref) => ( -
-)); +function Alert({ + className, + variant, + ref, + ...props +}: React.ComponentProps<'div'> & VariantProps) { + return
; +} Alert.displayName = 'Alert'; -const AlertTitle = React.forwardRef>( - ({className, ...props}, ref) => ( -
- ), -); +function AlertTitle({className, ref, ...props}: React.ComponentProps<'h5'>) { + return
; +} AlertTitle.displayName = 'AlertTitle'; -const AlertDescription = React.forwardRef>( - ({className, ...props}, ref) => ( -
- ), -); +function AlertDescription({className, ref, ...props}: React.ComponentProps<'div'>) { + return
; +} AlertDescription.displayName = 'AlertDescription'; export {Alert, AlertTitle, AlertDescription}; diff --git a/packages/ui/src/components/atoms/Button.tsx b/packages/ui/src/components/atoms/Button.tsx index fc99408..b4b0364 100644 --- a/packages/ui/src/components/atoms/Button.tsx +++ b/packages/ui/src/components/atoms/Button.tsx @@ -31,18 +31,14 @@ const buttonVariants = cva( }, ); -export interface ButtonProps - extends React.ButtonHTMLAttributes, - VariantProps { +export interface ButtonProps extends React.ComponentProps<'button'>, VariantProps { asChild?: boolean; } -const Button = React.forwardRef( - ({className, variant, size, asChild = false, ...props}, ref) => { - const Comp = asChild ? Slot : 'button'; - return ; - }, -); +function Button({className, variant, size, asChild = false, ref, ...props}: ButtonProps) { + const Comp = asChild ? Slot : 'button'; + return ; +} Button.displayName = 'Button'; export {Button, buttonVariants}; diff --git a/packages/ui/src/components/atoms/Card.tsx b/packages/ui/src/components/atoms/Card.tsx index fd121f4..9c8fdfa 100644 --- a/packages/ui/src/components/atoms/Card.tsx +++ b/packages/ui/src/components/atoms/Card.tsx @@ -2,42 +2,40 @@ import * as React from 'react'; import {cn} from '../../lib'; -const Card = React.forwardRef>(({className, ...props}, ref) => ( -
-)); +function Card({className, ref, ...props}: React.ComponentProps<'div'>) { + return ( +
+ ); +} Card.displayName = 'Card'; -const CardHeader = React.forwardRef>( - ({className, ...props}, ref) => ( -
- ), -); +function CardHeader({className, ref, ...props}: React.ComponentProps<'div'>) { + return
; +} CardHeader.displayName = 'CardHeader'; -const CardTitle = React.forwardRef>( - ({className, ...props}, ref) => ( -
- ), -); +function CardTitle({className, ref, ...props}: React.ComponentProps<'div'>) { + return
; +} CardTitle.displayName = 'CardTitle'; -const CardDescription = React.forwardRef>( - ({className, ...props}, ref) =>
, -); +function CardDescription({className, ref, ...props}: React.ComponentProps<'div'>) { + return
; +} CardDescription.displayName = 'CardDescription'; -const CardContent = React.forwardRef>( - ({className, ...props}, ref) =>
, -); +function CardContent({className, ref, ...props}: React.ComponentProps<'div'>) { + return
; +} CardContent.displayName = 'CardContent'; -const CardFooter = React.forwardRef>( - ({className, ...props}, ref) =>
, -); +function CardFooter({className, ref, ...props}: React.ComponentProps<'div'>) { + return
; +} CardFooter.displayName = 'CardFooter'; export {Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle}; diff --git a/packages/ui/src/components/atoms/Chart.tsx b/packages/ui/src/components/atoms/Chart.tsx index f9cd765..1b3a6e8 100644 --- a/packages/ui/src/components/atoms/Chart.tsx +++ b/packages/ui/src/components/atoms/Chart.tsx @@ -29,7 +29,7 @@ interface ChartContextProps { const ChartContext = React.createContext(null); function useChart() { - const context = React.useContext(ChartContext); + const context = React.use(ChartContext); if (!context) { throw new Error('useChart must be used within a '); @@ -47,8 +47,7 @@ interface ChartContainerProps extends React.ComponentProps<'div'> { children: React.ComponentProps['children']; } -const ChartContainer = React.forwardRef( - ({id, className, children, config, ...props}, ref) => { +function ChartContainer({id, className, children, config, ref, ...props}: ChartContainerProps) { const uniqueId = React.useId(); const chartId = `chart-${id || uniqueId.replace(/:/g, '')}`; @@ -65,8 +64,7 @@ const ChartContainer = React.forwardRef(
); - }, -); +} ChartContainer.displayName = 'ChartContainer'; // ============================================ @@ -119,25 +117,22 @@ interface ChartTooltipContentProps const ChartTooltip = RechartsPrimitive.Tooltip; -const ChartTooltipContent = React.forwardRef( - ( - { - active, - payload, - className, - indicator = 'dot', - hideLabel = false, - hideIndicator = false, - label, - labelFormatter, - labelClassName, - formatter, - color, - nameKey, - labelKey, - }, - ref, - ) => { +function ChartTooltipContent({ + active, + payload, + className, + indicator = 'dot', + hideLabel = false, + hideIndicator = false, + label, + labelFormatter, + labelClassName, + formatter, + color, + nameKey, + labelKey, + ref, +}: ChartTooltipContentProps & {ref?: React.Ref}) { const {config} = useChart(); const tooltipLabel = React.useMemo(() => { @@ -235,8 +230,7 @@ const ChartTooltipContent = React.forwardRef
); - }, -); +} ChartTooltipContent.displayName = 'ChartTooltipContent'; // ============================================ @@ -252,8 +246,14 @@ interface ChartLegendContentProps extends Omit, 'pay const ChartLegend = RechartsPrimitive.Legend; -const ChartLegendContent = React.forwardRef( - ({className, hideIcon = false, payload, verticalAlign = 'bottom', nameKey}, ref) => { +function ChartLegendContent({ + className, + hideIcon = false, + payload, + verticalAlign = 'bottom', + nameKey, + ref, +}: ChartLegendContentProps & {ref?: React.Ref}) { const {config} = useChart(); if (!payload?.length) { @@ -290,8 +290,7 @@ const ChartLegendContent = React.forwardRef ); - }, -); +} ChartLegendContent.displayName = 'ChartLegendContent'; export {ChartContainer, ChartTooltip, ChartTooltipContent, ChartLegend, ChartLegendContent, ChartStyle}; diff --git a/packages/ui/src/components/atoms/Checkbox.tsx b/packages/ui/src/components/atoms/Checkbox.tsx index 6342040..c105468 100644 --- a/packages/ui/src/components/atoms/Checkbox.tsx +++ b/packages/ui/src/components/atoms/Checkbox.tsx @@ -6,23 +6,22 @@ import * as React from 'react'; import {cn} from '../../lib'; -const Checkbox = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({className, ...props}, ref) => ( - - - - - -)); +function Checkbox({className, ref, ...props}: React.ComponentProps) { + return ( + + + + + + ); +} Checkbox.displayName = CheckboxPrimitive.Root.displayName; export {Checkbox}; diff --git a/packages/ui/src/components/atoms/Command.tsx b/packages/ui/src/components/atoms/Command.tsx index 403efeb..4da1ea1 100644 --- a/packages/ui/src/components/atoms/Command.tsx +++ b/packages/ui/src/components/atoms/Command.tsx @@ -7,16 +7,15 @@ import {Search} from 'lucide-react'; import {cn} from '../../lib'; -const Command = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({className, ...props}, ref) => ( - -)); +function Command({className, ref, ...props}: React.ComponentProps) { + return ( + + ); +} Command.displayName = CommandPrimitive.displayName; const CommandDialog = ({children, ...props}: React.ComponentProps) => { @@ -44,85 +43,72 @@ const CommandDialog = ({children, ...props}: React.ComponentProps, - React.ComponentPropsWithoutRef ->(({className, ...props}, ref) => ( -
- - ) { + return ( +
+ + +
+ ); +} +CommandInput.displayName = CommandPrimitive.Input.displayName; + +function CommandList({className, ref, ...props}: React.ComponentProps) { + return ( + + ); +} +CommandList.displayName = CommandPrimitive.List.displayName; + +function CommandEmpty({ref, ...props}: React.ComponentProps) { + return ; +} +CommandEmpty.displayName = CommandPrimitive.Empty.displayName; + +function CommandGroup({className, ref, ...props}: React.ComponentProps) { + return ( + -
-)); - -CommandInput.displayName = CommandPrimitive.Input.displayName; - -const CommandList = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({className, ...props}, ref) => ( - -)); - -CommandList.displayName = CommandPrimitive.List.displayName; - -const CommandEmpty = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->((props, ref) => ( - -)); - -CommandEmpty.displayName = CommandPrimitive.Empty.displayName; - -const CommandGroup = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({className, ...props}, ref) => ( - -)); - + ); +} CommandGroup.displayName = CommandPrimitive.Group.displayName; -const CommandSeparator = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({className, ...props}, ref) => ( - -)); +function CommandSeparator({className, ref, ...props}: React.ComponentProps) { + return ( + + ); +} CommandSeparator.displayName = CommandPrimitive.Separator.displayName; -const CommandItem = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({className, ...props}, ref) => ( - -)); - +function CommandItem({className, ref, ...props}: React.ComponentProps) { + return ( + + ); +} CommandItem.displayName = CommandPrimitive.Item.displayName; const CommandShortcut = ({className, ...props}: React.HTMLAttributes) => { diff --git a/packages/ui/src/components/atoms/Dialog.tsx b/packages/ui/src/components/atoms/Dialog.tsx index 5e014f7..eb81f02 100644 --- a/packages/ui/src/components/atoms/Dialog.tsx +++ b/packages/ui/src/components/atoms/Dialog.tsx @@ -12,43 +12,41 @@ const DialogPortal = DialogPrimitive.Portal; const DialogClose = DialogPrimitive.Close; -const DialogOverlay = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({className, ...props}, ref) => ( - -)); -DialogOverlay.displayName = DialogPrimitive.Overlay.displayName; - -const DialogContent = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({className, children, ...props}, ref) => ( - - - ) { + return ( + - {children} - - - Close - - - -)); + /> + ); +} +DialogOverlay.displayName = DialogPrimitive.Overlay.displayName; + +function DialogContent({className, children, ref, ...props}: React.ComponentProps) { + return ( + + + + {children} + + + Close + + + + ); +} DialogContent.displayName = DialogPrimitive.Content.displayName; const DialogHeader = ({className, ...props}: React.HTMLAttributes) => ( @@ -61,24 +59,22 @@ const DialogFooter = ({className, ...props}: React.HTMLAttributes, - React.ComponentPropsWithoutRef ->(({className, ...props}, ref) => ( - -)); +function DialogTitle({className, ref, ...props}: React.ComponentProps) { + return ( + + ); +} DialogTitle.displayName = DialogPrimitive.Title.displayName; -const DialogDescription = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({className, ...props}, ref) => ( - -)); +function DialogDescription({className, ref, ...props}: React.ComponentProps) { + return ( + + ); +} DialogDescription.displayName = DialogPrimitive.Description.displayName; export {Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger}; diff --git a/packages/ui/src/components/atoms/DropdownMenu.tsx b/packages/ui/src/components/atoms/DropdownMenu.tsx index 9dec651..1e18555 100644 --- a/packages/ui/src/components/atoms/DropdownMenu.tsx +++ b/packages/ui/src/components/atoms/DropdownMenu.tsx @@ -18,143 +18,169 @@ const DropdownMenuSub = DropdownMenuPrimitive.Sub; const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup; -const DropdownMenuSubTrigger = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef & { - inset?: boolean; - } ->(({className, inset, children, ...props}, ref) => ( - - {children} - - -)); +function DropdownMenuSubTrigger({ + className, + inset, + children, + ref, + ...props +}: React.ComponentProps & {inset?: boolean}) { + return ( + + {children} + + + ); +} DropdownMenuSubTrigger.displayName = DropdownMenuPrimitive.SubTrigger.displayName; -const DropdownMenuSubContent = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({className, ...props}, ref) => ( - -)); -DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName; - -const DropdownMenuContent = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({className, sideOffset = 4, ...props}, ref) => ( - - ) { + return ( + - -)); + ); +} +DropdownMenuSubContent.displayName = DropdownMenuPrimitive.SubContent.displayName; + +function DropdownMenuContent({ + className, + sideOffset = 4, + ref, + ...props +}: React.ComponentProps) { + return ( + + + + ); +} DropdownMenuContent.displayName = DropdownMenuPrimitive.Content.displayName; -const DropdownMenuItem = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef & { - inset?: boolean; - } ->(({className, inset, ...props}, ref) => ( - -)); +function DropdownMenuItem({ + className, + inset, + ref, + ...props +}: React.ComponentProps & {inset?: boolean}) { + return ( + + ); +} DropdownMenuItem.displayName = DropdownMenuPrimitive.Item.displayName; -const DropdownMenuCheckboxItem = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({className, children, checked, ...props}, ref) => ( - - - - - - - {children} - -)); +function DropdownMenuCheckboxItem({ + className, + children, + checked, + ref, + ...props +}: React.ComponentProps) { + return ( + + + + + + + {children} + + ); +} DropdownMenuCheckboxItem.displayName = DropdownMenuPrimitive.CheckboxItem.displayName; -const DropdownMenuRadioItem = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({className, children, ...props}, ref) => ( - - - - - - - {children} - -)); +function DropdownMenuRadioItem({ + className, + children, + ref, + ...props +}: React.ComponentProps) { + return ( + + + + + + + {children} + + ); +} DropdownMenuRadioItem.displayName = DropdownMenuPrimitive.RadioItem.displayName; -const DropdownMenuLabel = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef & { - inset?: boolean; - } ->(({className, inset, ...props}, ref) => ( - -)); +function DropdownMenuLabel({ + className, + inset, + ref, + ...props +}: React.ComponentProps & {inset?: boolean}) { + return ( + + ); +} DropdownMenuLabel.displayName = DropdownMenuPrimitive.Label.displayName; -const DropdownMenuSeparator = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({className, ...props}, ref) => ( - -)); +function DropdownMenuSeparator({ + className, + ref, + ...props +}: React.ComponentProps) { + return ( + + ); +} DropdownMenuSeparator.displayName = DropdownMenuPrimitive.Separator.displayName; const DropdownMenuShortcut = ({className, ...props}: React.HTMLAttributes) => { diff --git a/packages/ui/src/components/atoms/Form.tsx b/packages/ui/src/components/atoms/Form.tsx index 7bccc3e..18c6fa6 100644 --- a/packages/ui/src/components/atoms/Form.tsx +++ b/packages/ui/src/components/atoms/Form.tsx @@ -39,8 +39,8 @@ const FormField = < }; const useFormField = () => { - const fieldContext = React.useContext(FormFieldContext); - const itemContext = React.useContext(FormItemContext); + const fieldContext = React.use(FormFieldContext); + const itemContext = React.use(FormItemContext); const {getFieldState, formState} = useFormContext(); if (!fieldContext) { @@ -67,67 +67,60 @@ interface FormItemContextValue { const FormItemContext = React.createContext({} as FormItemContextValue); -const FormItem = React.forwardRef>( - ({className, ...props}, ref) => { - const id = React.useId(); +function FormItem({className, ref, ...props}: React.ComponentProps<'div'>) { + const id = React.useId(); - return ( - -
- - ); - }, -); + return ( + +
+ + ); +} FormItem.displayName = 'FormItem'; -const FormLabel = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({className, ...props}, ref) => { +function FormLabel({ + className, + ref, + ...props +}: React.ComponentProps) { const {formItemId} = useFormField(); return