PeriodPicker
A report period: a month, a quarter, a year or a custom date range. calendar="hijri" gives Umm al-Qura months, quarters (3 months) and years (“1448 AH”); the value is Gregorian ISO days in both calendars. The lists end on today, newest first: 24 months, 8 quarters, 5 years. A change of kind keeps the end of the current period, so September 2026 becomes Q3 2026, then 2026. A custom range with one day chosen is that day; a cleared range goes back to this month. kinds limits the choice. For reports with a custom range: presets are the preset buttons of the range (the DateRangePicker ids, for example today, yesterday, last7Days, last30Days; default as in DateRangePicker), weekStart is the first day of the week in the range calendar and in "This week" (0 Sunday … 6 Saturday; default 0), and clearTo is the period a cleared custom range goes back to (default: this month).
import { PeriodPicker, periodOf, periodOptions, type Period, type PeriodKind } from "@percentsa/ui";Examples
2026-12-01 – 2026-12-31
Code
export function PeriodPickerExample() {
const [period, setPeriod] = useState<Period>(() => periodOf("month", todayPlain()));
return (
<Stack gap={3}>
<PeriodPicker value={period} onValueChange={setPeriod} />
<Text size="sm" tone="muted" dir="ltr" className="font-mono">{`${period.from} – ${period.to}`}</Text>
</Stack>
);
}
/** A report period: presets in the custom range, a week that starts on Saturday, and a cleared range that goes back to the report's default. */2026-11-28 – 2026-12-04
Code
export function PeriodPickerReportExample() {
const [period, setPeriod] = useState<Period>(() => ({ kind: "custom", ...rangePreset("last7Days", todayPlain()) }) as Period);
return (
<Stack gap={3}>
<PeriodPicker value={period} onValueChange={setPeriod} presets={["today", "yesterday", "last7Days", "last30Days"]} weekStart={6} clearTo={periodOf("year", todayPlain())} />
<Text size="sm" tone="muted" dir="ltr" className="font-mono">{`${period.from} – ${period.to}`}</Text>
</Stack>
);
}
/** A list filter: a preset closes the popover; a single day is a valid filter too ("From 12/09/2026"). */