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