x4js 1.4.50 → 1.4.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/component.d.ts +8 -20
- package/lib/component.js +16 -23
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/property_editor.d.ts +1 -1
- package/lib/smartedit.js +1 -1
- package/lib/tabbar.d.ts +1 -1
- package/lib/x4react.d.ts +6 -0
- package/lib/x4react.js +35 -0
- package/license.md +21 -0
- package/package.json +1 -1
- package/src/base_component.ts +2 -1
- package/src/component.ts +2344 -2351
- package/src/index.ts +1 -0
- package/src/x4react.ts +42 -0
- package/tsconfig.json +3 -1
package/src/index.ts
CHANGED
package/src/x4react.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Component, ComponentContent } from './component';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
const createElement = ( clsOrTag, attrs, ...children ): ComponentContent => {
|
|
5
|
+
|
|
6
|
+
let comp: Component;
|
|
7
|
+
|
|
8
|
+
// fragment
|
|
9
|
+
if( clsOrTag==createFragment || clsOrTag==Fragment ) {
|
|
10
|
+
return children;
|
|
11
|
+
}
|
|
12
|
+
// class constructor, yes : dirty
|
|
13
|
+
else if( clsOrTag instanceof Function ) {
|
|
14
|
+
comp = new (clsOrTag as any)( attrs );
|
|
15
|
+
}
|
|
16
|
+
// basic tag
|
|
17
|
+
else {
|
|
18
|
+
comp = new Component( {
|
|
19
|
+
tag: clsOrTag,
|
|
20
|
+
...attrs,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if( children && children.length ) {
|
|
25
|
+
comp.setContent( children );
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return comp;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const Fragment = Symbol( "fragment" );
|
|
32
|
+
|
|
33
|
+
const createFragment = ( ): ComponentContent => {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export let React = {
|
|
38
|
+
createElement,
|
|
39
|
+
createFragment,
|
|
40
|
+
Fragment,
|
|
41
|
+
}
|
|
42
|
+
|
package/tsconfig.json
CHANGED