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

View File

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

View File

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

View File

@ -142,10 +142,18 @@ class Renderer extends Component<{ renderer: SimulatorRenderer }> {
});
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(
getDeviceView(Component, device, designMode),
viewProps,
leaf?.isContainer() ? (children == null ? [] : Array.isArray(children) ? children : [children]) : children,
_children,
);
}}
onCompGetRef={(schema: any, ref: ReactInstance | null) => {