@internetarchive/collection-browser 1.9.1-alpha.2 → 1.10.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 (32) hide show
  1. package/dist/src/collection-browser.d.ts +3 -1
  2. package/dist/src/collection-browser.js +26 -14
  3. package/dist/src/collection-browser.js.map +1 -1
  4. package/dist/src/models.d.ts +1 -0
  5. package/dist/src/models.js +13 -0
  6. package/dist/src/models.js.map +1 -1
  7. package/dist/src/sort-filter-bar/sort-filter-bar.d.ts +7 -0
  8. package/dist/src/sort-filter-bar/sort-filter-bar.js +21 -4
  9. package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
  10. package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js +1 -1
  11. package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js.map +1 -1
  12. package/dist/src/tiles/grid/tile-stats.js +1 -1
  13. package/dist/src/tiles/grid/tile-stats.js.map +1 -1
  14. package/dist/src/tiles/tile-dispatcher.js +1 -5
  15. package/dist/src/tiles/tile-dispatcher.js.map +1 -1
  16. package/dist/test/collection-browser.test.js +19 -0
  17. package/dist/test/collection-browser.test.js.map +1 -1
  18. package/dist/test/mocks/mock-search-responses.d.ts +1 -0
  19. package/dist/test/mocks/mock-search-responses.js +42 -0
  20. package/dist/test/mocks/mock-search-responses.js.map +1 -1
  21. package/dist/test/mocks/mock-search-service.js +2 -1
  22. package/dist/test/mocks/mock-search-service.js.map +1 -1
  23. package/package.json +1 -1
  24. package/src/collection-browser.ts +29 -14
  25. package/src/models.ts +13 -0
  26. package/src/sort-filter-bar/sort-filter-bar.ts +22 -4
  27. package/src/tiles/grid/styles/tile-grid-shared-styles.ts +1 -1
  28. package/src/tiles/grid/tile-stats.ts +1 -1
  29. package/src/tiles/tile-dispatcher.ts +1 -5
  30. package/test/collection-browser.test.ts +25 -0
  31. package/test/mocks/mock-search-responses.ts +46 -0
  32. package/test/mocks/mock-search-service.ts +2 -0
@@ -410,7 +410,9 @@ export declare class CollectionBrowser extends LitElement implements InfiniteScr
410
410
  /**
411
411
  * Applies any default sort option for the current collection, by checking
412
412
  * for one in the collection's metadata. If none is found, defaults to sorting
413
- * descending by weekly views.
413
+ * descending by:
414
+ * - Date Favorited for fav-* collections
415
+ * - Weekly views for all other collections
414
416
  */
415
417
  private applyDefaultCollectionSort;
416
418
  /**
@@ -402,6 +402,7 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
402
402
  });
403
403
  }
404
404
  get sortFilterBarTemplate() {
405
+ var _a;
405
406
  return html `
406
407
  <sort-filter-bar
407
408
  .defaultSortField=${this.defaultSortField}
@@ -409,6 +410,7 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
409
410
  .selectedSort=${this.selectedSort}
410
411
  .sortDirection=${this.sortDirection}
411
412
  .showRelevance=${this.isRelevanceSortAvailable}
413
+ .showDateFavorited=${(_a = this.withinCollection) === null || _a === void 0 ? void 0 : _a.startsWith('fav-')}
412
414
  .displayMode=${this.displayMode}
413
415
  .selectedTitleFilter=${this.selectedTitleFilter}
414
416
  .selectedCreatorFilter=${this.selectedCreatorFilter}
@@ -726,6 +728,9 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
726
728
  if (changed.has('selectedCreatorFilter')) {
727
729
  this.sendFilterByCreatorAnalytics(changed.get('selectedCreatorFilter'));
728
730
  }
731
+ if (changed.has('withinCollection')) {
732
+ this.clearFilters({ sort: true });
733
+ }
729
734
  if (changed.has('baseQuery') ||
730
735
  changed.has('searchType') ||
731
736
  changed.has('selectedTitleFilter') ||
@@ -1413,10 +1418,12 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
1413
1418
  /**
1414
1419
  * Applies any default sort option for the current collection, by checking
1415
1420
  * for one in the collection's metadata. If none is found, defaults to sorting
1416
- * descending by weekly views.
1421
+ * descending by:
1422
+ * - Date Favorited for fav-* collections
1423
+ * - Weekly views for all other collections
1417
1424
  */
1418
1425
  applyDefaultCollectionSort(collectionInfo) {
1419
- var _a, _b;
1426
+ var _a, _b, _c;
1420
1427
  if (this.baseQuery) {
1421
1428
  // If there's a query set, then we default to relevance sorting regardless of
1422
1429
  // the collection metadata-specified sort.
@@ -1424,9 +1431,17 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
1424
1431
  this.defaultSortDirection = null;
1425
1432
  return;
1426
1433
  }
1427
- const defaultSort = (_b = (_a = collectionInfo === null || collectionInfo === void 0 ? void 0 : collectionInfo.public_metadata) === null || _a === void 0 ? void 0 : _a['sort-by']) !== null && _b !== void 0 ? _b : '-week';
1434
+ // Favorite collections sort on Date Favorited by default.
1435
+ // Other collections fall back to sorting on weekly views.
1436
+ const baseDefaultSort = ((_b = (_a = collectionInfo === null || collectionInfo === void 0 ? void 0 : collectionInfo.public_metadata) === null || _a === void 0 ? void 0 : _a.identifier) === null || _b === void 0 ? void 0 : _b.startsWith('fav-'))
1437
+ ? '-favoritedate'
1438
+ : '-week';
1439
+ // The collection metadata may override the default sorting with something else
1440
+ const metadataSort = (_c = collectionInfo === null || collectionInfo === void 0 ? void 0 : collectionInfo.public_metadata) === null || _c === void 0 ? void 0 : _c['sort-by'];
1441
+ // Prefer the metadata-specified sort if one exists
1442
+ const defaultSortToApply = metadataSort !== null && metadataSort !== void 0 ? metadataSort : baseDefaultSort;
1428
1443
  // Account for both -field and field:dir formats
1429
- let [field, dir] = defaultSort.split(':');
1444
+ let [field, dir] = defaultSortToApply.split(':');
1430
1445
  if (field.startsWith('-')) {
1431
1446
  field = field.slice(1);
1432
1447
  dir = 'desc';
@@ -1736,7 +1751,7 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
1736
1751
  padding-left: 1rem;
1737
1752
  padding-right: 1rem;
1738
1753
  margin-top: var(--rightColumnMarginTop, 0);
1739
- background: var(--ia-theme-secondary-background-color, #fff);
1754
+ background: #fff;
1740
1755
  }
1741
1756
 
1742
1757
  .mobile #right-column {
@@ -1798,15 +1813,12 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
1798
1813
  }
1799
1814
 
1800
1815
  #facets-bottom-fade {
1801
- background: var(
1802
- --ia-theme-facet-fade-gradient,
1803
- linear-gradient(
1804
- to bottom,
1805
- #f5f5f700 0%,
1806
- #f5f5f7c0 50%,
1807
- #f5f5f7 80%,
1808
- #f5f5f7 100%
1809
- )
1816
+ background: linear-gradient(
1817
+ to bottom,
1818
+ #f5f5f700 0%,
1819
+ #f5f5f7c0 50%,
1820
+ #f5f5f7 80%,
1821
+ #f5f5f7 100%
1810
1822
  );
1811
1823
  position: fixed;
1812
1824
  bottom: 0;