import TemplateOne from "../shared/templates/templateCards/templateOne"; import { availableLargeContent } from "../../controls/constants"; import { Fragment, useEffect, useState } from "@wordpress/element"; const LoopContent = ({ posts, attributes, largeItemIndex = false, containerRef, }) => { const { postGridLayout } = attributes; const isAvailableLargeItem = availableLargeContent.includes(postGridLayout); const [selectedPostId, setSelectedPostId] = useState(null); useEffect(() => { const handleClickOutside = (event) => { if (containerRef.current && !containerRef.current.contains(event.target)) { setSelectedPostId(null); } }; document.addEventListener("mousedown", handleClickOutside); return () => document.removeEventListener("mousedown", handleClickOutside); }, []); return ( <> {posts?.map((post, i) => ( setSelectedPostId(post?.post_id)} /> ))} ); }; export default LoopContent;