import { type Dispatch, type FocusEventHandler, type ReactNode } from 'react'; import type { FormControlState } from '../../../core/types/form-control-state.js'; import { type FormFieldMessagesReducerAction } from '../state/formfield-messages-state-reducer.js'; import type { FormFieldMessageContextState, ValidationVisibility } from '../types/formfield-messages.types.js'; export type { ValidationVisibility } from '../types/formfield-messages.types.js'; /** * Props for `useFormControl`. Mirrors the inputs of the legacy form-control * hook stack that Strato controls used to call individually. * @internal — Strato controls only. */ export interface UseFormControlProps { /** Control id passed directly to the form control. */ propId?: string; /** Disabled state passed directly to the form control. */ propDisabled?: boolean; /** Aria-disabled state passed directly to the form control. */ propAriaDisabled?: boolean | 'true' | 'false'; /** Required state passed directly to the form control. */ propRequired?: boolean; /** Read-only state passed directly to the form control. */ propReadOnly?: boolean; /** * Legacy `controlState` plumbing for hint/error. * Removed by APPDEV-8298. */ controlState?: FormControlState; /** * When validation errors first become visible. Defaults to `'immediate'`. * @internal */ validationVisibility?: ValidationVisibility; } /** @internal */ export interface UseFormControlReturnType { id: string; disabled: boolean | undefined; required: boolean | undefined; readOnly: boolean | undefined; ariaDisabled: boolean | undefined; inputProps: { 'aria-describedby'?: string; 'aria-invalid': boolean; }; hintProps: { id: string; 'aria-live': 'polite'; }; /** Hint content from the legacy `controlState` prop, if any. */ hint: ReactNode; /** True if the control should render error styling right now. Disabled-gated. */ showError: boolean; /** Always present (defaults to empty state when no FormField wraps). */ messageState: FormFieldMessageContextState; /** Undefined when no FormField wraps the control. */ messageDispatch: Dispatch | undefined; /** * Focus handlers for the element that defines "the field". Only * meaningful in `'on-blur'` mode; an empty object otherwise, so callers * can spread it unconditionally. * @internal */ focusHandlers: { onFocus?: FocusEventHandler; onBlur?: FocusEventHandler; }; /** * Reveal any error immediately, ignoring touched and focus. Wire to a * control's imperative `validate()` so parent-driven validation paints the * error even while focus is still inside the field. * @internal */ revealErrors: () => void; } /** * Single entry point for Strato controls to wire id, disabled/required/readOnly * synchronisation with the FormField context, error/hint plumbing, and ARIA * attributes. Has no knowledge of `_Form`; that wiring lives in * `useInternalFormRegistration`. * @internal — Strato controls only. */ export declare function useFormControl({ propId, propDisabled, propAriaDisabled, propRequired, propReadOnly, controlState, validationVisibility, }: UseFormControlProps): UseFormControlReturnType; //# sourceMappingURL=useFormControl.d.ts.map