import { useEffect } from "react"; import type { PropsWithChildren } from "react"; import type { BoxProps } from "@mantine/core"; import { Box } from "@mantine/core"; import combineClasses from "clsx"; import type { SectionKind, WidgetKind } from "@homarr/definitions"; import type { GridItemHTMLElement } from "@homarr/gridstack"; interface Props extends BoxProps { id: string; type: "item" | "section"; kind: WidgetKind | SectionKind; xOffset: number; yOffset: number; width: number; height: number; minWidth?: number; minHeight?: number; innerRef: React.RefObject | undefined; } export const GridStackItem = ({ id, type, kind, xOffset, yOffset, width, height, minWidth = 1, minHeight = 1, innerRef, children, ...boxProps }: PropsWithChildren) => { useEffect(() => { if (!innerRef?.current?.gridstackNode) return; if (type !== "section") return; innerRef.current.gridstackNode.minW = minWidth; innerRef.current.gridstackNode.minH = minHeight; }, [minWidth, minHeight, innerRef, type]); return ( } > {children} ); };