1. container 组件可配置 children;

2. schema.children 和 props.children 内容合并
This commit is contained in:
mark.ck 2020-07-27 14:27:16 +08:00
parent 9061e4b384
commit 8de2a9d799
4 changed files with 59 additions and 32 deletions

View File

@ -188,8 +188,9 @@
"propType": "object" "propType": "object"
}, },
{ {
"name": "columns", "name": "children",
"propType": "array" "propType": "array",
"description": "列"
}, },
{ {
"name": "emptyContent", "name": "emptyContent",
@ -1077,10 +1078,8 @@
}, },
{ {
"name": "children", "name": "children",
"propType": { "description": "内容",
"type": "instanceOf", "propType": "array"
"value": "node"
}
}, },
{ {
"name": "style", "name": "style",
@ -1239,17 +1238,19 @@
}, },
{ {
"name": "children", "name": "children",
"propType": { "propType": "array"
"type": "instanceOf",
"value": "node"
}
}, },
{ {
"name": "style", "name": "style",
"propType": "object", "propType": "object",
"description": "自定义内联样式" "description": "自定义内联样式"
} }
] ],
"configure": {
"component": {
"isContainer": true
}
}
}, },
{ {
"componentName": "Button.Group", "componentName": "Button.Group",
@ -4120,8 +4121,14 @@
{ {
"name": "children", "name": "children",
"propType": { "propType": {
"type": "instanceOf", "type": "oneOfType",
"value": "node" "value": [
"bool",
{
"type": "instanceOf",
"value": "node"
}
]
}, },
"description": "内容" "description": "内容"
}, },
@ -4284,8 +4291,10 @@
} }
], ],
"configure": { "configure": {
"isContainer": true, "component": {
"isModel": true "isContainer": true,
"isModel": true
}
} }
}, },
{ {
@ -10510,11 +10519,24 @@
"propType": "func", "propType": "func",
"description": "接收 children 自定义渲染列表" "description": "接收 children 自定义渲染列表"
}, },
{
"name": "dataSource",
"propType": "array"
},
{ {
"name": "style", "name": "style",
"propType": "object" "propType": "object"
} }
] ],
"configure": {
"props": {
"isExtends": true,
"override": [{
"name": "dataSource",
"setter": "JsonSetter"
}]
}
}
}, },
{ {
"componentName": "Tree", "componentName": "Tree",
@ -12706,9 +12728,9 @@
"type": "primary", "type": "primary",
"size": "large", "size": "large",
"htmlType": "button", "htmlType": "button",
"component": "button" "component": "button",
}, "children": ["提交"]
"children": "提交" }
} }
} }
] ]
@ -12952,12 +12974,12 @@
"schema": { "schema": {
"componentName": "Breadcrumb.Item", "componentName": "Breadcrumb.Item",
"props": { "props": {
"prefix": "next-" "prefix": "next-",
}, "children": [
"children": [ "222",
"222", "222111"
"222111" ]
] }
} }
} }
] ]

View File

@ -456,13 +456,9 @@
"type":"JSExpression", "type":"JSExpression",
"value":"this.state.isShowDialog" "value":"this.state.isShowDialog"
}, },
"children":{
"type":"JSSlot"
},
"title":"标题", "title":"标题",
"footer":{
"type":"JSSlot"
},
"events":[ "events":[
] ]
} }

View File

@ -211,6 +211,7 @@ export default function(metadata: TransformedComponentMetadata): TransformedComp
) { ) {
if (component.isContainer !== false) { if (component.isContainer !== false) {
component.isContainer = true; component.isContainer = true;
props.push(propConfigToFieldConfig(prop));
return; return;
} }
} }

View File

@ -142,10 +142,18 @@ class Renderer extends Component<{ renderer: SimulatorRenderer }> {
}); });
console.info('menuprops', viewProps); console.info('menuprops', viewProps);
} }
let _children = leaf?.isContainer() ? (children == null ? [] : Array.isArray(children) ? children : [children]) : children;
if (props.children && props.children.length) {
if (Array.isArray(props.children)) {
_children = Array.isArray(_children) ? _children.concat(props.children) : props.children.unshift(_children);
} else {
Array.isArray(_children) && _children.push(props.children) || (_children = [_children].push(props.children));
}
}
return createElement( return createElement(
getDeviceView(Component, device, designMode), getDeviceView(Component, device, designMode),
viewProps, viewProps,
leaf?.isContainer() ? (children == null ? [] : Array.isArray(children) ? children : [children]) : children, _children,
); );
}} }}
onCompGetRef={(schema: any, ref: ReactInstance | null) => { onCompGetRef={(schema: any, ref: ReactInstance | null) => {