@internetarchive/collection-browser 4.1.2-alpha9 → 4.1.3-alpha-webdev8108.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/.claude/settings.local.json +11 -0
  2. package/.editorconfig +29 -29
  3. package/.github/workflows/ci.yml +27 -27
  4. package/.github/workflows/gh-pages-main.yml +39 -39
  5. package/.github/workflows/npm-publish.yml +39 -39
  6. package/.github/workflows/pr-preview.yml +38 -38
  7. package/.husky/pre-commit +1 -1
  8. package/.prettierignore +1 -1
  9. package/LICENSE +661 -661
  10. package/README.md +83 -83
  11. package/dist/src/app-root.js +1 -4
  12. package/dist/src/app-root.js.map +1 -1
  13. package/dist/src/collection-browser.js +30 -34
  14. package/dist/src/collection-browser.js.map +1 -1
  15. package/dist/src/data-source/collection-browser-data-source.js +3 -2
  16. package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
  17. package/dist/src/models.js.map +1 -1
  18. package/dist/src/tiles/hover/hover-pane-controller.js +30 -29
  19. package/dist/src/tiles/hover/hover-pane-controller.js.map +1 -1
  20. package/dist/src/tiles/tile-dispatcher.d.ts +6 -0
  21. package/dist/src/tiles/tile-dispatcher.js +224 -216
  22. package/dist/src/tiles/tile-dispatcher.js.map +1 -1
  23. package/dist/src/tiles/tile-display-value-provider.js.map +1 -1
  24. package/dist/test/mocks/mock-search-responses.js.map +1 -1
  25. package/dist/test/tiles/grid/item-tile.test.js +77 -77
  26. package/dist/test/tiles/grid/item-tile.test.js.map +1 -1
  27. package/dist/test/tiles/list/tile-list.test.js +126 -126
  28. package/dist/test/tiles/list/tile-list.test.js.map +1 -1
  29. package/dist/test/tiles/tile-dispatcher.test.js +94 -80
  30. package/dist/test/tiles/tile-dispatcher.test.js.map +1 -1
  31. package/dist/test/tiles/tile-display-value-provider.test.js.map +1 -1
  32. package/eslint.config.mjs +53 -53
  33. package/index.html +24 -24
  34. package/local.archive.org.cert +86 -86
  35. package/local.archive.org.key +27 -27
  36. package/package.json +120 -121
  37. package/renovate.json +6 -6
  38. package/src/app-root.ts +1 -4
  39. package/src/collection-browser.ts +41 -44
  40. package/src/data-source/collection-browser-data-source.ts +1445 -1444
  41. package/src/models.ts +874 -874
  42. package/src/tiles/hover/hover-pane-controller.ts +628 -627
  43. package/src/tiles/tile-dispatcher.ts +527 -518
  44. package/src/tiles/tile-display-value-provider.ts +124 -124
  45. package/test/mocks/mock-search-responses.ts +1364 -1364
  46. package/test/tiles/grid/item-tile.test.ts +520 -520
  47. package/test/tiles/list/tile-list.test.ts +552 -552
  48. package/test/tiles/tile-dispatcher.test.ts +300 -283
  49. package/test/tiles/tile-display-value-provider.test.ts +172 -172
  50. package/tsconfig.json +25 -25
  51. package/web-dev-server.config.mjs +30 -30
  52. package/web-test-runner.config.mjs +52 -52
package/src/app-root.ts CHANGED
@@ -510,10 +510,7 @@ export class AppRoot extends LitElement {
510
510
  .loggedIn=${this.loggedIn}
511
511
  .modalManager=${this.modalManager}
512
512
  .analyticsHandler=${this.analyticsHandler}
513
- .pageContext=${'profile'}
514
- .pageType=${'account_details'}
515
- .pageTarget=${'fav-neeraj_archive341'}
516
- .profileElement=${'favorites'}
513
+ .pageContext=${'search'}
517
514
  @visiblePageChanged=${this.visiblePageChanged}
518
515
  @baseQueryChanged=${this.baseQueryChanged}
519
516
  @searchTypeChanged=${this.searchTypeChanged}
@@ -605,6 +605,43 @@ export class CollectionBrowser
605
605
  if (changed.has('searchType') && this.searchType === SearchType.TV) {
606
606
  this.applyDefaultTVSearchSort();
607
607
  }
608
+
609
+ // If we need to clear filters due to a query change or other reset, we do so *before* any
610
+ // updates happen, to prevent unnecessary update cycles and ensure there's a clean slate
611
+ // for any search requests that fire.
612
+ if (
613
+ changed.has('baseQuery') ||
614
+ changed.has('identifiers') ||
615
+ changed.has('searchType') ||
616
+ changed.has('withinCollection')
617
+ ) {
618
+ // Unless this query/search type update is from the initial page load or the
619
+ // result of hitting the back button,
620
+ // we need to clear any existing filters since they may no longer be valid for
621
+ // the new set of search results.
622
+ if (!this.historyPopOccurred && this.initialQueryChangeHappened) {
623
+ // Ordinarily, we leave the sort param unchanged between searches.
624
+ // However, if we are changing the target collection itself, we want the sort cleared too,
625
+ // since different collections may have different sorting options available.
626
+ const shouldClearSort =
627
+ changed.has('withinCollection') &&
628
+ !changed.has('selectedSort') &&
629
+ !changed.has('sortDirection');
630
+
631
+ // Otherwise, only clear filters that haven't been simultaneously applied in this update
632
+ this.clearFilters({
633
+ sort: shouldClearSort,
634
+ facets: !changed.has('selectedFacets'),
635
+ dateRange: !(
636
+ changed.has('minSelectedDate') || changed.has('maxSelectedDate')
637
+ ),
638
+ letterFilters: !(
639
+ changed.has('selectedTitleFilter') ||
640
+ changed.has('selectedCreatorFilter')
641
+ ),
642
+ });
643
+ }
644
+ }
608
645
  }
609
646
 
610
647
  render() {
@@ -860,7 +897,10 @@ export class CollectionBrowser
860
897
  let sortFieldAvailability = defaultSortAvailability;
861
898
 
862
899
  // We adjust the available sort options for a couple of special cases...
863
- if (this.withinCollection?.startsWith('fav-') || this.profileElement === 'favorites') {
900
+ if (
901
+ this.withinCollection?.startsWith('fav-') ||
902
+ this.profileElement === 'favorites'
903
+ ) {
864
904
  // When viewing a fav- collection or the favorites profile tab,
865
905
  // we include the Date Favorited option as the default
866
906
  sortFieldAvailability = favoritesSortAvailability;
@@ -1638,7 +1678,6 @@ export class CollectionBrowser
1638
1678
  this.addController(this.dataSource);
1639
1679
 
1640
1680
  this.baseQuery = queryState.baseQuery;
1641
- this.withinProfile = queryState.withinProfile;
1642
1681
  this.profileElement = queryState.profileElement;
1643
1682
  this.searchType = queryState.searchType;
1644
1683
  this.selectedFacets =
@@ -1651,14 +1690,6 @@ export class CollectionBrowser
1651
1690
  this.selectedTitleFilter = queryState.selectedTitleFilter;
1652
1691
  this.selectedCreatorFilter = queryState.selectedCreatorFilter;
1653
1692
 
1654
- // Apply the correct default sort for the new profile element immediately,
1655
- // so it is in place before hostUpdate() fires on the data source.
1656
- // Without this, a stale defaultSortField from a previously-active tab
1657
- // could be used in the first fetch for the incoming tab.
1658
- if (this.profileElement) {
1659
- this.applyDefaultProfileSort();
1660
- }
1661
-
1662
1693
  this.pagesToRender = this.initialPageNumber;
1663
1694
 
1664
1695
  // We set this flag during the update to prevent the URL state persistence
@@ -1732,40 +1763,6 @@ export class CollectionBrowser
1732
1763
  this.infiniteScroller?.reload();
1733
1764
  }
1734
1765
 
1735
- if (
1736
- changed.has('baseQuery') ||
1737
- changed.has('identifiers') ||
1738
- changed.has('searchType') ||
1739
- changed.has('withinCollection')
1740
- ) {
1741
- // Unless this query/search type update is from the initial page load or the
1742
- // result of hitting the back button,
1743
- // we need to clear any existing filters since they may no longer be valid for
1744
- // the new set of search results.
1745
- if (!this.historyPopOccurred && this.initialQueryChangeHappened) {
1746
- // Ordinarily, we leave the sort param unchanged between searches.
1747
- // However, if we are changing the target collection itself, we want the sort cleared too,
1748
- // since different collections may have different sorting options available.
1749
- const shouldClearSort =
1750
- changed.has('withinCollection') &&
1751
- !changed.has('selectedSort') &&
1752
- !changed.has('sortDirection');
1753
-
1754
- // Otherwise, only clear filters that haven't been simultaneously applied in this update
1755
- this.clearFilters({
1756
- sort: shouldClearSort,
1757
- facets: !changed.has('selectedFacets'),
1758
- dateRange: !(
1759
- changed.has('minSelectedDate') || changed.has('maxSelectedDate')
1760
- ),
1761
- letterFilters: !(
1762
- changed.has('selectedTitleFilter') ||
1763
- changed.has('selectedCreatorFilter')
1764
- ),
1765
- });
1766
- }
1767
- }
1768
-
1769
1766
  if (changed.has('profileElement')) {
1770
1767
  this.applyDefaultProfileSort();
1771
1768
  }