import { type OutputHTMLAttributes, type ReactNode } from 'react';
import type { FieldBoxSize } from './fieldBox.js';
/** What a field's control takes to be named, described and marked by its field. Spread it
* on the control: `{(control) => }`. */
export interface FieldControlProps {
id: string;
/** Set for a group, which its legend names rather than a label. */
'aria-labelledby'?: string | undefined;
'aria-describedby'?: string | undefined;
'aria-invalid'?: true | undefined;
'aria-required'?: true | undefined;
}
/** Set by a layout that lines up the fields in a row, as a form's grid does: a stacked field's
* label and control take the row's label and control tracks, so controls under labels of
* different lengths line up. The layout makes the field's box a subgrid of two rows. */
export declare const FieldRowContext: import("react").Context;
/** The surrounding Field's control props, for a control drawn further down than the Field's
* own children. Null outside a Field. */
export declare function useFieldControl(): FieldControlProps | null;
/** The id for a control of this package placed in a Field: its own, or else the one the Field
* was given, which the label's `for` points at. Otherwise Base UI ties the label to the control
* itself. */
export declare function useFieldControlId(id: string | undefined): string | undefined;
/** Whether a control of this package placed in a Field is required, for it to carry
* `aria-required`: the Field's asterisk is hidden from assistive technology, so the control says
* so itself. Never in a group, whose options aren't each required. */
export declare function useFieldRequired(): true | undefined;
/** The surrounding Field's control props for a control that isn't a Base UI one, such as a
* code editor, a button that opens a picker or an ``, which the label's `for` can't
* name. The props name it by the label's id instead, and while it is mounted the label drops
* its `for`, which would point at no element, and focuses the control by its id when clicked.
* Null outside a Field. */
export declare function useFieldLabelledControl(): (FieldControlProps & {
'aria-labelledby': string;
}) | null;
export type FieldLayout = 'stacked' | 'inline';
export interface FieldProps {
label: ReactNode;
/** Beside the label and outside it, so it stays out of the control's name, such as a count. For
* help text, use `help`. */
hint?: ReactNode;
/** More about the field, behind a ? beside the label. It is read with the control as part of
* its description, so the ? is hidden from assistive technology and Tab passes over it. It
* opens on hover or press of the ?, and while the control has keyboard focus, until Escape.
* `[text](url)` links and line breaks show as such; a link keeps the ? in the Tab order, as
* the keyboard's way to it. */
help?: string | undefined;
/** Buttons at the far end of the label's row that act on the field, such as one that
* switches its control to a typed expression. */
actions?: ReactNode;
/** Help under the control, read with it. */
description?: ReactNode;
/** A message under the control. It also marks the control invalid. */
error?: ReactNode;
/** Marks the control invalid without a message, for one shown elsewhere. */
invalid?: boolean | undefined;
/** Ends the label in an asterisk, and the control says it's required. */
required?: boolean | undefined;
disabled?: boolean | undefined;
/** `stacked` puts the label above the control. `inline` puts it in a column to the left, as a
* form lays out its fields. */
layout?: FieldLayout | undefined;
/** With `inline`, the label takes only its own width rather than the column's. */
compact?: boolean | undefined;
/** Matches the label to a control of the same `size`. At `sm` the label is a small, muted
* caption for a compact control, such as a picker in a toolbar, and an inline label's row
* is the `sm` control's height. Set the control's own `size` to match. */
size?: FieldBoxSize | undefined;
/** A set of controls, such as radios or checkboxes, that a legend names instead of a label. */
group?: boolean | undefined;
/** Puts a checkbox, a switch or a lone radio before its label, as such a control reads: the
* control, then its label and ?, with the description and error under the label. A click on
* the label sets the control. A checkbox or a radio sits on the label's first line; a switch
* centers on the text's first two lines, such as the label and its description, and stays
* there under longer text. Inline it sits in the control column, under the controls above
* it; in a row of fields, its first line centers on the controls beside it, a switch's too.
* Not for a `group`, whose options are each a `FieldOption`. */
controlFirst?: boolean | undefined;
/** The control's id; one is made up when left out. */
id?: string | undefined;
className?: string | undefined;
/** The control, or a function that places the control props on it. Any control of this
* package, such as Input, Select, Combobox, NumberInput, Switch or DatePicker, takes its id,
* label, description and invalid state from the Field on its own; a native element needs the
* function. A value shown but not edited goes in a `FieldValue`. */
children: ReactNode | ((control: FieldControlProps) => ReactNode);
}
export interface ErrorTextProps {
id?: string | undefined;
/** `sm` is a Field's own error, under one control; `md` is for an error
* about a whole form or an action, such as a Save that failed. */
size?: 'sm' | 'md' | undefined;
/** Sits in a line of text instead of a line of its own, in that text's size; `size`
* applies only on a line of its own. */
inline?: boolean | undefined;
/** Places it, such as its margins, or a card footer's rule and padding. */
className?: string | undefined;
/** Nothing renders without it, so an error that may be absent needs no guard. */
children: ReactNode;
}
/** An error in the look a Field gives its own, for a control outside a Field, or for a part of
* one rather than the whole of it, such as a row of a list editor; `size="md"` for an error
* under a whole form or after an action. It is announced as it appears. Give it an `id` and
* name it in the control's `aria-describedby` so the error is read with the control. */
export declare function ErrorText({ id, size, inline, className, children, }: ErrorTextProps): import("react").JSX.Element | null;
/** A control with its label, help and error, tied to it for assistive technology. One frame
* for every field, in a form or standing alone. */
export declare function Field({ label, hint, help, actions, description, error, invalid, required, disabled, layout, compact, size, group, controlFirst, id: ownId, className, children, }: FieldProps): import("react").JSX.Element;
/** One checkbox or radio and its label inside a Field, such as an option of a group. A bare
* `` there would take the Field's label as its own, so every option read as the field. */
export declare function FieldOption({ disabled, className, children, }: {
disabled?: boolean | undefined;
className?: string | undefined;
children: ReactNode;
}): import("react").JSX.Element;
/** The eye button inside a secret's box that shows or hides what was typed. Give the box
* room for it on the right, such as `pr-9`. */
export declare function RevealToggle({ revealed, onRevealedChange, disabled, align, size, }: {
revealed: boolean;
onRevealedChange: (revealed: boolean) => void;
disabled?: boolean | undefined;
/** `top` keeps it on the first line of a tall box, such as a textarea's, of the box's
* `size`. */
align?: 'center' | 'top' | undefined;
size?: FieldBoxSize | undefined;
}): import("react").JSX.Element;
export interface FieldValueProps extends OutputHTMLAttributes {
/** Matches the height and text of the controls around it, as `size` does on a control. */
size?: FieldBoxSize | undefined;
}
/** A value a Field shows that nobody edits, such as one worked out from other fields. It is an
* ``, which the Field's label names and which reads out when the value changes; list
* the controls it is worked out from in `htmlFor`. It keeps a control's height, so it lines
* up with the fields around it. For a set of names and values on their own, use
* DescriptionList. */
export declare function FieldValue({ size, className, children, ...props }: FieldValueProps): import("react").JSX.Element;