import React, { type PropsWithChildren, type ReactElement } from "react"; import classnames from "classnames"; import FieldDocLabel from "./FieldDocLabel"; import Doc from "./Doc"; import generateUniqueId from "../libs/document-uid"; export type FieldsetProps = PropsWithChildren & { label?: string, fieldSpec?: { doc?: string }, action?: ReactElement, error?: {message: string} }; const Fieldset: React.FC = (props) => { const [showDoc, setShowDoc] = React.useState(false); const labelId = React.useRef(generateUniqueId("fieldset_label_")); const onToggleDoc = (val: boolean) => { setShowDoc(val); }; return (
{props.fieldSpec && (
)} {!props.fieldSpec && (
{props.label}
)}
{props.action}
{props.children}
{props.fieldSpec && (
)}
); }; export default Fieldset;