@internetarchive/collection-browser 2.12.1-alpha-webdev5427.6 → 2.12.1

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 (63) hide show
  1. package/.editorconfig +29 -29
  2. package/.husky/pre-commit +4 -4
  3. package/LICENSE +661 -661
  4. package/README.md +83 -83
  5. package/dist/src/app-root.d.ts +0 -1
  6. package/dist/src/app-root.js +2 -48
  7. package/dist/src/app-root.js.map +1 -1
  8. package/dist/src/collection-browser.js +1 -10
  9. package/dist/src/collection-browser.js.map +1 -1
  10. package/dist/src/collection-facets/facet-row.js +1 -7
  11. package/dist/src/collection-facets/facet-row.js.map +1 -1
  12. package/dist/src/collection-facets/more-facets-content.d.ts +0 -1
  13. package/dist/src/collection-facets/more-facets-content.js +4 -19
  14. package/dist/src/collection-facets/more-facets-content.js.map +1 -1
  15. package/dist/src/collection-facets/smart-facets/smart-facet-bar.js +3 -4
  16. package/dist/src/collection-facets/smart-facets/smart-facet-bar.js.map +1 -1
  17. package/dist/src/collection-facets.d.ts +1 -3
  18. package/dist/src/collection-facets.js +7 -37
  19. package/dist/src/collection-facets.js.map +1 -1
  20. package/dist/src/expanded-date-picker.d.ts +0 -1
  21. package/dist/src/expanded-date-picker.js +1 -7
  22. package/dist/src/expanded-date-picker.js.map +1 -1
  23. package/dist/src/models.d.ts +5 -22
  24. package/dist/src/models.js +3 -64
  25. package/dist/src/models.js.map +1 -1
  26. package/dist/src/utils/facet-utils.js +2 -8
  27. package/dist/src/utils/facet-utils.js.map +1 -1
  28. package/dist/src/utils/local-date-from-utc.js +1 -1
  29. package/dist/src/utils/local-date-from-utc.js.map +1 -1
  30. package/dist/test/collection-facets.test.js +0 -27
  31. package/dist/test/collection-facets.test.js.map +1 -1
  32. package/dist/test/restoration-state-handler.test.js +10 -17
  33. package/dist/test/restoration-state-handler.test.js.map +1 -1
  34. package/dist/test/tiles/grid/item-tile.test.js +1 -1
  35. package/dist/test/tiles/grid/item-tile.test.js.map +1 -1
  36. package/dist/test/tiles/list/tile-list-compact.test.js +1 -1
  37. package/dist/test/tiles/list/tile-list-compact.test.js.map +1 -1
  38. package/dist/test/tiles/list/tile-list.test.js +3 -3
  39. package/dist/test/tiles/list/tile-list.test.js.map +1 -1
  40. package/dist/test/utils/local-date-from-utc.test.js +4 -4
  41. package/dist/test/utils/local-date-from-utc.test.js.map +1 -1
  42. package/local.archive.org.cert +86 -86
  43. package/local.archive.org.key +27 -27
  44. package/package.json +4 -4
  45. package/renovate.json +6 -6
  46. package/src/app-root.ts +2 -49
  47. package/src/collection-browser.ts +0 -13
  48. package/src/collection-facets/facet-row.ts +1 -8
  49. package/src/collection-facets/more-facets-content.ts +5 -21
  50. package/src/collection-facets/smart-facets/smart-facet-bar.ts +2 -2
  51. package/src/collection-facets.ts +8 -37
  52. package/src/expanded-date-picker.ts +1 -5
  53. package/src/models.ts +10 -83
  54. package/src/utils/facet-utils.ts +3 -5
  55. package/src/utils/local-date-from-utc.ts +1 -1
  56. package/test/collection-facets.test.ts +0 -33
  57. package/test/restoration-state-handler.test.ts +10 -10
  58. package/test/tiles/grid/item-tile.test.ts +1 -1
  59. package/test/tiles/list/tile-list-compact.test.ts +1 -1
  60. package/test/tiles/list/tile-list.test.ts +3 -3
  61. package/test/utils/local-date-from-utc.test.ts +4 -4
  62. package/web-dev-server.config.mjs +30 -30
  63. package/web-test-runner.config.mjs +41 -41
@@ -32,7 +32,6 @@ import {
32
32
  defaultFacetSort,
33
33
  getDefaultSelectedFacets,
34
34
  FacetEventDetails,
35
- tvChannelFacetLabels,
36
35
  } from '../models';
37
36
  import type {
38
37
  CollectionTitles,
@@ -61,7 +60,7 @@ export class MoreFacetsContent extends LitElement {
61
60
 
62
61
  @property({ type: Object }) filterMap?: FilterMap;
63
62
 
64
- @property({ type: Number }) searchType?: SearchType;
63
+ @property({ type: String }) searchType?: SearchType;
65
64
 
66
65
  @property({ type: Object }) pageSpecifierParams?: PageSpecifierParams;
67
66
 
@@ -84,11 +83,9 @@ export class MoreFacetsContent extends LitElement {
84
83
  */
85
84
  @property({ type: Object }) selectedFacets?: SelectedFacets;
86
85
 
87
- @property({ type: Number }) sortedBy: AggregationSortType =
86
+ @property({ type: String }) sortedBy: AggregationSortType =
88
87
  AggregationSortType.COUNT;
89
88
 
90
- @property({ type: Boolean }) isTvSearch = false;
91
-
92
89
  @property({ type: Object }) modalManager?: ModalManagerInterface;
93
90
 
94
91
  @property({ type: Object }) searchService?: SearchServiceInterface;
@@ -112,8 +109,7 @@ export class MoreFacetsContent extends LitElement {
112
109
  * eventually merged into the existing `selectedFacets` when the patron applies
113
110
  * their changes, or discarded if they cancel/close the dialog.
114
111
  */
115
- @state() private unappliedFacetChanges: SelectedFacets =
116
- getDefaultSelectedFacets();
112
+ @state() private unappliedFacetChanges = getDefaultSelectedFacets();
117
113
 
118
114
  /**
119
115
  * Which page of facets we are showing.
@@ -276,25 +272,13 @@ export class MoreFacetsContent extends LitElement {
276
272
  // Apply any unapplied selections that appear on this page
277
273
  const unappliedBuckets = this.unappliedFacetChanges[this.facetKey];
278
274
  for (const [index, bucket] of bucketsWithCount.entries()) {
279
- const unappliedBucket = unappliedBuckets?.[bucket.key];
275
+ const unappliedBucket = unappliedBuckets[bucket.key];
280
276
  if (unappliedBucket) {
281
277
  bucketsWithCount[index] = { ...unappliedBucket };
282
278
  }
283
279
  }
284
-
285
- // For TV creator facets, uppercase the display text
286
- if (this.facetKey === 'creator' && this.isTvSearch) {
287
- bucketsWithCount.forEach(b => {
288
- b.displayText = (b.displayText ?? b.key)?.toLocaleUpperCase();
289
-
290
- const channelLabel = tvChannelFacetLabels[b.displayText];
291
- if (channelLabel && channelLabel !== b.displayText) {
292
- b.extraNote = `(${channelLabel})`;
293
- }
294
- });
295
- }
296
-
297
280
  facetGroup.buckets = bucketsWithCount;
281
+
298
282
  return facetGroup;
299
283
  }
300
284
 
@@ -202,7 +202,7 @@ export class SmartFacetBar extends LitElement {
202
202
  if (
203
203
  key === 'mediatype' &&
204
204
  this.selectedFacets &&
205
- Object.values(this.selectedFacets.mediatype ?? {}).some(
205
+ Object.values(this.selectedFacets.mediatype).some(
206
206
  bucket => bucket.state !== 'none',
207
207
  )
208
208
  ) {
@@ -213,7 +213,7 @@ export class SmartFacetBar extends LitElement {
213
213
  const buckets = agg.buckets as Bucket[];
214
214
 
215
215
  const unusedBuckets = buckets.filter(b => {
216
- const selectedFacetBucket = this.selectedFacets?.[facetType]?.[b.key];
216
+ const selectedFacetBucket = this.selectedFacets?.[facetType][b.key];
217
217
  if (selectedFacetBucket && selectedFacetBucket.state !== 'none') {
218
218
  return false;
219
219
  }
@@ -11,7 +11,7 @@ import { map } from 'lit/directives/map.js';
11
11
  import { ref } from 'lit/directives/ref.js';
12
12
  import { msg } from '@lit/localize';
13
13
  import { classMap } from 'lit/directives/class-map.js';
14
- import {
14
+ import type {
15
15
  Aggregation,
16
16
  AggregationSortType,
17
17
  Bucket,
@@ -36,7 +36,7 @@ import {
36
36
  SelectedFacets,
37
37
  FacetGroup,
38
38
  FacetBucket,
39
- defaultFacetDisplayOrder,
39
+ facetDisplayOrder,
40
40
  facetTitles,
41
41
  lendingFacetDisplayNames,
42
42
  lendingFacetKeysVisibility,
@@ -44,7 +44,6 @@ import {
44
44
  suppressedCollections,
45
45
  defaultFacetSort,
46
46
  FacetEventDetails,
47
- tvChannelFacetLabels,
48
47
  } from './models';
49
48
  import type {
50
49
  CollectionTitles,
@@ -69,7 +68,7 @@ import {
69
68
  export class CollectionFacets extends LitElement {
70
69
  @property({ type: Object }) searchService?: SearchServiceInterface;
71
70
 
72
- @property({ type: Number }) searchType?: SearchType;
71
+ @property({ type: String }) searchType?: SearchType;
73
72
 
74
73
  @property({ type: Object }) aggregations?: Record<string, Aggregation>;
75
74
 
@@ -109,11 +108,6 @@ export class CollectionFacets extends LitElement {
109
108
 
110
109
  @property({ type: Boolean }) isManageView = false;
111
110
 
112
- @property({ type: Boolean }) isTvSearch = false;
113
-
114
- @property({ type: Array }) facetDisplayOrder: FacetOption[] =
115
- defaultFacetDisplayOrder;
116
-
117
111
  @property({ type: Object, attribute: false })
118
112
  modalManager?: ModalManagerInterface;
119
113
 
@@ -140,9 +134,6 @@ export class CollectionFacets extends LitElement {
140
134
  creator: false,
141
135
  collection: false,
142
136
  year: false,
143
- program: false,
144
- person: false,
145
- sponsor: false,
146
137
  };
147
138
 
148
139
  /**
@@ -236,7 +227,6 @@ export class CollectionFacets extends LitElement {
236
227
  const minDate = fullYearsHistogramAggregation?.first_bucket_key;
237
228
  const maxDate = fullYearsHistogramAggregation?.last_bucket_key;
238
229
  const buckets = fullYearsHistogramAggregation?.buckets as number[];
239
- const dateFormat = this.isTvSearch ? 'YYYY-MM' : 'YYYY';
240
230
 
241
231
  // Because the modal manager does not clear its DOM content after being closed,
242
232
  // it may try to render the exact same date picker template when it is reopened.
@@ -261,7 +251,6 @@ export class CollectionFacets extends LitElement {
261
251
  .maxDate=${maxDate}
262
252
  .minSelectedDate=${this.minSelectedDate}
263
253
  .maxSelectedDate=${this.maxSelectedDate}
264
- .dateFormat=${dateFormat}
265
254
  .buckets=${buckets}
266
255
  .modalManager=${this.modalManager}
267
256
  .analyticsHandler=${this.analyticsHandler}
@@ -275,7 +264,7 @@ export class CollectionFacets extends LitElement {
275
264
  headerColor: '#194880',
276
265
  showHeaderLogo: false,
277
266
  closeOnBackdropClick: true, // TODO: want to fire analytics
278
- title: html`${msg('Select a date range')}`,
267
+ title: html`Select a date range`,
279
268
  });
280
269
 
281
270
  this.modalManager?.classList.add('expanded-date-picker');
@@ -330,18 +319,15 @@ export class CollectionFacets extends LitElement {
330
319
  const { fullYearsHistogramAggregation } = this;
331
320
  const minDate = fullYearsHistogramAggregation?.first_bucket_key;
332
321
  const maxDate = fullYearsHistogramAggregation?.last_bucket_key;
333
- const dateFormat = this.isTvSearch ? 'YYYY-MM' : 'YYYY';
334
322
  return this.fullYearAggregationLoading
335
323
  ? html`<div class="histogram-loading-indicator">&hellip;</div>` // Ellipsis block
336
324
  : html`
337
325
  <histogram-date-range
338
- class=${this.isTvSearch ? 'wide-inputs' : nothing}
339
326
  .minDate=${minDate}
340
327
  .maxDate=${maxDate}
341
328
  .minSelectedDate=${this.minSelectedDate ?? minDate}
342
329
  .maxSelectedDate=${this.maxSelectedDate ?? maxDate}
343
330
  .updateDelay=${100}
344
- .dateFormat=${dateFormat}
345
331
  missingDataMessage="..."
346
332
  .width=${this.collapsableFacets && this.contentWidth
347
333
  ? this.contentWidth
@@ -377,7 +363,7 @@ export class CollectionFacets extends LitElement {
377
363
  private get mergedFacets(): FacetGroup[] {
378
364
  const facetGroups: FacetGroup[] = [];
379
365
 
380
- this.facetDisplayOrder.forEach(facetKey => {
366
+ facetDisplayOrder.forEach(facetKey => {
381
367
  const selectedFacetGroup = this.selectedFacetGroups.find(
382
368
  group => group.key === facetKey,
383
369
  );
@@ -439,7 +425,7 @@ export class CollectionFacets extends LitElement {
439
425
  }
440
426
 
441
427
  // Sort the FacetBuckets so that selected and hidden buckets come before the rest
442
- sortBucketsBySelectionState(bucketsWithCount, defaultFacetSort[facetKey]);
428
+ sortBucketsBySelectionState(bucketsWithCount);
443
429
 
444
430
  // For mediatype facets, ensure the collection bucket is always shown if present
445
431
  if (facetKey === 'mediatype') {
@@ -462,18 +448,6 @@ export class CollectionFacets extends LitElement {
462
448
  }
463
449
  }
464
450
 
465
- // For TV creator facets, uppercase the display text
466
- if (facetKey === 'creator' && this.isTvSearch) {
467
- bucketsWithCount.forEach(b => {
468
- b.displayText = (b.displayText ?? b.key)?.toLocaleUpperCase();
469
-
470
- const channelLabel = tvChannelFacetLabels[b.displayText];
471
- if (channelLabel && channelLabel !== b.displayText) {
472
- b.extraNote = `(${channelLabel})`;
473
- }
474
- });
475
- }
476
-
477
451
  // slice off how many items we want to show in page facet area
478
452
  facetGroup.buckets = bucketsWithCount.slice(0, allowedFacetCount);
479
453
 
@@ -705,7 +679,6 @@ export class CollectionFacets extends LitElement {
705
679
  .collectionTitles=${this.collectionTitles}
706
680
  .selectedFacets=${this.selectedFacets}
707
681
  .sortedBy=${sortedBy}
708
- .isTvSearch=${this.isTvSearch}
709
682
  @facetsChanged=${(e: CustomEvent) => {
710
683
  const event = new CustomEvent<SelectedFacets>('facetsChanged', {
711
684
  detail: e.detail,
@@ -847,6 +820,8 @@ export class CollectionFacets extends LitElement {
847
820
 
848
821
  h3 {
849
822
  font-size: 1.4rem;
823
+ font-weight: 200
824
+ padding-bottom: 3px;
850
825
  margin: 0;
851
826
  }
852
827
 
@@ -883,10 +858,6 @@ export class CollectionFacets extends LitElement {
883
858
  height: 15px;
884
859
  cursor: pointer;
885
860
  }
886
-
887
- histogram-date-range.wide-inputs {
888
- --histogramDateRangeInputWidth: 4.8rem;
889
- }
890
861
  `,
891
862
  ];
892
863
  }
@@ -1,6 +1,5 @@
1
1
  import { css, html, LitElement, CSSResultGroup, TemplateResult } from 'lit';
2
2
  import { customElement, property } from 'lit/decorators.js';
3
- import { msg } from '@lit/localize';
4
3
  import type { ModalManagerInterface } from '@internetarchive/modal-manager';
5
4
  import type { AnalyticsManagerInterface } from '@internetarchive/analytics-manager';
6
5
  import {
@@ -20,8 +19,6 @@ export class ExpandedDatePicker extends LitElement {
20
19
 
21
20
  @property({ type: Array }) buckets?: number[];
22
21
 
23
- @property({ type: String }) dateFormat: string = 'YYYY';
24
-
25
22
  @property({ type: Object, attribute: false })
26
23
  modalManager?: ModalManagerInterface;
27
24
 
@@ -37,7 +34,6 @@ export class ExpandedDatePicker extends LitElement {
37
34
  .maxDate=${this.maxDate}
38
35
  .minSelectedDate=${this.minSelectedDate ?? this.minDate}
39
36
  .maxSelectedDate=${this.maxSelectedDate ?? this.maxDate}
40
- .dateFormat=${this.dateFormat}
41
37
  .updateDelay=${0}
42
38
  updateWhileFocused
43
39
  missingDataMessage="..."
@@ -51,7 +47,7 @@ export class ExpandedDatePicker extends LitElement {
51
47
  slot="inputs-right-side"
52
48
  @click=${this.applyBtnClicked}
53
49
  >
54
- ${msg('Apply date range')}
50
+ Apply date range
55
51
  </button>
56
52
  </histogram-date-range>
57
53
  </div>
package/src/models.ts CHANGED
@@ -530,24 +530,18 @@ export type FacetOption =
530
530
  | 'language'
531
531
  | 'creator'
532
532
  | 'collection'
533
- | 'year'
534
- // TV-specific facet options:
535
- | 'program'
536
- | 'person'
537
- | 'sponsor';
533
+ | 'year';
538
534
 
539
535
  export type SelectedFacetState = 'selected' | 'hidden';
540
536
 
541
537
  export type FacetState = SelectedFacetState | 'none';
542
538
 
543
539
  export interface FacetBucket {
540
+ // for some facets, we augment the key with a display value
541
+ displayText?: string;
544
542
  key: string;
545
543
  count: number;
546
544
  state: FacetState;
547
- // for some facets, we augment the key with a display value
548
- displayText?: string;
549
- // for TV channel facets, we add a parenthesized secondary name
550
- extraNote?: string;
551
545
  }
552
546
 
553
547
  export interface FacetGroup {
@@ -577,11 +571,12 @@ export type FacetEventDetails = {
577
571
 
578
572
  export type FacetValue = string;
579
573
 
580
- export type SelectedFacets = Partial<
581
- Record<FacetOption, Record<FacetValue, FacetBucket>>
574
+ export type SelectedFacets = Record<
575
+ FacetOption,
576
+ Record<FacetValue, FacetBucket>
582
577
  >;
583
578
 
584
- export const getDefaultSelectedFacets = (): Required<SelectedFacets> => ({
579
+ export const getDefaultSelectedFacets = (): SelectedFacets => ({
585
580
  subject: {},
586
581
  lending: {},
587
582
  mediatype: {},
@@ -589,15 +584,9 @@ export const getDefaultSelectedFacets = (): Required<SelectedFacets> => ({
589
584
  creator: {},
590
585
  collection: {},
591
586
  year: {},
592
- program: {},
593
- person: {},
594
- sponsor: {},
595
587
  });
596
588
 
597
- /**
598
- * Facet display order when presenting results for all search types *except* TV (see below).
599
- */
600
- export const defaultFacetDisplayOrder: FacetOption[] = [
589
+ export const facetDisplayOrder: FacetOption[] = [
601
590
  'mediatype',
602
591
  // 'lending', Commenting this out removes the lending facet from the sidebar for now
603
592
  'year',
@@ -607,23 +596,6 @@ export const defaultFacetDisplayOrder: FacetOption[] = [
607
596
  'language',
608
597
  ];
609
598
 
610
- /**
611
- * Specialized facet ordering when displaying TV search results
612
- */
613
- export const tvFacetDisplayOrder: FacetOption[] = [
614
- 'program',
615
- 'creator',
616
- 'year',
617
- 'subject',
618
- 'collection',
619
- 'person',
620
- 'sponsor',
621
- 'language',
622
- ];
623
-
624
- /**
625
- * Human-readable titles for each facet group.
626
- */
627
599
  export const facetTitles: Record<FacetOption, string> = {
628
600
  subject: 'Subject',
629
601
  lending: 'Availability',
@@ -632,9 +604,6 @@ export const facetTitles: Record<FacetOption, string> = {
632
604
  creator: 'Creator',
633
605
  collection: 'Collection',
634
606
  year: 'Year',
635
- program: 'Program',
636
- person: 'Person',
637
- sponsor: 'Sponsor',
638
607
  };
639
608
 
640
609
  /**
@@ -647,10 +616,7 @@ export const defaultFacetSort: Record<FacetOption, AggregationSortType> = {
647
616
  language: AggregationSortType.COUNT,
648
617
  creator: AggregationSortType.COUNT,
649
618
  collection: AggregationSortType.COUNT,
650
- year: AggregationSortType.NUMERIC, // Year facets are ordered by their numeric value by default
651
- program: AggregationSortType.COUNT,
652
- person: AggregationSortType.COUNT,
653
- sponsor: AggregationSortType.COUNT,
619
+ year: AggregationSortType.NUMERIC,
654
620
  };
655
621
 
656
622
  /**
@@ -664,48 +630,9 @@ export const valueFacetSort: Record<FacetOption, AggregationSortType> = {
664
630
  language: AggregationSortType.ALPHABETICAL,
665
631
  creator: AggregationSortType.ALPHABETICAL,
666
632
  collection: AggregationSortType.ALPHABETICAL,
667
- year: AggregationSortType.NUMERIC, // Year facets' values should be compared numerically, not lexicographically (year 2001 > year 3)
668
- program: AggregationSortType.ALPHABETICAL,
669
- person: AggregationSortType.ALPHABETICAL,
670
- sponsor: AggregationSortType.ALPHABETICAL,
633
+ year: AggregationSortType.NUMERIC,
671
634
  };
672
635
 
673
- /**
674
- * Extra parenthesized labels to show next to certain TV channel facets
675
- *
676
- * TODO this is temporary for testing
677
- */
678
- export const tvChannelFacetLabels: Record<string, string> = Object.fromEntries(
679
- Object.entries({
680
- 'Al Jazeera': ['ALJAZAM', 'ALJAZ'],
681
- Bloomberg: ['BLOOMBERG'],
682
- BBC: ['BBC', 'BBC1', 'BBC2'],
683
- 'BBC America': ['BBCAMERICA'],
684
- 'BBC News': ['BBCNEWS'],
685
- 'GB News': ['GBN'],
686
- BET: ['BETW'],
687
- CNBC: ['CNBC'],
688
- CNN: ['CNNW', 'CNN'],
689
- 'Comedy Central': ['COM', 'COMW'],
690
- CSPAN: ['CSPAN', 'CSPAN2', 'CSPAN3'],
691
- Current: ['CURRENT'],
692
- 'Deutsche Welle': ['DW'],
693
- 'France 24': ['FRANCE24'],
694
- 'FOX Business': ['FBC'],
695
- 'FOX News': ['FOXNEWSW', 'FOXNEWS'],
696
- LINKTV: ['LINKTV'],
697
- MSNBC: ['MSNBCW', 'MSNBC'],
698
- 'NHK World': ['NHK'],
699
- RT: ['RT'],
700
- 'Sky News': ['SKY'],
701
- })
702
- .map(e => e.reverse() as [string[], string])
703
- .reduce(
704
- (acc, cur) => acc.concat(cur[0].map(n => [n, cur[1]])),
705
- [] as [string, string][],
706
- ),
707
- );
708
-
709
636
  export type LendingFacetKey =
710
637
  | 'is_lendable'
711
638
  | 'is_borrowable'
@@ -62,7 +62,7 @@ export function updateSelectedFacetBucket(
62
62
  omitNoneState = false,
63
63
  ): SelectedFacets {
64
64
  const defaultedSelectedFacets = selectedFacets ?? getDefaultSelectedFacets();
65
- const newFacets: SelectedFacets = {
65
+ const newFacets = {
66
66
  ...defaultedSelectedFacets,
67
67
  [facetType]: {
68
68
  ...defaultedSelectedFacets[facetType],
@@ -71,7 +71,7 @@ export function updateSelectedFacetBucket(
71
71
  };
72
72
 
73
73
  if (omitNoneState && bucket.state === 'none') {
74
- delete newFacets[facetType]?.[bucket.key];
74
+ delete newFacets[facetType][bucket.key];
75
75
  }
76
76
 
77
77
  return newFacets;
@@ -93,7 +93,6 @@ export function cloneSelectedFacets(
93
93
  ): SelectedFacets {
94
94
  const cloneResult = getDefaultSelectedFacets();
95
95
  forEachFacetBucket(selectedFacets, (facetType, bucketKey, bucket) => {
96
- if (!cloneResult[facetType]) cloneResult[facetType] = {};
97
96
  cloneResult[facetType][bucketKey] = bucket;
98
97
  });
99
98
  return cloneResult;
@@ -125,14 +124,13 @@ export function mergeSelectedFacets(
125
124
  ): SelectedFacets {
126
125
  const mergeResult = cloneSelectedFacets(destination);
127
126
  forEachFacetBucket(source, (facetType, bucketKey, bucket) => {
128
- if (!mergeResult[facetType]) mergeResult[facetType] = {};
129
127
  mergeResult[facetType][bucketKey] = bucket;
130
128
  });
131
129
 
132
130
  // Normalize any 'none' states on the result (from either source or destination)
133
131
  forEachFacetBucket(mergeResult, (facetType, bucketKey, bucket) => {
134
132
  if (bucket.state === 'none') {
135
- delete mergeResult[facetType]?.[bucketKey];
133
+ delete mergeResult[facetType][bucketKey];
136
134
  }
137
135
  });
138
136
 
@@ -11,5 +11,5 @@ export function localDateFromUTC(date: Date): Date {
11
11
  */
12
12
  export function isFirstMillisecondOfUTCYear(date?: Date): boolean {
13
13
  if (!date) return false;
14
- return localDateFromUTC(date).toISOString().endsWith('-01-01T00:00:00.000Z');
14
+ return date.toISOString().endsWith('-01-01T00:00:00.000Z');
15
15
  }
@@ -629,39 +629,6 @@ describe('Collection Facets', () => {
629
629
  expect(facetRows?.[7]?.bucket?.key).to.equal('collection');
630
630
  });
631
631
 
632
- it('uses specified facet display order', async () => {
633
- const el = await fixture<CollectionFacets>(
634
- html`<collection-facets
635
- .facetDisplayOrder=${['language', 'creator'] as FacetOption[]}
636
- ></collection-facets>`,
637
- );
638
-
639
- const aggs: Record<string, Aggregation> = {
640
- mediatype: new Aggregation({
641
- buckets: [{ key: 'texts', doc_count: 5 }],
642
- }),
643
- collection: new Aggregation({
644
- buckets: [{ key: 'foo', doc_count: 10 }],
645
- }),
646
- creator: new Aggregation({
647
- buckets: [{ key: 'bar', doc_count: 15 }],
648
- }),
649
- language: new Aggregation({
650
- buckets: [{ key: 'baz', doc_count: 20 }],
651
- }),
652
- };
653
-
654
- el.aggregations = aggs;
655
- await el.updateComplete;
656
-
657
- const facetHeaders = el.shadowRoot?.querySelectorAll('.facet-group-header');
658
-
659
- // The only two facet groups should be Language and Creator (in that order)
660
- expect(facetHeaders?.length).to.equal(2);
661
- expect(facetHeaders?.[0].textContent).to.contain('Language');
662
- expect(facetHeaders?.[1].textContent).to.contain('Creator');
663
- });
664
-
665
632
  describe('More Facets', () => {
666
633
  it('Does not render < allowedFacetCount', async () => {
667
634
  const el = await fixture<CollectionFacets>(
@@ -100,7 +100,7 @@ describe('Restoration state handler', () => {
100
100
  window.history.replaceState({ path: url.href }, '', url.href);
101
101
 
102
102
  const restorationState = handler.getRestorationState();
103
- expect(restorationState.selectedFacets.year?.['2018'].state).to.equal(
103
+ expect(restorationState.selectedFacets.year['2018'].state).to.equal(
104
104
  'selected',
105
105
  );
106
106
  });
@@ -160,7 +160,7 @@ describe('Restoration state handler', () => {
160
160
  window.history.replaceState({ path: url.href }, '', url.href);
161
161
 
162
162
  const restorationState = handler.getRestorationState();
163
- expect(restorationState.selectedFacets.subject?.foo.state).to.equal(
163
+ expect(restorationState.selectedFacets.subject.foo.state).to.equal(
164
164
  'selected',
165
165
  );
166
166
  });
@@ -173,7 +173,7 @@ describe('Restoration state handler', () => {
173
173
  window.history.replaceState({ path: url.href }, '', url.href);
174
174
 
175
175
  const restorationState = handler.getRestorationState();
176
- expect(restorationState.selectedFacets.year?.['2018'].state).to.equal(
176
+ expect(restorationState.selectedFacets.year['2018'].state).to.equal(
177
177
  'hidden',
178
178
  );
179
179
  });
@@ -188,17 +188,17 @@ describe('Restoration state handler', () => {
188
188
 
189
189
  const restorationState = handler.getRestorationState();
190
190
 
191
- expect(restorationState.selectedFacets.collection?.foo.state).to.equal(
191
+ expect(restorationState.selectedFacets.collection.foo.state).to.equal(
192
192
  'selected',
193
193
  );
194
- expect(restorationState.selectedFacets.collection?.bar.state).to.equal(
194
+ expect(restorationState.selectedFacets.collection.bar.state).to.equal(
195
195
  'selected',
196
196
  );
197
197
 
198
- expect(restorationState.selectedFacets.collection?.baz.state).to.equal(
198
+ expect(restorationState.selectedFacets.collection.baz.state).to.equal(
199
199
  'hidden',
200
200
  );
201
- expect(restorationState.selectedFacets.collection?.boop.state).to.equal(
201
+ expect(restorationState.selectedFacets.collection.boop.state).to.equal(
202
202
  'hidden',
203
203
  );
204
204
  });
@@ -211,7 +211,7 @@ describe('Restoration state handler', () => {
211
211
  window.history.replaceState({ path: url.href }, '', url.href);
212
212
 
213
213
  const restorationState = handler.getRestorationState();
214
- expect(restorationState.selectedFacets.collection?.foo.state).to.equal(
214
+ expect(restorationState.selectedFacets.collection.foo.state).to.equal(
215
215
  'hidden',
216
216
  );
217
217
  });
@@ -224,7 +224,7 @@ describe('Restoration state handler', () => {
224
224
  window.history.replaceState({ path: url.href }, '', url.href);
225
225
 
226
226
  const restorationState = handler.getRestorationState();
227
- expect(restorationState.selectedFacets.subject?.foo.state).to.equal(
227
+ expect(restorationState.selectedFacets.subject.foo.state).to.equal(
228
228
  'selected',
229
229
  );
230
230
  });
@@ -237,7 +237,7 @@ describe('Restoration state handler', () => {
237
237
  window.history.replaceState({ path: url.href }, '', url.href);
238
238
 
239
239
  const restorationState = handler.getRestorationState();
240
- expect(restorationState.selectedFacets.year?.['2018'].state).to.equal(
240
+ expect(restorationState.selectedFacets.year['2018'].state).to.equal(
241
241
  'hidden',
242
242
  );
243
243
  });
@@ -247,7 +247,7 @@ describe('Item Tile', () => {
247
247
 
248
248
  it('should only show the year for a date published of Jan 1 at midnight UTC', async () => {
249
249
  const model: Partial<TileModel> = {
250
- datePublished: new Date(2012, 0, 1, 0, 0, 0, 0),
250
+ datePublished: new Date('2012-01-01T00:00:00Z'),
251
251
  };
252
252
 
253
253
  const el = await fixture<ItemTile>(html`
@@ -161,7 +161,7 @@ describe('List Tile Compact', () => {
161
161
 
162
162
  it('should only show the year for a date published of Jan 1 at midnight UTC', async () => {
163
163
  const model: Partial<TileModel> = {
164
- datePublished: new Date(2012, 0, 1, 0, 0, 0, 0),
164
+ datePublished: new Date('2012-01-01T00:00:00Z'),
165
165
  };
166
166
 
167
167
  const el = await fixture<TileListCompact>(html`
@@ -216,9 +216,9 @@ describe('List Tile', () => {
216
216
  expect(dateRow?.textContent?.trim()).to.contain('Reviewed: Jan 02, 2013');
217
217
  });
218
218
 
219
- it('should only show the year for a date published of Jan 1 at midnight', async () => {
219
+ it('should only show the year for a date published of Jan 1 at midnight UTC', async () => {
220
220
  const model: Partial<TileModel> = {
221
- datePublished: new Date(2012, 0, 1, 0, 0, 0, 0),
221
+ datePublished: new Date('2012-01-01T00:00:00Z'),
222
222
  };
223
223
 
224
224
  const el = await fixture<TileList>(html`
@@ -234,7 +234,7 @@ describe('List Tile', () => {
234
234
  expect(dateRow?.textContent?.trim()).to.contain('Published: 2012');
235
235
  });
236
236
 
237
- it('should show full date added/archived/reviewed, even on Jan 1 at midnight', async () => {
237
+ it('should show full date added/archived/reviewed, even on Jan 1 at midnight UTC', async () => {
238
238
  const model: Partial<TileModel> = {
239
239
  dateAdded: new Date(2010, 0, 1, 0, 0, 0, 0),
240
240
  dateArchived: new Date(2011, 0, 1, 0, 0, 0, 0),
@@ -16,18 +16,18 @@ describe('localDateFromUTC', () => {
16
16
 
17
17
  describe('isFirstMillisecondOfUTCYear', () => {
18
18
  it('returns true when date is exactly Jan 1 at midnight in UTC', async () => {
19
- const midnightOnNewYearsDay = new Date(2010, 0, 1, 0, 0, 0, 0);
19
+ const midnightOnNewYearsDay = new Date('2010-01-01T00:00:00Z');
20
20
  expect(isFirstMillisecondOfUTCYear(midnightOnNewYearsDay)).to.be.true;
21
21
  });
22
22
 
23
23
  it('returns false when date is not exactly Jan 1 at midnight in UTC', async () => {
24
- const oneMillisecondTooEarly = new Date(2009, 11, 31, 23, 59, 59, 999);
24
+ const oneMillisecondTooEarly = new Date('2009-12-31T23:59:59.999Z');
25
25
  expect(isFirstMillisecondOfUTCYear(oneMillisecondTooEarly)).to.be.false;
26
26
 
27
- const oneMillisecondTooLate = new Date(2010, 0, 1, 0, 0, 0, 1);
27
+ const oneMillisecondTooLate = new Date('2010-01-01T00:00:00.001Z');
28
28
  expect(isFirstMillisecondOfUTCYear(oneMillisecondTooLate)).to.be.false;
29
29
 
30
- const middleOfTheYear = new Date(2010, 6, 1, 0, 0, 0, 0);
30
+ const middleOfTheYear = new Date('2010-06-01T00:00:00Z');
31
31
  expect(isFirstMillisecondOfUTCYear(middleOfTheYear)).to.be.false;
32
32
  });
33
33