DateRangePicker
Two-click range selection over one Calendar, with preset shortcuts down the side.
Presets, or click a start then an end.
Pass presets={[]} when the shortcuts do not fit the domain.
import { DateRangePicker, type DateRange } from '@objectifthunes/whiteboard'
const [range, setRange] = useState<DateRange>({ start: null, end: null })
<DateRangePicker value={range} onChange={setRange} fullWidth />
// custom shortcuts — built at click time from today
<DateRangePicker
value={range}
onChange={setRange}
presets={[
{ label: 'This sprint', range: t => ({ start: addDays(t, -13), end: t }) },
{ label: 'Year to date', range: t => ({ start: new Date(t.getFullYear(), 0, 1), end: t }) },
]}
/>First click sets the start and clears the end, second click closes the range. Clicking a day before the pending start treats it as the new start rather than rejecting it, which is what people actually mean when they overshoot.
The popover stays open until both ends exist, so a half-finished range can never leak out to the caller. onChange only ever fires with both start and end set, or with both null on clear.
Presets are functions of "today", not fixed dates, so "Last 7 days" stays correct across a session and after midnight. DEFAULT_RANGE_PRESETS is exported if you want to extend rather than replace the list.
Reopening lands back on the selected range, not wherever you last paged to. Under 640px the preset column moves above the grid as a two-column strip.