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

@ -5,31 +5,23 @@ import {
Gravity, Gravity,
Group, Group,
LayoutSpec, LayoutSpec,
Image,
Text, Text,
makeRef, makeRef,
} from "doric"; } from "doric";
// class MyPanel extends Panel { function createFragment() {
// build(root: Group) { return (
// <VLayout <>
// space={20} <Text text="This is line 1 in fragment"></Text>
// gravity={Gravity.Center} <Text text="This is line 2 in fragment"></Text>
// layoutConfig={{ </>
// widthSpec: LayoutSpec.MOST, );
// heightSpec: LayoutSpec.MOST, }
// }}
// parent={root}
// >
// <Image imageUrl="https://doric.pub/logo.png" />
// <Text text="Hello,Doric" textSize={20} />
// </VLayout>;
// }
// }
@Entry @Entry
class Counter extends Panel { class Counter extends Panel {
build(root: Group) { build(root: Group) {
const fragmnets = createFragment();
const ref = makeRef<Text>(); const ref = makeRef<Text>();
let count = 0; let count = 0;
<VLayout <VLayout
@ -50,6 +42,7 @@ class Counter extends Panel {
ref.current.text = `${count}`; ref.current.text = `${count}`;
}} }}
/> />
{fragmnets}
</VLayout>; </VLayout>;
} }
} }

View File

@ -1,65 +0,0 @@
{
"compilerOptions": {
/* Basic Options */
// "incremental": true, /* Enable incremental compilation */
"target": "ES5", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019' or 'ESNEXT'. */
"module": "es2015", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */
"lib": [], /* Specify library files to be included in the compilation. */
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
"sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "build-es5/", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
// "tsBuildInfoFile": "./", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
// "downlevelIteration": true, /* Provide full support for iterables in 'for-of', spread, and destructuring when targeting 'ES5' or 'ES3'. */
// "isolatedModules": true, /* Transpile each file as a separate module (similar to 'ts.transpileModule'). */
/* Strict Type-Checking Options */
"strict": true, /* Enable all strict type-checking options. */
// "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */
// "strictNullChecks": true, /* Enable strict null checks. */
// "strictFunctionTypes": true, /* Enable strict checking of function types. */
// "strictBindCallApply": true, /* Enable strict 'bind', 'call', and 'apply' methods on functions. */
// "strictPropertyInitialization": true, /* Enable strict checking of property initialization in classes. */
// "noImplicitThis": true, /* Raise error on 'this' expressions with an implied 'any' type. */
// "alwaysStrict": true, /* Parse in strict mode and emit "use strict" for each source file. */
/* Additional Checks */
// "noUnusedLocals": true, /* Report errors on unused locals. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
/* Module Resolution Options */
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [], /* List of folders to include type definitions from. */
// "types": [], /* Type declaration files to be included in compilation. */
// "allowSyntheticDefaultImports": true, /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */
"esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */
// "preserveSymlinks": true, /* Do not resolve the real path of symlinks. */
// "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
/* Source Map Options */
// "sourceRoot": "", /* Specify the location where debugger should locate TypeScript files instead of source locations. */
// "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
// "inlineSourceMap": true, /* Emit a single file with source maps instead of having a separate file. */
// "inlineSources": true, /* Emit the source alongside the sourcemaps within a single file; requires '--inlineSourceMap' or '--sourceMap' to be set. */
/* Experimental Options */
"experimentalDecorators": true, /* Enables experimental support for ES7 decorators. */
"emitDecoratorMetadata": true /* Enables experimental support for emitting type metadata for decorators. */,
"resolveJsonModule": true
},
"include": [
"**/*.ts",
],
"exclude": [
"build",
]
}

View File

@ -139,7 +139,7 @@ function logw() {
nativeLog('w', out); nativeLog('w', out);
} }
var __extends$f = (undefined && undefined.__extends) || (function () { var __extends$g = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) { var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf || extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
@ -571,7 +571,7 @@ var View = /** @class */ (function () {
return View; return View;
}()); }());
var Superview = /** @class */ (function (_super) { var Superview = /** @class */ (function (_super) {
__extends$f(Superview, _super); __extends$g(Superview, _super);
function Superview() { function Superview() {
return _super !== null && _super.apply(this, arguments) || this; return _super !== null && _super.apply(this, arguments) || this;
} }
@ -687,7 +687,7 @@ var Superview = /** @class */ (function (_super) {
return Superview; return Superview;
}(View)); }(View));
var Group = /** @class */ (function (_super) { var Group = /** @class */ (function (_super) {
__extends$f(Group, _super); __extends$g(Group, _super);
function Group() { function Group() {
var _this = _super !== null && _super.apply(this, arguments) || this; var _this = _super !== null && _super.apply(this, arguments) || this;
_this.children = []; _this.children = [];
@ -886,7 +886,7 @@ function layoutConfig() {
return new LayoutConfigImpl; return new LayoutConfigImpl;
} }
var __extends$e = (undefined && undefined.__extends) || (function () { var __extends$f = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) { var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf || extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
@ -922,21 +922,21 @@ var __values$4 = (undefined && undefined.__values) || function(o) {
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
}; };
var Stack = /** @class */ (function (_super) { var Stack = /** @class */ (function (_super) {
__extends$e(Stack, _super); __extends$f(Stack, _super);
function Stack() { function Stack() {
return _super !== null && _super.apply(this, arguments) || this; return _super !== null && _super.apply(this, arguments) || this;
} }
return Stack; return Stack;
}(Group)); }(Group));
var Root = /** @class */ (function (_super) { var Root = /** @class */ (function (_super) {
__extends$e(Root, _super); __extends$f(Root, _super);
function Root() { function Root() {
return _super !== null && _super.apply(this, arguments) || this; return _super !== null && _super.apply(this, arguments) || this;
} }
return Root; return Root;
}(Stack)); }(Stack));
var LinearLayout = /** @class */ (function (_super) { var LinearLayout = /** @class */ (function (_super) {
__extends$e(LinearLayout, _super); __extends$f(LinearLayout, _super);
function LinearLayout() { function LinearLayout() {
return _super !== null && _super.apply(this, arguments) || this; return _super !== null && _super.apply(this, arguments) || this;
} }
@ -951,14 +951,14 @@ var LinearLayout = /** @class */ (function (_super) {
return LinearLayout; return LinearLayout;
}(Group)); }(Group));
var VLayout = /** @class */ (function (_super) { var VLayout = /** @class */ (function (_super) {
__extends$e(VLayout, _super); __extends$f(VLayout, _super);
function VLayout() { function VLayout() {
return _super !== null && _super.apply(this, arguments) || this; return _super !== null && _super.apply(this, arguments) || this;
} }
return VLayout; return VLayout;
}(LinearLayout)); }(LinearLayout));
var HLayout = /** @class */ (function (_super) { var HLayout = /** @class */ (function (_super) {
__extends$e(HLayout, _super); __extends$f(HLayout, _super);
function HLayout() { function HLayout() {
return _super !== null && _super.apply(this, arguments) || this; return _super !== null && _super.apply(this, arguments) || this;
} }
@ -1031,7 +1031,7 @@ function vlayout(views, config) {
return ret; return ret;
} }
var FlexLayout = /** @class */ (function (_super) { var FlexLayout = /** @class */ (function (_super) {
__extends$e(FlexLayout, _super); __extends$f(FlexLayout, _super);
function FlexLayout() { function FlexLayout() {
return _super !== null && _super.apply(this, arguments) || this; return _super !== null && _super.apply(this, arguments) || this;
} }
@ -1483,7 +1483,7 @@ var Panel = /** @class */ (function () {
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
var __extends$d = (undefined && undefined.__extends) || (function () { var __extends$e = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) { var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf || extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
@ -1598,7 +1598,7 @@ var Animation = /** @class */ (function () {
return Animation; return Animation;
}()); }());
var ScaleAnimation = /** @class */ (function (_super) { var ScaleAnimation = /** @class */ (function (_super) {
__extends$d(ScaleAnimation, _super); __extends$e(ScaleAnimation, _super);
function ScaleAnimation() { function ScaleAnimation() {
var _this = _super.call(this) || this; var _this = _super.call(this) || this;
_this.scaleXChangeable = { _this.scaleXChangeable = {
@ -1658,7 +1658,7 @@ var ScaleAnimation = /** @class */ (function (_super) {
return ScaleAnimation; return ScaleAnimation;
}(Animation)); }(Animation));
var TranslationAnimation = /** @class */ (function (_super) { var TranslationAnimation = /** @class */ (function (_super) {
__extends$d(TranslationAnimation, _super); __extends$e(TranslationAnimation, _super);
function TranslationAnimation() { function TranslationAnimation() {
var _this = _super.call(this) || this; var _this = _super.call(this) || this;
_this.translationXChangeable = { _this.translationXChangeable = {
@ -1718,7 +1718,7 @@ var TranslationAnimation = /** @class */ (function (_super) {
return TranslationAnimation; return TranslationAnimation;
}(Animation)); }(Animation));
var RotationAnimation = /** @class */ (function (_super) { var RotationAnimation = /** @class */ (function (_super) {
__extends$d(RotationAnimation, _super); __extends$e(RotationAnimation, _super);
function RotationAnimation() { function RotationAnimation() {
var _this = _super.call(this) || this; var _this = _super.call(this) || this;
_this.rotationChaneable = { _this.rotationChaneable = {
@ -1752,7 +1752,7 @@ var RotationAnimation = /** @class */ (function (_super) {
return RotationAnimation; return RotationAnimation;
}(Animation)); }(Animation));
var RotationXAnimation = /** @class */ (function (_super) { var RotationXAnimation = /** @class */ (function (_super) {
__extends$d(RotationXAnimation, _super); __extends$e(RotationXAnimation, _super);
function RotationXAnimation() { function RotationXAnimation() {
var _this = _super.call(this) || this; var _this = _super.call(this) || this;
_this.rotationChaneable = { _this.rotationChaneable = {
@ -1786,7 +1786,7 @@ var RotationXAnimation = /** @class */ (function (_super) {
return RotationXAnimation; return RotationXAnimation;
}(Animation)); }(Animation));
var RotationYAnimation = /** @class */ (function (_super) { var RotationYAnimation = /** @class */ (function (_super) {
__extends$d(RotationYAnimation, _super); __extends$e(RotationYAnimation, _super);
function RotationYAnimation() { function RotationYAnimation() {
var _this = _super.call(this) || this; var _this = _super.call(this) || this;
_this.rotationChaneable = { _this.rotationChaneable = {
@ -1851,7 +1851,7 @@ var AnimationSet = /** @class */ (function () {
return AnimationSet; return AnimationSet;
}()); }());
var __extends$c = (undefined && undefined.__extends) || (function () { var __extends$d = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) { var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf || extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
@ -1883,7 +1883,7 @@ exports.TruncateAt = void 0;
TruncateAt[TruncateAt["Clip"] = 3] = "Clip"; TruncateAt[TruncateAt["Clip"] = 3] = "Clip";
})(exports.TruncateAt || (exports.TruncateAt = {})); })(exports.TruncateAt || (exports.TruncateAt = {}));
var Text = /** @class */ (function (_super) { var Text = /** @class */ (function (_super) {
__extends$c(Text, _super); __extends$d(Text, _super);
function Text() { function Text() {
return _super !== null && _super.apply(this, arguments) || this; return _super !== null && _super.apply(this, arguments) || this;
} }
@ -2028,7 +2028,7 @@ exports.GradientOrientation = void 0;
GradientOrientation[GradientOrientation["TL_BR"] = 7] = "TL_BR"; GradientOrientation[GradientOrientation["TL_BR"] = 7] = "TL_BR";
})(exports.GradientOrientation || (exports.GradientOrientation = {})); })(exports.GradientOrientation || (exports.GradientOrientation = {}));
var __extends$b = (undefined && undefined.__extends) || (function () { var __extends$c = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) { var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf || extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
@ -2059,7 +2059,7 @@ exports.ScaleType = void 0;
ScaleType[ScaleType["ScaleAspectFill"] = 2] = "ScaleAspectFill"; ScaleType[ScaleType["ScaleAspectFill"] = 2] = "ScaleAspectFill";
})(exports.ScaleType || (exports.ScaleType = {})); })(exports.ScaleType || (exports.ScaleType = {}));
var Image = /** @class */ (function (_super) { var Image = /** @class */ (function (_super) {
__extends$b(Image, _super); __extends$c(Image, _super);
function Image() { function Image() {
return _super !== null && _super.apply(this, arguments) || this; return _super !== null && _super.apply(this, arguments) || this;
} }
@ -2156,7 +2156,7 @@ function image(config) {
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
var __extends$a = (undefined && undefined.__extends) || (function () { var __extends$b = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) { var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf || extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
@ -2202,7 +2202,7 @@ var __spreadArray$1 = (undefined && undefined.__spreadArray) || function (to, fr
return to; return to;
}; };
var ListItem = /** @class */ (function (_super) { var ListItem = /** @class */ (function (_super) {
__extends$a(ListItem, _super); __extends$b(ListItem, _super);
function ListItem() { function ListItem() {
return _super !== null && _super.apply(this, arguments) || this; return _super !== null && _super.apply(this, arguments) || this;
} }
@ -2217,7 +2217,7 @@ var ListItem = /** @class */ (function (_super) {
return ListItem; return ListItem;
}(Stack)); }(Stack));
var List = /** @class */ (function (_super) { var List = /** @class */ (function (_super) {
__extends$a(List, _super); __extends$b(List, _super);
function List() { function List() {
var _this = _super !== null && _super.apply(this, arguments) || this; var _this = _super !== null && _super.apply(this, arguments) || this;
_this.cachedViews = new Map; _this.cachedViews = new Map;
@ -2328,7 +2328,7 @@ function listItem(item, config) {
}); });
} }
var __extends$9 = (undefined && undefined.__extends) || (function () { var __extends$a = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) { var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf || extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
@ -2353,7 +2353,7 @@ var __metadata$7 = (undefined && undefined.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") { return Reflect.metadata(k, v); } if (typeof Reflect === "object" && typeof Reflect.metadata === "function") { return Reflect.metadata(k, v); }
}; };
var SlideItem = /** @class */ (function (_super) { var SlideItem = /** @class */ (function (_super) {
__extends$9(SlideItem, _super); __extends$a(SlideItem, _super);
function SlideItem() { function SlideItem() {
return _super !== null && _super.apply(this, arguments) || this; return _super !== null && _super.apply(this, arguments) || this;
} }
@ -2364,7 +2364,7 @@ var SlideItem = /** @class */ (function (_super) {
return SlideItem; return SlideItem;
}(Stack)); }(Stack));
var Slider = /** @class */ (function (_super) { var Slider = /** @class */ (function (_super) {
__extends$9(Slider, _super); __extends$a(Slider, _super);
function Slider() { function Slider() {
var _this = _super !== null && _super.apply(this, arguments) || this; var _this = _super !== null && _super.apply(this, arguments) || this;
_this.cachedViews = new Map; _this.cachedViews = new Map;
@ -2449,7 +2449,7 @@ function slideItem(item, config) {
}); });
} }
var __extends$8 = (undefined && undefined.__extends) || (function () { var __extends$9 = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) { var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf || extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
@ -2483,7 +2483,7 @@ function scroller(content, config) {
}); });
} }
var Scroller = /** @class */ (function (_super) { var Scroller = /** @class */ (function (_super) {
__extends$8(Scroller, _super); __extends$9(Scroller, _super);
function Scroller() { function Scroller() {
return _super !== null && _super.apply(this, arguments) || this; return _super !== null && _super.apply(this, arguments) || this;
} }
@ -2523,7 +2523,7 @@ var Scroller = /** @class */ (function (_super) {
return Scroller; return Scroller;
}(Superview)); }(Superview));
var __extends$7 = (undefined && undefined.__extends) || (function () { var __extends$8 = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) { var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf || extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
@ -2548,7 +2548,7 @@ var __metadata$5 = (undefined && undefined.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") { return Reflect.metadata(k, v); } if (typeof Reflect === "object" && typeof Reflect.metadata === "function") { return Reflect.metadata(k, v); }
}; };
var Refreshable = /** @class */ (function (_super) { var Refreshable = /** @class */ (function (_super) {
__extends$7(Refreshable, _super); __extends$8(Refreshable, _super);
function Refreshable() { function Refreshable() {
return _super !== null && _super.apply(this, arguments) || this; return _super !== null && _super.apply(this, arguments) || this;
} }
@ -2682,8 +2682,24 @@ exports.Display = void 0;
Display[Display["NONE"] = 1] = "NONE"; Display[Display["NONE"] = 1] = "NONE";
})(exports.Display || (exports.Display = {})); })(exports.Display || (exports.Display = {}));
var jsx = { var __extends$7 = (undefined && undefined.__extends) || (function () {
createElement: function (constructor, config) { var extendStatics = function (d, b) {
extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) { if (Object.prototype.hasOwnProperty.call(b, p)) { d[p] = b[p]; } } };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
{ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); }
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
})();
exports.jsx = void 0;
(function (jsx) {
function createElement(constructor, config) {
var arguments$1 = arguments; var arguments$1 = arguments;
var children = []; var children = [];
@ -2697,15 +2713,31 @@ var jsx = {
} }
if (children && children.length > 0) { if (children && children.length > 0) {
if (e instanceof Group) { if (e instanceof Group) {
children.forEach(function (child) { return e.addChild(child); }); children.forEach(function (child) {
if (child instanceof Fragment) {
child.children.forEach(function (c) { return e.addChild(c); });
}
else {
e.addChild(child);
}
});
} }
else { else {
throw new Error("Can only add child to group view, do not support " + constructor.name); throw new Error("Can only add child to group view, do not support " + constructor.name);
} }
} }
return e; return e;
}, }
}; jsx.createElement = createElement;
var Fragment = /** @class */ (function (_super) {
__extends$7(Fragment, _super);
function Fragment() {
return _super !== null && _super.apply(this, arguments) || this;
}
return Fragment;
}(Group));
jsx.Fragment = Fragment;
})(exports.jsx || (exports.jsx = {}));
var __extends$6 = (undefined && undefined.__extends) || (function () { var __extends$6 = (undefined && undefined.__extends) || (function () {
var extendStatics = function (d, b) { var extendStatics = function (d, b) {
@ -4074,7 +4106,6 @@ exports.hlayout = hlayout;
exports.image = image; exports.image = image;
exports.input = input; exports.input = input;
exports.internalScheme = internalScheme; exports.internalScheme = internalScheme;
exports.jsx = jsx;
exports.keyboard = keyboard; exports.keyboard = keyboard;
exports.layoutConfig = layoutConfig; exports.layoutConfig = layoutConfig;
exports.list = list; exports.list = list;

View File

@ -2060,8 +2060,9 @@ exports.Display = void 0;
Display[Display["NONE"] = 1] = "NONE"; Display[Display["NONE"] = 1] = "NONE";
})(exports.Display || (exports.Display = {})); })(exports.Display || (exports.Display = {}));
const jsx = { exports.jsx = void 0;
createElement: function (constructor, config, ...children) { (function (jsx) {
function createElement(constructor, config, ...children) {
const e = new constructor(); const e = new constructor();
e.layoutConfig = layoutConfig().fit(); e.layoutConfig = layoutConfig().fit();
if (config) { if (config) {
@ -2069,15 +2070,26 @@ const jsx = {
} }
if (children && children.length > 0) { if (children && children.length > 0) {
if (e instanceof Group) { 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 { else {
throw new Error(`Can only add child to group view, do not support ${constructor.name}`); throw new Error(`Can only add child to group view, do not support ${constructor.name}`);
} }
} }
return e; 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 __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; var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@ -3160,7 +3172,6 @@ exports.hlayout = hlayout;
exports.image = image; exports.image = image;
exports.input = input; exports.input = input;
exports.internalScheme = internalScheme; exports.internalScheme = internalScheme;
exports.jsx = jsx;
exports.keyboard = keyboard; exports.keyboard = keyboard;
exports.layoutConfig = layoutConfig; exports.layoutConfig = layoutConfig;
exports.list = list; exports.list = list;

View File

@ -3584,8 +3584,9 @@ exports.Display = void 0;
Display[Display["NONE"] = 1] = "NONE"; Display[Display["NONE"] = 1] = "NONE";
})(exports.Display || (exports.Display = {})); })(exports.Display || (exports.Display = {}));
const jsx = { exports.jsx = void 0;
createElement: function (constructor, config, ...children) { (function (jsx) {
function createElement(constructor, config, ...children) {
const e = new constructor(); const e = new constructor();
e.layoutConfig = layoutConfig().fit(); e.layoutConfig = layoutConfig().fit();
if (config) { if (config) {
@ -3593,15 +3594,26 @@ const jsx = {
} }
if (children && children.length > 0) { if (children && children.length > 0) {
if (e instanceof Group) { 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 { else {
throw new Error(`Can only add child to group view, do not support ${constructor.name}`); throw new Error(`Can only add child to group view, do not support ${constructor.name}`);
} }
} }
return e; 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 __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; var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
@ -4925,7 +4937,6 @@ exports.hlayout = hlayout;
exports.image = image; exports.image = image;
exports.input = input; exports.input = input;
exports.internalScheme = internalScheme; exports.internalScheme = internalScheme;
exports.jsx = jsx;
exports.keyboard = keyboard; exports.keyboard = keyboard;
exports.layoutConfig = layoutConfig; exports.layoutConfig = layoutConfig;
exports.list = list; exports.list = list;

10
doric-js/index.d.ts vendored
View File

@ -1399,11 +1399,13 @@ declare module 'doric/lib/src/util/flexbox' {
} }
declare module 'doric/lib/src/util/jsx' { declare module 'doric/lib/src/util/jsx' {
import { View } from "doric/lib/src/ui/view"; import { Group, View } from "doric/lib/src/ui/view";
import { ClassType } from "doric/lib/src/util/types"; import { ClassType } from "doric/lib/src/util/types";
export const jsx: { export namespace jsx {
createElement: <T extends View>(constructor: ClassType<T>, config: Partial<T> | null, ...children: View[]) => T; function createElement<T extends View>(constructor: ClassType<T>, config: Partial<T> | null, ...children: View[]): T;
}; class Fragment extends Group {
}
}
global { global {
namespace JSX { namespace JSX {
interface IntrinsicElements { interface IntrinsicElements {

View File

@ -1,8 +1,10 @@
import { View } from "../ui/view"; import { Group, View } from "../ui/view";
import { ClassType } from "./types"; import { ClassType } from "./types";
export declare const jsx: { export declare namespace jsx {
createElement: <T extends View>(constructor: ClassType<T>, config: Partial<T> | null, ...children: View[]) => T; function createElement<T extends View>(constructor: ClassType<T>, config: Partial<T> | null, ...children: View[]): T;
}; class Fragment extends Group {
}
}
declare global { declare global {
namespace JSX { namespace JSX {
interface IntrinsicElements { interface IntrinsicElements {

View File

@ -1,7 +1,8 @@
import { Group } from "../ui/view"; import { Group } from "../ui/view";
import { layoutConfig } from "./layoutconfig"; import { layoutConfig } from "./layoutconfig";
export const jsx = { export var jsx;
createElement: function (constructor, config, ...children) { (function (jsx) {
function createElement(constructor, config, ...children) {
const e = new constructor(); const e = new constructor();
e.layoutConfig = layoutConfig().fit(); e.layoutConfig = layoutConfig().fit();
if (config) { if (config) {
@ -9,12 +10,23 @@ export const jsx = {
} }
if (children && children.length > 0) { if (children && children.length > 0) {
if (e instanceof Group) { 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 { else {
throw new Error(`Can only add child to group view, do not support ${constructor.name}`); throw new Error(`Can only add child to group view, do not support ${constructor.name}`);
} }
} }
return e; return e;
}, }
}; jsx.createElement = createElement;
class Fragment extends Group {
}
jsx.Fragment = Fragment;
})(jsx || (jsx = {}));

View File

@ -2,12 +2,12 @@ import { Group, View } from "../ui/view";
import { layoutConfig } from "./layoutconfig"; import { layoutConfig } from "./layoutconfig";
import { ClassType } from "./types"; import { ClassType } from "./types";
export const jsx = { export namespace jsx {
createElement: function <T extends View>( export function createElement<T extends View>(
constructor: ClassType<T>, constructor: ClassType<T>,
config: Partial<T> | null, config: Partial<T> | null,
...children: View[] ...children: View[]
): T { ) {
const e = new constructor(); const e = new constructor();
e.layoutConfig = layoutConfig().fit() e.layoutConfig = layoutConfig().fit()
if (config) { if (config) {
@ -15,7 +15,13 @@ export const jsx = {
} }
if (children && children.length > 0) { if (children && children.length > 0) {
if (e instanceof Group) { 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 { } else {
throw new Error( throw new Error(
`Can only add child to group view, do not support ${constructor.name}` `Can only add child to group view, do not support ${constructor.name}`
@ -23,7 +29,8 @@ export const jsx = {
} }
} }
return e; return e;
}, }
export class Fragment extends Group { }
} }
declare global { declare global {

View File

@ -3638,8 +3638,9 @@ exports.Display = void 0;
Display[Display["NONE"] = 1] = "NONE"; Display[Display["NONE"] = 1] = "NONE";
})(exports.Display || (exports.Display = {})); })(exports.Display || (exports.Display = {}));
const jsx = { exports.jsx = void 0;
createElement: function (constructor, config, ...children) { (function (jsx) {
function createElement(constructor, config, ...children) {
const e = new constructor(); const e = new constructor();
e.layoutConfig = layoutConfig().fit(); e.layoutConfig = layoutConfig().fit();
if (config) { if (config) {
@ -3647,15 +3648,26 @@ const jsx = {
} }
if (children && children.length > 0) { if (children && children.length > 0) {
if (e instanceof Group) { 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 { else {
throw new Error(`Can only add child to group view, do not support ${constructor.name}`); throw new Error(`Can only add child to group view, do not support ${constructor.name}`);
} }
} }
return e; 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 __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; 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.image = image;
exports.input = input; exports.input = input;
exports.internalScheme = internalScheme; exports.internalScheme = internalScheme;
exports.jsx = jsx;
exports.keyboard = keyboard; exports.keyboard = keyboard;
exports.layoutConfig = layoutConfig; exports.layoutConfig = layoutConfig;
exports.list = list; exports.list = list;

File diff suppressed because one or more lines are too long