Preserve calendar presets and custom ranges across local midnight

This commit is contained in:
syntaxbullet
2026-09-08 16:29:20 +02:00
parent c91202bbfc
commit 82fe4a1db1
3 changed files with 52 additions and 10 deletions

View File

@@ -32,7 +32,7 @@ export function CalendarHeatmap({
loading = false,
}: {
availableRange?: { from: string; to: string };
onRangeChange?: (range: { from: string; to: string }) => void;
onRangeChange?: (range: { from: string; to: string }, months: MonthView | "custom") => void;
loading?: boolean;
days: CalendarDay[];
unit: string;
@@ -138,7 +138,7 @@ export function CalendarHeatmap({
type="button"
aria-label={`${value} ${value === 1 ? "month" : "months"}`}
aria-pressed={months === value}
onClick={() => { setMonths(value); if (anchor) onRangeChange?.(monthWindow(anchor, value)); }}
onClick={() => { setMonths(value); if (anchor) onRangeChange?.(monthWindow(anchor, value), value); }}
>
{value}m
</button>
@@ -150,6 +150,7 @@ export function CalendarHeatmap({
if (!customRange) setCustomRange({ from: days[0]!.date, to: days.at(-1)!.date });
setRangeError("");
setMonths("custom");
onRangeChange?.(customRange ?? { from: days[0]!.date, to: days.at(-1)!.date }, "custom");
}}
>
Custom
@@ -184,7 +185,7 @@ export function CalendarHeatmap({
return;
}
setCustomRange({ from: start.value, to: end.value });
onRangeChange?.({ from: start.value, to: end.value });
onRangeChange?.({ from: start.value, to: end.value }, "custom");
setRangeError("");
}}
>