lightview 1.7.1-b → 1.8.1-b
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/README.md +2 -2
- package/components/chart/chart.html +7 -5
- package/components/chart/example.html +3 -5
- package/components/chart.html +67 -65
- package/components/components.js +29 -9
- package/components/gantt/example.html +2 -7
- package/components/gantt/gantt.html +33 -26
- package/components/gauge/example.html +1 -1
- package/components/gauge/gauge.html +20 -0
- package/components/gauge.html +47 -44
- package/components/orgchart/example.html +25 -0
- package/components/orgchart/orgchart.html +41 -0
- package/components/repl/code-editor.html +64 -0
- package/components/repl/editor.html +37 -0
- package/components/repl/editorjs-inline-tool/index.js +3 -0
- package/components/repl/editorjs-inline-tool/inline-tools.js +28 -0
- package/components/repl/editorjs-inline-tool/tool.js +175 -0
- package/components/repl/repl-with-wysiwyg.html +355 -0
- package/components/repl/repl.html +345 -0
- package/components/repl/sup.js +44 -0
- package/components/repl/wysiwyg-repl.html +258 -0
- package/components/timeline/example.html +33 -0
- package/components/timeline/timeline.html +44 -0
- package/examples/anchor.html +11 -0
- package/examples/chart.html +22 -54
- package/examples/counter.html +5 -3
- package/examples/counter2.html +26 -0
- package/examples/directives.html +19 -17
- package/examples/forgeinform.html +45 -43
- package/examples/form.html +22 -20
- package/examples/gauge.html +2 -0
- package/examples/invalid-template-literals.html +5 -3
- package/examples/message.html +10 -4
- package/examples/nested.html +1 -1
- package/examples/object-bound-form.html +12 -10
- package/examples/remote.html +17 -15
- package/examples/shared.html +41 -0
- package/examples/xor.html +21 -19
- package/lightview.js +138 -90
- package/package.json +7 -2
- package/sites/client.html +48 -0
- package/sites/index.html +247 -0
- package/test/basic.html +17 -16
- package/test/basic.test.mjs +0 -10
- package/test/extended.html +17 -20
- package/types.js +10 -1
- package/unsplash.key +1 -0
- package/components/gauge/guage.html +0 -19
- package/examples/duration.html +0 -279
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>Lightview:Component:Timeline:Example</title>
|
|
5
|
+
<link href="./timeline.html" rel="module">
|
|
6
|
+
<script src="../../lightview.js"></script>
|
|
7
|
+
</head>
|
|
8
|
+
<body>
|
|
9
|
+
<l-timeline title="Presidents">
|
|
10
|
+
{
|
|
11
|
+
options: { showRowLabels: false },
|
|
12
|
+
rows: [
|
|
13
|
+
[ '1', 'George Washington','1789-03-30', '1797-2-04' ],
|
|
14
|
+
[ '2', 'John Adams', '1797-02-04', '1801-02-04' ],
|
|
15
|
+
[ '3', 'Thomas Jefferson', '1801-02-04', '1809-02-04']
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
</l-timeline>
|
|
19
|
+
<l-timeline title="Presidents and Vice Presidents">
|
|
20
|
+
{
|
|
21
|
+
options: { },
|
|
22
|
+
rows: [
|
|
23
|
+
[ 'President', 'George Washington','1789-03-30', '1797-2-04' ],
|
|
24
|
+
[ 'President', 'John Adams', '1797-02-04', '1801-02-04' ],
|
|
25
|
+
[ 'President', 'Thomas Jefferson', '1801-02-04', '1809-02-04'],
|
|
26
|
+
[ 'Vice President', 'John Adams','1789-03-21', '1797-02-04'],
|
|
27
|
+
[ 'Vice President', 'Thomas Jefferson','1797-02-04', '1801-02-04'],
|
|
28
|
+
[ 'Vice President', 'Aaron Burr','1801-02-04', '1805-02-04']
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
</l-timeline>
|
|
32
|
+
</body>
|
|
33
|
+
</html>
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>Lightview:Component:Timeline</title>
|
|
5
|
+
</head>
|
|
6
|
+
<body>
|
|
7
|
+
<div id="target"></div>
|
|
8
|
+
<script src="https://unpkg.com/json5@^2.0.0/dist/index.min.js"></script>
|
|
9
|
+
<script id="lightview">
|
|
10
|
+
(document.currentComponent||(document.currentComponent=document.body)).mount = async function() {
|
|
11
|
+
const {chart} = await import(new URL("../components.js", window.location.href).href);
|
|
12
|
+
chart(self, {
|
|
13
|
+
packages: ["timeline"],
|
|
14
|
+
columns: [
|
|
15
|
+
{id: "RowLabel", type: "string"},
|
|
16
|
+
{id: "BarLabel", type: "string"},
|
|
17
|
+
{id: "Start", type: "date"},
|
|
18
|
+
{id: "End", type: "date"}
|
|
19
|
+
],
|
|
20
|
+
type: "Timeline",
|
|
21
|
+
optionsTransform(options) {
|
|
22
|
+
options = {...options};
|
|
23
|
+
if ("showRowLabels" in options) {
|
|
24
|
+
options.timeline = {showRowLabels: options.showRowLabels};
|
|
25
|
+
}
|
|
26
|
+
return options;
|
|
27
|
+
},
|
|
28
|
+
rowTransform(row, i) {
|
|
29
|
+
return row.map((item, index) => {
|
|
30
|
+
if (item && (index === 2 || index === 3)) {
|
|
31
|
+
const date = new Date(item);
|
|
32
|
+
if (!date || typeof (date) !== "object" || !(date instanceof Date)) {
|
|
33
|
+
throw new TypeError(`row:${i} col:${index} is not a date`);
|
|
34
|
+
}
|
|
35
|
+
return date;
|
|
36
|
+
}
|
|
37
|
+
return item;
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
</script>
|
|
43
|
+
</body>
|
|
44
|
+
</html>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>Anchors</title>
|
|
5
|
+
<script src="../lightview.js?as=x-body"></script>
|
|
6
|
+
</head>
|
|
7
|
+
<body>
|
|
8
|
+
<p><a href="./counter.html" target="#mytarget" crossorigin="use-credentials">Show Counter</a></p>
|
|
9
|
+
<div id="mytarget">To Be Replaced</div>
|
|
10
|
+
</body>
|
|
11
|
+
</html>
|
package/examples/chart.html
CHANGED
|
@@ -1,66 +1,34 @@
|
|
|
1
1
|
<!DOCTYPE html>
|
|
2
2
|
<head>
|
|
3
3
|
<title>Chart</title>
|
|
4
|
-
<link href="../components/chart.html" rel="module">
|
|
4
|
+
<link href="../components/chart/chart.html" rel="module">
|
|
5
5
|
<script src="../lightview.js"></script>
|
|
6
6
|
</head>
|
|
7
7
|
<body>
|
|
8
|
-
<l-chart id="
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
8
|
+
<l-chart id="myChart" type="PieChart" style="height:500px;" title="How Much Pizza I Ate Last Night" hidden l-unhide>
|
|
9
|
+
{
|
|
10
|
+
options: {
|
|
11
|
+
|
|
12
|
+
},
|
|
13
|
+
columns: [
|
|
14
|
+
{label: "Topping", type: "string"},
|
|
15
|
+
{label: "Slices", type: "number"}
|
|
16
|
+
],
|
|
17
|
+
rows: [
|
|
18
|
+
["Mushrooms", 3],
|
|
19
|
+
["Onions", 1],
|
|
20
|
+
["Olives", 1],
|
|
21
|
+
["Zucchini", 1],
|
|
22
|
+
["Pepperoni", 2]
|
|
19
23
|
]
|
|
20
|
-
|
|
21
|
-
<l-chart id="myBarChart" style="max-width:750px" type="BarChart" title="How Much Pizza I Ate Last Night">
|
|
22
|
-
[
|
|
23
|
-
["Topping","Slices",{ role: "style" },{ role: "annotation" }], // column headings, annotation does not apply to Pie
|
|
24
|
-
["Mushrooms", 3, "brown","M"], // remaining rows are data
|
|
25
|
-
["Onions", 1, "yellow","On"],
|
|
26
|
-
["Olives", 1, "black", "Ol"],
|
|
27
|
-
["Zucchini", 1, "green","Z"],
|
|
28
|
-
["Pepperoni", 2, "red","P"]
|
|
29
|
-
]
|
|
30
|
-
</l-chart>
|
|
31
|
-
<l-chart id="myColumnChart" style="max-width:750px" type="ColumnChart" title="How Much Pizza I Ate Last Night">
|
|
32
|
-
[
|
|
33
|
-
["Topping","Slices",{ role: "style" },{ role: "annotation" }], // column headings, style does not apply to Pie or Bar
|
|
34
|
-
["Mushrooms", 3, "brown","Yum"], // remaining rows are data
|
|
35
|
-
["Onions", 1, "yellow","Sweet"],
|
|
36
|
-
["Olives", 1, "black","So, so"],
|
|
37
|
-
["Zucchini", 1, "green","Ick!"],
|
|
38
|
-
["Pepperoni", 2, "red","Spicy!"]
|
|
39
|
-
]
|
|
40
|
-
</l-chart>
|
|
41
|
-
<l-chart id="myGauges" style="max-width:750px" type="Gauge" title="Laptop">
|
|
42
|
-
[
|
|
43
|
-
['Label', 'Value'], // gauge will always take two columns, Label and Value
|
|
44
|
-
['Memory', 80],
|
|
45
|
-
['CPU', 55],
|
|
46
|
-
['Network', 68]
|
|
47
|
-
]
|
|
48
|
-
// there is also a separate l-gauge component that shows just one gauge
|
|
49
|
-
// and is driven entirely by attributes
|
|
24
|
+
}
|
|
50
25
|
</l-chart>
|
|
51
26
|
<script>
|
|
52
|
-
const
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
setInterval(function() {
|
|
58
|
-
gauges.setValue(1, 1, 40 + Math.round(60 * Math.random()));
|
|
59
|
-
}, 5000);
|
|
60
|
-
setInterval(function() {
|
|
61
|
-
gauges.setValue(2, 1, 60 + Math.round(40 * Math.random()));
|
|
62
|
-
}, 7500);
|
|
63
|
-
})
|
|
27
|
+
const el = document.getElementById("myChart");
|
|
28
|
+
el.addEventListener("mounted",() => {
|
|
29
|
+
chart = el.chart;
|
|
30
|
+
chart.addRow(["Anchovies",1]);
|
|
31
|
+
});
|
|
64
32
|
</script>
|
|
65
33
|
</body>
|
|
66
34
|
</html>
|
package/examples/counter.html
CHANGED
|
@@ -8,9 +8,11 @@
|
|
|
8
8
|
<button l-on:click="${bump}">Click count:${count}</button>
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
|
-
<script
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
<script id="lightview">
|
|
12
|
+
(document.currentComponent||(document.currentComponent=document.body)).mount = async function() {
|
|
13
|
+
self.variables({count: "number",}, {reactive, set: 0});
|
|
14
|
+
self.bump = () => count++;
|
|
15
|
+
}
|
|
14
16
|
</script>
|
|
15
17
|
|
|
16
18
|
<style>
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
<head>
|
|
2
|
+
<title>Lightview:Examples:Counter</title>
|
|
3
|
+
<script src="../lightview.js?as=x-body"></script>
|
|
4
|
+
</head>
|
|
5
|
+
|
|
6
|
+
<body>
|
|
7
|
+
<p>
|
|
8
|
+
<button l-on:click="${bump}">Click count:${count}</button>
|
|
9
|
+
</p>
|
|
10
|
+
|
|
11
|
+
<script id="lightview">
|
|
12
|
+
(document.currentComponent||(document.currentComponent=document.body)).mount = async function() {
|
|
13
|
+
this.variables({count: "number",}, {reactive,set:0});
|
|
14
|
+
this.bump = () => count++;
|
|
15
|
+
}
|
|
16
|
+
</script>
|
|
17
|
+
|
|
18
|
+
<style>
|
|
19
|
+
button {
|
|
20
|
+
margin: 20px;
|
|
21
|
+
background: gray
|
|
22
|
+
}
|
|
23
|
+
</style>
|
|
24
|
+
</body>
|
|
25
|
+
|
|
26
|
+
</html>
|
package/examples/directives.html
CHANGED
|
@@ -50,26 +50,28 @@
|
|
|
50
50
|
Variable Values
|
|
51
51
|
<p id="variables"></p>
|
|
52
52
|
</div>
|
|
53
|
-
<script
|
|
54
|
-
|
|
53
|
+
<script id="lightview">
|
|
54
|
+
(document.currentComponent||(document.currentComponent=document.body)).mount = async function() {
|
|
55
|
+
self.variables({on: "boolean", options: Array}, {reactive});
|
|
55
56
|
|
|
56
|
-
on = true;
|
|
57
|
-
options = ["lettuce"];
|
|
57
|
+
on = true;
|
|
58
|
+
options = ["lettuce"];
|
|
58
59
|
|
|
59
60
|
// demo instrumentation
|
|
60
|
-
const variableValues = () => {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
};
|
|
69
|
-
variableValues();
|
|
70
|
-
addEventListener("change",()=> {
|
|
71
|
-
|
|
72
|
-
});
|
|
61
|
+
const variableValues = () => {
|
|
62
|
+
const el = self.getElementById("variables");
|
|
63
|
+
while (el.lastElementChild) el.lastElementChild.remove();
|
|
64
|
+
self.getVariableNames().forEach((name) => {
|
|
65
|
+
const line = document.createElement("div");
|
|
66
|
+
line.innerText = `${name} = ${JSON.stringify(self.getVariableValue(name))}`;
|
|
67
|
+
el.appendChild(line);
|
|
68
|
+
});
|
|
69
|
+
};
|
|
70
|
+
variableValues();
|
|
71
|
+
addEventListener("change", () => {
|
|
72
|
+
variableValues()
|
|
73
|
+
});
|
|
74
|
+
}
|
|
73
75
|
|
|
74
76
|
</script>
|
|
75
77
|
</body>
|
|
@@ -46,50 +46,52 @@
|
|
|
46
46
|
|
|
47
47
|
</p>
|
|
48
48
|
</div>
|
|
49
|
-
<script
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
orders.forEach((order) => {
|
|
84
|
-
const line = document.createElement("div");
|
|
85
|
-
line.innerText = JSON.stringify(order);
|
|
49
|
+
<script id="lightview">
|
|
50
|
+
(document.currentComponent||(document.currentComponent=document.body)).mount = async function() {
|
|
51
|
+
const orders = [];
|
|
52
|
+
self.variables({
|
|
53
|
+
checked: "boolean"
|
|
54
|
+
}, {
|
|
55
|
+
reactive
|
|
56
|
+
});
|
|
57
|
+
self.variables({
|
|
58
|
+
color: "string",
|
|
59
|
+
hamburger: Array
|
|
60
|
+
}, {
|
|
61
|
+
reactive, exported
|
|
62
|
+
});
|
|
63
|
+
self.addEventListener("connected", () => {
|
|
64
|
+
color = "green";
|
|
65
|
+
checked = true;
|
|
66
|
+
hamburger = ["lettuce"];
|
|
67
|
+
});
|
|
68
|
+
self.placeOrder = () => {
|
|
69
|
+
orders.push(hamburger);
|
|
70
|
+
message = {hamburger};
|
|
71
|
+
};
|
|
72
|
+
// demo instrumentation
|
|
73
|
+
const variableValues = () => {
|
|
74
|
+
const el = self.getElementById("variables");
|
|
75
|
+
while (el.lastElementChild) el.lastElementChild.remove();
|
|
76
|
+
self.getVariableNames().forEach((name) => {
|
|
77
|
+
const line = document.createElement("div");
|
|
78
|
+
line.innerText = `${name} = ${JSON.stringify(self.getVariableValue(name))}`;
|
|
79
|
+
el.appendChild(line);
|
|
80
|
+
});
|
|
81
|
+
const line = document.createElement("div");
|
|
82
|
+
line.innerText = "Previous Orders";
|
|
86
83
|
el.appendChild(line);
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
84
|
+
orders.forEach((order) => {
|
|
85
|
+
const line = document.createElement("div");
|
|
86
|
+
line.innerText = JSON.stringify(order);
|
|
87
|
+
el.appendChild(line);
|
|
88
|
+
});
|
|
89
|
+
};
|
|
90
|
+
variableValues();
|
|
91
|
+
addEventListener("change", () => {
|
|
92
|
+
variableValues()
|
|
93
|
+
});
|
|
94
|
+
}
|
|
93
95
|
</script>
|
|
94
96
|
</body>
|
|
95
97
|
|
package/examples/form.html
CHANGED
|
@@ -33,26 +33,28 @@
|
|
|
33
33
|
|
|
34
34
|
</p>
|
|
35
35
|
</div>
|
|
36
|
-
<script
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
36
|
+
<script id="lightview">
|
|
37
|
+
(document.currentComponent||(document.currentComponent=document.body)).mount = async function() {
|
|
38
|
+
self.variables({color: "string"}, {reactive});
|
|
39
|
+
addEventListener("change", () => {
|
|
40
|
+
variableValues()
|
|
41
|
+
});
|
|
42
|
+
self.addEventListener("connected", () => {
|
|
43
|
+
color = "yellow";
|
|
44
|
+
checked = true;
|
|
45
|
+
hamburger = ["cheese"];
|
|
46
|
+
});
|
|
47
|
+
// demo instrumentation
|
|
48
|
+
const variableValues = () => {
|
|
49
|
+
const el = self.getElementById("variables");
|
|
50
|
+
while (el.lastElementChild) el.lastElementChild.remove();
|
|
51
|
+
self.getVariableNames().forEach((name) => {
|
|
52
|
+
const line = document.createElement("div");
|
|
53
|
+
line.innerText = `${name} = ${JSON.stringify(self.getVariableValue(name))}`;
|
|
54
|
+
el.appendChild(line);
|
|
55
|
+
});
|
|
56
|
+
};
|
|
57
|
+
}
|
|
56
58
|
</script>
|
|
57
59
|
</body>
|
|
58
60
|
|
package/examples/gauge.html
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
<title>Chart</title>
|
|
4
4
|
<link href="../components/gauge.html" rel="module">
|
|
5
5
|
<script src="../lightview.js"></script>
|
|
6
|
+
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
|
|
7
|
+
<script src="https://unpkg.com/json5@^2.0.0/dist/index.min.js"></script>
|
|
6
8
|
</head>
|
|
7
9
|
<body>
|
|
8
10
|
<l-gauge id="myGauge" style="max-width:750px" type="Gauge" label="Laptop" value="50"></l-gauge>
|
|
@@ -26,9 +26,11 @@
|
|
|
26
26
|
</p>
|
|
27
27
|
</div>
|
|
28
28
|
|
|
29
|
-
<script
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
<script id="lightview">
|
|
30
|
+
(document.currentComponent||(document.currentComponent=document.body)).mount = async function() {
|
|
31
|
+
self.variables({count: "number", test: "number"}, {reactive, set: 0});
|
|
32
|
+
self.bump = () => count++;
|
|
33
|
+
}
|
|
32
34
|
</script>
|
|
33
35
|
|
|
34
36
|
<style>
|
package/examples/message.html
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
<html>
|
|
2
2
|
<head>
|
|
3
3
|
<meta charset="UTF-8">
|
|
4
|
-
<title>Message</title>
|
|
4
|
+
<title>Lightview:Examples:Message</title>
|
|
5
|
+
<script src="../lightview2.js?as=x-body"></script>
|
|
5
6
|
</head>
|
|
6
|
-
<body>
|
|
7
|
+
<body value="Hello!">
|
|
7
8
|
${value}
|
|
8
|
-
<script
|
|
9
|
-
|
|
9
|
+
<script id="lightview">
|
|
10
|
+
/*(document.currentComponent||=document.body).mount = function() {
|
|
11
|
+
this.variables({value:"string"},{imported});
|
|
12
|
+
}*/
|
|
13
|
+
(document.currentComponent||(document.currentComponent=document.body)).mount = function() {
|
|
14
|
+
this.variables({value:"string"},{imported});
|
|
15
|
+
}
|
|
10
16
|
</script>
|
|
11
17
|
</body>
|
|
12
18
|
</html>
|
package/examples/nested.html
CHANGED
|
@@ -3,9 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
<head>
|
|
5
5
|
<title>Form</title>
|
|
6
|
-
<script src="
|
|
6
|
+
<script src="https://000686818.codepen.website/lightview.js?as=x-body"></script>
|
|
7
7
|
</head>
|
|
8
|
-
|
|
9
8
|
<body>
|
|
10
9
|
<form value="${hamburger}" style="margin:20px;padding:5px;border:1px;border-style:solid;">
|
|
11
10
|
<div>Hamburger options:</div>
|
|
@@ -18,15 +17,18 @@
|
|
|
18
17
|
|
|
19
18
|
</p>
|
|
20
19
|
</form>
|
|
21
|
-
<script
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
<script id="lightview">
|
|
21
|
+
(document.currentComponent||(document.currentComponent=document.body)).mount = async function() {
|
|
22
|
+
self.addEventListener("mounted",() => {
|
|
23
|
+
hamburger.options = ["cheese"];
|
|
24
|
+
// demo instrumentation
|
|
25
|
+
observe(() => {
|
|
26
|
+
const el = self.getElementById("variables");
|
|
27
|
+
el.innerText = JSON.stringify(hamburger);
|
|
28
|
+
});
|
|
27
29
|
});
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
+
}
|
|
31
|
+
</script>
|
|
30
32
|
</body>
|
|
31
33
|
|
|
32
34
|
</html>
|
package/examples/remote.html
CHANGED
|
@@ -6,27 +6,29 @@
|
|
|
6
6
|
<script src="../lightview.js?as=x-body"></script>
|
|
7
7
|
</head>
|
|
8
8
|
<body>
|
|
9
|
+
<p>You must run the file "remote-server.js" for this example to work.</p>
|
|
10
|
+
<input id="myRemote" type="text" value="${JSON.stringify(myRemote)}" size="${JSON.stringify(myRemote).length}"><br>
|
|
11
|
+
<button l-on:click="${patch}">Patch</button><br>
|
|
12
|
+
<button l-on:click="${replace}">Replace</button>
|
|
9
13
|
|
|
10
|
-
<input id="myRemote" type=text" value="${JSON.stringify(myRemote)}" size="${JSON.stringify(myRemote).length}"><br>
|
|
11
|
-
<button l-on:click="patch">Patch</button><br>
|
|
12
|
-
<button l-on:click="replace">Replace</button>
|
|
13
14
|
|
|
15
|
+
<script id="lightview">
|
|
16
|
+
(document.currentComponent||(document.currentComponent=document.body)).mount = async function() {
|
|
17
|
+
const {remote} = await import("../types.js");
|
|
14
18
|
|
|
15
|
-
|
|
16
|
-
const {remote} = await import("../types.js");
|
|
19
|
+
self.variables({myRemote: "object"}, {reactive, remote: remote("http://localhost:8000/remote.json")});
|
|
17
20
|
|
|
18
|
-
|
|
21
|
+
await myRemote; // must await remotes before the first time they are used, e.g. before HTML is rendered
|
|
19
22
|
|
|
20
|
-
|
|
23
|
+
self.patch = () => {
|
|
24
|
+
const json = JSON.parse(document.body.getElementById("myRemote").value);
|
|
25
|
+
Object.assign(myRemote, json);
|
|
26
|
+
};
|
|
21
27
|
|
|
22
|
-
self.
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
self.replace = () => {
|
|
28
|
-
myRemote = JSON.parse(document.body.getElementById("myRemote").value);
|
|
29
|
-
};
|
|
28
|
+
self.replace = () => {
|
|
29
|
+
myRemote = JSON.parse(document.body.getElementById("myRemote").value);
|
|
30
|
+
};
|
|
31
|
+
}
|
|
30
32
|
</script>
|
|
31
33
|
</body>
|
|
32
34
|
</html>
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<title>Form</title>
|
|
6
|
+
<template id="myform">
|
|
7
|
+
${formname}: <form>
|
|
8
|
+
<input type="text" value="${name}">
|
|
9
|
+
</form>
|
|
10
|
+
<script id="lightview">
|
|
11
|
+
(document.currentComponent||(document.currentComponent=document.body)).mount = async function() {
|
|
12
|
+
self.variables({
|
|
13
|
+
name: "string"
|
|
14
|
+
}, {
|
|
15
|
+
shared,
|
|
16
|
+
reactive
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
self.variables({
|
|
20
|
+
formname: "string"
|
|
21
|
+
}, {
|
|
22
|
+
imported
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
</script>
|
|
26
|
+
</template>
|
|
27
|
+
<script src="https://000686818.codepen.website/lightview.js"></script>
|
|
28
|
+
<script>
|
|
29
|
+
Lightview.createComponent("x-form", document.getElementById("myform"))
|
|
30
|
+
</script>
|
|
31
|
+
</head>
|
|
32
|
+
|
|
33
|
+
<body>
|
|
34
|
+
<div style="margin:20px">
|
|
35
|
+
<p>Changing one field will change the other. Try it.</p>
|
|
36
|
+
<x-form formname="Form1"></x-form>
|
|
37
|
+
<x-form formname="Form2"></x-form>
|
|
38
|
+
</div>
|
|
39
|
+
</body>
|
|
40
|
+
|
|
41
|
+
</html>
|