Skip to content

A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.

feat(calendar): add saved calendar view switching (#7125)

Thomas6eb7cfac0ed0
diff --git a/apps/docs/docs/widgets/calendar/img/advanced-view.png b/apps/docs/docs/widgets/calendar/img/advanced-view.png
deleted file mode 100644
index a17186774..000000000
Binary files a/apps/docs/docs/widgets/calendar/img/advanced-view.png and /dev/null differ
diff --git a/apps/docs/docs/widgets/calendar/img/current-view.png b/apps/docs/docs/widgets/calendar/img/current-view.png
deleted file mode 100644
index 0441e45e1..000000000
Binary files a/apps/docs/docs/widgets/calendar/img/current-view.png and /dev/null differ
diff --git a/apps/docs/docs/widgets/calendar/index.mdx b/apps/docs/docs/widgets/calendar/index.mdx
index 74cb105f7..60e97e8bd 100644
--- a/apps/docs/docs/widgets/calendar/index.mdx
+++ b/apps/docs/docs/widgets/calendar/index.mdx
@@ -18,21 +18,16 @@ import { radarrIntegration } from "@site/docs/integrations/radarr";
import { readarrIntegration } from "@site/docs/integrations/readarr";
import { sonarrIntegration } from "@site/docs/integrations/sonarr";
import { icalIntegration } from "@site/docs/integrations/ical";
-import currentView from "./img/current-view.png";
-import advancedView from "./img/advanced-view.png";
<WidgetHeader widget={calendarWidget} categories={["Media manager", "Servarr"]} />
-The Calendar widget combines events and upcoming releases in a month view. Advanced view shows a grouped event list with
-source, title, location, and description. Healthy integrations remain visible when another source fails.
+The Calendar widget combines events and upcoming media releases. Healthy integrations remain visible when another
+source fails.
-### Month view
-
-<img src={currentView.src} alt="Calendar month view with marked events" />
-
-### Advanced view
-
-<img src={advancedView.src} alt="Calendar advanced view with grouped events" />
+View choices are remembered per widget in this browser, including on read-only boards. They do not change the
+configured default or other users' views. Set the shared default in the widget configuration.
+Advanced view starts in Agenda and remembers its own browser-local selection. Timed events without an end time
+occupy a 30-minute slot in Day and Week; their details keep the original event time.
### Supported integrations
@@ -48,10 +43,22 @@ source, title, location, and description. Healthy integrations remain visible wh
]}
/>
+### Views
+
+**Compact month is the default**, keeping the familiar calendar with colored event indicators.
+
+| View | Preview |
+| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
+| **Compact month (default)** | <img src="/img/widgets/calendar/current-view.png" width={800} height={560} alt="Default compact month with colored event indicators" /> |
+| Month | <img src="/img/widgets/calendar/month-view.png" width={400} height={280} alt="Month grid with event times, titles, and overflow counts" /> |
+| Week | <img src="/img/widgets/calendar/week-view.png" width={400} height={280} alt="Week time grid with visible all-day events" /> |
+| Day | <img src="/img/widgets/calendar/day-view.png" width={400} height={280} alt="Day time grid with visible all-day and overlapping events" /> |
+| Agenda | <img src="/img/widgets/calendar/advanced-view.png" width={400} height={280} alt="Agenda with grouped events, source labels, and event details" /> |
+
### Interactions
- Hover or select a marked date to inspect its events.
-- Use advanced view to browse grouped events by month.
+- Month overflow counts open the complete list of events for that date.
<WidgetInteractionGuide />
diff --git a/apps/docs/docs/widgets/calendar/index.ts b/apps/docs/docs/widgets/calendar/index.ts
index b1e2d83b3..f39304ae7 100644
--- a/apps/docs/docs/widgets/calendar/index.ts
+++ b/apps/docs/docs/widgets/calendar/index.ts
@@ -8,6 +8,12 @@ export const calendarWidget: WidgetDefinition = {
path: "../../widgets/calendar",
configuration: {
items: [
+ {
+ name: "View",
+ description: "Shared default view. View menu selections are remembered only in the current browser.",
+ values: "Compact month, Month, Week, Day, Agenda",
+ defaultValue: "Compact month",
+ },
{
name: "Radarr release type",
description: "Select what type of release date to see.",
diff --git a/apps/docs/public/img/widgets/calendar/advanced-view.png b/apps/docs/public/img/widgets/calendar/advanced-view.png
new file mode 100644
index 000000000..57addfd01
Binary files /dev/null and b/apps/docs/public/img/widgets/calendar/advanced-view.png differ
diff --git a/apps/docs/public/img/widgets/calendar/current-view.png b/apps/docs/public/img/widgets/calendar/current-view.png
new file mode 100644
index 000000000..502412abe
Binary files /dev/null and b/apps/docs/public/img/widgets/calendar/current-view.png differ
diff --git a/apps/docs/public/img/widgets/calendar/day-view.png b/apps/docs/public/img/widgets/calendar/day-view.png
new file mode 100644
index 000000000..b827e356d
Binary files /dev/null and b/apps/docs/public/img/widgets/calendar/day-view.png differ
diff --git a/apps/docs/public/img/widgets/calendar/month-view.png b/apps/docs/public/img/widgets/calendar/month-view.png
new file mode 100644
index 000000000..0af37f313
Binary files /dev/null and b/apps/docs/public/img/widgets/calendar/month-view.png differ
diff --git a/apps/docs/public/img/widgets/calendar/week-view.png b/apps/docs/public/img/widgets/calendar/week-view.png
new file mode 100644
index 000000000..c82fa168d
Binary files /dev/null and b/apps/docs/public/img/widgets/calendar/week-view.png differ
diff --git a/bun.lock b/bun.lock
index 85f558afb..89f857ad0 100644
--- a/bun.lock
+++ b/bun.lock
@@ -981,6 +981,7 @@
"@mantine/dates": "catalog:",
"@mantine/form": "catalog:",
"@mantine/hooks": "catalog:",
+ "@mantine/schedule": "catalog:",
"@rexa-developer/tiks": "catalog:",
"@tabler/icons-react": "catalog:",
"@tiptap/extension-color": "catalog:",
@@ -1251,6 +1252,7 @@
"@mantine/lightbox": "9.6.0",
"@mantine/modals": "9.6.0",
"@mantine/notifications": "9.6.0",
+ "@mantine/schedule": "9.6.0",
"@mantine/spotlight": "9.6.0",
"@mantine/tiptap": "9.6.0",
"@modelcontextprotocol/server": "2.0.0",
@@ -2077,6 +2079,8 @@
"@mantine/notifications": ["@mantine/[email protected]", "", { "dependencies": { "@mantine/store": "9.6.0", "react-transition-group": "4.4.5" }, "peerDependencies": { "@mantine/core": "9.6.0", "@mantine/hooks": "9.6.0", "react": "^19.2.0", "react-dom": "^19.2.0" } }, "sha512-1sTE7EaGpr6LX7ykE8DOwpTNxi3U7AHF7Ve/oBd1VEe2k/5RmEYLTWpexxf7WwNpEmHCi99MvG7qUMQJyqc9Fg=="],
+ "@mantine/schedule": ["@mantine/[email protected]", "", { "dependencies": { "rrule": "^2.8.1" }, "peerDependencies": { "@mantine/core": "9.6.0", "@mantine/dates": "9.6.0", "@mantine/hooks": "9.6.0", "react": "^19.2.0", "react-dom": "^19.2.0" } }, "sha512-JQKfIq696yydxLcJM4uFh2Cv+BghiW/ZU+eQxvQlmRY1/f9o5yg1bp2wYIqFjRnwrQJas9W8hCVszwLpGPgdTQ=="],
+
"@mantine/spotlight": ["@mantine/[email protected]", "", { "dependencies": { "@mantine/store": "9.6.0" }, "peerDependencies": { "@mantine/core": "9.6.0", "@mantine/hooks": "9.6.0", "react": "^19.2.0", "react-dom": "^19.2.0" } }, "sha512-ZJgdrMWnhZDWSu6/OHcUkk5cXgLhkBnICCWWnHpuaapAKIa+ya3jj0BXDA8fzb3iY6yKCF06bqpKY5rhiuKaCw=="],
"@mantine/store": ["@mantine/[email protected]", "", { "peerDependencies": { "react": "^19.2.0" } }, "sha512-nYt2tfn1/e6CK35a5TWlPbOL3Xwf7OzBmBElV0l+Ae6mswVaMip1WHm0mCaHAbTKgsOnvL/tooDTVxBBrmm87Q=="],
@@ -4869,6 +4873,8 @@
"roughjs": ["[email protected]", "", { "dependencies": { "hachure-fill": "0.5.2", "path-data-parser": "0.1.0", "points-on-curve": "0.2.0", "points-on-path": "0.2.1" } }, "sha512-ZUz/69+SYpFN/g/lUlo2FXcIjRkSu3nDarreVdGGndHEBJ6cXPdKguS8JGxwj5HA5xIbVKSmLgr5b3AWxtRfvQ=="],
+ "rrule": ["[email protected]", "", { "dependencies": { "tslib": "^2.4.0" } }, "sha512-hM3dHSBMeaJ0Ktp7W38BJZ7O1zOgaFEsn41PDk+yHoEtfLV+PoJt9E9xAlZiWgf/iqEqionN0ebHFZIDAp+iGw=="],
+
"rw": ["[email protected]", "", {}, "sha512-PdhdWy89SiZogBLaw42zdeqtRJ//zFd2PgQavcICDUgJT5oW10QCRKbJ6bg4r0/UY2M6BWd5tkxuGFRvCkgfHQ=="],
"rxjs": ["[email protected]", "", { "dependencies": { "tslib": "2.8.1" } }, "sha512-dhKf903U/PQZY6boNNtAGdWbG85WAbjT/1xYoZIC7FAY0yWapOBQVsVrDl58W86//e1VpMNBtRV4MaXfdMySFA=="],
diff --git a/package.json b/package.json
index 2d4759710..c489b432b 100644
--- a/package.json
+++ b/package.json
@@ -57,6 +57,7 @@
"@mantine/lightbox": "9.6.0",
"@mantine/modals": "9.6.0",
"@mantine/notifications": "9.6.0",
+ "@mantine/schedule": "9.6.0",
"@mantine/spotlight": "9.6.0",
"@mantine/tiptap": "9.6.0",
"@modelcontextprotocol/server": "2.0.0",
diff --git a/packages/translation/src/lang/en.json b/packages/translation/src/lang/en.json
index 3e8693434..edfa99055 100644
--- a/packages/translation/src/lang/en.json
+++ b/packages/translation/src/lang/en.json
@@ -3221,6 +3221,9 @@
},
"showUnmonitored": {
"label": "Show unmonitored"
+ },
+ "viewMode": {
+ "label": "View"
}
},
"advanced": {
@@ -3229,6 +3232,26 @@
"eventCount": "{count, plural, one {# event} other {# events}}",
"loading": "Loading calendar events...",
"noEvents": "No events in this month"
+ },
+ "view": {
+ "compact": "Compact month",
+ "month": "Month",
+ "week": "Week",
+ "day": "Day",
+ "agenda": "Agenda"
+ },
+ "controls": {
+ "view": "Calendar view",
+ "today": "Today",
+ "previous": "Previous period",
+ "next": "Next period",
+ "noEvents": "No events in this period",
+ "more": "{count} more",
+ "moreLabel": "Show {count} more events",
+ "eventDetails": "Event details",
+ "close": "Close event details",
+ "timeSlot": "Time slot",
+ "weekday": "Weekday"
}
},
"weather": {
diff --git a/packages/widgets/package.json b/packages/widgets/package.json
index 251d9bf3a..b809ea19c 100644
--- a/packages/widgets/package.json
+++ b/packages/widgets/package.json
@@ -72,6 +72,7 @@
"@mantine/dates": "catalog:",
"@mantine/form": "catalog:",
"@mantine/hooks": "catalog:",
+ "@mantine/schedule": "catalog:",
"@rexa-developer/tiks": "catalog:",
"@tabler/icons-react": "catalog:",
"@tiptap/extension-color": "catalog:",
diff --git a/packages/widgets/src/calendar/calendar-display.tsx b/packages/widgets/src/calendar/calendar-display.tsx
new file mode 100644
index 000000000..4bd2e2de5
--- /dev/null
+++ b/packages/widgets/src/calendar/calendar-display.tsx
@@ -0,0 +1,413 @@
+"use client";
+
+import { useEffect, useMemo, useState } from "react";
+import type { CSSProperties } from "react";
+import {
+ ActionIcon,
+ Box,
+ Button,
+ Center,
+ Group,
+ Loader,
+ Menu,
+ Modal,
+ Text,
+ Tooltip,
+ UnstyledButton,
+ getThemeColor,
+ useMantineTheme,
+} from "@mantine/core";
+import { Calendar } from "@mantine/dates";
+import { useElementSize } from "@mantine/hooks";
+import { DayView, WeekView } from "@mantine/schedule";
+import { IconCheck, IconChevronDown, IconChevronLeft, IconChevronRight, IconCalendarEvent } from "@tabler/icons-react";
+import dayjs from "dayjs";
+
+import { useI18n } from "@homarr/translation/client";
+
+// oxlint-disable-next-line import/no-unassigned-import
+import "@mantine/schedule/styles.css";
+import actionTargetClasses from "../common/action-target.module.css";
+import { IntegrationErrorIndicator } from "../common/integration-error-indicator";
+import { formatLocalizedTime } from "../common/locale";
+import { CalendarDay } from "./calender-day";
+import { getCalendarAgendaEvents, groupEventsByDate, splitEvents, toCalendarDateKey } from "./calendar-events";
+import { CalendarEventList } from "./calendar-event-list";
+import type { CalendarEventWithSource } from "./calendar-event-list";
+import { getCalendarScheduleEvents, isCalendarAllDayEvent } from "./calendar-schedule-events";
+import { calendarViews } from "./calendar-view";
+import type { CalendarView } from "./calendar-view";
+import classes from "./component.module.css";
+
+interface CalendarDisplayProps {
+ events: CalendarEventWithSource[];
+ failedIntegrations: { integrationId: string; integrationName: string; error: string }[];
+ isPending: boolean;
+ isEditMode: boolean;
+ month: Date;
+ setMonth: (date: Date) => void;
+ view: CalendarView;
+ setView: (view: CalendarView) => void;
+ releaseType: readonly string[];
+ locale: string;
+ firstDayOfWeek: 0 | 1 | 2 | 3 | 4 | 5 | 6;
+ radius: CSSProperties["borderRadius"];
+}
+
+export const CalendarDisplay = ({
+ events,
+ failedIntegrations,
+ isPending,
+ isEditMode,
+ month: date,
+ setMonth: setDate,
+ view,
+ setView,
+ releaseType,
+ locale,
+ firstDayOfWeek,
+ radius,
+}: CalendarDisplayProps) => {
+ const t = useI18n("widget.calendar");
+ const { ref, width, height } = useElementSize();
+ const { ref: bodyRef, height: bodyHeight } = useElementSize();
+ const [details, setDetails] = useState<CalendarEventWithSource[] | null>(null);
+ useEffect(() => setDetails(null), [date, view]);
+ const filteredEvents = useMemo(
+ () =>
+ events.filter((event) => event.metadata?.type !== "radarr" || releaseType.includes(event.metadata.releaseType)),
+ [events, releaseType],
+ );
+ const eventsByDate = useMemo(() => groupEventsByDate(splitEvents(filteredEvents)), [filteredEvents]);
+ const agendaEvents = useMemo(() => getCalendarAgendaEvents(events, date, releaseType), [events, date, releaseType]);
+ const slotHeight = Math.max(40, bodyHeight / 12);
+ // Use the same visible interval for native event sizing and overlap columns.
+ const minimumEventDuration = Math.max(60, Math.ceil((24 / slotHeight) * 3600));
+ const scheduleEvents = useMemo(
+ () => getCalendarScheduleEvents(filteredEvents, view === "day" ? date : undefined, minimumEventDuration),
+ [filteredEvents, view, date, minimumEventDuration],
+ );
+ const labels = {
+ allDay: t("duration.allDay"),
+ today: t("controls.today"),
+ previous: t("controls.previous"),
+ next: t("controls.next"),
+ noEvents: t("controls.noEvents"),
+ weekday: t("controls.weekday"),
+ timeSlot: t("controls.timeSlot"),
+ moreLabel: (count: number) => t("controls.more", { count }),
+ };
+ const openEvent = (event: (typeof scheduleEvents)[number]) => {
+ if (isEditMode) return;
+ const original = event.payload?.event as CalendarEventWithSource | undefined;
+ if (original) setDetails([original]);
+ };
+ const openDay = (value: string) => {
+ if (isEditMode) return;
+ const dayEvents = eventsByDate.get(value) as CalendarEventWithSource[] | undefined;
+ if (dayEvents?.length) setDetails(dayEvents);
+ };
+ const moveDate = (amount: number) => {
+ if (view === "day") setDate(dayjs(date).add(amount, "day").toDate());
+ else if (view === "week") setDate(dayjs(date).add(amount, "week").toDate());
+ else setDate(dayjs(date).add(amount, "month").toDate());
+ };
+ let dateLabel = new Intl.DateTimeFormat(locale, { month: "long", year: "numeric" }).format(date);
+ if (view === "day")
+ dateLabel = new Intl.DateTimeFormat(locale, { month: "short", day: "numeric", year: "numeric" }).format(date);
+ if (view === "week") {
+ const start = dayjs(date).subtract((dayjs(date).day() - firstDayOfWeek + 7) % 7, "day");
+ const formatter = new Intl.DateTimeFormat(locale, { month: "short", day: "numeric" });
+ dateLabel = `${formatter.format(start.toDate())} – ${formatter.format(start.add(6, "day").toDate())}`;
+ }
+ const monthStart = dayjs(date).startOf("month");
+ const leadingDays = (monthStart.day() - firstDayOfWeek + 7) % 7;
+ const weekCount = Math.ceil((leadingDays + monthStart.daysInMonth()) / 7);
+ let scheduleMode: "static" | "default" = "default";
+ if (isEditMode) scheduleMode = "static";
+ const scheduleProps = {
+ date,
+ events: scheduleEvents,
+ endTime: "24:00:00",
+ locale,
+ labels,
+ withHeader: false,
+ mode: scheduleMode,
+ onEventClick: openEvent,
+ scrollAreaProps: {
+ h: bodyHeight,
+ mah: bodyHeight,
+ type: "auto" as const,
+ styles: { content: { minWidth: 0, width: "100%" } },
+ startScrollPosition: { y: 8 * Math.max(40, bodyHeight / 12) },
+ },
+ slotHeight,
+ allDaySlotHeight: 48,
+ h: "100%",
+ w: "100%",
+ slotLabelFormat: (value: string) => formatLocalizedTime(dayjs(value).toDate(), locale),
+ };
+
+ return (
+ <Box ref={ref} className={classes.root} h="100%" w="100%" p="xs" data-calendar-view={view}>
+ <Box className={classes.header}>
+ <Group className={classes.navigation} gap={2} wrap="nowrap">
+ <ActionIcon
+ className={actionTargetClasses.root}
+ variant="subtle"
+ size="sm"
+ aria-label={t("controls.previous")}
+ disabled={isEditMode}
+ onClick={() => moveDate(-1)}
+ >
+ <IconChevronLeft size={16} />
+ </ActionIcon>
+ <Text size="sm" fw={600} tt="capitalize" truncate className={classes.dateLabel}>
+ {dateLabel}
+ </Text>
+ <ActionIcon
+ className={actionTargetClasses.root}
+ variant="subtle"
+ size="sm"
+ aria-label={t("controls.next")}
+ disabled={isEditMode}
+ onClick={() => moveDate(1)}
+ >
+ <IconChevronRight size={16} />
+ </ActionIcon>
+ </Group>
+ <Group className={classes.tools} gap={4} wrap="nowrap">
+ <IntegrationErrorIndicator results={failedIntegrations} />
+ <Tooltip label={t("controls.today")} events={{ hover: true, focus: true, touch: false }}>
+ <ActionIcon
+ className={actionTargetClasses.root}
+ variant="subtle"
+ size="sm"
+ aria-label={t("controls.today")}
+ disabled={isEditMode}
+ onClick={() => setDate(new Date())}
+ >
+ <IconCalendarEvent size={16} />
+ </ActionIcon>
+ </Tooltip>
+ <Menu withinPortal position="bottom-end" shadow="sm">
+ <Menu.Target>
+ <Button
+ className={actionTargetClasses.root}
+ variant="subtle"
+ size="compact-xs"
+ disabled={isEditMode}
+ aria-label={`${t("controls.view")}: ${t(`view.${view}`)}`}
+ rightSection={<IconChevronDown size={12} />}
+ >
+ {t(`view.${view}`)}
+ </Button>
+ </Menu.Target>
+ <Menu.Dropdown>
+ {calendarViews.map((mode) => (
+ <Menu.Item
+ key={mode}
+ onClick={() => setView(mode)}
+ rightSection={view === mode && <IconCheck size={14} aria-hidden />}
+ >
+ {t(`view.${mode}`)}
+ </Menu.Item>
+ ))}
+ </Menu.Dropdown>
+ </Menu>
+ </Group>
+ </Box>
+ <Box ref={bodyRef} className={classes.body}>
+ {isPending && (
+ <Center h="100%" component="output" aria-label={t("advanced.loading")}>
+ <Loader size="sm" />
+ </Center>
+ )}
+ {!isPending && (view === "compact" || view === "month") && (
+ <Calendar
+ date={date}
+ onDateChange={(value) => setDate(dayjs(value).toDate())}
+ maxLevel="month"
+ fullWidth
+ highlightToday
+ locale={locale}
+ firstDayOfWeek={firstDayOfWeek}
+ static={view === "month"}
+ className={classes.calendar}
+ w="100%"
+ h="100%"
+ getDayProps={(value) => {
+ if (view === "month") return {};
+ return { onClick: () => openDay(value), disabled: isEditMode };
+ }}
+ styles={{
+ calendarHeader: { display: "none" },
+ levelsGroup: { height: "100%" },
+ month: { height: "100%", tableLayout: "fixed" },
+ monthCell: { textAlign: "center", position: "relative", padding: 2 },
+ day: {
+ borderRadius: radius,
+ width: "100%",
+ height: "100%",
+ position: "absolute",
+ inset: 0,
+ aspectRatio: "auto",
+ minHeight: 0,
+ minWidth: 0,
+ maxWidth: "100%",
+ overflow: "hidden",
+ },
+ weekday: { padding: 0, fontSize: "var(--mantine-font-size-xs)" },
+ weekdaysRow: { height: 22 },
+ }}
+ renderDay={(value) => {
+ const tileDate = dayjs(value).toDate();
+ const dayEvents = (eventsByDate.get(toCalendarDateKey(tileDate)) ?? []) as CalendarEventWithSource[];
+ if (view === "month")
+ return (
+ <DetailedDay
+ date={tileDate}
+ events={dayEvents}
+ locale={locale}
+ cellHeight={(bodyHeight - 22) / weekCount}
+ disabled={isEditMode}
+ onOpen={setDetails}
+ />
+ );
+ return (
+ <CalendarDay
+ date={tileDate}
+ events={dayEvents}
+ disabled={dayEvents.length === 0 || isEditMode}
+ rootWidth={width}
+ rootHeight={height}
+ />
+ );
+ }}
+ />
+ )}
+ {!isPending && view === "agenda" && (
+ <>
+ {agendaEvents.length > 0 && (
+ <CalendarEventList events={agendaEvents} advanced groupByDate locale={locale} fillHeight />
+ )}
+ {agendaEvents.length === 0 && (
+ <Center h="100%">
+ <Text size="sm" c="dimmed" ta="center">
+ {t("controls.noEvents")}
+ </Text>
+ </Center>
+ )}
+ </>
+ )}
+ {!isPending && view === "day" && bodyHeight > 0 && (
+ <DayView
+ {...scheduleProps}
+ classNames={{ dayViewAllDay: classes.dayAllDay, dayViewSlotLabel: classes.daySlotLabel }}
+ style={{ "--day-view-slot-labels-width": "3.5rem" } as CSSProperties}
+ styles={{ dayViewScrollArea: { height: "100%" }, dayViewSlotLabel: { fontSize: 10, whiteSpace: "nowrap" } }}
+ />
+ )}
+ {!isPending && view === "week" && bodyHeight > 0 && (
+ <WeekView
+ {...scheduleProps}
+ firstDayOfWeek={firstDayOfWeek}
+ withWeekNumber={false}
+ classNames={{ weekViewAllDaySlots: classes.weekAllDay }}
+ style={
+ {
+ "--week-view-min-slot-width": "0px",
+ "--week-view-slots-label-width": width < 350 ? "2rem" : "3.5rem",
+ } as CSSProperties
+ }
+ styles={{
+ weekViewRoot: { height: "100%" },
+ weekViewScrollArea: { height: "100%" },
+ weekViewDayLabel: { minWidth: 0, overflow: "hidden", fontSize: "var(--mantine-font-size-xs)" },
+ weekViewDayWeekday: { fontSize: 10 },
+ weekViewDayNumber: { fontSize: 10, paddingInline: 0, minWidth: 0 },
+ weekViewSlotLabel: { fontSize: 10, whiteSpace: "nowrap" },
+ weekViewAllDaySlotsLabel: { fontSize: 10 },
+ }}
+ weekdayFormat={(value) =>
+ new Intl.DateTimeFormat(locale, { weekday: width < 350 ? "narrow" : "short" }).format(
+ dayjs(value).toDate(),
+ )
+ }
+ onDateChange={(value) => {
+ if (!isEditMode) setDate(dayjs(value).toDate());
+ }}
+ onViewChange={(value) => {
+ if (!isEditMode && value === "day") setView("day");
+ }}
+ />
+ )}
+ </Box>
+ <Modal
+ opened={details !== null}
+ onClose={() => setDetails(null)}
+ title={t("controls.eventDetails")}
+ closeButtonProps={{ "aria-label": t("controls.close") }}
+ centered
+ size="lg"
+ >
+ {details && <CalendarEventList events={details} advanced locale={locale} />}
+ </Modal>
+ </Box>
+ );
+};
+
+interface DetailedDayProps {
+ date: Date;
+ events: CalendarEventWithSource[];
+ locale: string;
+ cellHeight: number;
+ disabled: boolean;
+ onOpen: (events: CalendarEventWithSource[]) => void;
+}
+
+const DetailedDay = ({ date, events, locale, cellHeight, disabled, onOpen }: DetailedDayProps) => {
+ const theme = useMantineTheme();
+ const t = useI18n("widget.calendar");
+ const maxRows = Math.max(0, Math.floor((cellHeight - 20) / 18));
+ let visibleCount = Math.min(events.length, maxRows);
+ if (events.length > maxRows) visibleCount = Math.max(0, maxRows - 1);
+ const hiddenCount = events.length - visibleCount;
+ return (
+ <Box className={classes.detailedDay} data-compact={maxRows === 0 || undefined}>
+ <UnstyledButton
+ className={classes.dayNumber}
+ aria-label={new Intl.DateTimeFormat(locale, { dateStyle: "full" }).format(date)}
+ disabled={disabled || events.length === 0}
+ onClick={() => onOpen(events)}
+ >
+ {date.getDate()}
+ </UnstyledButton>
+ {events.slice(0, visibleCount).map((event, index) => (
+ <UnstyledButton
+ key={index}
+ disabled={disabled}
+ className={classes.monthEvent}
+ onClick={() => onOpen([event])}
+ style={{ "--event-color": getThemeColor(event.indicatorColor ?? "blue", theme) } as CSSProperties}
+ title={event.title}
+ >
+ {!isCalendarAllDayEvent(event) && (
+ <span className={classes.eventTime}>{formatLocalizedTime(event.startDate, locale)} </span>
+ )}
+ {event.title}
+ </UnstyledButton>
+ ))}
+ {hiddenCount > 0 && (
+ <UnstyledButton
+ disabled={disabled}
+ className={classes.moreEvents}
+ aria-label={t("controls.moreLabel", { count: hiddenCount })}
+ onClick={() => onOpen(events)}
+ >
+ +{hiddenCount}
+ </UnstyledButton>
+ )}
+ </Box>
+ );
+};
diff --git a/packages/widgets/src/calendar/calendar-event-list.tsx b/packages/widgets/src/calendar/calendar-event-list.tsx
index c5b1644c7..1385ae650 100644
--- a/packages/widgets/src/calendar/calendar-event-list.tsx
+++ b/packages/widgets/src/calendar/calendar-event-list.tsx
@@ -13,13 +13,13 @@ import {
useMantineColorScheme,
} from "@mantine/core";
import { IconClock, IconPin } from "@tabler/icons-react";
-import dayjs from "dayjs";
import { isNullOrWhitespace } from "@homarr/common";
import type { CalendarEvent } from "@homarr/integrations/types";
import { useCurrentIntlLocale, useI18n } from "@homarr/translation/client";
import { groupEventsByDate } from "./calendar-events";
+import { isCalendarAllDayEvent } from "./calendar-schedule-events";
import { getSafeApplicationUrl, SAFE_NEW_TAB_REL } from "../common/application-url";
import { formatLocalizedTime } from "../common/locale";
import classes from "./calendar-event-list.module.css";
@@ -151,7 +151,7 @@ const CalendarEventRows = ({
<Group gap={3} wrap="nowrap" align={"center"} ml="auto">
<IconClock opacity={0.7} size={"1rem"} />
- {isAllDay(event) ? (
+ {isCalendarAllDayEvent(event) ? (
<Text c={"dimmed"} size={"sm"}>
{t("duration.allDay")}
</Text>
@@ -230,12 +230,3 @@ const CalendarEventRows = ({
</>
);
};
-
-const isAllDay = (event: Pick<CalendarEvent, "startDate" | "endDate">) => {
- if (!event.endDate) return false;
-
- const start = dayjs(event.startDate);
- const end = dayjs(event.endDate);
-
- return start.startOf("day").isSame(start) && end.endOf("day").isSame(end);
-};
diff --git a/packages/widgets/src/calendar/calendar-schedule-events.ts b/packages/widgets/src/calendar/calendar-schedule-events.ts
new file mode 100644
index 000000000..e88d836c5
--- /dev/null
+++ b/packages/widgets/src/calendar/calendar-schedule-events.ts
@@ -0,0 +1,58 @@
+import dayjs from "dayjs";
+import type { ScheduleEventData } from "@mantine/schedule";
+
+import type { CalendarEventWithSource } from "./calendar-event-list";
+
+export const isCalendarAllDayEvent = (event: CalendarEventWithSource) => {
+ const start = dayjs(event.startDate);
+ if (!start.isSame(start.startOf("day"))) return false;
+ if (!event.endDate) return true;
+ const end = dayjs(event.endDate);
+ return end.isSame(end.startOf("day")) || end.isSame(end.endOf("day"));
+};
+
+export const getCalendarScheduleEvents = (
+ events: CalendarEventWithSource[],
+ displayedDay?: Date,
+ minimumDurationSeconds = 60,
+): ScheduleEventData[] => {
+ const dayStart = displayedDay ? dayjs(displayedDay).startOf("day") : undefined;
+ const dayEnd = dayStart?.add(1, "day").startOf("day");
+ return events.flatMap((event, index) => {
+ let start = dayjs(event.startDate);
+ if (!start.isValid()) return [];
+ let end = start.add(30, "minute");
+ if (event.endDate) end = dayjs(event.endDate);
+ else if (isCalendarAllDayEvent(event)) end = start.add(1, "day");
+ if (!end.isValid() || end.isBefore(start)) return [];
+ if (end.isSame(start)) end = start.add(30, "minute");
+ // The schedule uses half-open intervals and second precision.
+ if (isCalendarAllDayEvent(event) && end.isSame(end.endOf("day"))) end = end.add(1, "millisecond");
+ // Timed midnight ends must stay in the preceding day's visible time range.
+ if (!isCalendarAllDayEvent(event) && end.isSame(end.startOf("day"))) end = end.subtract(1, "second");
+ if (dayStart && dayEnd) {
+ if (!start.isBefore(dayEnd) || !end.isAfter(dayStart)) return [];
+ if (start.isBefore(dayStart)) start = dayStart;
+ if (!end.isBefore(dayEnd)) end = dayEnd.subtract(1, "second");
+ }
+ // Keep short visual intervals inside their day, including the final second.
+ if (end.isSame(start, "day") && end.diff(start, "second") < minimumDurationSeconds) {
+ const latestEnd = start.endOf("day").startOf("second");
+ end = start.add(minimumDurationSeconds, "second");
+ if (end.isAfter(latestEnd)) {
+ end = latestEnd;
+ start = end.subtract(minimumDurationSeconds, "second");
+ }
+ }
+ return [
+ {
+ id: `${event.source?.integrationId ?? "calendar"}:${index}`,
+ title: event.title,
+ start: start.format("YYYY-MM-DD HH:mm:ss"),
+ end: end.format("YYYY-MM-DD HH:mm:ss"),
+ color: event.indicatorColor ?? "blue",
+ payload: { event },
+ },
+ ];
+ });
+};
diff --git a/packages/widgets/src/calendar/calendar-view.ts b/packages/widgets/src/calendar/calendar-view.ts
new file mode 100644
index 000000000..2ffb6eca6
--- /dev/null
+++ b/packages/widgets/src/calendar/calendar-view.ts
@@ -0,0 +1,4 @@
+export const calendarViews = ["compact", "month", "week", "day", "agenda"] as const;
+export type CalendarView = (typeof calendarViews)[number];
+
+export const isCalendarView = (value: unknown): value is CalendarView => calendarViews.some((view) => view === value);
diff --git a/packages/widgets/src/calendar/calender-day.tsx b/packages/widgets/src/calendar/calender-day.tsx
index 9d9ee59cb..13ccf2dff 100644
--- a/packages/widgets/src/calendar/calender-day.tsx
+++ b/packages/widgets/src/calendar/calender-day.tsx
@@ -1,5 +1,5 @@
import { useMemo } from "react";
-import { Box, Container, Flex, HoverCard, Text, useMantineTheme } from "@mantine/core";
+import { Box, Container, HoverCard, Text, useMantineTheme } from "@mantine/core";
import { useRequiredBoard } from "@homarr/boards/context";
import type { CalendarEvent } from "@homarr/integrations/types";
@@ -95,33 +95,27 @@ const NotificationIndicator = ({ events, size, marginTop, visible }: Notificatio
(color): color is string => Boolean(color),
);
- if (!visible) return null;
+ if (!visible || notificationEvents.length === 0) return null;
return (
- <Flex
+ <Box
mt={marginTop}
w="fit-content"
maw="75%"
- h={size}
- align={"center"}
- gap={2}
p={0}
- direction={"row"}
- justify={"center"}
+ style={{
+ display: "grid",
+ gridTemplateColumns: `repeat(${Math.min(notificationEvents.length, 3)}, ${size}px)`,
+ gap: 2,
+ justifyContent: "center",
+ }}
aria-hidden
>
{notificationEvents.map((notificationEvent) => {
return (
- <Box
- key={notificationEvent}
- bg={notificationEvent}
- h={size}
- w={size * 2}
- p={0}
- style={{ borderRadius: 999 }}
- />
+ <Box key={notificationEvent} bg={notificationEvent} h={size} w={size} p={0} style={{ borderRadius: 999 }} />
);
})}
- </Flex>
+ </Box>
);
};
diff --git a/packages/widgets/src/calendar/component.module.css b/packages/widgets/src/calendar/component.module.css
index 2ae544f49..7346d93d1 100644
--- a/packages/widgets/src/calendar/component.module.css
+++ b/packages/widgets/src/calendar/component.module.css
@@ -1,15 +1,112 @@
+.root {
+ display: flex;
+ flex-direction: column;
+ gap: 4px;
+ overflow: hidden;
+ container-type: inline-size;
+}
+.header {
+ display: flex;
+ align-items: center;
+ flex-wrap: wrap;
+ gap: 4px;
+ flex-shrink: 0;
+}
+.navigation {
+ flex: 1;
+ min-width: 120px;
+}
+.dateLabel {
+ flex: 1;
+ min-width: 0;
+ text-align: center;
+}
+.tools {
+ margin-inline-start: auto;
+}
+.body {
+ flex: 1;
+ min-height: 0;
+ min-width: 0;
+ overflow: hidden;
+}
.calendar div[data-month-level] {
width: 100%;
display: flex;
flex-direction: column;
}
+.detailedDay {
+ min-width: 0;
+ width: 100%;
+ height: 100%;
+ display: flex;
+ flex-direction: column;
+ align-items: stretch;
+ overflow: hidden;
+ gap: 1px;
+ padding: 1px;
+}
+.dayNumber {
+ font-size: var(--mantine-font-size-xs);
+ line-height: 16px;
+ flex-shrink: 0;
+ text-align: center;
+}
+.monthEvent {
+ min-width: 0;
+ width: 100%;
+ max-width: 100%;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+ text-align: start;
+ font-size: 11px;
+ line-height: 17px;
+ flex-shrink: 0;
+ border-inline-start: 2px solid var(--event-color);
+ padding-inline-start: 3px;
+ background-color: color-mix(in srgb, var(--event-color) 15%, transparent);
+ border-radius: 3px;
+}
+.moreEvents {
+ font-size: 10px;
+ line-height: 14px;
+ text-align: center;
+ color: var(--mantine-primary-color-light-color);
+ overflow: hidden;
+ margin-top: auto;
+}
+.detailedDay[data-compact] {
+ flex-direction: row;
+ align-items: center;
+ justify-content: center;
+ gap: 2px;
+}
+.detailedDay[data-compact] .dayNumber,
+.detailedDay[data-compact] .moreEvents {
+ font-size: 10px;
+ line-height: 12px;
+ margin: 0;
+}
+.dayAllDay,
+.weekAllDay,
+.daySlotLabel[data-all-day] {
+ position: sticky;
+ top: 0;
+ z-index: 4;
+ background-color: var(--mantine-color-body);
+}
+.weekAllDay {
+ top: var(--week-view-week-day-height);
+}
+@container (max-width: 340px) {
+ .navigation {
+ flex-basis: 100%;
+ }
+}
-.errorIndicator {
- top: calc(var(--mantine-spacing-md) + var(--mantine-spacing-xl));
- inset-inline-end: 4px;
- z-index: 1;
- padding: 2px;
- border: 1px solid rgb(from var(--mantine-primary-color-filled) r g b / calc(var(--opacity, 1) * 0.45));
- border-radius: var(--mantine-radius-sm);
- background-color: rgb(from var(--mantine-color-secondaryColor-filled) r g b / calc(var(--opacity, 1) * 0.18));
+@container (max-width: 350px) {
+ .eventTime {
+ display: none;
+ }
}
diff --git a/packages/widgets/src/calendar/component.tsx b/packages/widgets/src/calendar/component.tsx
index 2c87f5769..286753ad4 100644
--- a/packages/widgets/src/calendar/component.tsx
+++ b/packages/widgets/src/calendar/component.tsx
@@ -1,41 +1,28 @@
"use client";
import { useMemo, useState } from "react";
-import { ActionIcon, Box, Center, Group, Loader, Stack, Text, Tooltip, useMantineTheme } from "@mantine/core";
-import { Calendar } from "@mantine/dates";
-import { useElementSize } from "@mantine/hooks";
-import { IconChevronLeft, IconChevronRight } from "@tabler/icons-react";
+import { useMantineTheme } from "@mantine/core";
import { getQueryKey } from "@trpc/react-query";
-import dayjs from "dayjs";
import { clientApi } from "@homarr/api/client";
import { useRequiredBoard } from "@homarr/boards/context";
import { useSettings } from "@homarr/settings";
-import { useCurrentIntlLocale, useI18n } from "@homarr/translation/client";
+import { useCurrentIntlLocale } from "@homarr/translation/client";
-import actionTargetClasses from "../common/action-target.module.css";
import type { WidgetComponentProps } from "../definition";
-import { getUsableWidgetQueryData, isInitialWidgetQueryPending } from "../common/query-state";
-import { WidgetQueryLoadingState } from "../common/query-state-indicator";
+import { getUsableWidgetQueryData } from "../common/query-state";
+import { useLocalWidgetState } from "../common/use-local-widget-state";
import { useWidgetRuntimeQueries } from "../runtime-hooks";
-import { IntegrationErrorIndicator } from "../common/integration-error-indicator";
-import { CalendarDay } from "./calender-day";
-import {
- getCalendarAgendaEvents,
- groupEventsByDate,
- moveCalendarMonth,
- splitEvents,
- toCalendarDateKey,
-} from "./calendar-events";
import type { CalendarEventWithSource } from "./calendar-event-list";
-import { CalendarEventList } from "./calendar-event-list";
-import classes from "./component.module.css";
+import { CalendarDisplay } from "./calendar-display";
+import type { CalendarView } from "./calendar-view";
+import { isCalendarView } from "./calendar-view";
export default function CalendarWidget(props: WidgetComponentProps<"calendar">) {
const [month, setMonth] = useState(() => new Date());
const runtimeInput = {
integrationIds: props.integrationIds,
- month: month.getMonth(),
+ month: month.getMonth() + 1,
year: month.getFullYear(),
releaseType: props.options.releaseType,
showUnmonitored: props.options.showUnmonitored,
@@ -68,7 +55,8 @@ interface FetchCalendarProps extends WidgetComponentProps<"calendar"> {
setMonth: (date: Date) => void;
}
-const FetchCalendar = ({ month, setMonth, isEditMode, integrationIds, options, displayMode }: FetchCalendarProps) => {
+const FetchCalendar = ({ month, setMonth, ...props }: FetchCalendarProps) => {
+ const { integrationIds, options } = props;
const input = {
integrationIds,
month: month.getMonth() + 1,
@@ -99,243 +87,51 @@ const FetchCalendar = ({ month, setMonth, isEditMode, integrationIds, options, d
error ? [{ integrationId: integration.id, integrationName: integration.name, error }] : [],
) ?? [];
- if (isInitialWidgetQueryPending(calendarQuery)) return <WidgetQueryLoadingState />;
-
return (
<CalendarBase
- isEditMode={isEditMode}
+ {...props}
events={events}
failedIntegrations={failedIntegrations}
isPending={isPending}
month={month}
setMonth={setMonth}
- options={options}
- displayMode={displayMode}
/>
);
};
-interface CalendarBaseProps {
- isEditMode: boolean;
+interface CalendarBaseProps extends WidgetComponentProps<"calendar"> {
events: CalendarEventWithSource[];
failedIntegrations: { integrationId: string; integrationName: string; error: string }[];
isPending: boolean;
month: Date;
setMonth: (date: Date) => void;
- options: WidgetComponentProps<"calendar">["options"];
- displayMode?: WidgetComponentProps<"calendar">["displayMode"];
}
-const CalendarBase = ({
- isEditMode,
- events,
- failedIntegrations,
- isPending,
- month,
- setMonth,
- options,
- displayMode,
-}: CalendarBaseProps) => {
+const CalendarBase = ({ options, boardId, itemId, displayMode, ...props }: CalendarBaseProps) => {
const locale = useCurrentIntlLocale();
const { firstDayOfWeek } = useSettings();
const board = useRequiredBoard();
- const mantineTheme = useMantineTheme();
- const actualItemRadius = mantineTheme.radius[board.itemRadius];
- const { ref, width, height } = useElementSize();
- const isSmall = width < 256;
-
- const normalizedEvents = useMemo(
- () => (displayMode === "advanced" ? [] : splitEvents(events)),
- [displayMode, events],
- );
- const visibleEvents = useMemo(
- () =>
- normalizedEvents.filter(
- (event) => event.metadata?.type !== "radarr" || options.releaseType.includes(event.metadata.releaseType),
- ),
- [normalizedEvents, options.releaseType],
- );
- const eventsByDate = useMemo(() => groupEventsByDate(visibleEvents), [visibleEvents]);
- const agendaEvents = useMemo(
- () => (displayMode === "advanced" ? getCalendarAgendaEvents(events, month, options.releaseType) : []),
- [displayMode, events, month, options.releaseType],
- );
-
- if (displayMode === "advanced") {
- return (
- <CalendarAgenda
- events={agendaEvents}
- failedIntegrations={failedIntegrations}
- isPending={isPending}
- isEditMode={isEditMode}
- locale={locale}
- month={month}
- setMonth={setMonth}
- />
- );
- }
-
- return (
- <Box ref={ref} h="100%" w="100%" pos="relative" style={{ overflow: "hidden" }}>
- <Calendar
- defaultDate={new Date()}
- onPreviousMonth={(previousMonth) => setMonth(new Date(previousMonth))}
- onNextMonth={(nextMonth) => setMonth(new Date(nextMonth))}
- highlightToday
- locale={locale}
- hideWeekdays={false}
- date={month}
- maxLevel="month"
- firstDayOfWeek={firstDayOfWeek}
- className={classes.calendar}
- w="100%"
- h="100%"
- styles={{
- calendarHeaderControl: {
- borderRadius: "md",
- height: isSmall ? "1.5rem" : undefined,
- width: isSmall ? "1.5rem" : undefined,
- },
- calendarHeaderLevel: {
- pointerEvents: "none",
- fontSize: isSmall ? "0.75rem" : undefined,
- height: "100%",
- },
- levelsGroup: {
- height: "100%",
- padding: "md",
- },
- calendarHeader: {
- maxWidth: "unset",
- marginBottom: 0,
- },
- monthCell: {
- textAlign: "center",
- position: "relative",
- padding: 3,
- },
- day: {
- borderRadius: actualItemRadius,
- width: "100%",
- height: "100%",
- position: "absolute",
- top: 0,
- left: 0,
- bottom: 0,
- right: 0,
- },
- month: {
- height: "100%",
- },
- weekday: {
- padding: 0,
- },
- weekdaysRow: {
- height: 22,
- },
- }}
- renderDay={(tileDate) => {
- const eventsForDate = eventsByDate.get(toCalendarDateKey(dayjs(tileDate).toDate())) ?? [];
-
- return (
- <CalendarDay
- date={dayjs(tileDate).toDate()}
- events={eventsForDate}
- disabled={eventsForDate.length === 0}
- rootWidth={width}
- rootHeight={height}
- />
- );
- }}
- />
- {failedIntegrations.length > 0 && (
- <Group className={classes.errorIndicator} gap={0} pos="absolute">
- <IntegrationErrorIndicator results={failedIntegrations} />
- </Group>
- )}
- </Box>
- );
-};
-
-interface CalendarAgendaProps {
- events: CalendarEventWithSource[];
- failedIntegrations: CalendarBaseProps["failedIntegrations"];
- isPending: boolean;
- isEditMode: boolean;
- locale: string;
- month: Date;
- setMonth: (date: Date) => void;
-}
-
-const CalendarAgenda = ({
- events,
- failedIntegrations,
- isPending,
- isEditMode,
- locale,
- month,
- setMonth,
-}: CalendarAgendaProps) => {
- const t = useI18n("widget.calendar.advanced");
- const monthLabel = new Intl.DateTimeFormat(locale, { month: "long", year: "numeric" }).format(month);
+ const theme = useMantineTheme();
+ const defaultView = displayMode === "advanced" ? "agenda" : options.viewMode;
+ const [selectedView, setSelectedView] = useLocalWidgetState<CalendarView | null>({
+ key: boardId && itemId ? `homarr:calendar:${boardId}:${itemId}:view:${displayMode ?? "compact"}` : undefined,
+ version: 1,
+ defaultValue: null,
+ validate: (value): value is CalendarView | null => value === null || isCalendarView(value),
+ });
+ const setView = (view: CalendarView) => {
+ if (!props.isEditMode) setSelectedView(view);
+ };
return (
- <Stack h="100%" w="100%" gap="sm" p="md" style={{ overflow: "hidden" }}>
- <Group justify="space-between" align="center" wrap="nowrap">
- <Group gap="xs" wrap="nowrap">
- <Tooltip label={t("previousMonth")} events={{ hover: true, focus: true, touch: false }}>
- <ActionIcon
- className={actionTargetClasses.root}
- variant="subtle"
- size="lg"
- aria-label={t("previousMonth")}
- disabled={isEditMode}
- onClick={() => setMonth(moveCalendarMonth(month, -1))}
- >
- <IconChevronLeft size="var(--mantine-font-size-lg)" aria-hidden />
- </ActionIcon>
- </Tooltip>
- <Stack gap={0} miw={0}>
- <Text component="h3" size="sm" fw={600} tt="capitalize" lineClamp={1}>
- {monthLabel}
- </Text>
- <Text size="xs" c="dimmed">
- {isPending ? t("loading") : t("eventCount", { count: events.length })}
- </Text>
- </Stack>
- <Tooltip label={t("nextMonth")} events={{ hover: true, focus: true, touch: false }}>
- <ActionIcon
- className={actionTargetClasses.root}
- variant="subtle"
- size="lg"
- aria-label={t("nextMonth")}
- disabled={isEditMode}
- onClick={() => setMonth(moveCalendarMonth(month, 1))}
- >
- <IconChevronRight size="var(--mantine-font-size-lg)" aria-hidden />
- </ActionIcon>
- </Tooltip>
- </Group>
- <Group gap={0}>
- <IntegrationErrorIndicator results={failedIntegrations} />
- </Group>
- </Group>
-
- <Box style={{ flex: 1, minHeight: 0 }}>
- {isPending ? (
- <Center component="output" h="100%" aria-label={t("loading")}>
- <Loader size="sm" />
- </Center>
- ) : events.length > 0 ? (
- <CalendarEventList events={events} advanced groupByDate locale={locale} fillHeight />
- ) : (
- <Stack h="100%" align="center" justify="center" p="md">
- <Text c="dimmed" size="sm" ta="center">
- {t("noEvents")}
- </Text>
- </Stack>
- )}
- </Box>
- </Stack>
+ <CalendarDisplay
+ {...props}
+ releaseType={options.releaseType}
+ view={props.isEditMode ? defaultView : (selectedView ?? defaultView)}
+ setView={setView}
+ locale={locale}
+ firstDayOfWeek={firstDayOfWeek}
+ radius={theme.radius[board.itemRadius]}
+ />
);
};
diff --git a/packages/widgets/src/calendar/index.ts b/packages/widgets/src/calendar/index.ts
index 25873188b..3e035f2a8 100644
--- a/packages/widgets/src/calendar/index.ts
+++ b/packages/widgets/src/calendar/index.ts
@@ -6,6 +6,7 @@ import { radarrReleaseTypes } from "@homarr/integrations/types";
import { createWidgetDefinition, matchesWidgetRuntimeQuery } from "../definition";
import { optionsBuilder } from "../options";
+import { calendarViews } from "./calendar-view";
export const { definition, componentLoader } = createWidgetDefinition("calendar", {
icon: IconCalendar,
@@ -14,6 +15,13 @@ export const { definition, componentLoader } = createWidgetDefinition("calendar"
queryMatcher: matchesWidgetRuntimeQuery,
createOptions() {
return optionsBuilder.from((factory) => ({
+ viewMode: factory.select({
+ defaultValue: "compact",
+ options: calendarViews.map((value) => ({
+ value,
+ label: (t) => t(`widget.calendar.view.${value}`),
+ })),
+ }),
releaseType: factory.multiSelect({
defaultValue: ["inCinemas", "digitalRelease"],
options: radarrReleaseTypes.map((value) => ({