react-hook-form-bound single-date field. Wraps the @uxf/ui/date-picker-input primitive and manages its value, isInvalid, and helperText from form state.
Use @uxf/form/date-picker-input for a date field inside a @uxf/form form — it registers the field with react-hook-form via control/name and renders validation errors automatically. For a standalone, manually-controlled date input (outside a form), use the @uxf/ui/date-picker-input twin directly. For a date range use @uxf/form/date-range-picker-input.
import { DatePickerInput, DatePickerInputValue } from "@uxf/form/date-picker-input";
import { Form } from "@uxf/form/form";
import { useForm } from "react-hook-form";
interface FormData {
date: DatePickerInputValue;
}
function Example() {
const formApi = useForm<FormData>({ defaultValues: { date: null } });
return (
<Form formApi={formApi} id="example" onSubmit={(values) => console.log(values)}>
<DatePickerInput control={formApi.control} isClearable isRequired label="Date" name="date" />
</Form>
);
}
DatePickerInputValue = string | null — an ISO date string in OUTPUT_DATE_FORMAT ("YYYY-MM-DD"), or null when empty. This is what is stored in the form values (and what min/max validation compares against). The input still displays the value using displayDateFormat (default "D. M. YYYY"); see the twin for display/parsing details.
DatePickerInputProps<FormData> = ControlProps<FormData> + the visual props of the @uxf/ui/date-picker-input twin (minus the ones this field manages: isFocused, isInvalid, max, min, name, onChange, pattern, step, value) + the field-specific props below.
| Prop | Type | Default | Description |
|---|---|---|---|
control |
Control<FormData> |
— | Required. The control from useForm. |
name |
FieldPath<FormData> |
— | Required. Field path in the form values. |
rules |
RegisterOptions |
— | Extra react-hook-form rules; merged with the built-in validation below. |
shouldUnregister |
boolean |
— | Unregister the field (drop its value) on unmount. |
isRequired |
boolean |
false |
Adds a required rule and the required indicator. |
requiredMessage |
string |
localized | Message for the required rule. |
minDate |
string |
— | Earliest allowed date, ISO YYYY-MM-DD; constrains the calendar and adds a min-date validation. |
maxDate |
string |
— | Latest allowed date, ISO YYYY-MM-DD; constrains the calendar and adds a max-date validation. |
onChange |
(value: string | null, event?) => void |
— | Called after the field value updates. |
All other props (label, placeholder, size, variant, helperText, isClearable, displayDateFormat, allowedDateFormats, datesConfig, triggerElement, leftAddon/rightAddon/leftElement/rightElement, bottomContent, popoverPlacement/popoverStrategy, …) are forwarded to the twin — see @uxf/ui/date-picker-input. id defaults to `${formId}__${name}`.
Built-in rules (messages come from the uxf-form-date-picker-input:validation.* translations; override the required one with requiredMessage):
isRequired.YYYY-MM-DD, otherwise invalid-date-format (interpolates the displayDateFormat).minDate / maxDate is set and the value falls outside the range.rules; a function rules.validate is merged under the custom key. The field-level error is shown as the twin's helperText and sets isInvalid.Form — it reads the form context (formId, and inherits isDisabled / isReadOnly) and needs a react-hook-form control.@uxf/ui/date-picker-input, so include that component's stylesheet(s) and the @uxf/ui token layer — see @uxf/ui/date-picker-input.@uxf/ui/date-picker-input