import { Badge, Card } from "@mantine/core"; import { useElementSize } from "@mantine/hooks"; import { QueryErrorResetBoundary } from "@tanstack/react-query"; import combineClasses from "clsx"; import { NoIntegrationSelectedError } from "node_modules/@homarr/widgets/src/errors"; import { ErrorBoundary } from "react-error-boundary"; import { useRequiredBoard } from "@homarr/boards/context"; import { useEditMode } from "@homarr/boards/edit-mode"; import { useSettings } from "@homarr/settings"; import { loadWidgetDynamic, reduceWidgetOptionsWithDefaultValues, widgetImports } from "@homarr/widgets"; import { WidgetError } from "@homarr/widgets/errors"; import type { SectionItem } from "~/app/[locale]/boards/_types"; import classes from "../sections/item.module.css"; import { useItemActions } from "./item-actions"; import itemContentClasses from "./item-content.module.css"; import { BoardItemMenu } from "./item-menu"; interface BoardItemContentProps { item: SectionItem; } const getOverflowFromKind = (kind: SectionItem["kind"]) => { if (kind === "iframe") return "hidden"; if (kind === "systemResources") return "visible"; return undefined; }; export const BoardItemContent = ({ item }: BoardItemContentProps) => { const { ref, width, height } = useElementSize(); const board = useRequiredBoard(); return ( <> {item.advancedOptions.title?.trim() && ( {item.advancedOptions.title} )} ); }; interface InnerContentProps { item: SectionItem; width: number; height: number; } const InnerContent = ({ item, ...dimensions }: InnerContentProps) => { const settings = useSettings(); const board = useRequiredBoard(); const [isEditMode] = useEditMode(); const Comp = loadWidgetDynamic(item.kind); const { definition } = widgetImports[item.kind]; const options = reduceWidgetOptionsWithDefaultValues(item.kind, settings, item.options); const newItem = { ...item, options }; const { updateItemOptions } = useItemActions(); const updateOptions = ({ newOptions }: { newOptions: Record }) => updateItemOptions({ itemId: item.id, newOptions }); const widgetSupportsIntegrations = "supportedIntegrations" in definition && definition.supportedIntegrations.length >= 1; return ( {({ reset }) => ( ( <> )} > updateOptions({ newOptions: { ...options, ...partialNewOptions.newOptions, }, }) } {...dimensions} /> )} ); }; const Throw = ({ when, error }: { when: boolean; error: Error }) => { if (when) throw error; return null; };