import { type Rock } from "@ruiapp/move-style"; import { RapidResizableLayoutRockConfig } from "./rapid-resizable-layout-types"; import RapidResizableLayoutMeta from "./RapidResizableLayoutMeta"; import { PanelResizeHandle, Panel, PanelGroup } from "react-resizable-panels"; import { ClientOnlySuspense } from "../../components"; import { renderRock } from "@ruiapp/react-renderer"; import "./rapid-resizable-layout-style.css"; export default { Renderer(context, props) { const { direction = "horizontal" } = props; const layoutRenderer = (layouts: RapidResizableLayoutRockConfig["layouts"]) => { if (!layouts?.length) { return; } return layouts.map((layout, i) => { const key = layout.key || `${layout.kind}_${i}`; switch (layout.kind) { case "panel": return ( {renderRock({ context, rockConfig: layout.children })} ); case "resizehandle": const { resizable = true } = props; const disabled = !resizable || layout.disabled; let className = layout.props?.className || ""; if (!disabled) { className = `rapid-resizable-layout-handler ${className}`; } return ( {!disabled && (
)}
); default: return ""; } }); }; return ( {layoutRenderer(props.layouts)} ); }, ...RapidResizableLayoutMeta, } as Rock;