import { FormHelperTextProps, FormLabelProps } from "../../common/types/mui.js"; import "../../common/index.js"; import { JSX, ReactNode, Ref } from "react"; import { Control, FieldError, FieldValues, Path, RegisterOptions } from "react-hook-form"; import { DesktopTimePickerProps, PickerChangeHandlerContext, PickerValidDate, TimeValidationError } from "@mui/x-date-pickers"; import { CustomComponentIds } from "@nish1896/mui-components/types"; //#region src/mui-pickers/time/RHFDesktopTimePicker.d.ts type DesktopTimePickerInputProps = Omit; type PickerOnValueChangeProps = { newValue: PickerValidDate; context: PickerChangeHandlerContext; }; type PickerCustomOnChangeProps = PickerOnValueChangeProps & { rhfOnChange: (value: PickerValidDate) => void; }; type RHFDesktopTimePickerProps = { /** * Name/path of the React Hook Form field this component controls. */ fieldName: Path; /** * React Hook Form control object returned by `useForm`. */ control: Control; /** * Validation rules passed to React Hook Form for this field. */ registerOptions?: RegisterOptions>; /** * When true, marks the field as required in the UI and accessibility attributes. */ required?: boolean; /** * Overrides the default time picker change handling. * Receives every picker change, including time values that currently have validation errors. * Call `rhfOnChange` with the picker value that should be stored; else the form value will not be updated. * The default handler stores the value only when `context.validationError` is `null`. * * @param rhfOnChange - React Hook Form field change handler for the selected time value. * @param newValue - New time value emitted by MUI X. * @param context - MUI X picker change context, including validation status. */ customOnChange?: ({ rhfOnChange, newValue, context }: PickerCustomOnChangeProps) => void; /** * Called after the default time picker handler stores a valid time value in React Hook Form. * * ⚠️ Important: * This callback is not called when `customOnChange` is used. * * @param newValue - New time value emitted by MUI X. * @param context - MUI X picker change context, including validation status. */ onValueChange?: ({ newValue, context }: PickerOnValueChangeProps) => void; /** * When `true`, renders the label above the component instead of within the field layout. */ showLabelAboveFormField?: boolean; /** * Props forwarded to the internal `FormLabel`. The `id` is managed by the component. */ formLabelProps?: Omit; /** * When true, hides the rendered field label while preserving accessible labeling where possible. */ hideLabel?: boolean; /** * Custom renderer for the React Hook Form field error. * Receives the current field error and must return renderable content, such as `error.message` or a custom element. * * @param error - React Hook Form field error for this field. */ renderError?: (error: FieldError) => ReactNode; /** * If true, hides the error message text while keeping the field in an error state. */ hideErrorMessage?: boolean; /** * Helper text shown below the field when there is no visible validation error. */ helperText?: ReactNode; /** * Props forwarded to the internal `FormHelperText`. The `id` is managed by the component. */ formHelperTextProps?: Omit; /** * Custom ids for generated field, label, helper text, and error elements. */ customIds?: CustomComponentIds; } & DesktopTimePickerInputProps; /** * Controlled, desktop-only MUI X `DesktopTimePicker`, wired to a React Hook * Form field via `control`. * * Opens the clock in a popper rather than a modal. * * Docs: [RHFTimePicker](https://rhf-mui-components.vercel.app/components/mui-pickers/RHFTimePicker) * * API: [RHFDesktopTimePickerProps](https://rhf-mui-components.vercel.app/components/mui-pickers/RHFTimePicker#api) */ declare const RHFDesktopTimePicker: (props: RHFDesktopTimePickerProps & { ref?: Ref; }) => JSX.Element; //#endregion export { RHFDesktopTimePickerProps, RHFDesktopTimePicker as default };