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