"use client" import * as React from "react" import { AnimatePresence, motion } from "framer-motion" import { useLiftMode } from "@/hooks/use-lift-mode" import { Block } from "@/registry/schema" export function BlockWrapper({ block, children, }: React.PropsWithChildren<{ block: Block }>) { const { isLiftMode } = useLiftMode(block.name) React.useEffect(() => { const components = document.querySelectorAll("[x-chunk]") block.chunks?.map((chunk, index) => { const $chunk = document.querySelector( `[x-chunk="${chunk.name}"]` ) const $wrapper = document.querySelector( `[x-chunk-container="${chunk.name}"]` ) const $component = components[index] if (!$chunk || !$component) { return } const position = $component.getBoundingClientRect() $chunk.style.zIndex = "40" // $chunk.style.position = "absolute" // $chunk.style.top = `${position.top}px` // $chunk.style.left = `${position.left}px` $chunk.style.width = `${position.width}px` $chunk.style.height = `${position.height}px` if ($wrapper) { $wrapper.style.zIndex = "40" $wrapper.style.position = "absolute" $wrapper.style.top = `${position.top}px` $wrapper.style.left = `${position.left}px` $wrapper.style.width = `${position.width}px` $wrapper.style.height = `${position.height}px` } }) }, [block.chunks, isLiftMode]) return ( <> {children} {isLiftMode && ( )} ) }