import { defineComponent } from "vue";
import { useEditor } from "../..";
import { CompUI } from "../CompUI";
import { useCompRef } from "../CompUI/basicUI/hooks";

export default defineComponent({
  setup() {
    const { store, helper } = useEditor();
    const rootRef = useCompRef("root");
    return () => (
      <div
        ref={rootRef}
        class="overflow-hidden !h-auto"
        style={helper.createStyle(
          helper.findRootComp()?.layout || { size: [750] }
        )}
      >
        {store.pageCompIds.map((id) => {
          const compKey = store.designData.compMap[id]?.compKey;
          const Comp: any = (CompUI[compKey] || CompUI.Container).Component;
          return Comp && <Comp key={id} compId={id} />;
        })}
      </div>
    );
  },
});
