import React, { useRef } from "react"; import { AriaDatePickerProps, useDateField, useDateSegment, } from "@react-aria/datepicker"; import { useLocale } from "@react-aria/i18n"; import { DateFieldState, useDateFieldState, DateSegment, } from "@react-stately/datepicker"; import { createCalendar, DateValue } from "@internationalized/date"; import classNames from "classnames"; import { LabelledBox, Props } from ":/components/Forms/LabelledBox"; interface DateSegmentProps { currentSegment: DateSegment; previousSegment: DateSegment; state: DateFieldState; } const DateSegmentInput = ({ currentSegment, previousSegment, state, }: DateSegmentProps) => { const ref = useRef(null); const { segmentProps } = useDateSegment(currentSegment, state, ref); return (
{currentSegment.text}
); }; const DateField = (props: AriaDatePickerProps) => { const { locale } = useLocale(); const state = useDateFieldState({ ...props, locale, createCalendar, }); const ref = useRef(null); const { fieldProps } = useDateField(props, state, ref); return (
{state.segments.map((segment, i, segments) => ( ))}
); }; interface DateFieldBoxProps extends Props, Omit, "label"> {} const DateFieldBox = ({ ...props }: DateFieldBoxProps) => (
); export default DateFieldBox;