tsx:add fragment support
This commit is contained in:
parent
aeff0a06dc
commit
03633a7bea
@ -5,31 +5,23 @@ import {
|
||||
Gravity,
|
||||
Group,
|
||||
LayoutSpec,
|
||||
Image,
|
||||
Text,
|
||||
makeRef,
|
||||
} from "doric";
|
||||
|
||||
// class MyPanel extends Panel {
|
||||
// build(root: Group) {
|
||||
// <VLayout
|
||||
// space={20}
|
||||
// gravity={Gravity.Center}
|
||||
// layoutConfig={{
|
||||
// widthSpec: LayoutSpec.MOST,
|
||||
// heightSpec: LayoutSpec.MOST,
|
||||
// }}
|
||||
// parent={root}
|
||||
// >
|
||||
// <Image imageUrl="https://doric.pub/logo.png" />
|
||||
// <Text text="Hello,Doric" textSize={20} />
|
||||
// </VLayout>;
|
||||
// }
|
||||
// }
|
||||
function createFragment() {
|
||||
return (
|
||||
<>
|
||||
<Text text="This is line 1 in fragment"></Text>
|
||||
<Text text="This is line 2 in fragment"></Text>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
@Entry
|
||||
class Counter extends Panel {
|
||||
build(root: Group) {
|
||||
const fragmnets = createFragment();
|
||||
const ref = makeRef<Text>();
|
||||
let count = 0;
|
||||
<VLayout
|
||||
@ -50,6 +42,7 @@ class Counter extends Panel {
|
||||
ref.current.text = `${count}`;
|
||||
}}
|
||||
/>
|
||||
{fragmnets}
|
||||
</VLayout>;
|
||||
}
|
||||
}
|
||||
|
@ -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",
|
||||
]
|
||||
}
|
@ -139,7 +139,7 @@ function logw() {
|
||||
nativeLog('w', out);
|
||||
}
|
||||
|
||||
var __extends$f = (undefined && undefined.__extends) || (function () {
|
||||
var __extends$g = (undefined && undefined.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
@ -571,7 +571,7 @@ var View = /** @class */ (function () {
|
||||
return View;
|
||||
}());
|
||||
var Superview = /** @class */ (function (_super) {
|
||||
__extends$f(Superview, _super);
|
||||
__extends$g(Superview, _super);
|
||||
function Superview() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
@ -687,7 +687,7 @@ var Superview = /** @class */ (function (_super) {
|
||||
return Superview;
|
||||
}(View));
|
||||
var Group = /** @class */ (function (_super) {
|
||||
__extends$f(Group, _super);
|
||||
__extends$g(Group, _super);
|
||||
function Group() {
|
||||
var _this = _super !== null && _super.apply(this, arguments) || this;
|
||||
_this.children = [];
|
||||
@ -886,7 +886,7 @@ function layoutConfig() {
|
||||
return new LayoutConfigImpl;
|
||||
}
|
||||
|
||||
var __extends$e = (undefined && undefined.__extends) || (function () {
|
||||
var __extends$f = (undefined && undefined.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __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.");
|
||||
};
|
||||
var Stack = /** @class */ (function (_super) {
|
||||
__extends$e(Stack, _super);
|
||||
__extends$f(Stack, _super);
|
||||
function Stack() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
return Stack;
|
||||
}(Group));
|
||||
var Root = /** @class */ (function (_super) {
|
||||
__extends$e(Root, _super);
|
||||
__extends$f(Root, _super);
|
||||
function Root() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
return Root;
|
||||
}(Stack));
|
||||
var LinearLayout = /** @class */ (function (_super) {
|
||||
__extends$e(LinearLayout, _super);
|
||||
__extends$f(LinearLayout, _super);
|
||||
function LinearLayout() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
@ -951,14 +951,14 @@ var LinearLayout = /** @class */ (function (_super) {
|
||||
return LinearLayout;
|
||||
}(Group));
|
||||
var VLayout = /** @class */ (function (_super) {
|
||||
__extends$e(VLayout, _super);
|
||||
__extends$f(VLayout, _super);
|
||||
function VLayout() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
return VLayout;
|
||||
}(LinearLayout));
|
||||
var HLayout = /** @class */ (function (_super) {
|
||||
__extends$e(HLayout, _super);
|
||||
__extends$f(HLayout, _super);
|
||||
function HLayout() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
@ -1031,7 +1031,7 @@ function vlayout(views, config) {
|
||||
return ret;
|
||||
}
|
||||
var FlexLayout = /** @class */ (function (_super) {
|
||||
__extends$e(FlexLayout, _super);
|
||||
__extends$f(FlexLayout, _super);
|
||||
function FlexLayout() {
|
||||
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
|
||||
* limitations under the License.
|
||||
*/
|
||||
var __extends$d = (undefined && undefined.__extends) || (function () {
|
||||
var __extends$e = (undefined && undefined.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
@ -1598,7 +1598,7 @@ var Animation = /** @class */ (function () {
|
||||
return Animation;
|
||||
}());
|
||||
var ScaleAnimation = /** @class */ (function (_super) {
|
||||
__extends$d(ScaleAnimation, _super);
|
||||
__extends$e(ScaleAnimation, _super);
|
||||
function ScaleAnimation() {
|
||||
var _this = _super.call(this) || this;
|
||||
_this.scaleXChangeable = {
|
||||
@ -1658,7 +1658,7 @@ var ScaleAnimation = /** @class */ (function (_super) {
|
||||
return ScaleAnimation;
|
||||
}(Animation));
|
||||
var TranslationAnimation = /** @class */ (function (_super) {
|
||||
__extends$d(TranslationAnimation, _super);
|
||||
__extends$e(TranslationAnimation, _super);
|
||||
function TranslationAnimation() {
|
||||
var _this = _super.call(this) || this;
|
||||
_this.translationXChangeable = {
|
||||
@ -1718,7 +1718,7 @@ var TranslationAnimation = /** @class */ (function (_super) {
|
||||
return TranslationAnimation;
|
||||
}(Animation));
|
||||
var RotationAnimation = /** @class */ (function (_super) {
|
||||
__extends$d(RotationAnimation, _super);
|
||||
__extends$e(RotationAnimation, _super);
|
||||
function RotationAnimation() {
|
||||
var _this = _super.call(this) || this;
|
||||
_this.rotationChaneable = {
|
||||
@ -1752,7 +1752,7 @@ var RotationAnimation = /** @class */ (function (_super) {
|
||||
return RotationAnimation;
|
||||
}(Animation));
|
||||
var RotationXAnimation = /** @class */ (function (_super) {
|
||||
__extends$d(RotationXAnimation, _super);
|
||||
__extends$e(RotationXAnimation, _super);
|
||||
function RotationXAnimation() {
|
||||
var _this = _super.call(this) || this;
|
||||
_this.rotationChaneable = {
|
||||
@ -1786,7 +1786,7 @@ var RotationXAnimation = /** @class */ (function (_super) {
|
||||
return RotationXAnimation;
|
||||
}(Animation));
|
||||
var RotationYAnimation = /** @class */ (function (_super) {
|
||||
__extends$d(RotationYAnimation, _super);
|
||||
__extends$e(RotationYAnimation, _super);
|
||||
function RotationYAnimation() {
|
||||
var _this = _super.call(this) || this;
|
||||
_this.rotationChaneable = {
|
||||
@ -1851,7 +1851,7 @@ var AnimationSet = /** @class */ (function () {
|
||||
return AnimationSet;
|
||||
}());
|
||||
|
||||
var __extends$c = (undefined && undefined.__extends) || (function () {
|
||||
var __extends$d = (undefined && undefined.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
@ -1883,7 +1883,7 @@ exports.TruncateAt = void 0;
|
||||
TruncateAt[TruncateAt["Clip"] = 3] = "Clip";
|
||||
})(exports.TruncateAt || (exports.TruncateAt = {}));
|
||||
var Text = /** @class */ (function (_super) {
|
||||
__extends$c(Text, _super);
|
||||
__extends$d(Text, _super);
|
||||
function Text() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
@ -2028,7 +2028,7 @@ exports.GradientOrientation = void 0;
|
||||
GradientOrientation[GradientOrientation["TL_BR"] = 7] = "TL_BR";
|
||||
})(exports.GradientOrientation || (exports.GradientOrientation = {}));
|
||||
|
||||
var __extends$b = (undefined && undefined.__extends) || (function () {
|
||||
var __extends$c = (undefined && undefined.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
@ -2059,7 +2059,7 @@ exports.ScaleType = void 0;
|
||||
ScaleType[ScaleType["ScaleAspectFill"] = 2] = "ScaleAspectFill";
|
||||
})(exports.ScaleType || (exports.ScaleType = {}));
|
||||
var Image = /** @class */ (function (_super) {
|
||||
__extends$b(Image, _super);
|
||||
__extends$c(Image, _super);
|
||||
function Image() {
|
||||
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
|
||||
* limitations under the License.
|
||||
*/
|
||||
var __extends$a = (undefined && undefined.__extends) || (function () {
|
||||
var __extends$b = (undefined && undefined.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
@ -2202,7 +2202,7 @@ var __spreadArray$1 = (undefined && undefined.__spreadArray) || function (to, fr
|
||||
return to;
|
||||
};
|
||||
var ListItem = /** @class */ (function (_super) {
|
||||
__extends$a(ListItem, _super);
|
||||
__extends$b(ListItem, _super);
|
||||
function ListItem() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
@ -2217,7 +2217,7 @@ var ListItem = /** @class */ (function (_super) {
|
||||
return ListItem;
|
||||
}(Stack));
|
||||
var List = /** @class */ (function (_super) {
|
||||
__extends$a(List, _super);
|
||||
__extends$b(List, _super);
|
||||
function List() {
|
||||
var _this = _super !== null && _super.apply(this, arguments) || this;
|
||||
_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) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __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); }
|
||||
};
|
||||
var SlideItem = /** @class */ (function (_super) {
|
||||
__extends$9(SlideItem, _super);
|
||||
__extends$a(SlideItem, _super);
|
||||
function SlideItem() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
@ -2364,7 +2364,7 @@ var SlideItem = /** @class */ (function (_super) {
|
||||
return SlideItem;
|
||||
}(Stack));
|
||||
var Slider = /** @class */ (function (_super) {
|
||||
__extends$9(Slider, _super);
|
||||
__extends$a(Slider, _super);
|
||||
function Slider() {
|
||||
var _this = _super !== null && _super.apply(this, arguments) || this;
|
||||
_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) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
||||
@ -2483,7 +2483,7 @@ function scroller(content, config) {
|
||||
});
|
||||
}
|
||||
var Scroller = /** @class */ (function (_super) {
|
||||
__extends$8(Scroller, _super);
|
||||
__extends$9(Scroller, _super);
|
||||
function Scroller() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
@ -2523,7 +2523,7 @@ var Scroller = /** @class */ (function (_super) {
|
||||
return Scroller;
|
||||
}(Superview));
|
||||
|
||||
var __extends$7 = (undefined && undefined.__extends) || (function () {
|
||||
var __extends$8 = (undefined && undefined.__extends) || (function () {
|
||||
var extendStatics = function (d, b) {
|
||||
extendStatics = Object.setPrototypeOf ||
|
||||
({ __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); }
|
||||
};
|
||||
var Refreshable = /** @class */ (function (_super) {
|
||||
__extends$7(Refreshable, _super);
|
||||
__extends$8(Refreshable, _super);
|
||||
function Refreshable() {
|
||||
return _super !== null && _super.apply(this, arguments) || this;
|
||||
}
|
||||
@ -2682,8 +2682,24 @@ exports.Display = void 0;
|
||||
Display[Display["NONE"] = 1] = "NONE";
|
||||
})(exports.Display || (exports.Display = {}));
|
||||
|
||||
var jsx = {
|
||||
createElement: function (constructor, config) {
|
||||
var __extends$7 = (undefined && undefined.__extends) || (function () {
|
||||
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 children = [];
|
||||
@ -2697,15 +2713,31 @@ var jsx = {
|
||||
}
|
||||
if (children && children.length > 0) {
|
||||
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 {
|
||||
throw new Error("Can only add child to group view, do not support " + constructor.name);
|
||||
}
|
||||
}
|
||||
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 extendStatics = function (d, b) {
|
||||
@ -4074,7 +4106,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;
|
||||
|
@ -2060,8 +2060,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) {
|
||||
@ -2069,15 +2070,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;
|
||||
@ -3160,7 +3172,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;
|
||||
|
@ -3584,8 +3584,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) {
|
||||
@ -3593,15 +3594,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;
|
||||
@ -4925,7 +4937,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;
|
||||
|
10
doric-js/index.d.ts
vendored
10
doric-js/index.d.ts
vendored
@ -1399,11 +1399,13 @@ declare module 'doric/lib/src/util/flexbox' {
|
||||
}
|
||||
|
||||
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";
|
||||
export const jsx: {
|
||||
createElement: <T extends View>(constructor: ClassType<T>, config: Partial<T> | null, ...children: View[]) => T;
|
||||
};
|
||||
export namespace jsx {
|
||||
function createElement<T extends View>(constructor: ClassType<T>, config: Partial<T> | null, ...children: View[]): T;
|
||||
class Fragment extends Group {
|
||||
}
|
||||
}
|
||||
global {
|
||||
namespace JSX {
|
||||
interface IntrinsicElements {
|
||||
|
10
doric-js/lib/src/util/jsx.d.ts
vendored
10
doric-js/lib/src/util/jsx.d.ts
vendored
@ -1,8 +1,10 @@
|
||||
import { View } from "../ui/view";
|
||||
import { Group, View } from "../ui/view";
|
||||
import { ClassType } from "./types";
|
||||
export declare const jsx: {
|
||||
createElement: <T extends View>(constructor: ClassType<T>, config: Partial<T> | null, ...children: View[]) => T;
|
||||
};
|
||||
export declare namespace jsx {
|
||||
function createElement<T extends View>(constructor: ClassType<T>, config: Partial<T> | null, ...children: View[]): T;
|
||||
class Fragment extends Group {
|
||||
}
|
||||
}
|
||||
declare global {
|
||||
namespace JSX {
|
||||
interface IntrinsicElements {
|
||||
|
@ -1,7 +1,8 @@
|
||||
import { Group } from "../ui/view";
|
||||
import { layoutConfig } from "./layoutconfig";
|
||||
export const jsx = {
|
||||
createElement: function (constructor, config, ...children) {
|
||||
export var jsx;
|
||||
(function (jsx) {
|
||||
function createElement(constructor, config, ...children) {
|
||||
const e = new constructor();
|
||||
e.layoutConfig = layoutConfig().fit();
|
||||
if (config) {
|
||||
@ -9,12 +10,23 @@ export 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;
|
||||
})(jsx || (jsx = {}));
|
||||
|
@ -2,12 +2,12 @@ import { Group, View } from "../ui/view";
|
||||
import { layoutConfig } from "./layoutconfig";
|
||||
import { ClassType } from "./types";
|
||||
|
||||
export const jsx = {
|
||||
createElement: function <T extends View>(
|
||||
export namespace jsx {
|
||||
export function createElement<T extends View>(
|
||||
constructor: ClassType<T>,
|
||||
config: Partial<T> | null,
|
||||
...children: View[]
|
||||
): T {
|
||||
) {
|
||||
const e = new constructor();
|
||||
e.layoutConfig = layoutConfig().fit()
|
||||
if (config) {
|
||||
@ -15,7 +15,13 @@ export 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}`
|
||||
@ -23,7 +29,8 @@ export const jsx = {
|
||||
}
|
||||
}
|
||||
return e;
|
||||
},
|
||||
}
|
||||
export class Fragment extends Group { }
|
||||
}
|
||||
|
||||
declare global {
|
||||
|
23
doric-web/dist/index.js
vendored
23
doric-web/dist/index.js
vendored
@ -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;
|
||||
|
2
doric-web/dist/index.js.map
vendored
2
doric-web/dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user