@internetarchive/collection-browser 3.3.1 → 3.3.3

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