@pronto-tools-and-more/components-renderer 5.0.2 → 5.1.0
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/package.json +1 -1
- package/src/parts/CreateElement/CreateElement.js +1 -16
- package/src/parts/CreateFakeSection/CreateFakeSection.js +8 -0
- package/src/parts/FakeNode/FakeNode.js +6 -0
- package/src/parts/HasComplexChildren/HasComplexChildren.js +7 -0
- package/src/parts/RenderElement/RenderElement.js +25 -1
- package/src/parts/RenderView/RenderView.js +9 -0
- package/src/parts/RenderViews/RenderViews.js +58 -1
package/package.json
CHANGED
@@ -1,20 +1,5 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
export const createElement = (tag, props, children) => {
|
4
|
-
if (IsHtml.isHtml(tag)) {
|
5
|
-
return {
|
6
|
-
type: "section",
|
7
|
-
content: [
|
8
|
-
{
|
9
|
-
type: "html",
|
10
|
-
tag: "div",
|
11
|
-
content: "abc",
|
12
|
-
},
|
13
|
-
],
|
14
|
-
};
|
15
|
-
}
|
1
|
+
export const createElement = (tag, props, ...children) => {
|
16
2
|
return {
|
17
|
-
type: "section",
|
18
3
|
tag,
|
19
4
|
props,
|
20
5
|
children,
|
@@ -1,4 +1,28 @@
|
|
1
|
+
import * as CreateFakeSection from "../CreateFakeSection/CreateFakeSection.js";
|
2
|
+
import * as HasComplexChildren from "../HasComplexChildren/HasComplexChildren.js";
|
3
|
+
|
1
4
|
export const renderElement = (element) => {
|
2
|
-
if (element
|
5
|
+
if (typeof element === "string") {
|
6
|
+
return {
|
7
|
+
type: "html",
|
8
|
+
tag: "div",
|
9
|
+
content: element,
|
10
|
+
};
|
3
11
|
}
|
12
|
+
if (element.tag) {
|
13
|
+
const hasComplexChildren = HasComplexChildren.hasComplexChildren(element);
|
14
|
+
const renderedChildren = hasComplexChildren
|
15
|
+
? element.children.map(renderElement)
|
16
|
+
: [];
|
17
|
+
const content = hasComplexChildren ? "" : element.children[0] || "";
|
18
|
+
return CreateFakeSection.createFakeSection([
|
19
|
+
{
|
20
|
+
type: "html",
|
21
|
+
tag: element.tag,
|
22
|
+
content,
|
23
|
+
},
|
24
|
+
...renderedChildren,
|
25
|
+
]);
|
26
|
+
}
|
27
|
+
return {};
|
4
28
|
};
|
@@ -1,7 +1,9 @@
|
|
1
1
|
import * as Assert from "../Assert/Assert.js";
|
2
2
|
import * as CreateViews from "../CreateViews/CreateViews.js";
|
3
|
+
import * as FakeNode from "../FakeNode/FakeNode.js";
|
3
4
|
import * as LoadRoutes from "../LoadRoutes/LoadRoutes.js";
|
4
5
|
import * as LoadSwc from "../LoadSwc/LoadSwc.js";
|
6
|
+
import * as RenderView from "../RenderView/RenderView.js";
|
5
7
|
import * as SwcNodePath from "../SwcNodePath/SwcNodePath.js";
|
6
8
|
|
7
9
|
export const renderViews = async (componentsPathMain, tsconfigPath) => {
|
@@ -12,5 +14,60 @@ export const renderViews = async (componentsPathMain, tsconfigPath) => {
|
|
12
14
|
const values = Object.values(module);
|
13
15
|
// TODO return views string instead of json for faster performance?
|
14
16
|
const views = CreateViews.createViews(values);
|
15
|
-
|
17
|
+
const rendered = views.map(RenderView.renderView);
|
18
|
+
console.log(JSON.stringify(views, null, 2));
|
19
|
+
// console.log(JSON.stringify(rendered, null, 2));
|
20
|
+
if (Math) {
|
21
|
+
return rendered;
|
22
|
+
}
|
23
|
+
const newViews = [
|
24
|
+
{
|
25
|
+
content: [
|
26
|
+
{
|
27
|
+
type: "section",
|
28
|
+
content: [
|
29
|
+
FakeNode.fakeNode,
|
30
|
+
{
|
31
|
+
type: "html",
|
32
|
+
tag: "div",
|
33
|
+
className: "outer",
|
34
|
+
content: "",
|
35
|
+
},
|
36
|
+
{
|
37
|
+
type: "html",
|
38
|
+
tag: "div",
|
39
|
+
className: "inner",
|
40
|
+
content: "child",
|
41
|
+
},
|
42
|
+
// {
|
43
|
+
// type: "section",
|
44
|
+
// content: [
|
45
|
+
// FakeNode.fakeNode,
|
46
|
+
// {
|
47
|
+
// type: "html",
|
48
|
+
// tag: "p",
|
49
|
+
// content: "inner",
|
50
|
+
// },
|
51
|
+
// ],
|
52
|
+
// },
|
53
|
+
],
|
54
|
+
},
|
55
|
+
// {
|
56
|
+
// type: "section",
|
57
|
+
// content: [
|
58
|
+
// FakeNode.fakeNode,
|
59
|
+
// {
|
60
|
+
// type: "html",
|
61
|
+
// tag: "div",
|
62
|
+
// content: "23",
|
63
|
+
// },
|
64
|
+
// ],
|
65
|
+
// },
|
66
|
+
],
|
67
|
+
name: "test",
|
68
|
+
path: "test",
|
69
|
+
appBar: "login",
|
70
|
+
},
|
71
|
+
];
|
72
|
+
return newViews;
|
16
73
|
};
|