@internetarchive/collection-browser 3.3.0 → 3.3.1-alpha3

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 (69) 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 +266 -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/list/tile-list-compact.js +99 -99
  27. package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
  28. package/dist/src/tiles/list/tile-list.js +297 -297
  29. package/dist/src/tiles/list/tile-list.js.map +1 -1
  30. package/dist/src/tiles/tile-dispatcher.js +203 -203
  31. package/dist/src/tiles/tile-dispatcher.js.map +1 -1
  32. package/dist/src/utils/format-date.js.map +1 -1
  33. package/dist/test/collection-browser.test.js +189 -189
  34. package/dist/test/collection-browser.test.js.map +1 -1
  35. package/dist/test/tiles/grid/item-tile.test.js +77 -77
  36. package/dist/test/tiles/grid/item-tile.test.js.map +1 -1
  37. package/dist/test/tiles/list/tile-list-compact.test.js +70 -70
  38. package/dist/test/tiles/list/tile-list-compact.test.js.map +1 -1
  39. package/dist/test/tiles/list/tile-list.test.js +126 -126
  40. package/dist/test/tiles/list/tile-list.test.js.map +1 -1
  41. package/dist/test/utils/format-date.test.js.map +1 -1
  42. package/eslint.config.mjs +53 -53
  43. package/index.html +24 -24
  44. package/local.archive.org.cert +86 -86
  45. package/local.archive.org.key +27 -27
  46. package/package.json +117 -117
  47. package/renovate.json +6 -6
  48. package/src/collection-browser.ts +2829 -2829
  49. package/src/collection-facets/more-facets-content.ts +639 -639
  50. package/src/collection-facets.ts +995 -995
  51. package/src/data-source/collection-browser-data-source.ts +1401 -1401
  52. package/src/data-source/collection-browser-query-state.ts +65 -65
  53. package/src/data-source/models.ts +43 -43
  54. package/src/tiles/base-tile-component.ts +65 -65
  55. package/src/tiles/grid/account-tile.ts +113 -113
  56. package/src/tiles/grid/collection-tile.ts +163 -163
  57. package/src/tiles/grid/item-tile.ts +340 -340
  58. package/src/tiles/list/tile-list-compact.ts +239 -239
  59. package/src/tiles/list/tile-list.ts +700 -700
  60. package/src/tiles/tile-dispatcher.ts +490 -490
  61. package/src/utils/format-date.ts +62 -62
  62. package/test/collection-browser.test.ts +2403 -2403
  63. package/test/tiles/grid/item-tile.test.ts +520 -520
  64. package/test/tiles/list/tile-list-compact.test.ts +282 -282
  65. package/test/tiles/list/tile-list.test.ts +552 -552
  66. package/test/utils/format-date.test.ts +89 -89
  67. package/tsconfig.json +20 -20
  68. package/web-dev-server.config.mjs +30 -30
  69. package/web-test-runner.config.mjs +41 -41
@@ -1,995 +1,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-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-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
+ }