@xiee/utils 1.14.156 → 1.14.157
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 +7 -6
- package/css/lt-interactive.min.css +1 -1
- package/css/lt-interactive.min.css.map +1 -1
- package/js/lt-export.js +96 -0
- package/js/lt-export.min.js +2 -0
- package/js/lt-export.min.js.map +1 -0
- package/js/lt-interactive.js +47 -37
- package/js/lt-interactive.min.js +1 -1
- package/js/lt-interactive.min.js.map +1 -1
- package/js/lt.js +4 -1
- package/js/lt.min.js +1 -1
- package/js/lt.min.js.map +1 -1
- package/js/pages.js +5 -2
- package/js/pages.min.js +1 -1
- package/js/pages.min.js.map +1 -1
- package/package.json +1 -1
- package/purge.sh +2 -2
package/css/lt-interactive.css
CHANGED
|
@@ -141,10 +141,10 @@
|
|
|
141
141
|
height: 1.2em;
|
|
142
142
|
}
|
|
143
143
|
|
|
144
|
-
/* column-visibility
|
|
145
|
-
.lti-cols {
|
|
144
|
+
/* popup menus: column-visibility checklist (eye button) and download formats */
|
|
145
|
+
.lti-cols, .lti-dl {
|
|
146
146
|
position: relative;
|
|
147
|
-
& > button {
|
|
147
|
+
& > button:not(.lti-download) {
|
|
148
148
|
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>');
|
|
149
149
|
}
|
|
150
150
|
.lti-menu {
|
|
@@ -167,11 +167,12 @@
|
|
|
167
167
|
}
|
|
168
168
|
.lti-sub { padding-left: 1em; }
|
|
169
169
|
}
|
|
170
|
-
/* a labeled chip sits at the bar's end
|
|
171
|
-
|
|
170
|
+
/* a labeled chip sits at the bar's end, as does the download button: open
|
|
171
|
+
leftward, inside the table */
|
|
172
|
+
.lti-chip + .lti-menu, &.lti-dl .lti-menu { left: auto; right: 0; }
|
|
172
173
|
}
|
|
173
174
|
|
|
174
|
-
/*
|
|
175
|
+
/* download icon button */
|
|
175
176
|
.lti-download {
|
|
176
177
|
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>');
|
|
177
178
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
.lt-table{--lti-accent:#ffc800;& :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-nl{color:#555;font-size:.85em;&:empty{display:none}}& .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{fill:var(--lti-accent);opacity:1}}& .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-off{mask:url("data:image/svg+xml,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"black\" stroke-width=\"1.5\" stroke-linejoin=\"round\"><path d=\"M1 2h14l-5.5 6.5V14l-3 1V8.5z\"/></svg>") 50%/contain no-repeat}&.lti-on .lti-funnel{background:var(--lti-accent);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}}
|
|
1
|
+
.lt-table{--lti-accent:#ffc800;& :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-nl{color:#555;font-size:.85em;&:empty{display:none}}& .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{fill:var(--lti-accent);opacity:1}}& .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,& .lti-dl{position:relative;&>button:not(.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=\"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,&.lti-dl .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-off{mask:url("data:image/svg+xml,<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 16 16\" fill=\"none\" stroke=\"black\" stroke-width=\"1.5\" stroke-linejoin=\"round\"><path d=\"M1 2h14l-5.5 6.5V14l-3 1V8.5z\"/></svg>") 50%/contain no-repeat}&.lti-on .lti-funnel{background:var(--lti-accent);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,+BAIE,kEAOA,oSAKE,iDAOF,qCAGE,sBAIF,2DAKA,4CAMA,wEAKE,mBACA,2CAGF,kCAKA,oFAQA,oCAKA,yCAGA,0HASE,4CAMF,kDAKA,+BAIE,kEAGA,8EASF,qDAKE,6EAOA,sBAIE,sBAGF,sCAOF,kFAQA,
|
|
1
|
+
{"version":3,"mappings":"AAGA,+BAIE,kEAOA,oSAKE,iDAOF,qCAGE,sBAIF,2DAKA,4CAMA,wEAKE,mBACA,2CAGF,kCAKA,oFAQA,oCAKA,yCAGA,0HASE,4CAMF,kDAKA,+BAIE,kEAGA,8EASF,qDAKE,6EAOA,sBAIE,sBAGF,sCAOF,kFAQA,wCAEE,2TAGA,6GAQE,wDAMA,gDAIA,6BAIF,4DAIF,6QAKA,2KAYE,2BAEE,kCAEF,6DAKA,4BAEF,6BAEE,uQAUA,gQAIA,4DAIA,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 /* accent for active filter and profile highlight */\n --lti-accent: #ffc800;\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 /* how a query was read: shown only when conditions were recognized */\n .lti-nl {\n font-size: .85em;\n color: #555;\n &:empty { display: none; }\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 { fill: var(--lti-accent); opacity: 1; }\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 /* popup menus: column-visibility checklist (eye button) and download formats */\n .lti-cols, .lti-dl {\n position: relative;\n & > button:not(.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=\"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, as does the download button: open\n leftward, inside the table */\n .lti-chip + .lti-menu, &.lti-dl .lti-menu { left: auto; right: 0; }\n }\n\n /* 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 /* disabled column filter: outline funnel (stroke, no fill), inert */\n .lti-off {\n mask: 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=\"black\" stroke-width=\"1.5\" stroke-linejoin=\"round\"><path d=\"M1 2h14l-5.5 6.5V14l-3 1V8.5z\"/></svg>');\n }\n /* active when the column has a live term: accent funnel */\n &.lti-on .lti-funnel {\n background: var(--lti-accent);\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/js/lt-export.js
ADDED
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/* lt-export.js — table export formats (CSV, RTF) for lt.
|
|
2
|
+
*
|
|
3
|
+
* Plugin on the LT global (see lt.js), loaded after core. No DOM: each format
|
|
4
|
+
* turns a plain model of the table into a string, so the same code serves the
|
|
5
|
+
* download button of lt-interactive.js and Node (`lt_export()` in R). Add a
|
|
6
|
+
* format by adding an entry to `formats`; the download menu lists them all.
|
|
7
|
+
*
|
|
8
|
+
* LT.plugins.export.text(format, spec, rows?, src?)
|
|
9
|
+
*
|
|
10
|
+
* `spec` is a built spec (after LT.buildHtml), `rows` 1-based row indices
|
|
11
|
+
* (default: all), `src` the cell text by column (default: displayed text).
|
|
12
|
+
*/
|
|
13
|
+
(root => {
|
|
14
|
+
"use strict";
|
|
15
|
+
const LT = root.LT;
|
|
16
|
+
if (!LT?.plugins || LT.plugins.export) return;
|
|
17
|
+
|
|
18
|
+
// Text fields are a plain string or, if wrapped in I() in R, a one-element
|
|
19
|
+
// array of raw HTML (tags dropped).
|
|
20
|
+
const plain = v => Array.isArray(v) ? String(v[0] ?? "").replace(/<[^>]*>/g, "") : String(v ?? "");
|
|
21
|
+
|
|
22
|
+
// CSV: quote (doubling quotes) only if comma, quote, or newline.
|
|
23
|
+
const csvField = v => /[",\n]/.test(v) ? '"' + v.replace(/"/g, '""') + '"' : v;
|
|
24
|
+
const csv = m => [m.head, ...m.rows].map(r => r.map(csvField).join(",")).join("\n");
|
|
25
|
+
|
|
26
|
+
// RTF: escape \ { }, line breaks, and non-ASCII (as signed 16-bit \u codes).
|
|
27
|
+
const rtfEsc = v => v.replace(/[\\{}]/g, "\\$&").replace(/\r?\n/g, "\\line ")
|
|
28
|
+
.replace(/[^\x00-\x7f]/g, c => `\\u${(c.charCodeAt(0) << 16) >> 16}?`);
|
|
29
|
+
// A fixed look: rules above and below the header and below the last row, bold
|
|
30
|
+
// header, spanners as merged cells, title above and notes below, column
|
|
31
|
+
// widths by text length.
|
|
32
|
+
const rtf = ({ head, rows, align, indent, spans, title, subtitle, notes }) => {
|
|
33
|
+
const W = 9360, // text width in twips (6.5in)
|
|
34
|
+
len = head.map((h, j) => Math.min(30, rows.reduce((n, r) => Math.max(n, r[j].length), Math.max(4, h.length)))),
|
|
35
|
+
tot = len.reduce((a, b) => a + b, 0);
|
|
36
|
+
let x = 0;
|
|
37
|
+
const edge = len.map(l => x += Math.round(l / tot * W)),
|
|
38
|
+
// cells: [text, {a: align, b: bold, li: indent, bd: border sides, m: merge}]
|
|
39
|
+
row = cells => "\\trowd\\trgaph60" + cells.map(([, o], j) =>
|
|
40
|
+
(o.m || "") + [...(o.bd || "")].map(s => `\\clbrdr${s}\\brdrs\\brdrw10`).join("") + `\\cellx${edge[j]}`
|
|
41
|
+
).join("") + cells.map(([t, o]) =>
|
|
42
|
+
`\\pard\\intbl\\q${o.a || "l"}${o.li ? `\\li${o.li}` : ""} ${o.b ? `{\\b ${rtfEsc(t)}}` : rtfEsc(t)}\\cell`
|
|
43
|
+
).join("") + "\\row\n",
|
|
44
|
+
out = ["{\\rtf1\\ansi\\deff0{\\fonttbl{\\f0 Arial;}}\\fs18\n"];
|
|
45
|
+
if (title) out.push(`{\\pard\\qc\\b ${rtfEsc(title)}\\par}\n`);
|
|
46
|
+
if (subtitle) out.push(`{\\pard\\qc ${rtfEsc(subtitle)}\\par}\n`);
|
|
47
|
+
if (spans.length) {
|
|
48
|
+
const cells = [];
|
|
49
|
+
for (let j = 0; j < head.length;) {
|
|
50
|
+
const s = spans.find(s => s.from === j);
|
|
51
|
+
if (!s) { cells.push(["", { bd: "t" }]); j++; continue; }
|
|
52
|
+
cells.push([s.label, { a: "c", bd: "tb", m: "\\clmgf" }]);
|
|
53
|
+
for (let k = 1; k < s.n; k++) cells.push(["", { bd: "tb", m: "\\clmrg" }]);
|
|
54
|
+
j += s.n;
|
|
55
|
+
}
|
|
56
|
+
out.push(row(cells));
|
|
57
|
+
}
|
|
58
|
+
out.push(row(head.map((h, j) => [h, { a: align[j], b: 1, bd: (spans.length ? "" : "t") + "b" }])));
|
|
59
|
+
rows.forEach((r, i) => out.push(row(r.map((t, j) => [t, {
|
|
60
|
+
a: align[j], li: j ? 0 : indent[i] * 240, bd: i === rows.length - 1 ? "b" : ""
|
|
61
|
+
}]))));
|
|
62
|
+
for (const n of notes) out.push(`{\\pard\\fs16 ${rtfEsc(n)}\\par}\n`);
|
|
63
|
+
return out.join("") + "}";
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// Registered formats: key (also the file extension) -> label, MIME type, and
|
|
67
|
+
// `fn(model)`.
|
|
68
|
+
const formats = {
|
|
69
|
+
csv: { label: "CSV", mime: "text/csv", fn: csv },
|
|
70
|
+
rtf: { label: "RTF", mime: "application/rtf", fn: rtf },
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
// The table as plain strings: header, body rows, and what a format may use
|
|
74
|
+
// beyond them (alignment, row indents, spanners as column ranges, title,
|
|
75
|
+
// notes).
|
|
76
|
+
const model = (spec, rows, src = spec._display) => {
|
|
77
|
+
const cols = spec._cols, t = spec._tbl, ind = spec._indent;
|
|
78
|
+
rows ||= Array.from({ length: src[cols[0]]?.length ?? 0 }, (_, i) => i + 1);
|
|
79
|
+
return {
|
|
80
|
+
head: t.labels.map(plain),
|
|
81
|
+
rows: rows.map(r => cols.map(c => String(src[c]?.[r - 1] ?? ""))),
|
|
82
|
+
align: t.align.map(a => ({ center: "c", right: "r" })[a] || "l"),
|
|
83
|
+
indent: rows.map(r => ind?.[r - 1] || 0),
|
|
84
|
+
spans: (t.spanners || []).map(s => ({
|
|
85
|
+
label: plain(s.label), from: cols.indexOf(s.columns[0]), n: s.columns.length
|
|
86
|
+
})),
|
|
87
|
+
title: plain(t.header.title), subtitle: plain(t.header.subtitle),
|
|
88
|
+
notes: (t.notes || []).map(plain)
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
LT.plugins.export = {
|
|
93
|
+
formats, model,
|
|
94
|
+
text: (fmt, spec, rows, src) => formats[fmt].fn(model(spec, rows, src))
|
|
95
|
+
};
|
|
96
|
+
})(window);
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
(()=>{"use strict";const t=window.LT;if(!t?.plugins||t.plugins.export)return;const n=t=>Array.isArray(t)?String(t[0]??"").replace(/<[^>]*>/g,""):String(t??""),e=t=>/[",\n]/.test(t)?'"'+t.replace(/"/g,'""')+'"':t,a=t=>t.replace(/[\\{}]/g,"\\$&").replace(/\r?\n/g,"\\line ").replace(/[^\x00-\x7f]/g,t=>`\\u${t.charCodeAt(0)<<16>>16}?`),l={csv:{label:"CSV",mime:"text/csv",fn:t=>[t.head,...t.rows].map(t=>t.map(e).join(",")).join("\n")},rtf:{label:"RTF",mime:"application/rtf",fn:({head:t,rows:n,align:e,indent:l,spans:r,title:s,subtitle:p,notes:i})=>{const o=t.map((t,e)=>Math.min(30,n.reduce((t,n)=>Math.max(t,n[e].length),Math.max(4,t.length)))),m=o.reduce((t,n)=>t+n,0);let c=0;const d=o.map(t=>c+=Math.round(t/m*9360)),h=t=>"\\trowd\\trgaph60"+t.map(([,t],n)=>(t.m||"")+[...t.bd||""].map(t=>`\\clbrdr${t}\\brdrs\\brdrw10`).join("")+`\\cellx${d[n]}`).join("")+t.map(([t,n])=>`\\pard\\intbl\\q${n.a||"l"}${n.li?`\\li${n.li}`:""} ${n.b?`{\\b ${a(t)}}`:a(t)}\\cell`).join("")+"\\row\n",b=["{\\rtf1\\ansi\\deff0{\\fonttbl{\\f0 Arial;}}\\fs18\n"];if(s&&b.push(`{\\pard\\qc\\b ${a(s)}\\par}\n`),p&&b.push(`{\\pard\\qc ${a(p)}\\par}\n`),r.length){const n=[];for(let e=0;e<t.length;){const t=r.find(t=>t.from===e);if(t){n.push([t.label,{a:"c",bd:"tb",m:"\\clmgf"}]);for(let e=1;e<t.n;e++)n.push(["",{bd:"tb",m:"\\clmrg"}]);e+=t.n}else n.push(["",{bd:"t"}]),e++}b.push(h(n))}b.push(h(t.map((t,n)=>[t,{a:e[n],b:1,bd:(r.length?"":"t")+"b"}]))),n.forEach((t,a)=>b.push(h(t.map((t,r)=>[t,{a:e[r],li:r?0:240*l[a],bd:a===n.length-1?"b":""}]))));for(const t of i)b.push(`{\\pard\\fs16 ${a(t)}\\par}\n`);return b.join("")+"}"}}},r=(t,e,a=t._display)=>{const l=t._cols,r=t._tbl,s=t._indent;return e||=Array.from({length:a[l[0]]?.length??0},(t,n)=>n+1),{head:r.labels.map(n),rows:e.map(t=>l.map(n=>String(a[n]?.[t-1]??""))),align:r.align.map(t=>({center:"c",right:"r"}[t]||"l")),indent:e.map(t=>s?.[t-1]||0),spans:(r.spanners||[]).map(t=>({label:n(t.label),from:l.indexOf(t.columns[0]),n:t.columns.length})),title:n(r.header.title),subtitle:n(r.header.subtitle),notes:(r.notes||[]).map(n)}};t.plugins.export={formats:l,model:r,text:(t,n,e,a)=>l[t].fn(r(n,e,a))}})();
|
|
2
|
+
//# sourceMappingURL=lt-export.min.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["LT","window","plugins","export","plain","v","Array","isArray","String","replace","csvField","test","rtfEsc","c","charCodeAt","formats","csv","label","mime","fn","m","head","rows","map","r","join","rtf","align","indent","spans","title","subtitle","notes","len","h","j","Math","min","reduce","n","max","length","tot","a","b","x","edge","l","round","row","cells","o","bd","s","t","li","out","push","find","from","k","forEach","i","model","spec","src","_display","cols","_cols","_tbl","ind","_indent","_","labels","center","right","spanners","indexOf","columns","header","text","fmt"],"sources":["lt-export.js"],"mappings":"AAYA,MACE,aACA,MAAMA,EAiFLC,OAjFeD,GAChB,IAAKA,GAAIE,SAAWF,EAAGE,QAAQC,OAAQ,OAIvC,MAAMC,EAAQC,GAAKC,MAAMC,QAAQF,GAAKG,OAAOH,EAAE,IAAM,IAAII,QAAQ,WAAY,IAAMD,OAAOH,GAAK,IAGzFK,EAAWL,GAAK,SAASM,KAAKN,GAAK,IAAMA,EAAEI,QAAQ,KAAM,MAAQ,IAAMJ,EAIvEO,EAASP,GAAKA,EAAEI,QAAQ,UAAW,QAAQA,QAAQ,SAAU,WAChEA,QAAQ,gBAAiBI,GAAK,MAAOA,EAAEC,WAAW,IAAM,IAAO,OAwC5DC,EAAU,CACdC,IAAK,CAAEC,MAAO,MAAOC,KAAM,WAAYC,GA7C7BC,GAAK,CAACA,EAAEC,QAASD,EAAEE,MAAMC,IAAIC,GAAKA,EAAED,IAAIb,GAAUe,KAAK,MAAMA,KAAK,OA8C5EC,IAAK,CAAET,MAAO,MAAOC,KAAM,kBAAmBC,GAtCpC,EAAGE,OAAMC,OAAMK,QAAOC,SAAQC,QAAOC,QAAOC,WAAUC,YAChE,MACMC,EAAMZ,EAAKE,IAAI,CAACW,EAAGC,IAAMC,KAAKC,IAAI,GAAIf,EAAKgB,OAAO,CAACC,EAAGf,IAAMY,KAAKI,IAAID,EAAGf,EAAEW,GAAGM,QAASL,KAAKI,IAAI,EAAGN,EAAEO,WACpGC,EAAMT,EAAIK,OAAO,CAACK,EAAGC,IAAMD,EAAIC,EAAG,GACxC,IAAIC,EAAI,EACR,MAAMC,EAAOb,EAAIV,IAAIwB,GAAKF,GAAKT,KAAKY,MAAMD,EAAIL,EAJpC,OAMJO,EAAMC,GAAS,oBAAsBA,EAAM3B,IAAI,EAAE,CAAE4B,GAAIhB,KACpDgB,EAAE/B,GAAK,IAAM,IAAK+B,EAAEC,IAAM,IAAK7B,IAAI8B,GAAK,WAAWA,qBAAqB5B,KAAK,IAAM,UAAUqB,EAAKX,MACnGV,KAAK,IAAMyB,EAAM3B,IAAI,EAAE+B,EAAGH,KAC1B,mBAAmBA,EAAER,GAAK,MAAMQ,EAAEI,GAAK,OAAOJ,EAAEI,KAAO,MAAMJ,EAAEP,EAAI,QAAQhC,EAAO0C,MAAQ1C,EAAO0C,YACjG7B,KAAK,IAAM,UACb+B,EAAM,CAAC,wDAGb,GAFI1B,GAAO0B,EAAIC,KAAK,kBAAkB7C,EAAOkB,cACzCC,GAAUyB,EAAIC,KAAK,eAAe7C,EAAOmB,cACzCF,EAAMY,OAAQ,CAChB,MAAMS,EAAQ,GACd,IAAK,IAAIf,EAAI,EAAGA,EAAId,EAAKoB,QAAS,CAChC,MAAMY,EAAIxB,EAAM6B,KAAKL,GAAKA,EAAEM,OAASxB,GACrC,GAAKkB,EAAL,CACAH,EAAMO,KAAK,CAACJ,EAAEpC,MAAO,CAAE0B,EAAG,IAAKS,GAAI,KAAMhC,EAAG,aAC5C,IAAK,IAAIwC,EAAI,EAAGA,EAAIP,EAAEd,EAAGqB,IAAKV,EAAMO,KAAK,CAAC,GAAI,CAAEL,GAAI,KAAMhC,EAAG,aAC7De,GAAKkB,EAAEd,CAHiD,MAA9CW,EAAMO,KAAK,CAAC,GAAI,CAAEL,GAAI,OAASjB,GAI3C,CACAqB,EAAIC,KAAKR,EAAIC,GACf,CACAM,EAAIC,KAAKR,EAAI5B,EAAKE,IAAI,CAACW,EAAGC,IAAM,CAACD,EAAG,CAAES,EAAGhB,EAAMQ,GAAIS,EAAG,EAAGQ,IAAKvB,EAAMY,OAAS,GAAK,KAAO,SACzFnB,EAAKuC,QAAQ,CAACrC,EAAGsC,IAAMN,EAAIC,KAAKR,EAAIzB,EAAED,IAAI,CAAC+B,EAAGnB,IAAM,CAACmB,EAAG,CACtDX,EAAGhB,EAAMQ,GAAIoB,GAAIpB,EAAI,EAAgB,IAAZP,EAAOkC,GAAUV,GAAIU,IAAMxC,EAAKmB,OAAS,EAAI,IAAM,SAE9E,IAAK,MAAMF,KAAKP,EAAOwB,EAAIC,KAAK,iBAAiB7C,EAAO2B,cACxD,OAAOiB,EAAI/B,KAAK,IAAM,OAalBsC,EAAQ,CAACC,EAAM1C,EAAM2C,EAAMD,EAAKE,YACpC,MAAMC,EAAOH,EAAKI,MAAOd,EAAIU,EAAKK,KAAMC,EAAMN,EAAKO,QAEnD,OADAjD,IAAShB,MAAMqD,KAAK,CAAElB,OAAQwB,EAAIE,EAAK,KAAK1B,QAAU,GAAK,CAAC+B,EAAGV,IAAMA,EAAI,GAClE,CACLzC,KAAMiC,EAAEmB,OAAOlD,IAAInB,GACnBkB,KAAMA,EAAKC,IAAIC,GAAK2C,EAAK5C,IAAIV,GAAKL,OAAOyD,EAAIpD,KAAKW,EAAI,IAAM,MAC5DG,MAAO2B,EAAE3B,MAAMJ,IAAIoB,IAAK,CAAG+B,OAAQ,IAAKC,MAAO,KAAOhC,IAAM,MAC5Df,OAAQN,EAAKC,IAAIC,GAAK8C,IAAM9C,EAAI,IAAM,GACtCK,OAAQyB,EAAEsB,UAAY,IAAIrD,IAAI8B,IAAK,CACjCpC,MAAOb,EAAMiD,EAAEpC,OAAQ0C,KAAMQ,EAAKU,QAAQxB,EAAEyB,QAAQ,IAAKvC,EAAGc,EAAEyB,QAAQrC,UAExEX,MAAO1B,EAAMkD,EAAEyB,OAAOjD,OAAQC,SAAU3B,EAAMkD,EAAEyB,OAAOhD,UACvDC,OAAQsB,EAAEtB,OAAS,IAAIT,IAAInB,KAI/BJ,EAAGE,QAAQC,OAAS,CAClBY,UAASgD,QACTiB,KAAM,CAACC,EAAKjB,EAAM1C,EAAM2C,IAAQlD,EAAQkE,GAAK9D,GAAG4C,EAAMC,EAAM1C,EAAM2C,IAErE,EAnFD","ignoreList":[]}
|
package/js/lt-interactive.js
CHANGED
|
@@ -445,7 +445,7 @@
|
|
|
445
445
|
elem(el.ownerDocument, "div", { className: "lti-icons" }, headBar) : null;
|
|
446
446
|
if (opts.hide)
|
|
447
447
|
addColumnToggle(icons, el, hrow, cols, labels, opts.hide, layout, postSwap);
|
|
448
|
-
if (opts.download) addDownload(icons, el, spec,
|
|
448
|
+
if (opts.download) addDownload(icons, el, spec, opts.download);
|
|
449
449
|
// Control bar (`.lti-bar`; null if no table-wide controls) for callers to add
|
|
450
450
|
// widgets to; `chips` is its chip group (null only without a bar), home for
|
|
451
451
|
// caller chips
|
|
@@ -614,40 +614,58 @@
|
|
|
614
614
|
});
|
|
615
615
|
}
|
|
616
616
|
|
|
617
|
-
//
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
// `opt` = file name or `{file?, mode?}`; `mode: "raw"` exports `spec.data`
|
|
625
|
-
// instead of displayed text (`spec._display`). Skips group columns (null in
|
|
626
|
-
// `cols`). Uses Blob + <a>, no library.
|
|
627
|
-
function addDownload(cell, el, spec, cols, labels, opt) {
|
|
628
|
-
const doc = el.ownerDocument,
|
|
617
|
+
// Download button for the current view (all pages, `el._lt.view()`) in the
|
|
618
|
+
// formats of lt-export.js: a menu of them, or a direct download if only one.
|
|
619
|
+
// `opt` = file name or `{file?, mode?, formats?}`; `mode: "raw"` exports
|
|
620
|
+
// `spec.data` instead of displayed text. The file name is a stem: a format
|
|
621
|
+
// extension is replaced by the chosen format's. Uses Blob + <a>, no library.
|
|
622
|
+
function addDownload(cell, el, spec, opt) {
|
|
623
|
+
const doc = el.ownerDocument, X = LT.plugins.export,
|
|
629
624
|
o = typeof opt === "object" ? opt : { file: opt },
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
.replace(
|
|
633
|
-
|
|
625
|
+
fmts = o.formats ? [].concat(o.formats) : Object.keys(X.formats),
|
|
626
|
+
stem = (typeof o.file === "string" && o.file ? o.file : "lt-table")
|
|
627
|
+
.replace(new RegExp(`\\.(${Object.keys(X.formats).join("|")})$`, "i"), ""),
|
|
628
|
+
one = fmts.length === 1, name = X.formats[fmts[0]].label,
|
|
629
|
+
wrap = elem(doc, "span", { className: "lti-dl" }, cell),
|
|
634
630
|
btn = elem(doc, "button", {
|
|
635
|
-
type: "button", className: "lti-download",
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
631
|
+
type: "button", className: "lti-download",
|
|
632
|
+
title: one ? `Download ${name}` : "Download",
|
|
633
|
+
"aria-label": one ? `Download table as ${name}` : "Download table"
|
|
634
|
+
}, wrap);
|
|
635
|
+
const save = async fmt => {
|
|
639
636
|
// server mode: fetch every row of the view first
|
|
640
637
|
const all = await el._lt.server?.load(el._lt.state, true), s = all ? { ...spec, data: all.data } : spec;
|
|
641
638
|
if (all) LT.buildHtml(s);
|
|
642
|
-
const
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
new Blob([lines.join("\n")], { type: "text/csv" }));
|
|
648
|
-
elem(doc, "a", { href: url, download: file }).click();
|
|
639
|
+
const rows = all ? Array.from({ length: all.rows }, (_, i) => i + 1) : el._lt.view(),
|
|
640
|
+
url = URL.createObjectURL(new Blob(
|
|
641
|
+
[X.text(fmt, s, rows, o.mode === "raw" ? textual(s) : undefined)],
|
|
642
|
+
{ type: X.formats[fmt].mime }));
|
|
643
|
+
elem(doc, "a", { href: url, download: `${stem}.${fmt}` }).click();
|
|
649
644
|
URL.revokeObjectURL(url);
|
|
650
645
|
};
|
|
646
|
+
if (one) return btn.onclick = () => save(fmts[0]);
|
|
647
|
+
const menu = elem(doc, "div", { className: "lti-menu", hidden: true, role: "menu" }, wrap),
|
|
648
|
+
close = dropdown(doc, wrap, btn, menu);
|
|
649
|
+
for (const f of fmts) {
|
|
650
|
+
const item = elem(doc, "label", { textContent: X.formats[f].label, role: "menuitem", tabIndex: 0 }, menu);
|
|
651
|
+
item.onclick = () => { close(); save(f); };
|
|
652
|
+
item.onkeydown = e => { if (e.key === "Enter" || e.key === " ") { e.preventDefault(); item.click(); } };
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
|
|
656
|
+
// Open/close the popup `menu` from `btn`; it closes on an outside click or
|
|
657
|
+
// Escape. Returns the closer.
|
|
658
|
+
function dropdown(doc, wrap, btn, menu) {
|
|
659
|
+
const open = on => {
|
|
660
|
+
menu.hidden = !on;
|
|
661
|
+
btn.setAttribute("aria-expanded", String(on));
|
|
662
|
+
};
|
|
663
|
+
open(false);
|
|
664
|
+
btn.onclick = e => { e.stopPropagation(); open(menu.hidden); };
|
|
665
|
+
btn.onkeydown = e => { if (e.key === "Enter" || e.key === " ") { e.preventDefault(); btn.click(); } };
|
|
666
|
+
on(doc, "click", e => { if (!wrap.contains(e.target)) open(false); });
|
|
667
|
+
on(doc, "keydown", e => { if (e.key === "Escape") open(false); });
|
|
668
|
+
return () => open(false);
|
|
651
669
|
}
|
|
652
670
|
|
|
653
671
|
// Cycle a column asc -> desc -> unsorted in `state.sort`. Plain click sorts by
|
|
@@ -1066,7 +1084,6 @@
|
|
|
1066
1084
|
type: "button", title: "Show/Hide columns",
|
|
1067
1085
|
"aria-label": "Show/Hide columns"
|
|
1068
1086
|
});
|
|
1069
|
-
btn.setAttribute("aria-expanded", "false");
|
|
1070
1087
|
wrap.append(btn);
|
|
1071
1088
|
const menu = elem(doc, "div", { className: "lti-menu", hidden: true }, wrap);
|
|
1072
1089
|
// checkbox per column; `sub` indents under a spanner header
|
|
@@ -1092,14 +1109,7 @@
|
|
|
1092
1109
|
for (let i = c._start; i < c._start + c._span; i++) addBox(i, span);
|
|
1093
1110
|
} else cols.forEach((_, i) => addBox(i));
|
|
1094
1111
|
cols.forEach((_, i) => apply(i)); // apply initially hidden columns
|
|
1095
|
-
|
|
1096
|
-
menu.hidden = !on;
|
|
1097
|
-
btn.setAttribute("aria-expanded", String(on));
|
|
1098
|
-
};
|
|
1099
|
-
btn.onclick = e => { e.stopPropagation(); open(menu.hidden); };
|
|
1100
|
-
btn.onkeydown = e => { if (e.key === "Enter" || e.key === " ") { e.preventDefault(); btn.click(); } };
|
|
1101
|
-
on(doc, "click", e => { if (!wrap.contains(e.target)) open(false); });
|
|
1102
|
-
on(doc, "keydown", e => { if (e.key === "Escape") open(false); });
|
|
1112
|
+
dropdown(doc, wrap, btn, menu);
|
|
1103
1113
|
}
|
|
1104
1114
|
|
|
1105
1115
|
// --- Typed column filters (`filter` named-list form). A typed spec is
|
package/js/lt-interactive.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(t=>{"use strict";const e=t.LT;if(!e?.onMount||e.plugins.interactive)return;const n=e.plugins.query;let s;const l=t=>"string"!=typeof t?{...t}:"-"===t[0]?{col:t.slice(1),dir:"desc"}:{col:t,dir:"asc"},o=(t,e,n)=>(s||=new Intl.Collator,n?t-e:s.compare(String(t),String(e))),{$:r,$$:a,on:i,off:c,numCol:u,dateFmt:d}=e,p=t=>{const e=t.data||{};if(t._txt?.d!==e){const n={...e};for(const s in e){const l=d(e[s]);(l||t.dates?.includes(s))&&(n[s]=Object.assign(e[s].map(t=>null!=t&&l?l(t):t),{date:!0}))}t._txt={d:e,t:n}}return t._txt.t},f=t=>[...t.children].filter(t=>!t.classList.contains("lt-row-group")),h=t=>{const e=[...t.childNodes],n=e.findIndex(t=>"BR"===t.nodeName);return n<0?e:e.slice(0,n)};function m(t,e,n={},s){const l=t.createElement(e);for(const t in n)t.includes("-")?l.setAttribute(t,n[t]):l[t]=n[t];return s?s.appendChild(l):l}function g(t,e,n){t.preventDefault();const s=t.target.ownerDocument||document,l=t=>e(t);i(s,"pointermove",l),i(s,"pointerup",()=>{c(s,"pointermove",l),n&&n()},{once:!0})}function w(t){const e=String(t??"").trim();if(""===e)return null;if(/(^|[^\w$])x([^\w$]|$)/.test(e)){let t;try{t=new Function("x",`return (${e});`)}catch(t){}if(t){const n=/^\s*!|!=/.test(e),s=e=>{try{if(null==e)return n||!!t(void 0);const s=Number(e);return!!t(String(e))||""!==e&&isFinite(s)&&!!t(s)}catch(t){return!1}};return t=>t[n?"every":"some"](t=>s(t.raw))}}const n="!"===e[0],s=(n?e.slice(1).trim():e).toLowerCase();return""===s?null:t=>n!==t.some(t=>null!=t.disp&&String(t.disp).toLowerCase().includes(s))}function b(t,e,n){const s=t._cols||[],l=t.data||{},r=p(t),a=(l[s[0]]||[]).length,i=(t,n)=>({raw:r[t]?.[n-1]??null,disp:e[t]?.[n-1]??""}),c=[],d=t=>{if(t.op){const e=t.items.map(d);return"and"===t.op?t=>e.every(e=>e(t)):t=>e.some(e=>e(t))}const e=w(t.term);return e?null!=t.col?n=>e([i(t.col,n)]):t=>e(s.map(e=>i(e,t))):()=>!0};for(const t in n.filters||{}){const e=n.filters[t];c.push(d("string"==typeof e?{col:t,term:e}:e))}n.where&&c.push(d(n.where));const f=w(n.term);f&&c.push(t=>f(s.map(e=>i(e,t))));const h=Object.values(n.predicates||{});if(h.length){const t=Object.keys(l),e=e=>Object.fromEntries(t.map(t=>[t,l[t]?.[e-1]??null]));c.push(t=>{const n=e(t);return h.every(t=>t(n))})}const m=t=>c.every(e=>e(t)),g=t=>{const e=t.map(t=>{const e=r[t.col];return e&&{col:e,num:u(e),dir:"desc"===t.dir?-1:1}}).filter(Boolean);return e.length?(t,n)=>{for(const{col:s,num:l,dir:r}of e){const e=s[t-1],a=s[n-1],i=null==e,c=null==a;if(i||c){if(i!==c)return i?1:-1;continue}const u=o(e,a,l);if(u)return r*u}return 0}:null},b=t._indent,y=(t,e)=>{if(!b){const n=t.filter(m);return e?n.sort(e):n}const n=[],s=[];for(const e of t){const t={r:e,kids:[]},l=b[e-1]||0;for(;s.length&&s[s.length-1].lv>=l;)s.pop();(s.length?s[s.length-1].node.kids:n).push(t),s.push({node:t,lv:l})}const l=t=>t.map(t=>{const e=l(t.kids);return m(t.r)||e.length?{r:t.r,kids:e}:null}).filter(Boolean),o=t=>(e&&t.sort((t,n)=>e(t.r,n.r)),t.forEach(t=>o(t.kids)),t),r=[],a=t=>t.forEach(t=>{r.push(t.r),a(t.kids)});return a(o(l(n))),r},x=()=>Array.from({length:a},(t,e)=>e+1),v=t._rowspan;if(v){const t={},e=[];for(const s of n.sort||[])v.includes(s.col)?t[s.col]=s.dir:e.push(s);const s=g(e),l=(e,n)=>{if(n===v.length)return y(e,s);const a=r[v[n]],i=new Map;for(const t of e){const e=a[t-1],n=null==e?"\0":String(e);(i.get(n)||i.set(n,{v:e,rows:[]}).get(n)).rows.push(t)}let c=[...i.values()];if(t[v[n]]){const e=u(a),s="desc"===t[v[n]]?-1:1;c.sort((t,n)=>{const l=null==t.v,r=null==n.v;return l||r?l===r?0:l?1:-1:s*o(t.v,n.v,e)})}return c.flatMap(t=>l(t.rows,n+1))};return l(x(),0)}const $=g(n.sort||[]),N=t._groups;if(!N)return y(x(),$);const k=new Set,M=[];for(const t of N)t.rows.forEach(t=>k.add(t)),M.push(...y(t.rows,$));const S=[];for(let t=1;t<=a;t++)k.has(t)||S.push(t);return[...M,...y(S,$)]}function y(t,e){const n=e.pageSize;if(!n)return e.page=0,t;const s=Math.max(0,Math.ceil(t.length/n)-1);return e.page=Math.min(Math.max(e.page||0,0),s),t.slice(e.page*n,(e.page+1)*n)}function x(s,o){const c=o.interactive,u=o._cols||[],d=o.data||{},w=c.data_url&&e.plugins.server?.(c,o),x=w?c.data_n||0:(d[u[0]]||[]).length,k={},E=w?w.sum:t=>k[t]||=function(t,e){const n=t.filter(t=>null!=t),s=new Map,l={len:t.length,na:t.length-n.length,some:n.some(t=>""!==t),kind:t.date?"date":n.every(t=>"number"==typeof t)?"num":n.every(t=>"string"==typeof t)?"str":"mix"};for(const t of n)s.set(t,(s.get(t)||0)+1);l.m=s.size;const o=n.map(Number).filter(Number.isFinite),r=o.reduce((t,e)=>t+e,0);l.int=o.every(Number.isInteger),o.length&&(l.lo=o.reduce((t,e)=>Math.min(t,e)),l.hi=o.reduce((t,e)=>Math.max(t,e)),l.mean=r/o.length);let a;Object.defineProperty(l,"vals",{get:()=>a||=[...s.keys()].sort((t,e)=>"number"==typeof t&&"number"==typeof e?t-e:String(t).localeCompare(String(e)))}),t.date&&(l.lo=l.vals[0],l.hi=l.vals.at(-1),delete l.mean);if(!e)return l;const i=e=>t.date?Date.parse(e.replace(" ","T")):e,c=n.map(i),u=n.length&&c.every(Number.isFinite);let d=0,p=()=>-1;if(u){const t=c.reduce((t,e)=>Math.min(t,e)),e=c.reduce((t,e)=>Math.max(t,e));d=Math.min(T,s.size),p=n=>Math.min(d-1,Math.floor((i(n)-t)/(e-t||1)*d))}else if(n.length&&s.size<=n.length/2){const t=[...s].sort((t,e)=>e[1]-t[1]),e=new Map(t.map((t,e)=>[t[0],e]));l.top=t.slice(0,5),d=t.length,p=t=>e.get(t)??-1}return l.bar=d?t.map(t=>null==t?-1:p(t)):[],l.count=t=>{const e=Array(d).fill(0);for(const n of t)l.bar[n-1]>=0&&e[l.bar[n-1]]++;return e},l.bins=l.count(t.map((t,e)=>e+1)),l}(p(o)[t]||[],!0),_=o._groups,C={},L=_?[]:null;if(_){const t=new Set;_.forEach(e=>e.rows.forEach(n=>{C[n]=e,L.push(n),t.add(n)}));for(let e=1;e<=x;e++)t.has(e)||L.push(e)}const A=o._rowspan?o._rowspan.length:0,D=A?[...o._rowspan,...u]:u,F=A+u.length,P=o._display||function(t,e,n){const s={};e.forEach(t=>s[t]=[]);let l=0;return a(t,"tbody tr").forEach(t=>{if(t.classList.contains("lt-row-group"))return;const o=n?n[l]:l+1,r=f(t);e.forEach((t,e)=>s[t][o-1]=r[e]?.textContent??""),l++}),s}(s,u,L),I=[...a(s,"thead tr")].pop(),U={filters:{},predicates:{},paints:[],page:0,pageSize:0,sort:Array.isArray(c.sort)?c.sort.map(l):[]};let V,q=()=>{};const W=[],X=(t=!0)=>{if(w)return t&&(U.page=0),(()=>{const t=s.closest(".lt-wrap");return t?.classList.add("lti-busy"),w.load(U).then(e=>{e&&(t?.classList.remove("lti-busy"),o.data=e.data,U.page=e.page,U.paints.forEach(t=>t(null,U.prof=e.prof)),s._lt.clearDetail?.(),K(Array.from({length:Object.values(e.data)[0]?.length??0},(t,e)=>e+1),e.n))},e=>{t?.classList.remove("lti-busy"),console.error(e)})})();t&&(V=U.view=b(o,P,U),U.page=0,U.paints.forEach(t=>t(V,U.prof))),K(y(V,U),V.length)},K=(t,n)=>{const l=(t=>{if(!_)return t;const e=[];let n;for(const s of t){const t=C[s];t!==n&&(t&&e.push({label:t.label,raw:t.raw}),n=t),e.push(s)}return e})(t),a={...o,_viewRows:l},i=m(s.ownerDocument,"template",{innerHTML:e.buildHtml(a)});w&&(o._display=a._display);const c=r(i.content,"tbody");t.length?W.forEach(t=>t(c,l)):c.innerHTML=`<tr class="lti-empty"><td colspan="${F}">—</td></tr>`,r(s,"tbody").replaceWith(c),q(n)},G=M(s.closest(".lt-wrap"),(t=!0)=>X(t));let Q=!0,Z=!1;const tt=(t=!0)=>{Q?Z=!0:G(t)};s._lt={spec:o,state:U,server:w,refresh:(t=!0)=>G(t),view:()=>V||b(o,P,U),filter(t,e){e?U.predicates[t]=e:delete U.predicates[t],G()}};const et=c.filter,st=et?.cols?Object.keys(et.cols).filter(t=>et.cols[t]?.type&&"auto"!==et.cols[t].type&&!u.includes(t)):[],lt=!1!==c.search||c.hide||st.length||c.download?m(s.ownerDocument,"div",{className:"lti-bar"},N(s.tHead||s.createTHead(),"lti-head",F,0)):null,ot=f(I).map(t=>h(t).map(t=>t.textContent).join("")),rt=t=>ot[u.indexOf(t)]||t,at=Object.fromEntries(u.flatMap(t=>null==t?[]:[[t,t],[rt(t),t]]));!1!==c.sort&&function(t,e,n,s){const l=t.ownerDocument,o={},r=()=>{for(const t in o)o[t].th.removeAttribute("aria-sort"),o[t].ind.textContent="";const t=n.sort||[];t.forEach(({col:e,dir:n},s)=>{const l=o[e];l&&(l.th.setAttribute("aria-sort","desc"===n?"descending":"ascending"),l.ind.textContent=("desc"===n?"▼":"▲")+(t.length>1?String(s+1).replace(/\d/g,t=>"₀₁₂₃₄₅₆₇₈₉"[t]):""))})};a(t,"th").forEach((t,a)=>{const i=e[a];if(null==i)return;t.classList.add("lti-sortable");const c=h(t),u=m(l,"span",{className:"lti-label"}),d=m(l,"span",{className:"lti-sort"});t.prepend(u,d),u.append(...c),o[i]={th:t,ind:d},u.onclick=d.onclick=t=>{!function(t,e,n){const s=(t.sort||[]).slice(),l=s.findIndex(t=>t.col===e),o=l<0?"asc":"asc"===s[l].dir?"desc":null;if(!n)return void(t.sort=o?[{col:e,dir:o}]:[]);l<0?s.push({col:e,dir:o}):o?s[l]={col:e,dir:o}:s.splice(l,1);t.sort=s}(n,i,t.shiftKey),r(),s()}}),r()}(I,D,U,tt),"header"===c.profile&&function(t,e,n,s){const l=f(t);e.forEach((e,o)=>{l[o].append(m(t.ownerDocument,"br"),B(t.ownerDocument,n(e),s,e))})}(I,u,E,U),et&&(et.default||et.cols&&Object.keys(et.cols).some(t=>et.cols[t]&&u.includes(t)))&&function(t,e,s,l,o,r,a){const i=t.ownerDocument,c=f(t),u=s.default,d=s.cols||{};e.forEach((t,e)=>{const s=c[e],p=t in d,f=H(p?d[t]:u,l(t));if(null!=f&&(!1!==f||p)&&J(l(t))){if(m(i,"br",{},s),!1===f)return m(i,"button",{type:"button",className:"lti-funnel lti-off",disabled:!0},m(i,"span",{className:"lti-pop"},s));if(!0===f){const e=s.appendChild(v(i,`Filter ${t}`,$)),a=m(i,"div",{className:"lti-nl"});e.after(a),z(e,()=>j(l(t).vals),a),S(e,e=>{const s=n.parse(e,{},t);s?o.filters[t]=s:delete o.filters[t],a.textContent=n.parsed(s)?n.text(s,()=>null):"",r()})}else s.append(nt(i,t,f,l,o,r,null,a))}})}(I,u,et,E,U,tt,"filter"===c.profile);const it=c.resize?function(t,e,n,s=0){const l=[...a(e,"th")],o=function(t,e,n=0){let s=r(t,"colgroup");if(!s){const l=t.ownerDocument;s=m(l,"colgroup");for(let t=0;t<n+e;t++)m(l,"col",{},s);t.caption?t.caption.after(s):t.prepend(s)}return[...s.children]}(t,n,s),i=t=>t.getBoundingClientRect().width,c=()=>{if(t.classList.contains("lti-fixed"))return;const e=l.map(i);t.style.width=i(t)+"px",o.forEach((t,n)=>t.style.width=e[n]+"px"),t.classList.add("lti-fixed")},u=e=>{const n=o.map(t=>t.style.width),s=t.style.width;o.forEach(t=>t.style.width=""),t.style.width="",t.classList.remove("lti-fixed");const r=i(l[e]);return o.forEach((t,e)=>t.style.width=n[e]),t.style.width=s,t.classList.add("lti-fixed"),r},d=(e,n,s=24)=>{const l=parseFloat(o[e].style.width);o[e].style.width=Math.max(n,s)+"px",t.style.width=parseFloat(t.style.width)+parseFloat(o[e].style.width)-l+"px"};return{ths:l,cs:o,dataCs:o.slice(s),freeze:c,natural:u,setWidth:d}}(s,I,u.length,A):null;c.resize&&function(t,e){const n=t.ownerDocument,{ths:s,cs:l,freeze:o,natural:r,setWidth:a}=e;s.forEach((e,s)=>{const i=m(n,"div",{className:"lti-resizer"},e);i.ondblclick=t=>{t.stopPropagation(),o(),a(s,r(s))},i.onpointerdown=e=>{e.stopPropagation(),o();const n=e.clientX,r=parseFloat(l[s].style.width);t.classList.add("lti-resizing"),g(e,t=>a(s,r+t.clientX-n),()=>t.classList.remove("lti-resizing"))}})}(s,it),!1!==c.search&&function(t,e,s,l,o,r,a){const i=e.ownerDocument,c=t.appendChild(v(i,"Search")),u=m(i,"div",{className:"lti-nl"});t.after(u),z(c,a,u),S(c,t=>{const e=n.parse(t,o);s.where=e,u.textContent=n.parsed(e)?n.text(e,r):"",l()})}(lt,s,U,tt,at,rt,()=>O(p(o),u,rt));const ct=lt?m(s.ownerDocument,"div",{className:"lti-chips"},lt):null;st.length&&function(t,e,n,s,l,o,r){const a=t.ownerDocument;for(const i of e)t.append(nt(a,i,n[i],s,l,o,n[i].label||i,r))}(ct,st,et.cols,E,U,tt,"filter"===c.profile);const ut=c.hide||c.download?m(s.ownerDocument,"div",{className:"lti-icons"},lt):null;if(c.hide&&function(t,e,n,s,l,o,r,a){const c=e.ownerDocument,u=o&&o.hidden||[],d=new Set,p=(t,e,n)=>{const s=f(t)[e];s&&1===s.colSpan&&(s.hidden=n)};a.push(t=>d.forEach(e=>{for(const n of t.rows)p(n,e,!0)}));const h=[...n.children].length-f(n).length,g=[...e.rows].find(t=>t.classList.contains("lt-spanner-row")),w=g?f(g).slice(h):[];let b=0;w.forEach(t=>{t._span=t.colSpan,t._start=b,b+=t._span});const y=()=>{for(const t of w){let e=0;for(let n=t._start;n<t._start+t._span;n++)d.has(n)&&e++;t.colSpan=Math.max(1,t._span-e),t.hidden=e>=t._span}},x=t=>{const n=d.has(t);r?.dataCs[t]&&(r.dataCs[t].hidden=n);for(const s of e.rows)s.classList.contains("lt-spanner-row")||p(s,t,n);y()},v=m(c,"span",{className:"lti-cols"},t),$=o?.label?Object.assign(Y(c,o.label).el,{role:"button",tabIndex:0}):m(c,"button",{type:"button",title:"Show/Hide columns","aria-label":"Show/Hide columns"});$.setAttribute("aria-expanded","false"),v.append($);const N=m(c,"div",{className:"lti-menu",hidden:!0},v),k=(t,e)=>{const n=s[t];if(null==n)return;const o=m(c,"label",e?{className:"lti-sub"}:{},N),r=m(c,"input",{type:"checkbox",checked:!0},o);o.append(l[t]??n),u.includes(n)&&(r.checked=!1,d.add(t)),r.onchange=()=>{r.checked?d.delete(t):d.add(t),x(t)}};if(w.length)for(const t of w){const e=t.classList.contains("lt-spanner");e&&m(c,"div",{className:"lti-group",textContent:t.textContent},N);for(let n=t._start;n<t._start+t._span;n++)k(n,e)}else s.forEach((t,e)=>k(e));s.forEach((t,e)=>x(e));const M=t=>{N.hidden=!t,$.setAttribute("aria-expanded",String(t))};$.onclick=t=>{t.stopPropagation(),M(N.hidden)},$.onkeydown=t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),$.click())},i(c,"click",t=>{v.contains(t.target)||M(!1)}),i(c,"keydown",t=>{"Escape"===t.key&&M(!1)})}(ut,s,I,u,ot,c.hide,it,W),c.download&&function(t,n,s,l,o,r){const a=n.ownerDocument,i="object"==typeof r?r:{file:r},c="raw"===i.mode,u=("string"==typeof i.file&&i.file?i.file:"table").replace(/(\.csv)?$/i,".csv"),d=l.map((t,e)=>e).filter(t=>null!=l[t]);m(a,"button",{type:"button",className:"lti-download",title:"Download CSV","aria-label":"Download table as CSV"},t).onclick=async()=>{const t=await(n._lt.server?.load(n._lt.state,!0)),r=t?{...s,data:t.data}:s;t&&e.buildHtml(r);const i=(c?p(r):r._display)||{},f=[d.map(t=>R(o[t]??l[t])).join(",")];for(const e of t?Array.from({length:t.rows},(t,e)=>e+1):n._lt.view())f.push(d.map(t=>R((i[l[t]]||[])[e-1])).join(","));const h=URL.createObjectURL(new Blob([f.join("\n")],{type:"text/csv"}));m(a,"a",{href:h,download:u}).click(),URL.revokeObjectURL(h)}}(ut,s,o,u,ot,c.download),s._lt.bar=lt,s._lt.chips=ct,c.detail){const n=function(n,s,l,o,a,i){const c=n.ownerDocument,u={};o.expanded=new Set;const d=(t,e)=>{const n={};for(const s in t)n[s]=t[s]?.[e-1]??null;return n},p=e=>{if(e in u)return u[e];const n=d(s._display||{},e);let l=null;if(Array.isArray(a)){const t={};for(const e of a)t[e]=[n[e]??null];l={data:t}}else{const o="function"==typeof a?a:t[a];"function"==typeof o&&(l=o(d(s.data||{},e),e,n))}return u[e]=l},h=n.closest(".lt-wrap"),g=M(h,t=>t()),w=(t,e)=>{t.textContent=e?"▾":"▸",t.setAttribute("aria-expanded",String(e))},b=(t,n)=>{const s=p(n);if(!s)return null;const o=m(c,"tr",{className:"lti-detail",hidden:!0});return t.after(o),e.render(m(c,"div",{},m(c,"td",{colSpan:l},o)),s),o},y=(t,e)=>{const n=t.nextElementSibling;return n?.classList.contains("lti-detail")?n:b(t,e)};let x=0;const v=()=>{const t=Math.ceil(n.getBoundingClientRect().width);t>x&&t>(parseFloat(n.style.width)||0)&&(n.style.width=t+"px")},$=(t,e,n)=>{const s=o.expanded.has(n);s?o.expanded.delete(n):o.expanded.add(n),w(e,!s);const l=y(t,n);l&&(l.hidden=s,s||v())},N=c.defaultView,k=N.requestIdleCallback||N.setTimeout,S=t=>k(()=>{if(!t.isConnected)return;n.style.width="",x=n.getBoundingClientRect().width;const e=r(t,".lti-expand[aria-expanded='false']");e&&(e.click(),v(),e.click())}),E=(t,e)=>{[...t.rows].forEach((t,n)=>{const s=e[n];if("number"!=typeof s)return;const l=f(t)[0],r=o.expanded.has(s);if(!l)return;const a=m(c,"button",{type:"button",className:"lti-expand","aria-label":"Toggle detail"});if(w(a,r),a.onclick=()=>$(t,a,s),l.prepend(a),r){const e=y(t,s);e&&(e.hidden=!1)}}),S(t)};return E.clear=()=>{o.expanded.clear();for(const t in u)delete u[t]},E.reset=t=>{if(null==t)for(const t in u)delete u[t];else delete u[t];g(i)},E}(s,o,F,U,c.detail,()=>X(!1));W.push(n),s._lt.resetDetail=n.reset,s._lt.clearDetail=n.clear}if(Q=!1,c.pager){const t=Array.isArray(c.pager)?c.pager:[10,25,50,100];q=function(t,e,n,s,l,o){const r=t.ownerDocument;let a=t.tFoot;a||((a=t.createTFoot()).className="lt-footer");const i=m(r,"div",{className:"lti-pager"},N(a,"lti-pager-row",e,-1)),c=m(r,"span",{className:"lti-pos"});l.pageSize=n[0];const u=[()=>0,t=>t-1,t=>t+1,()=>1e9],d=["«","‹","›","»"].map((t,e)=>{const n=m(r,"button",{type:"button",textContent:t,"aria-label":["First","Previous","Next","Last"][e]},i);return n.onclick=()=>{l.page=u[e](l.page),o()},n});if(i.append(c),n.length>1&&s>Math.min(...n.filter(t=>t>0))){const t=m(r,"select",{"aria-label":"Rows per page"},i);n.forEach(e=>m(r,"option",{value:e,textContent:e||"∞"},t)),t.onchange=()=>{l.pageSize=+t.value,l.page=0,o()}}return t=>{const e=l.pageSize||t||1,n=Math.max(0,Math.ceil(t/e)-1),o=t<s?` (${s})`:"";c.textContent=(t?`${l.page*e+1}–${Math.min(t,(l.page+1)*e)} / ${t}`:"0 / 0")+o,d.forEach((t,e)=>t.disabled=e<2?!l.page:l.page===n)}}(s,F,t,x,U,()=>X(!1)),X()}else(U.sort.length||c.detail||Z)&&X()}function v(t,e,n=""){return m(t,"input",{type:"search",className:"lti-search","aria-label":e,title:n})}const $="Type a condition, or an expression where x stands for each value in this column, e.g. x > 5 && x < 9";function N(t,e,n,s){const l=t.insertRow(s);return l.className=e,m(t.ownerDocument,"td",{colSpan:n},l)}function k(t,e=400){let n;const s=()=>{clearTimeout(n),n=setTimeout(t,e)};return s.now=()=>{clearTimeout(n),t()},s}function M(t,e){let n,s=0;const l=t=>{const n=performance.now();e(t),s=performance.now()-n};return e=>{if(!t||s<120)return l(e);t.classList.add("lti-busy"),cancelAnimationFrame(n),n=requestAnimationFrame(()=>requestAnimationFrame(()=>{try{l(e)}finally{t.classList.remove("lti-busy")}}))}}function S(t,e){const n=k(()=>e(t.value),1e3);t.oninput=t=>t.inputType&&"insertReplacementText"!==t.inputType?n():n.now(),t.onchange=n.now}const E=t=>/[\s,;:"]/.test(t)?`"${t}"`:String(t),_=t=>t[Math.floor(Math.random()*t.length)],C=t=>t?.some(t=>null!=t&&""!==t),L=t=>{const e=t.filter(t=>null!=t).sort((t,e)=>t-e);return t=>+e[Math.floor((e.length-1)*t)].toPrecision(3)},A=t=>{const e=new Set;for(let n=0;n<30&&e.size<6;n++)e.add(t(n));return[...e]},D=(t,e)=>{if(u(t)){const n=L(t);return _([`${e}over ${n(.5)}`,`${e}under ${n(.5)}`,`${e}at least ${n(.75)}`,`${e}between ${n(.25)} and ${n(.75)}`,`${e}> ${n(.5)}`,`${e}<= ${n(.25)}`,`${e}!= ${n(.5)}`])}const n=[...new Set(t.filter(Boolean))],s=E(_(n)),l=E(_(n));return _([`${e}is ${s}`,`${e}is not ${s}`,`${e}contains ${s}`,`${e}does not contain ${s}`,`${e}is ${s} or ${e}is ${l}`,`${e}== ${s}`,`${e}!= ${s}`])},O=(t,e,n)=>{const s=e.filter(e=>C(t[e])),l=s.filter(e=>u(t[e])),o=s.filter(e=>!u(t[e])),r=e=>{const s=_(e);return D(t[s],`${E(n(s))} `)},a=[l.length&&(()=>r(l)),o.length&&(()=>r(o)),l.length&&o.length&&(()=>`${r(l)}${_([", "," and "])}${r(o)}`)].filter(Boolean);return a.length?A(t=>a[t%a.length]()):[]},j=t=>C(t)?A(e=>e%3==2?(t=>{if(u(t)){const e=L(t);return _([`x > ${e(.25)} && x < ${e(.75)}`,`x < ${e(.25)} || x > ${e(.75)}`])}const e=[...new Set(t.filter(Boolean))],n=JSON.stringify(_(e)),s=JSON.stringify(_(e));return _([`x == ${n} || x == ${s}`,`x != ${n} && x != ${s}`])})(t):D(t,"")):[];let F=0;function z(t,e,n=t){const s=t.ownerDocument,l=m(s,"datalist",{id:"lti-tips-"+ ++F});t.setAttribute("list",l.id),n.after(l);const o=()=>{const t=e();return l.replaceChildren(...t.map(t=>m(s,"option",{value:t}))),t},[r]=o();r&&(t.placeholder=`e.g. ${r}`),t.addEventListener("focus",o)}function R(t){const e=null==t?"":String(t);return/[",\n]/.test(e)?'"'+e.replace(/"/g,'""')+'"':e}const T=10;function B(t,e,n,s){const l=(t,e)=>+t.toPrecision(e),o=e.bins,r=Math.max(...o),a=m(t,"span",{className:"lti-prof"}),i=o.length?e.top?[e.m>5&&`${e.m+(e.na>0)} distinct`,(e.m>5?"top ":"")+e.top.map(([t,e])=>`${t} (${e})`).join(", "),e.na&&`${e.na} NA`]:"date"===e.kind?[`min ${e.lo}`,`max ${e.hi}`,e.na&&`${Math.round(100*e.na/e.len)}% NA`]:[`min ${l(e.lo,6)}`,`max ${l(e.hi,6)}`,`mean ${l(e.mean,4)}`,e.na&&`${Math.round(100*e.na/e.len)}% NA`]:[],c=(t,e)=>t.map((t,n)=>`<rect${e} x="${n}" y="${1-t/r}" width=".9" height="${t/r}"/>`).join(""),u=(t,n)=>{const l=n?.[s]||t?.length<e.len&&e.count?.(t);a.innerHTML=`<svg viewBox="0 0 ${o.length||1} 1" preserveAspectRatio="none">${c(o,"")}${l?c(l,' class="s"'):""}</svg>`};return a.title=i.filter(Boolean).join("; "),n.paints.push(u),u(n.view,n.prof),a}const H=(t,e)=>{if("auto"!==t?.type)return t;return("num"===e.kind||"date"===e.kind?e.m>1&&{type:"range"}:"str"===e.kind&&e.m<=10&&{type:"checklist"})||{type:"text"}},J=t=>t.some;const P="\0NA",I=t=>""===t?"":t===P?"x == null":`x == ${JSON.stringify(String(t))}`,U=t=>{const e=/^\s*x\s*==\s*(?:(['"])([\s\S]*)\1|null)\s*$/.exec(t||"");return e?e[1]?e[2]:P:null},V=(t,e,n,s,l)=>t<=n&&e>=s?"":l?`x >= ${JSON.stringify(l[t])} && x <= ${JSON.stringify(l[e])}`:`x >= ${t} && x <= ${e}`,q=(t,e)=>{const n=/^\s*x\s*>=\s*("[^"]*"|-?[\d.]+)\s*&&\s*x\s*<=\s*("[^"]*"|-?[\d.]+)\s*$/.exec(t||"");if(!n)return null;const s=t=>'"'!==t[0]?parseFloat(t):e?e.indexOf(JSON.parse(t)):NaN,l=[s(n[1]),s(n[2])];return l.some(t=>!isFinite(t)||e&&t<0)?null:l},W=(t,e)=>e.labels?`${e.labels[t[0]]} – ${e.labels[t[1]]}`:`${t[0]} – ${t[1]}`,X=(t,e)=>{if(t.length===e.length)return"";const n=t.map(t=>t===P?null:String(t));return`${JSON.stringify(n)}.includes(x${n.includes(null)?" ?? null":""})`},K=t=>{const e=/^\s*(\[[\s\S]*\])\.includes\(\s*x\s*(?:\?\?\s*null\s*)?\)\s*$/.exec(t||"");if(!e)return null;try{return JSON.parse(e[1]).map(t=>null===t?P:t)}catch(t){return null}};function G(t,e){if("select"===t.type||"checklist"===t.type){let n=t.choices??e.vals.map(t=>({value:String(t),label:String(t)}));return e.na&&(n=[...n,{value:P,label:"NA"}]),"select"!==t.type||n.some(t=>""===t.value)||(n=[{value:"",label:""},...n]),{...t,choices:n}}if("range"===t.type&&"date"===e.kind){const n=e.vals;return{...t,labels:n,min:0,max:n.length-1,step:1}}let{min:n,max:s,step:l}=t;const o=e.lo??0,r=e.hi??1;null==l&&(l=function(t,e){if(!(t>0&&isFinite(t)))return e?1:.1;const n=t/100,s=Math.pow(10,Math.floor(Math.log10(n))),l=[1,2,5,10].find(t=>t*s>=n)*s;return e?Math.max(1,Math.round(l)):l}((s??r)-(n??o),e.int));const a=t=>Math.round(1e9*t)/1e9;return null==n&&(n=a(Math.floor(o/l)*l)),null==s&&(s=a(Math.ceil(r/l)*l)),{...t,min:n,max:s,step:l}}function Q(t,e,n){const s=e.map(e=>{const n=m(t,"label",{className:"lti-check"}),s=m(t,"input",{type:"checkbox",checked:!0,value:e.value},n);return n.append(e.label),{o:e,box:s,label:n}}),l=()=>n(s.filter(t=>t.box.checked).map(t=>t.o.value));return s.forEach(t=>t.box.onchange=l),{el:s.map(t=>t.label),set:t=>s.forEach(e=>e.box.checked=t.includes(e.o.value))}}function Y(t,e,n){const s=m(t,"span",{className:"lti-chip"});m(t,"span",{className:"lti-chip-name",textContent:e},s);const l=m(t,"span",{className:"lti-chip-cur"},s);return n&&s.append(n),{el:s,mark:t=>s.classList.toggle("lti-on",!!t),summarize:t=>l.textContent=t}}function Z(t,e,n,s){const l=e.min,o=e.max,r=o-l||1,a=e.step||r/100,i=m(t,"div",{className:"lti-slider"}),c=m(t,"div",{className:"lti-slider-fill"},i),u=e=>m(t,"button",{type:"button",className:"lti-thumb",role:"slider","aria-label":e,"aria-valuemin":l,"aria-valuemax":o},i),d=[u("Minimum"),u("Maximum")];let p=[l,o];const f=k(()=>n(p.slice())),h=t=>p[0]!==t[0]||p[1]!==t[1],w=t=>(t-l)/r*100,b=()=>{d.forEach((t,e)=>{t.style.left=w(p[e])+"%",t.setAttribute("aria-valuenow",p[e])}),c.style.left=w(p[0])+"%",c.style.right=100-w(p[1])+"%"},y=(t,e)=>{p[t]=(t=>{const e=Math.round((t-l)/a)*a+l;return Math.min(o,Math.max(l,Math.round(1e6*e)/1e6))})(e),p[0]>p[1]&&(p=[Math.min(...p),Math.max(...p)]),b(),s&&s(p.slice())};return d.forEach((t,e)=>{t.onpointerdown=n=>{t.focus();const s=p.slice();g(n,t=>y(e,(t=>{const e=i.getBoundingClientRect();return l+r*Math.min(1,Math.max(0,(t-e.left)/e.width))})(t.clientX)),()=>h(s)&&f.now())},t.onkeydown=t=>{const n={ArrowLeft:-1,ArrowDown:-1,ArrowRight:1,ArrowUp:1}[t.key],s=p.slice();if(n)y(e,p[e]+n*a);else if("Home"===t.key)y(e,l);else{if("End"!==t.key)return;y(e,o)}h(s)&&f(),t.preventDefault()}}),b(),{el:i,set:t=>{p=t.slice(),b()}}}function tt(t,e,n,s,l){const o=m(t,"span",{className:"lti-pop"}),r=m(t,"button",{type:"button",className:"lti-funnel",title:e,"aria-label":e,"aria-expanded":"false"},o),a=m(t,"div",{className:"lti-pop-panel",hidden:!0},o);n(a);const c=e=>{const n=!a.hidden;a.hidden=!e,r.setAttribute("aria-expanded",String(e)),e?(()=>{a.style.left=a.style.right="";const e=(t.defaultView||window).innerWidth,n=o.closest(".lt-wrap"),s=Math.min(e,n?n.getBoundingClientRect().right:e);a.getBoundingClientRect().right>s-4&&(a.style.left="auto",a.style.right="0")})():n&&s&&s()},u=l||o;return u.onclick=t=>{a.contains(t.target)||c(a.hidden)},i(t,"pointerdown",t=>{u.contains(t.target)||c(!1)}),i(t,"keydown",t=>{"Escape"===t.key&&c(!1)}),o}const et={select:{describe:(t,e)=>{const n=U(t);if(null==n)return t?"⋯":"";const s=e.choices.find(t=>t.value===n);return s?s.label:n},init:t=>I(t.selected??""),parse:U,build:(t,e,n)=>{const s=function(t,e,n){const s=m(t,"select",{className:"lti-filter-pick"});return e.forEach(e=>m(t,"option",{value:e.value,textContent:e.label},s)),s.onchange=()=>n(s.value),{el:s,set:t=>s.value=t}}(t,e.choices,t=>n(I(t),l)),l={el:s.el,reflect:t=>{const e=U(t);s.set(null==e?"":e)}};return l}},range:{describe:(t,e)=>{const n=q(t,e.labels);return n?W(n,e):t?"⋯":""},init:t=>t.value?V(t.value[0],t.value[1],t.min,t.max,t.labels):"",parse:(t,e)=>q(t,e.labels),build:(t,e,n)=>{const s=m(t,"span",{className:"lti-slider-out"}),l=t=>s.textContent=W(t,e),o=Z(t,e,t=>{l(t),(t=>{n(V(t[0],t[1],e.min,e.max,e.labels),r)})(t)},l),r={el:[o.el,s],reflect:t=>{const n=q(t,e.labels)||[e.min,e.max];o.set(n),l(n)}};return r}},text:{describe:t=>t,init:()=>"",parse:t=>t,build:()=>({el:[],reflect:()=>{}})},checklist:{describe:(t,e)=>{const n=K(t);if(null==n)return t?"⋯":"";const s=e.choices.filter(t=>n.includes(t.value)).map(t=>t.label);return s.length<=2?s.join(", "):`${s.length} selected`},init:t=>X([].concat(t.selected??t.choices.map(t=>t.value)),t.choices),parse:K,build:(t,e,n)=>{const s=e.choices.map(t=>t.value),l=Q(t,e.choices,t=>n(X(t,e.choices),o)),o={el:l.el,reflect:t=>{const e=K(t);l.set(null==e?s:e)}};return o}}};function nt(t,e,s,l,o,r,a,i){const c=G(s,l(e)),u=et[c.type],d=[];let p=()=>{},f=()=>{},h=null;const g=(t,n)=>{t?o.filters[e]=t:delete o.filters[e],r();const s=o.filters[e]||"";d.forEach(t=>t!==n&&t.reflect(s)),h&&(h.hidden=!!s&&null==u.parse(s,c)),p(s)},w=a&&Y(t,a),b=tt(t,`Filter ${c.label||e}`,s=>{const r=i&&B(t,l(e),o,e);if(r&&s.append(r),!1!==c.box){const o=s.appendChild(v(t,`${c.label||e} filter expression`,$)),r={reflect:e=>{t.activeElement!==o&&(o.value=e)}},a=m(t,"div",{className:"lti-nl"},s);d.push(r),z(o,()=>j(l(e).vals)),S(o,t=>{const s=n.parse(t,{},e),l=n.expr(s);a.textContent=l&&n.parsed(s)?n.text(s,()=>null):"",g(l??t.trim(),r)})}const a=u.build(t,c,g);d.push(a),h=m(t,"div",{className:"lti-widget"},s),h.append(...[].concat(a.el)),g(u.init(c),null)},()=>f(),w&&w.el);let y=b;return w?(w.el.append(b),y=w.el,p=w.mark,f=()=>w.summarize(u.describe(o.filters[e]||"",c))):p=t=>y.classList.toggle("lti-on",!!t),p(o.filters[e]||""),f(),y}const st=(t,e)=>{e?.interactive&&!t.dataset.ltiOn&&(t.dataset.ltiOn="1",x(t,e))};e.plugins.interactive={matcher:w,computeView:b,pageSlice:y,enhance:x},e.ui=Object.assign(e.ui||{},{popover:tt,checklist:Q,chip:Y}),e.onMount.push(st),"undefined"!=typeof document&&a(document,".lt-table").forEach(t=>st(t,t._ltSpec))})("undefined"!=typeof window?window:globalThis);
|
|
1
|
+
(t=>{"use strict";const e=t.LT;if(!e?.onMount||e.plugins.interactive)return;const n=e.plugins.query;let s;const l=t=>"string"!=typeof t?{...t}:"-"===t[0]?{col:t.slice(1),dir:"desc"}:{col:t,dir:"asc"},o=(t,e,n)=>(s||=new Intl.Collator,n?t-e:s.compare(String(t),String(e))),{$:r,$$:a,on:i,off:c,numCol:u,dateFmt:d}=e,p=t=>{const e=t.data||{};if(t._txt?.d!==e){const n={...e};for(const s in e){const l=d(e[s]);(l||t.dates?.includes(s))&&(n[s]=Object.assign(e[s].map(t=>null!=t&&l?l(t):t),{date:!0}))}t._txt={d:e,t:n}}return t._txt.t},f=t=>[...t.children].filter(t=>!t.classList.contains("lt-row-group")),h=t=>{const e=[...t.childNodes],n=e.findIndex(t=>"BR"===t.nodeName);return n<0?e:e.slice(0,n)};function m(t,e,n={},s){const l=t.createElement(e);for(const t in n)t.includes("-")?l.setAttribute(t,n[t]):l[t]=n[t];return s?s.appendChild(l):l}function g(t,e,n){t.preventDefault();const s=t.target.ownerDocument||document,l=t=>e(t);i(s,"pointermove",l),i(s,"pointerup",()=>{c(s,"pointermove",l),n&&n()},{once:!0})}function w(t){const e=String(t??"").trim();if(""===e)return null;if(/(^|[^\w$])x([^\w$]|$)/.test(e)){let t;try{t=new Function("x",`return (${e});`)}catch(t){}if(t){const n=/^\s*!|!=/.test(e),s=e=>{try{if(null==e)return n||!!t(void 0);const s=Number(e);return!!t(String(e))||""!==e&&isFinite(s)&&!!t(s)}catch(t){return!1}};return t=>t[n?"every":"some"](t=>s(t.raw))}}const n="!"===e[0],s=(n?e.slice(1).trim():e).toLowerCase();return""===s?null:t=>n!==t.some(t=>null!=t.disp&&String(t.disp).toLowerCase().includes(s))}function b(t,e,n){const s=t._cols||[],l=t.data||{},r=p(t),a=(l[s[0]]||[]).length,i=(t,n)=>({raw:r[t]?.[n-1]??null,disp:e[t]?.[n-1]??""}),c=[],d=t=>{if(t.op){const e=t.items.map(d);return"and"===t.op?t=>e.every(e=>e(t)):t=>e.some(e=>e(t))}const e=w(t.term);return e?null!=t.col?n=>e([i(t.col,n)]):t=>e(s.map(e=>i(e,t))):()=>!0};for(const t in n.filters||{}){const e=n.filters[t];c.push(d("string"==typeof e?{col:t,term:e}:e))}n.where&&c.push(d(n.where));const f=w(n.term);f&&c.push(t=>f(s.map(e=>i(e,t))));const h=Object.values(n.predicates||{});if(h.length){const t=Object.keys(l),e=e=>Object.fromEntries(t.map(t=>[t,l[t]?.[e-1]??null]));c.push(t=>{const n=e(t);return h.every(t=>t(n))})}const m=t=>c.every(e=>e(t)),g=t=>{const e=t.map(t=>{const e=r[t.col];return e&&{col:e,num:u(e),dir:"desc"===t.dir?-1:1}}).filter(Boolean);return e.length?(t,n)=>{for(const{col:s,num:l,dir:r}of e){const e=s[t-1],a=s[n-1],i=null==e,c=null==a;if(i||c){if(i!==c)return i?1:-1;continue}const u=o(e,a,l);if(u)return r*u}return 0}:null},b=t._indent,y=(t,e)=>{if(!b){const n=t.filter(m);return e?n.sort(e):n}const n=[],s=[];for(const e of t){const t={r:e,kids:[]},l=b[e-1]||0;for(;s.length&&s[s.length-1].lv>=l;)s.pop();(s.length?s[s.length-1].node.kids:n).push(t),s.push({node:t,lv:l})}const l=t=>t.map(t=>{const e=l(t.kids);return m(t.r)||e.length?{r:t.r,kids:e}:null}).filter(Boolean),o=t=>(e&&t.sort((t,n)=>e(t.r,n.r)),t.forEach(t=>o(t.kids)),t),r=[],a=t=>t.forEach(t=>{r.push(t.r),a(t.kids)});return a(o(l(n))),r},x=()=>Array.from({length:a},(t,e)=>e+1),v=t._rowspan;if(v){const t={},e=[];for(const s of n.sort||[])v.includes(s.col)?t[s.col]=s.dir:e.push(s);const s=g(e),l=(e,n)=>{if(n===v.length)return y(e,s);const a=r[v[n]],i=new Map;for(const t of e){const e=a[t-1],n=null==e?"\0":String(e);(i.get(n)||i.set(n,{v:e,rows:[]}).get(n)).rows.push(t)}let c=[...i.values()];if(t[v[n]]){const e=u(a),s="desc"===t[v[n]]?-1:1;c.sort((t,n)=>{const l=null==t.v,r=null==n.v;return l||r?l===r?0:l?1:-1:s*o(t.v,n.v,e)})}return c.flatMap(t=>l(t.rows,n+1))};return l(x(),0)}const $=g(n.sort||[]),k=t._groups;if(!k)return y(x(),$);const N=new Set,M=[];for(const t of k)t.rows.forEach(t=>N.add(t)),M.push(...y(t.rows,$));const S=[];for(let t=1;t<=a;t++)N.has(t)||S.push(t);return[...M,...y(S,$)]}function y(t,e){const n=e.pageSize;if(!n)return e.page=0,t;const s=Math.max(0,Math.ceil(t.length/n)-1);return e.page=Math.min(Math.max(e.page||0,0),s),t.slice(e.page*n,(e.page+1)*n)}function x(s,o){const i=o.interactive,c=o._cols||[],u=o.data||{},d=i.data_url&&e.plugins.server?.(i,o),w=d?i.data_n||0:(u[c[0]]||[]).length,x={},N=d?d.sum:t=>x[t]||=function(t,e){const n=t.filter(t=>null!=t),s=new Map,l={len:t.length,na:t.length-n.length,some:n.some(t=>""!==t),kind:t.date?"date":n.every(t=>"number"==typeof t)?"num":n.every(t=>"string"==typeof t)?"str":"mix"};for(const t of n)s.set(t,(s.get(t)||0)+1);l.m=s.size;const o=n.map(Number).filter(Number.isFinite),r=o.reduce((t,e)=>t+e,0);l.int=o.every(Number.isInteger),o.length&&(l.lo=o.reduce((t,e)=>Math.min(t,e)),l.hi=o.reduce((t,e)=>Math.max(t,e)),l.mean=r/o.length);let a;Object.defineProperty(l,"vals",{get:()=>a||=[...s.keys()].sort((t,e)=>"number"==typeof t&&"number"==typeof e?t-e:String(t).localeCompare(String(e)))}),t.date&&(l.lo=l.vals[0],l.hi=l.vals.at(-1),delete l.mean);if(!e)return l;const i=e=>t.date?Date.parse(e.replace(" ","T")):e,c=n.map(i),u=n.length&&c.every(Number.isFinite);let d=0,p=()=>-1;if(u){const t=c.reduce((t,e)=>Math.min(t,e)),e=c.reduce((t,e)=>Math.max(t,e));d=Math.min(T,s.size),p=n=>Math.min(d-1,Math.floor((i(n)-t)/(e-t||1)*d))}else if(n.length&&s.size<=n.length/2){const t=[...s].sort((t,e)=>e[1]-t[1]),e=new Map(t.map((t,e)=>[t[0],e]));l.top=t.slice(0,5),d=t.length,p=t=>e.get(t)??-1}return l.bar=d?t.map(t=>null==t?-1:p(t)):[],l.count=t=>{const e=Array(d).fill(0);for(const n of t)l.bar[n-1]>=0&&e[l.bar[n-1]]++;return e},l.bins=l.count(t.map((t,e)=>e+1)),l}(p(o)[t]||[],!0),E=o._groups,_={},C=E?[]:null;if(E){const t=new Set;E.forEach(e=>e.rows.forEach(n=>{_[n]=e,C.push(n),t.add(n)}));for(let e=1;e<=w;e++)t.has(e)||C.push(e)}const L=o._rowspan?o._rowspan.length:0,D=L?[...o._rowspan,...c]:c,A=L+c.length,F=o._display||function(t,e,n){const s={};e.forEach(t=>s[t]=[]);let l=0;return a(t,"tbody tr").forEach(t=>{if(t.classList.contains("lt-row-group"))return;const o=n?n[l]:l+1,r=f(t);e.forEach((t,e)=>s[t][o-1]=r[e]?.textContent??""),l++}),s}(s,c,C),I=[...a(s,"thead tr")].pop(),P={filters:{},predicates:{},paints:[],page:0,pageSize:0,sort:Array.isArray(i.sort)?i.sort.map(l):[]};let U,q=()=>{};const W=[],V=(t=!0)=>{if(d)return t&&(P.page=0),(()=>{const t=s.closest(".lt-wrap");return t?.classList.add("lti-busy"),d.load(P).then(e=>{e&&(t?.classList.remove("lti-busy"),o.data=e.data,P.page=e.page,P.paints.forEach(t=>t(null,P.prof=e.prof)),s._lt.clearDetail?.(),X(Array.from({length:Object.values(e.data)[0]?.length??0},(t,e)=>e+1),e.n))},e=>{t?.classList.remove("lti-busy"),console.error(e)})})();t&&(U=P.view=b(o,F,P),P.page=0,P.paints.forEach(t=>t(U,P.prof))),X(y(U,P),U.length)},X=(t,n)=>{const l=(t=>{if(!E)return t;const e=[];let n;for(const s of t){const t=_[s];t!==n&&(t&&e.push({label:t.label,raw:t.raw}),n=t),e.push(s)}return e})(t),a={...o,_viewRows:l},i=m(s.ownerDocument,"template",{innerHTML:e.buildHtml(a)});d&&(o._display=a._display);const c=r(i.content,"tbody");t.length?W.forEach(t=>t(c,l)):c.innerHTML=`<tr class="lti-empty"><td colspan="${A}">—</td></tr>`,r(s,"tbody").replaceWith(c),q(n)},K=M(s.closest(".lt-wrap"),(t=!0)=>V(t));let G=!0,Q=!1;const Z=(t=!0)=>{G?Q=!0:K(t)};s._lt={spec:o,state:P,server:d,refresh:(t=!0)=>K(t),view:()=>U||b(o,F,P),filter(t,e){e?P.predicates[t]=e:delete P.predicates[t],K()}};const tt=i.filter,et=tt?.cols?Object.keys(tt.cols).filter(t=>tt.cols[t]?.type&&"auto"!==tt.cols[t].type&&!c.includes(t)):[],st=!1!==i.search||i.hide||et.length||i.download?m(s.ownerDocument,"div",{className:"lti-bar"},k(s.tHead||s.createTHead(),"lti-head",A,0)):null,lt=f(I).map(t=>h(t).map(t=>t.textContent).join("")),ot=t=>lt[c.indexOf(t)]||t,rt=Object.fromEntries(c.flatMap(t=>null==t?[]:[[t,t],[ot(t),t]]));!1!==i.sort&&function(t,e,n,s){const l=t.ownerDocument,o={},r=()=>{for(const t in o)o[t].th.removeAttribute("aria-sort"),o[t].ind.textContent="";const t=n.sort||[];t.forEach(({col:e,dir:n},s)=>{const l=o[e];l&&(l.th.setAttribute("aria-sort","desc"===n?"descending":"ascending"),l.ind.textContent=("desc"===n?"▼":"▲")+(t.length>1?String(s+1).replace(/\d/g,t=>"₀₁₂₃₄₅₆₇₈₉"[t]):""))})};a(t,"th").forEach((t,a)=>{const i=e[a];if(null==i)return;t.classList.add("lti-sortable");const c=h(t),u=m(l,"span",{className:"lti-label"}),d=m(l,"span",{className:"lti-sort"});t.prepend(u,d),u.append(...c),o[i]={th:t,ind:d},u.onclick=d.onclick=t=>{!function(t,e,n){const s=(t.sort||[]).slice(),l=s.findIndex(t=>t.col===e),o=l<0?"asc":"asc"===s[l].dir?"desc":null;if(!n)return void(t.sort=o?[{col:e,dir:o}]:[]);l<0?s.push({col:e,dir:o}):o?s[l]={col:e,dir:o}:s.splice(l,1);t.sort=s}(n,i,t.shiftKey),r(),s()}}),r()}(I,D,P,Z),"header"===i.profile&&function(t,e,n,s){const l=f(t);e.forEach((e,o)=>{l[o].append(m(t.ownerDocument,"br"),B(t.ownerDocument,n(e),s,e))})}(I,c,N,P),tt&&(tt.default||tt.cols&&Object.keys(tt.cols).some(t=>tt.cols[t]&&c.includes(t)))&&function(t,e,s,l,o,r,a){const i=t.ownerDocument,c=f(t),u=s.default,d=s.cols||{};e.forEach((t,e)=>{const s=c[e],p=t in d,f=H(p?d[t]:u,l(t));if(null!=f&&(!1!==f||p)&&J(l(t))){if(m(i,"br",{},s),!1===f)return m(i,"button",{type:"button",className:"lti-funnel lti-off",disabled:!0},m(i,"span",{className:"lti-pop"},s));if(!0===f){const e=s.appendChild(v(i,`Filter ${t}`,$)),a=m(i,"div",{className:"lti-nl"});e.after(a),z(e,()=>j(l(t).vals),a),S(e,e=>{const s=n.parse(e,{},t);s?o.filters[t]=s:delete o.filters[t],a.textContent=n.parsed(s)?n.text(s,()=>null):"",r()})}else s.append(nt(i,t,f,l,o,r,null,a))}})}(I,c,tt,N,P,Z,"filter"===i.profile);const at=i.resize?function(t,e,n,s=0){const l=[...a(e,"th")],o=function(t,e,n=0){let s=r(t,"colgroup");if(!s){const l=t.ownerDocument;s=m(l,"colgroup");for(let t=0;t<n+e;t++)m(l,"col",{},s);t.caption?t.caption.after(s):t.prepend(s)}return[...s.children]}(t,n,s),i=t=>t.getBoundingClientRect().width,c=()=>{if(t.classList.contains("lti-fixed"))return;const e=l.map(i);t.style.width=i(t)+"px",o.forEach((t,n)=>t.style.width=e[n]+"px"),t.classList.add("lti-fixed")},u=e=>{const n=o.map(t=>t.style.width),s=t.style.width;o.forEach(t=>t.style.width=""),t.style.width="",t.classList.remove("lti-fixed");const r=i(l[e]);return o.forEach((t,e)=>t.style.width=n[e]),t.style.width=s,t.classList.add("lti-fixed"),r},d=(e,n,s=24)=>{const l=parseFloat(o[e].style.width);o[e].style.width=Math.max(n,s)+"px",t.style.width=parseFloat(t.style.width)+parseFloat(o[e].style.width)-l+"px"};return{ths:l,cs:o,dataCs:o.slice(s),freeze:c,natural:u,setWidth:d}}(s,I,c.length,L):null;i.resize&&function(t,e){const n=t.ownerDocument,{ths:s,cs:l,freeze:o,natural:r,setWidth:a}=e;s.forEach((e,s)=>{const i=m(n,"div",{className:"lti-resizer"},e);i.ondblclick=t=>{t.stopPropagation(),o(),a(s,r(s))},i.onpointerdown=e=>{e.stopPropagation(),o();const n=e.clientX,r=parseFloat(l[s].style.width);t.classList.add("lti-resizing"),g(e,t=>a(s,r+t.clientX-n),()=>t.classList.remove("lti-resizing"))}})}(s,at),!1!==i.search&&function(t,e,s,l,o,r,a){const i=e.ownerDocument,c=t.appendChild(v(i,"Search")),u=m(i,"div",{className:"lti-nl"});t.after(u),z(c,a,u),S(c,t=>{const e=n.parse(t,o);s.where=e,u.textContent=n.parsed(e)?n.text(e,r):"",l()})}(st,s,P,Z,rt,ot,()=>O(p(o),c,ot));const it=st?m(s.ownerDocument,"div",{className:"lti-chips"},st):null;et.length&&function(t,e,n,s,l,o,r){const a=t.ownerDocument;for(const i of e)t.append(nt(a,i,n[i],s,l,o,n[i].label||i,r))}(it,et,tt.cols,N,P,Z,"filter"===i.profile);const ct=i.hide||i.download?m(s.ownerDocument,"div",{className:"lti-icons"},st):null;if(i.hide&&function(t,e,n,s,l,o,r,a){const i=e.ownerDocument,c=o&&o.hidden||[],u=new Set,d=(t,e,n)=>{const s=f(t)[e];s&&1===s.colSpan&&(s.hidden=n)};a.push(t=>u.forEach(e=>{for(const n of t.rows)d(n,e,!0)}));const p=[...n.children].length-f(n).length,h=[...e.rows].find(t=>t.classList.contains("lt-spanner-row")),g=h?f(h).slice(p):[];let w=0;g.forEach(t=>{t._span=t.colSpan,t._start=w,w+=t._span});const b=()=>{for(const t of g){let e=0;for(let n=t._start;n<t._start+t._span;n++)u.has(n)&&e++;t.colSpan=Math.max(1,t._span-e),t.hidden=e>=t._span}},y=t=>{const n=u.has(t);r?.dataCs[t]&&(r.dataCs[t].hidden=n);for(const s of e.rows)s.classList.contains("lt-spanner-row")||d(s,t,n);b()},x=m(i,"span",{className:"lti-cols"},t),v=o?.label?Object.assign(Y(i,o.label).el,{role:"button",tabIndex:0}):m(i,"button",{type:"button",title:"Show/Hide columns","aria-label":"Show/Hide columns"});x.append(v);const $=m(i,"div",{className:"lti-menu",hidden:!0},x),k=(t,e)=>{const n=s[t];if(null==n)return;const o=m(i,"label",e?{className:"lti-sub"}:{},$),r=m(i,"input",{type:"checkbox",checked:!0},o);o.append(l[t]??n),c.includes(n)&&(r.checked=!1,u.add(t)),r.onchange=()=>{r.checked?u.delete(t):u.add(t),y(t)}};if(g.length)for(const t of g){const e=t.classList.contains("lt-spanner");e&&m(i,"div",{className:"lti-group",textContent:t.textContent},$);for(let n=t._start;n<t._start+t._span;n++)k(n,e)}else s.forEach((t,e)=>k(e));s.forEach((t,e)=>y(e)),R(i,x,v,$)}(ct,s,I,c,lt,i.hide,at,W),i.download&&function(t,n,s,l){const o=n.ownerDocument,r=e.plugins.export,a="object"==typeof l?l:{file:l},i=a.formats?[].concat(a.formats):Object.keys(r.formats),c=("string"==typeof a.file&&a.file?a.file:"lt-table").replace(new RegExp(`\\.(${Object.keys(r.formats).join("|")})$`,"i"),""),u=1===i.length,d=r.formats[i[0]].label,f=m(o,"span",{className:"lti-dl"},t),h=m(o,"button",{type:"button",className:"lti-download",title:u?`Download ${d}`:"Download","aria-label":u?`Download table as ${d}`:"Download table"},f),g=async t=>{const l=await(n._lt.server?.load(n._lt.state,!0)),i=l?{...s,data:l.data}:s;l&&e.buildHtml(i);const u=l?Array.from({length:l.rows},(t,e)=>e+1):n._lt.view(),d=URL.createObjectURL(new Blob([r.text(t,i,u,"raw"===a.mode?p(i):void 0)],{type:r.formats[t].mime}));m(o,"a",{href:d,download:`${c}.${t}`}).click(),URL.revokeObjectURL(d)};if(u)return h.onclick=()=>g(i[0]);const w=m(o,"div",{className:"lti-menu",hidden:!0,role:"menu"},f),b=R(o,f,h,w);for(const t of i){const e=m(o,"label",{textContent:r.formats[t].label,role:"menuitem",tabIndex:0},w);e.onclick=()=>{b(),g(t)},e.onkeydown=t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),e.click())}}}(ct,s,o,i.download),s._lt.bar=st,s._lt.chips=it,i.detail){const n=function(n,s,l,o,a,i){const c=n.ownerDocument,u={};o.expanded=new Set;const d=(t,e)=>{const n={};for(const s in t)n[s]=t[s]?.[e-1]??null;return n},p=e=>{if(e in u)return u[e];const n=d(s._display||{},e);let l=null;if(Array.isArray(a)){const t={};for(const e of a)t[e]=[n[e]??null];l={data:t}}else{const o="function"==typeof a?a:t[a];"function"==typeof o&&(l=o(d(s.data||{},e),e,n))}return u[e]=l},h=n.closest(".lt-wrap"),g=M(h,t=>t()),w=(t,e)=>{t.textContent=e?"▾":"▸",t.setAttribute("aria-expanded",String(e))},b=(t,n)=>{const s=p(n);if(!s)return null;const o=m(c,"tr",{className:"lti-detail",hidden:!0});return t.after(o),e.render(m(c,"div",{},m(c,"td",{colSpan:l},o)),s),o},y=(t,e)=>{const n=t.nextElementSibling;return n?.classList.contains("lti-detail")?n:b(t,e)};let x=0;const v=()=>{const t=Math.ceil(n.getBoundingClientRect().width);t>x&&t>(parseFloat(n.style.width)||0)&&(n.style.width=t+"px")},$=(t,e,n)=>{const s=o.expanded.has(n);s?o.expanded.delete(n):o.expanded.add(n),w(e,!s);const l=y(t,n);l&&(l.hidden=s,s||v())},k=c.defaultView,N=k.requestIdleCallback||k.setTimeout,S=t=>N(()=>{if(!t.isConnected)return;n.style.width="",x=n.getBoundingClientRect().width;const e=r(t,".lti-expand[aria-expanded='false']");e&&(e.click(),v(),e.click())}),E=(t,e)=>{[...t.rows].forEach((t,n)=>{const s=e[n];if("number"!=typeof s)return;const l=f(t)[0],r=o.expanded.has(s);if(!l)return;const a=m(c,"button",{type:"button",className:"lti-expand","aria-label":"Toggle detail"});if(w(a,r),a.onclick=()=>$(t,a,s),l.prepend(a),r){const e=y(t,s);e&&(e.hidden=!1)}}),S(t)};return E.clear=()=>{o.expanded.clear();for(const t in u)delete u[t]},E.reset=t=>{if(null==t)for(const t in u)delete u[t];else delete u[t];g(i)},E}(s,o,A,P,i.detail,()=>V(!1));W.push(n),s._lt.resetDetail=n.reset,s._lt.clearDetail=n.clear}if(G=!1,i.pager){const t=Array.isArray(i.pager)?i.pager:[10,25,50,100];q=function(t,e,n,s,l,o){const r=t.ownerDocument;let a=t.tFoot;a||((a=t.createTFoot()).className="lt-footer");const i=m(r,"div",{className:"lti-pager"},k(a,"lti-pager-row",e,-1)),c=m(r,"span",{className:"lti-pos"});l.pageSize=n[0];const u=[()=>0,t=>t-1,t=>t+1,()=>1e9],d=["«","‹","›","»"].map((t,e)=>{const n=m(r,"button",{type:"button",textContent:t,"aria-label":["First","Previous","Next","Last"][e]},i);return n.onclick=()=>{l.page=u[e](l.page),o()},n});if(i.append(c),n.length>1&&s>Math.min(...n.filter(t=>t>0))){const t=m(r,"select",{"aria-label":"Rows per page"},i);n.forEach(e=>m(r,"option",{value:e,textContent:e||"∞"},t)),t.onchange=()=>{l.pageSize=+t.value,l.page=0,o()}}return t=>{const e=l.pageSize||t||1,n=Math.max(0,Math.ceil(t/e)-1),o=t<s?` (${s})`:"";c.textContent=(t?`${l.page*e+1}–${Math.min(t,(l.page+1)*e)} / ${t}`:"0 / 0")+o,d.forEach((t,e)=>t.disabled=e<2?!l.page:l.page===n)}}(s,A,t,w,P,()=>V(!1)),V()}else(P.sort.length||i.detail||Q)&&V()}function v(t,e,n=""){return m(t,"input",{type:"search",className:"lti-search","aria-label":e,title:n})}const $="Type a condition, or an expression where x stands for each value in this column, e.g. x > 5 && x < 9";function k(t,e,n,s){const l=t.insertRow(s);return l.className=e,m(t.ownerDocument,"td",{colSpan:n},l)}function N(t,e=400){let n;const s=()=>{clearTimeout(n),n=setTimeout(t,e)};return s.now=()=>{clearTimeout(n),t()},s}function M(t,e){let n,s=0;const l=t=>{const n=performance.now();e(t),s=performance.now()-n};return e=>{if(!t||s<120)return l(e);t.classList.add("lti-busy"),cancelAnimationFrame(n),n=requestAnimationFrame(()=>requestAnimationFrame(()=>{try{l(e)}finally{t.classList.remove("lti-busy")}}))}}function S(t,e){const n=N(()=>e(t.value),1e3);t.oninput=t=>t.inputType&&"insertReplacementText"!==t.inputType?n():n.now(),t.onchange=n.now}const E=t=>/[\s,;:"]/.test(t)?`"${t}"`:String(t),_=t=>t[Math.floor(Math.random()*t.length)],C=t=>t?.some(t=>null!=t&&""!==t),L=t=>{const e=t.filter(t=>null!=t).sort((t,e)=>t-e);return t=>+e[Math.floor((e.length-1)*t)].toPrecision(3)},D=t=>{const e=new Set;for(let n=0;n<30&&e.size<6;n++)e.add(t(n));return[...e]},A=(t,e)=>{if(u(t)){const n=L(t);return _([`${e}over ${n(.5)}`,`${e}under ${n(.5)}`,`${e}at least ${n(.75)}`,`${e}between ${n(.25)} and ${n(.75)}`,`${e}> ${n(.5)}`,`${e}<= ${n(.25)}`,`${e}!= ${n(.5)}`])}const n=[...new Set(t.filter(Boolean))],s=E(_(n)),l=E(_(n));return _([`${e}is ${s}`,`${e}is not ${s}`,`${e}contains ${s}`,`${e}does not contain ${s}`,`${e}is ${s} or ${e}is ${l}`,`${e}== ${s}`,`${e}!= ${s}`])},O=(t,e,n)=>{const s=e.filter(e=>C(t[e])),l=s.filter(e=>u(t[e])),o=s.filter(e=>!u(t[e])),r=e=>{const s=_(e);return A(t[s],`${E(n(s))} `)},a=[l.length&&(()=>r(l)),o.length&&(()=>r(o)),l.length&&o.length&&(()=>`${r(l)}${_([", "," and "])}${r(o)}`)].filter(Boolean);return a.length?D(t=>a[t%a.length]()):[]},j=t=>C(t)?D(e=>e%3==2?(t=>{if(u(t)){const e=L(t);return _([`x > ${e(.25)} && x < ${e(.75)}`,`x < ${e(.25)} || x > ${e(.75)}`])}const e=[...new Set(t.filter(Boolean))],n=JSON.stringify(_(e)),s=JSON.stringify(_(e));return _([`x == ${n} || x == ${s}`,`x != ${n} && x != ${s}`])})(t):A(t,"")):[];let F=0;function z(t,e,n=t){const s=t.ownerDocument,l=m(s,"datalist",{id:"lti-tips-"+ ++F});t.setAttribute("list",l.id),n.after(l);const o=()=>{const t=e();return l.replaceChildren(...t.map(t=>m(s,"option",{value:t}))),t},[r]=o();r&&(t.placeholder=`e.g. ${r}`),t.addEventListener("focus",o)}function R(t,e,n,s){const l=t=>{s.hidden=!t,n.setAttribute("aria-expanded",String(t))};return l(!1),n.onclick=t=>{t.stopPropagation(),l(s.hidden)},n.onkeydown=t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),n.click())},i(t,"click",t=>{e.contains(t.target)||l(!1)}),i(t,"keydown",t=>{"Escape"===t.key&&l(!1)}),()=>l(!1)}const T=10;function B(t,e,n,s){const l=(t,e)=>+t.toPrecision(e),o=e.bins,r=Math.max(...o),a=m(t,"span",{className:"lti-prof"}),i=o.length?e.top?[e.m>5&&`${e.m+(e.na>0)} distinct`,(e.m>5?"top ":"")+e.top.map(([t,e])=>`${t} (${e})`).join(", "),e.na&&`${e.na} NA`]:"date"===e.kind?[`min ${e.lo}`,`max ${e.hi}`,e.na&&`${Math.round(100*e.na/e.len)}% NA`]:[`min ${l(e.lo,6)}`,`max ${l(e.hi,6)}`,`mean ${l(e.mean,4)}`,e.na&&`${Math.round(100*e.na/e.len)}% NA`]:[],c=(t,e)=>t.map((t,n)=>`<rect${e} x="${n}" y="${1-t/r}" width=".9" height="${t/r}"/>`).join(""),u=(t,n)=>{const l=n?.[s]||t?.length<e.len&&e.count?.(t);a.innerHTML=`<svg viewBox="0 0 ${o.length||1} 1" preserveAspectRatio="none">${c(o,"")}${l?c(l,' class="s"'):""}</svg>`};return a.title=i.filter(Boolean).join("; "),n.paints.push(u),u(n.view,n.prof),a}const H=(t,e)=>{if("auto"!==t?.type)return t;return("num"===e.kind||"date"===e.kind?e.m>1&&{type:"range"}:"str"===e.kind&&e.m<=10&&{type:"checklist"})||{type:"text"}},J=t=>t.some;const I="\0NA",P=t=>""===t?"":t===I?"x == null":`x == ${JSON.stringify(String(t))}`,U=t=>{const e=/^\s*x\s*==\s*(?:(['"])([\s\S]*)\1|null)\s*$/.exec(t||"");return e?e[1]?e[2]:I:null},q=(t,e,n,s,l)=>t<=n&&e>=s?"":l?`x >= ${JSON.stringify(l[t])} && x <= ${JSON.stringify(l[e])}`:`x >= ${t} && x <= ${e}`,W=(t,e)=>{const n=/^\s*x\s*>=\s*("[^"]*"|-?[\d.]+)\s*&&\s*x\s*<=\s*("[^"]*"|-?[\d.]+)\s*$/.exec(t||"");if(!n)return null;const s=t=>'"'!==t[0]?parseFloat(t):e?e.indexOf(JSON.parse(t)):NaN,l=[s(n[1]),s(n[2])];return l.some(t=>!isFinite(t)||e&&t<0)?null:l},V=(t,e)=>e.labels?`${e.labels[t[0]]} – ${e.labels[t[1]]}`:`${t[0]} – ${t[1]}`,X=(t,e)=>{if(t.length===e.length)return"";const n=t.map(t=>t===I?null:String(t));return`${JSON.stringify(n)}.includes(x${n.includes(null)?" ?? null":""})`},K=t=>{const e=/^\s*(\[[\s\S]*\])\.includes\(\s*x\s*(?:\?\?\s*null\s*)?\)\s*$/.exec(t||"");if(!e)return null;try{return JSON.parse(e[1]).map(t=>null===t?I:t)}catch(t){return null}};function G(t,e){if("select"===t.type||"checklist"===t.type){let n=t.choices??e.vals.map(t=>({value:String(t),label:String(t)}));return e.na&&(n=[...n,{value:I,label:"NA"}]),"select"!==t.type||n.some(t=>""===t.value)||(n=[{value:"",label:""},...n]),{...t,choices:n}}if("range"===t.type&&"date"===e.kind){const n=e.vals;return{...t,labels:n,min:0,max:n.length-1,step:1}}let{min:n,max:s,step:l}=t;const o=e.lo??0,r=e.hi??1;null==l&&(l=function(t,e){if(!(t>0&&isFinite(t)))return e?1:.1;const n=t/100,s=Math.pow(10,Math.floor(Math.log10(n))),l=[1,2,5,10].find(t=>t*s>=n)*s;return e?Math.max(1,Math.round(l)):l}((s??r)-(n??o),e.int));const a=t=>Math.round(1e9*t)/1e9;return null==n&&(n=a(Math.floor(o/l)*l)),null==s&&(s=a(Math.ceil(r/l)*l)),{...t,min:n,max:s,step:l}}function Q(t,e,n){const s=e.map(e=>{const n=m(t,"label",{className:"lti-check"}),s=m(t,"input",{type:"checkbox",checked:!0,value:e.value},n);return n.append(e.label),{o:e,box:s,label:n}}),l=()=>n(s.filter(t=>t.box.checked).map(t=>t.o.value));return s.forEach(t=>t.box.onchange=l),{el:s.map(t=>t.label),set:t=>s.forEach(e=>e.box.checked=t.includes(e.o.value))}}function Y(t,e,n){const s=m(t,"span",{className:"lti-chip"});m(t,"span",{className:"lti-chip-name",textContent:e},s);const l=m(t,"span",{className:"lti-chip-cur"},s);return n&&s.append(n),{el:s,mark:t=>s.classList.toggle("lti-on",!!t),summarize:t=>l.textContent=t}}function Z(t,e,n,s){const l=e.min,o=e.max,r=o-l||1,a=e.step||r/100,i=m(t,"div",{className:"lti-slider"}),c=m(t,"div",{className:"lti-slider-fill"},i),u=e=>m(t,"button",{type:"button",className:"lti-thumb",role:"slider","aria-label":e,"aria-valuemin":l,"aria-valuemax":o},i),d=[u("Minimum"),u("Maximum")];let p=[l,o];const f=N(()=>n(p.slice())),h=t=>p[0]!==t[0]||p[1]!==t[1],w=t=>(t-l)/r*100,b=()=>{d.forEach((t,e)=>{t.style.left=w(p[e])+"%",t.setAttribute("aria-valuenow",p[e])}),c.style.left=w(p[0])+"%",c.style.right=100-w(p[1])+"%"},y=(t,e)=>{p[t]=(t=>{const e=Math.round((t-l)/a)*a+l;return Math.min(o,Math.max(l,Math.round(1e6*e)/1e6))})(e),p[0]>p[1]&&(p=[Math.min(...p),Math.max(...p)]),b(),s&&s(p.slice())};return d.forEach((t,e)=>{t.onpointerdown=n=>{t.focus();const s=p.slice();g(n,t=>y(e,(t=>{const e=i.getBoundingClientRect();return l+r*Math.min(1,Math.max(0,(t-e.left)/e.width))})(t.clientX)),()=>h(s)&&f.now())},t.onkeydown=t=>{const n={ArrowLeft:-1,ArrowDown:-1,ArrowRight:1,ArrowUp:1}[t.key],s=p.slice();if(n)y(e,p[e]+n*a);else if("Home"===t.key)y(e,l);else{if("End"!==t.key)return;y(e,o)}h(s)&&f(),t.preventDefault()}}),b(),{el:i,set:t=>{p=t.slice(),b()}}}function tt(t,e,n,s,l){const o=m(t,"span",{className:"lti-pop"}),r=m(t,"button",{type:"button",className:"lti-funnel",title:e,"aria-label":e,"aria-expanded":"false"},o),a=m(t,"div",{className:"lti-pop-panel",hidden:!0},o);n(a);const c=e=>{const n=!a.hidden;a.hidden=!e,r.setAttribute("aria-expanded",String(e)),e?(()=>{a.style.left=a.style.right="";const e=(t.defaultView||window).innerWidth,n=o.closest(".lt-wrap"),s=Math.min(e,n?n.getBoundingClientRect().right:e);a.getBoundingClientRect().right>s-4&&(a.style.left="auto",a.style.right="0")})():n&&s&&s()},u=l||o;return u.onclick=t=>{a.contains(t.target)||c(a.hidden)},i(t,"pointerdown",t=>{u.contains(t.target)||c(!1)}),i(t,"keydown",t=>{"Escape"===t.key&&c(!1)}),o}const et={select:{describe:(t,e)=>{const n=U(t);if(null==n)return t?"⋯":"";const s=e.choices.find(t=>t.value===n);return s?s.label:n},init:t=>P(t.selected??""),parse:U,build:(t,e,n)=>{const s=function(t,e,n){const s=m(t,"select",{className:"lti-filter-pick"});return e.forEach(e=>m(t,"option",{value:e.value,textContent:e.label},s)),s.onchange=()=>n(s.value),{el:s,set:t=>s.value=t}}(t,e.choices,t=>n(P(t),l)),l={el:s.el,reflect:t=>{const e=U(t);s.set(null==e?"":e)}};return l}},range:{describe:(t,e)=>{const n=W(t,e.labels);return n?V(n,e):t?"⋯":""},init:t=>t.value?q(t.value[0],t.value[1],t.min,t.max,t.labels):"",parse:(t,e)=>W(t,e.labels),build:(t,e,n)=>{const s=m(t,"span",{className:"lti-slider-out"}),l=t=>s.textContent=V(t,e),o=Z(t,e,t=>{l(t),(t=>{n(q(t[0],t[1],e.min,e.max,e.labels),r)})(t)},l),r={el:[o.el,s],reflect:t=>{const n=W(t,e.labels)||[e.min,e.max];o.set(n),l(n)}};return r}},text:{describe:t=>t,init:()=>"",parse:t=>t,build:()=>({el:[],reflect:()=>{}})},checklist:{describe:(t,e)=>{const n=K(t);if(null==n)return t?"⋯":"";const s=e.choices.filter(t=>n.includes(t.value)).map(t=>t.label);return s.length<=2?s.join(", "):`${s.length} selected`},init:t=>X([].concat(t.selected??t.choices.map(t=>t.value)),t.choices),parse:K,build:(t,e,n)=>{const s=e.choices.map(t=>t.value),l=Q(t,e.choices,t=>n(X(t,e.choices),o)),o={el:l.el,reflect:t=>{const e=K(t);l.set(null==e?s:e)}};return o}}};function nt(t,e,s,l,o,r,a,i){const c=G(s,l(e)),u=et[c.type],d=[];let p=()=>{},f=()=>{},h=null;const g=(t,n)=>{t?o.filters[e]=t:delete o.filters[e],r();const s=o.filters[e]||"";d.forEach(t=>t!==n&&t.reflect(s)),h&&(h.hidden=!!s&&null==u.parse(s,c)),p(s)},w=a&&Y(t,a),b=tt(t,`Filter ${c.label||e}`,s=>{const r=i&&B(t,l(e),o,e);if(r&&s.append(r),!1!==c.box){const o=s.appendChild(v(t,`${c.label||e} filter expression`,$)),r={reflect:e=>{t.activeElement!==o&&(o.value=e)}},a=m(t,"div",{className:"lti-nl"},s);d.push(r),z(o,()=>j(l(e).vals)),S(o,t=>{const s=n.parse(t,{},e),l=n.expr(s);a.textContent=l&&n.parsed(s)?n.text(s,()=>null):"",g(l??t.trim(),r)})}const a=u.build(t,c,g);d.push(a),h=m(t,"div",{className:"lti-widget"},s),h.append(...[].concat(a.el)),g(u.init(c),null)},()=>f(),w&&w.el);let y=b;return w?(w.el.append(b),y=w.el,p=w.mark,f=()=>w.summarize(u.describe(o.filters[e]||"",c))):p=t=>y.classList.toggle("lti-on",!!t),p(o.filters[e]||""),f(),y}const st=(t,e)=>{e?.interactive&&!t.dataset.ltiOn&&(t.dataset.ltiOn="1",x(t,e))};e.plugins.interactive={matcher:w,computeView:b,pageSlice:y,enhance:x},e.ui=Object.assign(e.ui||{},{popover:tt,checklist:Q,chip:Y}),e.onMount.push(st),"undefined"!=typeof document&&a(document,".lt-table").forEach(t=>st(t,t._ltSpec))})("undefined"!=typeof window?window:globalThis);
|
|
2
2
|
//# sourceMappingURL=lt-interactive.min.js.map
|