import type { ReactNode } from "react"; import type { TravelCalendarSizeVariant } from "./components/TravelCalendar"; export interface TravelDateRangeInputValue { startDate?: string; endDate?: string; } export type VisiblePanel = "calendar" | "month-picker"; export type DateTextInputVariant = "standard" | "labelled"; /** * What a date cell knows about itself, for rendering custom content in it. * * The flags describe the cell as it is drawn, which is not always the same as * the value. While the user hovers out a new range, the hovered range is what * the calendar shows, so that is what the flags follow too. */ export interface TravelDateContentContext { date: Date; dayOfMonth: number; size: TravelCalendarSizeVariant; isToday: boolean; isDisabled: boolean; /** * Drawn as the start of the selection, with the filled background. In a * calendar for a single date, this is the selected date. */ isSelectionStart: boolean; /** * Drawn as the end of the selection. In a calendar for a single date, this * is also the selected date. */ isSelectionEnd: boolean; /** Drawn inside the range band, between the start and the end. */ isInRange: boolean; /** Under the mouse, or reached with the arrow keys. */ isHovered: boolean; /** * The day number the calendar would have rendered. Render it to extend the * default content, or leave it out to replace it. */ defaultContent: ReactNode; /** * The mark the calendar puts on today's date, or null on any other date, so * it can be rendered unconditionally. It has no position of its own, so it * goes wherever it is placed. Use isToday instead to draw a marker of your * own. */ defaultTodayMarker: ReactNode; } /** * Renders the content of one date cell, in place of the day number. * * Only the content is replaced. The cell itself, with the selection, the hover * ring, the range band, focus and keyboard navigation, stays the calendar's. * * The content cannot be clicked or hovered: pointer events go to the cell, so * that the whole cell stays one hit area. Do not render interactive elements. * * The cell has no label of its own, so screen readers announce this content * as the date. Write it to be heard, and use ScreenReaderOnlyText where the * visible text is abbreviated or is an icon. * * It is called for every date in the visible month each time the calendar * renders, which includes every move of the mouse. Keep it to a lookup. * * Text in it can follow the colour of the day number, such as white on the * filled selection, with color: var(--travel-calendar-date-content-color). */ export type RenderTravelDateContent = (context: TravelDateContentContext) => ReactNode;