Date Search Dropdown
Date picker dropdown with calendar, quick-select ranges and confirm actions.
DateSearchDropdown wraps the inline calendar in a dialog with quick-select presets and an optional confirm action. The demo keeps the selected range in local state and reports callbacks; it does not fetch live rates from Mews.
Variants
Default (confirm variant)
The confirm variant shows a Confirm dates button that closes the dialog when a complete range is selected.
Unselected
The Unselected story demonstrates the empty state with no dates chosen.
External actions
The external-actions variant hides the confirm button and quick-select; the caller owns the commit/close flow.
Props
| Prop | Values | Notes |
|---|---|---|
variant | confirm, external-actions | confirm shows quick-select + confirm button; external-actions delegates to caller |
checkIn / checkOut | ISO date strings | Controlled range; empty = unselected |
dailyRates | Record<string, DailyRate> | Optional rate overlay for calendar cells |
showQuickSelect | boolean | Show quick-select presets (default: true in confirm variant) |
onChange | (checkIn, checkOut) => void | Called when range changes |
onClose | () => void | Called when dialog should close |
onVisibleRangeChange | (start, end) => void | Reports visible calendar months for rate pre-fetch |
triggerRef | React.RefObject<HTMLElement> | Optional external trigger for focus return |
DailyRate shape
interface DailyRate {
amount: number;
currency?: string;
available?: boolean;
minNights?: number;
invalidStayLengths?: number[];
restrictions?: RestrictionAdvisory[];
}
Accessibility
- Dialog role with
aria-label="Select dates of stay" - Calendar grid with
role="grid"and column headers - Selected dates announced via
aria-selectedandaria-pressed - Escape key closes and returns focus to trigger
- Month navigation via Previous/Next month buttons (keyboard accessible)
- Disabled dates (before
minDate) are crossed out and non-interactive; cachedavailable: falsedates remain selectable (advisory only — live Search validates availability)
Responsive behaviour
- Dialog constrained to
max-w-[760px]with horizontal padding - Calendar shows two months side-by-side on
mdand up; single month on smaller screens - Quick-select buttons wrap on narrow viewports
- Touch targets meet 44×44 minimum
Usage
import { DateSearchDropdown } from '@/components/booking/search/DateSearchDropdown';
<DateSearchDropdown
checkIn={range.checkIn}
checkOut={range.checkOut}
dailyRates={rates}
onChange={(checkIn, checkOut) => setRange({ checkIn, checkOut })}
onClose={onClose}
onVisibleRangeChange={prefetchRates}
/>