Skip to Content
Urban Cowboy
Components

Inline Date Range Picker

Two-month calendar with rate overlay, restriction advisories and hover preview.

InlineDateRangePicker is the standalone calendar used by DateSearchDropdown and SearchBarExpanded. It renders two months, shows nightly rates or restriction badges, and supports hover preview of check-out dates. The demo keeps the range in local state; it does not load live rates from Mews.

Props

PropValuesNotes
checkIn / checkOutISO date stringsControlled range; empty = unselected
minDateISO date stringEarliest selectable day; defaults to today (UTC)
dailyRatesRecord<string, DailyRate>Optional rate/restriction data for calendar cells
formatRate(rate) => stringCustom rate formatter (default: currency, 0 decimals)
onChange(checkIn, checkOut) => voidCalled when range changes
onVisibleRangeChange(start, end) => voidReports visible months for rate pre-fetch

DailyRate shape

interface DailyRate {
  amount: number;
  currency?: string;
  available?: boolean;
  minNights?: number;
  invalidStayLengths?: number[];
  restrictions?: RestrictionAdvisory[];
}

interface RestrictionAdvisory {
  type: 'ClosedToArrival' | 'ClosedToDeparture' | 'ClosedToStay';
}

Visual states

StateAppearanceMeaning
Selected check-inFilled circle, primary backgroundStart of stay
Selected check-outFilled circle, primary backgroundEnd of stay
In-rangeBackground washNights between check-in and check-out
Hover preview (check-out)Outline + in-range washPreview of candidate check-out
Minimum nights advisoryRing + tooltipStay shorter than minNights
Invalid stay lengthRing + tooltipStay length in invalidStayLengths
Restriction badgeDot + tooltipClosedToArrival/Departure/Stay on that date
Unavailable (cached)Crossed out, mutedavailable === false — advisory only, remains selectable; live Search validates
Past / before minDateCrossed out, disabledNot selectable

Accessibility

  • Month headers as role="grid" with column headers (M–S)
  • Each day is a <button role="gridcell"> with aria-selected, aria-pressed, aria-label
  • Month navigation buttons have aria-label (Previous/Next month)
  • Escape is handled by the parent dialog (DateSearchDropdown)
  • Focus visible ring on every interactive element
  • Tooltips on restriction/min-nights via group-hover on the day button
  • Note: Day-level keyboard navigation (arrow keys, Page Up/Down, Home/End) is not currently implemented; use month navigation buttons or mouse/touch.

Responsive behaviour

  • Two months side-by-side on md (768px+) with a vertical divider
  • Single month stacked on smaller screens
  • Fixed 6-week grid per month prevents layout shift when navigating
  • Rate text uses tabular figures (font-number) for alignment

Performance notes

  • Month cell arrays are cached (42 cells × 2 months) to avoid re-allocation on hover
  • Intl.NumberFormat and Intl.DateTimeFormat instances are module-level singletons
  • Restriction checks memoized per visible month pair
  • Selected range header memoized to avoid re-formatting on hover

Usage

import { InlineDateRangePicker } from '@/components/booking/search/InlineDateRangePicker';

<InlineDateRangePicker
  checkIn={range.checkIn}
  checkOut={range.checkOut}
  dailyRates={rates}
  onChange={(checkIn, checkOut) => setRange({ checkIn, checkOut })}
  onVisibleRangeChange={prefetchRates}
/>

View source