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.
Files changed (49) hide show
  1. package/README.md +2 -2
  2. package/components/chart/chart.html +7 -5
  3. package/components/chart/example.html +3 -5
  4. package/components/chart.html +67 -65
  5. package/components/components.js +29 -9
  6. package/components/gantt/example.html +2 -7
  7. package/components/gantt/gantt.html +33 -26
  8. package/components/gauge/example.html +1 -1
  9. package/components/gauge/gauge.html +20 -0
  10. package/components/gauge.html +47 -44
  11. package/components/orgchart/example.html +25 -0
  12. package/components/orgchart/orgchart.html +41 -0
  13. package/components/repl/code-editor.html +64 -0
  14. package/components/repl/editor.html +37 -0
  15. package/components/repl/editorjs-inline-tool/index.js +3 -0
  16. package/components/repl/editorjs-inline-tool/inline-tools.js +28 -0
  17. package/components/repl/editorjs-inline-tool/tool.js +175 -0
  18. package/components/repl/repl-with-wysiwyg.html +355 -0
  19. package/components/repl/repl.html +345 -0
  20. package/components/repl/sup.js +44 -0
  21. package/components/repl/wysiwyg-repl.html +258 -0
  22. package/components/timeline/example.html +33 -0
  23. package/components/timeline/timeline.html +44 -0
  24. package/examples/anchor.html +11 -0
  25. package/examples/chart.html +22 -54
  26. package/examples/counter.html +5 -3
  27. package/examples/counter2.html +26 -0
  28. package/examples/directives.html +19 -17
  29. package/examples/forgeinform.html +45 -43
  30. package/examples/form.html +22 -20
  31. package/examples/gauge.html +2 -0
  32. package/examples/invalid-template-literals.html +5 -3
  33. package/examples/message.html +10 -4
  34. package/examples/nested.html +1 -1
  35. package/examples/object-bound-form.html +12 -10
  36. package/examples/remote.html +17 -15
  37. package/examples/shared.html +41 -0
  38. package/examples/xor.html +21 -19
  39. package/lightview.js +138 -90
  40. package/package.json +7 -2
  41. package/sites/client.html +48 -0
  42. package/sites/index.html +247 -0
  43. package/test/basic.html +17 -16
  44. package/test/basic.test.mjs +0 -10
  45. package/test/extended.html +17 -20
  46. package/types.js +10 -1
  47. package/unsplash.key +1 -0
  48. package/components/gauge/guage.html +0 -19
  49. 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>
@@ -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="myPieChart" style="max-width:750px" type="PieChart" title="How Much Pizza I Ate Last Night">
9
- // Chart will resize automatically to a max-width of 750px and repaint on type and title changes.
10
- // The component DOM element also exposes a method `el.addRow(row:array)` to dynamically add data
11
- // And, `el.init()` will re-render from the initial data and current attributes.
12
- [
13
- ["Topping","Slices"], // column headings
14
- ["Mushrooms", 3], // remaining rows are data
15
- ["Onions", 1],
16
- ["Olives", 1],
17
- ["Zucchini", 1],
18
- ["Pepperoni", 2]
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
- </l-chart>
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 gauges = document.getElementById("myGauges");
53
- gauges.addEventListener("connected",() => {
54
- setInterval(function() {
55
- gauges.setValue(0, 1, 40 + Math.round(60 * Math.random()));
56
- }, 6000);
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>
@@ -8,9 +8,11 @@
8
8
  <button l-on:click="${bump}">Click count:${count}</button>
9
9
  </p>
10
10
 
11
- <script type="lightview/module">
12
- self.variables({count: "number",}, {reactive,set:0});
13
- self.bump = () => count++;
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>
@@ -50,26 +50,28 @@
50
50
  Variable Values
51
51
  <p id="variables"></p>
52
52
  </div>
53
- <script type="lightview/module">
54
- self.variables({on:"boolean",options:Array},{reactive});
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
- const el = self.getElementById("variables");
62
- while(el.lastElementChild) el.lastElementChild.remove();
63
- self.getVariableNames().forEach((name) => {
64
- const line = document.createElement("div");
65
- line.innerText = `${name} = ${JSON.stringify(self.getVariableValue(name))}`;
66
- el.appendChild(line);
67
- });
68
- };
69
- variableValues();
70
- addEventListener("change",()=> {
71
- variableValues()
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 type="lightview/module">
50
- const orders = [];
51
- self.variables({
52
- checked: "boolean"
53
- }, {
54
- reactive
55
- });
56
- self.variables({
57
- color: "string",
58
- hamburger: Array
59
- }, {
60
- reactive, exported
61
- });
62
- self.addEventListener("connected",() => {
63
- color = "green";
64
- checked = true;
65
- hamburger = ["lettuce"];
66
- });
67
- self.placeOrder = () => {
68
- orders.push(hamburger);
69
- message = {hamburger};
70
- };
71
- // demo instrumentation
72
- const variableValues = () => {
73
- const el = self.getElementById("variables");
74
- while (el.lastElementChild) el.lastElementChild.remove();
75
- self.getVariableNames().forEach((name) => {
76
- const line = document.createElement("div");
77
- line.innerText = `${name} = ${JSON.stringify(self.getVariableValue(name))}`;
78
- el.appendChild(line);
79
- });
80
- const line = document.createElement("div");
81
- line.innerText = "Previous Orders";
82
- el.appendChild(line);
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
- variableValues();
90
- addEventListener("change", () => {
91
- variableValues()
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
 
@@ -33,26 +33,28 @@
33
33
 
34
34
  </p>
35
35
  </div>
36
- <script type="lightview/module">
37
- self.variables({color:"string"},{reactive});
38
- addEventListener("change", () => {
39
- variableValues()
40
- });
41
- self.addEventListener("connected",() => {
42
- color = "yellow";
43
- checked = true;
44
- hamburger = ["cheese"];
45
- });
46
- // demo instrumentation
47
- const variableValues = () => {
48
- const el = self.getElementById("variables");
49
- while (el.lastElementChild) el.lastElementChild.remove();
50
- self.getVariableNames().forEach((name) => {
51
- const line = document.createElement("div");
52
- line.innerText = `${name} = ${JSON.stringify(self.getVariableValue(name))}`;
53
- el.appendChild(line);
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
 
@@ -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 type="lightview/module">
30
- self.variables({count: "number",test:"number"}, {reactive,set:0});
31
- self.bump = () => count++;
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>
@@ -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 type="lightview/module">
9
- self.variables({value:"string"},{imported});
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>
@@ -2,7 +2,7 @@
2
2
  <head>
3
3
  <title>Nested</title>
4
4
  <link href="./message.html" rel="module">
5
- <script src="../lightview.js?as=x-body"></script>
5
+ <script src="../lightview2.js?as=x-body"></script>
6
6
  </head>
7
7
  <body>
8
8
  <l-message value="Hello One"></l-message>
@@ -3,9 +3,8 @@
3
3
 
4
4
  <head>
5
5
  <title>Form</title>
6
- <script src="../lightview.js?as=x-body"></script>
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 type="lightview/module">
22
- self.addEventListener("connected",() => {
23
- hamburger.options = ["cheese"];
24
- observe(() => {
25
- const el = self.getElementById("variables");
26
- el.innerText = JSON.stringify(hamburger);
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
- </script>
30
+ }
31
+ </script>
30
32
  </body>
31
33
 
32
34
  </html>
@@ -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
- <script type="lightview/module">
16
- const {remote} = await import("../types.js");
19
+ self.variables({myRemote: "object"}, {reactive, remote: remote("http://localhost:8000/remote.json")});
17
20
 
18
- self.variables({myRemote:"object"},{reactive,remote:remote("http://localhost:8000/remote.json")});
21
+ await myRemote; // must await remotes before the first time they are used, e.g. before HTML is rendered
19
22
 
20
- await myRemote; // must await remotes before the first time they are used, e.g. before HTML is rendered
23
+ self.patch = () => {
24
+ const json = JSON.parse(document.body.getElementById("myRemote").value);
25
+ Object.assign(myRemote, json);
26
+ };
21
27
 
22
- self.patch = () => {
23
- const json = JSON.parse(document.body.getElementById("myRemote").value);
24
- Object.assign(myRemote,json);
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>