import * as React from "react"; import classNames from "classnames"; import { AriaDatePickerProps, DateValue, useDatePicker } from "react-aria"; import { useDatePickerState } from "react-stately"; import { Calendar as CalendarIcon } from "@faulty/gdq-icons/icons/Calendar"; import { Card } from "../Card/Card"; import { Clickable } from "../Clickable/Clickable"; import { Control, ControlInputProps } from "../Control/Control"; import { InputAttachmentProps, InputWithAttachments, useInputStyleClasses } from "../Input/Input"; import { useInteractiveClass } from "../Interactive/Interactive"; import { Stack } from "../Stack/Stack"; import { Calendar } from "./Calendar"; import { DateTimeField } from "./DateTimeField"; import { PickerPopover } from "./PickerPopover"; import styles from "./DatePicker.module.css"; export interface DatePickerProps extends AriaDatePickerProps, ControlInputProps, InputAttachmentProps { // TODO: Not sure of the best way to inherent these props directly /** * Determines whether the date picker popover should close automatically when a date is selected. * @default true */ shouldCloseOnSelect?: boolean | (() => boolean); } export function DatePicker(props: DatePickerProps) { const inputStyles = useInputStyleClasses(props); const ref = React.useRef(null); const state = useDatePickerState(props); const { buttonProps, calendarProps, dialogProps, labelProps, descriptionProps, fieldProps, errorMessageProps, groupProps, } = useDatePicker(props, state, ref); const interactiveClass = useInteractiveClass({ background: true }); return (
{state.isOpen ? ( ) : null}
); }