@uvalib/web-components 1.8.5 → 1.10.0
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/CHANGELOG.md +48 -0
- package/README.md +719 -72
- package/bin/install-skill.mjs +174 -54
- package/dist/base/clipboard.d.ts +9 -0
- package/dist/base/clipboard.js +30 -0
- package/dist/base/clipboard.js.map +1 -0
- package/dist/base.css +301 -3
- package/dist/components/uvalib-citation/UvalibCitation.d.ts +124 -0
- package/dist/components/uvalib-citation/UvalibCitation.js +545 -0
- package/dist/components/uvalib-citation/UvalibCitation.js.map +1 -0
- package/dist/components/uvalib-citation/uvalib-citation.d.ts +1 -0
- package/dist/components/uvalib-citation/uvalib-citation.js +4 -0
- package/dist/components/uvalib-citation/uvalib-citation.js.map +1 -0
- package/dist/components/uvalib-dialog/UvalibDialog.d.ts +167 -0
- package/dist/components/uvalib-dialog/UvalibDialog.js +688 -0
- package/dist/components/uvalib-dialog/UvalibDialog.js.map +1 -0
- package/dist/components/uvalib-dialog/uvalib-dialog.d.ts +1 -0
- package/dist/components/uvalib-dialog/uvalib-dialog.js +4 -0
- package/dist/components/uvalib-dialog/uvalib-dialog.js.map +1 -0
- package/dist/components/uvalib-filter/UvalibFilter.d.ts +92 -9
- package/dist/components/uvalib-filter/UvalibFilter.js +748 -60
- package/dist/components/uvalib-filter/UvalibFilter.js.map +1 -1
- package/dist/components/uvalib-list-filter/UvalibListFilter.d.ts +162 -0
- package/dist/components/uvalib-list-filter/UvalibListFilter.js +685 -0
- package/dist/components/uvalib-list-filter/UvalibListFilter.js.map +1 -0
- package/dist/components/uvalib-list-filter/uvalib-list-filter.d.ts +1 -0
- package/dist/components/uvalib-list-filter/uvalib-list-filter.js +4 -0
- package/dist/components/uvalib-list-filter/uvalib-list-filter.js.map +1 -0
- package/dist/components/uvalib-metadata/UvalibMetadata.js +3 -4
- package/dist/components/uvalib-metadata/UvalibMetadata.js.map +1 -1
- package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.d.ts +28 -1
- package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js +139 -3
- package/dist/components/uvalib-pagefind-search/UvalibPagefindSearch.js.map +1 -1
- package/dist/custom-elements.json +9503 -6086
- package/dist/edition.css +758 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/styles/base.js +112 -1
- package/dist/styles/base.js.map +1 -1
- package/dist/styles/color-scheme.js +4 -0
- package/dist/styles/color-scheme.js.map +1 -1
- package/dist/styles/controls.js +6 -0
- package/dist/styles/controls.js.map +1 -1
- package/dist/styles/edition.d.ts +1 -0
- package/dist/styles/edition.js +747 -0
- package/dist/styles/edition.js.map +1 -0
- package/dist/styles/field-text.d.ts +1 -0
- package/dist/styles/field-text.js +21 -0
- package/dist/styles/field-text.js.map +1 -0
- package/dist/styles/hidden.js +15 -1
- package/dist/styles/hidden.js.map +1 -1
- package/dist/styles/layout.d.ts +1 -0
- package/dist/styles/layout.js +92 -0
- package/dist/styles/layout.js.map +1 -0
- package/dist/styles/table.d.ts +1 -0
- package/dist/styles/table.js +164 -0
- package/dist/styles/table.js.map +1 -0
- package/dist/tokens.css +4 -0
- package/dist-cdn/base.css +301 -3
- package/dist-cdn/chunks/{base-B3tNX103.js → base-DXkGlSgH.js} +113 -2
- package/dist-cdn/chunks/base-DXkGlSgH.js.map +1 -0
- package/dist-cdn/chunks/clipboard-CNG7Y_5X.js +18 -0
- package/dist-cdn/chunks/clipboard-CNG7Y_5X.js.map +1 -0
- package/dist-cdn/chunks/if-defined-COiQb-gl.js +6 -0
- package/dist-cdn/chunks/if-defined-COiQb-gl.js.map +1 -0
- package/dist-cdn/chunks/{site-header-CEmNtmk5.js → site-header-B78a_ldi.js} +27 -22
- package/dist-cdn/chunks/site-header-B78a_ldi.js.map +1 -0
- package/dist-cdn/chunks/{site-main-nav-CAwKq_x5.js → site-main-nav-CmMq2t8t.js} +52 -51
- package/dist-cdn/chunks/site-main-nav-CmMq2t8t.js.map +1 -0
- package/dist-cdn/custom-elements.json +9503 -6086
- package/dist-cdn/edition.css +758 -0
- package/dist-cdn/manifest.json +7 -3
- package/dist-cdn/site-header.js +1 -1
- package/dist-cdn/site-main-nav.js +1 -1
- package/dist-cdn/site-page.js +3 -3
- package/dist-cdn/site-style.js +1 -1
- package/dist-cdn/skills/uvalib-web-components/SKILL.md +34 -10
- package/dist-cdn/skills/uvalib-web-components/reference/components.md +188 -9
- package/dist-cdn/tokens.css +4 -0
- package/dist-cdn/uvalib-citation.js +382 -0
- package/dist-cdn/uvalib-citation.js.map +1 -0
- package/dist-cdn/uvalib-dialog.js +419 -0
- package/dist-cdn/uvalib-dialog.js.map +1 -0
- package/dist-cdn/uvalib-filter.js +603 -69
- package/dist-cdn/uvalib-filter.js.map +1 -1
- package/dist-cdn/uvalib-list-filter.js +451 -0
- package/dist-cdn/uvalib-list-filter.js.map +1 -0
- package/dist-cdn/uvalib-metadata.js +49 -49
- package/dist-cdn/uvalib-metadata.js.map +1 -1
- package/dist-cdn/uvalib-pagefind-search.js +118 -48
- package/dist-cdn/uvalib-pagefind-search.js.map +1 -1
- package/package.json +14 -1
- package/skills/uvalib-web-components/SKILL.md +34 -10
- package/skills/uvalib-web-components/reference/components.md +188 -9
- package/dist-cdn/chunks/base-B3tNX103.js.map +0 -1
- package/dist-cdn/chunks/site-header-CEmNtmk5.js.map +0 -1
- package/dist-cdn/chunks/site-main-nav-CAwKq_x5.js.map +0 -1
|
@@ -1,19 +1,59 @@
|
|
|
1
|
-
import { a as e,
|
|
2
|
-
import { t as
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { a as e, d as t, f as n, i as r, l as i, m as a, n as o, o as s, p as c, t as l } from "./chunks/UvalibElement-pGONDAwB.js";
|
|
2
|
+
import { t as u } from "./chunks/repeat-m5Zd_QeP.js";
|
|
3
|
+
import { t as d } from "./chunks/if-defined-COiQb-gl.js";
|
|
4
|
+
import { a as f } from "./chunks/analytics-DTTihuBD.js";
|
|
5
|
+
import { t as p } from "./chunks/accessible-DJv7YOtS.js";
|
|
5
6
|
// src/components/uvalib-filter/UvalibFilter.ts
|
|
6
|
-
var
|
|
7
|
+
var m = "uvalib-filter", h = {
|
|
8
|
+
announce: 500,
|
|
9
|
+
track: 1500
|
|
10
|
+
}, g = 0, _ = /\p{M}/gu, v = (e) => e.normalize("NFD").replace(_, "").toLowerCase();
|
|
11
|
+
function y(e) {
|
|
12
|
+
let t = "", n = [], r = 0;
|
|
13
|
+
for (let i of e) {
|
|
14
|
+
let e = v(i);
|
|
15
|
+
for (let t = 0; t < e.length; t++) n.push(r);
|
|
16
|
+
t += e, r += i.length;
|
|
17
|
+
}
|
|
18
|
+
return n.push(r), {
|
|
19
|
+
text: t,
|
|
20
|
+
map: n
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function b(e, t) {
|
|
24
|
+
if (!t) return e;
|
|
25
|
+
let { text: n, map: r } = y(e), a = [], o = 0;
|
|
26
|
+
for (let s = n.indexOf(t); s !== -1; s = n.indexOf(t, s + t.length)) {
|
|
27
|
+
let n = r[s], c = r[s + t.length];
|
|
28
|
+
n > o && a.push(e.slice(o, n)), a.push(i`<mark>${e.slice(n, c)}</mark>`), o = c;
|
|
29
|
+
}
|
|
30
|
+
return a.push(e.slice(o)), a;
|
|
31
|
+
}
|
|
32
|
+
var x = new Intl.Collator(void 0, {
|
|
33
|
+
sensitivity: "base",
|
|
34
|
+
numeric: !0
|
|
35
|
+
}), S = (e) => e.toLowerCase(), C = (e, t, n = `${t}s`) => `${e} ${e === 1 ? t : n}`, w = (e) => e.toLocaleString("en-US"), T = t`<svg class="check" viewBox="0 0 16 16" aria-hidden="true" focusable="false"><path d="M3 8.5l3.2 3.2L13 4.8" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round" stroke-linejoin="round"/></svg>`;
|
|
36
|
+
function E(e, t) {
|
|
37
|
+
switch (e) {
|
|
38
|
+
case 2: return i`<h2 class="heading">${t}</h2>`;
|
|
39
|
+
case 3: return i`<h3 class="heading">${t}</h3>`;
|
|
40
|
+
case 4: return i`<h4 class="heading">${t}</h4>`;
|
|
41
|
+
case 5: return i`<h5 class="heading">${t}</h5>`;
|
|
42
|
+
case 6: return i`<h6 class="heading">${t}</h6>`;
|
|
43
|
+
default: return t;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
var D = "var(--uva-color-text-muted, #4f4f4f)", O = "var(--uva-color-control-border, var(--uva-grey, #808080))", k = "var(--uva-color-link, var(--uva-brand-blue, #232d4b))", A = "var(--uva-color-accent-bg, var(--uva-brand-blue, #232d4b))", j = "var(--uva-color-surface-raised, #fff)", M = "var(--uva-color-focus, var(--uva-brand-orange, #e57200))", N = class extends l {
|
|
7
47
|
constructor(...e) {
|
|
8
48
|
super(...e), this.filter = {
|
|
9
49
|
name: "",
|
|
10
50
|
title: "",
|
|
11
51
|
position: 0,
|
|
12
52
|
buckets: []
|
|
13
|
-
}, this.value = [], this.scopes = [], this.scopeValue = [], this.scopesLabel = "", this.limit = 0, this.currentLimit = 0, this.uid = `uvalib-filter-${++
|
|
53
|
+
}, this.value = [], this.scopes = [], this.scopeValue = [], this.scopesLabel = "", this.limit = 0, this.collapsible = !1, this.collapsed = !1, this.headingLevel = 0, this.searchable = !1, this.searchLabel = "", this.unit = "values", this.sortable = !1, this.sort = "count", this.clearable = !1, this.applyButton = !1, this.currentLimit = 0, this.query = "", this.announcement = "", this.staged = /* @__PURE__ */ new Map(), this.uid = `uvalib-filter-${++g}`, this.lastTracked = "";
|
|
14
54
|
}
|
|
15
55
|
static {
|
|
16
|
-
this.styles = [
|
|
56
|
+
this.styles = [p, n`
|
|
17
57
|
:host {
|
|
18
58
|
display: block;
|
|
19
59
|
}
|
|
@@ -21,6 +61,7 @@ var d = "uvalib-filter", f = 0, p = class extends s {
|
|
|
21
61
|
border: none;
|
|
22
62
|
padding: 0;
|
|
23
63
|
margin: 0;
|
|
64
|
+
min-inline-size: 0;
|
|
24
65
|
}
|
|
25
66
|
legend {
|
|
26
67
|
font-weight: bold;
|
|
@@ -68,19 +109,295 @@ var d = "uvalib-filter", f = 0, p = class extends s {
|
|
|
68
109
|
outline: 2px solid var(--uva-color-focus, var(--uva-brand-orange, #e57200));
|
|
69
110
|
outline-offset: 2px;
|
|
70
111
|
}
|
|
112
|
+
|
|
113
|
+
/* ---- Filter-group features (each opt-in). ---- */
|
|
114
|
+
legend.group {
|
|
115
|
+
inline-size: 100%;
|
|
116
|
+
margin: 0;
|
|
117
|
+
padding: 0;
|
|
118
|
+
}
|
|
119
|
+
.heading {
|
|
120
|
+
margin: 0;
|
|
121
|
+
font: inherit;
|
|
122
|
+
}
|
|
123
|
+
.toggle {
|
|
124
|
+
display: flex;
|
|
125
|
+
align-items: center;
|
|
126
|
+
justify-content: space-between;
|
|
127
|
+
gap: 0.75rem;
|
|
128
|
+
box-sizing: border-box;
|
|
129
|
+
inline-size: 100%;
|
|
130
|
+
min-block-size: 44px;
|
|
131
|
+
margin: 0;
|
|
132
|
+
padding: 0.5rem 0.25rem 0.5rem 0;
|
|
133
|
+
border: 0;
|
|
134
|
+
background: none;
|
|
135
|
+
color: inherit;
|
|
136
|
+
font: inherit;
|
|
137
|
+
font-weight: 700;
|
|
138
|
+
line-height: 1.5;
|
|
139
|
+
text-align: start;
|
|
140
|
+
cursor: pointer;
|
|
141
|
+
}
|
|
142
|
+
/* The library's caret (as in uvalib-contents and site-main-nav): a rotated border box,
|
|
143
|
+
turned over when open. It flips at once: no motion. */
|
|
144
|
+
.toggle::after {
|
|
145
|
+
content: '';
|
|
146
|
+
flex: none;
|
|
147
|
+
inline-size: 0.5em;
|
|
148
|
+
block-size: 0.5em;
|
|
149
|
+
margin-block-end: 0.25em;
|
|
150
|
+
border-inline-end: 2px solid ${c(k)};
|
|
151
|
+
border-block-end: 2px solid ${c(k)};
|
|
152
|
+
transform: rotate(45deg);
|
|
153
|
+
}
|
|
154
|
+
.toggle[aria-expanded='true']::after {
|
|
155
|
+
margin-block: 0.25em 0;
|
|
156
|
+
transform: rotate(225deg);
|
|
157
|
+
}
|
|
158
|
+
.selected-count {
|
|
159
|
+
margin-inline-start: 0.5rem;
|
|
160
|
+
color: ${c(D)};
|
|
161
|
+
font-size: 0.875rem;
|
|
162
|
+
font-weight: 400;
|
|
163
|
+
}
|
|
164
|
+
.body.collapsible {
|
|
165
|
+
padding-block-start: 0.25rem;
|
|
166
|
+
}
|
|
167
|
+
.match,
|
|
168
|
+
.search-status,
|
|
169
|
+
.apply-status {
|
|
170
|
+
margin: 0 0 0.5rem;
|
|
171
|
+
color: ${c(D)};
|
|
172
|
+
font-size: 0.875rem;
|
|
173
|
+
line-height: 1.5;
|
|
174
|
+
}
|
|
175
|
+
.search {
|
|
176
|
+
margin: 0 0 0.5rem;
|
|
177
|
+
}
|
|
178
|
+
.search label {
|
|
179
|
+
display: block;
|
|
180
|
+
margin-block-end: 0.25rem;
|
|
181
|
+
font-size: 0.875rem;
|
|
182
|
+
font-weight: 600;
|
|
183
|
+
}
|
|
184
|
+
.search input {
|
|
185
|
+
box-sizing: border-box;
|
|
186
|
+
inline-size: 100%;
|
|
187
|
+
min-block-size: 44px;
|
|
188
|
+
margin: 0;
|
|
189
|
+
padding: 0.5rem 0.75rem;
|
|
190
|
+
border: 1px solid ${c(O)};
|
|
191
|
+
border-radius: 0.3rem;
|
|
192
|
+
background: ${c(j)};
|
|
193
|
+
color: var(--uva-color-input-text, #1f2937);
|
|
194
|
+
font: inherit;
|
|
195
|
+
}
|
|
196
|
+
.search-status {
|
|
197
|
+
margin: 0.25rem 0 0;
|
|
198
|
+
}
|
|
199
|
+
mark {
|
|
200
|
+
background: none;
|
|
201
|
+
color: inherit;
|
|
202
|
+
font-weight: 700;
|
|
203
|
+
text-decoration: underline;
|
|
204
|
+
text-underline-offset: 0.15em;
|
|
205
|
+
}
|
|
206
|
+
.tools {
|
|
207
|
+
display: flex;
|
|
208
|
+
flex-wrap: wrap;
|
|
209
|
+
align-items: center;
|
|
210
|
+
gap: 0.25rem 0.75rem;
|
|
211
|
+
margin: 0 0 0.25rem;
|
|
212
|
+
}
|
|
213
|
+
.sort {
|
|
214
|
+
display: flex;
|
|
215
|
+
flex-wrap: wrap;
|
|
216
|
+
align-items: center;
|
|
217
|
+
}
|
|
218
|
+
.sort-label {
|
|
219
|
+
margin-inline-end: 0.5rem;
|
|
220
|
+
font-size: 0.875rem;
|
|
221
|
+
}
|
|
222
|
+
.seg {
|
|
223
|
+
position: relative;
|
|
224
|
+
display: inline-flex;
|
|
225
|
+
align-items: center;
|
|
226
|
+
min-block-size: 44px;
|
|
227
|
+
min-inline-size: 44px;
|
|
228
|
+
}
|
|
229
|
+
.seg + .seg {
|
|
230
|
+
margin-inline-start: -1px;
|
|
231
|
+
}
|
|
232
|
+
.seg input {
|
|
233
|
+
position: absolute;
|
|
234
|
+
inset: 0;
|
|
235
|
+
inline-size: 100%;
|
|
236
|
+
block-size: 100%;
|
|
237
|
+
margin: 0;
|
|
238
|
+
opacity: 0;
|
|
239
|
+
cursor: pointer;
|
|
240
|
+
}
|
|
241
|
+
.face {
|
|
242
|
+
display: inline-flex;
|
|
243
|
+
align-items: center;
|
|
244
|
+
gap: 0.3rem;
|
|
245
|
+
box-sizing: border-box;
|
|
246
|
+
min-block-size: 2.25rem;
|
|
247
|
+
padding: 0.25rem 0.625rem;
|
|
248
|
+
border: 1px solid ${c(O)};
|
|
249
|
+
background: ${c(j)};
|
|
250
|
+
color: ${c(k)};
|
|
251
|
+
font-size: 0.875rem;
|
|
252
|
+
font-weight: 600;
|
|
253
|
+
line-height: 1.3;
|
|
254
|
+
white-space: nowrap;
|
|
255
|
+
}
|
|
256
|
+
.seg:first-of-type .face {
|
|
257
|
+
border-start-start-radius: 0.3rem;
|
|
258
|
+
border-end-start-radius: 0.3rem;
|
|
259
|
+
}
|
|
260
|
+
.seg:last-of-type .face {
|
|
261
|
+
border-start-end-radius: 0.3rem;
|
|
262
|
+
border-end-end-radius: 0.3rem;
|
|
263
|
+
}
|
|
264
|
+
.seg input:checked + .face {
|
|
265
|
+
position: relative;
|
|
266
|
+
border-color: ${c(A)};
|
|
267
|
+
background: ${c(A)};
|
|
268
|
+
color: var(--uva-color-on-accent, #fff);
|
|
269
|
+
}
|
|
270
|
+
.seg input:focus-visible {
|
|
271
|
+
outline: none;
|
|
272
|
+
}
|
|
273
|
+
.seg input:focus-visible + .face,
|
|
274
|
+
.search input:focus-visible {
|
|
275
|
+
position: relative;
|
|
276
|
+
z-index: 1;
|
|
277
|
+
outline: 3px solid ${c(M)};
|
|
278
|
+
outline-offset: 2px;
|
|
279
|
+
}
|
|
280
|
+
.check {
|
|
281
|
+
flex: none;
|
|
282
|
+
inline-size: 1em;
|
|
283
|
+
block-size: 1em;
|
|
284
|
+
}
|
|
285
|
+
.button {
|
|
286
|
+
box-sizing: border-box;
|
|
287
|
+
min-block-size: 44px;
|
|
288
|
+
min-inline-size: 44px;
|
|
289
|
+
margin: 0;
|
|
290
|
+
padding: 0.25rem 0.875rem;
|
|
291
|
+
border: 1px solid ${c(O)};
|
|
292
|
+
border-radius: 0.3rem;
|
|
293
|
+
background: ${c(j)};
|
|
294
|
+
color: ${c(k)};
|
|
295
|
+
font: inherit;
|
|
296
|
+
font-size: 0.875rem;
|
|
297
|
+
font-weight: 600;
|
|
298
|
+
cursor: pointer;
|
|
299
|
+
}
|
|
300
|
+
.button:hover {
|
|
301
|
+
border-color: ${c(k)};
|
|
302
|
+
}
|
|
303
|
+
.clear {
|
|
304
|
+
margin-inline-start: auto;
|
|
305
|
+
}
|
|
306
|
+
.button.primary {
|
|
307
|
+
border-color: ${c(A)};
|
|
308
|
+
background: ${c(A)};
|
|
309
|
+
color: var(--uva-color-on-accent, #fff);
|
|
310
|
+
}
|
|
311
|
+
.button[aria-disabled='true'] {
|
|
312
|
+
border-style: dashed;
|
|
313
|
+
border-color: ${c(O)};
|
|
314
|
+
background: ${c(j)};
|
|
315
|
+
color: ${c(D)};
|
|
316
|
+
cursor: not-allowed;
|
|
317
|
+
}
|
|
318
|
+
.apply-bar {
|
|
319
|
+
display: flex;
|
|
320
|
+
flex-wrap: wrap;
|
|
321
|
+
align-items: center;
|
|
322
|
+
gap: 0.5rem;
|
|
323
|
+
margin-block-start: 0.5rem;
|
|
324
|
+
}
|
|
325
|
+
.apply-status {
|
|
326
|
+
flex: 1 1 100%;
|
|
327
|
+
margin: 0;
|
|
328
|
+
}
|
|
329
|
+
.pending {
|
|
330
|
+
margin-inline-start: 0.4rem;
|
|
331
|
+
padding: 0 0.3rem;
|
|
332
|
+
border: 1px dashed currentColor;
|
|
333
|
+
border-radius: 0.25rem;
|
|
334
|
+
color: ${c(D)};
|
|
335
|
+
font-size: 0.75rem;
|
|
336
|
+
font-style: italic;
|
|
337
|
+
}
|
|
338
|
+
.staged {
|
|
339
|
+
font-style: italic;
|
|
340
|
+
}
|
|
341
|
+
@media (forced-colors: active) {
|
|
342
|
+
.seg input:checked + .face,
|
|
343
|
+
.button.primary {
|
|
344
|
+
forced-color-adjust: none;
|
|
345
|
+
border-color: Highlight;
|
|
346
|
+
background: Highlight;
|
|
347
|
+
color: HighlightText;
|
|
348
|
+
}
|
|
349
|
+
.button[aria-disabled='true'] {
|
|
350
|
+
forced-color-adjust: none;
|
|
351
|
+
border-color: GrayText;
|
|
352
|
+
background: Canvas;
|
|
353
|
+
color: GrayText;
|
|
354
|
+
}
|
|
355
|
+
.toggle::after {
|
|
356
|
+
border-color: ButtonText;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
71
359
|
`];
|
|
72
360
|
}
|
|
73
361
|
get buckets() {
|
|
74
362
|
return this.filter?.buckets ?? [];
|
|
75
363
|
}
|
|
364
|
+
get facetTitle() {
|
|
365
|
+
return this.filter?.title ?? "";
|
|
366
|
+
}
|
|
367
|
+
get ordered() {
|
|
368
|
+
let e = this.buckets;
|
|
369
|
+
return this.sort === "name" ? [...e].sort((e, t) => x.compare(e.key, t.key)) : this.sortable ? [...e].sort((e, t) => t.doc_count - e.doc_count) : e;
|
|
370
|
+
}
|
|
371
|
+
isApplied(e) {
|
|
372
|
+
return this.value.some((t) => S(t) === S(e));
|
|
373
|
+
}
|
|
374
|
+
isChecked(e) {
|
|
375
|
+
return this.staged.get(S(e))?.checked ?? this.isApplied(e);
|
|
376
|
+
}
|
|
377
|
+
get shownValue() {
|
|
378
|
+
let e = this.value.filter((e) => this.staged.get(S(e))?.checked !== !1), t = [...this.staged.values()].filter((e) => e.checked).map((e) => e.key);
|
|
379
|
+
return [...e, ...t];
|
|
380
|
+
}
|
|
76
381
|
onChange(e) {
|
|
77
|
-
let t = e.target
|
|
78
|
-
|
|
79
|
-
|
|
382
|
+
let t = e.target;
|
|
383
|
+
if (this.applyButton) {
|
|
384
|
+
let e = S(t.value), n = new Map(this.staged);
|
|
385
|
+
t.checked === this.isApplied(t.value) ? n.delete(e) : n.set(e, {
|
|
386
|
+
key: t.value,
|
|
387
|
+
checked: t.checked
|
|
388
|
+
}), this.staged = n;
|
|
389
|
+
return;
|
|
390
|
+
}
|
|
391
|
+
let n = this.value.filter((e) => e.toLowerCase() !== t.value.toLowerCase());
|
|
392
|
+
this.value = t.checked ? [...n, t.value] : n, f(this, [
|
|
393
|
+
m,
|
|
80
394
|
"facet-change",
|
|
81
395
|
`${this.filter.title}: ${t.value}`,
|
|
82
396
|
+t.checked
|
|
83
|
-
]), this.
|
|
397
|
+
]), this.emitChange();
|
|
398
|
+
}
|
|
399
|
+
emitChange() {
|
|
400
|
+
this.dispatchEvent(new CustomEvent("filter-change", { detail: {
|
|
84
401
|
name: this.filter.name,
|
|
85
402
|
value: this.value
|
|
86
403
|
} }));
|
|
@@ -90,13 +407,96 @@ var d = "uvalib-filter", f = 0, p = class extends s {
|
|
|
90
407
|
let n = this.scopeValue.filter((t) => t.toLowerCase() !== e.toLowerCase()), r = n.length === this.scopeValue.length;
|
|
91
408
|
this.scopeValue = r ? [...n, e] : n;
|
|
92
409
|
let i = this.scopes.find((t) => t.value === e)?.label ?? e;
|
|
93
|
-
|
|
94
|
-
|
|
410
|
+
f(this, [
|
|
411
|
+
m,
|
|
95
412
|
"scope-change",
|
|
96
413
|
i,
|
|
97
414
|
+r
|
|
98
415
|
]), this.dispatchEvent(new CustomEvent("scope-change", { detail: { value: this.scopeValue } }));
|
|
99
416
|
}
|
|
417
|
+
toggleOpen() {
|
|
418
|
+
this.collapsed = !this.collapsed;
|
|
419
|
+
let e = !this.collapsed;
|
|
420
|
+
f(this, [
|
|
421
|
+
m,
|
|
422
|
+
"toggle",
|
|
423
|
+
this.facetTitle,
|
|
424
|
+
+e
|
|
425
|
+
]), this.dispatchEvent(new CustomEvent("toggle", { detail: { open: e } }));
|
|
426
|
+
}
|
|
427
|
+
onSort(e) {
|
|
428
|
+
let t = e.target.value;
|
|
429
|
+
this.sort = t, f(this, [
|
|
430
|
+
m,
|
|
431
|
+
"sort",
|
|
432
|
+
`${this.facetTitle}: ${t}`
|
|
433
|
+
]), this.dispatchEvent(new CustomEvent("sort", { detail: { sort: t } }));
|
|
434
|
+
}
|
|
435
|
+
async clear() {
|
|
436
|
+
let e = this.shownValue.length, t = this.value.length;
|
|
437
|
+
this.staged = /* @__PURE__ */ new Map(), f(this, [
|
|
438
|
+
m,
|
|
439
|
+
"clear",
|
|
440
|
+
this.facetTitle,
|
|
441
|
+
e
|
|
442
|
+
]), t && (this.value = [], this.emitChange()), await this.updateComplete;
|
|
443
|
+
let n = this.renderRoot;
|
|
444
|
+
(n.querySelector("input[type=checkbox]") ?? n.querySelector("button[part=toggle]"))?.focus();
|
|
445
|
+
}
|
|
446
|
+
apply() {
|
|
447
|
+
let e = [...this.staged.values()];
|
|
448
|
+
if (e.length) {
|
|
449
|
+
this.value = this.shownValue, this.staged = /* @__PURE__ */ new Map();
|
|
450
|
+
for (let t of e) f(this, [
|
|
451
|
+
m,
|
|
452
|
+
"facet-change",
|
|
453
|
+
`${this.facetTitle}: ${t.key}`,
|
|
454
|
+
+t.checked
|
|
455
|
+
]);
|
|
456
|
+
f(this, [
|
|
457
|
+
m,
|
|
458
|
+
"apply",
|
|
459
|
+
this.facetTitle,
|
|
460
|
+
e.length
|
|
461
|
+
]), this.emitChange();
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
reset() {
|
|
465
|
+
this.staged = /* @__PURE__ */ new Map();
|
|
466
|
+
}
|
|
467
|
+
onSearch(e) {
|
|
468
|
+
this.query = e.target.value, this.scheduleStatus();
|
|
469
|
+
}
|
|
470
|
+
onSearchKey(e) {
|
|
471
|
+
e.key === "Escape" && this.query && (e.preventDefault(), e.stopPropagation(), e.target.value = "", this.query = "", this.scheduleStatus());
|
|
472
|
+
}
|
|
473
|
+
get search() {
|
|
474
|
+
let e = this.searchable ? v(this.query.trim()) : "";
|
|
475
|
+
return {
|
|
476
|
+
q: e,
|
|
477
|
+
matches: e ? this.ordered.filter((t) => v(t.key).includes(e)) : []
|
|
478
|
+
};
|
|
479
|
+
}
|
|
480
|
+
statusText(e) {
|
|
481
|
+
return `${w(e)} of ${w(this.buckets.length)} ${this.unit}`;
|
|
482
|
+
}
|
|
483
|
+
scheduleStatus() {
|
|
484
|
+
clearTimeout(this.announceTimer), clearTimeout(this.trackTimer), this.search.q ? (this.announceTimer = setTimeout(() => {
|
|
485
|
+
let { q: e, matches: t } = this.search;
|
|
486
|
+
e && (this.announcement = this.statusText(t.length));
|
|
487
|
+
}, h.announce), this.trackTimer = setTimeout(() => {
|
|
488
|
+
let { q: e, matches: t } = this.search;
|
|
489
|
+
e && e !== this.lastTracked && (this.lastTracked = e, f(this, [
|
|
490
|
+
m,
|
|
491
|
+
"search",
|
|
492
|
+
this.facetTitle,
|
|
493
|
+
t.length
|
|
494
|
+
]));
|
|
495
|
+
}, h.track)) : this.announcement = "";
|
|
496
|
+
}
|
|
497
|
+
disconnectedCallback() {
|
|
498
|
+
super.disconnectedCallback(), clearTimeout(this.announceTimer), clearTimeout(this.trackTimer);
|
|
499
|
+
}
|
|
100
500
|
get focused() {
|
|
101
501
|
let e = this.renderRoot instanceof ShadowRoot ? this.renderRoot.activeElement : this.contains(document.activeElement) ? document.activeElement : null;
|
|
102
502
|
return e instanceof HTMLElement ? e : null;
|
|
@@ -115,7 +515,11 @@ var d = "uvalib-filter", f = 0, p = class extends s {
|
|
|
115
515
|
}
|
|
116
516
|
willUpdate(e) {
|
|
117
517
|
let t = this.hasUpdated ? this.focused : null;
|
|
118
|
-
if (this.focusKey = t ? this.keyOf(t) : void 0,
|
|
518
|
+
if (this.focusKey = t ? this.keyOf(t) : void 0, e.has("value") && this.staged.size) {
|
|
519
|
+
let t = new Set((e.get("value") ?? []).map(S)), n = new Set(this.value.map(S));
|
|
520
|
+
(t.size !== n.size || [...n].some((e) => !t.has(e))) && (this.staged = /* @__PURE__ */ new Map());
|
|
521
|
+
}
|
|
522
|
+
if (e.has("applyButton") && !this.applyButton && (this.staged = /* @__PURE__ */ new Map()), !e.has("limit") && !e.has("filter")) return;
|
|
119
523
|
let n = this.buckets.length, r = this.filter?.name;
|
|
120
524
|
this.currentLimit = this.limit <= 0 ? n : e.has("limit") || r !== this.facetName ? this.limit : Math.max(this.limit, Math.min(this.currentLimit, n)), this.facetName = r;
|
|
121
525
|
}
|
|
@@ -124,82 +528,212 @@ var d = "uvalib-filter", f = 0, p = class extends s {
|
|
|
124
528
|
this.focusKey = void 0, e && !this.focused && this.findByFocusKey(e)?.focus({ preventScroll: !0 });
|
|
125
529
|
}
|
|
126
530
|
showMore() {
|
|
127
|
-
this.currentLimit = Math.min(this.currentLimit * 2, this.buckets.length),
|
|
128
|
-
|
|
531
|
+
this.currentLimit = Math.min(this.currentLimit * 2, this.buckets.length), f(this, [
|
|
532
|
+
m,
|
|
129
533
|
"see-more",
|
|
130
534
|
this.filter.title
|
|
131
535
|
]);
|
|
132
536
|
}
|
|
133
537
|
showLess() {
|
|
134
|
-
this.currentLimit = Math.max(Math.ceil(this.currentLimit / 2), this.limit),
|
|
135
|
-
|
|
538
|
+
this.currentLimit = Math.max(Math.ceil(this.currentLimit / 2), this.limit), f(this, [
|
|
539
|
+
m,
|
|
136
540
|
"see-less",
|
|
137
541
|
this.filter.title
|
|
138
542
|
]);
|
|
139
543
|
}
|
|
544
|
+
renderLegend(e, t, n) {
|
|
545
|
+
let r = this.headingLevel >= 2 && this.headingLevel <= 6 ? this.headingLevel : 0;
|
|
546
|
+
if (!this.collapsible) return E(r, e);
|
|
547
|
+
let a = !this.collapsed;
|
|
548
|
+
return E(r, i`<button
|
|
549
|
+
type="button"
|
|
550
|
+
part="toggle"
|
|
551
|
+
class="toggle"
|
|
552
|
+
aria-expanded=${a ? "true" : "false"}
|
|
553
|
+
aria-controls=${t}
|
|
554
|
+
@click=${this.toggleOpen}
|
|
555
|
+
>
|
|
556
|
+
<span
|
|
557
|
+
>${e}${!a && n ? i`<span class="selected-count"
|
|
558
|
+
><span class="visually-hidden">, </span>${n} selected</span
|
|
559
|
+
>` : s}</span
|
|
560
|
+
>
|
|
561
|
+
</button>`);
|
|
562
|
+
}
|
|
563
|
+
renderSort() {
|
|
564
|
+
let e = `${this.uid}-sort`;
|
|
565
|
+
return i`<div class="sort" role="radiogroup" aria-labelledby="${e}-label">
|
|
566
|
+
<span class="sort-label" id="${e}-label">Sort by</span>
|
|
567
|
+
${[["count", "Count"], ["name", "Name (A–Z)"]].map(([t, n]) => i`<label class="seg"
|
|
568
|
+
><input
|
|
569
|
+
type="radio"
|
|
570
|
+
name=${e}
|
|
571
|
+
form="${e}-none"
|
|
572
|
+
value=${t}
|
|
573
|
+
.checked=${this.sort === t}
|
|
574
|
+
@change=${this.onSort}
|
|
575
|
+
/><span class="face">${this.sort === t ? T : s}${n}</span></label
|
|
576
|
+
>`)}
|
|
577
|
+
</div>`;
|
|
578
|
+
}
|
|
579
|
+
renderBucket(e, t, n) {
|
|
580
|
+
let r = `${this.uid}-${t}`, a = this.isChecked(e.key), o = this.staged.has(S(e.key)), c = e.key ? b(e.key, n) : "(empty)", l = e.doc_count, u = o ? i`<span class="pending">not applied</span>` : s;
|
|
581
|
+
return i`<div class="checkbox">
|
|
582
|
+
<input
|
|
583
|
+
type="checkbox"
|
|
584
|
+
id=${r}
|
|
585
|
+
name=${this.filter.name}
|
|
586
|
+
value=${e.key}
|
|
587
|
+
@change=${this.onChange}
|
|
588
|
+
.checked=${a}
|
|
589
|
+
/>
|
|
590
|
+
<label for=${r} class=${o ? "staged" : s}>${c} (${l})${u}</label>
|
|
591
|
+
</div>`;
|
|
592
|
+
}
|
|
140
593
|
render() {
|
|
141
|
-
let e = this.buckets.length, t = this.
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
594
|
+
let e = this.buckets.length, t = this.facetTitle, { q: n, matches: r } = this.search, a = `${this.uid}-list`, o = `${this.uid}-body`, c = `${this.uid}-match`, l = this.shownValue.length, f = this.staged.size, p = f ? `${C(f, "change")} not applied yet` : "", m = f ? `Apply ${C(f, "change")}` : "Apply", h = this.collapsible || this.headingLevel > 0, g, _ = 0;
|
|
595
|
+
if (n) {
|
|
596
|
+
let e = r.filter((e) => !this.isChecked(e.key));
|
|
597
|
+
g = [...this.ordered.filter((e) => this.isChecked(e.key)), ...e.slice(0, 100)];
|
|
598
|
+
} else _ = Math.min(this.currentLimit || e, e), g = this.ordered.slice(0, _);
|
|
599
|
+
let v = this.limit > 0 && !n, y = n && r.filter((e) => !this.isChecked(e.key)).length > 100, b = i`
|
|
600
|
+
${this.match === "any" || this.match === "all" ? i`<p class="match" id=${c}>
|
|
601
|
+
${this.match === "all" ? "Matches all selected values" : "Matches any selected value"}
|
|
602
|
+
</p>` : s}
|
|
603
|
+
${this.scopes.length ? i`<div
|
|
604
|
+
class="scopes"
|
|
605
|
+
role="group"
|
|
606
|
+
aria-label=${this.scopesLabel || `Filter ${t} by type`}
|
|
607
|
+
>
|
|
608
|
+
${this.scopes.map((e) => {
|
|
609
|
+
let t = this.scopeValue.some((t) => S(t) === S(e.value));
|
|
610
|
+
return i`<button
|
|
611
|
+
type="button"
|
|
612
|
+
class="scope"
|
|
613
|
+
value=${e.value}
|
|
614
|
+
aria-pressed=${t ? "true" : "false"}
|
|
615
|
+
@click=${(t) => this.toggleScope(e.value, t)}
|
|
616
|
+
>
|
|
617
|
+
${e.label}
|
|
618
|
+
</button>`;
|
|
161
619
|
})}
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
620
|
+
</div>` : s}
|
|
621
|
+
${this.searchable ? i`<div class="search">
|
|
622
|
+
<label for="${this.uid}-search">${this.searchLabel || `Search ${t}`}</label>
|
|
623
|
+
<input
|
|
624
|
+
id="${this.uid}-search"
|
|
625
|
+
part="search"
|
|
626
|
+
type="search"
|
|
627
|
+
autocomplete="off"
|
|
628
|
+
spellcheck="false"
|
|
629
|
+
.value=${this.query}
|
|
630
|
+
@input=${this.onSearch}
|
|
631
|
+
@keydown=${this.onSearchKey}
|
|
632
|
+
/>
|
|
633
|
+
${n ? i`<p class="search-status">
|
|
634
|
+
${this.statusText(r.length)}${y ? ". Showing the first 100; type more to narrow them." : ""}
|
|
635
|
+
</p>` : s}
|
|
636
|
+
<span class="visually-hidden" role="status" aria-live="polite" aria-atomic="true"
|
|
637
|
+
>${this.announcement}</span
|
|
638
|
+
>
|
|
639
|
+
</div>` : s}
|
|
640
|
+
${this.sortable || this.clearable && l ? i`<div class="tools">
|
|
641
|
+
${this.sortable ? this.renderSort() : s}
|
|
642
|
+
${this.clearable && l ? i`<button
|
|
643
|
+
type="button"
|
|
644
|
+
part="clear"
|
|
645
|
+
class="button clear"
|
|
646
|
+
@click=${this.clear}
|
|
647
|
+
>
|
|
648
|
+
Clear<span class="visually-hidden"> ${t} filters</span>
|
|
649
|
+
</button>` : s}
|
|
650
|
+
</div>` : s}
|
|
651
|
+
<div id=${a}>
|
|
652
|
+
${u(g, (e) => e.key, (e, t) => this.renderBucket(e, t, n))}
|
|
653
|
+
</div>
|
|
654
|
+
${v && _ < e ? i`<button
|
|
655
|
+
type="button"
|
|
656
|
+
part="see-more"
|
|
657
|
+
aria-controls=${a}
|
|
658
|
+
@click=${this.showMore}
|
|
659
|
+
>
|
|
660
|
+
See more<span class="visually-hidden"> ${t}</span>
|
|
661
|
+
</button>` : s}
|
|
662
|
+
${v && _ > this.limit ? i`<button
|
|
663
|
+
type="button"
|
|
664
|
+
part="see-less"
|
|
665
|
+
aria-controls=${a}
|
|
666
|
+
@click=${this.showLess}
|
|
667
|
+
>
|
|
668
|
+
See less<span class="visually-hidden"> ${t}</span>
|
|
669
|
+
</button>` : s}
|
|
670
|
+
${this.applyButton ? i`<div class="apply-bar">
|
|
671
|
+
<p class="apply-status" role="status" aria-live="polite">${p}</p>
|
|
672
|
+
<button
|
|
180
673
|
type="button"
|
|
181
|
-
part="
|
|
182
|
-
|
|
183
|
-
|
|
674
|
+
part="apply"
|
|
675
|
+
class="button primary"
|
|
676
|
+
aria-disabled=${f ? "false" : "true"}
|
|
677
|
+
@click=${this.apply}
|
|
184
678
|
>
|
|
185
|
-
|
|
186
|
-
</button
|
|
187
|
-
|
|
679
|
+
${m}<span class="visually-hidden"> to ${t}</span>
|
|
680
|
+
</button>
|
|
681
|
+
<button
|
|
188
682
|
type="button"
|
|
189
|
-
part="
|
|
190
|
-
|
|
191
|
-
|
|
683
|
+
part="reset"
|
|
684
|
+
class="button"
|
|
685
|
+
aria-disabled=${f ? "false" : "true"}
|
|
686
|
+
@click=${this.reset}
|
|
192
687
|
>
|
|
193
|
-
|
|
194
|
-
</button
|
|
688
|
+
Reset<span class="visually-hidden"> ${t}</span>
|
|
689
|
+
</button>
|
|
690
|
+
</div>` : s}
|
|
691
|
+
`, x = this.renderLegend(t, o, l), w = this.match === "any" || this.match === "all" ? c : void 0;
|
|
692
|
+
return i`
|
|
693
|
+
<fieldset aria-describedby=${d(w)}>
|
|
694
|
+
<legend class=${h ? "group" : s}>${x}</legend>
|
|
695
|
+
${this.collapsible ? i`<div class="body collapsible" id=${o} ?hidden=${this.collapsed}>
|
|
696
|
+
${b}
|
|
697
|
+
</div>` : b}
|
|
195
698
|
</fieldset>
|
|
196
699
|
`;
|
|
197
700
|
}
|
|
198
701
|
};
|
|
199
702
|
// src/components/uvalib-filter/uvalib-filter.ts
|
|
200
|
-
|
|
703
|
+
o([e({ type: Object })], N.prototype, "filter", void 0), o([e({ type: Array })], N.prototype, "value", void 0), o([e({ type: Array })], N.prototype, "scopes", void 0), o([e({ type: Array })], N.prototype, "scopeValue", void 0), o([e({
|
|
201
704
|
type: String,
|
|
202
705
|
attribute: "scopes-label"
|
|
203
|
-
})],
|
|
706
|
+
})], N.prototype, "scopesLabel", void 0), o([e({ type: Number })], N.prototype, "limit", void 0), o([e({
|
|
707
|
+
type: Boolean,
|
|
708
|
+
reflect: !0
|
|
709
|
+
})], N.prototype, "collapsible", void 0), o([e({
|
|
710
|
+
type: Boolean,
|
|
711
|
+
reflect: !0
|
|
712
|
+
})], N.prototype, "collapsed", void 0), o([e({
|
|
713
|
+
type: Number,
|
|
714
|
+
attribute: "heading-level"
|
|
715
|
+
})], N.prototype, "headingLevel", void 0), o([e({
|
|
716
|
+
type: Boolean,
|
|
717
|
+
reflect: !0
|
|
718
|
+
})], N.prototype, "searchable", void 0), o([e({
|
|
719
|
+
type: String,
|
|
720
|
+
attribute: "search-label"
|
|
721
|
+
})], N.prototype, "searchLabel", void 0), o([e({ type: String })], N.prototype, "unit", void 0), o([e({
|
|
722
|
+
type: Boolean,
|
|
723
|
+
reflect: !0
|
|
724
|
+
})], N.prototype, "sortable", void 0), o([e({
|
|
725
|
+
type: String,
|
|
726
|
+
reflect: !0
|
|
727
|
+
})], N.prototype, "sort", void 0), o([e({
|
|
728
|
+
type: Boolean,
|
|
729
|
+
reflect: !0
|
|
730
|
+
})], N.prototype, "clearable", void 0), o([e({
|
|
731
|
+
type: Boolean,
|
|
732
|
+
reflect: !0,
|
|
733
|
+
attribute: "apply-button"
|
|
734
|
+
})], N.prototype, "applyButton", void 0), o([e({
|
|
735
|
+
type: String,
|
|
736
|
+
reflect: !0
|
|
737
|
+
})], N.prototype, "match", void 0), o([r()], N.prototype, "currentLimit", void 0), o([r()], N.prototype, "query", void 0), o([r()], N.prototype, "announcement", void 0), o([r()], N.prototype, "staged", void 0), a("uvalib-filter", N);
|
|
204
738
|
|
|
205
739
|
//# sourceMappingURL=uvalib-filter.js.map
|