forked from alibaba/lowcode-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblock.tsx
More file actions
38 lines (30 loc) · 1.11 KB
/
block.tsx
File metadata and controls
38 lines (30 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import baseRendererFactory from './base';
import { IBaseRendererProps, IBaseRenderComponent } from '../types';
export default function blockRendererFactory(): IBaseRenderComponent {
const BaseRenderer = baseRendererFactory();
return class BlockRenderer extends BaseRenderer {
static dislayName = 'block-renderer';
__namespace = 'block';
__afterInit(props: IBaseRendererProps) {
this.__generateCtx({});
const schema = props.__schema || {};
this.state = this.__parseData(schema.state || {});
this.__initDataSource(props);
this.__setLifeCycleMethods('constructor', [...arguments]);
}
render() {
const { __schema, __components } = this.props;
if (this.__checkSchema(__schema, 'Div')) {
return '区块 schema 结构异常!';
}
this.__debug(`${BlockRenderer.dislayName} render - ${__schema?.fileName}`);
this.__generateCtx({});
this.__render();
const { Block } = __components;
if (Block) {
return this.__renderComp(Block, {});
}
return this.__renderContent(this.__renderContextProvider());
}
};
}