import type { ReactNode } from "react"; import React, { forwardRef, useCallback, useId, useState } from "react"; import { useFormContext } from "react-hook-form"; import classNames from "@calcom/lib/classNames"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { Alert, Input, InputField, Tooltip } from "../../.."; import { Eye, EyeOff, Search } from "../../icon"; import { Label } from "./Label"; import type { InputFieldProps } from "./types"; export function InputLeading(props: JSX.IntrinsicElements["div"]) { return ( {props.children} ); } export const PasswordField = forwardRef(function PasswordField( props, ref ) { const { t } = useLocale(); const [isPasswordVisible, setIsPasswordVisible] = useState(false); const toggleIsPasswordVisible = useCallback( () => setIsPasswordVisible(!isPasswordVisible), [isPasswordVisible, setIsPasswordVisible] ); const textLabel = isPasswordVisible ? t("hide_password") : t("show_password"); return ( toggleIsPasswordVisible()}> {isPasswordVisible ? ( ) : ( )} {textLabel} } /> ); }); export const EmailInput = forwardRef(function EmailInput(props, ref) { return ( ); }); export const EmailField = forwardRef(function EmailField(props, ref) { return ( ); }); type TextAreaProps = JSX.IntrinsicElements["textarea"]; export const TextArea = forwardRef(function TextAreaInput(props, ref) { return ( ); }); type TextAreaFieldProps = { label?: ReactNode; t?: (key: string) => string; } & React.ComponentProps & { name: string; labelProps?: React.ComponentProps; }; export const TextAreaField = forwardRef(function TextField( props, ref ) { const id = useId(); const { t: _t } = useLocale(); const t = props.t || _t; const methods = useFormContext(); const { label = t(props.name as string), labelProps, /** Prevents displaying untranslated placeholder keys */ placeholder = t(props.name + "_placeholder") !== props.name + "_placeholder" ? t(props.name + "_placeholder") : "", ...passThrough } = props; return ( {!!props.name && ( {label} )} {methods?.formState?.errors[props.name]?.message && ( {methods.formState.errors[props.name]?.message}>} /> )} ); }); export function FieldsetLegend(props: JSX.IntrinsicElements["legend"]) { return ( {props.children} ); } export function InputGroupBox(props: JSX.IntrinsicElements["div"]) { return ( {props.children} ); } export const NumberInput = forwardRef(function NumberInput(props, ref) { return ( ); }); export const FilterSearchField = forwardRef(function TextField( props, ref ) { return ( ); });