@internetarchive/collection-browser 2.22.1-webdev-7936.0 → 3.0.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.
Files changed (83) hide show
  1. package/.editorconfig +29 -29
  2. package/.github/workflows/ci.yml +27 -27
  3. package/.github/workflows/gh-pages-main.yml +39 -39
  4. package/.github/workflows/npm-publish.yml +39 -39
  5. package/.github/workflows/pr-preview.yml +38 -38
  6. package/.husky/pre-commit +4 -4
  7. package/.prettierignore +1 -1
  8. package/LICENSE +661 -661
  9. package/README.md +83 -83
  10. package/dist/src/collection-browser.d.ts +5 -2
  11. package/dist/src/collection-browser.js +699 -690
  12. package/dist/src/collection-browser.js.map +1 -1
  13. package/dist/src/collection-facets/facet-row.js +130 -130
  14. package/dist/src/collection-facets/facet-row.js.map +1 -1
  15. package/dist/src/collection-facets/smart-facets/smart-facet-bar.js +75 -75
  16. package/dist/src/collection-facets/smart-facets/smart-facet-bar.js.map +1 -1
  17. package/dist/src/collection-facets.js +263 -264
  18. package/dist/src/collection-facets.js.map +1 -1
  19. package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
  20. package/dist/src/data-source/collection-browser-query-state.js.map +1 -1
  21. package/dist/src/data-source/models.js.map +1 -1
  22. package/dist/src/models.js.map +1 -1
  23. package/dist/src/restoration-state-handler.js.map +1 -1
  24. package/dist/src/tiles/base-tile-component.js.map +1 -1
  25. package/dist/src/tiles/grid/collection-tile.js +2 -3
  26. package/dist/src/tiles/grid/collection-tile.js.map +1 -1
  27. package/dist/src/tiles/grid/item-tile.js +139 -139
  28. package/dist/src/tiles/grid/item-tile.js.map +1 -1
  29. package/dist/src/tiles/grid/search-tile.js +2 -3
  30. package/dist/src/tiles/grid/search-tile.js.map +1 -1
  31. package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js +1 -2
  32. package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js.map +1 -1
  33. package/dist/src/tiles/hover/hover-pane-controller.js +21 -21
  34. package/dist/src/tiles/hover/hover-pane-controller.js.map +1 -1
  35. package/dist/src/tiles/hover/tile-hover-pane.js +108 -108
  36. package/dist/src/tiles/hover/tile-hover-pane.js.map +1 -1
  37. package/dist/src/tiles/list/tile-list-compact-header.js +45 -45
  38. package/dist/src/tiles/list/tile-list-compact-header.js.map +1 -1
  39. package/dist/src/tiles/list/tile-list-compact.js +97 -97
  40. package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
  41. package/dist/src/tiles/list/tile-list.js +289 -295
  42. package/dist/src/tiles/list/tile-list.js.map +1 -1
  43. package/dist/src/tiles/tile-dispatcher.js +200 -200
  44. package/dist/src/tiles/tile-dispatcher.js.map +1 -1
  45. package/dist/src/tiles/tile-display-value-provider.js.map +1 -1
  46. package/dist/test/collection-browser.test.js +183 -197
  47. package/dist/test/collection-browser.test.js.map +1 -1
  48. package/dist/test/restoration-state-handler.test.js.map +1 -1
  49. package/dist/test/tiles/list/tile-list.test.js +0 -1
  50. package/dist/test/tiles/list/tile-list.test.js.map +1 -1
  51. package/eslint.config.mjs +53 -53
  52. package/index.html +24 -24
  53. package/local.archive.org.cert +86 -86
  54. package/local.archive.org.key +27 -27
  55. package/package.json +117 -117
  56. package/renovate.json +6 -6
  57. package/src/collection-browser.ts +2775 -2756
  58. package/src/collection-facets/facet-row.ts +282 -282
  59. package/src/collection-facets/smart-facets/smart-facet-bar.ts +437 -437
  60. package/src/collection-facets.ts +990 -991
  61. package/src/data-source/collection-browser-data-source.ts +1390 -1390
  62. package/src/data-source/collection-browser-query-state.ts +63 -63
  63. package/src/data-source/models.ts +43 -43
  64. package/src/models.ts +870 -870
  65. package/src/restoration-state-handler.ts +544 -544
  66. package/src/tiles/base-tile-component.ts +53 -53
  67. package/src/tiles/grid/collection-tile.ts +2 -3
  68. package/src/tiles/grid/item-tile.ts +339 -339
  69. package/src/tiles/grid/search-tile.ts +2 -3
  70. package/src/tiles/grid/styles/tile-grid-shared-styles.ts +1 -2
  71. package/src/tiles/hover/hover-pane-controller.ts +517 -517
  72. package/src/tiles/hover/tile-hover-pane.ts +180 -180
  73. package/src/tiles/list/tile-list-compact-header.ts +86 -86
  74. package/src/tiles/list/tile-list-compact.ts +236 -236
  75. package/src/tiles/list/tile-list.ts +688 -692
  76. package/src/tiles/tile-dispatcher.ts +486 -486
  77. package/src/tiles/tile-display-value-provider.ts +124 -124
  78. package/test/collection-browser.test.ts +2340 -2359
  79. package/test/restoration-state-handler.test.ts +510 -510
  80. package/test/tiles/list/tile-list.test.ts +0 -1
  81. package/tsconfig.json +20 -20
  82. package/web-dev-server.config.mjs +30 -30
  83. package/web-test-runner.config.mjs +41 -41
@@ -1,991 +1,990 @@
1
- import {
2
- css,
3
- html,
4
- LitElement,
5
- PropertyValues,
6
- nothing,
7
- TemplateResult,
8
- } from 'lit';
9
- import { customElement, property, state } from 'lit/decorators.js';
10
- import { map } from 'lit/directives/map.js';
11
- import { ref } from 'lit/directives/ref.js';
12
- import { msg } from '@lit/localize';
13
- import { classMap } from 'lit/directives/class-map.js';
14
- import {
15
- Aggregation,
16
- AggregationSortType,
17
- Bucket,
18
- FilterMap,
19
- SearchServiceInterface,
20
- SearchType,
21
- } from '@internetarchive/search-service';
22
- import '@internetarchive/histogram-date-range';
23
- import '@internetarchive/feature-feedback';
24
- import {
25
- ModalConfig,
26
- ModalManagerInterface,
27
- } from '@internetarchive/modal-manager';
28
- import type { FeatureFeedbackServiceInterface } from '@internetarchive/feature-feedback';
29
- import type { RecaptchaManagerInterface } from '@internetarchive/recaptcha-manager';
30
- import type { AnalyticsManagerInterface } from '@internetarchive/analytics-manager';
31
- import type { SharedResizeObserverInterface } from '@internetarchive/shared-resize-observer';
32
- import type {
33
- BarScalingOption,
34
- BinSnappingInterval,
35
- } from '@internetarchive/histogram-date-range';
36
- import chevronIcon from './assets/img/icons/chevron';
37
- import expandIcon from './assets/img/icons/expand';
38
- import {
39
- FacetOption,
40
- SelectedFacets,
41
- FacetGroup,
42
- FacetBucket,
43
- defaultFacetDisplayOrder,
44
- facetTitles,
45
- lendingFacetDisplayNames,
46
- lendingFacetKeysVisibility,
47
- LendingFacetKey,
48
- suppressedCollections,
49
- defaultFacetSort,
50
- FacetEventDetails,
51
- } from './models';
52
- import type {
53
- CollectionTitles,
54
- PageSpecifierParams,
55
- TVChannelAliases,
56
- } from './data-source/models';
57
- import {
58
- analyticsActions,
59
- analyticsCategories,
60
- } from './utils/analytics-events';
61
- import { srOnlyStyle } from './styles/sr-only';
62
- import { ExpandedDatePicker } from './expanded-date-picker';
63
- import {
64
- sortBucketsBySelectionState,
65
- updateSelectedFacetBucket,
66
- } from './utils/facet-utils';
67
-
68
- import '@internetarchive/histogram-date-range';
69
- import './collection-facets/more-facets-content';
70
- import './collection-facets/facets-template';
71
- import './collection-facets/facet-tombstone-row';
72
- import './expanded-date-picker';
73
-
74
- @customElement('collection-facets')
75
- export class CollectionFacets extends LitElement {
76
- @property({ type: Object }) searchService?: SearchServiceInterface;
77
-
78
- @property({ type: Number }) searchType?: SearchType;
79
-
80
- @property({ type: Object }) aggregations?: Record<string, Aggregation>;
81
-
82
- @property({ type: Object }) histogramAggregation?: Aggregation;
83
-
84
- @property({ type: String }) minSelectedDate?: string;
85
-
86
- @property({ type: String }) maxSelectedDate?: string;
87
-
88
- @property({ type: Boolean }) moreLinksVisible = true;
89
-
90
- @property({ type: Boolean }) facetsLoading = false;
91
-
92
- @property({ type: Boolean }) histogramAggregationLoading = false;
93
-
94
- @property({ type: Object }) selectedFacets?: SelectedFacets;
95
-
96
- @property({ type: Boolean }) collapsableFacets = false;
97
-
98
- @property({ type: Number }) contentWidth?: number;
99
-
100
- @property({ type: Boolean }) showHistogramDatePicker = false;
101
-
102
- @property({ type: Boolean }) allowExpandingDatePicker = false;
103
-
104
- @property({ type: Boolean }) suppressMediatypeFacets = false;
105
-
106
- @property({ type: String }) query?: string;
107
-
108
- @property({ type: Object }) pageSpecifierParams?: PageSpecifierParams;
109
-
110
- @property({ type: Array }) parentCollections: string[] = [];
111
-
112
- @property({ type: Object }) filterMap?: FilterMap;
113
-
114
- @property({ type: String }) baseNavigationUrl?: string;
115
-
116
- @property({ type: String }) collectionPagePath: string = '/details/';
117
-
118
- @property({ type: Boolean }) isManageView = false;
119
-
120
- @property({ type: Boolean }) isTvSearch = false;
121
-
122
- @property({ type: Array }) facetDisplayOrder: FacetOption[] =
123
- defaultFacetDisplayOrder;
124
-
125
- @property({ type: Object, attribute: false })
126
- modalManager?: ModalManagerInterface;
127
-
128
- @property({ type: Object, attribute: false })
129
- resizeObserver?: SharedResizeObserverInterface;
130
-
131
- @property({ type: Object, attribute: false })
132
- featureFeedbackService?: FeatureFeedbackServiceInterface;
133
-
134
- @property({ type: Object, attribute: false })
135
- recaptchaManager?: RecaptchaManagerInterface;
136
-
137
- @property({ type: Object, attribute: false })
138
- analyticsHandler?: AnalyticsManagerInterface;
139
-
140
- @property({ type: Object, attribute: false })
141
- collectionTitles?: CollectionTitles;
142
-
143
- @property({ type: Object, attribute: false })
144
- tvChannelAliases?: TVChannelAliases;
145
-
146
- @state() openFacets: Record<FacetOption, boolean> = {
147
- subject: false,
148
- lending: false,
149
- mediatype: false,
150
- language: false,
151
- creator: false,
152
- collection: false,
153
- year: false,
154
- program: false,
155
- person: false,
156
- sponsor: false,
157
- };
158
-
159
- /**
160
- * Maximum # of facet buckets to render per facet group
161
- */
162
- private allowedFacetCount = 6;
163
-
164
- render() {
165
- const containerClasses = classMap({
166
- loading: this.facetsLoading,
167
- managing: this.isManageView,
168
- });
169
-
170
- // Added data-testid for Playwright testing
171
- // Using facet-group class and aria-labels is not ideal for Playwright locator
172
- const datePickerLabelId = 'date-picker-label';
173
- return html`
174
- <div id="container" class=${containerClasses}>
175
- ${this.showHistogramDatePicker &&
176
- (this.histogramAggregation || this.histogramAggregationLoading)
177
- ? html`
178
- <section
179
- class="facet-group"
180
- aria-labelledby=${datePickerLabelId}
181
- data-testid="facet-group-header-label-date-picker"
182
- >
183
- <h3 id=${datePickerLabelId}>
184
- Year Published <span class="sr-only">range filter</span>
185
- ${this.expandDatePickerBtnTemplate}
186
- </h3>
187
- ${this.histogramTemplate}
188
- </section>
189
- `
190
- : nothing}
191
- ${this.collectionPartOfTemplate}
192
- ${this.mergedFacets.map(facetGroup =>
193
- this.getFacetGroupTemplate(facetGroup),
194
- )}
195
- </div>
196
- `;
197
- }
198
-
199
- private get collectionPartOfTemplate(): TemplateResult | typeof nothing {
200
- // We only display the "Part Of" section on collection pages
201
- if (!this.parentCollections?.length) return nothing;
202
-
203
- // Added data-testid for Playwright testing
204
- // Using className and aria-labels is not ideal for Playwright locator
205
- const headingId = 'partof-heading';
206
- return html`
207
- <section
208
- class="facet-group partof-collections"
209
- aria-labelledby=${headingId}
210
- data-testid="facet-group-partof-collections"
211
- >
212
- <div class="facet-group-header">
213
- <h3 id=${headingId}>${msg('Part Of')}</h3>
214
- </div>
215
- <ul>
216
- ${map(this.parentCollections, collxn => {
217
- const collectionURL = `${this.baseNavigationUrl}${this.collectionPagePath}${collxn}`;
218
-
219
- return html` <li>
220
- <a
221
- href=${collectionURL}
222
- data-id=${collxn}
223
- @click=${this.partOfCollectionClicked}
224
- >
225
- ${this.collectionTitles?.get(collxn) ?? collxn}
226
- </a>
227
- </li>`;
228
- })}
229
- </ul>
230
- </section>
231
- `;
232
- }
233
-
234
- private partOfCollectionClicked(e: Event): void {
235
- this.analyticsHandler?.sendEvent({
236
- category: analyticsCategories.default,
237
- action: analyticsActions.partOfCollectionClicked,
238
- label: (e.target as HTMLElement).dataset.id,
239
- });
240
- }
241
-
242
- /**
243
- * Properties to pass into the date-picker histogram component
244
- */
245
- private get histogramProps() {
246
- const { histogramAggregation: aggregation } = this;
247
- if (!aggregation) return undefined;
248
-
249
- // Normalize some properties from the raw aggregation
250
- const firstYear =
251
- aggregation.first_bucket_year ?? aggregation.first_bucket_key;
252
- const lastYear =
253
- aggregation.last_bucket_year ?? aggregation.last_bucket_key;
254
- if (firstYear == null || lastYear == null) return undefined; // We at least need a start/end year defined
255
-
256
- const firstMonth = aggregation.first_bucket_month ?? 1;
257
- const lastMonth = aggregation.last_bucket_month ?? 12;
258
-
259
- const yearInterval = aggregation.interval ?? 1;
260
- const monthInterval = aggregation.interval_in_months ?? 12;
261
-
262
- const zeroPadMonth = (month: number) => month.toString().padStart(2, '0');
263
-
264
- // The date picker is configured differently for TV search, allowing month-level resolution
265
- if (this.isTvSearch) {
266
- // Whether the bucket interval is less than a year
267
- // (i.e., requires individual months to be handled & labeled)
268
- const mustHandleMonths = monthInterval < 12;
269
-
270
- return {
271
- buckets: aggregation.buckets as number[],
272
- dateFormat: 'YYYY-MM',
273
- tooltipDateFormat: mustHandleMonths ? 'MMM YYYY' : 'YYYY',
274
- tooltipLabel: 'broadcast',
275
- binSnapping: (mustHandleMonths
276
- ? 'month'
277
- : 'year') as BinSnappingInterval,
278
- barScaling: 'linear' as BarScalingOption,
279
- minDate: `${firstYear}-${zeroPadMonth(firstMonth)}`,
280
- maxDate: `${lastYear}-${zeroPadMonth(lastMonth + monthInterval - 1)}`,
281
- };
282
- }
283
-
284
- // All other search types use the same configuration
285
- return {
286
- buckets: aggregation.buckets as number[],
287
- dateFormat: 'YYYY',
288
- tooltipDateFormat: 'YYYY',
289
- tooltipLabel: 'item',
290
- binSnapping: 'year' as BinSnappingInterval,
291
- barScaling: 'logarithmic' as BarScalingOption,
292
- minDate: `${firstYear}`,
293
- maxDate: `${lastYear + yearInterval - 1}`,
294
- };
295
- }
296
-
297
- /**
298
- * Opens a modal dialog containing an enlarged version of the date picker.
299
- */
300
- private showDatePickerModal(): void {
301
- const { histogramProps } = this;
302
- if (!histogramProps) return;
303
-
304
- const {
305
- buckets,
306
- dateFormat,
307
- tooltipDateFormat,
308
- tooltipLabel,
309
- binSnapping,
310
- barScaling,
311
- minDate,
312
- maxDate,
313
- } = histogramProps;
314
-
315
- // Because the modal manager does not clear its DOM content after being closed,
316
- // it may try to render the exact same date picker template when it is reopened.
317
- // And because it isn't actually a descendent of this collection-facets component,
318
- // changes to the template defined here may not trigger a reactive update to the date
319
- // picker, resulting in it displaying a stale date range.
320
- // This ref callback ensures that every time the date picker modal is opened, it will
321
- // always propagate the most recent date range into the date picker regardless of
322
- // whether Lit thinks the update is necessary.
323
- const expandedDatePickerChanged = (elmt?: Element) => {
324
- if (elmt && elmt instanceof ExpandedDatePicker) {
325
- const expandedDatePicker = elmt as ExpandedDatePicker;
326
- expandedDatePicker.minSelectedDate = this.minSelectedDate;
327
- expandedDatePicker.maxSelectedDate = this.maxSelectedDate;
328
- }
329
- };
330
-
331
- const customModalContent = html`
332
- <expanded-date-picker
333
- ${ref(expandedDatePickerChanged)}
334
- .minDate=${minDate}
335
- .maxDate=${maxDate}
336
- .minSelectedDate=${this.minSelectedDate}
337
- .maxSelectedDate=${this.maxSelectedDate}
338
- .customDateFormat=${dateFormat}
339
- .customTooltipDateFormat=${tooltipDateFormat}
340
- .customTooltipLabel=${tooltipLabel}
341
- .binSnapping=${binSnapping}
342
- .barScaling=${barScaling}
343
- .buckets=${buckets}
344
- .modalManager=${this.modalManager}
345
- .analyticsHandler=${this.analyticsHandler}
346
- @histogramDateRangeApplied=${this.histogramDateRangeUpdated}
347
- @modalClosed=${this.handleExpandedDatePickerClosed}
348
- ></expanded-date-picker>
349
- `;
350
-
351
- const config = new ModalConfig({
352
- bodyColor: '#fff',
353
- headerColor: '#194880',
354
- showHeaderLogo: false,
355
- closeOnBackdropClick: true, // TODO: want to fire analytics
356
- title: html`${msg('Select a date range')}`,
357
- });
358
-
359
- this.modalManager?.classList.add('expanded-date-picker');
360
- this.modalManager?.showModal({
361
- config,
362
- customModalContent,
363
- userClosedModalCallback: this.handleExpandedDatePickerClosed,
364
- });
365
-
366
- this.analyticsHandler?.sendEvent({
367
- category: analyticsCategories.default,
368
- action: analyticsActions.histogramExpanded,
369
- label: window.location.href,
370
- });
371
- }
372
-
373
- private handleExpandedDatePickerClosed = (): void => {
374
- this.modalManager?.classList.remove('expanded-date-picker');
375
- };
376
-
377
- updated(changed: PropertyValues) {
378
- if (changed.has('selectedFacets')) {
379
- this.dispatchFacetsChangedEvent();
380
- }
381
- }
382
-
383
- // TODO: want to fire analytics?
384
- private dispatchFacetsChangedEvent() {
385
- const event = new CustomEvent<SelectedFacets>('facetsChanged', {
386
- detail: this.selectedFacets,
387
- });
388
- this.dispatchEvent(event);
389
- }
390
-
391
- /**
392
- * Template for the "Expand" button to show the date picker modal, or
393
- * `nothing` if that button should currently not be shown.
394
- */
395
- private get expandDatePickerBtnTemplate(): TemplateResult | typeof nothing {
396
- return this.allowExpandingDatePicker && !this.facetsLoading
397
- ? html`<button
398
- class="expand-date-picker-btn"
399
- aria-hidden="true"
400
- tabindex="-1"
401
- @click=${this.showDatePickerModal}
402
- >
403
- ${expandIcon}
404
- </button>`
405
- : nothing;
406
- }
407
-
408
- private get histogramTemplate(): TemplateResult | typeof nothing {
409
- if (this.histogramAggregationLoading) {
410
- return html` <div class="histogram-loading-indicator">&hellip;</div> `;
411
- }
412
-
413
- const { histogramProps } = this;
414
- if (!histogramProps) return nothing;
415
-
416
- const {
417
- buckets,
418
- dateFormat,
419
- tooltipDateFormat,
420
- tooltipLabel,
421
- binSnapping,
422
- barScaling,
423
- minDate,
424
- maxDate,
425
- } = histogramProps;
426
-
427
- return html`
428
- <histogram-date-range
429
- class=${this.isTvSearch ? 'wide-inputs' : nothing}
430
- .minDate=${minDate}
431
- .maxDate=${maxDate}
432
- .minSelectedDate=${this.minSelectedDate ?? minDate}
433
- .maxSelectedDate=${this.maxSelectedDate ?? maxDate}
434
- .updateDelay=${100}
435
- .dateFormat=${dateFormat}
436
- .tooltipDateFormat=${tooltipDateFormat}
437
- .tooltipLabel=${tooltipLabel}
438
- .binSnapping=${binSnapping}
439
- .barScaling=${barScaling}
440
- .bins=${buckets}
441
- missingDataMessage="..."
442
- .width=${this.collapsableFacets && this.contentWidth
443
- ? this.contentWidth
444
- : 180}
445
- @histogramDateRangeUpdated=${this.histogramDateRangeUpdated}
446
- ></histogram-date-range>
447
- `;
448
- }
449
-
450
- /**
451
- * Dispatches a `histogramDateRangeUpdated` event with the date range copied from the
452
- * input event.
453
- *
454
- * Arrow function to ensure `this` is always bound to the current component.
455
- */
456
- private histogramDateRangeUpdated = (
457
- e: CustomEvent<{
458
- minDate: string;
459
- maxDate: string;
460
- }>,
461
- ): void => {
462
- const { minDate, maxDate } = e.detail;
463
- const event = new CustomEvent('histogramDateRangeUpdated', {
464
- detail: { minDate, maxDate },
465
- });
466
- this.dispatchEvent(event);
467
- };
468
-
469
- /**
470
- * Combines the selected facets with the aggregations to create a single list of facets
471
- */
472
- private get mergedFacets(): FacetGroup[] {
473
- const facetGroups: FacetGroup[] = [];
474
-
475
- this.facetDisplayOrder.forEach(facetKey => {
476
- if (facetKey === 'mediatype' && this.suppressMediatypeFacets) return;
477
-
478
- const selectedFacetGroup = this.selectedFacetGroups.find(
479
- group => group.key === facetKey,
480
- );
481
- const aggregateFacetGroup = this.aggregationFacetGroups.find(
482
- group => group.key === facetKey,
483
- );
484
-
485
- // if the user selected a facet, but it's not in the aggregation, we add it as-is
486
- if (selectedFacetGroup && !aggregateFacetGroup) {
487
- facetGroups.push(selectedFacetGroup);
488
- return;
489
- }
490
-
491
- // if we don't have an aggregate facet group, don't add this to the list
492
- if (!aggregateFacetGroup) return;
493
-
494
- // start with either the selected group if we have one, or the aggregate group
495
- const facetGroup = selectedFacetGroup ?? aggregateFacetGroup;
496
-
497
- // attach the counts to the selected buckets
498
- let bucketsWithCount =
499
- selectedFacetGroup?.buckets.map(bucket => {
500
- const selectedBucket = aggregateFacetGroup.buckets.find(
501
- b => b.key === bucket.key,
502
- );
503
- return selectedBucket
504
- ? {
505
- ...bucket,
506
- count: selectedBucket.count,
507
- }
508
- : bucket;
509
- }) ?? [];
510
-
511
- // append any additional buckets that were not selected
512
- aggregateFacetGroup.buckets.forEach(bucket => {
513
- const existingBucket = bucketsWithCount.find(b => b.key === bucket.key);
514
- if (existingBucket) return;
515
- bucketsWithCount.push(bucket);
516
- });
517
-
518
- /**
519
- * render limited facet items on page facet area
520
- *
521
- * - by-default we are showing 6 items
522
- * - additionally want to show all items (selected/suppressed) in page facet area
523
- */
524
- let allowedFacetCount = Object.keys(
525
- (selectedFacetGroup?.buckets as []) || [],
526
- )?.length;
527
- if (allowedFacetCount < this.allowedFacetCount) {
528
- allowedFacetCount = this.allowedFacetCount; // splice start index from 0th
529
- }
530
-
531
- // For lending facets, only include a specific subset of buckets
532
- if (facetKey === 'lending') {
533
- bucketsWithCount = bucketsWithCount.filter(
534
- bucket => lendingFacetKeysVisibility[bucket.key as LendingFacetKey],
535
- );
536
- }
537
-
538
- // Sort the FacetBuckets so that selected and hidden buckets come before the rest
539
- sortBucketsBySelectionState(bucketsWithCount, defaultFacetSort[facetKey]);
540
-
541
- // For mediatype facets, ensure the collection bucket is always shown if present
542
- if (facetKey === 'mediatype') {
543
- const collectionIndex = bucketsWithCount.findIndex(
544
- bucket => bucket.key === 'collection',
545
- );
546
-
547
- if (collectionIndex >= allowedFacetCount) {
548
- const [collectionBucket] = bucketsWithCount.splice(
549
- collectionIndex,
550
- 1,
551
- );
552
-
553
- // If we're showing lots of selected facets, ensure we're not cutting off the last one
554
- if (allowedFacetCount > this.allowedFacetCount) {
555
- allowedFacetCount += 1;
556
- }
557
-
558
- bucketsWithCount.splice(allowedFacetCount - 1, 0, collectionBucket);
559
- }
560
- }
561
-
562
- // For TV creator facets, uppercase the display text
563
- if (facetKey === 'creator' && this.isTvSearch) {
564
- bucketsWithCount.forEach(b => {
565
- b.displayText = (b.displayText ?? b.key)?.toLocaleUpperCase();
566
-
567
- const channelLabel = this.tvChannelAliases?.get(b.displayText);
568
- if (channelLabel && channelLabel !== b.displayText) {
569
- b.extraNote = `(${channelLabel})`;
570
- }
571
- });
572
- }
573
-
574
- // slice off how many items we want to show in page facet area
575
- facetGroup.buckets = bucketsWithCount.slice(0, allowedFacetCount);
576
-
577
- facetGroups.push(facetGroup);
578
- });
579
-
580
- return facetGroups;
581
- }
582
-
583
- /**
584
- * Converts the selected facets to a `FacetGroup` array,
585
- * which is easier to work with
586
- */
587
- private get selectedFacetGroups(): FacetGroup[] {
588
- if (!this.selectedFacets) return [];
589
-
590
- const facetGroups: FacetGroup[] = Object.entries(this.selectedFacets).map(
591
- ([key, selectedFacets]) => {
592
- const option = key as FacetOption;
593
- const title = facetTitles[option];
594
-
595
- const buckets: FacetBucket[] = Object.entries(selectedFacets).map(
596
- ([value, facetData]) => {
597
- let displayText: string = value;
598
- // for lending facets, convert the key to a readable format
599
- if (option === 'lending') {
600
- displayText =
601
- lendingFacetDisplayNames[value as LendingFacetKey] ?? value;
602
- }
603
- return {
604
- displayText,
605
- key: value,
606
- count: facetData.count,
607
- state: facetData.state,
608
- };
609
- },
610
- );
611
-
612
- return {
613
- title,
614
- key: option,
615
- buckets,
616
- };
617
- },
618
- );
619
-
620
- return facetGroups;
621
- }
622
-
623
- /**
624
- * Converts the raw `aggregations` to `FacetGroups`, which are easier to use
625
- */
626
- private get aggregationFacetGroups(): FacetGroup[] {
627
- const facetGroups: FacetGroup[] = [];
628
- Object.entries(this.aggregations ?? []).forEach(([key, aggregation]) => {
629
- // the year_histogram and date_histogram data is in a different format so can't be handled here
630
- if (['year_histogram', 'date_histogram'].includes(key)) return;
631
-
632
- const option = key as FacetOption;
633
- const title = facetTitles[option];
634
- if (!title) return;
635
-
636
- let castedBuckets = aggregation.getSortedBuckets(
637
- defaultFacetSort[option],
638
- ) as Bucket[];
639
-
640
- if (option === 'collection') {
641
- // we are not showing fav- collections or certain deemphasized collections in facets
642
- castedBuckets = castedBuckets?.filter(bucket => {
643
- const bucketKey = bucket?.key?.toString();
644
- return (
645
- !suppressedCollections[bucketKey] && !bucketKey?.startsWith('fav-')
646
- );
647
- });
648
- }
649
-
650
- const facetBuckets: FacetBucket[] = castedBuckets.map(bucket => {
651
- const bucketKey = bucket.key;
652
- let displayText = `${bucket.key}`;
653
- // for lending facets, convert the bucket key to a readable format
654
- if (option === 'lending') {
655
- displayText =
656
- lendingFacetDisplayNames[bucket.key as LendingFacetKey] ??
657
- `${bucket.key}`;
658
- }
659
- return {
660
- displayText,
661
- key: `${bucketKey}`,
662
- count: bucket.doc_count,
663
- state: 'none',
664
- };
665
- });
666
- const group: FacetGroup = {
667
- title,
668
- key: option,
669
- buckets: facetBuckets,
670
- };
671
- facetGroups.push(group);
672
- });
673
- return facetGroups;
674
- }
675
-
676
- /**
677
- * Generate the template for a facet group with a header and the collapsible
678
- * chevron for the mobile view
679
- */
680
- private getFacetGroupTemplate(
681
- facetGroup: FacetGroup,
682
- ): TemplateResult | typeof nothing {
683
- if (!this.facetsLoading && facetGroup.buckets.length === 0) return nothing;
684
-
685
- const { key } = facetGroup;
686
- const isOpen = this.openFacets[key];
687
- const collapser = html`
688
- <span class="collapser ${isOpen ? 'open' : ''}"> ${chevronIcon} </span>
689
- `;
690
-
691
- const toggleCollapsed = () => {
692
- const newOpenFacets = { ...this.openFacets };
693
- newOpenFacets[key] = !isOpen;
694
- this.openFacets = newOpenFacets;
695
- };
696
-
697
- // Added data-testid for Playwright testing
698
- // Using className and aria-labels is not ideal for Playwright locator
699
- const headerId = `facet-group-header-label-${facetGroup.key}`;
700
- return html`
701
- <section
702
- class="facet-group ${this.collapsableFacets ? 'mobile' : ''}"
703
- aria-labelledby=${headerId}
704
- data-testid=${headerId}
705
- >
706
- <div class="facet-group-header">
707
- <h3
708
- id=${headerId}
709
- @click=${toggleCollapsed}
710
- @keyup=${toggleCollapsed}
711
- >
712
- ${this.collapsableFacets ? collapser : nothing} ${facetGroup.title}
713
- <span class="sr-only">filters</span>
714
- </h3>
715
- </div>
716
- <div
717
- class="facet-group-content ${isOpen ? 'open' : ''}"
718
- data-testid="facet-group-content-${facetGroup.key}"
719
- >
720
- ${this.facetsLoading
721
- ? this.getTombstoneFacetGroupTemplate()
722
- : html`
723
- ${this.getFacetTemplate(facetGroup)}
724
- ${this.searchMoreFacetsLink(facetGroup)}
725
- `}
726
- </div>
727
- </section>
728
- `;
729
- }
730
-
731
- private getTombstoneFacetGroupTemplate(): TemplateResult {
732
- // Render five tombstone rows
733
- return html`
734
- ${map(
735
- Array(5).fill(null),
736
- () => html`<facet-tombstone-row></facet-tombstone-row>`,
737
- )}
738
- `;
739
- }
740
-
741
- /**
742
- * Generate the More... link button just below the facets group
743
- *
744
- * TODO: want to fire analytics?
745
- */
746
- private searchMoreFacetsLink(
747
- facetGroup: FacetGroup,
748
- ): TemplateResult | typeof nothing {
749
- // Don't render More... links for FTS searches
750
- if (!this.moreLinksVisible) {
751
- return nothing;
752
- }
753
-
754
- // Don't render More... links for lending facets
755
- if (facetGroup.key === 'lending') {
756
- return nothing;
757
- }
758
-
759
- // Don't render More... link if the number of facets < this.allowedFacetCount
760
- if (Object.keys(facetGroup.buckets).length < this.allowedFacetCount) {
761
- return nothing;
762
- }
763
-
764
- // We sort years in numeric order by default, rather than bucket count
765
- const facetSort = defaultFacetSort[facetGroup.key];
766
-
767
- // Added data-testid for Playwright testing
768
- // Using the className is not ideal for Playwright locator
769
- return html`<button
770
- class="more-link"
771
- @click=${() => {
772
- this.showMoreFacetsModal(facetGroup, facetSort);
773
- this.analyticsHandler?.sendEvent({
774
- category: analyticsCategories.default,
775
- action: analyticsActions.showMoreFacetsModal,
776
- label: facetGroup.key,
777
- });
778
- this.dispatchEvent(
779
- new CustomEvent('showMoreFacets', { detail: facetGroup.key }),
780
- );
781
- }}
782
- data-testid="more-link-btn"
783
- >
784
- More...
785
- </button>`;
786
- }
787
-
788
- async showMoreFacetsModal(
789
- facetGroup: FacetGroup,
790
- sortedBy: AggregationSortType,
791
- ): Promise<void> {
792
- const customModalContent = html`
793
- <more-facets-content
794
- .analyticsHandler=${this.analyticsHandler}
795
- .facetKey=${facetGroup.key}
796
- .query=${this.query}
797
- .filterMap=${this.filterMap}
798
- .pageSpecifierParams=${this.pageSpecifierParams}
799
- .modalManager=${this.modalManager}
800
- .searchService=${this.searchService}
801
- .searchType=${this.searchType}
802
- .collectionTitles=${this.collectionTitles}
803
- .tvChannelAliases=${this.tvChannelAliases}
804
- .selectedFacets=${this.selectedFacets}
805
- .sortedBy=${sortedBy}
806
- .isTvSearch=${this.isTvSearch}
807
- @facetsChanged=${(e: CustomEvent) => {
808
- const event = new CustomEvent<SelectedFacets>('facetsChanged', {
809
- detail: e.detail,
810
- bubbles: true,
811
- composed: true,
812
- });
813
- this.dispatchEvent(event);
814
- }}
815
- >
816
- </more-facets-content>
817
- `;
818
-
819
- const config = new ModalConfig({
820
- bodyColor: '#fff',
821
- headerColor: '#194880',
822
- showHeaderLogo: false,
823
- closeOnBackdropClick: true, // TODO: want to fire analytics
824
- title: html`Select filters`,
825
- });
826
- this.modalManager?.classList.add('more-search-facets');
827
- this.modalManager?.showModal({
828
- config,
829
- customModalContent,
830
- userClosedModalCallback: () => {
831
- this.modalManager?.classList.remove('more-search-facets');
832
- },
833
- });
834
- }
835
-
836
- /**
837
- * Generate the list template for each bucket in a facet group
838
- */
839
- private getFacetTemplate(facetGroup: FacetGroup): TemplateResult {
840
- return html`
841
- <facets-template
842
- .collectionPagePath=${this.collectionPagePath}
843
- .facetGroup=${facetGroup}
844
- .selectedFacets=${this.selectedFacets}
845
- .collectionTitles=${this.collectionTitles}
846
- @facetClick=${(e: CustomEvent<FacetEventDetails>) => {
847
- this.selectedFacets = updateSelectedFacetBucket(
848
- this.selectedFacets,
849
- facetGroup.key,
850
- e.detail.bucket,
851
- true,
852
- );
853
-
854
- const event = new CustomEvent<SelectedFacets>('facetsChanged', {
855
- detail: this.selectedFacets,
856
- bubbles: true,
857
- composed: true,
858
- });
859
- this.dispatchEvent(event);
860
- }}
861
- ></facets-template>
862
- `;
863
- }
864
-
865
- static get styles() {
866
- return [
867
- srOnlyStyle,
868
- css`
869
- a:link {
870
- text-decoration: none;
871
- color: var(--ia-theme-link-color, #4b64ff);
872
- }
873
- a:link:hover {
874
- text-decoration: underline;
875
- }
876
-
877
- #container.loading {
878
- opacity: 0.5;
879
- }
880
-
881
- #container.managing {
882
- opacity: 0.3;
883
- }
884
-
885
- .histogram-loading-indicator {
886
- width: 100%;
887
- height: 2.25rem;
888
- margin-top: 1.75rem;
889
- font-size: 1.4rem;
890
- text-align: center;
891
- }
892
-
893
- .collapser {
894
- display: inline-block;
895
- cursor: pointer;
896
- width: 10px;
897
- height: 10px;
898
- }
899
-
900
- .collapser svg {
901
- transition: transform 0.2s ease-in-out;
902
- }
903
-
904
- .collapser.open svg {
905
- transform: rotate(90deg);
906
- }
907
-
908
- .facet-group:not(:last-child) {
909
- margin-bottom: 2rem;
910
- }
911
-
912
- .facet-group h3 {
913
- margin-bottom: 0.7rem;
914
- }
915
-
916
- .facet-group.mobile h3 {
917
- cursor: pointer;
918
- }
919
-
920
- .facet-group-header {
921
- display: flex;
922
- margin-bottom: 0.7rem;
923
- justify-content: space-between;
924
- border-bottom: 1px solid rgb(232, 232, 232);
925
- }
926
-
927
- .facet-group-content {
928
- transition: max-height 0.2s ease-in-out;
929
- }
930
-
931
- .facet-group.mobile .facet-group-content {
932
- max-height: 0;
933
- overflow: hidden;
934
- }
935
-
936
- .facet-group.mobile .facet-group-content.open {
937
- max-height: 2000px;
938
- }
939
-
940
- .partof-collections ul {
941
- list-style-type: none;
942
- padding: 0;
943
- font-size: 1.2rem;
944
- }
945
-
946
- h3 {
947
- font-size: 1.4rem;
948
- margin: 0;
949
- }
950
-
951
- .more-link {
952
- font-size: 1.2rem;
953
- text-decoration: none;
954
- padding: 0;
955
- background: inherit;
956
- border: 0;
957
- color: var(--ia-theme-link-color, #4b64ff);
958
- cursor: pointer;
959
- }
960
-
961
- #date-picker-label {
962
- display: flex;
963
- justify-content: space-between;
964
- }
965
-
966
- .expand-date-picker-btn {
967
- margin: 0;
968
- padding: 0;
969
- border: 0;
970
- appearance: none;
971
- background: none;
972
- cursor: pointer;
973
- }
974
-
975
- .expand-date-picker-btn > svg {
976
- width: 14px;
977
- height: 14px;
978
- }
979
-
980
- .sorting-icon {
981
- height: 15px;
982
- cursor: pointer;
983
- }
984
-
985
- histogram-date-range.wide-inputs {
986
- --histogramDateRangeInputWidth: 4.8rem;
987
- }
988
- `,
989
- ];
990
- }
991
- }
1
+ import {
2
+ css,
3
+ html,
4
+ LitElement,
5
+ PropertyValues,
6
+ nothing,
7
+ TemplateResult,
8
+ } from 'lit';
9
+ import { customElement, property, state } from 'lit/decorators.js';
10
+ import { map } from 'lit/directives/map.js';
11
+ import { ref } from 'lit/directives/ref.js';
12
+ import { msg } from '@lit/localize';
13
+ import { classMap } from 'lit/directives/class-map.js';
14
+ import {
15
+ Aggregation,
16
+ AggregationSortType,
17
+ Bucket,
18
+ FilterMap,
19
+ SearchServiceInterface,
20
+ SearchType,
21
+ } from '@internetarchive/search-service';
22
+ import '@internetarchive/histogram-date-range';
23
+ import '@internetarchive/feature-feedback';
24
+ import {
25
+ ModalConfig,
26
+ ModalManagerInterface,
27
+ } from '@internetarchive/modal-manager';
28
+ import type { FeatureFeedbackServiceInterface } from '@internetarchive/feature-feedback';
29
+ import type { RecaptchaManagerInterface } from '@internetarchive/recaptcha-manager';
30
+ import type { AnalyticsManagerInterface } from '@internetarchive/analytics-manager';
31
+ import type { SharedResizeObserverInterface } from '@internetarchive/shared-resize-observer';
32
+ import type {
33
+ BarScalingOption,
34
+ BinSnappingInterval,
35
+ } from '@internetarchive/histogram-date-range';
36
+ import chevronIcon from './assets/img/icons/chevron';
37
+ import expandIcon from './assets/img/icons/expand';
38
+ import {
39
+ FacetOption,
40
+ SelectedFacets,
41
+ FacetGroup,
42
+ FacetBucket,
43
+ defaultFacetDisplayOrder,
44
+ facetTitles,
45
+ lendingFacetDisplayNames,
46
+ lendingFacetKeysVisibility,
47
+ LendingFacetKey,
48
+ suppressedCollections,
49
+ defaultFacetSort,
50
+ FacetEventDetails,
51
+ } from './models';
52
+ import type {
53
+ CollectionTitles,
54
+ PageSpecifierParams,
55
+ TVChannelAliases,
56
+ } from './data-source/models';
57
+ import {
58
+ analyticsActions,
59
+ analyticsCategories,
60
+ } from './utils/analytics-events';
61
+ import { srOnlyStyle } from './styles/sr-only';
62
+ import { ExpandedDatePicker } from './expanded-date-picker';
63
+ import {
64
+ sortBucketsBySelectionState,
65
+ updateSelectedFacetBucket,
66
+ } from './utils/facet-utils';
67
+
68
+ import '@internetarchive/histogram-date-range';
69
+ import './collection-facets/more-facets-content';
70
+ import './collection-facets/facets-template';
71
+ import './collection-facets/facet-tombstone-row';
72
+ import './expanded-date-picker';
73
+
74
+ @customElement('collection-facets')
75
+ export class CollectionFacets extends LitElement {
76
+ @property({ type: Object }) searchService?: SearchServiceInterface;
77
+
78
+ @property({ type: Number }) searchType?: SearchType;
79
+
80
+ @property({ type: Object }) aggregations?: Record<string, Aggregation>;
81
+
82
+ @property({ type: Object }) histogramAggregation?: Aggregation;
83
+
84
+ @property({ type: String }) minSelectedDate?: string;
85
+
86
+ @property({ type: String }) maxSelectedDate?: string;
87
+
88
+ @property({ type: Boolean }) moreLinksVisible = true;
89
+
90
+ @property({ type: Boolean }) facetsLoading = false;
91
+
92
+ @property({ type: Boolean }) histogramAggregationLoading = false;
93
+
94
+ @property({ type: Object }) selectedFacets?: SelectedFacets;
95
+
96
+ @property({ type: Boolean }) collapsableFacets = false;
97
+
98
+ @property({ type: Number }) contentWidth?: number;
99
+
100
+ @property({ type: Boolean }) showHistogramDatePicker = false;
101
+
102
+ @property({ type: Boolean }) allowExpandingDatePicker = false;
103
+
104
+ @property({ type: Boolean }) suppressMediatypeFacets = false;
105
+
106
+ @property({ type: String }) query?: string;
107
+
108
+ @property({ type: Object }) pageSpecifierParams?: PageSpecifierParams;
109
+
110
+ @property({ type: Array }) parentCollections: string[] = [];
111
+
112
+ @property({ type: Object }) filterMap?: FilterMap;
113
+
114
+ @property({ type: String }) baseNavigationUrl?: string;
115
+
116
+ @property({ type: String }) collectionPagePath: string = '/details/';
117
+
118
+ @property({ type: Boolean }) isManageView = false;
119
+
120
+ @property({ type: Boolean }) isTvSearch = false;
121
+
122
+ @property({ type: Array }) facetDisplayOrder: FacetOption[] =
123
+ defaultFacetDisplayOrder;
124
+
125
+ @property({ type: Object, attribute: false })
126
+ modalManager?: ModalManagerInterface;
127
+
128
+ @property({ type: Object, attribute: false })
129
+ resizeObserver?: SharedResizeObserverInterface;
130
+
131
+ @property({ type: Object, attribute: false })
132
+ featureFeedbackService?: FeatureFeedbackServiceInterface;
133
+
134
+ @property({ type: Object, attribute: false })
135
+ recaptchaManager?: RecaptchaManagerInterface;
136
+
137
+ @property({ type: Object, attribute: false })
138
+ analyticsHandler?: AnalyticsManagerInterface;
139
+
140
+ @property({ type: Object, attribute: false })
141
+ collectionTitles?: CollectionTitles;
142
+
143
+ @property({ type: Object, attribute: false })
144
+ tvChannelAliases?: TVChannelAliases;
145
+
146
+ @state() openFacets: Record<FacetOption, boolean> = {
147
+ subject: false,
148
+ lending: false,
149
+ mediatype: false,
150
+ language: false,
151
+ creator: false,
152
+ collection: false,
153
+ year: false,
154
+ program: false,
155
+ person: false,
156
+ sponsor: false,
157
+ };
158
+
159
+ /**
160
+ * Maximum # of facet buckets to render per facet group
161
+ */
162
+ private allowedFacetCount = 6;
163
+
164
+ render() {
165
+ const containerClasses = classMap({
166
+ loading: this.facetsLoading,
167
+ managing: this.isManageView,
168
+ });
169
+
170
+ // Added data-testid for Playwright testing
171
+ // Using facet-group class and aria-labels is not ideal for Playwright locator
172
+ const datePickerLabelId = 'date-picker-label';
173
+ return html`
174
+ <div id="container" class=${containerClasses}>
175
+ ${this.showHistogramDatePicker &&
176
+ (this.histogramAggregation || this.histogramAggregationLoading)
177
+ ? html`
178
+ <section
179
+ class="facet-group"
180
+ aria-labelledby=${datePickerLabelId}
181
+ data-testid="facet-group-header-label-date-picker"
182
+ >
183
+ <h3 id=${datePickerLabelId}>
184
+ Year Published <span class="sr-only">range filter</span>
185
+ ${this.expandDatePickerBtnTemplate}
186
+ </h3>
187
+ ${this.histogramTemplate}
188
+ </section>
189
+ `
190
+ : nothing}
191
+ ${this.collectionPartOfTemplate}
192
+ ${this.mergedFacets.map(facetGroup =>
193
+ this.getFacetGroupTemplate(facetGroup),
194
+ )}
195
+ </div>
196
+ `;
197
+ }
198
+
199
+ private get collectionPartOfTemplate(): TemplateResult | typeof nothing {
200
+ // We only display the "Part Of" section on collection pages
201
+ if (!this.parentCollections?.length) return nothing;
202
+
203
+ // Added data-testid for Playwright testing
204
+ // Using className and aria-labels is not ideal for Playwright locator
205
+ const headingId = 'partof-heading';
206
+ return html`
207
+ <section
208
+ class="facet-group partof-collections"
209
+ aria-labelledby=${headingId}
210
+ data-testid="facet-group-partof-collections"
211
+ >
212
+ <div class="facet-group-header">
213
+ <h3 id=${headingId}>${msg('Part Of')}</h3>
214
+ </div>
215
+ <ul>
216
+ ${map(this.parentCollections, collxn => {
217
+ const collectionURL = `${this.baseNavigationUrl}${this.collectionPagePath}${collxn}`;
218
+
219
+ return html` <li>
220
+ <a
221
+ href=${collectionURL}
222
+ data-id=${collxn}
223
+ @click=${this.partOfCollectionClicked}
224
+ >
225
+ ${this.collectionTitles?.get(collxn) ?? collxn}
226
+ </a>
227
+ </li>`;
228
+ })}
229
+ </ul>
230
+ </section>
231
+ `;
232
+ }
233
+
234
+ private partOfCollectionClicked(e: Event): void {
235
+ this.analyticsHandler?.sendEvent({
236
+ category: analyticsCategories.default,
237
+ action: analyticsActions.partOfCollectionClicked,
238
+ label: (e.target as HTMLElement).dataset.id,
239
+ });
240
+ }
241
+
242
+ /**
243
+ * Properties to pass into the date-picker histogram component
244
+ */
245
+ private get histogramProps() {
246
+ const { histogramAggregation: aggregation } = this;
247
+ if (!aggregation) return undefined;
248
+
249
+ // Normalize some properties from the raw aggregation
250
+ const firstYear =
251
+ aggregation.first_bucket_year ?? aggregation.first_bucket_key;
252
+ const lastYear =
253
+ aggregation.last_bucket_year ?? aggregation.last_bucket_key;
254
+ if (firstYear == null || lastYear == null) return undefined; // We at least need a start/end year defined
255
+
256
+ const firstMonth = aggregation.first_bucket_month ?? 1;
257
+ const lastMonth = aggregation.last_bucket_month ?? 12;
258
+
259
+ const yearInterval = aggregation.interval ?? 1;
260
+ const monthInterval = aggregation.interval_in_months ?? 12;
261
+
262
+ const zeroPadMonth = (month: number) => month.toString().padStart(2, '0');
263
+
264
+ // The date picker is configured differently for TV search, allowing month-level resolution
265
+ if (this.isTvSearch) {
266
+ // Whether the bucket interval is less than a year
267
+ // (i.e., requires individual months to be handled & labeled)
268
+ const mustHandleMonths = monthInterval < 12;
269
+
270
+ return {
271
+ buckets: aggregation.buckets as number[],
272
+ dateFormat: 'YYYY-MM',
273
+ tooltipDateFormat: mustHandleMonths ? 'MMM YYYY' : 'YYYY',
274
+ tooltipLabel: 'broadcast',
275
+ binSnapping: (mustHandleMonths
276
+ ? 'month'
277
+ : 'year') as BinSnappingInterval,
278
+ barScaling: 'linear' as BarScalingOption,
279
+ minDate: `${firstYear}-${zeroPadMonth(firstMonth)}`,
280
+ maxDate: `${lastYear}-${zeroPadMonth(lastMonth + monthInterval - 1)}`,
281
+ };
282
+ }
283
+
284
+ // All other search types use the same configuration
285
+ return {
286
+ buckets: aggregation.buckets as number[],
287
+ dateFormat: 'YYYY',
288
+ tooltipDateFormat: 'YYYY',
289
+ tooltipLabel: 'item',
290
+ binSnapping: 'year' as BinSnappingInterval,
291
+ barScaling: 'logarithmic' as BarScalingOption,
292
+ minDate: `${firstYear}`,
293
+ maxDate: `${lastYear + yearInterval - 1}`,
294
+ };
295
+ }
296
+
297
+ /**
298
+ * Opens a modal dialog containing an enlarged version of the date picker.
299
+ */
300
+ private showDatePickerModal(): void {
301
+ const { histogramProps } = this;
302
+ if (!histogramProps) return;
303
+
304
+ const {
305
+ buckets,
306
+ dateFormat,
307
+ tooltipDateFormat,
308
+ tooltipLabel,
309
+ binSnapping,
310
+ barScaling,
311
+ minDate,
312
+ maxDate,
313
+ } = histogramProps;
314
+
315
+ // Because the modal manager does not clear its DOM content after being closed,
316
+ // it may try to render the exact same date picker template when it is reopened.
317
+ // And because it isn't actually a descendent of this collection-facets component,
318
+ // changes to the template defined here may not trigger a reactive update to the date
319
+ // picker, resulting in it displaying a stale date range.
320
+ // This ref callback ensures that every time the date picker modal is opened, it will
321
+ // always propagate the most recent date range into the date picker regardless of
322
+ // whether Lit thinks the update is necessary.
323
+ const expandedDatePickerChanged = (elmt?: Element) => {
324
+ if (elmt && elmt instanceof ExpandedDatePicker) {
325
+ const expandedDatePicker = elmt as ExpandedDatePicker;
326
+ expandedDatePicker.minSelectedDate = this.minSelectedDate;
327
+ expandedDatePicker.maxSelectedDate = this.maxSelectedDate;
328
+ }
329
+ };
330
+
331
+ const customModalContent = html`
332
+ <expanded-date-picker
333
+ ${ref(expandedDatePickerChanged)}
334
+ .minDate=${minDate}
335
+ .maxDate=${maxDate}
336
+ .minSelectedDate=${this.minSelectedDate}
337
+ .maxSelectedDate=${this.maxSelectedDate}
338
+ .customDateFormat=${dateFormat}
339
+ .customTooltipDateFormat=${tooltipDateFormat}
340
+ .customTooltipLabel=${tooltipLabel}
341
+ .binSnapping=${binSnapping}
342
+ .barScaling=${barScaling}
343
+ .buckets=${buckets}
344
+ .modalManager=${this.modalManager}
345
+ .analyticsHandler=${this.analyticsHandler}
346
+ @histogramDateRangeApplied=${this.histogramDateRangeUpdated}
347
+ @modalClosed=${this.handleExpandedDatePickerClosed}
348
+ ></expanded-date-picker>
349
+ `;
350
+
351
+ const config = new ModalConfig({
352
+ bodyColor: '#fff',
353
+ headerColor: '#194880',
354
+ showHeaderLogo: false,
355
+ closeOnBackdropClick: true, // TODO: want to fire analytics
356
+ title: html`${msg('Select a date range')}`,
357
+ });
358
+
359
+ this.modalManager?.classList.add('expanded-date-picker');
360
+ this.modalManager?.showModal({
361
+ config,
362
+ customModalContent,
363
+ userClosedModalCallback: this.handleExpandedDatePickerClosed,
364
+ });
365
+
366
+ this.analyticsHandler?.sendEvent({
367
+ category: analyticsCategories.default,
368
+ action: analyticsActions.histogramExpanded,
369
+ label: window.location.href,
370
+ });
371
+ }
372
+
373
+ private handleExpandedDatePickerClosed = (): void => {
374
+ this.modalManager?.classList.remove('expanded-date-picker');
375
+ };
376
+
377
+ updated(changed: PropertyValues) {
378
+ if (changed.has('selectedFacets')) {
379
+ this.dispatchFacetsChangedEvent();
380
+ }
381
+ }
382
+
383
+ // TODO: want to fire analytics?
384
+ private dispatchFacetsChangedEvent() {
385
+ const event = new CustomEvent<SelectedFacets>('facetsChanged', {
386
+ detail: this.selectedFacets,
387
+ });
388
+ this.dispatchEvent(event);
389
+ }
390
+
391
+ /**
392
+ * Template for the "Expand" button to show the date picker modal, or
393
+ * `nothing` if that button should currently not be shown.
394
+ */
395
+ private get expandDatePickerBtnTemplate(): TemplateResult | typeof nothing {
396
+ return this.allowExpandingDatePicker && !this.facetsLoading
397
+ ? html`<button
398
+ class="expand-date-picker-btn"
399
+ aria-hidden="true"
400
+ @click=${this.showDatePickerModal}
401
+ >
402
+ ${expandIcon}
403
+ </button>`
404
+ : nothing;
405
+ }
406
+
407
+ private get histogramTemplate(): TemplateResult | typeof nothing {
408
+ if (this.histogramAggregationLoading) {
409
+ return html` <div class="histogram-loading-indicator">&hellip;</div> `;
410
+ }
411
+
412
+ const { histogramProps } = this;
413
+ if (!histogramProps) return nothing;
414
+
415
+ const {
416
+ buckets,
417
+ dateFormat,
418
+ tooltipDateFormat,
419
+ tooltipLabel,
420
+ binSnapping,
421
+ barScaling,
422
+ minDate,
423
+ maxDate,
424
+ } = histogramProps;
425
+
426
+ return html`
427
+ <histogram-date-range
428
+ class=${this.isTvSearch ? 'wide-inputs' : nothing}
429
+ .minDate=${minDate}
430
+ .maxDate=${maxDate}
431
+ .minSelectedDate=${this.minSelectedDate ?? minDate}
432
+ .maxSelectedDate=${this.maxSelectedDate ?? maxDate}
433
+ .updateDelay=${100}
434
+ .dateFormat=${dateFormat}
435
+ .tooltipDateFormat=${tooltipDateFormat}
436
+ .tooltipLabel=${tooltipLabel}
437
+ .binSnapping=${binSnapping}
438
+ .barScaling=${barScaling}
439
+ .bins=${buckets}
440
+ missingDataMessage="..."
441
+ .width=${this.collapsableFacets && this.contentWidth
442
+ ? this.contentWidth
443
+ : 180}
444
+ @histogramDateRangeUpdated=${this.histogramDateRangeUpdated}
445
+ ></histogram-date-range>
446
+ `;
447
+ }
448
+
449
+ /**
450
+ * Dispatches a `histogramDateRangeUpdated` event with the date range copied from the
451
+ * input event.
452
+ *
453
+ * Arrow function to ensure `this` is always bound to the current component.
454
+ */
455
+ private histogramDateRangeUpdated = (
456
+ e: CustomEvent<{
457
+ minDate: string;
458
+ maxDate: string;
459
+ }>,
460
+ ): void => {
461
+ const { minDate, maxDate } = e.detail;
462
+ const event = new CustomEvent('histogramDateRangeUpdated', {
463
+ detail: { minDate, maxDate },
464
+ });
465
+ this.dispatchEvent(event);
466
+ };
467
+
468
+ /**
469
+ * Combines the selected facets with the aggregations to create a single list of facets
470
+ */
471
+ private get mergedFacets(): FacetGroup[] {
472
+ const facetGroups: FacetGroup[] = [];
473
+
474
+ this.facetDisplayOrder.forEach(facetKey => {
475
+ if (facetKey === 'mediatype' && this.suppressMediatypeFacets) return;
476
+
477
+ const selectedFacetGroup = this.selectedFacetGroups.find(
478
+ group => group.key === facetKey,
479
+ );
480
+ const aggregateFacetGroup = this.aggregationFacetGroups.find(
481
+ group => group.key === facetKey,
482
+ );
483
+
484
+ // if the user selected a facet, but it's not in the aggregation, we add it as-is
485
+ if (selectedFacetGroup && !aggregateFacetGroup) {
486
+ facetGroups.push(selectedFacetGroup);
487
+ return;
488
+ }
489
+
490
+ // if we don't have an aggregate facet group, don't add this to the list
491
+ if (!aggregateFacetGroup) return;
492
+
493
+ // start with either the selected group if we have one, or the aggregate group
494
+ const facetGroup = selectedFacetGroup ?? aggregateFacetGroup;
495
+
496
+ // attach the counts to the selected buckets
497
+ let bucketsWithCount =
498
+ selectedFacetGroup?.buckets.map(bucket => {
499
+ const selectedBucket = aggregateFacetGroup.buckets.find(
500
+ b => b.key === bucket.key,
501
+ );
502
+ return selectedBucket
503
+ ? {
504
+ ...bucket,
505
+ count: selectedBucket.count,
506
+ }
507
+ : bucket;
508
+ }) ?? [];
509
+
510
+ // append any additional buckets that were not selected
511
+ aggregateFacetGroup.buckets.forEach(bucket => {
512
+ const existingBucket = bucketsWithCount.find(b => b.key === bucket.key);
513
+ if (existingBucket) return;
514
+ bucketsWithCount.push(bucket);
515
+ });
516
+
517
+ /**
518
+ * render limited facet items on page facet area
519
+ *
520
+ * - by-default we are showing 6 items
521
+ * - additionally want to show all items (selected/suppressed) in page facet area
522
+ */
523
+ let allowedFacetCount = Object.keys(
524
+ (selectedFacetGroup?.buckets as []) || [],
525
+ )?.length;
526
+ if (allowedFacetCount < this.allowedFacetCount) {
527
+ allowedFacetCount = this.allowedFacetCount; // splice start index from 0th
528
+ }
529
+
530
+ // For lending facets, only include a specific subset of buckets
531
+ if (facetKey === 'lending') {
532
+ bucketsWithCount = bucketsWithCount.filter(
533
+ bucket => lendingFacetKeysVisibility[bucket.key as LendingFacetKey],
534
+ );
535
+ }
536
+
537
+ // Sort the FacetBuckets so that selected and hidden buckets come before the rest
538
+ sortBucketsBySelectionState(bucketsWithCount, defaultFacetSort[facetKey]);
539
+
540
+ // For mediatype facets, ensure the collection bucket is always shown if present
541
+ if (facetKey === 'mediatype') {
542
+ const collectionIndex = bucketsWithCount.findIndex(
543
+ bucket => bucket.key === 'collection',
544
+ );
545
+
546
+ if (collectionIndex >= allowedFacetCount) {
547
+ const [collectionBucket] = bucketsWithCount.splice(
548
+ collectionIndex,
549
+ 1,
550
+ );
551
+
552
+ // If we're showing lots of selected facets, ensure we're not cutting off the last one
553
+ if (allowedFacetCount > this.allowedFacetCount) {
554
+ allowedFacetCount += 1;
555
+ }
556
+
557
+ bucketsWithCount.splice(allowedFacetCount - 1, 0, collectionBucket);
558
+ }
559
+ }
560
+
561
+ // For TV creator facets, uppercase the display text
562
+ if (facetKey === 'creator' && this.isTvSearch) {
563
+ bucketsWithCount.forEach(b => {
564
+ b.displayText = (b.displayText ?? b.key)?.toLocaleUpperCase();
565
+
566
+ const channelLabel = this.tvChannelAliases?.get(b.displayText);
567
+ if (channelLabel && channelLabel !== b.displayText) {
568
+ b.extraNote = `(${channelLabel})`;
569
+ }
570
+ });
571
+ }
572
+
573
+ // slice off how many items we want to show in page facet area
574
+ facetGroup.buckets = bucketsWithCount.slice(0, allowedFacetCount);
575
+
576
+ facetGroups.push(facetGroup);
577
+ });
578
+
579
+ return facetGroups;
580
+ }
581
+
582
+ /**
583
+ * Converts the selected facets to a `FacetGroup` array,
584
+ * which is easier to work with
585
+ */
586
+ private get selectedFacetGroups(): FacetGroup[] {
587
+ if (!this.selectedFacets) return [];
588
+
589
+ const facetGroups: FacetGroup[] = Object.entries(this.selectedFacets).map(
590
+ ([key, selectedFacets]) => {
591
+ const option = key as FacetOption;
592
+ const title = facetTitles[option];
593
+
594
+ const buckets: FacetBucket[] = Object.entries(selectedFacets).map(
595
+ ([value, facetData]) => {
596
+ let displayText: string = value;
597
+ // for lending facets, convert the key to a readable format
598
+ if (option === 'lending') {
599
+ displayText =
600
+ lendingFacetDisplayNames[value as LendingFacetKey] ?? value;
601
+ }
602
+ return {
603
+ displayText,
604
+ key: value,
605
+ count: facetData.count,
606
+ state: facetData.state,
607
+ };
608
+ },
609
+ );
610
+
611
+ return {
612
+ title,
613
+ key: option,
614
+ buckets,
615
+ };
616
+ },
617
+ );
618
+
619
+ return facetGroups;
620
+ }
621
+
622
+ /**
623
+ * Converts the raw `aggregations` to `FacetGroups`, which are easier to use
624
+ */
625
+ private get aggregationFacetGroups(): FacetGroup[] {
626
+ const facetGroups: FacetGroup[] = [];
627
+ Object.entries(this.aggregations ?? []).forEach(([key, aggregation]) => {
628
+ // the year_histogram and date_histogram data is in a different format so can't be handled here
629
+ if (['year_histogram', 'date_histogram'].includes(key)) return;
630
+
631
+ const option = key as FacetOption;
632
+ const title = facetTitles[option];
633
+ if (!title) return;
634
+
635
+ let castedBuckets = aggregation.getSortedBuckets(
636
+ defaultFacetSort[option],
637
+ ) as Bucket[];
638
+
639
+ if (option === 'collection') {
640
+ // we are not showing fav- collections or certain deemphasized collections in facets
641
+ castedBuckets = castedBuckets?.filter(bucket => {
642
+ const bucketKey = bucket?.key?.toString();
643
+ return (
644
+ !suppressedCollections[bucketKey] && !bucketKey?.startsWith('fav-')
645
+ );
646
+ });
647
+ }
648
+
649
+ const facetBuckets: FacetBucket[] = castedBuckets.map(bucket => {
650
+ const bucketKey = bucket.key;
651
+ let displayText = `${bucket.key}`;
652
+ // for lending facets, convert the bucket key to a readable format
653
+ if (option === 'lending') {
654
+ displayText =
655
+ lendingFacetDisplayNames[bucket.key as LendingFacetKey] ??
656
+ `${bucket.key}`;
657
+ }
658
+ return {
659
+ displayText,
660
+ key: `${bucketKey}`,
661
+ count: bucket.doc_count,
662
+ state: 'none',
663
+ };
664
+ });
665
+ const group: FacetGroup = {
666
+ title,
667
+ key: option,
668
+ buckets: facetBuckets,
669
+ };
670
+ facetGroups.push(group);
671
+ });
672
+ return facetGroups;
673
+ }
674
+
675
+ /**
676
+ * Generate the template for a facet group with a header and the collapsible
677
+ * chevron for the mobile view
678
+ */
679
+ private getFacetGroupTemplate(
680
+ facetGroup: FacetGroup,
681
+ ): TemplateResult | typeof nothing {
682
+ if (!this.facetsLoading && facetGroup.buckets.length === 0) return nothing;
683
+
684
+ const { key } = facetGroup;
685
+ const isOpen = this.openFacets[key];
686
+ const collapser = html`
687
+ <span class="collapser ${isOpen ? 'open' : ''}"> ${chevronIcon} </span>
688
+ `;
689
+
690
+ const toggleCollapsed = () => {
691
+ const newOpenFacets = { ...this.openFacets };
692
+ newOpenFacets[key] = !isOpen;
693
+ this.openFacets = newOpenFacets;
694
+ };
695
+
696
+ // Added data-testid for Playwright testing
697
+ // Using className and aria-labels is not ideal for Playwright locator
698
+ const headerId = `facet-group-header-label-${facetGroup.key}`;
699
+ return html`
700
+ <section
701
+ class="facet-group ${this.collapsableFacets ? 'mobile' : ''}"
702
+ aria-labelledby=${headerId}
703
+ data-testid=${headerId}
704
+ >
705
+ <div class="facet-group-header">
706
+ <h3
707
+ id=${headerId}
708
+ @click=${toggleCollapsed}
709
+ @keyup=${toggleCollapsed}
710
+ >
711
+ ${this.collapsableFacets ? collapser : nothing} ${facetGroup.title}
712
+ <span class="sr-only">filters</span>
713
+ </h3>
714
+ </div>
715
+ <div
716
+ class="facet-group-content ${isOpen ? 'open' : ''}"
717
+ data-testid="facet-group-content-${facetGroup.key}"
718
+ >
719
+ ${this.facetsLoading
720
+ ? this.getTombstoneFacetGroupTemplate()
721
+ : html`
722
+ ${this.getFacetTemplate(facetGroup)}
723
+ ${this.searchMoreFacetsLink(facetGroup)}
724
+ `}
725
+ </div>
726
+ </section>
727
+ `;
728
+ }
729
+
730
+ private getTombstoneFacetGroupTemplate(): TemplateResult {
731
+ // Render five tombstone rows
732
+ return html`
733
+ ${map(
734
+ Array(5).fill(null),
735
+ () => html`<facet-tombstone-row></facet-tombstone-row>`,
736
+ )}
737
+ `;
738
+ }
739
+
740
+ /**
741
+ * Generate the More... link button just below the facets group
742
+ *
743
+ * TODO: want to fire analytics?
744
+ */
745
+ private searchMoreFacetsLink(
746
+ facetGroup: FacetGroup,
747
+ ): TemplateResult | typeof nothing {
748
+ // Don't render More... links for FTS searches
749
+ if (!this.moreLinksVisible) {
750
+ return nothing;
751
+ }
752
+
753
+ // Don't render More... links for lending facets
754
+ if (facetGroup.key === 'lending') {
755
+ return nothing;
756
+ }
757
+
758
+ // Don't render More... link if the number of facets < this.allowedFacetCount
759
+ if (Object.keys(facetGroup.buckets).length < this.allowedFacetCount) {
760
+ return nothing;
761
+ }
762
+
763
+ // We sort years in numeric order by default, rather than bucket count
764
+ const facetSort = defaultFacetSort[facetGroup.key];
765
+
766
+ // Added data-testid for Playwright testing
767
+ // Using the className is not ideal for Playwright locator
768
+ return html`<button
769
+ class="more-link"
770
+ @click=${() => {
771
+ this.showMoreFacetsModal(facetGroup, facetSort);
772
+ this.analyticsHandler?.sendEvent({
773
+ category: analyticsCategories.default,
774
+ action: analyticsActions.showMoreFacetsModal,
775
+ label: facetGroup.key,
776
+ });
777
+ this.dispatchEvent(
778
+ new CustomEvent('showMoreFacets', { detail: facetGroup.key }),
779
+ );
780
+ }}
781
+ data-testid="more-link-btn"
782
+ >
783
+ More...
784
+ </button>`;
785
+ }
786
+
787
+ async showMoreFacetsModal(
788
+ facetGroup: FacetGroup,
789
+ sortedBy: AggregationSortType,
790
+ ): Promise<void> {
791
+ const customModalContent = html`
792
+ <more-facets-content
793
+ .analyticsHandler=${this.analyticsHandler}
794
+ .facetKey=${facetGroup.key}
795
+ .query=${this.query}
796
+ .filterMap=${this.filterMap}
797
+ .pageSpecifierParams=${this.pageSpecifierParams}
798
+ .modalManager=${this.modalManager}
799
+ .searchService=${this.searchService}
800
+ .searchType=${this.searchType}
801
+ .collectionTitles=${this.collectionTitles}
802
+ .tvChannelAliases=${this.tvChannelAliases}
803
+ .selectedFacets=${this.selectedFacets}
804
+ .sortedBy=${sortedBy}
805
+ .isTvSearch=${this.isTvSearch}
806
+ @facetsChanged=${(e: CustomEvent) => {
807
+ const event = new CustomEvent<SelectedFacets>('facetsChanged', {
808
+ detail: e.detail,
809
+ bubbles: true,
810
+ composed: true,
811
+ });
812
+ this.dispatchEvent(event);
813
+ }}
814
+ >
815
+ </more-facets-content>
816
+ `;
817
+
818
+ const config = new ModalConfig({
819
+ bodyColor: '#fff',
820
+ headerColor: '#194880',
821
+ showHeaderLogo: false,
822
+ closeOnBackdropClick: true, // TODO: want to fire analytics
823
+ title: html`Select filters`,
824
+ });
825
+ this.modalManager?.classList.add('more-search-facets');
826
+ this.modalManager?.showModal({
827
+ config,
828
+ customModalContent,
829
+ userClosedModalCallback: () => {
830
+ this.modalManager?.classList.remove('more-search-facets');
831
+ },
832
+ });
833
+ }
834
+
835
+ /**
836
+ * Generate the list template for each bucket in a facet group
837
+ */
838
+ private getFacetTemplate(facetGroup: FacetGroup): TemplateResult {
839
+ return html`
840
+ <facets-template
841
+ .collectionPagePath=${this.collectionPagePath}
842
+ .facetGroup=${facetGroup}
843
+ .selectedFacets=${this.selectedFacets}
844
+ .collectionTitles=${this.collectionTitles}
845
+ @facetClick=${(e: CustomEvent<FacetEventDetails>) => {
846
+ this.selectedFacets = updateSelectedFacetBucket(
847
+ this.selectedFacets,
848
+ facetGroup.key,
849
+ e.detail.bucket,
850
+ true,
851
+ );
852
+
853
+ const event = new CustomEvent<SelectedFacets>('facetsChanged', {
854
+ detail: this.selectedFacets,
855
+ bubbles: true,
856
+ composed: true,
857
+ });
858
+ this.dispatchEvent(event);
859
+ }}
860
+ ></facets-template>
861
+ `;
862
+ }
863
+
864
+ static get styles() {
865
+ return [
866
+ srOnlyStyle,
867
+ css`
868
+ a:link {
869
+ text-decoration: none;
870
+ color: var(--ia-theme-link-color, #4b64ff);
871
+ }
872
+ a:link:hover {
873
+ text-decoration: underline;
874
+ }
875
+
876
+ #container.loading {
877
+ opacity: 0.5;
878
+ }
879
+
880
+ #container.managing {
881
+ opacity: 0.3;
882
+ }
883
+
884
+ .histogram-loading-indicator {
885
+ width: 100%;
886
+ height: 2.25rem;
887
+ margin-top: 1.75rem;
888
+ font-size: 1.4rem;
889
+ text-align: center;
890
+ }
891
+
892
+ .collapser {
893
+ display: inline-block;
894
+ cursor: pointer;
895
+ width: 10px;
896
+ height: 10px;
897
+ }
898
+
899
+ .collapser svg {
900
+ transition: transform 0.2s ease-in-out;
901
+ }
902
+
903
+ .collapser.open svg {
904
+ transform: rotate(90deg);
905
+ }
906
+
907
+ .facet-group:not(:last-child) {
908
+ margin-bottom: 2rem;
909
+ }
910
+
911
+ .facet-group h3 {
912
+ margin-bottom: 0.7rem;
913
+ }
914
+
915
+ .facet-group.mobile h3 {
916
+ cursor: pointer;
917
+ }
918
+
919
+ .facet-group-header {
920
+ display: flex;
921
+ margin-bottom: 0.7rem;
922
+ justify-content: space-between;
923
+ border-bottom: 1px solid rgb(232, 232, 232);
924
+ }
925
+
926
+ .facet-group-content {
927
+ transition: max-height 0.2s ease-in-out;
928
+ }
929
+
930
+ .facet-group.mobile .facet-group-content {
931
+ max-height: 0;
932
+ overflow: hidden;
933
+ }
934
+
935
+ .facet-group.mobile .facet-group-content.open {
936
+ max-height: 2000px;
937
+ }
938
+
939
+ .partof-collections ul {
940
+ list-style-type: none;
941
+ padding: 0;
942
+ font-size: 1.2rem;
943
+ }
944
+
945
+ h3 {
946
+ font-size: 1.4rem;
947
+ margin: 0;
948
+ }
949
+
950
+ .more-link {
951
+ font-size: 1.2rem;
952
+ text-decoration: none;
953
+ padding: 0;
954
+ background: inherit;
955
+ border: 0;
956
+ color: var(--ia-theme-link-color, #4b64ff);
957
+ cursor: pointer;
958
+ }
959
+
960
+ #date-picker-label {
961
+ display: flex;
962
+ justify-content: space-between;
963
+ }
964
+
965
+ .expand-date-picker-btn {
966
+ margin: 0;
967
+ padding: 0;
968
+ border: 0;
969
+ appearance: none;
970
+ background: none;
971
+ cursor: pointer;
972
+ }
973
+
974
+ .expand-date-picker-btn > svg {
975
+ width: 14px;
976
+ height: 14px;
977
+ }
978
+
979
+ .sorting-icon {
980
+ height: 15px;
981
+ cursor: pointer;
982
+ }
983
+
984
+ histogram-date-range.wide-inputs {
985
+ --histogramDateRangeInputWidth: 4.8rem;
986
+ }
987
+ `,
988
+ ];
989
+ }
990
+ }