import * as React from "react" import { DateInput, type DateInputProps } from "./date" import { cn } from "@/lib/utils" export type DateRangeValue = { from?: string to?: string } export type DateRangeInputProps = Omit, "onChange"> & { value?: DateRangeValue onValueChange?: (value: DateRangeValue) => void fromPlaceholder?: string toPlaceholder?: string fromInputProps?: Omit toInputProps?: Omit separator?: React.ReactNode inputClassName?: string } function DateRangeInput({ className, value, onValueChange, fromPlaceholder = "From", toPlaceholder = "To", fromInputProps, toInputProps, separator = "—", inputClassName, ...props }: DateRangeInputProps) { const nextValue = (patch: DateRangeValue) => { onValueChange?.({ from: value?.from ?? "", to: value?.to ?? "", ...patch, }) } return (
nextValue({ from })} {...fromInputProps} /> {separator} nextValue({ to })} {...toInputProps} />
) } export { DateRangeInput }