Files
front-ui-registry/.tooling/components/ui/calendar.tsx

30 lines
780 B
TypeScript

import type { HTMLAttributes } from "react";
import { cn } from "@/lib/utils";
export type CalendarDateRange = {
from?: Date;
to?: Date;
};
type CalendarBaseProps = Omit<HTMLAttributes<HTMLDivElement>, "onSelect">;
type CalendarSingleProps = CalendarBaseProps & {
mode: "single";
selected?: Date;
onSelect?: (date: Date | undefined) => void;
initialFocus?: boolean;
};
type CalendarRangeProps = CalendarBaseProps & {
mode: "range";
selected?: CalendarDateRange;
onSelect?: (range: CalendarDateRange | undefined) => void;
initialFocus?: boolean;
};
export type CalendarProps = CalendarSingleProps | CalendarRangeProps;
export function Calendar({ className, ...props }: CalendarProps) {
return <div className={cn(className)} data-mode={props.mode} />;
}