import { useId } from "@radix-ui/react-id"; import type { InputHTMLAttributes } from "react"; import React, { forwardRef } from "react"; import classNames from "@calcom/lib/classNames"; type Props = InputHTMLAttributes & { label?: React.ReactNode; description: string; descriptionAsLabel?: boolean; informationIconText?: string; error?: boolean; className?: string; descriptionClassName?: string; }; const CheckboxField = forwardRef( ({ label, description, error, disabled, ...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-red-800" ), }, <>
{description} )} {/* {informationIconText && } */}
); } ); CheckboxField.displayName = "CheckboxField"; export default CheckboxField;