๐ Date Picker Components
Date selection components built on a shared CalendarMonth grid.
graph LR
CAL["CalendarMonth<br/><small>Monthly grid ยท Keyboard nav<br/>Locale-aware ยท Highlights</small>"]
CAL --> SDP["SingleDatePicker<br/><small>Single date dropdown</small>"]
CAL --> DRP["DateRangePicker<br/><small>Start/end range with presets</small>"]
SDP -.->|used by| DE["DataEditor"]
SDP -.->|used by| BF["BrokerForm"]
SDP -.->|used by| TFM["TransactionFormModal"]
SDP -.->|used by| ECM["EventCreateMiniModal"]
SDP -.->|used by| SIE["ScheduledInvestmentEditor"]
SDP -.->|used by| BDM["BoundaryDateModal"]
DRP -.->|used by| PG["Page toolbars<br/><small>Dashboard ยท Broker detail<br/>FX list ยท FX detail<br/>Assets list ยท Asset detail</small>"]
DRP -.->|used by| MP["MeasurePanel"]
DRP -.->|used by| DTF["DataTableColumnFilter"]
DRP -.->|used by| CDR["CellDateRange"]
DRP -.->|used by| L4R["L4Replay"]
style CAL fill:#e3f2fd,color:#1b1b1b,stroke:#1565c0
style SDP fill:#e3f2fd,color:#1b1b1b,stroke:#1565c0
style DRP fill:#e3f2fd,color:#1b1b1b,stroke:#1565c0
๐ CalendarMonth
A monthly calendar grid component โ the visual building block for date pickers.
- Displays a single month with day cells
- Highlights today, selected date, and date range
- Keyboard navigation within the grid
- Locale-aware (week starts on Monday for most locales)
- The pending day (
highlights.pending, the day of a first click inDateRangePicker) cannot be chosen again: it is adisabledbutton with the not-allowed cursor, as a future day is, while its colour and itsdata-statestay those of the pending day. The click handler refuses it as well, as it refusesdisabledDates, because a dispatched click (what Testing Library'sfireEvent.clicksends in jsdom) still reaches a disabled button's handlers.SingleDatePickernever setspending, so its grid is unaffected.
Used by: SingleDatePicker, DateRangePicker.
๐ SingleDatePicker
A single-date picker dropdown with calendar.
- Opens a
CalendarMonthin a dropdown - Manual text input with date parsing
- Month/year navigation with arrows
- Formats date according to locale
Used by:
- DataEditor โ the date of a newly added row; the dates already in the series are disabled
- BrokerForm โ Account Opened, never in the future
- TransactionFormModal โ the transaction date and, for a pair, the To side's own date
- EventCreateMiniModal โ the date of an asset event created inline from the transaction form
- ScheduledInvestmentEditor โ the date of each event row of the schedule
- BoundaryDateModal โ the boundary date(s) that ScheduledInvestmentEditor asks for when it deletes or splits a period
๐ DateRangePicker
A date range picker with start and end dates.
- Two
CalendarMonthgrids side by side (current + next month) - Visual highlight of selected range
- Quick presets: 1W, 1M, 3M, 6M, 1Y, 2Y, YTD and MAX, plus a custom window (an amount
and a granularity). 3Y, 5Y, 10Y, MTD, QTD and WTD fill the toolbar only when a JS
measurement finds room to spare, never at the cost of an extra line (
DateRangePicker.svelte:36,216-251) - Start and end date text inputs
Used by:
- Page toolbars โ the period of the Dashboard, broker detail, FX list, FX detail, Assets list and asset detail pages (Pages)
- MeasurePanel โ the two dates of a measure, without presets, while its row is expanded
- DataTableColumnFilter โ the filter of a
datecolumn, where either end may stay blank - CellDateRange โ the Period cell of each row in ScheduledInvestmentEditor's period table (Scheduled Investment Provider)
- L4Replay โ the replay period, with quick ranges but no
MAX
๐ซ No range of a single day
A range always spans two different days (lot Y-N65, developer decision of 2026-10-19): every way
into the picker refuses an end on the other end's day. The comparison is between real dates only:
a blank end, or a min/max sentinel, never matches a date.
- Calendar. The first click leaves its day pending (
pendingDate, handed to both grids ashighlights.pending, which disables it).handleDayClickignores a second click on that day: nothing is published, the calendar stays open and the day stays pending. The next different day clicked closes the range, sorted.handleDayHoverpreviews the range from the pending day to the day under the pointer, and nothing while the pointer is on the pending day itself. - Typed date.
isAcceptableDate(which, iso)is the calendar's ceiling (isSelectableDate: no future day unlessallowFuture) plus "not the other end's day". A date equal to the other end is refused like a typed future date: it stays in its field, turns red once armed (blur or Enter,data-invalid="true"), and nothing is published. It is applied as soon as the other end moves to another day:applyRangeDatetakes the waiting date (waitingTypedDate) together with the new one, as a pair, and the usual swap orders the two dates the user wrote. Typing ยซFromยป as the old ยซToยป, then a new ยซToยป, applies both at once. - โ/โ on a field. A step that would land on the other end's day goes one day further in the same direction, and the swap still applies. When that further day is a future day the picker refuses, the step does nothing.
Open ends. A date typed while the other end is blank, or holds the min/max sentinel of
MAX (ยซAllยป), leaves that end as it is. Before Y-N65 the other end was filled with the same date,
a range of one day.
| Range before | Date typed | Published | Meaning |
|---|---|---|---|
('', '') |
ยซFromยป X | (X, '') |
from X on |
('', '') |
ยซToยป X | ('', X) |
up to X |
('min', 'max') |
ยซFromยป X | (X, 'max') |
from X to today |
('min', 'max') |
ยซToยป X | ('min', X) |
from the first data up to X |
A blank end is the open range of a date column filter. The pages
resolve the sentinels as they always have, through resolveDateSentinel
(lib/stores/dateRangeStore.svelte.ts), then the first date of their data for min.
Ranges of one day saved earlier still load and work as they are: the page period in
sessionStorage (librefolio_dateRange) or in the URL (?start=&end=), a table filter in the
URL, a scheduled-investment period. Only new ones can no longer be made.
The cases are pinned in DateRangePicker.test.ts and CalendarMonth.test.ts (their Y-N65
describes).