@uvalib/web-components 1.8.4 → 1.9.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 +32 -0
- package/README.md +486 -60
- 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 +188 -3
- package/dist/components/site-page/SitePage.js +2 -1
- package/dist/components/site-page/SitePage.js.map +1 -1
- package/dist/components/site-style/SiteStyle.js +2 -1
- package/dist/components/site-style/SiteStyle.js.map +1 -1
- 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-metadata/UvalibMetadata.js +3 -4
- package/dist/components/uvalib-metadata/UvalibMetadata.js.map +1 -1
- package/dist/custom-elements.json +5881 -3592
- package/dist/index.d.ts +4 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/styles/base.js +41 -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 +4 -0
- package/dist/styles/controls.js.map +1 -1
- 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/font-fallback.d.ts +7 -0
- package/dist/styles/font-fallback.js +15 -0
- package/dist/styles/font-fallback.js.map +1 -1
- package/dist/styles/hidden.js +13 -1
- package/dist/styles/hidden.js.map +1 -1
- 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 +188 -3
- package/dist-cdn/chunks/{base-DfLI8lpa.js → base-CHMHBPeI.js} +58 -7
- package/dist-cdn/chunks/base-CHMHBPeI.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 +5881 -3592
- package/dist-cdn/manifest.json +4 -2
- package/dist-cdn/site-header.js +1 -1
- package/dist-cdn/site-main-nav.js +1 -1
- package/dist-cdn/site-page.js +48 -48
- package/dist-cdn/site-page.js.map +1 -1
- package/dist-cdn/site-style.js +7 -7
- package/dist-cdn/site-style.js.map +1 -1
- package/dist-cdn/skills/uvalib-web-components/SKILL.md +8 -5
- package/dist-cdn/skills/uvalib-web-components/reference/components.md +135 -8
- 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-metadata.js +49 -49
- package/dist-cdn/uvalib-metadata.js.map +1 -1
- package/package.json +9 -1
- package/skills/uvalib-web-components/SKILL.md +8 -5
- package/skills/uvalib-web-components/reference/components.md +135 -8
- package/dist-cdn/chunks/base-DfLI8lpa.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
|
@@ -4,36 +4,125 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { html, css, nothing } from 'lit';
|
|
7
|
+
import { html, css, svg, unsafeCSS, nothing } from 'lit';
|
|
8
8
|
import { property, state } from 'lit/decorators.js';
|
|
9
9
|
import { repeat } from 'lit/directives/repeat.js';
|
|
10
|
+
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
10
11
|
import { trackEvent } from '../../base/analytics.js';
|
|
11
12
|
import { UvalibElement } from '../../base/UvalibElement.js';
|
|
12
13
|
import { accessible } from '../../styles/accessible.js';
|
|
13
14
|
/** The analytics category. */
|
|
14
15
|
const TAG = 'uvalib-filter';
|
|
16
|
+
/**
|
|
17
|
+
* Timing of the search-within status, in milliseconds (exported for tests). `announce`: after
|
|
18
|
+
* the last keystroke, the polite "12 of 340 subjects" is spoken. `track`: after the last
|
|
19
|
+
* keystroke, one `search` analytics event (the number of matches, never the text) is sent.
|
|
20
|
+
*/
|
|
21
|
+
export const filterTiming = { announce: 500, track: 1500 };
|
|
22
|
+
/** While searching, at most this many matching values are listed ("Type more to narrow them"). */
|
|
23
|
+
export const SEARCH_CAP = 100;
|
|
15
24
|
/** Element ids share the document id space in light DOM, so each instance gets its own prefix. */
|
|
16
25
|
let instanceCounter = 0;
|
|
26
|
+
const MARKS = /\p{M}/gu;
|
|
27
|
+
/** Case- and accent-insensitive form: "Ébène" and "ebene" match. */
|
|
28
|
+
const fold = (s) => s.normalize('NFD').replace(MARKS, '').toLowerCase();
|
|
29
|
+
/** `label` folded, with the index in `label` that each folded character came from. */
|
|
30
|
+
function foldMap(label) {
|
|
31
|
+
let text = '';
|
|
32
|
+
const map = [];
|
|
33
|
+
let i = 0;
|
|
34
|
+
for (const ch of label) {
|
|
35
|
+
const f = fold(ch);
|
|
36
|
+
for (let k = 0; k < f.length; k++)
|
|
37
|
+
map.push(i);
|
|
38
|
+
text += f;
|
|
39
|
+
i += ch.length;
|
|
40
|
+
}
|
|
41
|
+
map.push(i);
|
|
42
|
+
return { text, map };
|
|
43
|
+
}
|
|
44
|
+
/** `label` with each match of the folded query `q` in a `<mark>`. */
|
|
45
|
+
function marked(label, q) {
|
|
46
|
+
if (!q)
|
|
47
|
+
return label;
|
|
48
|
+
const { text, map } = foldMap(label);
|
|
49
|
+
const parts = [];
|
|
50
|
+
let last = 0;
|
|
51
|
+
for (let i = text.indexOf(q); i !== -1; i = text.indexOf(q, i + q.length)) {
|
|
52
|
+
const s = map[i];
|
|
53
|
+
const end = map[i + q.length];
|
|
54
|
+
if (s > last)
|
|
55
|
+
parts.push(label.slice(last, s));
|
|
56
|
+
parts.push(html `<mark>${label.slice(s, end)}</mark>`);
|
|
57
|
+
last = end;
|
|
58
|
+
}
|
|
59
|
+
parts.push(label.slice(last));
|
|
60
|
+
return parts;
|
|
61
|
+
}
|
|
62
|
+
const collator = new Intl.Collator(undefined, { sensitivity: 'base', numeric: true });
|
|
63
|
+
const lower = (s) => s.toLowerCase();
|
|
64
|
+
const plural = (n, one, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
|
|
65
|
+
const count = (n) => n.toLocaleString('en-US');
|
|
66
|
+
/** The tick on the current sort, so it never rests on colour alone. */
|
|
67
|
+
const CHECK = svg `<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>`;
|
|
68
|
+
/** A heading of `level` (2 to 6) around `content`, or the content alone. */
|
|
69
|
+
function heading(level, content) {
|
|
70
|
+
switch (level) {
|
|
71
|
+
case 2:
|
|
72
|
+
return html `<h2 class="heading">${content}</h2>`;
|
|
73
|
+
case 3:
|
|
74
|
+
return html `<h3 class="heading">${content}</h3>`;
|
|
75
|
+
case 4:
|
|
76
|
+
return html `<h4 class="heading">${content}</h4>`;
|
|
77
|
+
case 5:
|
|
78
|
+
return html `<h5 class="heading">${content}</h5>`;
|
|
79
|
+
case 6:
|
|
80
|
+
return html `<h6 class="heading">${content}</h6>`;
|
|
81
|
+
default:
|
|
82
|
+
return content;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
const MUTED = 'var(--uva-color-text-muted, #4f4f4f)';
|
|
86
|
+
const BORDER = 'var(--uva-color-control-border, var(--uva-grey, #808080))';
|
|
87
|
+
const LINK = 'var(--uva-color-link, var(--uva-brand-blue, #232d4b))';
|
|
88
|
+
const ACCENT = 'var(--uva-color-accent-bg, var(--uva-brand-blue, #232d4b))';
|
|
89
|
+
const RAISED = 'var(--uva-color-surface-raised, #fff)';
|
|
90
|
+
const FOCUS = 'var(--uva-color-focus, var(--uva-brand-orange, #e57200))';
|
|
17
91
|
/**
|
|
18
92
|
* A faceted-search filter: a fieldset of checkboxes (value plus result count), optional
|
|
19
93
|
* toggle chips ("scopes") above them, and "See more" / "See less" buttons when `limit` is set.
|
|
20
94
|
* It is controlled: set `filter`, `value` and `scopeValue` from your search state and listen
|
|
21
95
|
* for the change events.
|
|
22
96
|
*
|
|
97
|
+
* Optional filter-group features, each off by default (without them the markup, events and
|
|
98
|
+
* order are as before): `collapsible` (a caret disclosure button in the legend, with the
|
|
99
|
+
* selected count while collapsed), `searchable` (search within the values), `sortable`
|
|
100
|
+
* (Count | Name (A–Z)), `clearable` (a Clear button), `apply-button` (stage changes until
|
|
101
|
+
* Apply) and `match` (says how the values combine).
|
|
102
|
+
*
|
|
23
103
|
* @tagname uvalib-filter
|
|
24
|
-
* @fires filter-change - A checkbox was toggled. `detail` is `{ name, value }`: the facet name and the new array of selected keys. Does not bubble.
|
|
104
|
+
* @fires filter-change - A checkbox was toggled, Clear was pressed, or (with `apply-button`) Apply was pressed. `detail` is `{ name, value }`: the facet name and the new array of selected keys (`[]` after Clear). Does not bubble.
|
|
25
105
|
* @fires scope-change - A scope chip was toggled. `detail` is `{ value }`: the new array of pressed scope values. Does not bubble.
|
|
26
|
-
* @fires
|
|
106
|
+
* @fires toggle - With `collapsible`: the visitor opened or closed the group. `detail` is `{ open }`. Does not bubble.
|
|
107
|
+
* @fires sort - With `sortable`: the visitor chose a sort. `detail` is `{ sort }` (`count` or `name`). Does not bubble.
|
|
108
|
+
* @fires uvalib-analytics-event - For `<site-analytics>`, on the visitor's changes only: `['uvalib-filter', 'facet-change', '<title>: <value>', 1 | 0]` (checked or unchecked; with `apply-button`, one per value when Apply is pressed), `['uvalib-filter', 'scope-change', <scope label>, 1 | 0]` (pressed or not), `['uvalib-filter', 'see-more' | 'see-less', <title>]`, `['uvalib-filter', 'toggle', <title>, 1 | 0]` (opened or closed), `['uvalib-filter', 'sort', '<title>: count' | '<title>: name']`, `['uvalib-filter', 'clear', <title>, <number cleared>]`, `['uvalib-filter', 'apply', <title>, <number of changes>]` and `['uvalib-filter', 'search', <title>, <number of matches>]` once a search-within settles (never the typed text). Bubbles and is composed.
|
|
27
109
|
* @csspart see-more - The "See more" button (shadow mode).
|
|
28
110
|
* @csspart see-less - The "See less" button (shadow mode).
|
|
111
|
+
* @csspart toggle - The disclosure button in the legend (`collapsible`).
|
|
112
|
+
* @csspart search - The search-within field (`searchable`).
|
|
113
|
+
* @csspart clear - The Clear button (`clearable`).
|
|
114
|
+
* @csspart apply - The Apply button (`apply-button`).
|
|
115
|
+
* @csspart reset - The Reset button (`apply-button`).
|
|
29
116
|
* @cssprop [--uva-brand-blue=#232d4b] - Scope chip text, hover border and pressed background.
|
|
30
117
|
* @cssprop [--uva-brand-orange=#e57200] - Focus ring colour (focus-visible outline).
|
|
31
118
|
* @cssprop --uva-color-border - Dark-mode role token: divider under the scope chips (else #e5e7eb).
|
|
32
|
-
* @cssprop --uva-color-control-border - Dark-mode role token: scope chip
|
|
33
|
-
* @cssprop --uva-color-surface-raised - Dark-mode role token: scope chip background (else #fff).
|
|
34
|
-
* @cssprop --uva-color-link - Dark-mode role token: scope chip text
|
|
35
|
-
* @cssprop --uva-color-accent-bg - Dark-mode role token: pressed chip
|
|
36
|
-
* @cssprop --uva-color-on-accent - Dark-mode role token: pressed chip text (else #fff).
|
|
119
|
+
* @cssprop --uva-color-control-border - Dark-mode role token: scope chip, search field, sort and button borders (else `--uva-grey`, #808080).
|
|
120
|
+
* @cssprop --uva-color-surface-raised - Dark-mode role token: scope chip, search field, sort and button background (else #fff).
|
|
121
|
+
* @cssprop --uva-color-link - Dark-mode role token: scope chip and button text, the caret, hover border (else `--uva-brand-blue`).
|
|
122
|
+
* @cssprop --uva-color-accent-bg - Dark-mode role token: pressed chip, current sort and Apply background (else `--uva-brand-blue`).
|
|
123
|
+
* @cssprop --uva-color-on-accent - Dark-mode role token: pressed chip, current sort and Apply text (else #fff).
|
|
124
|
+
* @cssprop --uva-color-text-muted - Dark-mode role token: the match text, selected count, search status and staged note (else #4f4f4f).
|
|
125
|
+
* @cssprop --uva-color-input-text - Dark-mode role token: search field text (else #1f2937).
|
|
37
126
|
* @cssprop --uva-color-focus - Dark-mode role token: focus ring (else `--uva-brand-orange`).
|
|
38
127
|
*/
|
|
39
128
|
export class UvalibFilter extends UvalibElement {
|
|
@@ -51,8 +140,35 @@ export class UvalibFilter extends UvalibElement {
|
|
|
51
140
|
this.scopesLabel = '';
|
|
52
141
|
/** Maximum buckets to show at first; 0 shows all. "See more" doubles it, "See less" halves it back. */
|
|
53
142
|
this.limit = 0;
|
|
143
|
+
/** The legend becomes a disclosure button (with the library's caret) that shows and hides the group. */
|
|
144
|
+
this.collapsible = false;
|
|
145
|
+
/** With `collapsible`: the group is closed (its legend button and selected count only). The visitor's toggle updates it; nothing is remembered. */
|
|
146
|
+
this.collapsed = false;
|
|
147
|
+
/** Wrap the legend's text (or disclosure button) in a heading of this level, 2 to 6. Unset (the default): no heading, as before. */
|
|
148
|
+
this.headingLevel = 0;
|
|
149
|
+
/** A search field above the values that narrows them as the visitor types. */
|
|
150
|
+
this.searchable = false;
|
|
151
|
+
/** The search field's visible label. Empty (the default) means `Search <title>`. */
|
|
152
|
+
this.searchLabel = '';
|
|
153
|
+
/** What the values are, plural, for the search status ("12 of 340 subjects"). */
|
|
154
|
+
this.unit = 'values';
|
|
155
|
+
/** A "Sort by: Count | Name (A–Z)" control. */
|
|
156
|
+
this.sortable = false;
|
|
157
|
+
/** The order: `count` (most results first; without `sortable`, the data's own order) or `name` (A–Z). The visitor's choice updates it. */
|
|
158
|
+
this.sort = 'count';
|
|
159
|
+
/** A Clear button, shown while something in the group is selected. */
|
|
160
|
+
this.clearable = false;
|
|
161
|
+
/** Stage checkbox changes until the visitor presses Apply (with Reset back to the applied state); `filter-change` fires on Apply only. */
|
|
162
|
+
this.applyButton = false;
|
|
54
163
|
this.currentLimit = 0;
|
|
164
|
+
/** The search-within text, as typed. */
|
|
165
|
+
this.query = '';
|
|
166
|
+
/** What the polite live region says (the settled search status). */
|
|
167
|
+
this.announcement = '';
|
|
168
|
+
/** With `apply-button`: keys (lower-cased) whose checkbox differs from `value`, and the state shown. */
|
|
169
|
+
this.staged = new Map();
|
|
55
170
|
this.uid = `uvalib-filter-${++instanceCounter}`;
|
|
171
|
+
this.lastTracked = '';
|
|
56
172
|
}
|
|
57
173
|
static { this.styles = [
|
|
58
174
|
accessible,
|
|
@@ -64,6 +180,7 @@ export class UvalibFilter extends UvalibElement {
|
|
|
64
180
|
border: none;
|
|
65
181
|
padding: 0;
|
|
66
182
|
margin: 0;
|
|
183
|
+
min-inline-size: 0;
|
|
67
184
|
}
|
|
68
185
|
legend {
|
|
69
186
|
font-weight: bold;
|
|
@@ -111,16 +228,302 @@ export class UvalibFilter extends UvalibElement {
|
|
|
111
228
|
outline: 2px solid var(--uva-color-focus, var(--uva-brand-orange, #e57200));
|
|
112
229
|
outline-offset: 2px;
|
|
113
230
|
}
|
|
231
|
+
|
|
232
|
+
/* ---- Filter-group features (each opt-in). ---- */
|
|
233
|
+
legend.group {
|
|
234
|
+
inline-size: 100%;
|
|
235
|
+
margin: 0;
|
|
236
|
+
padding: 0;
|
|
237
|
+
}
|
|
238
|
+
.heading {
|
|
239
|
+
margin: 0;
|
|
240
|
+
font: inherit;
|
|
241
|
+
}
|
|
242
|
+
.toggle {
|
|
243
|
+
display: flex;
|
|
244
|
+
align-items: center;
|
|
245
|
+
justify-content: space-between;
|
|
246
|
+
gap: 0.75rem;
|
|
247
|
+
box-sizing: border-box;
|
|
248
|
+
inline-size: 100%;
|
|
249
|
+
min-block-size: 44px;
|
|
250
|
+
margin: 0;
|
|
251
|
+
padding: 0.5rem 0.25rem 0.5rem 0;
|
|
252
|
+
border: 0;
|
|
253
|
+
background: none;
|
|
254
|
+
color: inherit;
|
|
255
|
+
font: inherit;
|
|
256
|
+
font-weight: 700;
|
|
257
|
+
line-height: 1.5;
|
|
258
|
+
text-align: start;
|
|
259
|
+
cursor: pointer;
|
|
260
|
+
}
|
|
261
|
+
/* The library's caret (as in uvalib-contents and site-main-nav): a rotated border box,
|
|
262
|
+
turned over when open. It flips at once: no motion. */
|
|
263
|
+
.toggle::after {
|
|
264
|
+
content: '';
|
|
265
|
+
flex: none;
|
|
266
|
+
inline-size: 0.5em;
|
|
267
|
+
block-size: 0.5em;
|
|
268
|
+
margin-block-end: 0.25em;
|
|
269
|
+
border-inline-end: 2px solid ${unsafeCSS(LINK)};
|
|
270
|
+
border-block-end: 2px solid ${unsafeCSS(LINK)};
|
|
271
|
+
transform: rotate(45deg);
|
|
272
|
+
}
|
|
273
|
+
.toggle[aria-expanded='true']::after {
|
|
274
|
+
margin-block: 0.25em 0;
|
|
275
|
+
transform: rotate(225deg);
|
|
276
|
+
}
|
|
277
|
+
.selected-count {
|
|
278
|
+
margin-inline-start: 0.5rem;
|
|
279
|
+
color: ${unsafeCSS(MUTED)};
|
|
280
|
+
font-size: 0.875rem;
|
|
281
|
+
font-weight: 400;
|
|
282
|
+
}
|
|
283
|
+
.body.collapsible {
|
|
284
|
+
padding-block-start: 0.25rem;
|
|
285
|
+
}
|
|
286
|
+
.match,
|
|
287
|
+
.search-status,
|
|
288
|
+
.apply-status {
|
|
289
|
+
margin: 0 0 0.5rem;
|
|
290
|
+
color: ${unsafeCSS(MUTED)};
|
|
291
|
+
font-size: 0.875rem;
|
|
292
|
+
line-height: 1.5;
|
|
293
|
+
}
|
|
294
|
+
.search {
|
|
295
|
+
margin: 0 0 0.5rem;
|
|
296
|
+
}
|
|
297
|
+
.search label {
|
|
298
|
+
display: block;
|
|
299
|
+
margin-block-end: 0.25rem;
|
|
300
|
+
font-size: 0.875rem;
|
|
301
|
+
font-weight: 600;
|
|
302
|
+
}
|
|
303
|
+
.search input {
|
|
304
|
+
box-sizing: border-box;
|
|
305
|
+
inline-size: 100%;
|
|
306
|
+
min-block-size: 44px;
|
|
307
|
+
margin: 0;
|
|
308
|
+
padding: 0.5rem 0.75rem;
|
|
309
|
+
border: 1px solid ${unsafeCSS(BORDER)};
|
|
310
|
+
border-radius: 0.3rem;
|
|
311
|
+
background: ${unsafeCSS(RAISED)};
|
|
312
|
+
color: var(--uva-color-input-text, #1f2937);
|
|
313
|
+
font: inherit;
|
|
314
|
+
}
|
|
315
|
+
.search-status {
|
|
316
|
+
margin: 0.25rem 0 0;
|
|
317
|
+
}
|
|
318
|
+
mark {
|
|
319
|
+
background: none;
|
|
320
|
+
color: inherit;
|
|
321
|
+
font-weight: 700;
|
|
322
|
+
text-decoration: underline;
|
|
323
|
+
text-underline-offset: 0.15em;
|
|
324
|
+
}
|
|
325
|
+
.tools {
|
|
326
|
+
display: flex;
|
|
327
|
+
flex-wrap: wrap;
|
|
328
|
+
align-items: center;
|
|
329
|
+
gap: 0.25rem 0.75rem;
|
|
330
|
+
margin: 0 0 0.25rem;
|
|
331
|
+
}
|
|
332
|
+
.sort {
|
|
333
|
+
display: flex;
|
|
334
|
+
flex-wrap: wrap;
|
|
335
|
+
align-items: center;
|
|
336
|
+
}
|
|
337
|
+
.sort-label {
|
|
338
|
+
margin-inline-end: 0.5rem;
|
|
339
|
+
font-size: 0.875rem;
|
|
340
|
+
}
|
|
341
|
+
.seg {
|
|
342
|
+
position: relative;
|
|
343
|
+
display: inline-flex;
|
|
344
|
+
align-items: center;
|
|
345
|
+
min-block-size: 44px;
|
|
346
|
+
min-inline-size: 44px;
|
|
347
|
+
}
|
|
348
|
+
.seg + .seg {
|
|
349
|
+
margin-inline-start: -1px;
|
|
350
|
+
}
|
|
351
|
+
.seg input {
|
|
352
|
+
position: absolute;
|
|
353
|
+
inset: 0;
|
|
354
|
+
inline-size: 100%;
|
|
355
|
+
block-size: 100%;
|
|
356
|
+
margin: 0;
|
|
357
|
+
opacity: 0;
|
|
358
|
+
cursor: pointer;
|
|
359
|
+
}
|
|
360
|
+
.face {
|
|
361
|
+
display: inline-flex;
|
|
362
|
+
align-items: center;
|
|
363
|
+
gap: 0.3rem;
|
|
364
|
+
box-sizing: border-box;
|
|
365
|
+
min-block-size: 2.25rem;
|
|
366
|
+
padding: 0.25rem 0.625rem;
|
|
367
|
+
border: 1px solid ${unsafeCSS(BORDER)};
|
|
368
|
+
background: ${unsafeCSS(RAISED)};
|
|
369
|
+
color: ${unsafeCSS(LINK)};
|
|
370
|
+
font-size: 0.875rem;
|
|
371
|
+
font-weight: 600;
|
|
372
|
+
line-height: 1.3;
|
|
373
|
+
white-space: nowrap;
|
|
374
|
+
}
|
|
375
|
+
.seg:first-of-type .face {
|
|
376
|
+
border-start-start-radius: 0.3rem;
|
|
377
|
+
border-end-start-radius: 0.3rem;
|
|
378
|
+
}
|
|
379
|
+
.seg:last-of-type .face {
|
|
380
|
+
border-start-end-radius: 0.3rem;
|
|
381
|
+
border-end-end-radius: 0.3rem;
|
|
382
|
+
}
|
|
383
|
+
.seg input:checked + .face {
|
|
384
|
+
position: relative;
|
|
385
|
+
border-color: ${unsafeCSS(ACCENT)};
|
|
386
|
+
background: ${unsafeCSS(ACCENT)};
|
|
387
|
+
color: var(--uva-color-on-accent, #fff);
|
|
388
|
+
}
|
|
389
|
+
.seg input:focus-visible {
|
|
390
|
+
outline: none;
|
|
391
|
+
}
|
|
392
|
+
.seg input:focus-visible + .face,
|
|
393
|
+
.search input:focus-visible {
|
|
394
|
+
position: relative;
|
|
395
|
+
z-index: 1;
|
|
396
|
+
outline: 3px solid ${unsafeCSS(FOCUS)};
|
|
397
|
+
outline-offset: 2px;
|
|
398
|
+
}
|
|
399
|
+
.check {
|
|
400
|
+
flex: none;
|
|
401
|
+
inline-size: 1em;
|
|
402
|
+
block-size: 1em;
|
|
403
|
+
}
|
|
404
|
+
.button {
|
|
405
|
+
box-sizing: border-box;
|
|
406
|
+
min-block-size: 44px;
|
|
407
|
+
min-inline-size: 44px;
|
|
408
|
+
margin: 0;
|
|
409
|
+
padding: 0.25rem 0.875rem;
|
|
410
|
+
border: 1px solid ${unsafeCSS(BORDER)};
|
|
411
|
+
border-radius: 0.3rem;
|
|
412
|
+
background: ${unsafeCSS(RAISED)};
|
|
413
|
+
color: ${unsafeCSS(LINK)};
|
|
414
|
+
font: inherit;
|
|
415
|
+
font-size: 0.875rem;
|
|
416
|
+
font-weight: 600;
|
|
417
|
+
cursor: pointer;
|
|
418
|
+
}
|
|
419
|
+
.button:hover {
|
|
420
|
+
border-color: ${unsafeCSS(LINK)};
|
|
421
|
+
}
|
|
422
|
+
.clear {
|
|
423
|
+
margin-inline-start: auto;
|
|
424
|
+
}
|
|
425
|
+
.button.primary {
|
|
426
|
+
border-color: ${unsafeCSS(ACCENT)};
|
|
427
|
+
background: ${unsafeCSS(ACCENT)};
|
|
428
|
+
color: var(--uva-color-on-accent, #fff);
|
|
429
|
+
}
|
|
430
|
+
.button[aria-disabled='true'] {
|
|
431
|
+
border-style: dashed;
|
|
432
|
+
border-color: ${unsafeCSS(BORDER)};
|
|
433
|
+
background: ${unsafeCSS(RAISED)};
|
|
434
|
+
color: ${unsafeCSS(MUTED)};
|
|
435
|
+
cursor: not-allowed;
|
|
436
|
+
}
|
|
437
|
+
.apply-bar {
|
|
438
|
+
display: flex;
|
|
439
|
+
flex-wrap: wrap;
|
|
440
|
+
align-items: center;
|
|
441
|
+
gap: 0.5rem;
|
|
442
|
+
margin-block-start: 0.5rem;
|
|
443
|
+
}
|
|
444
|
+
.apply-status {
|
|
445
|
+
flex: 1 1 100%;
|
|
446
|
+
margin: 0;
|
|
447
|
+
}
|
|
448
|
+
.pending {
|
|
449
|
+
margin-inline-start: 0.4rem;
|
|
450
|
+
padding: 0 0.3rem;
|
|
451
|
+
border: 1px dashed currentColor;
|
|
452
|
+
border-radius: 0.25rem;
|
|
453
|
+
color: ${unsafeCSS(MUTED)};
|
|
454
|
+
font-size: 0.75rem;
|
|
455
|
+
font-style: italic;
|
|
456
|
+
}
|
|
457
|
+
.staged {
|
|
458
|
+
font-style: italic;
|
|
459
|
+
}
|
|
460
|
+
@media (forced-colors: active) {
|
|
461
|
+
.seg input:checked + .face,
|
|
462
|
+
.button.primary {
|
|
463
|
+
forced-color-adjust: none;
|
|
464
|
+
border-color: Highlight;
|
|
465
|
+
background: Highlight;
|
|
466
|
+
color: HighlightText;
|
|
467
|
+
}
|
|
468
|
+
.button[aria-disabled='true'] {
|
|
469
|
+
forced-color-adjust: none;
|
|
470
|
+
border-color: GrayText;
|
|
471
|
+
background: Canvas;
|
|
472
|
+
color: GrayText;
|
|
473
|
+
}
|
|
474
|
+
.toggle::after {
|
|
475
|
+
border-color: ButtonText;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
114
478
|
`,
|
|
115
479
|
]; }
|
|
116
480
|
get buckets() {
|
|
117
481
|
return this.filter?.buckets ?? [];
|
|
118
482
|
}
|
|
483
|
+
get facetTitle() {
|
|
484
|
+
return this.filter?.title ?? '';
|
|
485
|
+
}
|
|
486
|
+
/** The buckets in display order: the data's order unless sorted (stable on ties). */
|
|
487
|
+
get ordered() {
|
|
488
|
+
const b = this.buckets;
|
|
489
|
+
if (this.sort === 'name')
|
|
490
|
+
return [...b].sort((x, y) => collator.compare(x.key, y.key));
|
|
491
|
+
if (this.sortable)
|
|
492
|
+
return [...b].sort((x, y) => y.doc_count - x.doc_count);
|
|
493
|
+
return b;
|
|
494
|
+
}
|
|
495
|
+
/** Whether `key` is applied (in `value`). */
|
|
496
|
+
isApplied(key) {
|
|
497
|
+
return this.value.some((v) => lower(v) === lower(key));
|
|
498
|
+
}
|
|
499
|
+
/** Whether `key`'s checkbox is shown checked (applied, or staged with `apply-button`). */
|
|
500
|
+
isChecked(key) {
|
|
501
|
+
return this.staged.get(lower(key))?.checked ?? this.isApplied(key);
|
|
502
|
+
}
|
|
503
|
+
/** The selection as shown: `value` with the staged changes. */
|
|
504
|
+
get shownValue() {
|
|
505
|
+
const kept = this.value.filter((v) => this.staged.get(lower(v))?.checked !== false);
|
|
506
|
+
const added = [...this.staged.values()].filter((s) => s.checked).map((s) => s.key);
|
|
507
|
+
return [...kept, ...added];
|
|
508
|
+
}
|
|
119
509
|
onChange(e) {
|
|
120
510
|
const input = e.target;
|
|
511
|
+
if (this.applyButton) {
|
|
512
|
+
const k = lower(input.value);
|
|
513
|
+
const staged = new Map(this.staged);
|
|
514
|
+
if (input.checked === this.isApplied(input.value))
|
|
515
|
+
staged.delete(k);
|
|
516
|
+
else
|
|
517
|
+
staged.set(k, { key: input.value, checked: input.checked });
|
|
518
|
+
this.staged = staged;
|
|
519
|
+
return;
|
|
520
|
+
}
|
|
121
521
|
const rest = this.value.filter((v) => v.toLowerCase() !== input.value.toLowerCase());
|
|
122
522
|
this.value = input.checked ? [...rest, input.value] : rest;
|
|
123
523
|
trackEvent(this, [TAG, 'facet-change', `${this.filter.title}: ${input.value}`, +input.checked]);
|
|
524
|
+
this.emitChange();
|
|
525
|
+
}
|
|
526
|
+
emitChange() {
|
|
124
527
|
this.dispatchEvent(new CustomEvent('filter-change', { detail: { name: this.filter.name, value: this.value } }));
|
|
125
528
|
}
|
|
126
529
|
toggleScope(key, e) {
|
|
@@ -133,6 +536,93 @@ export class UvalibFilter extends UvalibElement {
|
|
|
133
536
|
trackEvent(this, [TAG, 'scope-change', label, +pressed]);
|
|
134
537
|
this.dispatchEvent(new CustomEvent('scope-change', { detail: { value: this.scopeValue } }));
|
|
135
538
|
}
|
|
539
|
+
toggleOpen() {
|
|
540
|
+
this.collapsed = !this.collapsed;
|
|
541
|
+
const open = !this.collapsed;
|
|
542
|
+
trackEvent(this, [TAG, 'toggle', this.facetTitle, +open]);
|
|
543
|
+
this.dispatchEvent(new CustomEvent('toggle', { detail: { open } }));
|
|
544
|
+
}
|
|
545
|
+
onSort(e) {
|
|
546
|
+
const sort = e.target.value;
|
|
547
|
+
this.sort = sort;
|
|
548
|
+
trackEvent(this, [TAG, 'sort', `${this.facetTitle}: ${sort}`]);
|
|
549
|
+
this.dispatchEvent(new CustomEvent('sort', { detail: { sort } }));
|
|
550
|
+
}
|
|
551
|
+
async clear() {
|
|
552
|
+
const n = this.shownValue.length;
|
|
553
|
+
const applied = this.value.length;
|
|
554
|
+
this.staged = new Map();
|
|
555
|
+
trackEvent(this, [TAG, 'clear', this.facetTitle, n]);
|
|
556
|
+
if (applied) {
|
|
557
|
+
this.value = [];
|
|
558
|
+
this.emitChange();
|
|
559
|
+
}
|
|
560
|
+
await this.updateComplete;
|
|
561
|
+
const root = this.renderRoot;
|
|
562
|
+
(root.querySelector('input[type=checkbox]') ??
|
|
563
|
+
root.querySelector('button[part=toggle]'))?.focus();
|
|
564
|
+
}
|
|
565
|
+
apply() {
|
|
566
|
+
const changes = [...this.staged.values()];
|
|
567
|
+
if (!changes.length)
|
|
568
|
+
return;
|
|
569
|
+
this.value = this.shownValue;
|
|
570
|
+
this.staged = new Map();
|
|
571
|
+
for (const c of changes)
|
|
572
|
+
trackEvent(this, [TAG, 'facet-change', `${this.facetTitle}: ${c.key}`, +c.checked]);
|
|
573
|
+
trackEvent(this, [TAG, 'apply', this.facetTitle, changes.length]);
|
|
574
|
+
this.emitChange();
|
|
575
|
+
}
|
|
576
|
+
reset() {
|
|
577
|
+
this.staged = new Map();
|
|
578
|
+
}
|
|
579
|
+
onSearch(e) {
|
|
580
|
+
this.query = e.target.value;
|
|
581
|
+
this.scheduleStatus();
|
|
582
|
+
}
|
|
583
|
+
onSearchKey(e) {
|
|
584
|
+
if (e.key !== 'Escape' || !this.query)
|
|
585
|
+
return;
|
|
586
|
+
// Clear the search, and keep Escape from closing a surrounding dialog (the filter drawer).
|
|
587
|
+
e.preventDefault();
|
|
588
|
+
e.stopPropagation();
|
|
589
|
+
e.target.value = '';
|
|
590
|
+
this.query = '';
|
|
591
|
+
this.scheduleStatus();
|
|
592
|
+
}
|
|
593
|
+
/** The search results: the folded query, the matching buckets, and the status line. */
|
|
594
|
+
get search() {
|
|
595
|
+
const q = this.searchable ? fold(this.query.trim()) : '';
|
|
596
|
+
return { q, matches: q ? this.ordered.filter((b) => fold(b.key).includes(q)) : [] };
|
|
597
|
+
}
|
|
598
|
+
statusText(n) {
|
|
599
|
+
return `${count(n)} of ${count(this.buckets.length)} ${this.unit}`;
|
|
600
|
+
}
|
|
601
|
+
scheduleStatus() {
|
|
602
|
+
clearTimeout(this.announceTimer);
|
|
603
|
+
clearTimeout(this.trackTimer);
|
|
604
|
+
if (!this.search.q) {
|
|
605
|
+
this.announcement = '';
|
|
606
|
+
return;
|
|
607
|
+
}
|
|
608
|
+
this.announceTimer = setTimeout(() => {
|
|
609
|
+
const { q, matches } = this.search;
|
|
610
|
+
if (q)
|
|
611
|
+
this.announcement = this.statusText(matches.length);
|
|
612
|
+
}, filterTiming.announce);
|
|
613
|
+
this.trackTimer = setTimeout(() => {
|
|
614
|
+
const { q, matches } = this.search;
|
|
615
|
+
if (!q || q === this.lastTracked)
|
|
616
|
+
return;
|
|
617
|
+
this.lastTracked = q;
|
|
618
|
+
trackEvent(this, [TAG, 'search', this.facetTitle, matches.length]);
|
|
619
|
+
}, filterTiming.track);
|
|
620
|
+
}
|
|
621
|
+
disconnectedCallback() {
|
|
622
|
+
super.disconnectedCallback();
|
|
623
|
+
clearTimeout(this.announceTimer);
|
|
624
|
+
clearTimeout(this.trackTimer);
|
|
625
|
+
}
|
|
136
626
|
/** The focused control inside this component (checkbox, scope chip or see more/less button). */
|
|
137
627
|
get focused() {
|
|
138
628
|
const active = this.renderRoot instanceof ShadowRoot
|
|
@@ -163,6 +653,15 @@ export class UvalibFilter extends UvalibElement {
|
|
|
163
653
|
// Moving a focused node (a reordered bucket) drops focus to <body>; remember it to restore.
|
|
164
654
|
const focused = this.hasUpdated ? this.focused : null;
|
|
165
655
|
this.focusKey = focused ? this.keyOf(focused) : undefined;
|
|
656
|
+
// A new applied selection (from the page) replaces staged changes; the same one keeps them.
|
|
657
|
+
if (changed.has('value') && this.staged.size) {
|
|
658
|
+
const before = new Set((changed.get('value') ?? []).map(lower));
|
|
659
|
+
const now = new Set(this.value.map(lower));
|
|
660
|
+
if (before.size !== now.size || [...now].some((v) => !before.has(v)))
|
|
661
|
+
this.staged = new Map();
|
|
662
|
+
}
|
|
663
|
+
if (changed.has('applyButton') && !this.applyButton)
|
|
664
|
+
this.staged = new Map();
|
|
166
665
|
if (!changed.has('limit') && !changed.has('filter'))
|
|
167
666
|
return;
|
|
168
667
|
const total = this.buckets.length;
|
|
@@ -195,72 +694,219 @@ export class UvalibFilter extends UvalibElement {
|
|
|
195
694
|
this.currentLimit = Math.max(Math.ceil(this.currentLimit / 2), this.limit);
|
|
196
695
|
trackEvent(this, [TAG, 'see-less', this.filter.title]);
|
|
197
696
|
}
|
|
697
|
+
/** The legend's content: the title, or the disclosure button; in a heading if asked. */
|
|
698
|
+
renderLegend(title, bodyId, selected) {
|
|
699
|
+
const level = this.headingLevel >= 2 && this.headingLevel <= 6 ? this.headingLevel : 0;
|
|
700
|
+
if (!this.collapsible)
|
|
701
|
+
return heading(level, title);
|
|
702
|
+
const open = !this.collapsed;
|
|
703
|
+
return heading(level, html `<button
|
|
704
|
+
type="button"
|
|
705
|
+
part="toggle"
|
|
706
|
+
class="toggle"
|
|
707
|
+
aria-expanded=${open ? 'true' : 'false'}
|
|
708
|
+
aria-controls=${bodyId}
|
|
709
|
+
@click=${this.toggleOpen}
|
|
710
|
+
>
|
|
711
|
+
<span
|
|
712
|
+
>${title}${!open && selected
|
|
713
|
+
? html `<span class="selected-count"
|
|
714
|
+
><span class="visually-hidden">, </span>${selected} selected</span
|
|
715
|
+
>`
|
|
716
|
+
: nothing}</span
|
|
717
|
+
>
|
|
718
|
+
</button>`);
|
|
719
|
+
}
|
|
720
|
+
renderSort() {
|
|
721
|
+
const id = `${this.uid}-sort`;
|
|
722
|
+
const options = [
|
|
723
|
+
['count', 'Count'],
|
|
724
|
+
['name', 'Name (A–Z)'],
|
|
725
|
+
];
|
|
726
|
+
// form= names no form: the radios group by name, and a surrounding form never submits them.
|
|
727
|
+
return html `<div class="sort" role="radiogroup" aria-labelledby="${id}-label">
|
|
728
|
+
<span class="sort-label" id="${id}-label">Sort by</span>
|
|
729
|
+
${options.map(([value, label]) => html `<label class="seg"
|
|
730
|
+
><input
|
|
731
|
+
type="radio"
|
|
732
|
+
name=${id}
|
|
733
|
+
form="${id}-none"
|
|
734
|
+
value=${value}
|
|
735
|
+
.checked=${this.sort === value}
|
|
736
|
+
@change=${this.onSort}
|
|
737
|
+
/><span class="face">${this.sort === value ? CHECK : nothing}${label}</span></label
|
|
738
|
+
>`)}
|
|
739
|
+
</div>`;
|
|
740
|
+
}
|
|
741
|
+
renderBucket(bucket, idx, q) {
|
|
742
|
+
const id = `${this.uid}-${idx}`;
|
|
743
|
+
const checked = this.isChecked(bucket.key);
|
|
744
|
+
const staged = this.staged.has(lower(bucket.key));
|
|
745
|
+
const text = bucket.key ? marked(bucket.key, q) : '(empty)';
|
|
746
|
+
const n = bucket.doc_count;
|
|
747
|
+
const note = staged ? html `<span class="pending">not applied</span>` : nothing;
|
|
748
|
+
return html `<div class="checkbox">
|
|
749
|
+
<input
|
|
750
|
+
type="checkbox"
|
|
751
|
+
id=${id}
|
|
752
|
+
name=${this.filter.name}
|
|
753
|
+
value=${bucket.key}
|
|
754
|
+
@change=${this.onChange}
|
|
755
|
+
.checked=${checked}
|
|
756
|
+
/>
|
|
757
|
+
<label for=${id} class=${staged ? 'staged' : nothing}>${text} (${n})${note}</label>
|
|
758
|
+
</div>`;
|
|
759
|
+
}
|
|
198
760
|
render() {
|
|
199
761
|
const total = this.buckets.length;
|
|
200
|
-
const title = this.
|
|
201
|
-
const
|
|
202
|
-
const collapsible = this.limit > 0;
|
|
762
|
+
const title = this.facetTitle;
|
|
763
|
+
const { q, matches } = this.search;
|
|
203
764
|
const listId = `${this.uid}-list`;
|
|
204
|
-
const
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
765
|
+
const bodyId = `${this.uid}-body`;
|
|
766
|
+
const matchId = `${this.uid}-match`;
|
|
767
|
+
const selected = this.shownValue.length;
|
|
768
|
+
const pending = this.staged.size;
|
|
769
|
+
const pendingText = pending ? `${plural(pending, 'change')} not applied yet` : '';
|
|
770
|
+
const applyText = pending ? `Apply ${plural(pending, 'change')}` : 'Apply';
|
|
771
|
+
const groupy = this.collapsible || this.headingLevel > 0;
|
|
772
|
+
// While searching: every checked value first (so a selection never disappears), then the
|
|
773
|
+
// unchecked matches, up to SEARCH_CAP. Otherwise: the first `currentLimit` values.
|
|
774
|
+
let shownBuckets;
|
|
775
|
+
let shown = 0;
|
|
776
|
+
if (q) {
|
|
777
|
+
const rest = matches.filter((b) => !this.isChecked(b.key));
|
|
778
|
+
shownBuckets = [
|
|
779
|
+
...this.ordered.filter((b) => this.isChecked(b.key)),
|
|
780
|
+
...rest.slice(0, SEARCH_CAP),
|
|
781
|
+
];
|
|
782
|
+
}
|
|
783
|
+
else {
|
|
784
|
+
shown = Math.min(this.currentLimit || total, total);
|
|
785
|
+
shownBuckets = this.ordered.slice(0, shown);
|
|
786
|
+
}
|
|
787
|
+
const collapsible = this.limit > 0 && !q;
|
|
788
|
+
const capped = q && matches.filter((b) => !this.isChecked(b.key)).length > SEARCH_CAP;
|
|
789
|
+
const body = html `
|
|
790
|
+
${this.match === 'any' || this.match === 'all'
|
|
791
|
+
? html `<p class="match" id=${matchId}>
|
|
792
|
+
${this.match === 'all' ? 'Matches all selected values' : 'Matches any selected value'}
|
|
793
|
+
</p>`
|
|
794
|
+
: nothing}
|
|
795
|
+
${this.scopes.length
|
|
209
796
|
? html `<div
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
797
|
+
class="scopes"
|
|
798
|
+
role="group"
|
|
799
|
+
aria-label=${this.scopesLabel || `Filter ${title} by type`}
|
|
800
|
+
>
|
|
801
|
+
${this.scopes.map((scope) => {
|
|
215
802
|
const pressed = this.scopeValue.some((v) => lower(v) === lower(scope.value));
|
|
216
803
|
return html `<button
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
804
|
+
type="button"
|
|
805
|
+
class="scope"
|
|
806
|
+
value=${scope.value}
|
|
807
|
+
aria-pressed=${pressed ? 'true' : 'false'}
|
|
808
|
+
@click=${(e) => this.toggleScope(scope.value, e)}
|
|
809
|
+
>
|
|
810
|
+
${scope.label}
|
|
811
|
+
</button>`;
|
|
225
812
|
})}
|
|
226
|
-
|
|
813
|
+
</div>`
|
|
227
814
|
: nothing}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
aria-controls=${listId}
|
|
249
|
-
@click=${this.showMore}
|
|
815
|
+
${this.searchable
|
|
816
|
+
? html `<div class="search">
|
|
817
|
+
<label for="${this.uid}-search">${this.searchLabel || `Search ${title}`}</label>
|
|
818
|
+
<input
|
|
819
|
+
id="${this.uid}-search"
|
|
820
|
+
part="search"
|
|
821
|
+
type="search"
|
|
822
|
+
autocomplete="off"
|
|
823
|
+
spellcheck="false"
|
|
824
|
+
.value=${this.query}
|
|
825
|
+
@input=${this.onSearch}
|
|
826
|
+
@keydown=${this.onSearchKey}
|
|
827
|
+
/>
|
|
828
|
+
${q
|
|
829
|
+
? html `<p class="search-status">
|
|
830
|
+
${this.statusText(matches.length)}${capped ? `. Showing the first ${SEARCH_CAP}; type more to narrow them.` : ''}
|
|
831
|
+
</p>`
|
|
832
|
+
: nothing}
|
|
833
|
+
<span class="visually-hidden" role="status" aria-live="polite" aria-atomic="true"
|
|
834
|
+
>${this.announcement}</span
|
|
250
835
|
>
|
|
251
|
-
|
|
252
|
-
</button>`
|
|
836
|
+
</div>`
|
|
253
837
|
: nothing}
|
|
254
|
-
|
|
838
|
+
${this.sortable || (this.clearable && selected)
|
|
839
|
+
? html `<div class="tools">
|
|
840
|
+
${this.sortable ? this.renderSort() : nothing}
|
|
841
|
+
${this.clearable && selected
|
|
842
|
+
? html `<button
|
|
843
|
+
type="button"
|
|
844
|
+
part="clear"
|
|
845
|
+
class="button clear"
|
|
846
|
+
@click=${this.clear}
|
|
847
|
+
>
|
|
848
|
+
Clear<span class="visually-hidden"> ${title} filters</span>
|
|
849
|
+
</button>`
|
|
850
|
+
: nothing}
|
|
851
|
+
</div>`
|
|
852
|
+
: nothing}
|
|
853
|
+
<div id=${listId}>
|
|
854
|
+
${repeat(shownBuckets, (bucket) => bucket.key, (bucket, idx) => this.renderBucket(bucket, idx, q))}
|
|
855
|
+
</div>
|
|
856
|
+
${collapsible && shown < total
|
|
857
|
+
? html `<button
|
|
858
|
+
type="button"
|
|
859
|
+
part="see-more"
|
|
860
|
+
aria-controls=${listId}
|
|
861
|
+
@click=${this.showMore}
|
|
862
|
+
>
|
|
863
|
+
See more<span class="visually-hidden"> ${title}</span>
|
|
864
|
+
</button>`
|
|
865
|
+
: nothing}
|
|
866
|
+
${collapsible && shown > this.limit
|
|
255
867
|
? html `<button
|
|
868
|
+
type="button"
|
|
869
|
+
part="see-less"
|
|
870
|
+
aria-controls=${listId}
|
|
871
|
+
@click=${this.showLess}
|
|
872
|
+
>
|
|
873
|
+
See less<span class="visually-hidden"> ${title}</span>
|
|
874
|
+
</button>`
|
|
875
|
+
: nothing}
|
|
876
|
+
${this.applyButton
|
|
877
|
+
? html `<div class="apply-bar">
|
|
878
|
+
<p class="apply-status" role="status" aria-live="polite">${pendingText}</p>
|
|
879
|
+
<button
|
|
256
880
|
type="button"
|
|
257
|
-
part="
|
|
258
|
-
|
|
259
|
-
|
|
881
|
+
part="apply"
|
|
882
|
+
class="button primary"
|
|
883
|
+
aria-disabled=${pending ? 'false' : 'true'}
|
|
884
|
+
@click=${this.apply}
|
|
260
885
|
>
|
|
261
|
-
|
|
262
|
-
</button
|
|
886
|
+
${applyText}<span class="visually-hidden"> to ${title}</span>
|
|
887
|
+
</button>
|
|
888
|
+
<button
|
|
889
|
+
type="button"
|
|
890
|
+
part="reset"
|
|
891
|
+
class="button"
|
|
892
|
+
aria-disabled=${pending ? 'false' : 'true'}
|
|
893
|
+
@click=${this.reset}
|
|
894
|
+
>
|
|
895
|
+
Reset<span class="visually-hidden"> ${title}</span>
|
|
896
|
+
</button>
|
|
897
|
+
</div>`
|
|
263
898
|
: nothing}
|
|
899
|
+
`;
|
|
900
|
+
const legend = this.renderLegend(title, bodyId, selected);
|
|
901
|
+
const describedBy = this.match === 'any' || this.match === 'all' ? matchId : undefined;
|
|
902
|
+
return html `
|
|
903
|
+
<fieldset aria-describedby=${ifDefined(describedBy)}>
|
|
904
|
+
<legend class=${groupy ? 'group' : nothing}>${legend}</legend>
|
|
905
|
+
${this.collapsible
|
|
906
|
+
? html `<div class="body collapsible" id=${bodyId} ?hidden=${this.collapsed}>
|
|
907
|
+
${body}
|
|
908
|
+
</div>`
|
|
909
|
+
: body}
|
|
264
910
|
</fieldset>
|
|
265
911
|
`;
|
|
266
912
|
}
|
|
@@ -283,7 +929,49 @@ __decorate([
|
|
|
283
929
|
__decorate([
|
|
284
930
|
property({ type: Number })
|
|
285
931
|
], UvalibFilter.prototype, "limit", void 0);
|
|
932
|
+
__decorate([
|
|
933
|
+
property({ type: Boolean, reflect: true })
|
|
934
|
+
], UvalibFilter.prototype, "collapsible", void 0);
|
|
935
|
+
__decorate([
|
|
936
|
+
property({ type: Boolean, reflect: true })
|
|
937
|
+
], UvalibFilter.prototype, "collapsed", void 0);
|
|
938
|
+
__decorate([
|
|
939
|
+
property({ type: Number, attribute: 'heading-level' })
|
|
940
|
+
], UvalibFilter.prototype, "headingLevel", void 0);
|
|
941
|
+
__decorate([
|
|
942
|
+
property({ type: Boolean, reflect: true })
|
|
943
|
+
], UvalibFilter.prototype, "searchable", void 0);
|
|
944
|
+
__decorate([
|
|
945
|
+
property({ type: String, attribute: 'search-label' })
|
|
946
|
+
], UvalibFilter.prototype, "searchLabel", void 0);
|
|
947
|
+
__decorate([
|
|
948
|
+
property({ type: String })
|
|
949
|
+
], UvalibFilter.prototype, "unit", void 0);
|
|
950
|
+
__decorate([
|
|
951
|
+
property({ type: Boolean, reflect: true })
|
|
952
|
+
], UvalibFilter.prototype, "sortable", void 0);
|
|
953
|
+
__decorate([
|
|
954
|
+
property({ type: String, reflect: true })
|
|
955
|
+
], UvalibFilter.prototype, "sort", void 0);
|
|
956
|
+
__decorate([
|
|
957
|
+
property({ type: Boolean, reflect: true })
|
|
958
|
+
], UvalibFilter.prototype, "clearable", void 0);
|
|
959
|
+
__decorate([
|
|
960
|
+
property({ type: Boolean, reflect: true, attribute: 'apply-button' })
|
|
961
|
+
], UvalibFilter.prototype, "applyButton", void 0);
|
|
962
|
+
__decorate([
|
|
963
|
+
property({ type: String, reflect: true })
|
|
964
|
+
], UvalibFilter.prototype, "match", void 0);
|
|
286
965
|
__decorate([
|
|
287
966
|
state()
|
|
288
967
|
], UvalibFilter.prototype, "currentLimit", void 0);
|
|
968
|
+
__decorate([
|
|
969
|
+
state()
|
|
970
|
+
], UvalibFilter.prototype, "query", void 0);
|
|
971
|
+
__decorate([
|
|
972
|
+
state()
|
|
973
|
+
], UvalibFilter.prototype, "announcement", void 0);
|
|
974
|
+
__decorate([
|
|
975
|
+
state()
|
|
976
|
+
], UvalibFilter.prototype, "staged", void 0);
|
|
289
977
|
//# sourceMappingURL=UvalibFilter.js.map
|