The date-range picker, a port of calendar-range/calendar-range.tsx.
Renders as <calendar-range>. The first click on a day starts a range and
fires onRangeStart; the range then follows the pointer (and the keyboard)
until a second click sorts the pair, fires onRangeEnd and then onChange.
Everything the picker remembers for itself.
tentative is the first click of a range, Cally's tentative property, and
hovered is the day the provisional range currently reaches to.
Opaque. Route it back with update through Config.toMsg.
Everything Cally takes as a prop, plus the messages this picker sends you.
id prefixes every DOM id the picker renders, so it must be unique on the page
and stable across renders; focus uses those ids.
How the previous and next buttons move: a whole page of months at a time,
or one month at a time. Cally's page-by.
What focus should put the browser focus on.
A Config with Cally's defaults: one month, paged by months, narrow
weekday names, no outside days, no week numbers, and the locale's own first day
of the week.
The starting model. Focus lands on the start of the value, or on today
when there is no value, clamped to min and max.
Render the picker. The children are the months, and anything else that
reads the Context; each one is applied to the Context so it can sit
anywhere in the tree.
The update you wire into your own.
Consumer callbacks (onChange, onFocusDay, onPageChange) come back as
commands, so they arrive as ordinary messages on the next update. The command
also carries the Browser.Dom.focus call that keyboard navigation needs.
The pure core of update.
events are the callbacks the message produced, in the order Cally dispatches
them, and focus is the element the picker wants the browser focus on
afterwards (Cally's setTimeout(focus)). update is this function with the
two turned into commands; tests use this one.
Put the browser focus on the day that holds tabindex="0", or on one of
the paging buttons. Cally's focus({ target }).
Move the roving focus, Cally's focused-date property. The date is clamped
to min and max, and the page follows it.
The Context this picker hands its children. Exposed so you can build a
child on your own, and so tests can inspect it.
What this picker selects: a start and an end, or nothing. The pair is always sorted.