import type { ReactNode } from 'react'; import { InlineMessage } from '~/components/ui/inline-message'; import { Label } from '~/components/ui/label'; import { Text } from '~/components/ui/text'; interface FieldProps { label: string; htmlFor?: string; required?: boolean; hint?: string; error?: string; // Shown on the right of the label: "Optional" / "Required" requirement?: 'optional' | 'required'; action?: ReactNode; children?: ReactNode; } export function Field({ label, htmlFor, required, hint, error, requirement, action, children }: FieldProps) { return (
{action ?? (requirement && {requirement === 'optional' ? 'Optional' : 'Required'})}
{children} {error ? {error} : hint && {hint}}
); }