UNPKG

@alilc/lowcode-renderer-core

Version:
59 lines 2.35 kB
import _inheritsLoose from "@babel/runtime/helpers/inheritsLoose"; import baseRendererFactory from './base'; export default function componentRendererFactory() { var _CompRenderer; var BaseRenderer = baseRendererFactory(); return _CompRenderer = /*#__PURE__*/function (_BaseRenderer) { function CompRenderer() { var _this; for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } _this = _BaseRenderer.call.apply(_BaseRenderer, [this].concat(args)) || this; _this.__namespace = 'component'; return _this; } _inheritsLoose(CompRenderer, _BaseRenderer); var _proto = CompRenderer.prototype; _proto.__afterInit = function __afterInit(props) { this.__generateCtx({ component: this }); var schema = props.__schema || {}; this.state = this.__parseData(schema.state || {}); this.__initDataSource(props); this.__executeLifeCycleMethod('constructor', arguments); }; _proto.render = function render() { var _schema$props; var _this$props = this.props, __schema = _this$props.__schema, __components = _this$props.__components; if (this.__checkSchema(__schema)) { return '自定义组件 schema 结构异常!'; } this.__debug(CompRenderer.displayName + " render - " + __schema.fileName); this.__generateCtx({ component: this }); this.__render(); var noContainer = this.__parseData((_schema$props = __schema.props) === null || _schema$props === void 0 ? void 0 : _schema$props.noContainer); this.__bindCustomMethods(this.props); if (noContainer) { return this.__renderContextProvider({ compContext: this }); } var Component = __components === null || __components === void 0 ? void 0 : __components[__schema === null || __schema === void 0 ? void 0 : __schema.componentName]; if (!Component) { return this.__renderContent(this.__renderContextProvider({ compContext: this })); } return this.__renderComp(Component, this.__renderContextProvider({ compContext: this })); }; return CompRenderer; }(BaseRenderer), _CompRenderer.displayName = 'CompRenderer', _CompRenderer; }