@xiee/utils 1.14.36 → 1.14.38
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/css/lt.css +45 -0
- package/css/lt.min.css +2 -0
- package/css/lt.min.css.map +1 -0
- package/css/pages.css +0 -3
- package/css/pages.min.css +1 -1
- package/css/pages.min.css.map +1 -1
- package/js/lt.js +152 -0
- package/js/lt.min.js +2 -0
- package/js/lt.min.js.map +1 -0
- package/package.json +1 -1
package/css/lt.css
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
.lt-table {
|
|
2
|
+
border-collapse: collapse;
|
|
3
|
+
border-top: 1px solid;
|
|
4
|
+
border-bottom: 1px solid;
|
|
5
|
+
|
|
6
|
+
caption {
|
|
7
|
+
.lt-title { font-size: 1.2em; font-weight: 600; }
|
|
8
|
+
.lt-subtitle { font-size: 0.9em; }
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
thead th { border-bottom: 1px solid #888; }
|
|
12
|
+
thead .lt-spanner-row {
|
|
13
|
+
.lt-spanner { border-bottom: 1px solid #bbb; text-align: center; }
|
|
14
|
+
.lt-spanner-empty { border-bottom: none; }
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
tbody {
|
|
18
|
+
th.lt-stub { text-align: left; }
|
|
19
|
+
.lt-row-group th {
|
|
20
|
+
text-align: left;
|
|
21
|
+
font-weight: 600;
|
|
22
|
+
font-style: italic;
|
|
23
|
+
border-top: 1px solid #ccc;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
tfoot.lt-footer {
|
|
28
|
+
td {
|
|
29
|
+
font-size: 0.85em;
|
|
30
|
+
border-top: 1px solid #aaa;
|
|
31
|
+
}
|
|
32
|
+
.lt-footnote td { border-top: none; }
|
|
33
|
+
.lt-footnote:first-child td { border-top: 1px solid #aaa; }
|
|
34
|
+
.lt-source-note td { border-top: 1px dashed #bbb; font-style: italic; }
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.al-r { text-align: right; }
|
|
38
|
+
.al-c { text-align: center; }
|
|
39
|
+
|
|
40
|
+
sup.lt-fnref {
|
|
41
|
+
color: #06c;
|
|
42
|
+
&::before { content: " ["; }
|
|
43
|
+
&::after { content: "]"; }
|
|
44
|
+
}
|
|
45
|
+
}
|
package/css/lt.min.css
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
.lt-table{border-collapse:collapse;border-top:1px solid;border-bottom:1px solid;& caption{& .lt-title{font-size:1.2em;font-weight:600}& .lt-subtitle{font-size:.9em}}& thead th{border-bottom:1px solid #888}& thead .lt-spanner-row{& .lt-spanner{text-align:center;border-bottom:1px solid #bbb}& .lt-spanner-empty{border-bottom:none}}& tbody{& th.lt-stub{text-align:left}& .lt-row-group th{text-align:left;border-top:1px solid #ccc;font-style:italic;font-weight:600}}& tfoot.lt-footer{& td{border-top:1px solid #aaa;font-size:.85em}& .lt-footnote td{border-top:none}& .lt-footnote:first-child td{border-top:1px solid #aaa}& .lt-source-note td{border-top:1px dashed #bbb;font-style:italic}}& .al-r{text-align:right}& .al-c{text-align:center}& sup.lt-fnref{color:#06c;&:before{content:" ["}&:after{content:"]"}}}
|
|
2
|
+
/*# sourceMappingURL=lt.min.css.map */
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"mappings":"AAAA,gFAKE,UACE,4CACA,+BAGF,wCACA,wBACE,6DACA,wCAGF,QACE,6BACA,gGAQF,kBACE,+CAIA,kCACA,wDACA,mEAGF,yBACA,0BAEA,0BAEE,sBACA","sources":["lt.css"],"sourcesContent":[".lt-table {\n border-collapse: collapse;\n border-top: 1px solid;\n border-bottom: 1px solid;\n\n caption {\n .lt-title { font-size: 1.2em; font-weight: 600; }\n .lt-subtitle { font-size: 0.9em; }\n }\n\n thead th { border-bottom: 1px solid #888; }\n thead .lt-spanner-row {\n .lt-spanner { border-bottom: 1px solid #bbb; text-align: center; }\n .lt-spanner-empty { border-bottom: none; }\n }\n\n tbody {\n th.lt-stub { text-align: left; }\n .lt-row-group th {\n text-align: left;\n font-weight: 600;\n font-style: italic;\n border-top: 1px solid #ccc;\n }\n }\n\n tfoot.lt-footer {\n td {\n font-size: 0.85em;\n border-top: 1px solid #aaa;\n }\n .lt-footnote td { border-top: none; }\n .lt-footnote:first-child td { border-top: 1px solid #aaa; }\n .lt-source-note td { border-top: 1px dashed #bbb; font-style: italic; }\n }\n\n .al-r { text-align: right; }\n .al-c { text-align: center; }\n\n sup.lt-fnref {\n color: #06c;\n &::before { content: \" [\"; }\n &::after { content: \"]\"; }\n }\n}\n"],"names":[]}
|
package/css/pages.css
CHANGED
package/css/pages.min.css
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
:root{--paper-width:210mm;--paper-height:297mm;--paper-margin-top:40px;--paper-margin-right:80px;--paper-margin-bottom:40px;--paper-margin-left:80px;--page-header-height:40px;--page-header-bottom:40px;--page-footer-height:40px;--page-footer-top:40px}@page{size:var(--paper-width) var(--paper-height);margin:0}@page multiple{margin-top:var(--paper-margin-top);margin-bottom:var(--paper-margin-bottom)}.page-multiple{page:multiple}.pagesjs{flex-wrap:wrap;justify-content:center;gap:5mm;max-width:100%;margin:5mm;padding:0;display:flex;& .frontmatter,& .chapter{min-height:unset;box-shadow:none}&>*,&:not(:has(.frontmatter)):has(.chapter-toc) #TOC:not(.chapter-toc){display:none}& .pagesjs-page{width:var(--paper-width);height:var(--paper-height);padding:var(--paper-margin-top) var(--paper-margin-right) var(--paper-margin-bottom) var(--paper-margin-left);break-after:page;flex-direction:column;justify-content:space-between;display:flex;overflow:hidden;& img{max-width:100%}& .chapter-before,& .chapter-after,& .buttons:has(+.chapter-before){display:none}& #TOC{border:none;margin-left:auto;padding:0;&:not(.chapter-toc):is(.fragment-first,:not(.pagesjs-fragmented)):before{content:"Contents";margin-bottom:1em;font-size:1.5em;font-weight:700;display:block}
|
|
1
|
+
:root{--paper-width:210mm;--paper-height:297mm;--paper-margin-top:40px;--paper-margin-right:80px;--paper-margin-bottom:40px;--paper-margin-left:80px;--page-header-height:40px;--page-header-bottom:40px;--page-footer-height:40px;--page-footer-top:40px}@page{size:var(--paper-width) var(--paper-height);margin:0}@page multiple{margin-top:var(--paper-margin-top);margin-bottom:var(--paper-margin-bottom)}.page-multiple{page:multiple}.pagesjs{flex-wrap:wrap;justify-content:center;gap:5mm;max-width:100%;margin:5mm;padding:0;display:flex;& .frontmatter,& .chapter{min-height:unset;box-shadow:none}&>*,&:not(:has(.frontmatter)):has(.chapter-toc) #TOC:not(.chapter-toc){display:none}& .pagesjs-page{width:var(--paper-width);height:var(--paper-height);padding:var(--paper-margin-top) var(--paper-margin-right) var(--paper-margin-bottom) var(--paper-margin-left);break-after:page;flex-direction:column;justify-content:space-between;display:flex;overflow:hidden;& img{max-width:100%}& .chapter-before,& .chapter-after,& .buttons:has(+.chapter-before){display:none}& #TOC{border:none;margin-left:auto;padding:0;&:not(.chapter-toc):is(.fragment-first,:not(.pagesjs-fragmented)):before{content:"Contents";margin-bottom:1em;font-size:1.5em;font-weight:700;display:block}& a{display:flex;&:after{content:attr(data-page-number);align-self:end;margin-left:1ch}& .section-number{margin-right:.3em}& .toc-text{flex:1 0;position:relative;overflow:hidden;&:after{content:"";border-bottom:1px dashed;width:100%;margin-left:1ch;position:absolute;bottom:1.5ex}}}}&>.pagesjs-body>.pagesjs-fragmented{&:not(.fragment-first){&,& .pagesjs-fragmented{border-top:none;&>thead{opacity:.5}}}&:not(.fragment-last){&,& .pagesjs-fragmented{border-bottom:none;&>tfoot{opacity:.5}}}}& .fullwidth{float:none;max-width:none;width:var(--paper-width);margin-left:calc(0px - var(--paper-margin-left));transform:none}& .footnotes:before{content:"";border-top:1px solid;max-width:20em;display:block}&:has(.side-left,.embed-left) .pagesjs-body{padding-left:calc(0px - var(--side-margin));& .fullwidth{transform:translate(var(--side-margin))}}&:has(.side-right,.embed-right) .pagesjs-body{padding-right:calc(0px - var(--side-margin))}& .side{background:0 0;font-size:.9em}}}.pagesjs-header,.pagesjs-footer{justify-content:space-between;font-size:.9em;display:flex}.pagesjs-header{flex:0 0 var(--page-header-height);margin-bottom:var(--page-header-bottom);align-items:end;&:before{content:attr(data-main-title)}&:after{content:attr(data-page-title)}}.pagesjs-footer{flex:0 0 var(--page-footer-height);margin-top:var(--page-footer-top);align-items:start;&:before{content:" "}&:after{content:attr(data-page-number)}}.pagesjs-body{flex-grow:1;position:relative}@media only screen{.pagesjs{&:has(.pagesjs-page){background:#f7f7f7}& .pagesjs-page{background:#fff}& .page-multiple{overflow-y:auto}}.pagesjs-filling{display:block;& .pagesjs-page{height:auto;& .pagesjs-body:has(.footnotes){margin-bottom:1em;& .footnotes{float:left;width:100%}}}}}@media print{.pagesjs{gap:0;margin:0;& .page-multiple{height:auto;padding-top:0;padding-bottom:0}}}
|
|
2
2
|
/*# sourceMappingURL=pages.min.css.map */
|
package/css/pages.min.css.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"mappings":"AAAA,0PAYA,2DAIA,2FAIA,6BAGA,wGAQE,2DAIA,oFAGA,oRASE,qBAGA,iFAGA,8CAIE,4JAOA,
|
|
1
|
+
{"version":3,"mappings":"AAAA,0PAYA,2DAIA,2FAIA,6BAGA,wGAQE,2DAIA,oFAGA,oRASE,qBAGA,iFAGA,8CAIE,4JAOA,iBAEE,sEAKA,oCAGA,uDAIE,yGAWN,oCACE,uBACE,wCAEE,qBAGJ,sBACE,2CAEE,sBAIN,gIAOA,iFAMA,wFAEE,sDAIF,2FAGA,wCAMJ,0FAKA,2GAIE,uCAGA,uCAIF,uGAIE,qBAGA,wCAIF,4CAIA,mBACE,SACE,wCAGA,gCAGA,kCAIF,+BAEE,4BAEE,kDAEE,uCAQR,aACE,wBAGE","sources":["pages.css"],"sourcesContent":[":root {\n --paper-width: 210mm;\n --paper-height: 297mm;\n --paper-margin-top: 40px;\n --paper-margin-right: 80px;\n --paper-margin-bottom: 40px;\n --paper-margin-left: 80px;\n --page-header-height: 40px;\n --page-header-bottom: 40px;\n --page-footer-height: 40px;\n --page-footer-top: 40px;\n}\n@page {\n size: var(--paper-width) var(--paper-height);\n margin: 0;\n}\n@page multiple {\n margin-top: var(--paper-margin-top);\n margin-bottom: var(--paper-margin-bottom);\n}\n.page-multiple {\n page: multiple;\n}\n.pagesjs {\n padding: 0;\n max-width: 100%;\n margin: 5mm;\n display: flex;\n justify-content: center;\n flex-wrap: wrap;\n gap: 5mm;\n .frontmatter, .chapter {\n min-height: unset;\n box-shadow: none;\n }\n & > *, &:not(:has(.frontmatter)):has(.chapter-toc) #TOC:not(.chapter-toc) {\n display: none;\n }\n .pagesjs-page {\n width: var(--paper-width);\n height: var(--paper-height);\n padding: var(--paper-margin-top) var(--paper-margin-right) var(--paper-margin-bottom) var(--paper-margin-left);\n break-after: page;\n display: flex;\n flex-direction: column;\n justify-content: space-between;\n overflow: hidden;\n img {\n max-width: 100%;\n }\n .chapter-before, .chapter-after, .buttons:has(+ .chapter-before) {\n display: none;\n }\n #TOC {\n border: none;\n padding: 0;\n margin-left: auto;\n &:not(.chapter-toc):is(.fragment-first, :not(.pagesjs-fragmented))::before {\n content: \"Contents\";\n display: block;\n font-weight: bold;\n font-size: 1.5em;\n margin-bottom: 1em;\n }\n a {\n display: flex;\n &::after {\n content: attr(data-page-number);\n align-self: end;\n margin-left: 1ch;\n }\n .section-number {\n margin-right: .3em;\n }\n .toc-text {\n position: relative;\n flex: 1 0;\n overflow: hidden;\n &::after {\n content: \"\";\n width: 100%;\n position: absolute;\n bottom: 1.5ex;\n margin-left: 1ch;\n border-bottom: dashed 1px;\n }\n }\n }\n }\n & > .pagesjs-body > .pagesjs-fragmented {\n &:not(.fragment-first) {\n &, & .pagesjs-fragmented {\n border-top: none;\n & > thead { opacity: .5; }\n }\n }\n &:not(.fragment-last) {\n &, & .pagesjs-fragmented {\n border-bottom: none;\n & > tfoot { opacity: .5; }\n }\n }\n }\n .fullwidth {\n float: none;\n max-width: none;\n width: var(--paper-width);\n margin-left: calc(0px - var(--paper-margin-left));\n transform: none;\n }\n .footnotes::before {\n content: \"\";\n display: block;\n max-width: 20em;\n border-top: solid 1px;\n }\n &:has(.side-left, .embed-left) .pagesjs-body {\n padding-left: calc(0px - var(--side-margin));\n .fullwidth {\n transform: translate(var(--side-margin));\n }\n }\n &:has(.side-right, .embed-right) .pagesjs-body {\n padding-right: calc(0px - var(--side-margin));\n }\n .side {\n font-size: .9em;\n background: none;\n }\n }\n}\n.pagesjs-header, .pagesjs-footer {\n font-size: .9em;\n display: flex;\n justify-content: space-between;\n}\n.pagesjs-header {\n flex: 0 0 var(--page-header-height);\n margin-bottom: var(--page-header-bottom);\n align-items: end;\n &::before {\n content: attr(data-main-title);\n }\n &::after {\n content: attr(data-page-title);\n }\n}\n.pagesjs-footer {\n flex: 0 0 var(--page-footer-height);\n margin-top: var(--page-footer-top);\n align-items: start;\n &::before {\n content: \" \";\n }\n &::after {\n content: attr(data-page-number);\n }\n}\n.pagesjs-body {\n flex-grow: 1;\n position: relative;\n}\n@media only screen {\n .pagesjs {\n &:has(.pagesjs-page) {\n background: #f7f7f7;\n }\n .pagesjs-page {\n background: white;\n }\n .page-multiple {\n overflow-y: auto;\n }\n }\n .pagesjs-filling {\n display: block;\n .pagesjs-page {\n height: auto;\n .pagesjs-body:has(.footnotes) {\n margin-bottom: 1em;\n .footnotes {\n float: left;\n width: 100%;\n }\n }\n }\n }\n}\n@media print {\n .pagesjs {\n margin: 0;\n gap: 0;\n .page-multiple {\n padding-top: 0;\n padding-bottom: 0;\n height: auto;\n }\n }\n}\n"],"names":[]}
|
package/js/lt.js
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/* lt.js — build a semantic <table> from a JSON spec.
|
|
2
|
+
* Call LT.build(spec) from an inline <script> to render a table in place.
|
|
3
|
+
* One runtime per page renders any number of tables.
|
|
4
|
+
*/
|
|
5
|
+
(root => {
|
|
6
|
+
"use strict";
|
|
7
|
+
if (root.LT && root.LT.buildHtml) return; // duplicate inclusion is a no-op
|
|
8
|
+
|
|
9
|
+
// `[<]` (not `<`) avoids `</…` so this file is safe to inline in <script>.
|
|
10
|
+
const esc = s => String(s)
|
|
11
|
+
.replace(/&/g, "&").replace(/[<]/g, "<")
|
|
12
|
+
.replace(/>/g, ">").replace(/"/g, """);
|
|
13
|
+
const sup = i => `<sup class="lt-fnref">${i}</sup>`;
|
|
14
|
+
|
|
15
|
+
// Footnotes: dedup by text, assign 1..N in first-seen order.
|
|
16
|
+
function indexFootnotes(fns) {
|
|
17
|
+
const order = [], idx = {};
|
|
18
|
+
fns.forEach(f => {
|
|
19
|
+
if (idx[f.text] == null) { idx[f.text] = order.length + 1; order.push(f.text); }
|
|
20
|
+
});
|
|
21
|
+
return { order, idx };
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// matcher(fns, idx)(type, p) → 1-based footnote index whose location
|
|
25
|
+
// matches, or 0. Encapsulates all "what footnote applies here?" logic.
|
|
26
|
+
const matcher = (fns, idx) => (type, p) => {
|
|
27
|
+
for (const f of fns) {
|
|
28
|
+
const loc = f.location;
|
|
29
|
+
if (loc.type !== type) continue;
|
|
30
|
+
const hit = idx[f.text];
|
|
31
|
+
if (type === "title" && loc.group === p.group) return hit;
|
|
32
|
+
if (type === "column_labels" &&
|
|
33
|
+
p.columns.every(c => loc.columns.indexOf(c) >= 0)) return hit;
|
|
34
|
+
if (type === "column_spanners" &&
|
|
35
|
+
p.spanners.every(s => loc.spanners.indexOf(s) >= 0)) return hit;
|
|
36
|
+
if (type === "row_groups") {
|
|
37
|
+
if (loc.match === "all") return hit;
|
|
38
|
+
if (loc.match === "exact" && loc.values.indexOf(p.label) >= 0) return hit;
|
|
39
|
+
if (loc.match === "starts_with" && p.label.indexOf(loc.value) === 0) return hit;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
return 0;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
function buildHtml(spec) {
|
|
46
|
+
const cols = spec.columns || [],
|
|
47
|
+
align = spec.align || [],
|
|
48
|
+
rows = spec.rows || [],
|
|
49
|
+
stub = spec.stub,
|
|
50
|
+
spanners = spec.spanners || [],
|
|
51
|
+
groups = spec.row_groups || [],
|
|
52
|
+
fns = spec.footnotes || [],
|
|
53
|
+
notes = spec.notes || [],
|
|
54
|
+
hdr = spec.header || {},
|
|
55
|
+
reg = indexFootnotes(fns),
|
|
56
|
+
fIdx = matcher(fns, reg.idx),
|
|
57
|
+
stubLabel = spec.stub_label || "",
|
|
58
|
+
nCol = cols.length + (stub ? 1 : 0),
|
|
59
|
+
out = [`<table class="lt-table">`];
|
|
60
|
+
const alCls = i => { const a = align[i]; return a === "right" ? " class=\"al-r\"" : a === "center" ? " class=\"al-c\"" : ""; };
|
|
61
|
+
const mark = (type, p) => { const i = fIdx(type, p); return i ? sup(i) : ""; };
|
|
62
|
+
|
|
63
|
+
// <caption>
|
|
64
|
+
const hasT = hdr.title != null && hdr.title !== "",
|
|
65
|
+
hasS = hdr.subtitle != null && hdr.subtitle !== "";
|
|
66
|
+
if (hasT || hasS) {
|
|
67
|
+
out.push(`<caption class="lt-caption">`);
|
|
68
|
+
if (hasT) out.push(`<div class="lt-title">${esc(hdr.title)}${mark("title", { group: "title" })}</div>`);
|
|
69
|
+
if (hasS) out.push(`<div class="lt-subtitle">${esc(hdr.subtitle)}${mark("title", { group: "subtitle" })}</div>`);
|
|
70
|
+
out.push(`</caption>`);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// <thead>: optional spanner row + column-label row.
|
|
74
|
+
out.push(`<thead>`);
|
|
75
|
+
if (spanners.length) {
|
|
76
|
+
out.push(`<tr class="lt-spanner-row">${stub ? `<th class="lt-spanner-empty"></th>` : ""}`);
|
|
77
|
+
for (let k = 0; k < cols.length;) {
|
|
78
|
+
const sp = spanners.find(s => s.columns[0] === cols[k]);
|
|
79
|
+
if (sp) {
|
|
80
|
+
out.push(`<th colspan="${sp.columns.length}" scope="colgroup" class="lt-spanner">${esc(sp.label)}${mark("column_spanners", { spanners: [sp.label] })}</th>`);
|
|
81
|
+
k += sp.columns.length;
|
|
82
|
+
} else {
|
|
83
|
+
out.push(`<th class="lt-spanner-empty"></th>`);
|
|
84
|
+
k++;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
out.push(`</tr>`);
|
|
88
|
+
}
|
|
89
|
+
out.push(`<tr>${stub ? `<th scope="col">${esc(stubLabel)}</th>` : ""}`);
|
|
90
|
+
for (let i = 0; i < cols.length; i++)
|
|
91
|
+
out.push(`<th scope="col"${alCls(i)}>${esc(cols[i])}${mark("column_labels", { columns: [cols[i]] })}</th>`);
|
|
92
|
+
out.push(`</tr></thead>`);
|
|
93
|
+
|
|
94
|
+
// body-footnote markers per (row,col), 1-based row.
|
|
95
|
+
const bodyMarks = {};
|
|
96
|
+
for (const f of fns) {
|
|
97
|
+
if (f.location.type !== "body") continue;
|
|
98
|
+
const fi = reg.idx[f.text],
|
|
99
|
+
fcols = f.location.columns || [],
|
|
100
|
+
frows = f.location.rows; // absent = all
|
|
101
|
+
for (let r = 1; r <= rows.length; r++) {
|
|
102
|
+
if (frows && frows.indexOf(r) < 0) continue;
|
|
103
|
+
for (const c of fcols) {
|
|
104
|
+
const ci = cols.indexOf(c);
|
|
105
|
+
if (ci >= 0) bodyMarks[`${r},${ci}`] = fi;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const pushRow = r => {
|
|
111
|
+
out.push(`<tr>`);
|
|
112
|
+
if (stub) out.push(`<th scope="row" class="lt-stub">${esc(stub[r - 1])}</th>`);
|
|
113
|
+
for (let ci = 0; ci < cols.length; ci++) {
|
|
114
|
+
const m = bodyMarks[`${r},${ci}`];
|
|
115
|
+
out.push(`<td${alCls(ci)}>${esc(rows[r - 1][ci])}${m ? sup(m) : ""}</td>`);
|
|
116
|
+
}
|
|
117
|
+
out.push(`</tr>`);
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
// <tbody>
|
|
121
|
+
out.push(`<tbody>`);
|
|
122
|
+
if (groups.length) {
|
|
123
|
+
const seen = {};
|
|
124
|
+
for (const g of groups) {
|
|
125
|
+
out.push(`<tr class="lt-row-group"><th colspan="${nCol}" scope="colgroup">${esc(g.label)}${mark("row_groups", { label: g.label })}</th></tr>`);
|
|
126
|
+
for (const r of g.rows) { seen[r] = 1; pushRow(r); }
|
|
127
|
+
}
|
|
128
|
+
for (let r = 1; r <= rows.length; r++) if (!seen[r]) pushRow(r);
|
|
129
|
+
} else {
|
|
130
|
+
for (let r = 1; r <= rows.length; r++) pushRow(r);
|
|
131
|
+
}
|
|
132
|
+
out.push(`</tbody>`);
|
|
133
|
+
|
|
134
|
+
// <tfoot>
|
|
135
|
+
if (reg.order.length || notes.length) {
|
|
136
|
+
out.push(`<tfoot class="lt-footer">`);
|
|
137
|
+
reg.order.forEach((txt, i) => out.push(
|
|
138
|
+
`<tr class="lt-footnote"><td colspan="${nCol}">${sup(i + 1)} ${esc(txt)}</td></tr>`));
|
|
139
|
+
for (const n of notes)
|
|
140
|
+
out.push(`<tr class="lt-source-note"><td colspan="${nCol}">${esc(n)}</td></tr>`);
|
|
141
|
+
out.push(`</tfoot>`);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
out.push(`</table>`);
|
|
145
|
+
return out.join("");
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const mount = (s, spec) => s.insertAdjacentHTML("afterend", buildHtml(spec));
|
|
149
|
+
|
|
150
|
+
(root.LT && root.LT.q || []).forEach(e => mount(e.s, e.d));
|
|
151
|
+
root.LT = { build(spec) { mount(document.currentScript, spec); }, buildHtml };
|
|
152
|
+
})(window);
|
package/js/lt.min.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
(t=>{"use strict";if(t.LT&&t.LT.buildHtml)return;const s=t=>String(t).replace(/&/g,"&").replace(/[<]/g,"<").replace(/>/g,">").replace(/"/g,"""),l=t=>`<sup class="lt-fnref">${t}</sup>`;function e(t){const e=t.columns||[],o=t.align||[],n=t.rows||[],r=t.stub,c=t.spanners||[],u=t.row_groups||[],a=t.footnotes||[],p=t.notes||[],h=t.header||{},i=function(t){const s=[],l={};return t.forEach(t=>{null==l[t.text]&&(l[t.text]=s.length+1,s.push(t.text))}),{order:s,idx:l}}(a),f=((t,s)=>(l,e)=>{for(const o of t){const t=o.location;if(t.type!==l)continue;const n=s[o.text];if("title"===l&&t.group===e.group)return n;if("column_labels"===l&&e.columns.every(s=>t.columns.indexOf(s)>=0))return n;if("column_spanners"===l&&e.spanners.every(s=>t.spanners.indexOf(s)>=0))return n;if("row_groups"===l){if("all"===t.match)return n;if("exact"===t.match&&t.values.indexOf(e.label)>=0)return n;if("starts_with"===t.match&&0===e.label.indexOf(t.value))return n}}return 0})(a,i.idx),d=t.stub_label||"",g=e.length+(r?1:0),$=['<table class="lt-table">'],b=t=>{const s=o[t];return"right"===s?' class="al-r"':"center"===s?' class="al-c"':""},m=(t,s)=>{const e=f(t,s);return e?l(e):""},x=null!=h.title&&""!==h.title,w=null!=h.subtitle&&""!==h.subtitle;if((x||w)&&($.push('<caption class="lt-caption">'),x&&$.push(`<div class="lt-title">${s(h.title)}${m("title",{group:"title"})}</div>`),w&&$.push(`<div class="lt-subtitle">${s(h.subtitle)}${m("title",{group:"subtitle"})}</div>`),$.push("</caption>")),$.push("<thead>"),c.length){$.push('<tr class="lt-spanner-row">'+(r?'<th class="lt-spanner-empty"></th>':""));for(let t=0;t<e.length;){const l=c.find(s=>s.columns[0]===e[t]);l?($.push(`<th colspan="${l.columns.length}" scope="colgroup" class="lt-spanner">${s(l.label)}${m("column_spanners",{spanners:[l.label]})}</th>`),t+=l.columns.length):($.push('<th class="lt-spanner-empty"></th>'),t++)}$.push("</tr>")}$.push("<tr>"+(r?`<th scope="col">${s(d)}</th>`:""));for(let t=0;t<e.length;t++)$.push(`<th scope="col"${b(t)}>${s(e[t])}${m("column_labels",{columns:[e[t]]})}</th>`);$.push("</tr></thead>");const y={};for(const t of a){if("body"!==t.location.type)continue;const s=i.idx[t.text],l=t.location.columns||[],o=t.location.rows;for(let t=1;t<=n.length;t++)if(!(o&&o.indexOf(t)<0))for(const o of l){const l=e.indexOf(o);l>=0&&(y[`${t},${l}`]=s)}}const _=t=>{$.push("<tr>"),r&&$.push(`<th scope="row" class="lt-stub">${s(r[t-1])}</th>`);for(let o=0;o<e.length;o++){const e=y[`${t},${o}`];$.push(`<td${b(o)}>${s(n[t-1][o])}${e?l(e):""}</td>`)}$.push("</tr>")};if($.push("<tbody>"),u.length){const t={};for(const l of u){$.push(`<tr class="lt-row-group"><th colspan="${g}" scope="colgroup">${s(l.label)}${m("row_groups",{label:l.label})}</th></tr>`);for(const s of l.rows)t[s]=1,_(s)}for(let s=1;s<=n.length;s++)t[s]||_(s)}else for(let t=1;t<=n.length;t++)_(t);if($.push("</tbody>"),i.order.length||p.length){$.push('<tfoot class="lt-footer">'),i.order.forEach((t,e)=>$.push(`<tr class="lt-footnote"><td colspan="${g}">${l(e+1)} ${s(t)}</td></tr>`));for(const t of p)$.push(`<tr class="lt-source-note"><td colspan="${g}">${s(t)}</td></tr>`);$.push("</tfoot>")}return $.push("</table>"),$.join("")}const o=(t,s)=>t.insertAdjacentHTML("afterend",e(s));(t.LT&&t.LT.q||[]).forEach(t=>o(t.s,t.d)),t.LT={build(t){o(document.currentScript,t)},buildHtml:e}})(window);
|
|
2
|
+
//# sourceMappingURL=lt.min.js.map
|
package/js/lt.min.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["root","LT","buildHtml","esc","s","String","replace","sup","i","spec","cols","columns","align","rows","stub","spanners","groups","row_groups","fns","footnotes","notes","hdr","header","reg","order","idx","forEach","f","text","length","push","indexFootnotes","fIdx","type","p","loc","location","hit","group","every","c","indexOf","match","values","label","value","matcher","stubLabel","stub_label","nCol","out","alCls","a","mark","hasT","title","hasS","subtitle","k","sp","find","bodyMarks","fi","fcols","frows","r","ci","pushRow","m","seen","g","txt","n","join","mount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