@xiee/utils 1.14.146 → 1.14.148
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-interactive.css +22 -6
- package/css/lt-interactive.min.css +1 -1
- package/css/lt-interactive.min.css.map +1 -1
- package/css/lt.css +7 -0
- package/css/lt.min.css +1 -1
- package/css/lt.min.css.map +1 -1
- package/css/pkgdown-like.css +2 -5
- package/css/pkgdown-like.min.css +1 -1
- package/css/pkgdown-like.min.css.map +1 -1
- package/js/lt-interactive.js +159 -60
- package/js/lt-interactive.min.js +1 -1
- package/js/lt-interactive.min.js.map +1 -1
- package/js/lt.js +23 -4
- package/js/lt.min.js +1 -1
- package/js/lt.min.js.map +1 -1
- package/package.json +1 -1
package/css/lt-interactive.css
CHANGED
|
@@ -32,6 +32,16 @@
|
|
|
32
32
|
font-size: 0.8em;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
/* column profile: mini histogram in the header */
|
|
36
|
+
.lti-prof svg {
|
|
37
|
+
width: 100%;
|
|
38
|
+
height: 1.5em;
|
|
39
|
+
min-width: 4em;
|
|
40
|
+
fill: currentColor;
|
|
41
|
+
rect { opacity: 0.25; }
|
|
42
|
+
rect.s { opacity: 0.7; }
|
|
43
|
+
}
|
|
44
|
+
|
|
35
45
|
.lti-empty td {
|
|
36
46
|
text-align: center;
|
|
37
47
|
}
|
|
@@ -75,11 +85,16 @@
|
|
|
75
85
|
/* frozen widths are authoritative: a drag moves one edge only */
|
|
76
86
|
&.lti-fixed {
|
|
77
87
|
table-layout: fixed;
|
|
78
|
-
/* clip a shrunk column so the grip can shrink it freely;
|
|
79
|
-
*
|
|
80
|
-
|
|
88
|
+
/* clip a shrunk column's cells and labels so the grip can shrink it freely;
|
|
89
|
+
* header cells (holding filter popovers) and the detail row must overflow */
|
|
90
|
+
tbody tr:not(.lti-detail) td, thead .lti-label {
|
|
81
91
|
overflow: hidden;
|
|
82
92
|
}
|
|
93
|
+
thead .lti-label {
|
|
94
|
+
display: inline-block;
|
|
95
|
+
max-width: 100%;
|
|
96
|
+
vertical-align: bottom;
|
|
97
|
+
}
|
|
83
98
|
}
|
|
84
99
|
|
|
85
100
|
/* control bar: search, chips, icons. Only search grows, taking free space; it
|
|
@@ -183,10 +198,11 @@
|
|
|
183
198
|
padding: 0;
|
|
184
199
|
width: 1.1em;
|
|
185
200
|
height: 1.1em;
|
|
186
|
-
|
|
187
|
-
|
|
201
|
+
background: currentColor;
|
|
202
|
+
opacity: 0.4;
|
|
203
|
+
mask: center / contain no-repeat url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16"><path d="M1 2h14l-5.5 6.5V14l-3 1V8.5z"/></svg>');
|
|
188
204
|
}
|
|
189
|
-
/* active when the column has a live term */
|
|
205
|
+
/* active when the column has a live term: darker funnel */
|
|
190
206
|
&.lti-on .lti-funnel {
|
|
191
207
|
opacity: 1;
|
|
192
208
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
.lt-table{& :is(.lti-head,.lti-pager-row) td{padding-left:0;padding-right:0}& .lti-search{background:url("data:image/svg+xml,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"gray\" stroke-width=\"2\"><circle cx=\"6.5\" cy=\"6.5\" r=\"4.5\"/><path d=\"M10 10l5 5\"/></svg>") .4em/1em no-repeat;width:100%;padding:.5em 0 .5em 1.6em;&:focus{background-image:none;padding-left:.5em}}& .lti-sortable .lti-label{cursor:pointer;user-select:none}& .lti-sort{margin-left:.3em;font-size:.8em}& .lti-empty td{text-align:center}& .lti-expand{cursor:pointer;background:0 0;border:none;margin-right:.4em;padding:0}& .lti-detail>td{padding-left:1.5em}& th:has(.lti-resizer){position:relative}& .lti-resizer{cursor:col-resize;user-select:none;touch-action:none;width:5px;height:100%;position:absolute;top:0;right:0;&:hover{opacity:.3;background:currentColor}}&.lti-resizing{cursor:col-resize;user-select:none}&.lti-fixed{table-layout:fixed;&
|
|
1
|
+
.lt-table{& :is(.lti-head,.lti-pager-row) td{padding-left:0;padding-right:0}& .lti-search{background:url("data:image/svg+xml,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"gray\" stroke-width=\"2\"><circle cx=\"6.5\" cy=\"6.5\" r=\"4.5\"/><path d=\"M10 10l5 5\"/></svg>") .4em/1em no-repeat;width:100%;padding:.5em 0 .5em 1.6em;&:focus{background-image:none;padding-left:.5em}}& .lti-sortable .lti-label{cursor:pointer;user-select:none}& .lti-sort{margin-left:.3em;font-size:.8em}& .lti-prof svg{fill:currentColor;width:100%;min-width:4em;height:1.5em;& rect{opacity:.25}& rect.s{opacity:.7}}& .lti-empty td{text-align:center}& .lti-expand{cursor:pointer;background:0 0;border:none;margin-right:.4em;padding:0}& .lti-detail>td{padding-left:1.5em}& th:has(.lti-resizer){position:relative}& .lti-resizer{cursor:col-resize;user-select:none;touch-action:none;width:5px;height:100%;position:absolute;top:0;right:0;&:hover{opacity:.3;background:currentColor}}&.lti-resizing{cursor:col-resize;user-select:none}&.lti-fixed{table-layout:fixed;& tbody tr:not(.lti-detail) td,& thead .lti-label{overflow:hidden}& thead .lti-label{vertical-align:bottom;max-width:100%;display:inline-block}}& .lti-bar{align-items:center;gap:1.2em;display:flex;& .lti-icons,& .lti-chips{flex:none;align-items:center;gap:.3em;display:flex}& .lti-chips{gap:.5em;&:empty{display:none}}&>.lti-search{flex:8em;min-width:6em}}& .lti-cols>button,& .lti-download{border:none;width:1.2em;height:1.2em;padding:0}& .lti-cols{position:relative;&>button{background:url("data:image/svg+xml,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"gray\" stroke-width=\"1.5\"><path d=\"M1 8s2.5-4.5 7-4.5 7 4.5 7 4.5-2.5 4.5-7 4.5-7-4.5-7-4.5z\"/><circle cx=\"8\" cy=\"8\" r=\"2\"/></svg>") 50%/contain no-repeat}& .lti-menu{z-index:1;background:canvas;border:1px solid;padding:.3em .6em;position:absolute;top:100%;left:0;& label{white-space:nowrap;cursor:pointer;display:block}& .lti-group{white-space:nowrap;font-weight:600}& .lti-sub{padding-left:1em}}& .lti-chip+.lti-menu{left:auto;right:0}}& .lti-download{background:url("data:image/svg+xml,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"gray\" stroke-width=\"1.5\"><path d=\"M8 1v9m0 0L4.5 6.5M8 10l3.5-3.5\"/><path d=\"M2 11v3h12v-3\"/></svg>") 50%/contain no-repeat}& .lti-chip{cursor:pointer;background:#f7f7f7;border:1px solid #ccc;border-radius:4px;align-items:center;gap:.3em;padding:.05em .5em;display:inline-flex;position:relative;&.lti-on{border-color:#999;& .lti-chip-name{font-weight:600}}& .lti-chip-cur{color:#555;font-variant-numeric:tabular-nums}& .lti-pop{position:static}}& .lti-pop{position:relative;& .lti-funnel{opacity:.4;background:currentColor;border:none;width:1.1em;height:1.1em;padding:0;mask:url("data:image/svg+xml,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\"><path d=\"M1 2h14l-5.5 6.5V14l-3 1V8.5z\"/></svg>") 50%/contain no-repeat}&.lti-on .lti-funnel{opacity:1}& .lti-pop-panel{z-index:1;background:canvas;border:1px solid;flex-direction:column;gap:.5em;min-width:14em;max-width:90vw;padding:.6em;display:flex;position:absolute;top:100%;left:0;& .lti-widget{display:contents}&[hidden],& [hidden]{display:none}& .lti-check{white-space:nowrap;cursor:pointer;align-items:center;gap:.4em;display:flex}}}& .lti-slider{height:1.2em;margin:.4em .6em;position:relative;&:before{content:"";background:#c8c8c8;border-radius:3px;height:3px;position:absolute;inset:50% 0 auto;transform:translateY(-50%)}& .lti-slider-fill{background:#4a90d9;height:3px;position:absolute;inset:50% 0;transform:translateY(-50%)}& .lti-thumb{cursor:pointer;touch-action:none;background:#4a90d9;border:2px solid #fff;border-radius:50%;width:14px;height:14px;padding:0;position:absolute;top:50%;transform:translate(-50%,-50%);box-shadow:0 0 2px #0006}}& .lti-slider-out{text-align:center;font-variant-numeric:tabular-nums}& .lti-pager{align-items:center;gap:.3em;display:flex}& button,& select{font:inherit;cursor:pointer}& .lti-pos{margin:0 auto 0 .3em}}.lti-busy{&,& *{cursor:wait!important}& tbody{opacity:.5}}
|
|
2
2
|
/*# sourceMappingURL=lt-interactive.min.css.map */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"mappings":"AAGA,UAEE,kEAOA,oSAKE,iDAOF,2DAKA,
|
|
1
|
+
{"version":3,"mappings":"AAGA,UAEE,kEAOA,oSAKE,iDAOF,2DAKA,4CAMA,wEAKE,mBACA,qBAGF,kCAKA,oFAQA,oCAKA,yCAGA,0HASE,4CAMF,kDAKA,+BAIE,kEAGA,8EASF,qDAKE,6EAOA,sBAIE,sBAGF,sCAOF,kFAQA,8BAEE,wSAGA,6GAQE,wDAMA,gDAIA,6BAGF,yCAIF,6QAKA,2KAYE,2BAEE,kCAEF,6DAKA,4BAEF,6BAEE,uQAUA,+BAGA,uLAaE,+BACA,kCAEA,0FAWJ,8DAIE,kIASA,0GAOA,6NAeF,sEAKA,sDAKA,8CAKA,iCAMF,UAEE,4BAGA","sources":["lt-interactive.css"],"sourcesContent":["/* Controls for lt-interactive.js. `lti-*` classes avoid clashing with core\n * `lt-*`. Declare only properties that change a default. */\n\n.lt-table {\n /* full-width rows: align with table edges, not cell text */\n :is(.lti-head, .lti-pager-row) td {\n padding-left: 0;\n padding-right: 0;\n }\n\n /* Box fills its cell. Faded magnifier replaces a (translatable) placeholder;\n * hidden on focus. */\n .lti-search {\n width: 100%;\n padding: .5em 0 .5em 1.6em;\n background: url('data:image/svg+xml,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"gray\" stroke-width=\"2\"><circle cx=\"6.5\" cy=\"6.5\" r=\"4.5\"/><path d=\"M10 10l5 5\"/></svg>') 0.4em center / 1em no-repeat;\n /* no icon on focus: smaller left pad so caret sits near the edge */\n &:focus {\n padding-left: .5em;\n background-image: none;\n }\n }\n\n /* click target is the label, not the cell (keeps resize grip separate) */\n .lti-sortable .lti-label {\n cursor: pointer;\n user-select: none;\n }\n /* ▲/▼ indicator */\n .lti-sort {\n margin-left: 0.3em;\n font-size: 0.8em;\n }\n\n /* column profile: mini histogram in the header */\n .lti-prof svg {\n width: 100%;\n height: 1.5em;\n min-width: 4em;\n fill: currentColor;\n rect { opacity: 0.25; }\n rect.s { opacity: 0.7; }\n }\n\n .lti-empty td {\n text-align: center;\n }\n\n /* expand caret: glyph is its own (▸ / ▾), so strip button chrome */\n .lti-expand {\n border: none;\n background: none;\n padding: 0;\n margin-right: 0.4em;\n cursor: pointer;\n }\n /* inset ties the detail to the row above */\n .lti-detail > td {\n padding-left: 1.5em;\n }\n\n /* drag grip on a column's right edge */\n th:has(.lti-resizer) {\n position: relative;\n }\n .lti-resizer {\n position: absolute;\n top: 0;\n right: 0;\n width: 5px;\n height: 100%;\n cursor: col-resize;\n user-select: none;\n touch-action: none;\n &:hover {\n background: currentColor;\n opacity: 0.3;\n }\n }\n /* keep resize cursor and block text selection during drag */\n &.lti-resizing {\n cursor: col-resize;\n user-select: none;\n }\n /* frozen widths are authoritative: a drag moves one edge only */\n &.lti-fixed {\n table-layout: fixed;\n /* clip a shrunk column's cells and labels so the grip can shrink it freely;\n * header cells (holding filter popovers) and the detail row must overflow */\n tbody tr:not(.lti-detail) td, thead .lti-label {\n overflow: hidden;\n }\n thead .lti-label {\n display: inline-block;\n max-width: 100%;\n vertical-align: bottom;\n }\n }\n\n /* control bar: search, chips, icons. Only search grows, taking free space; it\n * fills the bar when alone. */\n .lti-bar {\n display: flex;\n align-items: center;\n /* wide gap between parts ... */\n gap: 1.2em;\n .lti-icons, .lti-chips {\n flex: 0 0 auto;\n display: flex;\n align-items: center;\n /* ... tight within a part */\n gap: 0.3em;\n }\n .lti-chips {\n gap: 0.5em;\n /* always present as a drop target for caller chips (el._lt.chips);\n collapse when empty to avoid a stray gap */\n &:empty { display: none; }\n }\n /* direct child only: chip popovers hold their own `.lti-search` */\n & > .lti-search {\n flex: 1 1 8em;\n min-width: 6em;\n }\n }\n\n /* shared size of eye and download buttons */\n .lti-cols > button, .lti-download {\n border: none;\n padding: 0;\n width: 1.2em;\n height: 1.2em;\n }\n\n /* column-visibility menu: eye button + checklist popup */\n .lti-cols {\n position: relative;\n & > button {\n background: center / contain no-repeat url('data:image/svg+xml,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"gray\" stroke-width=\"1.5\"><path d=\"M1 8s2.5-4.5 7-4.5 7 4.5 7 4.5-2.5 4.5-7 4.5-7-4.5-7-4.5z\"/><circle cx=\"8\" cy=\"8\" r=\"2\"/></svg>');\n }\n .lti-menu {\n position: absolute;\n z-index: 1;\n top: 100%;\n left: 0;\n background: Canvas;\n border: 1px solid;\n padding: 0.3em 0.6em;\n label {\n display: block;\n white-space: nowrap;\n cursor: pointer;\n }\n /* spanner label above its indented columns */\n .lti-group {\n font-weight: 600;\n white-space: nowrap;\n }\n .lti-sub { padding-left: 1em; }\n }\n /* a labeled chip sits at the bar's end: open leftward, inside the table */\n .lti-chip + .lti-menu { left: auto; right: 0; }\n }\n\n /* CSV download icon button */\n .lti-download {\n background: center / contain no-repeat url('data:image/svg+xml,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"gray\" stroke-width=\"1.5\"><path d=\"M8 1v9m0 0L4.5 6.5M8 10l3.5-3.5\"/><path d=\"M2 11v3h12v-3\"/></svg>');\n }\n\n /* typed filter chip: label, filter summary, funnel opening widget + box */\n .lti-chip {\n /* whole chip is the click target and panel anchor (panel flush with chip) */\n position: relative;\n cursor: pointer;\n display: inline-flex;\n align-items: center;\n gap: 0.3em;\n /* pill look separates chips */\n padding: 0.05em 0.5em;\n border: 1px solid #ccc;\n border-radius: 4px;\n background: #f7f7f7;\n &.lti-on {\n border-color: #999;\n .lti-chip-name { font-weight: 600; }\n }\n .lti-chip-cur {\n color: #555;\n font-variant-numeric: tabular-nums;\n }\n /* panel positions against the chip, not the funnel wrap */\n .lti-pop { position: static; }\n }\n .lti-pop {\n position: relative;\n .lti-funnel {\n border: none;\n padding: 0;\n width: 1.1em;\n height: 1.1em;\n background: currentColor;\n opacity: 0.4;\n mask: center / contain no-repeat url('data:image/svg+xml,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\"><path d=\"M1 2h14l-5.5 6.5V14l-3 1V8.5z\"/></svg>');\n }\n /* active when the column has a live term: darker funnel */\n &.lti-on .lti-funnel {\n opacity: 1;\n }\n .lti-pop-panel {\n position: absolute;\n z-index: 1;\n top: 100%;\n left: 0;\n display: flex;\n flex-direction: column;\n gap: 0.5em;\n min-width: 14em;\n max-width: 90vw;\n padding: 0.6em;\n background: Canvas;\n border: 1px solid;\n .lti-widget { display: contents; }\n &[hidden], [hidden] { display: none; }\n /* checklist row: checkbox + label */\n .lti-check {\n display: flex;\n align-items: center;\n gap: 0.4em;\n white-space: nowrap;\n cursor: pointer;\n }\n }\n }\n\n /* range slider: track, fill band, two button thumbs */\n .lti-slider {\n position: relative;\n height: 1.2em;\n margin: 0.4em 0.6em;\n &::before {\n content: \"\";\n position: absolute;\n inset: 50% 0 auto;\n height: 3px;\n transform: translateY(-50%);\n background: #c8c8c8;\n border-radius: 3px;\n }\n .lti-slider-fill {\n position: absolute;\n inset: 50% 0;\n height: 3px;\n transform: translateY(-50%);\n background: #4a90d9;\n }\n .lti-thumb {\n position: absolute;\n top: 50%;\n width: 14px;\n height: 14px;\n padding: 0;\n transform: translate(-50%, -50%);\n border: 2px solid #fff;\n border-radius: 50%;\n background: #4a90d9;\n box-shadow: 0 0 2px rgba(0, 0, 0, 0.4);\n cursor: pointer;\n touch-action: none;\n }\n }\n .lti-slider-out {\n text-align: center;\n font-variant-numeric: tabular-nums;\n }\n\n .lti-pager {\n display: flex;\n align-items: center;\n gap: 0.3em;\n }\n button, select {\n font: inherit;\n cursor: pointer;\n }\n /* row count away from arrows; page size pushed to far end */\n .lti-pos {\n margin: 0 auto 0 0.3em;\n }\n}\n\n/* Busy state during a page-freezing recompute (see lt-interactive.js). */\n.lti-busy {\n /* beat controls' own cursors */\n &, & * {\n cursor: wait !important;\n }\n & tbody {\n opacity: 0.5;\n }\n}\n"],"names":[]}
|
package/css/lt.css
CHANGED
|
@@ -31,6 +31,13 @@
|
|
|
31
31
|
&:not(:first-child) { border-left: var(--bg); }
|
|
32
32
|
&:not(:last-child) { border-right: var(--bg); }
|
|
33
33
|
}
|
|
34
|
+
/* the whole header (spanners, labels, controls) stays in view when .lt-wrap
|
|
35
|
+
* scrolls; opaque background hides scrolled content */
|
|
36
|
+
thead { position: sticky; top: 0; z-index: 2; background: Canvas; }
|
|
37
|
+
.lt-type {
|
|
38
|
+
font-size: 0.8em;
|
|
39
|
+
opacity: 0.6;
|
|
40
|
+
}
|
|
34
41
|
.lt-indent { padding-left: 1em; }
|
|
35
42
|
.lt-spanner-row {
|
|
36
43
|
.lt-spanner { border-bottom: 1px solid #bbb; text-align: center; }
|
package/css/lt.min.css
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
.lt-wrap{overflow-x:auto}.lt-table{--bg:4px solid transparent;--bd:1.5px solid #888;& th,& td{padding:5px}border-collapse:separate;caption-side:top;border-spacing:0;border-top:var(--bd);border-bottom:var(--bd);margin:1em auto;& caption{text-align:center;border-top:var(--bd);padding:.5em;& .lt-title{font-size:1.2em}& .lt-subtitle{font-size:.9em}}& th{font-weight:400}& tbody{& :not(:last-child) :is(td,th){border-bottom:1px solid #ddd}& .lt-row-group :is(td,th){border-bottom:1.5px solid #ddd}& .lt-row-group{text-align:left;&.lt-row-open{border-bottom-color:#0000}}}& thead th{border-bottom:1px solid #888;&:not(:first-child){border-left:var(--bg)}&:not(:last-child){border-right:var(--bg)}}& .lt-indent{padding-left:1em}& .lt-spanner-row{& .lt-spanner{text-align:center;border-bottom:1px solid #bbb}& .lt-spanner-empty{border-bottom:none}}& .lt-footer{font-size:.85em;& .lt-footnote:first-child td{border-top:1px solid #aaa}& .lt-source-note:first-child td{border-top:1px dashed #aaa}& .lt-source-note td{font-style:italic}}& .al-r{text-align:right}& .al-c{text-align:center}& .lt-fnref{color:#06c;&:before{content:" ["}&:after{content:"]"}}}.lt-raw [title]:after{content:" (" attr(title) ")";background:#ffffe0;font-size:.85em}
|
|
1
|
+
.lt-wrap{overflow-x:auto}.lt-table{--bg:4px solid transparent;--bd:1.5px solid #888;& th,& td{padding:5px}border-collapse:separate;caption-side:top;border-spacing:0;border-top:var(--bd);border-bottom:var(--bd);margin:1em auto;& caption{text-align:center;border-top:var(--bd);padding:.5em;& .lt-title{font-size:1.2em}& .lt-subtitle{font-size:.9em}}& th{font-weight:400}& tbody{& :not(:last-child) :is(td,th){border-bottom:1px solid #ddd}& .lt-row-group :is(td,th){border-bottom:1.5px solid #ddd}& .lt-row-group{text-align:left;&.lt-row-open{border-bottom-color:#0000}}}& thead th{border-bottom:1px solid #888;&:not(:first-child){border-left:var(--bg)}&:not(:last-child){border-right:var(--bg)}}& thead{z-index:2;background:canvas;position:sticky;top:0}& .lt-type{opacity:.6;font-size:.8em}& .lt-indent{padding-left:1em}& .lt-spanner-row{& .lt-spanner{text-align:center;border-bottom:1px solid #bbb}& .lt-spanner-empty{border-bottom:none}}& .lt-footer{font-size:.85em;& .lt-footnote:first-child td{border-top:1px solid #aaa}& .lt-source-note:first-child td{border-top:1px dashed #aaa}& .lt-source-note td{font-style:italic}}& .al-r{text-align:right}& .al-c{text-align:center}& .lt-fnref{color:#06c;&:before{content:" ["}&:after{content:"]"}}}.lt-raw [title]:after{content:" (" attr(title) ")";background:#ffffe0;font-size:.85em}
|
|
2
2
|
/*# sourceMappingURL=lt.min.css.map */
|
package/css/lt.min.css.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"mappings":"AAAA,yBACA,2DAIE,sBACgB,wHAOhB,8DAEE,4BACA,+BAGF,qBACA,QACE,4DACA,0DACA,gCAEE,0CAGJ,wCAEE,0CACA,
|
|
1
|
+
{"version":3,"mappings":"AAAA,yBACA,2DAIE,sBACgB,wHAOhB,8DAEE,4BACA,+BAGF,qBACA,QACE,4DACA,0DACA,gCAEE,0CAGJ,wCAEE,0CACA,2CAIF,0DACA,qCAIA,8BACA,kBACE,6DACA,wCAGF,6BAEE,wDACA,4DACA,wCAGF,yBACA,0BAEA,uBAEE,uBACA,sBAGJ","sources":["lt.css"],"sourcesContent":[".lt-wrap { overflow-x: auto; }\n.lt-table {\n --bg: 4px solid transparent;\n --bd: 1.5px solid #888;\n\n th, td{ padding: 5px; }\n border-collapse: separate;\n caption-side: top;\n margin: 1em auto;\n border-spacing: 0;\n border-top: var(--bd);\n border-bottom: var(--bd);\n\n caption {\n padding: .5em; text-align: center; border-top: var(--bd);\n .lt-title { font-size: 1.2em; }\n .lt-subtitle { font-size: 0.9em; }\n }\n\n th { font-weight: normal; }\n tbody {\n :not(:last-child) :is(td, th) { border-bottom: 1px solid #ddd; }\n .lt-row-group :is(td, th) { border-bottom: 1.5px solid #ddd; }\n .lt-row-group {\n text-align: left;\n &.lt-row-open { border-bottom-color: transparent; }\n }\n }\n thead th {\n border-bottom: 1px solid #888;\n &:not(:first-child) { border-left: var(--bg); }\n &:not(:last-child) { border-right: var(--bg); }\n }\n /* the whole header (spanners, labels, controls) stays in view when .lt-wrap\n * scrolls; opaque background hides scrolled content */\n thead { position: sticky; top: 0; z-index: 2; background: Canvas; }\n .lt-type {\n font-size: 0.8em;\n opacity: 0.6;\n }\n .lt-indent { padding-left: 1em; }\n .lt-spanner-row {\n .lt-spanner { border-bottom: 1px solid #bbb; text-align: center; }\n .lt-spanner-empty { border-bottom: none; }\n }\n\n .lt-footer {\n font-size: 0.85em;\n .lt-footnote:first-child td { border-top: 1px solid #aaa; }\n .lt-source-note:first-child td { border-top: 1px dashed #aaa; }\n .lt-source-note td { font-style: italic; }\n }\n\n .al-r { text-align: right; }\n .al-c { text-align: center; }\n\n .lt-fnref {\n color: #06c;\n &::before { content: \"\\00a0[\"; }\n &::after { content: \"]\"; }\n }\n}\n.lt-raw [title]::after {\n content: \" (\" attr(title) \")\";\n background: lightyellow;\n font-size: 0.85em;\n}\n"],"names":[]}
|
package/css/pkgdown-like.css
CHANGED
|
@@ -36,9 +36,6 @@ article h2 { border: 0; }
|
|
|
36
36
|
|
|
37
37
|
/* tinted full-bleed navbar */
|
|
38
38
|
.site-nav {
|
|
39
|
-
position: sticky;
|
|
40
|
-
top: 0;
|
|
41
|
-
z-index: 10;
|
|
42
39
|
padding: .5rem 0;
|
|
43
40
|
background: var(--pk-nav-bg);
|
|
44
41
|
box-shadow: 0 0 0 100vmax var(--pk-nav-bg);
|
|
@@ -81,13 +78,13 @@ article:not(.pagesjs *), .frontmatter {
|
|
|
81
78
|
/* "On this page" */
|
|
82
79
|
.side { background: var(--pk-bg); }
|
|
83
80
|
|
|
84
|
-
#TOC { position: sticky;
|
|
81
|
+
#TOC { position: sticky; }
|
|
85
82
|
#TOC.side {
|
|
86
83
|
.active { color: var(--pk-primary); }
|
|
87
84
|
&::before {
|
|
88
85
|
content: "On this page";
|
|
89
86
|
display: block;
|
|
90
|
-
margin:
|
|
87
|
+
margin: .5rem 0;
|
|
91
88
|
font-size: 1.25rem;
|
|
92
89
|
font-weight: 500;
|
|
93
90
|
}
|
package/css/pkgdown-like.min.css
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
:root{--pk-primary:#0054ad;--pk-fg:#212529;--pk-muted:#212529bf;--pk-bg:#fff;--pk-border:#dee2e6;--pk-code-bg:#0000000a;--pk-soft:#2125291a;--pk-nav-bg:color-mix(in oklab, var(--pk-bg) 90%, var(--pk-primary));--accent:var(--pk-primary);--muted-bg:var(--pk-code-bg);--border-color:var(--pk-border);--rule-color:var(--pk-border);--article-bg:transparent;--side-width:16rem}@media (prefers-color-scheme:dark){:root{--pk-bg:#deddd8}}body{background:var(--pk-bg);max-width:1140px;color:var(--pk-fg);padding-top:0;font-family:system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif}a{color:var(--pk-primary)}article h2{border:0}.site-nav{
|
|
1
|
+
:root{--pk-primary:#0054ad;--pk-fg:#212529;--pk-muted:#212529bf;--pk-bg:#fff;--pk-border:#dee2e6;--pk-code-bg:#0000000a;--pk-soft:#2125291a;--pk-nav-bg:color-mix(in oklab, var(--pk-bg) 90%, var(--pk-primary));--accent:var(--pk-primary);--muted-bg:var(--pk-code-bg);--border-color:var(--pk-border);--rule-color:var(--pk-border);--article-bg:transparent;--side-width:16rem}@media (prefers-color-scheme:dark){:root{--pk-bg:#deddd8}}body{background:var(--pk-bg);max-width:1140px;color:var(--pk-fg);padding-top:0;font-family:system-ui,-apple-system,Segoe UI,Roboto,Helvetica Neue,Arial,sans-serif}a{color:var(--pk-primary)}article h2{border:0}.site-nav{background:var(--pk-nav-bg);box-shadow:0 0 0 100vmax var(--pk-nav-bg);clip-path:inset(0 -100vmax);padding:.5rem 0;&>p{align-items:center;margin:0;&,&:last-child{border:0}}& a{color:inherit;background:0 0;border-radius:.5rem;margin:0;&:hover{background:var(--pk-soft);color:inherit}&[aria-current]{box-shadow:none;background:var(--pk-soft);margin-bottom:0}&.brand{font-size:1.25rem}}& .version{color:var(--pk-muted);margin-right:1em}}article:not(.pagesjs *),.frontmatter{box-shadow:none;background:0 0;margin:0}.frontmatter{border-bottom:1px solid var(--pk-border);text-align:left;margin:1.5rem 0 .5rem;padding-bottom:.5rem}@media (width>=62em){article:not(.pagesjs *){margin-right:calc(var(--side-width) + var(--side-gap))}}.side{background:var(--pk-bg)}#TOC{position:sticky}#TOC.side{& .active{color:var(--pk-primary)}&:before{content:"On this page";margin:.5rem 0;font-size:1.25rem;font-weight:500;display:block}& a{color:inherit}}body:has(.pkg-desc) #TOC{display:none}pre>code,pre>code[class]{border:1px solid var(--pk-border);background:var(--pk-code-bg);border-radius:.5rem}:not(pre)>code{background:var(--pk-code-bg);border-radius:.5rem}footer{color:var(--pk-muted);border-top:1px solid var(--pk-border);font-size:.875em}
|
|
2
2
|
/*# sourceMappingURL=pkgdown-like.min.css.map */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"mappings":"AAIA,mXAgBA,mCACE,uBAKF,mKAOA,0BACA,oBAGA,
|
|
1
|
+
{"version":3,"mappings":"AAIA,mXAgBA,mCACE,uBAKF,mKAOA,0BACA,oBAGA,4HAKE,gCAGE,yBAEF,8DAKE,gDACA,0EACA,2BAEF,mDAIF,6EAKA,iHAQA,qBACE,gFAIF,8BAEA,qBACA,UACE,kCACA,+FAOA,mBAEF,sCAGA,4GAKA,gEAKA","sources":["pkgdown-like.css"],"sourcesContent":["/* Make a site look like a pkgdown site (Bootstrap 5): a tinted top navbar, a\n page header with a rule, a right sidebar (\"On this page\"), pale code blocks.\n Load it after the default site CSS. The TOC goes to the right via\n `toc: {class: \"side side-right\"}` in _litedown.yml. */\n:root {\n --pk-primary: #0054ad;\n --pk-fg: #212529;\n --pk-muted: rgba(33, 37, 41, .75);\n --pk-bg: #fff;\n --pk-border: #dee2e6;\n --pk-code-bg: rgba(0, 0, 0, .04);\n --pk-soft: rgba(33, 37, 41, .1);\n --pk-nav-bg: color-mix(in oklab, var(--pk-bg) 90%, var(--pk-primary));\n --accent: var(--pk-primary);\n --muted-bg: var(--pk-code-bg);\n --border-color: var(--pk-border);\n --rule-color: var(--pk-border);\n --article-bg: transparent;\n --side-width: 16rem;\n}\n@media (prefers-color-scheme: dark) {\n :root {\n --pk-bg: #deddd8;\n }\n}\n\nbody {\n max-width: 1140px;\n padding-top: 0;\n background: var(--pk-bg);\n color: var(--pk-fg);\n font-family: system-ui, -apple-system, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif;\n}\na { color: var(--pk-primary); }\narticle h2 { border: 0; }\n\n/* tinted full-bleed navbar */\n.site-nav {\n padding: .5rem 0;\n background: var(--pk-nav-bg);\n box-shadow: 0 0 0 100vmax var(--pk-nav-bg);\n clip-path: inset(0 -100vmax);\n & > p {\n align-items: center;\n margin: 0;\n &, &:last-child { border: 0; }\n }\n a {\n margin: 0;\n border-radius: .5rem;\n background: none;\n color: inherit;\n &:hover { background: var(--pk-soft); color: inherit; }\n &[aria-current] { box-shadow: none; margin-bottom: 0; background: var(--pk-soft); }\n &.brand { font-size: 1.25rem; }\n }\n .version { color: var(--pk-muted); margin-right: 1em; }\n}\n\n/* page without card; header with a rule below */\narticle:not(.pagesjs *), .frontmatter {\n margin: 0;\n background: none;\n box-shadow: none;\n}\n.frontmatter {\n margin: 1.5rem 0 .5rem;\n padding-bottom: .5rem;\n border-bottom: 1px solid var(--pk-border);\n text-align: left;\n}\n\n/* make room for the sidebar, which hangs in the right margin of the article */\n@media (min-width: 62em) {\n article:not(.pagesjs *) { margin-right: calc(var(--side-width) + var(--side-gap)); }\n}\n\n/* \"On this page\" */\n.side { background: var(--pk-bg); }\n\n#TOC { position: sticky; }\n#TOC.side {\n .active { color: var(--pk-primary); }\n &::before {\n content: \"On this page\";\n display: block;\n margin: .5rem 0;\n font-size: 1.25rem;\n font-weight: 500;\n }\n a { color: inherit; }\n}\nbody:has(.pkg-desc) #TOC { display: none; }\n\n/* code */\npre > code, pre > code[class] {\n border: 1px solid var(--pk-border);\n border-radius: .5rem;\n background: var(--pk-code-bg);\n}\n:not(pre) > code {\n border-radius: .5rem;\n background: var(--pk-code-bg);\n}\n\nfooter {\n font-size: .875em;\n color: var(--pk-muted);\n border-top: 1px solid var(--pk-border);\n}\n"],"names":[]}
|
package/js/lt-interactive.js
CHANGED
|
@@ -29,12 +29,35 @@
|
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
// --- Small DOM helpers ---
|
|
32
|
-
const { $, $$, on, off, numCol } = LT;
|
|
32
|
+
const { $, $$, on, off, numCol, dateFmt } = LT;
|
|
33
|
+
// Columns as sort/filter see them: date-time columns become their displayed
|
|
34
|
+
// text, as do R dates (already "YYYY-MM-DD"), so `x >= "2024-01-05"` works and
|
|
35
|
+
// text order is time order. Such arrays are flagged `date`; the raw
|
|
36
|
+
// `spec.data` is untouched. Cached per data object.
|
|
37
|
+
const textual = spec => {
|
|
38
|
+
const d = spec.data || {};
|
|
39
|
+
if (spec._txt?.d !== d) {
|
|
40
|
+
const t = { ...d };
|
|
41
|
+
for (const c in d) {
|
|
42
|
+
const f = dateFmt(d[c]);
|
|
43
|
+
if (f || spec.dates?.includes(c))
|
|
44
|
+
t[c] = Object.assign(d[c].map(v => v == null || !f ? v : f(v)), { date: true });
|
|
45
|
+
}
|
|
46
|
+
spec._txt = { d, t };
|
|
47
|
+
}
|
|
48
|
+
return spec._txt.t;
|
|
49
|
+
};
|
|
33
50
|
// A row's data cells in column order: children minus leading rowspan group
|
|
34
51
|
// cells (`lt-row-group`), which aren't in `spec._cols` and are missing on a
|
|
35
52
|
// run's later rows. Class-based, not positional, so index code stays correct.
|
|
36
53
|
const dataCells = tr =>
|
|
37
54
|
[...tr.children].filter(c => !c.classList.contains("lt-row-group"));
|
|
55
|
+
// A header cell's label nodes: those before the <br> that starts the type tag
|
|
56
|
+
// and filter line (if any)
|
|
57
|
+
const labelNodes = th => {
|
|
58
|
+
const n = [...th.childNodes], i = n.findIndex(e => e.nodeName === "BR");
|
|
59
|
+
return i < 0 ? n : n.slice(0, i);
|
|
60
|
+
};
|
|
38
61
|
// Create <tag> with `props`: dashed key = attribute, else DOM property.
|
|
39
62
|
// Appends to `parent` if given; returns the element.
|
|
40
63
|
function elem(doc, tag, props = {}, parent) {
|
|
@@ -71,8 +94,9 @@
|
|
|
71
94
|
try { fn = new Function("x", `return (${v});`); } catch (e) {}
|
|
72
95
|
if (fn) {
|
|
73
96
|
const neg = /^\s*!|!=/.test(v), test = raw => {
|
|
74
|
-
if (raw == null) return neg;
|
|
75
97
|
try {
|
|
98
|
+
// missing value is `undefined`: `x == null` matches it, `x > 5` doesn't
|
|
99
|
+
if (raw == null) return neg || !!fn(undefined);
|
|
76
100
|
const num = Number(raw);
|
|
77
101
|
return !!fn(String(raw)) || (raw !== "" && isFinite(num) && !!fn(num));
|
|
78
102
|
} catch (e) { return false; }
|
|
@@ -93,10 +117,10 @@
|
|
|
93
117
|
// matches). `state`: `filters[col]` terms, `term` search, `predicates` by id
|
|
94
118
|
// (see el._lt.filter), `sort` = ordered `{col, dir}` keys.
|
|
95
119
|
function computeView(spec, disp, state) {
|
|
96
|
-
const cols = spec._cols || [], data = spec.data || {},
|
|
120
|
+
const cols = spec._cols || [], data = spec.data || {}, vals = textual(spec),
|
|
97
121
|
nRow = (data[cols[0]] || []).length,
|
|
98
122
|
cell = (c, r) => ({
|
|
99
|
-
raw:
|
|
123
|
+
raw: vals[c]?.[r - 1] ?? null, disp: disp[c]?.[r - 1] ?? ""
|
|
100
124
|
});
|
|
101
125
|
|
|
102
126
|
// Per-row keep test, ANDed; cheap single-cell filters first.
|
|
@@ -122,7 +146,7 @@
|
|
|
122
146
|
// direction. Null if nothing to sort.
|
|
123
147
|
const makeCmp = sortKeys => {
|
|
124
148
|
const keys = sortKeys.map(k => {
|
|
125
|
-
const col =
|
|
149
|
+
const col = vals[k.col];
|
|
126
150
|
return col && { col, num: numCol(col), dir: k.dir === "desc" ? -1 : 1 };
|
|
127
151
|
}).filter(Boolean);
|
|
128
152
|
return keys.length ? (a, b) => {
|
|
@@ -182,7 +206,7 @@
|
|
|
182
206
|
const leafCmp = makeCmp(leaf);
|
|
183
207
|
const partition = (rows, depth) => {
|
|
184
208
|
if (depth === gcols.length) return reduce(rows, leafCmp);
|
|
185
|
-
const col =
|
|
209
|
+
const col = vals[gcols[depth]], blocks = new Map();
|
|
186
210
|
for (const r of rows) {
|
|
187
211
|
const v = col[r - 1], key = v == null ? "\0" : String(v);
|
|
188
212
|
(blocks.get(key) || blocks.set(key, { v, rows: [] }).get(key)).rows.push(r);
|
|
@@ -281,7 +305,7 @@
|
|
|
281
305
|
hrow = [...$$(el, "thead tr")].pop(),
|
|
282
306
|
// array `sort` = initial sort (see parseKey); `true` just enables it
|
|
283
307
|
state = {
|
|
284
|
-
filters: {}, predicates: {}, page: 0, pageSize: 0,
|
|
308
|
+
filters: {}, predicates: {}, paints: [], page: 0, pageSize: 0,
|
|
285
309
|
sort: Array.isArray(opts.sort) ? opts.sort.map(parseKey) : []
|
|
286
310
|
};
|
|
287
311
|
let view, // filtered + sorted indices, cached across page turns
|
|
@@ -293,7 +317,10 @@
|
|
|
293
317
|
|
|
294
318
|
// `stale`: view changed (term/sort), not just page; recompute, go to page 1.
|
|
295
319
|
const refresh = (stale = true) => {
|
|
296
|
-
if (stale) {
|
|
320
|
+
if (stale) {
|
|
321
|
+
view = state.view = computeView(spec, disp, state); state.page = 0;
|
|
322
|
+
state.paints.forEach(f => f(view));
|
|
323
|
+
}
|
|
297
324
|
const rows = pageSlice(view, state),
|
|
298
325
|
// _viewRows = page rows with group headers; postSwap gets the same
|
|
299
326
|
// list, one entry per <tbody> row
|
|
@@ -356,13 +383,14 @@
|
|
|
356
383
|
fullRow(el.tHead || el.createTHead(), "lti-head", nAll, 0)) : null;
|
|
357
384
|
// Data-column header labels, read before sort/resize decorate cells, so the
|
|
358
385
|
// column menu shows displayed labels, not raw names
|
|
359
|
-
const labels = dataCells(hrow).map(th => th.textContent);
|
|
360
|
-
// Sort before
|
|
361
|
-
//
|
|
386
|
+
const labels = dataCells(hrow).map(th => labelNodes(th).map(n => n.textContent).join(""));
|
|
387
|
+
// Sort before filters join the header cells; `allCols` binds group headers
|
|
388
|
+
// too
|
|
362
389
|
if (opts.sort !== false) addSort(hrow, allCols, state, requestRefresh);
|
|
363
|
-
|
|
390
|
+
if (opts.profile === "header") addProfile(hrow, cols, textual(spec), state);
|
|
391
|
+
// Header filters: needed if a default applies or a named column is visible
|
|
364
392
|
if (flt && (flt.default || (flt.cols && Object.keys(flt.cols).some(c => flt.cols[c] && cols.includes(c)))))
|
|
365
|
-
addFilter(hrow, cols, flt, spec
|
|
393
|
+
addFilter(hrow, cols, flt, textual(spec), state, requestRefresh, opts.profile === "filter");
|
|
366
394
|
const layout = opts.resize ? fixedLayout(el, hrow, cols.length, nGroup) : null;
|
|
367
395
|
if (opts.resize) addResize(el, layout);
|
|
368
396
|
// DOM order = visual order. Chips group is always created with a bar so callers
|
|
@@ -371,7 +399,7 @@
|
|
|
371
399
|
if (opts.search !== false) addSearch(headBar, el, state, requestRefresh);
|
|
372
400
|
const chips = headBar ?
|
|
373
401
|
elem(el.ownerDocument, "div", { className: "lti-chips" }, headBar) : null;
|
|
374
|
-
if (barCols.length) addControlFilters(chips, barCols, flt.cols, spec
|
|
402
|
+
if (barCols.length) addControlFilters(chips, barCols, flt.cols, textual(spec), state, requestRefresh, opts.profile === "filter");
|
|
375
403
|
const icons = (opts.hide || opts.download) ?
|
|
376
404
|
elem(el.ownerDocument, "div", { className: "lti-icons" }, headBar) : null;
|
|
377
405
|
if (opts.hide)
|
|
@@ -489,7 +517,7 @@
|
|
|
489
517
|
"aria-label": "Download table as CSV"
|
|
490
518
|
}, cell);
|
|
491
519
|
btn.onclick = () => {
|
|
492
|
-
const src = (raw ? spec
|
|
520
|
+
const src = (raw ? textual(spec) : spec._display) || {},
|
|
493
521
|
lines = [keep.map(i => csvField(labels[i] ?? cols[i])).join(",")];
|
|
494
522
|
for (const r of el._lt.view())
|
|
495
523
|
lines.push(keep.map(i => csvField((src[cols[i]] || [])[r - 1])).join(","));
|
|
@@ -537,46 +565,94 @@
|
|
|
537
565
|
if (col == null) return;
|
|
538
566
|
th.classList.add("lti-sortable");
|
|
539
567
|
// label only, so the resize grip (outside it) doesn't sort
|
|
540
|
-
const lab = elem(doc, "span", { className: "lti-label" },
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
lab.
|
|
568
|
+
const nodes = labelNodes(th), lab = elem(doc, "span", { className: "lti-label" }),
|
|
569
|
+
ind = elem(doc, "span", { className: "lti-sort" });
|
|
570
|
+
th.prepend(lab, ind);
|
|
571
|
+
lab.append(...nodes);
|
|
572
|
+
marks[col] = { th, ind };
|
|
573
|
+
lab.onclick = ind.onclick = e => { cycle(state, col, e.shiftKey); paint(); refresh(); };
|
|
544
574
|
});
|
|
545
575
|
paint(); // reflect initial sort
|
|
546
576
|
}
|
|
547
577
|
|
|
548
|
-
// Per-column
|
|
549
|
-
// and
|
|
550
|
-
// default. `true` = plain box;
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
578
|
+
// Per-column filters, in the header cells (on a line of their own, after the
|
|
579
|
+
// label and type tag) so the <tbody> swap keeps them and typed input. `flt` =
|
|
580
|
+
// normalized { default?, cols? }: named spec else default. `true` = plain box;
|
|
581
|
+
// typed = funnel + popover (see typedFilter).
|
|
582
|
+
function addFilter(hrow, cols, flt, data, state, refresh, prof) {
|
|
583
|
+
const doc = hrow.ownerDocument, hCells = dataCells(hrow),
|
|
554
584
|
def = flt.default, explicit = flt.cols || {};
|
|
555
|
-
// group columns get no filter but need cells so boxes line up under headers
|
|
556
|
-
for (let i = 0; i < nGroup; i++) elem(doc, "td", {}, row);
|
|
557
|
-
// copy header alignment onto filter cells so funnels sit under header text
|
|
558
|
-
const hCells = dataCells(hrow);
|
|
559
585
|
cols.forEach((c, ci) => {
|
|
560
|
-
const
|
|
561
|
-
cell = elem(doc, "td", al ? { className: al } : {}, row),
|
|
586
|
+
const cell = hCells[ci],
|
|
562
587
|
spec = autoSpec(c in explicit ? explicit[c] : def, data[c]);
|
|
563
588
|
if (!spec || !filterable(data, c)) return; // no filter on this column
|
|
589
|
+
elem(doc, "br", {}, cell);
|
|
564
590
|
if (spec === true) { // a plain search box
|
|
565
591
|
const input = cell.appendChild(searchInput(doc, `Filter ${c}`));
|
|
566
592
|
onType(input, v => { v ? (state.filters[c] = v) : delete state.filters[c]; refresh(); });
|
|
567
|
-
} else // a typed funnel under the
|
|
568
|
-
cell.append(typedFilter(doc, c, spec, data, state, refresh, null));
|
|
593
|
+
} else // a typed funnel under the label
|
|
594
|
+
cell.append(typedFilter(doc, c, spec, data, state, refresh, null, prof));
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
|
|
598
|
+
// Column profile: a mini bar chart with the summary stats as its tooltip. A
|
|
599
|
+
// histogram of up to K equal-width bins for numbers/dates, one bar per category
|
|
600
|
+
// (most frequent first) for text; empty svg (keeps the header aligned) for text
|
|
601
|
+
// where over half the values are distinct (not categorical). Bars
|
|
602
|
+
// count all rows lightly, and the rows in the current view darkly (`state.paints`
|
|
603
|
+
// repaint it when the view changes).
|
|
604
|
+
function profile(doc, col, state) {
|
|
605
|
+
const K = 10, vals = col.filter(v => v != null), sig = (x, d) => +x.toPrecision(d),
|
|
606
|
+
p = elem(doc, "span", { className: "lti-prof" });
|
|
607
|
+
const num = v => col.date ? Date.parse(v.replace(" ", "T")) : v,
|
|
608
|
+
nums = vals.map(num), isNum = nums.every(Number.isFinite), m = new Map();
|
|
609
|
+
for (const v of vals) m.set(v, (m.get(v) || 0) + 1);
|
|
610
|
+
const nNA = col.length - vals.length, tip = [];
|
|
611
|
+
let n = K, bin = () => -1; // n bars; bin: value -> bar index (-1 for none)
|
|
612
|
+
const slots = list => { n = list.length; const s = new Map(list.map((e, i) => [e[0], i])); bin = v => s.get(v) ?? -1; };
|
|
613
|
+
// no bars (empty svg as placeholder) for an all-NA or too-distinct text column
|
|
614
|
+
if (!vals.length || (!isNum && m.size > vals.length / 2)) n = 0;
|
|
615
|
+
else if (isNum) {
|
|
616
|
+
const lo = nums.reduce((a, b) => Math.min(a, b)), hi = nums.reduce((a, b) => Math.max(a, b)),
|
|
617
|
+
at = x => col.date ? vals[nums.indexOf(x)] : sig(x, 6);
|
|
618
|
+
tip.push(`min ${at(lo)}`, `max ${at(hi)}`);
|
|
619
|
+
col.date || tip.push(`mean ${sig(nums.reduce((a, b) => a + b) / nums.length, 4)}`);
|
|
620
|
+
nNA && tip.push(`${Math.round(100 * nNA / col.length)}% NA`);
|
|
621
|
+
n = Math.min(K, m.size); // never more bins than distinct values
|
|
622
|
+
bin = v => Math.min(n - 1, Math.floor((num(v) - lo) / (hi - lo || 1) * n));
|
|
623
|
+
} else {
|
|
624
|
+
const all = [...m].sort((a, b) => b[1] - a[1]), top = all.slice(0, 5);
|
|
625
|
+
slots(all);
|
|
626
|
+
tip.push(`${m.size + (nNA > 0)} distinct`, (m.size > 5 ? "top " : "") + top.map(([v, k]) => `${v} (${k})`).join(", "));
|
|
627
|
+
nNA && tip.push(`${nNA} NA`);
|
|
628
|
+
}
|
|
629
|
+
const bars = col.map(v => v == null ? -1 : bin(v)),
|
|
630
|
+
count = rows => { const c = Array(n).fill(0); for (const r of rows) bars[r - 1] >= 0 && c[bars[r - 1]]++; return c; },
|
|
631
|
+
full = count(col.map((_, i) => i + 1)), max = Math.max(...full),
|
|
632
|
+
rects = (c, cls) => c.map((k, i) =>
|
|
633
|
+
`<rect${cls} x="${i}" y="${1 - k / max}" width=".9" height="${k / max}"/>`).join(""),
|
|
634
|
+
paint = rows => p.innerHTML = `<svg viewBox="0 0 ${n || 1} 1" preserveAspectRatio="none">${rects(full, "")}${rows.length < col.length ? rects(count(rows), ' class="s"') : ""}</svg>`;
|
|
635
|
+
p.title = tip.filter(Boolean).join("; ");
|
|
636
|
+
state.paints.push(paint);
|
|
637
|
+
paint(state.view || col.map((_, i) => i + 1));
|
|
638
|
+
return p;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
// Profile in the header cell, after the type tag (`profile: "header"`)
|
|
642
|
+
function addProfile(hrow, cols, data, state) {
|
|
643
|
+
const hCells = dataCells(hrow);
|
|
644
|
+
cols.forEach((c, ci) => {
|
|
645
|
+
hCells[ci].append(elem(hrow.ownerDocument, "br"), profile(hrow.ownerDocument, data[c], state));
|
|
569
646
|
});
|
|
570
|
-
hrow.after(row);
|
|
571
647
|
}
|
|
572
648
|
|
|
573
649
|
// `"auto"` filter: pick the widget from the column's data. Numbers get a range
|
|
574
|
-
// slider (a plain box if constant), strings with few distinct
|
|
575
|
-
// checklist, anything else a plain box.
|
|
650
|
+
// slider (a plain box if constant), so do dates; strings with few distinct
|
|
651
|
+
// values a checklist, anything else a plain box.
|
|
576
652
|
const autoSpec = (spec, col = []) => {
|
|
577
653
|
if (spec?.type !== "auto") return spec;
|
|
578
654
|
const vals = col.filter(v => v != null), n = new Set(vals).size;
|
|
579
|
-
return vals.every(v => typeof v === "number") ? (n > 1 ? { type: "range" } : true)
|
|
655
|
+
return vals.every(v => typeof v === "number") || col.date ? (n > 1 ? { type: "range" } : true)
|
|
580
656
|
: vals.every(v => typeof v === "string") && n <= 10 ? { type: "checklist" } : true;
|
|
581
657
|
};
|
|
582
658
|
|
|
@@ -873,25 +949,38 @@
|
|
|
873
949
|
|
|
874
950
|
// Filter term <-> widget value, per type. `null` parse = a hand-typed term the
|
|
875
951
|
// widget can't show: widget goes neutral, box stays authoritative.
|
|
876
|
-
|
|
952
|
+
// value of the missing-value ("NA") choice; not a string any data holds
|
|
953
|
+
const NA = "\0NA",
|
|
954
|
+
selExpr = v => v === "" ? "" : v === NA ? "x == null" : `x == ${JSON.stringify(String(v))}`,
|
|
877
955
|
selParse = s => {
|
|
878
|
-
const m = /^\s*x\s*==\s*(['"])([\s\S]*)\1\s*$/.exec(s || "");
|
|
879
|
-
return m ? m[2] : null;
|
|
956
|
+
const m = /^\s*x\s*==\s*(?:(['"])([\s\S]*)\1|null)\s*$/.exec(s || "");
|
|
957
|
+
return m ? (m[1] ? m[2] : NA) : null;
|
|
880
958
|
},
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
959
|
+
// range over numbers (`x >= 1 && x <= 3`) or, with `labels` (dates), over
|
|
960
|
+
// their indices written as quoted labels (`x >= "2024-01-05"`)
|
|
961
|
+
rngExpr = (lo, hi, min, max, labels) => lo <= min && hi >= max ? "" :
|
|
962
|
+
labels ? `x >= ${JSON.stringify(labels[lo])} && x <= ${JSON.stringify(labels[hi])}`
|
|
963
|
+
: `x >= ${lo} && x <= ${hi}`,
|
|
964
|
+
rngParse = (s, labels) => {
|
|
965
|
+
const m = /^\s*x\s*>=\s*("[^"]*"|-?[\d.]+)\s*&&\s*x\s*<=\s*("[^"]*"|-?[\d.]+)\s*$/.exec(s || "");
|
|
966
|
+
if (!m) return null;
|
|
967
|
+
// a quoted bound is a date label (unknown label or no labels: can't show)
|
|
968
|
+
const at = t => t[0] !== '"' ? parseFloat(t) : labels ? labels.indexOf(JSON.parse(t)) : NaN,
|
|
969
|
+
p = [at(m[1]), at(m[2])];
|
|
970
|
+
return p.some(v => !isFinite(v) || (labels && v < 0)) ? null : p;
|
|
886
971
|
},
|
|
972
|
+
rngShow = (p, cfg) => cfg.labels ? `${cfg.labels[p[0]]} – ${cfg.labels[p[1]]}` : `${p[0]} – ${p[1]}`,
|
|
887
973
|
// keeps rows whose value is checked; all checked -> "" (no filter), none ->
|
|
888
|
-
// "[].includes(x)" (no rows)
|
|
889
|
-
setExpr = (sel, all) =>
|
|
890
|
-
sel.length === all.length
|
|
974
|
+
// "[].includes(x)" (no rows). NA is `null` in the list, matched via `x ?? null`.
|
|
975
|
+
setExpr = (sel, all) => {
|
|
976
|
+
if (sel.length === all.length) return "";
|
|
977
|
+
const vals = sel.map(v => v === NA ? null : String(v));
|
|
978
|
+
return `${JSON.stringify(vals)}.includes(x${vals.includes(null) ? " ?? null" : ""})`;
|
|
979
|
+
},
|
|
891
980
|
setParse = s => {
|
|
892
|
-
const m = /^\s*(\[[\s\S]*\])\.includes\(\s*x\s
|
|
981
|
+
const m = /^\s*(\[[\s\S]*\])\.includes\(\s*x\s*(?:\?\?\s*null\s*)?\)\s*$/.exec(s || "");
|
|
893
982
|
if (!m) return null;
|
|
894
|
-
try { return JSON.parse(m[1]); } catch (e) { return null; }
|
|
983
|
+
try { return JSON.parse(m[1]).map(v => v === null ? NA : v); } catch (e) { return null; }
|
|
895
984
|
};
|
|
896
985
|
|
|
897
986
|
// "Nice" slider step: 1/2/5 x 10^k nearest ~1% of span (~50-100 increments),
|
|
@@ -916,12 +1005,19 @@
|
|
|
916
1005
|
? a - b : String(a).localeCompare(String(b)));
|
|
917
1006
|
choices = vals.map(v => ({ value: String(v), label: String(v) }));
|
|
918
1007
|
}
|
|
1008
|
+
// missing values get their own choice, so they can be selected too
|
|
1009
|
+
if (column.some(v => v == null)) choices = [...choices, { value: NA, label: "NA" }];
|
|
919
1010
|
// select gets a leading blank "no filter" choice; checklist starts all
|
|
920
1011
|
// checked (also "no filter"), so needs none
|
|
921
1012
|
if (spec.type === "select" && !choices.some(o => o.value === ""))
|
|
922
1013
|
choices = [{ value: "", label: "" }, ...choices];
|
|
923
1014
|
return { ...spec, choices };
|
|
924
1015
|
}
|
|
1016
|
+
// dates: the slider steps through the distinct values present (by index)
|
|
1017
|
+
if (spec.type === "range" && column.date) {
|
|
1018
|
+
const labels = [...new Set(column.filter(v => v != null))].sort();
|
|
1019
|
+
return { ...spec, labels, min: 0, max: labels.length - 1, step: 1 };
|
|
1020
|
+
}
|
|
925
1021
|
let { min, max, step } = spec;
|
|
926
1022
|
let lo = Infinity, hi = -Infinity, allInt = true;
|
|
927
1023
|
if (min == null || max == null || step == null) {
|
|
@@ -1119,14 +1215,15 @@
|
|
|
1119
1215
|
}
|
|
1120
1216
|
},
|
|
1121
1217
|
range: {
|
|
1122
|
-
describe: t => { const p = rngParse(t); return p ?
|
|
1123
|
-
init: cfg => cfg.value ? rngExpr(cfg.value[0], cfg.value[1], cfg.min, cfg.max) : "",
|
|
1124
|
-
parse: rngParse,
|
|
1218
|
+
describe: (t, cfg) => { const p = rngParse(t, cfg.labels); return p ? rngShow(p, cfg) : t ? "⋯" : ""; },
|
|
1219
|
+
init: cfg => cfg.value ? rngExpr(cfg.value[0], cfg.value[1], cfg.min, cfg.max, cfg.labels) : "",
|
|
1220
|
+
parse: (t, cfg) => rngParse(t, cfg.labels),
|
|
1125
1221
|
build: (doc, cfg, setTerm) => {
|
|
1126
1222
|
const out = elem(doc, "span", { className: "lti-slider-out" }),
|
|
1127
|
-
show = p => out.textContent =
|
|
1128
|
-
|
|
1129
|
-
|
|
1223
|
+
show = p => out.textContent = rngShow(p, cfg),
|
|
1224
|
+
put = v => setTerm(rngExpr(v[0], v[1], cfg.min, cfg.max, cfg.labels), ed),
|
|
1225
|
+
w = makeSlider(doc, cfg, v => { show(v); put(v); }, show),
|
|
1226
|
+
ed = { el: [w.el, out], reflect: t => { const p = rngParse(t, cfg.labels) || [cfg.min, cfg.max]; w.set(p); show(p); } };
|
|
1130
1227
|
return ed;
|
|
1131
1228
|
}
|
|
1132
1229
|
},
|
|
@@ -1153,7 +1250,7 @@
|
|
|
1153
1250
|
// Build a typed column filter element. Funnel + popover is shared: head-bar chip
|
|
1154
1251
|
// (label + summary around the funnel) if `chipLabel` is a string, else a bare
|
|
1155
1252
|
// funnel under the header (null).
|
|
1156
|
-
function typedFilter(doc, col, spec, data, state, refresh, chipLabel) {
|
|
1253
|
+
function typedFilter(doc, col, spec, data, state, refresh, chipLabel, prof) {
|
|
1157
1254
|
const cfg = resolveSpec(spec, data[col] || []),
|
|
1158
1255
|
kind = KINDS[cfg.type],
|
|
1159
1256
|
editors = []; // expression box + widget, kept in sync
|
|
@@ -1168,13 +1265,15 @@
|
|
|
1168
1265
|
refresh();
|
|
1169
1266
|
const cur = state.filters[col] || "";
|
|
1170
1267
|
editors.forEach(e => e !== from && e.reflect(cur));
|
|
1171
|
-
if (widget) widget.hidden = !!cur && kind.parse(cur) == null;
|
|
1268
|
+
if (widget) widget.hidden = !!cur && kind.parse(cur, cfg) == null;
|
|
1172
1269
|
mark(cur);
|
|
1173
1270
|
};
|
|
1174
1271
|
// Hidden column: funnel in a labeled chip (makeChip), also the popover's click
|
|
1175
1272
|
// target; visible: bare funnel under its header. Chip built first to host it.
|
|
1176
1273
|
const chip = chipLabel && makeChip(doc, chipLabel);
|
|
1177
1274
|
const wrap = popover(doc, `Filter ${cfg.label || col}`, panel => {
|
|
1275
|
+
const p = prof && profile(doc, data[col] || [], state);
|
|
1276
|
+
p && panel.append(p);
|
|
1178
1277
|
// `box = FALSE` drops the expression box, limiting to the widget's choices
|
|
1179
1278
|
if (cfg.box !== false) {
|
|
1180
1279
|
const box = elem(doc, "input", {
|
|
@@ -1208,11 +1307,11 @@
|
|
|
1208
1307
|
}
|
|
1209
1308
|
|
|
1210
1309
|
// Head-bar chip per hidden typed column (see typedFilter).
|
|
1211
|
-
function addControlFilters(cell, barCols, cfg, data, state, refresh) {
|
|
1310
|
+
function addControlFilters(cell, barCols, cfg, data, state, refresh, prof) {
|
|
1212
1311
|
const doc = cell.ownerDocument;
|
|
1213
1312
|
for (const col of barCols)
|
|
1214
1313
|
cell.append(
|
|
1215
|
-
typedFilter(doc, col, cfg[col], data, state, refresh, cfg[col].label || col));
|
|
1314
|
+
typedFilter(doc, col, cfg[col], data, state, refresh, cfg[col].label || col, prof));
|
|
1216
1315
|
}
|
|
1217
1316
|
|
|
1218
1317
|
// Pager as the last <tfoot> row (after footnotes), plus a page-size <select> if
|