import React, { forwardRef, ReactNode, useRef } from 'react' import * as Ariakit from '@ariakit/react' import * as styles from './styles.css' import { Box } from '../Box/Box' import { Text } from '../Text/Text' import { Stack } from '../Stack/Stack' import { Button, ButtonProps } from '../Button/Button' import clsx, { ClassValue } from 'clsx' import { Variants } from './styles.css' import { Badge } from '../Badge/Badge' type FormComponent = React.FC & { Input: typeof Input Error: typeof Error Submit: typeof Submit Field: typeof Field Select: typeof Select NamedSection: typeof NamedSection Label: typeof Label useFormStore: typeof Ariakit.useFormStore } interface LabelProps { label: string name: Ariakit.FormInputProps['name'] tag?: ReactNode optional?: boolean } export const Label: React.FC = ({ label, name, tag, optional }) => { return ( {label && ( {label} {tag} )} {optional && } ) } type HasLabel = { name: Ariakit.FormInputProps['name'] label?: string optional?: boolean tag?: ReactNode icon?: ReactNode } export const NamedSection = ({ children, label, name, tag, icon, optional = false, }: React.PropsWithChildren) => { return label ? ( {label && {children} ) : ( <>{children} ) } const FormContext = React.createContext( {} as Ariakit.FormStore, ) export const useForm = () => React.useContext(FormContext) type Props = Ariakit.FormProps export const Form: FormComponent = ({ children, ...props }: Props) => { return ( {children} ) } export const Error = ({ ...props }: Ariakit.FormErrorProps) => { return } /> } export const Submit = ({ ...props }: ButtonProps) => { return