import type { DslDefinition } from '@oinone/kunlun-dsl'; import type { RuntimeM2OField, RuntimeO2OField, RuntimeView } from '@oinone/kunlun-engine'; import type { FormComplexFieldProps } from '../FormComplexFieldWidget'; import { FormSubviewObjectFieldWidget } from './FormSubviewObjectFieldWidget'; export class AsyncFormSubviewObjectFieldWidget< Field extends RuntimeO2OField | RuntimeM2OField = RuntimeO2OField | RuntimeM2OField, Props extends FormComplexFieldProps = FormComplexFieldProps > extends FormSubviewObjectFieldWidget { protected async initSubview(props: Props): Promise { const { currentViewDsl, metadataSubviewWidget } = this; if (!metadataSubviewWidget) { return; } let viewDsl = currentViewDsl; if (!viewDsl) { viewDsl = await this.getViewDsl(props); this.currentViewDsl = viewDsl; } const runtimeSubview = await this.generatorRuntimeSubview(props); this.runtimeSubviewContext = this.initRuntimeContext(metadataSubviewWidget, runtimeSubview); this.initSubviewAfterProperties(props); } protected async generatorRuntimeSubview(props: Props): Promise { return { type: this.subviewType, model: this.subviewModel, modelName: this.subviewModelName || '', module: this.subviewModule, moduleName: this.subviewModuleName, layout: await this.getViewLayout(props), dsl: this.currentViewDsl, template: await this.getViewTemplate(props) }; } protected async getViewLayout(props: Props): Promise { return undefined; } protected async getViewDsl(props: Props): Promise { const { template } = props; return template && this.findViewDslNode(template); } protected async getViewTemplate(props: Props): Promise { return undefined; } }