react-hook-form-bound date-and-time field. Wraps the @uxf/ui/datetime-picker-input primitive and manages its value, isInvalid, and helperText from form state.
Use @uxf/form/datetime-picker-input for a combined date + time 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 datetime input (outside a form), use the @uxf/ui/datetime-picker-input twin directly. For a date-only field use @uxf/form/date-picker-input; for time-only use @uxf/form/time-picker-input.
import { DatetimePickerInput, DatetimePickerInputValue } from "@uxf/form/datetime-picker-input";
import { Form } from "@uxf/form/form";
import { useForm } from "react-hook-form";
interface FormData {
datetime: DatetimePickerInputValue;
}
function Example() {
const formApi = useForm<FormData>({ defaultValues: { datetime: null } });
return (
<Form formApi={formApi} id="example" onSubmit={(values) => console.log(values)}>
<DatetimePickerInput control={formApi.control} isClearable isRequired label="Date and time" name="datetime" />
</Form>
);
}
DatetimePickerInputValue = string | null — an ISO 8601 datetime string (e.g. from dayjs(...).toISOString()), or null when empty. The input displays it as D. M. YYYY H:mm (DISPLAY_DATETIME_FORMAT); see the twin for parsing/display details.
DatetimePickerInputProps<FormData> = ControlProps<FormData> + the visual props of the @uxf/ui/datetime-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 (compared at date granularity). |
maxDate |
string |
— | Latest allowed date, ISO YYYY-MM-DD; constrains the calendar and adds a max-date validation (compared at date granularity). |
CustomDatetimePicker |
(props: { value; onChange; onClose }) => ReactNode |
— | Render a custom picker body in the popover instead of the default one. |
onChange |
(value: string | null, event?) => void |
— | Called after the field value updates. |
All other props (label, placeholder, size, variant, helperText, isClearable, triggerElement, leftAddon/rightAddon/leftElement/rightElement, bottomContent, unavailableDates, popoverPlacement/popoverStrategy, …) are forwarded to the twin — see @uxf/ui/datetime-picker-input. id defaults to `${formId}__${name}`.
Built-in rules (messages come from the uxf-form-datetime-picker-input:validation.* translations; override the required one with requiredMessage):
isRequired.invalid-datetime-format (interpolates DISPLAY_DATETIME_FORMAT).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/datetime-picker-input, so include that component's stylesheet(s) and the @uxf/ui token layer — see @uxf/ui/datetime-picker-input.@uxf/ui/datetime-picker-input