component.tsx 918 B

1234567891011121314151617181920212223242526272829
  1. import { defineComponent } from "vue";
  2. import { string } from "vue-types";
  3. import { useCompData } from ".";
  4. import { useEditor } from "../../../..";
  5. import { DesignComp } from "../../../../objects/DesignTemp/DesignComp";
  6. import { View } from "../View";
  7. import { CompUI } from "../..";
  8. export const Component = defineComponent({
  9. props: {
  10. compId: string().isRequired,
  11. },
  12. setup(props) {
  13. const { helper, controls } = useEditor();
  14. const { children } = useCompData(props.compId);
  15. return () => (
  16. <View compId={props.compId}>
  17. {children.default?.map((compId) => {
  18. const compItem = helper.findComp(compId) as DesignComp;
  19. const Comp =
  20. controls.compUICtrl.state.components.get(compItem.compKey)
  21. ?.Component || CompUI.Container.Component;
  22. return <Comp key={compItem.id} compId={compItem.id} />;
  23. })}
  24. </View>
  25. );
  26. },
  27. });