@internetarchive/collection-browser 0.2.16-alpha1 → 0.2.18
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.d.ts +0 -1
- package/dist/src/app-root.js +2 -29
- package/dist/src/app-root.js.map +1 -1
- package/dist/src/collection-browser.d.ts +0 -2
- package/dist/src/collection-browser.js +19 -8
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/collection-facets.d.ts +2 -19
- package/dist/src/collection-facets.js +0 -102
- package/dist/src/collection-facets.js.map +1 -1
- package/dist/test/mocks/mock-search-responses.js +0 -13
- package/dist/test/mocks/mock-search-responses.js.map +1 -1
- package/package.json +1 -3
- package/src/app-root.ts +2 -29
- package/src/collection-browser.ts +19 -7
- package/src/collection-facets.ts +1 -117
- package/test/mocks/mock-search-responses.ts +0 -13
- package/dist/src/assets/img/icons/arrow-left.d.ts +0 -2
- package/dist/src/assets/img/icons/arrow-left.js +0 -10
- package/dist/src/assets/img/icons/arrow-left.js.map +0 -1
- package/dist/src/assets/img/icons/arrow-right.d.ts +0 -2
- package/dist/src/assets/img/icons/arrow-right.js +0 -10
- package/dist/src/assets/img/icons/arrow-right.js.map +0 -1
- package/dist/src/collection-facets/more-facets-content.d.ts +0 -56
- package/dist/src/collection-facets/more-facets-content.js +0 -374
- package/dist/src/collection-facets/more-facets-content.js.map +0 -1
- package/dist/src/collection-facets/more-facets-pagination.d.ts +0 -27
- package/dist/src/collection-facets/more-facets-pagination.js +0 -193
- package/dist/src/collection-facets/more-facets-pagination.js.map +0 -1
- package/dist/test/collection-facets/more-facets-content.test.d.ts +0 -1
- package/dist/test/collection-facets/more-facets-content.test.js +0 -75
- package/dist/test/collection-facets/more-facets-content.test.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 -38
- package/dist/test/collection-facets/more-facets-pagination.test.js.map +0 -1
- package/src/assets/img/icons/arrow-left.ts +0 -10
- package/src/assets/img/icons/arrow-right.ts +0 -10
- package/src/collection-facets/more-facets-content.ts +0 -393
- package/src/collection-facets/more-facets-pagination.ts +0 -201
- package/test/collection-facets/more-facets-content.test.ts +0 -113
- package/test/collection-facets/more-facets-pagination.test.ts +0 -70
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { LitElement, PropertyValues, TemplateResult } from 'lit';
|
|
2
|
-
import type { Aggregation
|
|
2
|
+
import type { Aggregation } from '@internetarchive/search-service';
|
|
3
3
|
import '@internetarchive/histogram-date-range';
|
|
4
4
|
import '@internetarchive/feature-feedback';
|
|
5
5
|
import '@internetarchive/collection-name-cache';
|
|
6
6
|
import type { CollectionNameCacheInterface } from '@internetarchive/collection-name-cache';
|
|
7
|
-
import {
|
|
8
|
-
import { FacetOption, SelectedFacets, FacetGroup } from './models';
|
|
7
|
+
import { FacetOption, SelectedFacets } from './models';
|
|
9
8
|
import type { LanguageCodeHandlerInterface } from './language-code-handler/language-code-handler';
|
|
10
|
-
import './collection-facets/more-facets-content';
|
|
11
9
|
export declare class CollectionFacets extends LitElement {
|
|
12
|
-
searchService?: SearchServiceInterface;
|
|
13
10
|
aggregations?: Record<string, Aggregation>;
|
|
14
11
|
fullYearsHistogramAggregation?: Aggregation;
|
|
15
12
|
minSelectedDate?: string;
|
|
@@ -19,16 +16,9 @@ export declare class CollectionFacets extends LitElement {
|
|
|
19
16
|
selectedFacets?: SelectedFacets;
|
|
20
17
|
collapsableFacets: boolean;
|
|
21
18
|
showHistogramDatePicker: boolean;
|
|
22
|
-
fullQuery?: string;
|
|
23
|
-
modalManager?: ModalManagerInterface;
|
|
24
19
|
languageCodeHandler?: LanguageCodeHandlerInterface;
|
|
25
20
|
collectionNameCache?: CollectionNameCacheInterface;
|
|
26
21
|
openFacets: Record<FacetOption, boolean>;
|
|
27
|
-
/**
|
|
28
|
-
* If listed facets on page more then this number,
|
|
29
|
-
* - show the more link button just below the facets group
|
|
30
|
-
*/
|
|
31
|
-
private moreLinkEligibilityCount;
|
|
32
22
|
render(): TemplateResult<1>;
|
|
33
23
|
updated(changed: PropertyValues): void;
|
|
34
24
|
private dispatchFacetsChangedEvent;
|
|
@@ -53,13 +43,6 @@ export declare class CollectionFacets extends LitElement {
|
|
|
53
43
|
* chevron for the mobile view
|
|
54
44
|
*/
|
|
55
45
|
private getFacetGroupTemplate;
|
|
56
|
-
/**
|
|
57
|
-
* Generate the More... link button just below the facets group
|
|
58
|
-
*
|
|
59
|
-
* TODO: want to fire analytics?
|
|
60
|
-
*/
|
|
61
|
-
private searchMoreFacetsLink;
|
|
62
|
-
showMoreFacetsModal(facetGroup: FacetGroup): Promise<void>;
|
|
63
46
|
/**
|
|
64
47
|
* Generate the list template for each bucket in a facet group
|
|
65
48
|
*/
|
|
@@ -6,12 +6,10 @@ import { repeat } from 'lit/directives/repeat.js';
|
|
|
6
6
|
import '@internetarchive/histogram-date-range';
|
|
7
7
|
import '@internetarchive/feature-feedback';
|
|
8
8
|
import '@internetarchive/collection-name-cache';
|
|
9
|
-
import { ModalConfig, } from '@internetarchive/modal-manager';
|
|
10
9
|
import eyeIcon from './assets/img/icons/eye';
|
|
11
10
|
import eyeClosedIcon from './assets/img/icons/eye-closed';
|
|
12
11
|
import chevronIcon from './assets/img/icons/chevron';
|
|
13
12
|
import { defaultSelectedFacets, } from './models';
|
|
14
|
-
import './collection-facets/more-facets-content';
|
|
15
13
|
const facetDisplayOrder = [
|
|
16
14
|
'mediatype',
|
|
17
15
|
'year',
|
|
@@ -51,11 +49,6 @@ let CollectionFacets = class CollectionFacets extends LitElement {
|
|
|
51
49
|
collection: false,
|
|
52
50
|
year: false,
|
|
53
51
|
};
|
|
54
|
-
/**
|
|
55
|
-
* If listed facets on page more then this number,
|
|
56
|
-
* - show the more link button just below the facets group
|
|
57
|
-
*/
|
|
58
|
-
this.moreLinkEligibilityCount = 5;
|
|
59
52
|
}
|
|
60
53
|
render() {
|
|
61
54
|
return html `
|
|
@@ -77,7 +70,6 @@ let CollectionFacets = class CollectionFacets extends LitElement {
|
|
|
77
70
|
this.dispatchFacetsChangedEvent();
|
|
78
71
|
}
|
|
79
72
|
}
|
|
80
|
-
// TODO: want to fire analytics?
|
|
81
73
|
dispatchFacetsChangedEvent() {
|
|
82
74
|
const event = new CustomEvent('facetsChanged', {
|
|
83
75
|
detail: this.selectedFacets,
|
|
@@ -256,82 +248,10 @@ let CollectionFacets = class CollectionFacets extends LitElement {
|
|
|
256
248
|
</h1>
|
|
257
249
|
<div class="facet-group-content ${isOpen ? 'open' : ''}">
|
|
258
250
|
${this.getFacetTemplate(facetGroup)}
|
|
259
|
-
${this.searchMoreFacetsLink(facetGroup)}
|
|
260
251
|
</div>
|
|
261
252
|
</div>
|
|
262
253
|
`;
|
|
263
254
|
}
|
|
264
|
-
/**
|
|
265
|
-
* Generate the More... link button just below the facets group
|
|
266
|
-
*
|
|
267
|
-
* TODO: want to fire analytics?
|
|
268
|
-
*/
|
|
269
|
-
searchMoreFacetsLink(facetGroup) {
|
|
270
|
-
// don't render More... link if the number of facets is < this.moreLinkEligibilityCount
|
|
271
|
-
if (Object.keys(facetGroup.buckets).length < this.moreLinkEligibilityCount)
|
|
272
|
-
return nothing;
|
|
273
|
-
return html `<button
|
|
274
|
-
class="more-link"
|
|
275
|
-
@click=${() => {
|
|
276
|
-
this.showMoreFacetsModal(facetGroup);
|
|
277
|
-
}}
|
|
278
|
-
>
|
|
279
|
-
More...
|
|
280
|
-
</button>`;
|
|
281
|
-
}
|
|
282
|
-
async showMoreFacetsModal(facetGroup) {
|
|
283
|
-
var _a, _b;
|
|
284
|
-
const facetAggrKey = Object.keys(aggregationToFacetOption).find(value => aggregationToFacetOption[value] === facetGroup.key);
|
|
285
|
-
// TODO - lets move sr-only style into modal-manager component as well
|
|
286
|
-
const headline = html `
|
|
287
|
-
<span
|
|
288
|
-
style="display:block;text-align:left;font-size:1.8rem;padding:0 10px;"
|
|
289
|
-
>
|
|
290
|
-
<span
|
|
291
|
-
style="position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip: rect(0,0,0,0);border:0;"
|
|
292
|
-
>More facets for:
|
|
293
|
-
</span>
|
|
294
|
-
${facetTitles[facetGroup.key]}
|
|
295
|
-
<img
|
|
296
|
-
src="https://archive.org/images/filter-count.png"
|
|
297
|
-
style="height: 1.5rem;vertical-align: baseline;"
|
|
298
|
-
alt=""
|
|
299
|
-
/>
|
|
300
|
-
</span>
|
|
301
|
-
`;
|
|
302
|
-
const message = html `
|
|
303
|
-
<more-facets-content
|
|
304
|
-
@facetsChanged=${(e) => {
|
|
305
|
-
const event = new CustomEvent('facetsChanged', {
|
|
306
|
-
detail: e.detail,
|
|
307
|
-
bubbles: true,
|
|
308
|
-
composed: true,
|
|
309
|
-
});
|
|
310
|
-
this.dispatchEvent(event);
|
|
311
|
-
}}
|
|
312
|
-
.facetKey=${facetGroup.key}
|
|
313
|
-
.facetAggregationKey=${facetAggrKey}
|
|
314
|
-
.fullQuery=${this.fullQuery}
|
|
315
|
-
.modalManager=${this.modalManager}
|
|
316
|
-
.searchService=${this.searchService}
|
|
317
|
-
.collectionNameCache=${this.collectionNameCache}
|
|
318
|
-
.languageCodeHandler=${this.languageCodeHandler}
|
|
319
|
-
.selectedFacets=${this.selectedFacets}
|
|
320
|
-
>
|
|
321
|
-
</more-facets-content>
|
|
322
|
-
`;
|
|
323
|
-
const config = new ModalConfig({
|
|
324
|
-
bodyColor: '#fff',
|
|
325
|
-
headerColor: '#194880',
|
|
326
|
-
showHeaderLogo: false,
|
|
327
|
-
closeOnBackdropClick: true,
|
|
328
|
-
title: html `Select filters`,
|
|
329
|
-
headline,
|
|
330
|
-
message,
|
|
331
|
-
});
|
|
332
|
-
(_a = this.modalManager) === null || _a === void 0 ? void 0 : _a.classList.add('more-search-facets');
|
|
333
|
-
(_b = this.modalManager) === null || _b === void 0 ? void 0 : _b.showModal({ config });
|
|
334
|
-
}
|
|
335
255
|
/**
|
|
336
256
|
* Generate the list template for each bucket in a facet group
|
|
337
257
|
*/
|
|
@@ -594,25 +514,9 @@ let CollectionFacets = class CollectionFacets extends LitElement {
|
|
|
594
514
|
.hide-facet-icon.active .eye {
|
|
595
515
|
display: none;
|
|
596
516
|
}
|
|
597
|
-
|
|
598
|
-
.more-link {
|
|
599
|
-
font-size: 1.2rem;
|
|
600
|
-
text-decoration: none;
|
|
601
|
-
padding: 0px 4px;
|
|
602
|
-
background: inherit;
|
|
603
|
-
border: 0;
|
|
604
|
-
color: blue;
|
|
605
|
-
cursor: pointer;
|
|
606
|
-
}
|
|
607
|
-
.sorting-icon {
|
|
608
|
-
cursor: pointer;
|
|
609
|
-
}
|
|
610
517
|
`;
|
|
611
518
|
}
|
|
612
519
|
};
|
|
613
|
-
__decorate([
|
|
614
|
-
property({ type: Object })
|
|
615
|
-
], CollectionFacets.prototype, "searchService", void 0);
|
|
616
520
|
__decorate([
|
|
617
521
|
property({ type: Object })
|
|
618
522
|
], CollectionFacets.prototype, "aggregations", void 0);
|
|
@@ -640,12 +544,6 @@ __decorate([
|
|
|
640
544
|
__decorate([
|
|
641
545
|
property({ type: Boolean })
|
|
642
546
|
], CollectionFacets.prototype, "showHistogramDatePicker", void 0);
|
|
643
|
-
__decorate([
|
|
644
|
-
property({ type: String })
|
|
645
|
-
], CollectionFacets.prototype, "fullQuery", void 0);
|
|
646
|
-
__decorate([
|
|
647
|
-
property({ type: Object })
|
|
648
|
-
], CollectionFacets.prototype, "modalManager", void 0);
|
|
649
547
|
__decorate([
|
|
650
548
|
property({ type: Object })
|
|
651
549
|
], CollectionFacets.prototype, "languageCodeHandler", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection-facets.js","sourceRoot":"","sources":["../../src/collection-facets.ts"],"names":[],"mappings":";AAAA,yCAAyC;AACzC,OAAO,EACL,GAAG,EACH,IAAI,EACJ,UAAU,EAEV,OAAO,GAER,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,K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E,MAAM,EAAE,CAAC;sDAA4C;AAE3C;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uEAA6C;AAE5C;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yDAA0B;AAEzB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yDAA0B;AAExB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;uDAAuB;AAEtB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;oEAAoC;AAEpC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;wDAAiC;AAE/B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;2DAA2B;AAE1B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;iEAAiC;AAEjC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mDAAoB;AAEnB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sDAAsC;AAGjE;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6DACwB;AAGnD;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6DACwB;AAE1C;IAAR,KAAK,EAAE;oDAON;AAtCS,gBAAgB;IAD5B,aAAa,CAAC,mBAAmB,CAAC;GACtB,gBAAgB,CAopB5B;SAppBY,gBAAgB","sourcesContent":["/* eslint-disable import/no-duplicates */\nimport {\n css,\n html,\n LitElement,\n PropertyValues,\n nothing,\n TemplateResult,\n} from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport { repeat } from 'lit/directives/repeat.js';\nimport type {\n Aggregation,\n Bucket,\n SearchServiceInterface,\n} from '@internetarchive/search-service';\nimport '@internetarchive/histogram-date-range';\nimport '@internetarchive/feature-feedback';\nimport '@internetarchive/collection-name-cache';\nimport type { CollectionNameCacheInterface } from '@internetarchive/collection-name-cache';\nimport {\n ModalConfig,\n ModalManagerInterface,\n} from '@internetarchive/modal-manager';\nimport eyeIcon from './assets/img/icons/eye';\nimport eyeClosedIcon from './assets/img/icons/eye-closed';\nimport chevronIcon from './assets/img/icons/chevron';\nimport {\n FacetOption,\n SelectedFacets,\n FacetGroup,\n FacetBucket,\n defaultSelectedFacets,\n} from './models';\nimport type { LanguageCodeHandlerInterface } from './language-code-handler/language-code-handler';\nimport './collection-facets/more-facets-content';\n\nconst facetDisplayOrder: FacetOption[] = [\n 'mediatype',\n 'year',\n 'subject',\n 'collection',\n 'creator',\n 'language',\n];\n\nconst aggregationToFacetOption: Record<string, FacetOption> = {\n subjectSorter: 'subject',\n mediatypeSorter: 'mediatype',\n languageSorter: 'language',\n creatorSorter: 'creator',\n collection: 'collection',\n year: 'year',\n};\n\nconst facetTitles: Record<FacetOption, string> = {\n subject: 'Subject',\n mediatype: 'Media Type',\n language: 'Language',\n creator: 'Creator',\n collection: 'Collection',\n year: 'Year',\n};\n\n@customElement('collection-facets')\nexport class CollectionFacets extends LitElement {\n @property({ type: Object }) searchService?: SearchServiceInterface;\n\n @property({ type: Object }) aggregations?: Record<string, Aggregation>;\n\n @property({ type: Object }) fullYearsHistogramAggregation?: Aggregation;\n\n @property({ type: String }) minSelectedDate?: string;\n\n @property({ type: String }) maxSelectedDate?: string;\n\n @property({ type: Boolean }) facetsLoading = false;\n\n @property({ type: Boolean }) fullYearAggregationLoading = false;\n\n @property({ type: Object }) selectedFacets?: SelectedFacets;\n\n @property({ type: Boolean }) collapsableFacets = false;\n\n @property({ type: Boolean }) showHistogramDatePicker = false;\n\n @property({ type: String }) fullQuery?: string;\n\n @property({ type: Object }) modalManager?: ModalManagerInterface;\n\n @property({ type: Object })\n languageCodeHandler?: LanguageCodeHandlerInterface;\n\n @property({ type: Object })\n collectionNameCache?: CollectionNameCacheInterface;\n\n @state() openFacets: Record<FacetOption, boolean> = {\n subject: false,\n mediatype: false,\n language: false,\n creator: false,\n collection: false,\n year: false,\n };\n\n /**\n * If listed facets on page more then this number,\n * - show the more link button just below the facets group\n */\n private moreLinkEligibilityCount = 5;\n\n render() {\n return html`\n <div id=\"container\" class=\"${this.facetsLoading ? 'loading' : ''}\">\n ${this.showHistogramDatePicker && this.fullYearsHistogramAggregation\n ? html`\n <div class=\"facet-group\">\n <h1>Year Published <feature-feedback></feature-feedback></h1>\n ${this.histogramTemplate}\n </div>\n `\n : nothing}\n ${this.mergedFacets.map(facetGroup =>\n this.getFacetGroupTemplate(facetGroup)\n )}\n </div>\n `;\n }\n\n updated(changed: PropertyValues) {\n if (changed.has('selectedFacets')) {\n this.dispatchFacetsChangedEvent();\n }\n }\n\n // TODO: want to fire analytics?\n private dispatchFacetsChangedEvent() {\n const event = new CustomEvent<SelectedFacets>('facetsChanged', {\n detail: this.selectedFacets,\n });\n this.dispatchEvent(event);\n }\n\n private get currentYearsHistogramAggregation(): Aggregation | undefined {\n return this.aggregations?.year_histogram;\n }\n\n private get histogramTemplate() {\n const { fullYearsHistogramAggregation } = this;\n return html`\n <histogram-date-range\n .minDate=${fullYearsHistogramAggregation?.first_bucket_key}\n .maxDate=${fullYearsHistogramAggregation?.last_bucket_key}\n .minSelectedDate=${this.minSelectedDate}\n .maxSelectedDate=${this.maxSelectedDate}\n .updateDelay=${100}\n missingDataMessage=\"...\"\n .width=${180}\n .bins=${fullYearsHistogramAggregation?.buckets as number[]}\n @histogramDateRangeUpdated=${this.histogramDateRangeUpdated}\n ></histogram-date-range>\n `;\n }\n\n private histogramDateRangeUpdated(\n e: CustomEvent<{\n minDate: string;\n maxDate: string;\n }>\n ) {\n const { minDate, maxDate } = e.detail;\n const event = new CustomEvent('histogramDateRangeUpdated', {\n detail: { minDate, maxDate },\n });\n this.dispatchEvent(event);\n }\n\n /**\n * Combines the selected facets with the aggregations to create a single list of facets\n */\n private get mergedFacets(): FacetGroup[] {\n const facetGroups: FacetGroup[] = [];\n\n facetDisplayOrder.forEach(facetKey => {\n const selectedFacetGroup = this.selectedFacetGroups.find(\n group => group.key === facetKey\n );\n const aggregateFacetGroup = this.aggregationFacetGroups.find(\n group => group.key === facetKey\n );\n\n // if the user selected a facet, but it's not in the aggregation, we add it as-is\n if (selectedFacetGroup && !aggregateFacetGroup) {\n facetGroups.push(selectedFacetGroup);\n return;\n }\n\n // if we don't have an aggregate facet group, don't add this to the list\n if (!aggregateFacetGroup) return;\n\n // start with either the selected group if we have one, or the aggregate group\n const facetGroup = selectedFacetGroup ?? aggregateFacetGroup;\n\n // attach the counts to the selected buckets\n const bucketsWithCount =\n selectedFacetGroup?.buckets.map(bucket => {\n const selectedBucket = aggregateFacetGroup.buckets.find(\n b => b.key === bucket.key\n );\n return selectedBucket\n ? {\n ...bucket,\n count: selectedBucket.count,\n }\n : bucket;\n }) ?? [];\n\n // append any additional buckets that were not selected\n aggregateFacetGroup.buckets.forEach(bucket => {\n const existingBucket = bucketsWithCount.find(b => b.key === bucket.key);\n if (existingBucket) return;\n bucketsWithCount.push(bucket);\n });\n facetGroup.buckets = bucketsWithCount.splice(0, 5);\n\n facetGroups.push(facetGroup);\n });\n\n return facetGroups;\n }\n\n /**\n * Converts the selected facets to a `FacetGroup` array,\n * which is easier to work with\n */\n private get selectedFacetGroups(): FacetGroup[] {\n if (!this.selectedFacets) return [];\n\n const facetGroups: FacetGroup[] = Object.entries(this.selectedFacets).map(\n ([key, selectedFacets]) => {\n const option = key as FacetOption;\n const title = facetTitles[option];\n\n const buckets: FacetBucket[] = Object.entries(selectedFacets).map(\n ([value, facetState]) => {\n let displayText = value;\n // for selected languages, we store the language code instead of the\n // display name, so look up the name from the mapping\n if (option === 'language') {\n displayText =\n this.languageCodeHandler?.getLanguageNameFromCodeString(\n value\n ) ?? value;\n }\n return {\n displayText,\n key: value,\n count: 0,\n state: facetState,\n };\n }\n );\n\n return {\n title,\n key: option,\n buckets,\n };\n }\n );\n\n return facetGroups;\n }\n\n /**\n * Converts the raw `aggregations` to `FacetGroups`, which are easier to use\n */\n private get aggregationFacetGroups(): FacetGroup[] {\n const facetGroups: FacetGroup[] = [];\n Object.entries(this.aggregations ?? []).forEach(([key, buckets]) => {\n // the year_histogram data is in a different format so can't be handled here\n if (key === 'year_histogram') return;\n const option = this.getFacetOptionFromKey(key);\n const title = facetTitles[option];\n const castedBuckets = buckets.buckets as Bucket[];\n const facetBuckets: FacetBucket[] = castedBuckets.map(bucket => {\n let bucketKey = bucket.key;\n // for languages, we need to search by language code instead of the\n // display name, which is what we get from the search engine result\n if (option === 'language') {\n // const languageCodeKey = languageToCodeMap[bucket.key];\n bucketKey =\n this.languageCodeHandler?.getCodeStringFromLanguageName(\n `${bucket.key}`\n ) ?? bucket.key;\n // bucketKey = languageCodeKey ?? bucket.key;\n }\n return {\n displayText: `${bucket.key}`,\n key: `${bucketKey}`,\n count: bucket.doc_count,\n state: 'none',\n };\n });\n const group: FacetGroup = {\n title,\n key: option,\n buckets: facetBuckets,\n };\n facetGroups.push(group);\n });\n return facetGroups;\n }\n\n /**\n * Generate the template for a facet group with a header and the collapsible\n * chevron for the mobile view\n */\n private getFacetGroupTemplate(\n facetGroup: FacetGroup\n ): TemplateResult | typeof nothing {\n if (facetGroup.buckets.length === 0) return nothing;\n const { key } = facetGroup;\n const isOpen = this.openFacets[key];\n const collapser = html`\n <span class=\"collapser ${isOpen ? 'open' : ''}\"> ${chevronIcon} </span>\n `;\n\n return html`\n <div class=\"facet-group ${this.collapsableFacets ? 'mobile' : ''}\">\n <h1\n @click=${() => {\n const newOpenFacets = { ...this.openFacets };\n newOpenFacets[key] = !isOpen;\n this.openFacets = newOpenFacets;\n }}\n @keyup=${() => {\n const newOpenFacets = { ...this.openFacets };\n newOpenFacets[key] = !isOpen;\n this.openFacets = newOpenFacets;\n }}\n >\n ${this.collapsableFacets ? collapser : nothing} ${facetGroup.title}\n </h1>\n <div class=\"facet-group-content ${isOpen ? 'open' : ''}\">\n ${this.getFacetTemplate(facetGroup)}\n ${this.searchMoreFacetsLink(facetGroup)}\n </div>\n </div>\n `;\n }\n\n /**\n * Generate the More... link button just below the facets group\n *\n * TODO: want to fire analytics?\n */\n private searchMoreFacetsLink(\n facetGroup: FacetGroup\n ): TemplateResult | typeof nothing {\n // don't render More... link if the number of facets is < this.moreLinkEligibilityCount\n if (Object.keys(facetGroup.buckets).length < this.moreLinkEligibilityCount)\n return nothing;\n\n return html`<button\n class=\"more-link\"\n @click=${() => {\n this.showMoreFacetsModal(facetGroup);\n }}\n >\n More...\n </button>`;\n }\n\n async showMoreFacetsModal(facetGroup: FacetGroup): Promise<void> {\n const facetAggrKey = Object.keys(aggregationToFacetOption).find(\n value => aggregationToFacetOption[value] === facetGroup.key\n );\n\n // TODO - lets move sr-only style into modal-manager component as well\n const headline = html`\n <span\n style=\"display:block;text-align:left;font-size:1.8rem;padding:0 10px;\"\n >\n <span\n style=\"position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip: rect(0,0,0,0);border:0;\"\n >More facets for:\n </span>\n ${facetTitles[facetGroup.key]}\n <img\n src=\"https://archive.org/images/filter-count.png\"\n style=\"height: 1.5rem;vertical-align: baseline;\"\n alt=\"\"\n />\n </span>\n `;\n\n const message = html`\n <more-facets-content\n @facetsChanged=${(e: CustomEvent) => {\n const event = new CustomEvent<SelectedFacets>('facetsChanged', {\n detail: e.detail,\n bubbles: true,\n composed: true,\n });\n this.dispatchEvent(event);\n }}\n .facetKey=${facetGroup.key}\n .facetAggregationKey=${facetAggrKey}\n .fullQuery=${this.fullQuery}\n .modalManager=${this.modalManager}\n .searchService=${this.searchService}\n .collectionNameCache=${this.collectionNameCache}\n .languageCodeHandler=${this.languageCodeHandler}\n .selectedFacets=${this.selectedFacets}\n >\n </more-facets-content>\n `;\n\n const config = new ModalConfig({\n bodyColor: '#fff',\n headerColor: '#194880',\n showHeaderLogo: false,\n closeOnBackdropClick: true, // TODO: want to fire analytics\n title: html`Select filters`,\n headline,\n message,\n });\n this.modalManager?.classList.add('more-search-facets');\n this.modalManager?.showModal({ config });\n }\n\n /**\n * Generate the list template for each bucket in a facet group\n */\n private getFacetTemplate(facetGroup: FacetGroup): TemplateResult {\n const bucketsNoFavorites = facetGroup.buckets.filter(\n bucket => bucket.key.startsWith('fav-') === false\n );\n const bucketsMaxSix = bucketsNoFavorites.slice(0, 6);\n\n return html`\n <ul class=\"facet-list\">\n ${repeat(\n bucketsMaxSix,\n bucket => `${facetGroup.key}:${bucket.key}`,\n bucket => {\n const showOnlyCheckboxId = `${facetGroup.key}:${bucket.key}-show-only`;\n const negativeCheckboxId = `${facetGroup.key}:${bucket.key}-negative`;\n\n // for collections, we need to asynchronously load the collection name\n // so we use the `async-collection-name` widget and for the rest, we have\n // a static value to use\n const bucketTextDisplay =\n facetGroup.key !== 'collection'\n ? html`${bucket.displayText ?? bucket.key}`\n : html`\n <async-collection-name\n .collectionNameCache=${this.collectionNameCache}\n .identifier=${bucket.key}\n placeholder=\"-\"\n ></async-collection-name>\n `;\n\n const facetHidden = bucket.state === 'hidden';\n const facetSelected = bucket.state === 'selected';\n\n const titleText = `${facetGroup.key}: ${\n bucket.displayText ?? bucket.key\n }`;\n const onlyShowText = facetSelected\n ? `Show all ${facetGroup.key}s`\n : `Only show ${titleText}`;\n const hideText = `Hide ${titleText}`;\n const unhideText = `Unhide ${titleText}`;\n const showHideText = facetHidden ? unhideText : hideText;\n\n return html`\n <li>\n <div class=\"facet-row\">\n <div class=\"facet-checkbox\">\n <input\n type=\"checkbox\"\n .name=${facetGroup.key}\n .value=${bucket.key}\n @click=${(e: Event) => {\n this.facetClicked(e, bucket, false);\n }}\n .checked=${facetSelected}\n class=\"select-facet-checkbox\"\n title=${onlyShowText}\n id=${showOnlyCheckboxId}\n />\n <input\n type=\"checkbox\"\n id=${negativeCheckboxId}\n .name=${facetGroup.key}\n .value=${bucket.key}\n @click=${(e: Event) => {\n this.facetClicked(e, bucket, true);\n }}\n .checked=${facetHidden}\n class=\"hide-facet-checkbox\"\n />\n <label\n for=${negativeCheckboxId}\n class=\"hide-facet-icon${facetHidden ? ' active' : ''}\"\n title=${showHideText}\n >\n <span class=\"eye\">${eyeIcon}</span>\n <span class=\"eye-closed\">${eyeClosedIcon}</span>\n </label>\n </div>\n\n <label\n for=${showOnlyCheckboxId}\n class=\"facet-info-display\"\n title=${onlyShowText}\n >\n <div class=\"facet-title\">${bucketTextDisplay}</div>\n <div class=\"facet-count\">${bucket.count}</div>\n </label>\n </div>\n </li>\n `;\n }\n )}\n </ul>\n `;\n }\n\n private facetClicked(e: Event, bucket: FacetBucket, negative: boolean) {\n const target = e.target as HTMLInputElement;\n const { checked, name, value } = target;\n if (checked) {\n this.facetChecked(name as FacetOption, value, negative);\n } else {\n this.facetUnchecked(name as FacetOption, value);\n }\n }\n\n private facetChecked(key: FacetOption, value: string, negative: boolean) {\n const { selectedFacets } = this;\n let newFacets: SelectedFacets;\n if (selectedFacets) {\n newFacets = {\n ...selectedFacets,\n };\n } else {\n newFacets = defaultSelectedFacets;\n }\n newFacets[key][value] = negative ? 'hidden' : 'selected';\n this.selectedFacets = newFacets;\n }\n\n private facetUnchecked(key: FacetOption, value: string) {\n const { selectedFacets } = this;\n let newFacets: SelectedFacets;\n if (selectedFacets) {\n newFacets = {\n ...selectedFacets,\n };\n } else {\n newFacets = defaultSelectedFacets;\n }\n delete newFacets[key][value];\n this.selectedFacets = newFacets;\n }\n\n /**\n * Parse the aggregate key title into the human readable title\n *\n * Example: user_aggs__terms__field:mediatypeSorter__size:6 => Media Type\n *\n * @param key\n * @returns\n */\n private getFacetOptionFromKey(key: string): FacetOption {\n const parts = key.split('__');\n const fieldNamePart = parts[2];\n const fieldName = fieldNamePart.split(':')[1];\n const facetMatch = Object.entries(aggregationToFacetOption).find(([key2]) =>\n fieldName.includes(key2)\n );\n const option = facetMatch?.[1];\n if (!option) throw new Error(`Could not find facet option for key: ${key}`);\n return option;\n }\n\n static get styles() {\n return css`\n #container.loading {\n opacity: 0.5;\n }\n\n .collapser {\n display: inline-block;\n cursor: pointer;\n width: 10px;\n height: 10px;\n }\n\n .collapser svg {\n transition: transform 0.2s ease-in-out;\n }\n\n .collapser.open svg {\n transform: rotate(90deg);\n }\n\n .facet-group {\n margin-bottom: 2rem;\n }\n\n .facet-group h1 {\n margin-bottom: 0.7rem;\n }\n\n .facet-group.mobile h1 {\n cursor: pointer;\n }\n\n .facet-group-content {\n transition: max-height 0.2s ease-in-out;\n }\n\n .facet-group.mobile .facet-group-content {\n max-height: 0;\n overflow: hidden;\n }\n\n .facet-group.mobile .facet-group-content.open {\n max-height: 2000px;\n }\n\n h1 {\n font-size: 1.4rem;\n font-weight: 200;\n border-bottom: 1px solid rgb(232, 232, 232);\n padding-bottom: 3px;\n margin: 0;\n }\n\n ul.facet-list {\n list-style: none;\n margin: 0;\n padding: 0;\n }\n\n ul.facet-list li {\n margin-bottom: 0.2rem;\n }\n\n .facet-checkbox {\n margin-right: 0.5rem;\n display: flex;\n align-items: center;\n }\n\n .facet-row {\n display: flex;\n align-items: start;\n font-weight: 500;\n font-size: 1.2rem;\n }\n\n .facet-info-display {\n display: flex;\n flex: 1;\n cursor: pointer;\n }\n\n .facet-title {\n flex: 1;\n }\n\n .facet-count {\n margin-left: 0.5rem;\n }\n\n .select-facet-checkbox {\n cursor: pointer;\n margin-right: 5px;\n }\n\n .hide-facet-checkbox {\n display: none;\n }\n\n .hide-facet-icon {\n width: 15px;\n height: 15px;\n cursor: pointer;\n opacity: 0.3;\n }\n .hide-facet-icon:hover,\n .active {\n opacity: 1;\n }\n .hide-facet-icon:hover .eye,\n .hide-facet-icon .eye-closed {\n display: none;\n }\n .hide-facet-icon:hover .eye-closed,\n .hide-facet-icon.active .eye-closed {\n display: inline;\n }\n .hide-facet-icon.active .eye {\n display: none;\n }\n\n .more-link {\n font-size: 1.2rem;\n text-decoration: none;\n padding: 0px 4px;\n background: inherit;\n border: 0;\n color: blue;\n cursor: pointer;\n }\n .sorting-icon {\n cursor: pointer;\n }\n `;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"collection-facets.js","sourceRoot":"","sources":["../../src/collection-facets.ts"],"names":[],"mappings":";AAAA,yCAAyC;AACzC,OAAO,EACL,GAAG,EACH,IAAI,EACJ,UAAU,EAEV,OAAO,GAER,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAElD,OAAO,uCAAuC,CAAC;AAC/C,OAAO,mCAAmC,CAAC;AAC3C,OAAO,wCAAwC,CAAC;AAEhD,OAAO,OAAO,MAAM,wBAAwB,CAAC;AAC7C,OAAO,aAAa,MAAM,+BAA+B,CAAC;AAC1D,OAAO,WAAW,MAAM,4BAA4B,CAAC;AACrD,OAAO,EAKL,qBAAqB,GACtB,MAAM,UAAU,CAAC;AAGlB,MAAM,iBAAiB,GAAkB;IACvC,WAAW;IACX,MAAM;IACN,SAAS;IACT,YAAY;IACZ,SAAS;IACT,UAAU;CACX,CAAC;AAEF,MAAM,wBAAwB,GAAgC;IAC5D,aAAa,EAAE,SAAS;IACxB,eAAe,EAAE,WAAW;IAC5B,cAAc,EAAE,UAAU;IAC1B,aAAa,EAAE,SAAS;IACxB,UAAU,EAAE,YAAY;IACxB,IAAI,EAAE,MAAM;CACb,CAAC;AAEF,MAAM,WAAW,GAAgC;IAC/C,OAAO,EAAE,SAAS;IAClB,SAAS,EAAE,YAAY;IACvB,QAAQ,EAAE,UAAU;IACpB,OAAO,EAAE,SAAS;IAClB,UAAU,EAAE,YAAY;IACxB,IAAI,EAAE,MAAM;CACb,CAAC;AAGF,IAAa,gBAAgB,GAA7B,MAAa,gBAAiB,SAAQ,UAAU;IAAhD;;QAS+B,kBAAa,GAAG,KAAK,CAAC;QAEtB,+BAA0B,GAAG,KAAK,CAAC;QAInC,sBAAiB,GAAG,KAAK,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B;AAEtB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;oEAAoC;AAEpC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;wDAAiC;AAE/B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;2DAA2B;AAE1B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;iEAAiC;AAG7D;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6DACwB;AAGnD;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6DACwB;AAE1C;IAAR,KAAK,EAAE;oDAON;AAhCS,gBAAgB;IAD5B,aAAa,CAAC,mBAAmB,CAAC;GACtB,gBAAgB,CAyiB5B;SAziBY,gBAAgB","sourcesContent":["/* eslint-disable import/no-duplicates */\nimport {\n css,\n html,\n LitElement,\n PropertyValues,\n nothing,\n TemplateResult,\n} from 'lit';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport { repeat } from 'lit/directives/repeat.js';\nimport type { Aggregation, Bucket } from '@internetarchive/search-service';\nimport '@internetarchive/histogram-date-range';\nimport '@internetarchive/feature-feedback';\nimport '@internetarchive/collection-name-cache';\nimport type { CollectionNameCacheInterface } from '@internetarchive/collection-name-cache';\nimport eyeIcon from './assets/img/icons/eye';\nimport eyeClosedIcon from './assets/img/icons/eye-closed';\nimport chevronIcon from './assets/img/icons/chevron';\nimport {\n FacetOption,\n SelectedFacets,\n FacetGroup,\n FacetBucket,\n defaultSelectedFacets,\n} from './models';\nimport type { LanguageCodeHandlerInterface } from './language-code-handler/language-code-handler';\n\nconst facetDisplayOrder: FacetOption[] = [\n 'mediatype',\n 'year',\n 'subject',\n 'collection',\n 'creator',\n 'language',\n];\n\nconst aggregationToFacetOption: Record<string, FacetOption> = {\n subjectSorter: 'subject',\n mediatypeSorter: 'mediatype',\n languageSorter: 'language',\n creatorSorter: 'creator',\n collection: 'collection',\n year: 'year',\n};\n\nconst facetTitles: Record<FacetOption, string> = {\n subject: 'Subject',\n mediatype: 'Media Type',\n language: 'Language',\n creator: 'Creator',\n collection: 'Collection',\n year: 'Year',\n};\n\n@customElement('collection-facets')\nexport class CollectionFacets extends LitElement {\n @property({ type: Object }) aggregations?: Record<string, Aggregation>;\n\n @property({ type: Object }) fullYearsHistogramAggregation?: Aggregation;\n\n @property({ type: String }) minSelectedDate?: string;\n\n @property({ type: String }) maxSelectedDate?: string;\n\n @property({ type: Boolean }) facetsLoading = false;\n\n @property({ type: Boolean }) fullYearAggregationLoading = false;\n\n @property({ type: Object }) selectedFacets?: SelectedFacets;\n\n @property({ type: Boolean }) collapsableFacets = false;\n\n @property({ type: Boolean }) showHistogramDatePicker = false;\n\n @property({ type: Object })\n languageCodeHandler?: LanguageCodeHandlerInterface;\n\n @property({ type: Object })\n collectionNameCache?: CollectionNameCacheInterface;\n\n @state() openFacets: Record<FacetOption, boolean> = {\n subject: false,\n mediatype: false,\n language: false,\n creator: false,\n collection: false,\n year: false,\n };\n\n render() {\n return html`\n <div id=\"container\" class=\"${this.facetsLoading ? 'loading' : ''}\">\n ${this.showHistogramDatePicker && this.fullYearsHistogramAggregation\n ? html`\n <div class=\"facet-group\">\n <h1>Year Published <feature-feedback></feature-feedback></h1>\n ${this.histogramTemplate}\n </div>\n `\n : nothing}\n ${this.mergedFacets.map(facetGroup =>\n this.getFacetGroupTemplate(facetGroup)\n )}\n </div>\n `;\n }\n\n updated(changed: PropertyValues) {\n if (changed.has('selectedFacets')) {\n this.dispatchFacetsChangedEvent();\n }\n }\n\n private dispatchFacetsChangedEvent() {\n const event = new CustomEvent<SelectedFacets>('facetsChanged', {\n detail: this.selectedFacets,\n });\n this.dispatchEvent(event);\n }\n\n private get currentYearsHistogramAggregation(): Aggregation | undefined {\n return this.aggregations?.year_histogram;\n }\n\n private get histogramTemplate() {\n const { fullYearsHistogramAggregation } = this;\n return html`\n <histogram-date-range\n .minDate=${fullYearsHistogramAggregation?.first_bucket_key}\n .maxDate=${fullYearsHistogramAggregation?.last_bucket_key}\n .minSelectedDate=${this.minSelectedDate}\n .maxSelectedDate=${this.maxSelectedDate}\n .updateDelay=${100}\n missingDataMessage=\"...\"\n .width=${180}\n .bins=${fullYearsHistogramAggregation?.buckets as number[]}\n @histogramDateRangeUpdated=${this.histogramDateRangeUpdated}\n ></histogram-date-range>\n `;\n }\n\n private histogramDateRangeUpdated(\n e: CustomEvent<{\n minDate: string;\n maxDate: string;\n }>\n ) {\n const { minDate, maxDate } = e.detail;\n const event = new CustomEvent('histogramDateRangeUpdated', {\n detail: { minDate, maxDate },\n });\n this.dispatchEvent(event);\n }\n\n /**\n * Combines the selected facets with the aggregations to create a single list of facets\n */\n private get mergedFacets(): FacetGroup[] {\n const facetGroups: FacetGroup[] = [];\n\n facetDisplayOrder.forEach(facetKey => {\n const selectedFacetGroup = this.selectedFacetGroups.find(\n group => group.key === facetKey\n );\n const aggregateFacetGroup = this.aggregationFacetGroups.find(\n group => group.key === facetKey\n );\n\n // if the user selected a facet, but it's not in the aggregation, we add it as-is\n if (selectedFacetGroup && !aggregateFacetGroup) {\n facetGroups.push(selectedFacetGroup);\n return;\n }\n\n // if we don't have an aggregate facet group, don't add this to the list\n if (!aggregateFacetGroup) return;\n\n // start with either the selected group if we have one, or the aggregate group\n const facetGroup = selectedFacetGroup ?? aggregateFacetGroup;\n\n // attach the counts to the selected buckets\n const bucketsWithCount =\n selectedFacetGroup?.buckets.map(bucket => {\n const selectedBucket = aggregateFacetGroup.buckets.find(\n b => b.key === bucket.key\n );\n return selectedBucket\n ? {\n ...bucket,\n count: selectedBucket.count,\n }\n : bucket;\n }) ?? [];\n\n // append any additional buckets that were not selected\n aggregateFacetGroup.buckets.forEach(bucket => {\n const existingBucket = bucketsWithCount.find(b => b.key === bucket.key);\n if (existingBucket) return;\n bucketsWithCount.push(bucket);\n });\n facetGroup.buckets = bucketsWithCount.splice(0, 5);\n\n facetGroups.push(facetGroup);\n });\n\n return facetGroups;\n }\n\n /**\n * Converts the selected facets to a `FacetGroup` array,\n * which is easier to work with\n */\n private get selectedFacetGroups(): FacetGroup[] {\n if (!this.selectedFacets) return [];\n\n const facetGroups: FacetGroup[] = Object.entries(this.selectedFacets).map(\n ([key, selectedFacets]) => {\n const option = key as FacetOption;\n const title = facetTitles[option];\n\n const buckets: FacetBucket[] = Object.entries(selectedFacets).map(\n ([value, facetState]) => {\n let displayText = value;\n // for selected languages, we store the language code instead of the\n // display name, so look up the name from the mapping\n if (option === 'language') {\n displayText =\n this.languageCodeHandler?.getLanguageNameFromCodeString(\n value\n ) ?? value;\n }\n return {\n displayText,\n key: value,\n count: 0,\n state: facetState,\n };\n }\n );\n\n return {\n title,\n key: option,\n buckets,\n };\n }\n );\n\n return facetGroups;\n }\n\n /**\n * Converts the raw `aggregations` to `FacetGroups`, which are easier to use\n */\n private get aggregationFacetGroups(): FacetGroup[] {\n const facetGroups: FacetGroup[] = [];\n Object.entries(this.aggregations ?? []).forEach(([key, buckets]) => {\n // the year_histogram data is in a different format so can't be handled here\n if (key === 'year_histogram') return;\n const option = this.getFacetOptionFromKey(key);\n const title = facetTitles[option];\n const castedBuckets = buckets.buckets as Bucket[];\n const facetBuckets: FacetBucket[] = castedBuckets.map(bucket => {\n let bucketKey = bucket.key;\n // for languages, we need to search by language code instead of the\n // display name, which is what we get from the search engine result\n if (option === 'language') {\n // const languageCodeKey = languageToCodeMap[bucket.key];\n bucketKey =\n this.languageCodeHandler?.getCodeStringFromLanguageName(\n `${bucket.key}`\n ) ?? bucket.key;\n // bucketKey = languageCodeKey ?? bucket.key;\n }\n return {\n displayText: `${bucket.key}`,\n key: `${bucketKey}`,\n count: bucket.doc_count,\n state: 'none',\n };\n });\n const group: FacetGroup = {\n title,\n key: option,\n buckets: facetBuckets,\n };\n facetGroups.push(group);\n });\n return facetGroups;\n }\n\n /**\n * Generate the template for a facet group with a header and the collapsible\n * chevron for the mobile view\n */\n private getFacetGroupTemplate(\n facetGroup: FacetGroup\n ): TemplateResult | typeof nothing {\n if (facetGroup.buckets.length === 0) return nothing;\n const { key } = facetGroup;\n const isOpen = this.openFacets[key];\n const collapser = html`\n <span class=\"collapser ${isOpen ? 'open' : ''}\"> ${chevronIcon} </span>\n `;\n\n return html`\n <div class=\"facet-group ${this.collapsableFacets ? 'mobile' : ''}\">\n <h1\n @click=${() => {\n const newOpenFacets = { ...this.openFacets };\n newOpenFacets[key] = !isOpen;\n this.openFacets = newOpenFacets;\n }}\n @keyup=${() => {\n const newOpenFacets = { ...this.openFacets };\n newOpenFacets[key] = !isOpen;\n this.openFacets = newOpenFacets;\n }}\n >\n ${this.collapsableFacets ? collapser : nothing} ${facetGroup.title}\n </h1>\n <div class=\"facet-group-content ${isOpen ? 'open' : ''}\">\n ${this.getFacetTemplate(facetGroup)}\n </div>\n </div>\n `;\n }\n\n /**\n * Generate the list template for each bucket in a facet group\n */\n private getFacetTemplate(facetGroup: FacetGroup): TemplateResult {\n const bucketsNoFavorites = facetGroup.buckets.filter(\n bucket => bucket.key.startsWith('fav-') === false\n );\n const bucketsMaxSix = bucketsNoFavorites.slice(0, 6);\n\n return html`\n <ul class=\"facet-list\">\n ${repeat(\n bucketsMaxSix,\n bucket => `${facetGroup.key}:${bucket.key}`,\n bucket => {\n const showOnlyCheckboxId = `${facetGroup.key}:${bucket.key}-show-only`;\n const negativeCheckboxId = `${facetGroup.key}:${bucket.key}-negative`;\n\n // for collections, we need to asynchronously load the collection name\n // so we use the `async-collection-name` widget and for the rest, we have\n // a static value to use\n const bucketTextDisplay =\n facetGroup.key !== 'collection'\n ? html`${bucket.displayText ?? bucket.key}`\n : html`\n <async-collection-name\n .collectionNameCache=${this.collectionNameCache}\n .identifier=${bucket.key}\n placeholder=\"-\"\n ></async-collection-name>\n `;\n\n const facetHidden = bucket.state === 'hidden';\n const facetSelected = bucket.state === 'selected';\n\n const titleText = `${facetGroup.key}: ${\n bucket.displayText ?? bucket.key\n }`;\n const onlyShowText = facetSelected\n ? `Show all ${facetGroup.key}s`\n : `Only show ${titleText}`;\n const hideText = `Hide ${titleText}`;\n const unhideText = `Unhide ${titleText}`;\n const showHideText = facetHidden ? unhideText : hideText;\n\n return html`\n <li>\n <div class=\"facet-row\">\n <div class=\"facet-checkbox\">\n <input\n type=\"checkbox\"\n .name=${facetGroup.key}\n .value=${bucket.key}\n @click=${(e: Event) => {\n this.facetClicked(e, bucket, false);\n }}\n .checked=${facetSelected}\n class=\"select-facet-checkbox\"\n title=${onlyShowText}\n id=${showOnlyCheckboxId}\n />\n <input\n type=\"checkbox\"\n id=${negativeCheckboxId}\n .name=${facetGroup.key}\n .value=${bucket.key}\n @click=${(e: Event) => {\n this.facetClicked(e, bucket, true);\n }}\n .checked=${facetHidden}\n class=\"hide-facet-checkbox\"\n />\n <label\n for=${negativeCheckboxId}\n class=\"hide-facet-icon${facetHidden ? ' active' : ''}\"\n title=${showHideText}\n >\n <span class=\"eye\">${eyeIcon}</span>\n <span class=\"eye-closed\">${eyeClosedIcon}</span>\n </label>\n </div>\n\n <label\n for=${showOnlyCheckboxId}\n class=\"facet-info-display\"\n title=${onlyShowText}\n >\n <div class=\"facet-title\">${bucketTextDisplay}</div>\n <div class=\"facet-count\">${bucket.count}</div>\n </label>\n </div>\n </li>\n `;\n }\n )}\n </ul>\n `;\n }\n\n private facetClicked(e: Event, bucket: FacetBucket, negative: boolean) {\n const target = e.target as HTMLInputElement;\n const { checked, name, value } = target;\n if (checked) {\n this.facetChecked(name as FacetOption, value, negative);\n } else {\n this.facetUnchecked(name as FacetOption, value);\n }\n }\n\n private facetChecked(key: FacetOption, value: string, negative: boolean) {\n const { selectedFacets } = this;\n let newFacets: SelectedFacets;\n if (selectedFacets) {\n newFacets = {\n ...selectedFacets,\n };\n } else {\n newFacets = defaultSelectedFacets;\n }\n newFacets[key][value] = negative ? 'hidden' : 'selected';\n this.selectedFacets = newFacets;\n }\n\n private facetUnchecked(key: FacetOption, value: string) {\n const { selectedFacets } = this;\n let newFacets: SelectedFacets;\n if (selectedFacets) {\n newFacets = {\n ...selectedFacets,\n };\n } else {\n newFacets = defaultSelectedFacets;\n }\n delete newFacets[key][value];\n this.selectedFacets = newFacets;\n }\n\n /**\n * Parse the aggregate key title into the human readable title\n *\n * Example: user_aggs__terms__field:mediatypeSorter__size:6 => Media Type\n *\n * @param key\n * @returns\n */\n private getFacetOptionFromKey(key: string): FacetOption {\n const parts = key.split('__');\n const fieldNamePart = parts[2];\n const fieldName = fieldNamePart.split(':')[1];\n const facetMatch = Object.entries(aggregationToFacetOption).find(([key2]) =>\n fieldName.includes(key2)\n );\n const option = facetMatch?.[1];\n if (!option) throw new Error(`Could not find facet option for key: ${key}`);\n return option;\n }\n\n static get styles() {\n return css`\n #container.loading {\n opacity: 0.5;\n }\n\n .collapser {\n display: inline-block;\n cursor: pointer;\n width: 10px;\n height: 10px;\n }\n\n .collapser svg {\n transition: transform 0.2s ease-in-out;\n }\n\n .collapser.open svg {\n transform: rotate(90deg);\n }\n\n .facet-group {\n margin-bottom: 2rem;\n }\n\n .facet-group h1 {\n margin-bottom: 0.7rem;\n }\n\n .facet-group.mobile h1 {\n cursor: pointer;\n }\n\n .facet-group-content {\n transition: max-height 0.2s ease-in-out;\n }\n\n .facet-group.mobile .facet-group-content {\n max-height: 0;\n overflow: hidden;\n }\n\n .facet-group.mobile .facet-group-content.open {\n max-height: 2000px;\n }\n\n h1 {\n font-size: 1.4rem;\n font-weight: 200;\n border-bottom: 1px solid rgb(232, 232, 232);\n padding-bottom: 3px;\n margin: 0;\n }\n\n ul.facet-list {\n list-style: none;\n margin: 0;\n padding: 0;\n }\n\n ul.facet-list li {\n margin-bottom: 0.2rem;\n }\n\n .facet-checkbox {\n margin-right: 0.5rem;\n display: flex;\n align-items: center;\n }\n\n .facet-row {\n display: flex;\n align-items: start;\n font-weight: 500;\n font-size: 1.2rem;\n }\n\n .facet-info-display {\n display: flex;\n flex: 1;\n cursor: pointer;\n }\n\n .facet-title {\n flex: 1;\n }\n\n .facet-count {\n margin-left: 0.5rem;\n }\n\n .select-facet-checkbox {\n cursor: pointer;\n margin-right: 5px;\n }\n\n .hide-facet-checkbox {\n display: none;\n }\n\n .hide-facet-icon {\n width: 15px;\n height: 15px;\n cursor: pointer;\n opacity: 0.3;\n }\n .hide-facet-icon:hover,\n .active {\n opacity: 1;\n }\n .hide-facet-icon:hover .eye,\n .hide-facet-icon .eye-closed {\n display: none;\n }\n .hide-facet-icon:hover .eye-closed,\n .hide-facet-icon.active .eye-closed {\n display: inline;\n }\n .hide-facet-icon.active .eye {\n display: none;\n }\n `;\n }\n}\n"]}
|
|
@@ -15,19 +15,6 @@ export const mockSuccessResponse = {
|
|
|
15
15
|
}),
|
|
16
16
|
],
|
|
17
17
|
start: 0,
|
|
18
|
-
aggregations: {
|
|
19
|
-
'user_aggs__terms__field:mediatypeSorter__size:100': {
|
|
20
|
-
buckets: [
|
|
21
|
-
{ key: 'audio', doc_count: 121 },
|
|
22
|
-
{ key: 'movies', doc_count: 2195 },
|
|
23
|
-
{ key: 'texts', doc_count: 1392 },
|
|
24
|
-
{ key: 'data', doc_count: 605 },
|
|
25
|
-
{ key: 'web', doc_count: 301 },
|
|
26
|
-
{ key: 'collection', doc_count: 167 },
|
|
27
|
-
{ key: 'account', doc_count: 167 },
|
|
28
|
-
],
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
18
|
},
|
|
32
19
|
responseHeader: {
|
|
33
20
|
status: 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock-search-responses.js","sourceRoot":"","sources":["../../../test/mocks/mock-search-responses.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,GAGT,MAAM,iCAAiC,CAAC;AAEzC,MAAM,CAAC,MAAM,mBAAmB,GAA+C;IAC7E,OAAO,EAAE;QACP,WAAW,EAAE,EAAE;QACf,QAAQ,EAAE;YACR,QAAQ,EAAE,CAAC;YACX,IAAI,EAAE;gBACJ,IAAI,QAAQ,CAAC;oBACX,UAAU,EAAE,KAAK;oBACjB,eAAe,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;iBAChC,CAAC;gBACF,IAAI,QAAQ,CAAC;oBACX,UAAU,EAAE,KAAK;oBACjB,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC;iBACjC,CAAC;aACH;YACD,KAAK,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"mock-search-responses.js","sourceRoot":"","sources":["../../../test/mocks/mock-search-responses.ts"],"names":[],"mappings":"AACA,OAAO,EACL,QAAQ,GAGT,MAAM,iCAAiC,CAAC;AAEzC,MAAM,CAAC,MAAM,mBAAmB,GAA+C;IAC7E,OAAO,EAAE;QACP,WAAW,EAAE,EAAE;QACf,QAAQ,EAAE;YACR,QAAQ,EAAE,CAAC;YACX,IAAI,EAAE;gBACJ,IAAI,QAAQ,CAAC;oBACX,UAAU,EAAE,KAAK;oBACjB,eAAe,EAAE,CAAC,KAAK,EAAE,KAAK,CAAC;iBAChC,CAAC;gBACF,IAAI,QAAQ,CAAC;oBACX,UAAU,EAAE,KAAK;oBACjB,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC;iBACjC,CAAC;aACH;YACD,KAAK,EAAE,CAAC;SACT;QACD,cAAc,EAAE;YACd,MAAM,EAAE,CAAC;YACT,KAAK,EAAE,CAAC;YACR,MAAM,EAAE;gBACN,KAAK,EAAE,gBAAgB;gBACvB,GAAG,EAAE,gBAAgB;gBACrB,MAAM,EAAE,6BAA6B;gBACrC,EAAE,EAAE,KAAK;gBACT,KAAK,EAAE,CAAC;aACT;SACF;KACF;CACF,CAAC","sourcesContent":["import type { Result } from '@internetarchive/result-type';\nimport {\n Metadata,\n SearchResponse,\n SearchServiceError,\n} from '@internetarchive/search-service';\n\nexport const mockSuccessResponse: Result<SearchResponse, SearchServiceError> = {\n success: {\n rawResponse: {},\n response: {\n numFound: 2,\n docs: [\n new Metadata({\n identifier: 'foo',\n collections_raw: ['foo', 'bar'],\n }),\n new Metadata({\n identifier: 'bar',\n collections_raw: ['baz', 'boop'],\n }),\n ],\n start: 0,\n },\n responseHeader: {\n status: 0,\n QTime: 0,\n params: {\n query: 'collection:foo',\n qin: 'collection:foo',\n fields: 'identifier, collections_raw',\n wt: 'foo',\n start: 0,\n },\n },\n },\n};\n"]}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "The Internet Archive Collection Browser.",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"author": "Internet Archive",
|
|
6
|
-
"version": "0.2.
|
|
6
|
+
"version": "0.2.18",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"module": "dist/index.js",
|
|
9
9
|
"scripts": {
|
|
@@ -26,10 +26,8 @@
|
|
|
26
26
|
"@internetarchive/feature-feedback": "^0.1.4",
|
|
27
27
|
"@internetarchive/field-parsers": "^0.1.3",
|
|
28
28
|
"@internetarchive/histogram-date-range": "^0.1.7",
|
|
29
|
-
"@internetarchive/ia-activity-indicator": "^0.0.3",
|
|
30
29
|
"@internetarchive/infinite-scroller": "^0.1.3",
|
|
31
30
|
"@internetarchive/local-cache": "^0.2.1",
|
|
32
|
-
"@internetarchive/modal-manager": "^0.2.6",
|
|
33
31
|
"@internetarchive/search-service": "^0.3.4",
|
|
34
32
|
"@internetarchive/shared-resize-observer": "^0.2.0",
|
|
35
33
|
"@lit/localize": "^0.11.2",
|
package/src/app-root.ts
CHANGED
|
@@ -4,7 +4,6 @@ import { html, css, LitElement, PropertyValues } from 'lit';
|
|
|
4
4
|
import { customElement, query, state } from 'lit/decorators.js';
|
|
5
5
|
import { SharedResizeObserver } from '@internetarchive/shared-resize-observer';
|
|
6
6
|
import { CollectionNameCache } from '@internetarchive/collection-name-cache';
|
|
7
|
-
import type { ModalManagerInterface } from '@internetarchive/modal-manager';
|
|
8
7
|
import type { CollectionBrowser } from '../src/collection-browser';
|
|
9
8
|
import '../src/collection-browser';
|
|
10
9
|
|
|
@@ -41,8 +40,6 @@ export class AppRoot extends LitElement {
|
|
|
41
40
|
|
|
42
41
|
@query('collection-browser') private collectionBrowser!: CollectionBrowser;
|
|
43
42
|
|
|
44
|
-
@query('modal-manager') private modalManager!: ModalManagerInterface;
|
|
45
|
-
|
|
46
43
|
private searchPressed(e: Event) {
|
|
47
44
|
e.preventDefault();
|
|
48
45
|
this.searchQuery = this.baseQueryField.value;
|
|
@@ -174,13 +171,11 @@ export class AppRoot extends LitElement {
|
|
|
174
171
|
.collectionNameCache=${this.collectionNameCache}
|
|
175
172
|
.showHistogramDatePicker=${true}
|
|
176
173
|
.loggedIn=${this.loggedIn}
|
|
177
|
-
.modalManager=${this.modalManager}
|
|
178
174
|
@visiblePageChanged=${this.visiblePageChanged}
|
|
179
175
|
@baseQueryChanged=${this.baseQueryChanged}
|
|
180
176
|
>
|
|
181
177
|
</collection-browser>
|
|
182
178
|
</div>
|
|
183
|
-
<modal-manager></modal-manager>
|
|
184
179
|
`;
|
|
185
180
|
}
|
|
186
181
|
|
|
@@ -260,28 +255,6 @@ export class AppRoot extends LitElement {
|
|
|
260
255
|
static styles = css`
|
|
261
256
|
:host {
|
|
262
257
|
display: block;
|
|
263
|
-
--primaryButtonBGColor: #194880;
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
/* add the following styles to ensure proper modal visibility */
|
|
267
|
-
body.modal-manager-open {
|
|
268
|
-
overflow: hidden;
|
|
269
|
-
}
|
|
270
|
-
modal-manager {
|
|
271
|
-
display: none;
|
|
272
|
-
}
|
|
273
|
-
modal-manager[mode='open'] {
|
|
274
|
-
display: block;
|
|
275
|
-
}
|
|
276
|
-
modal-manager.more-search-facets {
|
|
277
|
-
--modalWidth: 85rem;
|
|
278
|
-
--modalBorder: 2px solid var(--primaryButtonBGColor, #194880);
|
|
279
|
-
--modalTitleLineHeight: 4rem;
|
|
280
|
-
--modalTitleFontSize: 1.8rem;
|
|
281
|
-
--modalCornerRadius: 0;
|
|
282
|
-
--modalBottomPadding: 0;
|
|
283
|
-
--modalScrollOffset: 0;
|
|
284
|
-
--modalCornerRadius: 0.5rem;
|
|
285
258
|
}
|
|
286
259
|
|
|
287
260
|
input,
|
|
@@ -290,7 +263,7 @@ export class AppRoot extends LitElement {
|
|
|
290
263
|
}
|
|
291
264
|
|
|
292
265
|
collection-browser {
|
|
293
|
-
margin-top:
|
|
266
|
+
margin-top: 30rem;
|
|
294
267
|
}
|
|
295
268
|
|
|
296
269
|
#base-query-field {
|
|
@@ -301,7 +274,7 @@ export class AppRoot extends LitElement {
|
|
|
301
274
|
position: fixed;
|
|
302
275
|
top: 0;
|
|
303
276
|
left: 0;
|
|
304
|
-
z-index:
|
|
277
|
+
z-index: 10;
|
|
305
278
|
-webkit-backdrop-filter: blur(10px);
|
|
306
279
|
backdrop-filter: blur(10px);
|
|
307
280
|
padding: 0.5rem 1rem;
|
|
@@ -27,7 +27,6 @@ import type {
|
|
|
27
27
|
} from '@internetarchive/shared-resize-observer';
|
|
28
28
|
import '@internetarchive/infinite-scroller';
|
|
29
29
|
import type { CollectionNameCacheInterface } from '@internetarchive/collection-name-cache';
|
|
30
|
-
import type { ModalManagerInterface } from '@internetarchive/modal-manager';
|
|
31
30
|
import './tiles/tile-dispatcher';
|
|
32
31
|
import './tiles/collection-browser-loading-tile';
|
|
33
32
|
import './sort-filter-bar/sort-filter-bar';
|
|
@@ -116,8 +115,6 @@ export class CollectionBrowser
|
|
|
116
115
|
|
|
117
116
|
@property({ type: Boolean }) loggedIn = false;
|
|
118
117
|
|
|
119
|
-
@property({ type: Object }) modalManager?: ModalManagerInterface = undefined;
|
|
120
|
-
|
|
121
118
|
/**
|
|
122
119
|
* If item management UI active
|
|
123
120
|
*/
|
|
@@ -254,7 +251,10 @@ export class CollectionBrowser
|
|
|
254
251
|
render() {
|
|
255
252
|
this.setPlaceholderType();
|
|
256
253
|
return html`
|
|
257
|
-
<div
|
|
254
|
+
<div
|
|
255
|
+
id="content-container"
|
|
256
|
+
class=${this.mobileView ? 'mobile' : 'desktop'}
|
|
257
|
+
>
|
|
258
258
|
${this.placeholderType
|
|
259
259
|
? this.emptyPlaceholderTemplate
|
|
260
260
|
: this.collectionBrowserTemplate}
|
|
@@ -428,7 +428,6 @@ export class CollectionBrowser
|
|
|
428
428
|
<collection-facets
|
|
429
429
|
@facetsChanged=${this.facetsChanged}
|
|
430
430
|
@histogramDateRangeUpdated=${this.histogramDateRangeUpdated}
|
|
431
|
-
.searchService=${this.searchService}
|
|
432
431
|
.aggregations=${this.aggregations}
|
|
433
432
|
.fullYearsHistogramAggregation=${this.fullYearsHistogramAggregation}
|
|
434
433
|
.minSelectedDate=${this.minSelectedDate}
|
|
@@ -437,8 +436,6 @@ export class CollectionBrowser
|
|
|
437
436
|
.collectionNameCache=${this.collectionNameCache}
|
|
438
437
|
.languageCodeHandler=${this.languageCodeHandler}
|
|
439
438
|
.showHistogramDatePicker=${this.showHistogramDatePicker}
|
|
440
|
-
.fullQuery=${this.fullQuery}
|
|
441
|
-
.modalManager=${this.modalManager}
|
|
442
439
|
?collapsableFacets=${this.mobileView}
|
|
443
440
|
?facetsLoading=${this.facetDataLoading}
|
|
444
441
|
?fullYearAggregationLoading=${this.fullYearAggregationLoading}
|
|
@@ -1217,11 +1214,24 @@ export class CollectionBrowser
|
|
|
1217
1214
|
padding-right: 1rem;
|
|
1218
1215
|
}
|
|
1219
1216
|
|
|
1217
|
+
.desktop #left-column::-webkit-scrollbar {
|
|
1218
|
+
display: none;
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1220
1221
|
.mobile #left-column {
|
|
1221
1222
|
width: 100%;
|
|
1222
1223
|
padding: 0;
|
|
1223
1224
|
}
|
|
1224
1225
|
|
|
1226
|
+
.desktop #left-column {
|
|
1227
|
+
top: 0;
|
|
1228
|
+
position: sticky;
|
|
1229
|
+
max-height: 100vh;
|
|
1230
|
+
overflow: scroll;
|
|
1231
|
+
-ms-overflow-style: none; /* hide scrollbar IE and Edge */
|
|
1232
|
+
scrollbar-width: none; /* hide scrollbar Firefox */
|
|
1233
|
+
}
|
|
1234
|
+
|
|
1225
1235
|
#mobile-header-container {
|
|
1226
1236
|
display: flex;
|
|
1227
1237
|
justify-content: space-between;
|
|
@@ -1232,10 +1242,12 @@ export class CollectionBrowser
|
|
|
1232
1242
|
max-height: 0;
|
|
1233
1243
|
transition: max-height 0.2s ease-in-out;
|
|
1234
1244
|
z-index: 1;
|
|
1245
|
+
padding-bottom: 2rem;
|
|
1235
1246
|
}
|
|
1236
1247
|
|
|
1237
1248
|
.mobile #facets-container {
|
|
1238
1249
|
overflow: hidden;
|
|
1250
|
+
padding-bottom: 0;
|
|
1239
1251
|
}
|
|
1240
1252
|
|
|
1241
1253
|
#facets-container.expanded {
|