lightview 1.7.2-b → 1.8.2
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 +15 -16
- package/docs/CNAME +1 -0
- package/docs/api.html +674 -0
- package/docs/blank.html +10 -0
- package/docs/comparedto.html +89 -0
- package/docs/components/chart-repl.html +69 -0
- package/docs/components/chart.html +17 -0
- package/{components → docs/components}/components.js +31 -11
- package/docs/components/contents.html +17 -0
- package/docs/components/gantt-repl.html +61 -0
- package/docs/components/gantt.html +42 -0
- package/docs/components/gauge-repl.html +66 -0
- package/docs/components/gauge.html +20 -0
- package/docs/components/orgchart-repl.html +64 -0
- package/docs/components/orgchart.html +41 -0
- package/docs/components/repl-as-src.html +17 -0
- package/docs/components/repl-repl.html +95 -0
- package/docs/components/repl.html +527 -0
- package/docs/components/timeline-repl.html +72 -0
- package/docs/components/timeline.html +44 -0
- package/docs/components.html +14 -0
- package/docs/css/highlightjs.min.css +9 -0
- package/docs/css/tutorial.css +35 -0
- package/docs/examples/anchor.html +11 -0
- package/{components/chart/example.html → docs/examples/chart.html} +6 -4
- package/docs/examples/counter.html +26 -0
- package/{examples → docs/examples}/counter.test.mjs +0 -0
- package/docs/examples/counter2.html +26 -0
- package/{examples → docs/examples}/directives.html +20 -18
- package/{examples → docs/examples}/foreign.html +1 -1
- package/docs/examples/forgeinform.html +98 -0
- package/docs/examples/form.html +61 -0
- package/{examples → docs/examples}/gauge.html +4 -2
- package/{examples → docs/examples}/invalid-template-literals.html +6 -4
- package/{examples → docs/examples}/medium/remote.html +1 -1
- package/docs/examples/message.html +18 -0
- package/{examples → docs/examples}/nested.html +2 -2
- package/docs/examples/object-bound-form.html +34 -0
- package/{examples → docs/examples}/remote-server.js +0 -0
- package/docs/examples/remote.html +34 -0
- package/{examples → docs/examples}/remote.json +0 -0
- package/{examples → docs/examples}/scratch.html +1 -1
- package/docs/examples/sensors/index.html +44 -0
- package/{examples → docs/examples}/sensors/sensor-server.js +0 -0
- package/docs/examples/shared.html +41 -0
- package/{examples → docs/examples}/template.html +1 -1
- package/{examples → docs/examples}/timeline.html +2 -2
- package/docs/examples/todo.html +40 -0
- package/docs/examples/top.html +10 -0
- package/{examples → docs/examples}/types.html +1 -1
- package/{examples → docs/examples}/xor.html +22 -20
- package/docs/examples.html +25 -0
- package/docs/index.html +44 -0
- package/docs/javascript/codejar.min.js +8 -0
- package/docs/javascript/highlightjs.min.js +1173 -0
- package/docs/javascript/isomorphic-git.js +9 -0
- package/docs/javascript/json5.min.js +1 -0
- package/docs/javascript/lightning-fs.js +1 -0
- package/docs/javascript/lightview.js +1285 -0
- package/docs/javascript/marked.min.js +6 -0
- package/docs/javascript/peerjs.min.js +70 -0
- package/docs/javascript/turndown.js +973 -0
- package/docs/javascript/types.js +606 -0
- package/docs/javascript/utils.js +45 -0
- package/docs/lightview.html +63 -0
- package/docs/old_index.html +965 -0
- package/docs/old_index.md +1132 -0
- package/docs/slidein.html +51 -0
- package/docs/tutorial/0-getting-started.html +67 -0
- package/docs/tutorial/1-intro-to-variables.html +103 -0
- package/docs/tutorial/10-template-components.html +80 -0
- package/docs/tutorial/11-linked-components.html +76 -0
- package/docs/tutorial/12-imported-components.html +67 -0
- package/docs/tutorial/13-input-binding.html +94 -0
- package/docs/tutorial/14-automatic-variable-creation.html +74 -0
- package/docs/tutorial/15-form-binding.html +110 -0
- package/docs/tutorial/16-if-directive.html +60 -0
- package/docs/tutorial/17-loop-directives.html +83 -0
- package/docs/tutorial/18-sanitizing-and-escaping-input.html +79 -0
- package/docs/tutorial/2-imported-and-exported-variables.html +80 -0
- package/docs/tutorial/3-data-types.html +89 -0
- package/docs/tutorial/4-extended-data-types.html +83 -0
- package/docs/tutorial/5-extended-functional-types.html +96 -0
- package/docs/tutorial/5.1-extended-functional-types.html +79 -0
- package/docs/tutorial/5.2-extended-functional-types.html +70 -0
- package/docs/tutorial/6-conventional-javascript.html +75 -0
- package/docs/tutorial/7-monitoring-with-observers.html +107 -0
- package/docs/tutorial/8-event-listeners.html +65 -0
- package/docs/tutorial/9-intro-to-components.html +91 -0
- package/docs/tutorial/contents.html +32 -0
- package/docs/tutorial/my-component.html +29 -0
- package/docs/tutorial/remote-value.json +4 -0
- package/docs/websiterepl.html +46 -0
- package/lightview.js +499 -363
- package/lightview.min.js +1 -0
- package/lightview_good.js +1267 -0
- package/lightview_optimized.js +1274 -0
- package/package.json +7 -2
- package/repl_hold.html +320 -0
- package/test/basic.html +29 -17
- package/test/basic.test.mjs +1 -11
- package/test/extended.html +16 -19
- package/types.js +118 -36
- package/unsplash.key +1 -0
- package/components/chart/chart.html +0 -15
- package/components/chart.html +0 -81
- package/components/gantt/example.html +0 -27
- package/components/gantt/gantt.html +0 -34
- package/components/gauge/example.html +0 -28
- package/components/gauge/guage.html +0 -19
- package/components/gauge.html +0 -57
- package/components/timeline.html +0 -81
- package/examples/chart.html +0 -66
- package/examples/counter.html +0 -24
- package/examples/forgeinform.html +0 -96
- package/examples/form.html +0 -59
- package/examples/message.html +0 -12
- package/examples/object-bound-form.html +0 -32
- package/examples/remote.html +0 -32
- package/examples/sensors/index.html +0 -30
- package/examples/todo.html +0 -38
- package/examples/top.html +0 -10
package/types.js
CHANGED
|
@@ -17,6 +17,41 @@ function reviver(property,value) {
|
|
|
17
17
|
if(value==="@NaN") return NaN;
|
|
18
18
|
return value;
|
|
19
19
|
}
|
|
20
|
+
const deepEqual = (a,b,matchType=deepEqual.LEFT, seen=new Set()) => {
|
|
21
|
+
if(matchType===deepEqual.RIGHT) return deepEqual(b,a,deepEqual.LEFT,seen);
|
|
22
|
+
if(matchType===deepEqual.COMMUTATIVE) return deepEqual(a,b,deepEqual.LEFT) && deepEqual(b,a,deepEqual.LEFT);
|
|
23
|
+
if(a===b) return true;
|
|
24
|
+
const type = typeof(a);
|
|
25
|
+
if(type==="function" || type!==typeof(b) || (a && !b) || (b && !a)) return false;
|
|
26
|
+
if(type==="number" && isNaN(a) && isNaN(b)) return true;
|
|
27
|
+
if(a && type==="object") {
|
|
28
|
+
if(seen.has(a)) return true;
|
|
29
|
+
seen.add(a);
|
|
30
|
+
if(a.constructor!==b.constructor || a.length!==b.length || a.size!==b.size) return false;
|
|
31
|
+
if(a instanceof Date) a.getTime() === b.getTime();
|
|
32
|
+
if(a instanceof RegExp) return a.toString() === b.toString();
|
|
33
|
+
if(a instanceof Set) {
|
|
34
|
+
for(const avalue of [...a]) {
|
|
35
|
+
if(![...b].some((bvalue) => deepEqual(avalue,bvalue,matchType,seen))) return false;
|
|
36
|
+
}
|
|
37
|
+
return true;
|
|
38
|
+
}
|
|
39
|
+
if(a instanceof Map) {
|
|
40
|
+
for(const [key,value] of [...a]) {
|
|
41
|
+
if(!deepEqual(b.get(key),value,matchType,seen)) return false;
|
|
42
|
+
}
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
45
|
+
for(const key in a) {
|
|
46
|
+
if(!deepEqual(a[key],b[key],matchType,seen)) return false;
|
|
47
|
+
}
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
deepEqual.LEFT = 1;
|
|
53
|
+
deepEqual.COMMUTATIVE = 2;
|
|
54
|
+
deepEqual.RIGHT = 3;
|
|
20
55
|
|
|
21
56
|
function ValidityState(options) {
|
|
22
57
|
if(!this || !(this instanceof ValidityState)) return new ValidityState(options);
|
|
@@ -245,11 +280,11 @@ const validateNumber = function(value,variable) {
|
|
|
245
280
|
variable.validityState = ValidityState({typeMismatch:true,value});
|
|
246
281
|
} else if(isNaN(result) && !this.allowNaN) {
|
|
247
282
|
variable.validityState = ValidityState({badInput:true,value});
|
|
248
|
-
} else if(this.min!=null && result<this.min) {
|
|
283
|
+
} else if(this.min!=null && result<this.min && !(this.min===-Infinity && isNaN(result))) {
|
|
249
284
|
variable.validityState = ValidityState({rangeUnderflow:true,value});
|
|
250
|
-
} else if(this.max!=null && result>this.max) {
|
|
285
|
+
} else if(this.max!=null && result>this.max && !(this.max===Infinity && isNaN(result))) {
|
|
251
286
|
variable.validityState = ValidityState({rangeOverflow:true,value});
|
|
252
|
-
} else if(this.step
|
|
287
|
+
} else if(this.step!=null && (result % this.step)!==0) {
|
|
253
288
|
variable.validityState = ValidityState({rangeUnderflow:true,value});
|
|
254
289
|
} else {
|
|
255
290
|
variable.validityState = ValidityState({valid:true});
|
|
@@ -258,7 +293,7 @@ const validateNumber = function(value,variable) {
|
|
|
258
293
|
}
|
|
259
294
|
return this.whenInvalid(variable,value);
|
|
260
295
|
}
|
|
261
|
-
const number = ({coerce=false,required = false,whenInvalid = ifInvalid,min=-Infinity,max=Infinity,step
|
|
296
|
+
const number = ({coerce=false,required = false,whenInvalid = ifInvalid,min=-Infinity,max=Infinity,step,allowNaN = true,...rest}={}) => {
|
|
262
297
|
if(typeof(coerce)!=="boolean") throw new TypeError(`coerce, ${JSON.stringify(coerce)}, must be a boolean`);
|
|
263
298
|
if(typeof(required)!=="boolean") throw new TypeError(`required, ${JSON.stringify(required)}, must be a boolean`);
|
|
264
299
|
if(typeof(whenInvalid)!=="function") throw new TypeError(`whenInvalid, ${whenInvalid}, must be a function`);
|
|
@@ -356,6 +391,15 @@ const string = ({coerce=false, required = false,whenInvalid = ifInvalid, maxleng
|
|
|
356
391
|
}
|
|
357
392
|
}
|
|
358
393
|
|
|
394
|
+
const html = (...args) => string(...args);
|
|
395
|
+
html.safe = true;
|
|
396
|
+
|
|
397
|
+
const css = (...args) => string(...args);
|
|
398
|
+
css.safe = true;
|
|
399
|
+
|
|
400
|
+
const script = (...args) => string(...args);
|
|
401
|
+
script.safe = true;
|
|
402
|
+
|
|
359
403
|
|
|
360
404
|
const validateSymbol = function(value,variable) {
|
|
361
405
|
if(value===undefined && variable.value===undefined) {
|
|
@@ -475,51 +519,89 @@ const put = (href,variable) => {
|
|
|
475
519
|
}
|
|
476
520
|
|
|
477
521
|
const handleRemote = async ({variable, functionalType, config=functionalType, component},doput) => {
|
|
478
|
-
const type = typeof (config);
|
|
479
522
|
let value;
|
|
480
|
-
if
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
if(
|
|
486
|
-
|
|
487
|
-
if(!config.path) config.path = `./${variable.name}`;
|
|
488
|
-
if(config.path.endsWith("/")) config.path = `${config.path}${variable.name}`;
|
|
489
|
-
const href = new URL(config.path,window.location.href).href;
|
|
490
|
-
if(!config.get || !config.put) {
|
|
491
|
-
if(!href) throw new Error(`A remote path is required if no put function is provided for remote data`)
|
|
492
|
-
if(!config.get) config.get = get;
|
|
493
|
-
if(!config.put && variable.reactive) config.put = put;
|
|
494
|
-
}
|
|
495
|
-
value = (doput
|
|
496
|
-
? config.put(href,variable)
|
|
497
|
-
: config.get(href,variable));
|
|
498
|
-
if(config.ttl && !doput && !config.intervalId) {
|
|
499
|
-
config.intervalId = setInterval(async () => {
|
|
500
|
-
await handleRemote({variable, config, component});
|
|
501
|
-
//schedule();
|
|
502
|
-
},config.ttl);
|
|
503
|
-
}
|
|
504
|
-
if(variable.value===undefined) variable.value = value;
|
|
523
|
+
if(!config.path) config.path = `./${variable.name}`;
|
|
524
|
+
if(config.path.endsWith("/")) config.path = `${config.path}${variable.name}`;
|
|
525
|
+
const href = new URL(config.path,new URL(config.base.replace("blob:","")).href).href;
|
|
526
|
+
if(!config.get || !config.put) {
|
|
527
|
+
if(!href) throw new Error(`A remote path is required if no put function is provided for remote data`)
|
|
528
|
+
if(!config.get) config.get = get;
|
|
529
|
+
if(!config.put && variable.reactive) config.put = put;
|
|
505
530
|
}
|
|
506
|
-
|
|
507
|
-
|
|
531
|
+
let areequal;
|
|
532
|
+
value = (doput
|
|
533
|
+
? (areequal = deepEqual(variable.value,config.previousValue,deepEqual.COMMUTATIVE)) ? variable.value : config.put(href,variable)
|
|
534
|
+
: config.get(href,variable));
|
|
535
|
+
if(config.ttl && !doput && !config.intervalId) {
|
|
536
|
+
config.intervalId = setInterval(async () => {
|
|
537
|
+
await handleRemote({variable, config, component});
|
|
538
|
+
//schedule();
|
|
539
|
+
},config.ttl);
|
|
540
|
+
}
|
|
541
|
+
if(variable.value===undefined) variable.value = value;
|
|
542
|
+
if(value && !areequal) {
|
|
543
|
+
const json = config.previousValue = await value;
|
|
508
544
|
if (json && typeof (json) === "object" && variable.reactive) {
|
|
509
|
-
|
|
545
|
+
component.setVariableValue(variable.name,remoteProxy({json, variable,config, component}));
|
|
546
|
+
// variable.value = remoteProxy({json, variable,config, component});
|
|
510
547
|
} else {
|
|
511
548
|
component.setVariableValue(variable.name,json);
|
|
512
549
|
}
|
|
513
550
|
}
|
|
514
551
|
}
|
|
515
552
|
|
|
516
|
-
const remote = (config) => {
|
|
553
|
+
const remote = (config,base=document.baseURI||window.location.href) => {
|
|
554
|
+
if(typeof(config)==="string") config = {path:config};
|
|
555
|
+
config.base = base;
|
|
517
556
|
return {
|
|
518
|
-
config,
|
|
557
|
+
config:{...config},
|
|
519
558
|
handleRemote
|
|
520
559
|
}
|
|
521
560
|
}
|
|
522
561
|
|
|
562
|
+
const shared = () => {
|
|
563
|
+
return {
|
|
564
|
+
init({variable, component}) {
|
|
565
|
+
const name = variable.name,
|
|
566
|
+
set = variable.set || (() => {});
|
|
567
|
+
variable.shared = true;
|
|
568
|
+
variable.set = function(newValue) {
|
|
569
|
+
set(newValue);
|
|
570
|
+
if(this.shared) { // still shared
|
|
571
|
+
component.siblings.forEach((instance) => {
|
|
572
|
+
const svariable = instance.vars[name];
|
|
573
|
+
if(svariable?.shared) {
|
|
574
|
+
instance.setVariableValue(name, newValue);
|
|
575
|
+
}
|
|
576
|
+
});
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
// initialize
|
|
580
|
+
component.siblings.forEach((instance) => {
|
|
581
|
+
if(instance===component) return;
|
|
582
|
+
const svariable = instance.vars[name];
|
|
583
|
+
if(svariable?.shared) {
|
|
584
|
+
if(variable.value==null) {
|
|
585
|
+
if(svariable.value!=null) variable.value = instance.vars[name].value
|
|
586
|
+
} else instance.setVariableValue(name, variable.value);
|
|
587
|
+
}
|
|
588
|
+
});
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
const observed = () => {
|
|
594
|
+
return {
|
|
595
|
+
init({variable, component}) {
|
|
596
|
+
if(variable.observed) return;
|
|
597
|
+
const name = variable.name;
|
|
598
|
+
variable.value = component.hasAttribute(name) ? coerce(component.getAttribute(name), variable.type) : variable.value;
|
|
599
|
+
variable.observed = true;
|
|
600
|
+
component.observedAttributes.add(name);
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
|
|
523
605
|
const remoteGenerator = handleRemote;
|
|
524
606
|
|
|
525
|
-
export {ValidityState,any,array,boolean,duration,number,object,remote,remoteGenerator,string,symbol,reviver}
|
|
607
|
+
export {ValidityState,any,array,boolean,duration,number,object,remote,shared,observed,remoteGenerator,string,symbol,reviver,html,css,script}
|
package/unsplash.key
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
nRe-dHABvjv2shxyvDFQd3Y9MPni77qBG9ImAVH0wig
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
<html>
|
|
2
|
-
<head>
|
|
3
|
-
<meta charset="UTF-8">
|
|
4
|
-
<title>Lightview:Chart</title>
|
|
5
|
-
</head>
|
|
6
|
-
<body>
|
|
7
|
-
<div id="target"></div>
|
|
8
|
-
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
|
|
9
|
-
<script src="https://unpkg.com/json5@^2.0.0/dist/index.min.js"></script>
|
|
10
|
-
<script type="lightview/module">
|
|
11
|
-
const {chart} = await import("/components/components.js");
|
|
12
|
-
chart(self);
|
|
13
|
-
</script>
|
|
14
|
-
</body>
|
|
15
|
-
</html>
|
package/components/chart.html
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
<html>
|
|
2
|
-
<head>
|
|
3
|
-
<meta charset="UTF-8">
|
|
4
|
-
<title>Lightview:Chart</title>
|
|
5
|
-
</head>
|
|
6
|
-
<body hidden>
|
|
7
|
-
<div id="target"></div>
|
|
8
|
-
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
|
|
9
|
-
<script src="https://unpkg.com/json5@^2.0.0/dist/index.min.js"></script>
|
|
10
|
-
<script type="lightview/module">
|
|
11
|
-
let table = JSON5.parse(self.firstChild.textContent.trim()),
|
|
12
|
-
chart,
|
|
13
|
-
datatable,
|
|
14
|
-
options = {};
|
|
15
|
-
const target = self.getElementById("target"),
|
|
16
|
-
resizeObserver = new ResizeObserver(entries => {
|
|
17
|
-
for (let entry of entries) {
|
|
18
|
-
if(entry.contentBoxSize) {
|
|
19
|
-
// Firefox implements `contentBoxSize` as a single content rect, rather than an array
|
|
20
|
-
const contentBoxSize = Array.isArray(entry.contentBoxSize) ? entry.contentBoxSize[0] : entry.contentBoxSize;
|
|
21
|
-
options.width = contentBoxSize.inlineSize;
|
|
22
|
-
} else {
|
|
23
|
-
options.width = entry.contentRect.width;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
chart.draw(datatable, options);
|
|
27
|
-
}),
|
|
28
|
-
callback = (textNode, oldValue, newValue) => {
|
|
29
|
-
datatable = new google.visualization.DataTable();
|
|
30
|
-
try {
|
|
31
|
-
table = table || JSON5.parse(newValue.trim());
|
|
32
|
-
datatable = google.visualization.arrayToDataTable(table);
|
|
33
|
-
chart.draw(datatable, options);
|
|
34
|
-
table = null;
|
|
35
|
-
} catch (e) {
|
|
36
|
-
target.innerText = e + newValue;
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
self.firstChild.innerText = "Loading ...";
|
|
40
|
-
self.variables({type: "string", title: "string", style: "string"}, {observed});
|
|
41
|
-
if(style) target.setAttribute("style",style);
|
|
42
|
-
self.addRow = (row) => {
|
|
43
|
-
datatable.addRows([row]);
|
|
44
|
-
chart.draw(datatable, options);
|
|
45
|
-
};
|
|
46
|
-
self.setValue = (row,col,value) => {
|
|
47
|
-
if(datatable) {
|
|
48
|
-
datatable.setValue(row,col,value);
|
|
49
|
-
chart.draw(datatable, options);
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
self.setOptions = (newOptions) => {
|
|
53
|
-
Object.assign(options,newOptions);
|
|
54
|
-
};
|
|
55
|
-
self.init = () => {
|
|
56
|
-
if(!options.title && title) options.title = title;
|
|
57
|
-
chart = new google.visualization[type](target);
|
|
58
|
-
addEventListener("change",({target,value}) => {
|
|
59
|
-
if (target === "type") {
|
|
60
|
-
chart = new google.visualization[type](target);
|
|
61
|
-
} else if (target === "title") {
|
|
62
|
-
options.title = value;
|
|
63
|
-
} else if(target === "style") {
|
|
64
|
-
target.setAttribute("style",value);
|
|
65
|
-
}
|
|
66
|
-
chart.draw(datatable, options);
|
|
67
|
-
});
|
|
68
|
-
const node = self.firstChild;
|
|
69
|
-
callback(node, node.textContent, node.textContent);
|
|
70
|
-
// Will be used by the Lightview global observer
|
|
71
|
-
node.characterDataMutationCallback = callback;
|
|
72
|
-
// resized charts if window resizes
|
|
73
|
-
resizeObserver.observe(target);
|
|
74
|
-
};
|
|
75
|
-
self.addEventListener("connected", ({target}) => {
|
|
76
|
-
google.charts.load("current", {"packages": ["corechart","gauge"]});
|
|
77
|
-
google.charts.setOnLoadCallback(self.init);
|
|
78
|
-
});
|
|
79
|
-
</script>
|
|
80
|
-
</body>
|
|
81
|
-
</html>
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<head>
|
|
3
|
-
<title>Lightview:Chart:Example</title>
|
|
4
|
-
<link href="./gantt.html" rel="module">
|
|
5
|
-
<script src="../../lightview.js"></script>
|
|
6
|
-
</head>
|
|
7
|
-
<body>
|
|
8
|
-
<l-gantt id="myChart" style="height:500px;" title="Research Project">
|
|
9
|
-
{
|
|
10
|
-
options: { },
|
|
11
|
-
rows: [
|
|
12
|
-
['Research', 'Find sources',"2015-01-01", "2015-01-05", null, 100, null],
|
|
13
|
-
['Write', 'Write paper',null,"2015-01-09", "3d", 25, 'Research,Outline'],
|
|
14
|
-
['Cite', 'Create bibliography',null, "2015-01-07","1d" , 20, 'Research'],
|
|
15
|
-
['Complete', 'Hand in paper', null, "2015-01-10", "1d" , 0, 'Cite,Write'],
|
|
16
|
-
['Outline', 'Outline paper', null, "2015-01-06", "1d" , 100, 'Research']
|
|
17
|
-
]
|
|
18
|
-
}
|
|
19
|
-
</l-gantt>
|
|
20
|
-
<script>
|
|
21
|
-
const el = document.getElementById("myChart");
|
|
22
|
-
el.addEventListener("mounted",() => {
|
|
23
|
-
chart = el.chart;
|
|
24
|
-
});
|
|
25
|
-
</script>
|
|
26
|
-
</body>
|
|
27
|
-
</html>
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
<html>
|
|
2
|
-
<head>
|
|
3
|
-
<title>Lightview:Gantt</title>
|
|
4
|
-
</head>
|
|
5
|
-
<body>
|
|
6
|
-
<div id="target"></div>
|
|
7
|
-
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
|
|
8
|
-
<script src="https://unpkg.com/json5@^2.0.0/dist/index.min.js"></script>
|
|
9
|
-
<script type="lightview/module">
|
|
10
|
-
const {chart} = await import("/components/components.js"),
|
|
11
|
-
{duration} = await import("/types.js");
|
|
12
|
-
chart(self,{
|
|
13
|
-
packages:["gantt"],
|
|
14
|
-
columns:[
|
|
15
|
-
{label:"Task ID",type:"string"},
|
|
16
|
-
{label:"Task Name",type:"string"},
|
|
17
|
-
{label:"Start Date",type:"date"},
|
|
18
|
-
{label:"End Date",type:"date"},
|
|
19
|
-
{label:"Duration",type:"number"},
|
|
20
|
-
{label:"% Complete",type:"number"},
|
|
21
|
-
{label:"Dependencies",type:"string"}
|
|
22
|
-
],
|
|
23
|
-
type:"Gantt",
|
|
24
|
-
rowTransform(row) {
|
|
25
|
-
return row.map((item,index) => {
|
|
26
|
-
if(item && (index===2 || index===3)) return new Date(item);
|
|
27
|
-
if(item && index===4) return duration.parse(item);
|
|
28
|
-
return item;
|
|
29
|
-
})
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
</script>
|
|
33
|
-
</body>
|
|
34
|
-
</html>
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<head>
|
|
3
|
-
<title>Lightview:Gauge:Example</title>
|
|
4
|
-
<link href="./gauge.html" rel="module">
|
|
5
|
-
<script src="../../lightview.js"></script>
|
|
6
|
-
</head>
|
|
7
|
-
<body>
|
|
8
|
-
<l-gauge id="myChart" style="height:500px;" title="Server" hidden l-unhide>
|
|
9
|
-
{
|
|
10
|
-
options: {
|
|
11
|
-
|
|
12
|
-
},
|
|
13
|
-
rows: [
|
|
14
|
-
['Memory', 80],
|
|
15
|
-
['CPU', 55],
|
|
16
|
-
['Network', 68]
|
|
17
|
-
]
|
|
18
|
-
}
|
|
19
|
-
</l-gauge>
|
|
20
|
-
<script>
|
|
21
|
-
const el = document.getElementById("myChart");
|
|
22
|
-
el.addEventListener("mounted",() => {
|
|
23
|
-
chart = el.chart;
|
|
24
|
-
chart.addRow(["Storage",10]);
|
|
25
|
-
});
|
|
26
|
-
</script>
|
|
27
|
-
</body>
|
|
28
|
-
</html>
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
<html>
|
|
2
|
-
<head>
|
|
3
|
-
<meta charset="UTF-8">
|
|
4
|
-
<title>Lightview:Gauge</title>
|
|
5
|
-
</head>
|
|
6
|
-
<body>
|
|
7
|
-
<div id="target"></div>
|
|
8
|
-
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
|
|
9
|
-
<script src="https://unpkg.com/json5@^2.0.0/dist/index.min.js"></script>
|
|
10
|
-
<script type="lightview/module">
|
|
11
|
-
const {chart} = await import("/components/components.js");
|
|
12
|
-
chart(self,{
|
|
13
|
-
packages:["corechart","gauge"],
|
|
14
|
-
columns:[{label:"Label",type:"string"},{label:"Value",type:"number"}],
|
|
15
|
-
type:"Gauge"
|
|
16
|
-
});
|
|
17
|
-
</script>
|
|
18
|
-
</body>
|
|
19
|
-
</html>
|
package/components/gauge.html
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
<html>
|
|
2
|
-
<head>
|
|
3
|
-
<meta charset="UTF-8">
|
|
4
|
-
<title>Lightview:Gauge</title>
|
|
5
|
-
</head>
|
|
6
|
-
<body hidden>
|
|
7
|
-
<div id="target"></div>
|
|
8
|
-
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
|
|
9
|
-
<script type="lightview/module">
|
|
10
|
-
const target = self.getElementById("target"),
|
|
11
|
-
resizeObserver = new ResizeObserver(entries => {
|
|
12
|
-
for (let entry of entries) {
|
|
13
|
-
if(entry.contentBoxSize) {
|
|
14
|
-
// Firefox implements `contentBoxSize` as a single content rect, rather than an array
|
|
15
|
-
const contentBoxSize = Array.isArray(entry.contentBoxSize) ? entry.contentBoxSize[0] : entry.contentBoxSize;
|
|
16
|
-
options.width = contentBoxSize.inlineSize;
|
|
17
|
-
} else {
|
|
18
|
-
options.width = entry.contentRect.width;
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
chart.draw(datatable, options);
|
|
22
|
-
});
|
|
23
|
-
let chart,
|
|
24
|
-
datatable,
|
|
25
|
-
options;
|
|
26
|
-
self.variables({label: "string", value:"number", style: "string"}, {observed});
|
|
27
|
-
if(style) target.setAttribute("style",style);
|
|
28
|
-
self.setValue = (newValue) => {
|
|
29
|
-
if(datatable) {
|
|
30
|
-
datatable.setValue(0,1,newValue);
|
|
31
|
-
chart.draw(datatable, options);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
self.init = () => {
|
|
35
|
-
options = { };
|
|
36
|
-
chart = new google.visualization.Gauge(target);
|
|
37
|
-
datatable = google.visualization.arrayToDataTable([["Label","Value"],[label,value]]);
|
|
38
|
-
addEventListener("change",({target,value}) => {
|
|
39
|
-
if (target === "label") {
|
|
40
|
-
datatable.setValue(0,0,value);
|
|
41
|
-
} else if(target ==="value") {
|
|
42
|
-
self.setValue(value);
|
|
43
|
-
} else if(target === "style") {
|
|
44
|
-
target.setAttribute("style",value);
|
|
45
|
-
}
|
|
46
|
-
chart.draw(datatable, options);
|
|
47
|
-
});
|
|
48
|
-
resizeObserver.observe(target);
|
|
49
|
-
self.removeAttribute("hidden");
|
|
50
|
-
};
|
|
51
|
-
self.addEventListener("connected", ({target}) => {
|
|
52
|
-
google.charts.load("current", {"packages": ["corechart","gauge"]});
|
|
53
|
-
google.charts.setOnLoadCallback(self.init);
|
|
54
|
-
});
|
|
55
|
-
</script>
|
|
56
|
-
</body>
|
|
57
|
-
</html>
|
package/components/timeline.html
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
<html>
|
|
2
|
-
<head>
|
|
3
|
-
<meta charset="UTF-8">
|
|
4
|
-
<title>Lightview:Timeline</title>
|
|
5
|
-
</head>
|
|
6
|
-
<body hidden>
|
|
7
|
-
<div id="target"></div>
|
|
8
|
-
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
|
|
9
|
-
<script src="https://unpkg.com/json5@^2.0.0/dist/index.min.js"></script>
|
|
10
|
-
<script type="lightview/module">
|
|
11
|
-
debugger;
|
|
12
|
-
let table = JSON5.parse(self.firstChild.textContent.trim()),
|
|
13
|
-
chart,
|
|
14
|
-
datatable,
|
|
15
|
-
options = {};
|
|
16
|
-
const target = self.getElementById("target"),
|
|
17
|
-
resizeObserver = new ResizeObserver(entries => {
|
|
18
|
-
for (let entry of entries) {
|
|
19
|
-
if(entry.contentBoxSize) {
|
|
20
|
-
// Firefox implements `contentBoxSize` as a single content rect, rather than an array
|
|
21
|
-
const contentBoxSize = Array.isArray(entry.contentBoxSize) ? entry.contentBoxSize[0] : entry.contentBoxSize;
|
|
22
|
-
options.width = contentBoxSize.inlineSize;
|
|
23
|
-
} else {
|
|
24
|
-
options.width = entry.contentRect.width;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
chart.draw(datatable, options);
|
|
28
|
-
}),
|
|
29
|
-
callback = (textNode, oldValue, newValue) => {
|
|
30
|
-
datatable = new google.visualization.DataTable();
|
|
31
|
-
try {
|
|
32
|
-
table = table || JSON5.parse(newValue.trim());
|
|
33
|
-
datatable = google.visualization.arrayToDataTable(table);
|
|
34
|
-
chart.draw(datatable, options);
|
|
35
|
-
table = null;
|
|
36
|
-
} catch (e) {
|
|
37
|
-
target.innerText = e + newValue;
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
self.firstChild.innerText = "Loading ...";
|
|
41
|
-
self.variables({type: "string", title: "string", style: "string"}, {observed});
|
|
42
|
-
if(style) target.setAttribute("style",style);
|
|
43
|
-
self.addRow = (row) => {
|
|
44
|
-
datatable.addRows([row]);
|
|
45
|
-
chart.draw(datatable, options);
|
|
46
|
-
};
|
|
47
|
-
self.setValue = (row,col,value) => {
|
|
48
|
-
if(datatable) {
|
|
49
|
-
datatable.setValue(row,col,value);
|
|
50
|
-
chart.draw(datatable, options);
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
self.setOptions = (newOptions) => {
|
|
54
|
-
Object.assign(options,newOptions);
|
|
55
|
-
};
|
|
56
|
-
self.init = () => {
|
|
57
|
-
if(!options.title && title) options.title = title;
|
|
58
|
-
chart = new google.visualization.Timeline(target);
|
|
59
|
-
addEventListener("change",({target,value}) => {
|
|
60
|
-
if(target === "title") {
|
|
61
|
-
options.title = value;
|
|
62
|
-
} else if(target === "style") {
|
|
63
|
-
target.setAttribute("style",value);
|
|
64
|
-
}
|
|
65
|
-
chart.draw(datatable, options);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
const node = self.firstChild;
|
|
69
|
-
callback(node, node.textContent, node.textContent);
|
|
70
|
-
// Will be used by the Lightview global observer
|
|
71
|
-
node.characterDataMutationCallback = callback;
|
|
72
|
-
// resized charts if window resizes
|
|
73
|
-
resizeObserver.observe(target);
|
|
74
|
-
};
|
|
75
|
-
self.addEventListener("connected", ({target}) => {
|
|
76
|
-
google.charts.load("current", {"packages": ["timeline"]});
|
|
77
|
-
google.charts.setOnLoadCallback(self.init);
|
|
78
|
-
});
|
|
79
|
-
</script>
|
|
80
|
-
</body>
|
|
81
|
-
</html>
|
package/examples/chart.html
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<head>
|
|
3
|
-
<title>Chart</title>
|
|
4
|
-
<link href="../components/chart.html" rel="module">
|
|
5
|
-
<script src="../lightview.js"></script>
|
|
6
|
-
</head>
|
|
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]
|
|
19
|
-
]
|
|
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
|
|
50
|
-
</l-chart>
|
|
51
|
-
<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
|
-
})
|
|
64
|
-
</script>
|
|
65
|
-
</body>
|
|
66
|
-
</html>
|
package/examples/counter.html
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
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 type="lightview/module">
|
|
12
|
-
self.variables({count: "number",}, {reactive,set:0});
|
|
13
|
-
self.bump = () => count++;
|
|
14
|
-
</script>
|
|
15
|
-
|
|
16
|
-
<style>
|
|
17
|
-
button {
|
|
18
|
-
margin: 20px;
|
|
19
|
-
background: gray
|
|
20
|
-
}
|
|
21
|
-
</style>
|
|
22
|
-
</body>
|
|
23
|
-
|
|
24
|
-
</html>
|