@internetarchive/collection-browser 4.7.1-alpha-webdev9189.0 → 4.8.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/dist/src/app-root.js +0 -2
- package/dist/src/app-root.js.map +1 -1
- package/dist/src/assets/img/icons/check.d.ts +2 -0
- package/dist/src/assets/img/icons/check.js +5 -0
- package/dist/src/assets/img/icons/check.js.map +1 -0
- package/dist/src/collection-browser.js +2 -24
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/collection-facets/facet-row-template.d.ts +38 -0
- package/dist/src/collection-facets/facet-row-template.js +200 -0
- package/dist/src/collection-facets/facet-row-template.js.map +1 -0
- package/dist/src/collection-facets/facet-row.js +11 -186
- package/dist/src/collection-facets/facet-row.js.map +1 -1
- package/dist/src/collection-facets/models.d.ts +7 -2
- package/dist/src/collection-facets/models.js +7 -2
- package/dist/src/collection-facets/models.js.map +1 -1
- package/dist/src/collection-facets/more-facets-content.d.ts +87 -21
- package/dist/src/collection-facets/more-facets-content.js +477 -200
- package/dist/src/collection-facets/more-facets-content.js.map +1 -1
- package/dist/src/collection-facets/more-facets-scroller.d.ts +85 -0
- package/dist/src/collection-facets/more-facets-scroller.js +428 -0
- package/dist/src/collection-facets/more-facets-scroller.js.map +1 -0
- package/dist/src/collection-facets/page-window.d.ts +73 -0
- package/dist/src/collection-facets/page-window.js +202 -0
- package/dist/src/collection-facets/page-window.js.map +1 -0
- package/dist/src/collection-facets/toggle-switch.js +1 -0
- package/dist/src/collection-facets/toggle-switch.js.map +1 -1
- package/dist/src/models.d.ts +4 -0
- package/dist/src/models.js +16 -0
- package/dist/src/models.js.map +1 -1
- package/dist/src/sort-filter-bar/sort-filter-bar.js +0 -1
- package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
- package/dist/src/utils/log.d.ts +1 -4
- package/dist/src/utils/normalize-filter-text.d.ts +28 -0
- package/dist/src/utils/normalize-filter-text.js +35 -0
- package/dist/src/utils/normalize-filter-text.js.map +1 -0
- package/dist/test/collection-browser.test.js +0 -34
- package/dist/test/collection-browser.test.js.map +1 -1
- package/dist/test/collection-facets/more-facets-content.test.js +367 -17
- package/dist/test/collection-facets/more-facets-content.test.js.map +1 -1
- package/dist/test/collection-facets/more-facets-scroller.test.d.ts +1 -0
- package/dist/test/collection-facets/more-facets-scroller.test.js +288 -0
- package/dist/test/collection-facets/more-facets-scroller.test.js.map +1 -0
- package/dist/test/collection-facets/page-window.test.d.ts +1 -0
- package/dist/test/collection-facets/page-window.test.js +175 -0
- package/dist/test/collection-facets/page-window.test.js.map +1 -0
- package/dist/test/mocks/mock-search-responses.d.ts +6 -0
- package/dist/test/mocks/mock-search-responses.js +52 -0
- package/dist/test/mocks/mock-search-responses.js.map +1 -1
- package/dist/test/mocks/mock-search-service.js +2 -1
- package/dist/test/mocks/mock-search-service.js.map +1 -1
- package/dist/test/sort-filter-bar/sort-filter-bar.test.js +0 -22
- package/dist/test/sort-filter-bar/sort-filter-bar.test.js.map +1 -1
- package/dist/test/utils/normalize-filter-text.test.d.ts +1 -0
- package/dist/test/utils/normalize-filter-text.test.js +69 -0
- package/dist/test/utils/normalize-filter-text.test.js.map +1 -0
- package/docs/design/column-virtualization.md +214 -0
- package/package.json +3 -1
- package/src/app-root.ts +0 -2
- package/src/assets/img/icons/check.ts +5 -0
- package/src/collection-browser.ts +4 -26
- package/src/collection-facets/facet-row-template.ts +242 -0
- package/src/collection-facets/facet-row.ts +15 -202
- package/src/collection-facets/models.ts +8 -2
- package/src/collection-facets/more-facets-content.ts +528 -221
- package/src/collection-facets/more-facets-scroller.ts +485 -0
- package/src/collection-facets/page-window.ts +247 -0
- package/src/collection-facets/toggle-switch.ts +1 -0
- package/src/models.ts +17 -0
- package/src/sort-filter-bar/sort-filter-bar.ts +0 -1
- package/src/utils/normalize-filter-text.ts +54 -0
- package/test/collection-browser.test.ts +0 -55
- package/test/collection-facets/more-facets-content.test.ts +509 -24
- package/test/collection-facets/more-facets-scroller.test.ts +401 -0
- package/test/collection-facets/page-window.test.ts +208 -0
- package/test/mocks/mock-search-responses.ts +56 -0
- package/test/mocks/mock-search-service.ts +2 -0
- package/test/sort-filter-bar/sort-filter-bar.test.ts +0 -29
- package/test/utils/normalize-filter-text.test.ts +87 -0
- package/web-test-runner.config.mjs +7 -2
- package/dist/src/collection-facets/more-facets-pagination.d.ts +0 -36
- package/dist/src/collection-facets/more-facets-pagination.js +0 -260
- package/dist/src/collection-facets/more-facets-pagination.js.map +0 -1
- package/dist/test/collection-facets/more-facets-pagination.test.d.ts +0 -1
- package/dist/test/collection-facets/more-facets-pagination.test.js +0 -126
- package/dist/test/collection-facets/more-facets-pagination.test.js.map +0 -1
- package/src/collection-facets/more-facets-pagination.ts +0 -294
- package/test/collection-facets/more-facets-pagination.test.ts +0 -201
|
@@ -1,14 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
css,
|
|
3
|
-
html,
|
|
4
|
-
LitElement,
|
|
5
|
-
TemplateResult,
|
|
6
|
-
CSSResultGroup,
|
|
7
|
-
nothing,
|
|
8
|
-
} from 'lit';
|
|
1
|
+
import { html, LitElement, TemplateResult, CSSResultGroup, nothing } from 'lit';
|
|
9
2
|
import { customElement, property } from 'lit/decorators.js';
|
|
10
|
-
import eyeIcon from '../assets/img/icons/eye';
|
|
11
|
-
import eyeClosedIcon from '../assets/img/icons/eye-closed';
|
|
12
3
|
import type {
|
|
13
4
|
FacetOption,
|
|
14
5
|
FacetBucket,
|
|
@@ -17,6 +8,11 @@ import type {
|
|
|
17
8
|
} from '../models';
|
|
18
9
|
import type { CollectionTitles } from '../data-source/models';
|
|
19
10
|
import { srOnlyStyle } from '../styles/sr-only';
|
|
11
|
+
import {
|
|
12
|
+
facetRowStyles,
|
|
13
|
+
facetRowTemplate,
|
|
14
|
+
getFacetState,
|
|
15
|
+
} from './facet-row-template';
|
|
20
16
|
|
|
21
17
|
@customElement('facet-row')
|
|
22
18
|
export class FacetRow extends LitElement {
|
|
@@ -61,92 +57,13 @@ export class FacetRow extends LitElement {
|
|
|
61
57
|
const { bucket, facetType } = this;
|
|
62
58
|
if (!bucket || !facetType) return nothing;
|
|
63
59
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
:
|
|
70
|
-
|
|
71
|
-
// For collections, we render the collection title as a link.
|
|
72
|
-
// For other facet types, we just have a static value to use.
|
|
73
|
-
const bucketTextDisplay =
|
|
74
|
-
facetType !== 'collection'
|
|
75
|
-
? html`${bucket.displayText ?? bucket.key} ${extraNoteSpan}`
|
|
76
|
-
: html`<a href="/details/${bucket.key}">
|
|
77
|
-
${this.collectionTitles?.get(bucket.key) ?? bucket.key}
|
|
78
|
-
</a> `;
|
|
79
|
-
|
|
80
|
-
const bucketCountText =
|
|
81
|
-
bucket.count > 0 ? bucket.count.toLocaleString() : '';
|
|
82
|
-
|
|
83
|
-
const facetHidden = bucket.state === 'hidden';
|
|
84
|
-
const facetSelected = bucket.state === 'selected';
|
|
85
|
-
|
|
86
|
-
const titleText = `${facetType}: ${bucket.displayText ?? bucket.key}`;
|
|
87
|
-
const onlyShowText = facetSelected
|
|
88
|
-
? `Show all ${facetType}s`
|
|
89
|
-
: `Only show ${titleText}`;
|
|
90
|
-
const hideText = `Hide ${titleText}`;
|
|
91
|
-
const unhideText = `Unhide ${titleText}`;
|
|
92
|
-
const showHideText = facetHidden ? unhideText : hideText;
|
|
93
|
-
const ariaLabel = `${titleText}, ${bucket.count} results`;
|
|
94
|
-
|
|
95
|
-
// Added data-testid for Playwright testing
|
|
96
|
-
return html`
|
|
97
|
-
<div class="facet-row-container">
|
|
98
|
-
<div class="facet-checkboxes">
|
|
99
|
-
<input
|
|
100
|
-
type="checkbox"
|
|
101
|
-
.name=${facetType}
|
|
102
|
-
.value=${bucket.key}
|
|
103
|
-
@click=${(e: Event) => {
|
|
104
|
-
this.facetClicked(e, false);
|
|
105
|
-
}}
|
|
106
|
-
.checked=${facetSelected}
|
|
107
|
-
class="select-facet-checkbox"
|
|
108
|
-
title=${onlyShowText}
|
|
109
|
-
id=${showOnlyCheckboxId}
|
|
110
|
-
data-testid=${showOnlyCheckboxId}
|
|
111
|
-
/>
|
|
112
|
-
<div
|
|
113
|
-
class="hide-facet-container"
|
|
114
|
-
?hidden=${this.omitHideButton && !facetHidden}
|
|
115
|
-
>
|
|
116
|
-
<input
|
|
117
|
-
type="checkbox"
|
|
118
|
-
id=${negativeCheckboxId}
|
|
119
|
-
.name=${facetType}
|
|
120
|
-
.value=${bucket.key}
|
|
121
|
-
@click=${(e: Event) => {
|
|
122
|
-
this.facetClicked(e, true);
|
|
123
|
-
}}
|
|
124
|
-
.checked=${facetHidden}
|
|
125
|
-
class="hide-facet-checkbox"
|
|
126
|
-
/>
|
|
127
|
-
<label
|
|
128
|
-
for=${negativeCheckboxId}
|
|
129
|
-
class="hide-facet-icon${facetHidden ? ' active' : ''}"
|
|
130
|
-
title=${showHideText}
|
|
131
|
-
data-testid=${negativeCheckboxId}
|
|
132
|
-
>
|
|
133
|
-
<span class="sr-only">${showHideText}</span>
|
|
134
|
-
<span class="eye eye-open">${eyeIcon}</span>
|
|
135
|
-
<span class="eye eye-closed">${eyeClosedIcon}</span>
|
|
136
|
-
</label>
|
|
137
|
-
</div>
|
|
138
|
-
</div>
|
|
139
|
-
<label
|
|
140
|
-
for=${showOnlyCheckboxId}
|
|
141
|
-
class="facet-info-display"
|
|
142
|
-
title=${onlyShowText}
|
|
143
|
-
aria-label=${ariaLabel}
|
|
144
|
-
>
|
|
145
|
-
<div class="facet-title">${bucketTextDisplay}</div>
|
|
146
|
-
<div class="facet-count">${bucketCountText}</div>
|
|
147
|
-
</label>
|
|
148
|
-
</div>
|
|
149
|
-
`;
|
|
60
|
+
return facetRowTemplate({
|
|
61
|
+
facetType,
|
|
62
|
+
bucket,
|
|
63
|
+
collectionTitles: this.collectionTitles,
|
|
64
|
+
omitHideButton: this.omitHideButton,
|
|
65
|
+
onCheckboxClick: (e, negative) => this.facetClicked(e, negative),
|
|
66
|
+
});
|
|
150
67
|
}
|
|
151
68
|
|
|
152
69
|
//
|
|
@@ -192,13 +109,7 @@ export class FacetRow extends LitElement {
|
|
|
192
109
|
* Returns the composed facet state corresponding to a positive or negative facet's checked state
|
|
193
110
|
*/
|
|
194
111
|
static getFacetState(checked: boolean, negative: boolean): FacetState {
|
|
195
|
-
|
|
196
|
-
if (checked) {
|
|
197
|
-
state = negative ? 'hidden' : 'selected';
|
|
198
|
-
} else {
|
|
199
|
-
state = 'none';
|
|
200
|
-
}
|
|
201
|
-
return state;
|
|
112
|
+
return getFacetState(checked, negative);
|
|
202
113
|
}
|
|
203
114
|
|
|
204
115
|
//
|
|
@@ -206,104 +117,6 @@ export class FacetRow extends LitElement {
|
|
|
206
117
|
//
|
|
207
118
|
|
|
208
119
|
static get styles(): CSSResultGroup {
|
|
209
|
-
|
|
210
|
-
const facetRowBorderBottom = css`var(--facet-row-border-bottom, 1px solid transparent)`;
|
|
211
|
-
const checkboxHeight = css`15px`;
|
|
212
|
-
|
|
213
|
-
const ownCss = css`
|
|
214
|
-
.facet-checkboxes {
|
|
215
|
-
margin: 0 5px 0 0;
|
|
216
|
-
display: flex;
|
|
217
|
-
height: ${checkboxHeight};
|
|
218
|
-
}
|
|
219
|
-
.facet-checkboxes input:first-child {
|
|
220
|
-
margin-right: 5px;
|
|
221
|
-
}
|
|
222
|
-
.facet-checkboxes input {
|
|
223
|
-
height: ${checkboxHeight};
|
|
224
|
-
width: ${checkboxHeight};
|
|
225
|
-
margin: 0;
|
|
226
|
-
}
|
|
227
|
-
.facet-row-container {
|
|
228
|
-
display: flex;
|
|
229
|
-
font-weight: 500;
|
|
230
|
-
font-size: 1.2rem;
|
|
231
|
-
margin: 0 auto;
|
|
232
|
-
padding: 0.25rem 0;
|
|
233
|
-
height: auto;
|
|
234
|
-
border-top: ${facetRowBorderTop};
|
|
235
|
-
border-bottom: ${facetRowBorderBottom};
|
|
236
|
-
}
|
|
237
|
-
.facet-info-display {
|
|
238
|
-
display: flex;
|
|
239
|
-
flex: 1 1 0%;
|
|
240
|
-
cursor: pointer;
|
|
241
|
-
flex-wrap: wrap;
|
|
242
|
-
}
|
|
243
|
-
.facet-title {
|
|
244
|
-
word-break: break-word;
|
|
245
|
-
display: inline-block;
|
|
246
|
-
flex: 1 1 0%;
|
|
247
|
-
}
|
|
248
|
-
.facet-note {
|
|
249
|
-
color: #bbb;
|
|
250
|
-
}
|
|
251
|
-
.facet-count {
|
|
252
|
-
text-align: right;
|
|
253
|
-
}
|
|
254
|
-
.select-facet-checkbox {
|
|
255
|
-
cursor: pointer;
|
|
256
|
-
display: inline-block;
|
|
257
|
-
}
|
|
258
|
-
.hide-facet-checkbox {
|
|
259
|
-
position: absolute;
|
|
260
|
-
clip: rect(0, 0, 0, 0);
|
|
261
|
-
pointer-events: none;
|
|
262
|
-
}
|
|
263
|
-
.hide-facet-checkbox:focus-visible + .hide-facet-icon {
|
|
264
|
-
outline-style: auto;
|
|
265
|
-
outline-offset: 2px;
|
|
266
|
-
}
|
|
267
|
-
.hide-facet-icon {
|
|
268
|
-
width: ${checkboxHeight};
|
|
269
|
-
height: ${checkboxHeight};
|
|
270
|
-
cursor: pointer;
|
|
271
|
-
display: flex;
|
|
272
|
-
}
|
|
273
|
-
.eye {
|
|
274
|
-
width: ${checkboxHeight};
|
|
275
|
-
height: ${checkboxHeight};
|
|
276
|
-
opacity: 0.3;
|
|
277
|
-
}
|
|
278
|
-
.hide-facet-icon:hover .eye,
|
|
279
|
-
.active .eye {
|
|
280
|
-
opacity: 1;
|
|
281
|
-
}
|
|
282
|
-
.hide-facet-icon:hover .eye-open,
|
|
283
|
-
.hide-facet-icon .eye-closed {
|
|
284
|
-
display: none;
|
|
285
|
-
}
|
|
286
|
-
.hide-facet-icon:hover .eye-closed,
|
|
287
|
-
.hide-facet-icon.active .eye-closed {
|
|
288
|
-
display: inline;
|
|
289
|
-
}
|
|
290
|
-
.hide-facet-icon.active .eye-open {
|
|
291
|
-
display: none;
|
|
292
|
-
}
|
|
293
|
-
.sorting-icon {
|
|
294
|
-
cursor: pointer;
|
|
295
|
-
}
|
|
296
|
-
|
|
297
|
-
a:link,
|
|
298
|
-
a:visited {
|
|
299
|
-
text-decoration: none;
|
|
300
|
-
color: var(--ia-theme-link-color, #4b64ff);
|
|
301
|
-
}
|
|
302
|
-
a:hover {
|
|
303
|
-
text-decoration: underline;
|
|
304
|
-
}
|
|
305
|
-
`;
|
|
306
|
-
|
|
307
|
-
return [srOnlyStyle, ownCss];
|
|
120
|
+
return [srOnlyStyle, facetRowStyles];
|
|
308
121
|
}
|
|
309
122
|
}
|
|
@@ -4,7 +4,13 @@
|
|
|
4
4
|
export const MORE_FACETS__MAX_AGGREGATIONS = 10000;
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Width in px of each column of facets in the More... facet dialogs. Every
|
|
8
|
+
* column is this wide; the number of columns per page is however many fit.
|
|
9
|
+
*/
|
|
10
|
+
export const MORE_FACETS__COLUMN_WIDTH = 250;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Default number of facets stacked in each column of the More... facet dialogs.
|
|
8
14
|
* Can be overridden via component property.
|
|
9
15
|
*/
|
|
10
|
-
export const
|
|
16
|
+
export const MORE_FACETS__ROWS_PER_COLUMN = 12;
|