diff --git a/apps/web/components/eventtype/EventLimitsTab.tsx b/apps/web/components/eventtype/EventLimitsTab.tsx index f3daf7db898712..7d15f394bb6fb9 100644 --- a/apps/web/components/eventtype/EventLimitsTab.tsx +++ b/apps/web/components/eventtype/EventLimitsTab.tsx @@ -19,10 +19,14 @@ import type { PeriodType } from "@calcom/prisma/enums"; import type { IntervalLimit } from "@calcom/types/Calendar"; import { Button, DateRangePicker, InputField, Label, Select, SettingsToggle, TextField } from "@calcom/ui"; -const MinimumBookingNoticeInput = React.forwardRef< - HTMLInputElement, - Omit, "ref"> ->(function MinimumBookingNoticeInput({ ...passThroughProps }, ref) { +const MinimumBookingNoticeInput = function MinimumBookingNoticeInput( + { + ref, + ...passThroughProps + }: Omit, "ref"> & { + ref: React.RefObject; + } +) { const { t } = useLocale(); const { setValue, getValues } = useFormContext(); const durationTypeOptions: { @@ -107,7 +111,7 @@ const MinimumBookingNoticeInput = React.forwardRef< /> ); -}); +}; export const EventLimitsTab = ({ eventType }: Pick) => { const { t, i18n } = useLocale(); diff --git a/apps/web/components/ui/form/CheckboxField.tsx b/apps/web/components/ui/form/CheckboxField.tsx index 3b264d7bbc4b4d..edcb2cc85a3a95 100644 --- a/apps/web/components/ui/form/CheckboxField.tsx +++ b/apps/web/components/ui/form/CheckboxField.tsx @@ -1,5 +1,5 @@ import type { InputHTMLAttributes } from "react"; -import React, { forwardRef } from "react"; +import React from "react"; import classNames from "@calcom/lib/classNames"; import { InfoBadge } from "@calcom/ui"; @@ -11,56 +11,64 @@ type Props = InputHTMLAttributes & { informationIconText?: string; }; -const CheckboxField = forwardRef( - ({ label, description, informationIconText, ...rest }, ref) => { - const descriptionAsLabel = !label || rest.descriptionAsLabel; - return ( -
- {label && ( -
- {React.createElement( - descriptionAsLabel ? "div" : "label", - { - className: "flex text-sm font-medium text-default", - ...(!descriptionAsLabel - ? { - htmlFor: rest.id, - } - : {}), - }, - label - )} -
- )} -
-
- {React.createElement( - descriptionAsLabel ? "label" : "div", - { - className: classNames( - "relative flex items-start", - descriptionAsLabel ? "text-default" : "text-emphasis" - ), - }, - <> -
- -
- {description} - - )} - {informationIconText && } -
+const CheckboxField = ( + { + ref, + label, + description, + informationIconText, + ...rest + }: Props & { + ref: React.RefObject; + } +) => { + const descriptionAsLabel = !label || rest.descriptionAsLabel; + return ( +
+ {label && ( +
+ {React.createElement( + descriptionAsLabel ? "div" : "label", + { + className: "flex text-sm font-medium text-default", + ...(!descriptionAsLabel + ? { + htmlFor: rest.id, + } + : {}), + }, + label + )} +
+ )} +
+
+ {React.createElement( + descriptionAsLabel ? "label" : "div", + { + className: classNames( + "relative flex items-start", + descriptionAsLabel ? "text-default" : "text-emphasis" + ), + }, + <> +
+ +
+ {description} + + )} + {informationIconText && }
- ); - } -); +
+ ); +}; CheckboxField.displayName = "CheckboxField"; diff --git a/apps/web/components/ui/form/MinutesField.tsx b/apps/web/components/ui/form/MinutesField.tsx index 42d147ef6a1173..0aff3861762cb0 100644 --- a/apps/web/components/ui/form/MinutesField.tsx +++ b/apps/web/components/ui/form/MinutesField.tsx @@ -1,12 +1,20 @@ import classNames from "classnames"; import type { InputHTMLAttributes, ReactNode } from "react"; -import React, { forwardRef } from "react"; +import React from "react"; type Props = InputHTMLAttributes & { label?: ReactNode; }; -const MinutesField = forwardRef(({ label, ...rest }, ref) => { +const MinutesField = ( + { + ref, + label, + ...rest + }: Props & { + ref: React.RefObject; + } +) => { return (
{!!label && ( @@ -36,7 +44,7 @@ const MinutesField = forwardRef(({ label, ...rest }, re
); -}); +}; MinutesField.displayName = "MinutesField"; diff --git a/packages/app-store/routing-forms/components/FormActions.tsx b/packages/app-store/routing-forms/components/FormActions.tsx index fbe6f8ed465b23..0e1ed77f62f781 100644 --- a/packages/app-store/routing-forms/components/FormActions.tsx +++ b/packages/app-store/routing-forms/components/FormActions.tsx @@ -1,6 +1,6 @@ import type { App_RoutingForms_Form } from "@prisma/client"; import { usePathname, useRouter } from "next/navigation"; -import { createContext, forwardRef, useContext, useState } from "react"; +import { createContext, useContext, useState } from "react"; import { Controller, useForm } from "react-hook-form"; import { v4 as uuidv4 } from "uuid"; import { z } from "zod"; @@ -386,9 +386,13 @@ type FormActionProps = { extraClassNames?: string; } & ButtonProps; -export const FormAction = forwardRef(function FormAction( - props: FormActionProps, - forwardedRef: React.ForwardedRef +export const FormAction = function FormAction( + { + ref: forwardedRef, + ...props + }: FormActionProps & { + ref: React.RefObject; + } ) { const { action: actionName, @@ -517,4 +521,4 @@ export const FormAction = forwardRef(function FormAction ); -}); +}; diff --git a/packages/features/bookings/Booker/components/Section.tsx b/packages/features/bookings/Booker/components/Section.tsx index abfcbc76ea9efc..e8ae93bca9eee1 100644 --- a/packages/features/bookings/Booker/components/Section.tsx +++ b/packages/features/bookings/Booker/components/Section.tsx @@ -1,6 +1,5 @@ import type { MotionProps } from "framer-motion"; import { m } from "framer-motion"; -import { forwardRef } from "react"; import { classNames } from "@calcom/lib"; @@ -40,9 +39,17 @@ const gridAreaClassNameMap: { [key in BookerAreas]: string } = { /** * Small helper compnent that renders a booker section in a specific grid area. */ -export const BookerSection = forwardRef(function BookerSection( - { children, area, visible, className, ...props }, - ref +export const BookerSection = function BookerSection( + { + ref, + children, + area, + visible, + className, + ...props + }: BookerSectionProps & { + ref: React.RefObject; + } ) { const layout = useBookerStore((state) => state.layout); let gridClassName: string; @@ -60,4 +67,4 @@ export const BookerSection = forwardRef(func {children} ); -}); +}; diff --git a/packages/features/calendars/weeklyview/components/grid/index.tsx b/packages/features/calendars/weeklyview/components/grid/index.tsx index 682e84f26d2707..2f6ba8ed857aa5 100644 --- a/packages/features/calendars/weeklyview/components/grid/index.tsx +++ b/packages/features/calendars/weeklyview/components/grid/index.tsx @@ -7,9 +7,16 @@ type Props = { zIndex?: number; }; -export const SchedulerColumns = React.forwardRef(function SchedulerColumns( - { offsetHeight, gridStopsPerDay, children, zIndex }, - ref +export const SchedulerColumns = function SchedulerColumns( + { + ref, + offsetHeight, + gridStopsPerDay, + children, + zIndex + }: Props & { + ref: React.RefObject; + } ) { return (
    (functi {children}
); -}); +}; diff --git a/packages/features/embed/lib/EmbedTabs.tsx b/packages/features/embed/lib/EmbedTabs.tsx index 654ee273bbf384..11b36f38b1aa54 100644 --- a/packages/features/embed/lib/EmbedTabs.tsx +++ b/packages/features/embed/lib/EmbedTabs.tsx @@ -1,5 +1,4 @@ import type { MutableRefObject } from "react"; -import { forwardRef } from "react"; import type { BookerLayout } from "@calcom/features/bookings/Booker/types"; import { APP_NAME } from "@calcom/lib/constants"; @@ -20,10 +19,15 @@ export const tabs = [ href: "embedTabName=embed-code", icon: "code" as const, type: "code", - Component: forwardRef< - HTMLTextAreaElement | HTMLIFrameElement | null, - { embedType: EmbedType; calLink: string; previewState: PreviewState; namespace: string } - >(function EmbedHtml({ embedType, calLink, previewState, namespace }, ref) { + Component: function EmbedHtml( + { + ref, + embedType, + calLink, + previewState, + namespace + } + ) { const { t } = useLocale(); const embedSnippetString = useGetEmbedSnippetString(namespace); const embedCalOrigin = useEmbedCalOrigin(); @@ -69,17 +73,22 @@ export const tabs = [

{t("need_help_embedding")}

); - }), + }, }, { name: "React", href: "embedTabName=embed-react", icon: "code" as const, type: "code", - Component: forwardRef< - HTMLTextAreaElement | HTMLIFrameElement | null, - { embedType: EmbedType; calLink: string; previewState: PreviewState; namespace: string } - >(function EmbedReact({ embedType, calLink, previewState, namespace }, ref) { + Component: function EmbedReact( + { + ref, + embedType, + calLink, + previewState, + namespace + } + ) { const { t } = useLocale(); const embedCalOrigin = useEmbedCalOrigin(); @@ -118,17 +127,20 @@ export const tabs = [ /> ); - }), + }, }, { name: "Preview", href: "embedTabName=embed-preview", icon: "trello" as const, type: "iframe", - Component: forwardRef< - HTMLIFrameElement | HTMLTextAreaElement | null, - { calLink: string; embedType: EmbedType; previewState: PreviewState; namespace: string } - >(function Preview({ calLink, embedType }, ref) { + Component: function Preview( + { + ref, + calLink, + embedType + } + ) { const bookerUrl = useBookerUrl(); const iframeSrc = `${EMBED_PREVIEW_HTML_URL}?embedType=${embedType}&calLink=${calLink}&embedLibUrl=${embedLibUrl}&bookerUrl=${bookerUrl}`; if (ref instanceof Function || !ref) { @@ -148,7 +160,7 @@ export const tabs = [ key={iframeSrc} /> ); - }), + }, }, ]; diff --git a/packages/features/filters/components/TeamsFilter.tsx b/packages/features/filters/components/TeamsFilter.tsx index 74700545ccc687..9f3e95b5d5eedd 100644 --- a/packages/features/filters/components/TeamsFilter.tsx +++ b/packages/features/filters/components/TeamsFilter.tsx @@ -1,6 +1,5 @@ import { useSession } from "next-auth/react"; import type { InputHTMLAttributes, ReactNode } from "react"; -import { forwardRef } from "react"; import { classNames } from "@calcom/lib"; import { getPlaceholderAvatar } from "@calcom/lib/defaultAvatarImage"; @@ -147,7 +146,16 @@ type Props = InputHTMLAttributes & { icon?: ReactNode; }; -export const FilterCheckboxField = forwardRef(({ label, icon, ...rest }, ref) => { +export const FilterCheckboxField = ( + { + ref, + label, + icon, + ...rest + }: Props & { + ref: React.RefObject; + } +) => { return (
); -}); +}; FilterCheckboxField.displayName = "FilterCheckboxField"; diff --git a/packages/platform/atoms/src/components/ui/button.tsx b/packages/platform/atoms/src/components/ui/button.tsx index f44261ad80c240..f35e1c02c10951 100644 --- a/packages/platform/atoms/src/components/ui/button.tsx +++ b/packages/platform/atoms/src/components/ui/button.tsx @@ -36,12 +36,21 @@ export interface ButtonProps asChild?: boolean; } -const Button = React.forwardRef( - ({ className, variant, size, asChild = false, ...props }, ref) => { - const Comp = asChild ? Slot : "button"; - return ; +const Button = ( + { + ref, + className, + variant, + size, + asChild = false, + ...props + }: ButtonProps & { + ref: React.RefObject; } -); +) => { + const Comp = asChild ? Slot : "button"; + return ; +}; Button.displayName = "Button"; export { Button, buttonVariants }; diff --git a/packages/platform/atoms/src/components/ui/dialog.tsx b/packages/platform/atoms/src/components/ui/dialog.tsx index e35cad9be85962..4bfbb2770d36f4 100644 --- a/packages/platform/atoms/src/components/ui/dialog.tsx +++ b/packages/platform/atoms/src/components/ui/dialog.tsx @@ -13,42 +13,49 @@ const DialogPortal = DialogPrimitive.Portal; const DialogClose = DialogPrimitive.Close; -const DialogOverlay = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - & { + ref: React.RefObject>; + } +) => (); +DialogOverlay.displayName = DialogPrimitive.Overlay.displayName; + +const DialogContent = ( + { + ref, + className, + children, + ...props + }: React.ComponentPropsWithoutRef & { + ref: React.RefObject>; + } +) => (<> + + -)); -DialogOverlay.displayName = DialogPrimitive.Overlay.displayName; - -const DialogContent = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, children, ...props }, ref) => ( - <> - - - {children} - - - Close - - - -)); + {...props}> + {children} + + + Close + + +); DialogContent.displayName = DialogPrimitive.Content.displayName; const DialogHeader = ({ className, ...props }: React.HTMLAttributes) => ( @@ -64,28 +71,34 @@ const DialogFooter = ({ className, ...props }: React.HTMLAttributes, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)); +const DialogTitle = ( + { + ref, + className, + ...props + }: React.ComponentPropsWithoutRef & { + ref: React.RefObject>; + } +) => (); DialogTitle.displayName = DialogPrimitive.Title.displayName; -const DialogDescription = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)); +const DialogDescription = ( + { + ref, + className, + ...props + }: React.ComponentPropsWithoutRef & { + ref: React.RefObject>; + } +) => (); DialogDescription.displayName = DialogPrimitive.Description.displayName; export { diff --git a/packages/platform/atoms/src/components/ui/toast.tsx b/packages/platform/atoms/src/components/ui/toast.tsx index 1d0f0f8f170bb2..3836c173c939ac 100644 --- a/packages/platform/atoms/src/components/ui/toast.tsx +++ b/packages/platform/atoms/src/components/ui/toast.tsx @@ -8,19 +8,22 @@ import { cn } from "../../lib/utils"; const ToastProvider = ToastPrimitives.Provider; -const ToastViewport = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)); +const ToastViewport = ( + { + ref, + className, + ...props + }: React.ComponentPropsWithoutRef & { + ref: React.RefObject>; + } +) => (); ToastViewport.displayName = ToastPrimitives.Viewport.displayName; const toastVariants = cva( @@ -38,60 +41,76 @@ const toastVariants = cva( } ); -const Toast = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef & VariantProps ->(({ className, variant, ...props }, ref) => { +const Toast = ( + { + ref, + className, + variant, + ...props + } +) => { return ; -}); +}; Toast.displayName = ToastPrimitives.Root.displayName; -const ToastAction = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)); +const ToastAction = ( + { + ref, + className, + ...props + }: React.ComponentPropsWithoutRef & { + ref: React.RefObject>; + } +) => (); ToastAction.displayName = ToastPrimitives.Action.displayName; -const ToastClose = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - - - -)); +const ToastClose = ( + { + ref, + className, + ...props + }: React.ComponentPropsWithoutRef & { + ref: React.RefObject>; + } +) => ( + +); ToastClose.displayName = ToastPrimitives.Close.displayName; -const ToastTitle = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)); +const ToastTitle = ( + { + ref, + className, + ...props + }: React.ComponentPropsWithoutRef & { + ref: React.RefObject>; + } +) => (); ToastTitle.displayName = ToastPrimitives.Title.displayName; -const ToastDescription = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)); +const ToastDescription = ( + { + ref, + className, + ...props + }: React.ComponentPropsWithoutRef & { + ref: React.RefObject>; + } +) => (); ToastDescription.displayName = ToastPrimitives.Description.displayName; type ToastProps = React.ComponentPropsWithoutRef; diff --git a/packages/ui/components/alert/Alert.tsx b/packages/ui/components/alert/Alert.tsx index 98ae1dc2f0af22..7739ea6566a607 100644 --- a/packages/ui/components/alert/Alert.tsx +++ b/packages/ui/components/alert/Alert.tsx @@ -1,6 +1,5 @@ import classNames from "classnames"; import type { ReactNode } from "react"; -import { forwardRef } from "react"; import { Icon, type IconName } from "../.."; @@ -17,7 +16,14 @@ export interface AlertProps { CustomIcon?: IconName; customIconColor?: string; } -export const Alert = forwardRef((props, ref) => { +export const Alert = ( + { + ref, + ...props + }: AlertProps & { + ref: React.RefObject; + } +) => { const { severity, iconClassName, CustomIcon, customIconColor } = props; return ( @@ -98,6 +104,6 @@ export const Alert = forwardRef((props, ref) => {
); -}); +}; Alert.displayName = "Alert"; diff --git a/packages/ui/components/button/Button.tsx b/packages/ui/components/button/Button.tsx index 1a0495438bf0c8..211d570d9bea02 100644 --- a/packages/ui/components/button/Button.tsx +++ b/packages/ui/components/button/Button.tsx @@ -2,7 +2,7 @@ import type { VariantProps } from "class-variance-authority"; import { cva } from "class-variance-authority"; import type { LinkProps } from "next/link"; import Link from "next/link"; -import React, { forwardRef } from "react"; +import React from "react"; import classNames from "@calcom/lib/classNames"; @@ -115,9 +115,13 @@ export const buttonClasses = cva( } ); -export const Button = forwardRef(function Button( - props: ButtonProps, - forwardedRef +export const Button = function Button( + { + ref: forwardedRef, + ...props + }: ButtonProps & { + ref: React.RefObject; + } ) { const { loading = false, @@ -232,7 +236,7 @@ export const Button = forwardRef ); -}); +}; const Wrapper = ({ children, diff --git a/packages/ui/components/command/index.tsx b/packages/ui/components/command/index.tsx index c6a7b961c20696..37a70305a62c28 100644 --- a/packages/ui/components/command/index.tsx +++ b/packages/ui/components/command/index.tsx @@ -6,19 +6,22 @@ import { classNames } from "@calcom/lib"; import { Dialog, DialogContent } from "../dialog"; -const Command = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)); +const Command = ( + { + ref, + className, + ...props + }: React.ComponentPropsWithoutRef & { + ref: React.RefObject>; + } +) => (); Command.displayName = CommandPrimitive.displayName; type CommandDialogProps = DialogProps; @@ -35,85 +38,104 @@ const CommandDialog = ({ children, ...props }: CommandDialogProps) => { ); }; -const CommandInput = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( -
- -
-)); - -CommandInput.displayName = CommandPrimitive.Input.displayName; - -const CommandList = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - & { + ref: React.RefObject>; + } +) => (
+ -)); +
); + +CommandInput.displayName = CommandPrimitive.Input.displayName; + +const CommandList = ( + { + ref, + className, + ...props + }: React.ComponentPropsWithoutRef & { + ref: React.RefObject>; + } +) => (); CommandList.displayName = CommandPrimitive.List.displayName; -const CommandEmpty = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->((props, ref) => ); +const CommandEmpty = ( + { + ref, + ...props + }: React.ComponentPropsWithoutRef & { + ref: React.RefObject>; + } +) => ; CommandEmpty.displayName = CommandPrimitive.Empty.displayName; -const CommandGroup = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)); +const CommandGroup = ( + { + ref, + className, + ...props + }: React.ComponentPropsWithoutRef & { + ref: React.RefObject>; + } +) => (); CommandGroup.displayName = CommandPrimitive.Group.displayName; -const CommandSeparator = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)); +const CommandSeparator = ( + { + ref, + className, + ...props + }: React.ComponentPropsWithoutRef & { + ref: React.RefObject>; + } +) => (); CommandSeparator.displayName = CommandPrimitive.Separator.displayName; -const CommandItem = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - -)); +const CommandItem = ( + { + ref, + className, + ...props + }: React.ComponentPropsWithoutRef & { + ref: React.RefObject>; + } +) => (); CommandItem.displayName = CommandPrimitive.Item.displayName; diff --git a/packages/ui/components/dialog/Dialog.tsx b/packages/ui/components/dialog/Dialog.tsx index 9df8d7105504a0..76bd3c51e960be 100644 --- a/packages/ui/components/dialog/Dialog.tsx +++ b/packages/ui/components/dialog/Dialog.tsx @@ -90,66 +90,76 @@ type DialogContentProps = React.ComponentProps<(typeof DialogPrimitive)["Content }; // enableOverflow:- use this prop whenever content inside DialogContent could overflow and require scrollbar -export const DialogContent = React.forwardRef( - ({ children, title, Icon: icon, enableOverflow, type = "creation", ...props }, forwardedRef) => { - const isPlatform = useIsPlatform(); - const [Portal, Overlay, Content] = useMemo( - () => - isPlatform - ? [ - ({ children }: { children: ReactElement | ReactElement[] }) => <>{children}, - PlatformDialogPrimitives.DialogOverlay, - PlatformDialogPrimitives.DialogContent, - ] - : [DialogPrimitive.Portal, DialogPrimitive.Overlay, DialogPrimitive.Content], - [isPlatform] - ); - return ( - - - - {type === "creation" && ( -
- -
- {children} -
+export const DialogContent = ( + { + ref: forwardedRef, + children, + title, + Icon: icon, + enableOverflow, + type = "creation", + ...props + }: DialogContentProps & { + ref: React.RefObject; + } +) => { + const isPlatform = useIsPlatform(); + const [Portal, Overlay, Content] = useMemo( + () => + isPlatform + ? [ + ({ children }: { children: ReactElement | ReactElement[] }) => <>{children}, + PlatformDialogPrimitives.DialogOverlay, + PlatformDialogPrimitives.DialogContent, + ] + : [DialogPrimitive.Portal, DialogPrimitive.Overlay, DialogPrimitive.Content], + [isPlatform] + ); + return ( + + + + {type === "creation" && ( +
+ +
+ {children}
- )} - {type === "confirmation" && ( -
- {icon && ( -
- -
- )} -
- -
{children}
+
+ )} + {type === "confirmation" && ( +
+ {icon && ( +
+
+ )} +
+ +
{children}
- )} - {!type && children} - - - ); - } -); +
+ )} + {!type && children} + + + ); +}; type DialogHeaderProps = { title: React.ReactNode; @@ -179,10 +189,10 @@ type DialogFooterProps = { export function DialogFooter(props: DialogFooterProps) { return ( -
+ (
{props.showDivider && ( // TODO: the -mx-8 is causing overflow in the dialog buttons -
+ (
) )}
{props.children}
-
+
) ); } @@ -199,14 +209,19 @@ DialogContent.displayName = "DialogContent"; export const DialogTrigger: ForwardRefExoticComponent< DialogPrimitive.DialogTriggerProps & React.RefAttributes -> = React.forwardRef((props, ref) => { +> = ( + { + ref, + ...props + } +) => { const isPlatform = useIsPlatform(); return !isPlatform ? ( ) : ( ); -}); +}; DialogTrigger.displayName = "DialogTrigger"; diff --git a/packages/ui/components/form/checkbox/Checkbox.tsx b/packages/ui/components/form/checkbox/Checkbox.tsx index 8dc84724ef3bf8..8410cc66a37592 100644 --- a/packages/ui/components/form/checkbox/Checkbox.tsx +++ b/packages/ui/components/form/checkbox/Checkbox.tsx @@ -1,7 +1,7 @@ import * as CheckboxPrimitive from "@radix-ui/react-checkbox"; import { useId } from "@radix-ui/react-id"; import type { InputHTMLAttributes } from "react"; -import React, { forwardRef } from "react"; +import React from "react"; import classNames from "@calcom/lib/classNames"; import { Icon } from "@calcom/ui"; @@ -20,95 +20,108 @@ type Props = InputHTMLAttributes & { descriptionAsSafeHtml?: string; }; -const Checkbox = React.forwardRef< - React.ElementRef, - React.ComponentPropsWithoutRef ->(({ className, ...props }, ref) => ( - - - - - -)); +const Checkbox = ( + { + ref, + className, + ...props + }: React.ComponentPropsWithoutRef & { + ref: React.RefObject>; + } +) => ( + + + +); Checkbox.displayName = CheckboxPrimitive.Root.displayName; -const CheckboxField = forwardRef( - ({ label, description, error, disabled, descriptionAsSafeHtml, ...rest }, ref) => { - const descriptionAsLabel = !label || rest.descriptionAsLabel; - const id = useId(); - return ( -
- {label && ( -
- {React.createElement( - descriptionAsLabel ? "div" : "label", - { - className: classNames("flex text-sm font-medium text-emphasis"), - ...(!descriptionAsLabel - ? { - htmlFor: rest.id ? rest.id : id, - } - : {}), - }, - label - )} -
- )} -
-
- {React.createElement( - descriptionAsLabel ? "label" : "div", - { - className: classNames( - "relative flex items-start", - !error && descriptionAsLabel ? "text-emphasis" : "text-emphasis", - error && "text-error" - ), - }, - <> -
- -
- {descriptionAsSafeHtml ? ( - - ) : ( - {description} - )} - - )} - {/* {informationIconText && } */} -
+const CheckboxField = ( + { + ref, + label, + description, + error, + disabled, + descriptionAsSafeHtml, + ...rest + }: Props & { + ref: React.RefObject; + } +) => { + const descriptionAsLabel = !label || rest.descriptionAsLabel; + const id = useId(); + return ( +
+ {label && ( +
+ {React.createElement( + descriptionAsLabel ? "div" : "label", + { + className: classNames("flex text-sm font-medium text-emphasis"), + ...(!descriptionAsLabel + ? { + htmlFor: rest.id ? rest.id : id, + } + : {}), + }, + label + )} +
+ )} +
+
+ {React.createElement( + descriptionAsLabel ? "label" : "div", + { + className: classNames( + "relative flex items-start", + !error && descriptionAsLabel ? "text-emphasis" : "text-emphasis", + error && "text-error" + ), + }, + <> +
+ +
+ {descriptionAsSafeHtml ? ( + + ) : ( + {description} + )} + + )} + {/* {informationIconText && } */}
- ); - } -); +
+ ); +}; CheckboxField.displayName = "CheckboxField"; diff --git a/packages/ui/components/form/dropdown/Dropdown.tsx b/packages/ui/components/form/dropdown/Dropdown.tsx index cd09315c335ae6..796025658f33ef 100644 --- a/packages/ui/components/form/dropdown/Dropdown.tsx +++ b/packages/ui/components/form/dropdown/Dropdown.tsx @@ -1,7 +1,6 @@ import * as DropdownMenuPrimitive from "@radix-ui/react-dropdown-menu"; import Link from "next/link"; import type { ComponentProps } from "react"; -import { forwardRef } from "react"; import { classNames } from "@calcom/lib"; import { Icon, type IconName } from "@calcom/ui"; @@ -11,18 +10,22 @@ import type { ButtonColor } from "../../button/Button"; export const Dropdown = DropdownMenuPrimitive.Root; type DropdownMenuTriggerProps = ComponentProps<(typeof DropdownMenuPrimitive)["Trigger"]>; -export const DropdownMenuTrigger = forwardRef( - ({ className = "", ...props }, forwardedRef) => ( - - ) -); +export const DropdownMenuTrigger = ( + { + ref: forwardedRef, + className = "", + ...props + }: DropdownMenuTriggerProps & { + ref: React.RefObject; + } +) => (); DropdownMenuTrigger.displayName = "DropdownMenuTrigger"; export const DropdownMenuTriggerItem = DropdownMenuPrimitive.Trigger; @@ -30,24 +33,32 @@ export const DropdownMenuTriggerItem = DropdownMenuPrimitive.Trigger; export const DropdownMenuPortal = DropdownMenuPrimitive.Portal; type DropdownMenuContentProps = ComponentProps<(typeof DropdownMenuPrimitive)["Content"]>; -export const DropdownMenuContent = forwardRef( - ({ children, sideOffset = 2, align = "end", ...props }, forwardedRef) => { - return ( - *:first-child]:mt-1 [&>*:last-child]:mb-1", - props.className - )} - ref={forwardedRef}> - {children} - - ); +export const DropdownMenuContent = ( + { + ref: forwardedRef, + children, + sideOffset = 2, + align = "end", + ...props + }: DropdownMenuContentProps & { + ref: React.RefObject; } -); +) => { + return ( + *:first-child]:mt-1 [&>*:last-child]:mb-1", + props.className + )} + ref={forwardedRef}> + {children} + + ); +}; DropdownMenuContent.displayName = "DropdownMenuContent"; type DropdownMenuLabelProps = ComponentProps<(typeof DropdownMenuPrimitive)["Label"]>; @@ -56,49 +67,65 @@ export const DropdownMenuLabel = (props: DropdownMenuLabelProps) => ( ); type DropdownMenuItemProps = ComponentProps<(typeof DropdownMenuPrimitive)["CheckboxItem"]>; -export const DropdownMenuItem = forwardRef( - ({ className = "", ...props }, forwardedRef) => ( - - ) -); +export const DropdownMenuItem = ( + { + ref: forwardedRef, + className = "", + ...props + }: DropdownMenuItemProps & { + ref: React.RefObject; + } +) => (); DropdownMenuItem.displayName = "DropdownMenuItem"; export const DropdownMenuGroup = DropdownMenuPrimitive.Group; type DropdownMenuCheckboxItemProps = ComponentProps<(typeof DropdownMenuPrimitive)["CheckboxItem"]>; -export const DropdownMenuCheckboxItem = forwardRef( - ({ children, ...props }, forwardedRef) => { - return ( - - {children} - - - - - ); +export const DropdownMenuCheckboxItem = ( + { + ref: forwardedRef, + children, + ...props + }: DropdownMenuCheckboxItemProps & { + ref: React.RefObject; } -); +) => { + return ( + + {children} + + + + + ); +}; DropdownMenuCheckboxItem.displayName = "DropdownMenuCheckboxItem"; export const DropdownMenuRadioGroup = DropdownMenuPrimitive.RadioGroup; type DropdownMenuRadioItemProps = ComponentProps<(typeof DropdownMenuPrimitive)["RadioItem"]>; -export const DropdownMenuRadioItem = forwardRef( - ({ children, ...props }, forwardedRef) => { - return ( - - {children} - - - - - ); +export const DropdownMenuRadioItem = ( + { + ref: forwardedRef, + children, + ...props + }: DropdownMenuRadioItemProps & { + ref: React.RefObject; } -); +) => { + return ( + + {children} + + + + + ); +}; DropdownMenuRadioItem.displayName = "DropdownMenuRadioItem"; type DropdownItemProps = { @@ -153,17 +180,23 @@ export const DropdownItem = (props: DropdownItemProps) => { }; type DropdownMenuSeparatorProps = ComponentProps<(typeof DropdownMenuPrimitive)["Separator"]>; -export const DropdownMenuSeparator = forwardRef( - ({ className = "", ...props }, forwardedRef) => { - return ( - - ); +export const DropdownMenuSeparator = ( + { + ref: forwardedRef, + className = "", + ...props + }: DropdownMenuSeparatorProps & { + ref: React.RefObject; } -); +) => { + return ( + + ); +}; DropdownMenuSeparator.displayName = "DropdownMenuSeparator"; export default Dropdown; diff --git a/packages/ui/components/form/inputs/Input.tsx b/packages/ui/components/form/inputs/Input.tsx index fef01c209e0074..8085cad1878c84 100644 --- a/packages/ui/components/form/inputs/Input.tsx +++ b/packages/ui/components/form/inputs/Input.tsx @@ -1,5 +1,5 @@ import type { ReactNode } from "react"; -import React, { forwardRef, useCallback, useId, useState } from "react"; +import React, { useCallback, useId, useState } from "react"; import { useFormContext } from "react-hook-form"; import classNames from "@calcom/lib/classNames"; @@ -17,9 +17,13 @@ export function InputLeading(props: JSX.IntrinsicElements["div"]) { ); } -export const PasswordField = forwardRef(function PasswordField( - props, - ref +export const PasswordField = function PasswordField( + { + ref, + ...props + }: InputFieldProps & { + ref: React.RefObject; + } ) { const { t } = useLocale(); const [isPasswordVisible, setIsPasswordVisible] = useState(false); @@ -58,9 +62,16 @@ export const PasswordField = forwardRef(funct } /> ); -}); +}; -export const EmailInput = forwardRef(function EmailInput(props, ref) { +export const EmailInput = function EmailInput( + { + ref, + ...props + }: InputFieldProps & { + ref: React.RefObject; + } +) { return ( (function {...props} /> ); -}); +}; -export const EmailField = forwardRef(function EmailField(props, ref) { +export const EmailField = function EmailField( + { + ref, + ...props + }: InputFieldProps & { + ref: React.RefObject; + } +) { return ( (function {...props} /> ); -}); +}; type TextAreaProps = JSX.IntrinsicElements["textarea"]; -export const TextArea = forwardRef(function TextAreaInput(props, ref) { +export const TextArea = function TextAreaInput( + { + ref, + ...props + }: TextAreaProps & { + ref: React.RefObject; + } +) { return (