Tally UI

DateRangeMenu

Pick a Reports period from the date presets or a custom range on a calendar.

Import

import { DateRangeMenu } from '@tallyui/components';

Usage

<DateRangeMenu value={{ preset: filters.preset, range: filters.range }} timezone={timezone}
  earliestDay={earliestDay}
  onChange={({ preset, range }) => setFilters({ ...filters, preset, range })} />

The trigger shows the preset name and the range, for example “This Week · 3–10 Nov”. The menu lists the presets Today, Yesterday, This Week, Last Week, This Month and Last Month, worked out in store time by presetRange from @tallyui/pos, beside a range calendar that ends today. A preset row applies at once. Done applies the calendar's range, and names it with a preset when the range matches one, otherwise as a custom range. Below 768 px wide the presets stack above the calendar. SalesFiltersBar uses this menu for its period.

Props

PropTypeDefaultDescription
value{ preset: DatePreset | 'custom'; range: DayRange }requiredThe current preset and range
onChange(next: { preset: DatePreset | 'custom'; range: DayRange }) => voidrequiredCalled on a preset row (immediately) and on Done (the calendar's range)
timezonestringrequiredIANA zone of the store, or device
now() => DateTime of the pressThe clock presets and today are worked out from
earliestDayStoreDay—The earliest store day the data covers; the calendar's minimum
testIDstring'reports-period'Test ID of the trigger, and the prefix of the menu's test IDs

On this page