mirror of
https://github.com/alibaba/lowcode-engine.git
synced 2026-02-28 04:40:32 +00:00
fix initialCHildren
This commit is contained in:
parent
df2362c67d
commit
7c3e7e315e
@ -157,10 +157,17 @@ export class Node<Schema extends NodeSchema = NodeSchema> {
|
||||
}
|
||||
|
||||
private initialChildren(children: any): NodeData[] {
|
||||
// FIXME! this is dirty code
|
||||
if (children == null) {
|
||||
return this.componentMeta.getMetadata().experimental?.initialChildren || [];
|
||||
const initialChildren = this.componentMeta.getMetadata().experimental?.initialChildren;
|
||||
if (initialChildren) {
|
||||
if (typeof initialChildren === 'function') {
|
||||
return initialChildren(this as any) || [];
|
||||
}
|
||||
return initialChildren;
|
||||
}
|
||||
}
|
||||
return children;
|
||||
return children || [];
|
||||
}
|
||||
|
||||
isContainer(): boolean {
|
||||
|
||||
@ -54,7 +54,7 @@ export interface Experimental {
|
||||
initials?: InitialItem[];
|
||||
callbacks?: Callbacks;
|
||||
// TODO: thinkof function
|
||||
initialChildren?: NodeData[];
|
||||
initialChildren?: NodeData[] | ((target: SettingTarget) => NodeData[]);
|
||||
|
||||
// 样式 及 位置,handle上必须有明确的标识以便事件路由判断,或者主动设置事件独占模式
|
||||
// NWSE 是交给引擎计算放置位置,ReactElement 必须自己控制初始位置
|
||||
|
||||
@ -568,7 +568,7 @@ export function upgradeMetadata(oldConfig: OldPrototypeConfig) {
|
||||
if (snippets) {
|
||||
experimental.snippets = snippets.map(data => {
|
||||
const { schema = {} } = data;
|
||||
if (initialChildren && !schema.children) {
|
||||
if (!schema.children && initialChildren && typeof initialChildren !== 'function') {
|
||||
schema.children = initialChildren;
|
||||
}
|
||||
return {
|
||||
@ -596,7 +596,9 @@ export function upgradeMetadata(oldConfig: OldPrototypeConfig) {
|
||||
}
|
||||
}
|
||||
if (initialChildren) {
|
||||
experimental.initialChildren = initialChildren;
|
||||
experimental.initialChildren = typeof initialChildren === 'function' ? (field: Field) => {
|
||||
return initialChildren.call(field, (field as any).props);
|
||||
} : initialChildren;
|
||||
}
|
||||
if (view) {
|
||||
experimental.view = view;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user