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
| Prop | Type | Default | Description |
|---|---|---|---|
value | { preset: DatePreset | 'custom'; range: DayRange } | required | The current preset and range |
onChange | (next: { preset: DatePreset | 'custom'; range: DayRange }) => void | required | Called on a preset row (immediately) and on Done (the calendar's range) |
timezone | string | required | IANA zone of the store, or device |
now | () => Date | Time of the press | The clock presets and today are worked out from |
earliestDay | StoreDay | — | The earliest store day the data covers; the calendar's minimum |
testID | string | 'reports-period' | Test ID of the trigger, and the prefix of the menu's test IDs |