component.tsx 979 B

123456789101112131415161718192021222324252627282930
  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. import { SelectTransfer } from "../Transfer/select";
  9. export const Component = defineComponent({
  10. props: {
  11. compId: string().isRequired,
  12. },
  13. setup(props) {
  14. const { helper, controls , store} = useEditor();
  15. const { children } = useCompData(props.compId);
  16. return () => (
  17. <View compId={props.compId}>
  18. {children.default?.map((compId) => {
  19. const compItem = helper.findComp(compId) as DesignComp;
  20. const Comp =
  21. controls.compUICtrl.state.components.get(compItem?.compKey)
  22. ?.Component || CompUI.Container.Component;
  23. return <Comp key={compItem.id} compId={compItem.id} />;
  24. })}
  25. </View>
  26. );
  27. },
  28. });