tsx:add fragment support

This commit is contained in:
pengfei.zhou
2021-09-02 12:03:19 +08:00
committed by osborn
parent aeff0a06dc
commit 03633a7bea
11 changed files with 170 additions and 155 deletions

View File

@@ -3638,8 +3638,9 @@ exports.Display = void 0;
Display[Display["NONE"] = 1] = "NONE";
})(exports.Display || (exports.Display = {}));
const jsx = {
createElement: function (constructor, config, ...children) {
exports.jsx = void 0;
(function (jsx) {
function createElement(constructor, config, ...children) {
const e = new constructor();
e.layoutConfig = layoutConfig().fit();
if (config) {
@@ -3647,15 +3648,26 @@ const jsx = {
}
if (children && children.length > 0) {
if (e instanceof Group) {
children.forEach((child) => e.addChild(child));
children.forEach((child) => {
if (child instanceof Fragment) {
child.children.forEach(c => e.addChild(c));
}
else {
e.addChild(child);
}
});
}
else {
throw new Error(`Can only add child to group view, do not support ${constructor.name}`);
}
}
return e;
},
};
}
jsx.createElement = createElement;
class Fragment extends Group {
}
jsx.Fragment = Fragment;
})(exports.jsx || (exports.jsx = {}));
var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@@ -4738,7 +4750,6 @@ exports.hlayout = hlayout;
exports.image = image;
exports.input = input;
exports.internalScheme = internalScheme;
exports.jsx = jsx;
exports.keyboard = keyboard;
exports.layoutConfig = layoutConfig;
exports.list = list;

File diff suppressed because one or more lines are too long