@internetarchive/collection-browser 1.7.1-alpha.0 → 1.9.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 (30) hide show
  1. package/dist/src/collection-browser.js +18 -11
  2. package/dist/src/collection-browser.js.map +1 -1
  3. package/dist/src/collection-facets/more-facets-content.d.ts +1 -0
  4. package/dist/src/collection-facets/more-facets-content.js +9 -2
  5. package/dist/src/collection-facets/more-facets-content.js.map +1 -1
  6. package/dist/src/collection-facets.d.ts +1 -0
  7. package/dist/src/collection-facets.js +4 -0
  8. package/dist/src/collection-facets.js.map +1 -1
  9. package/dist/src/models.d.ts +48 -35
  10. package/dist/src/models.js +139 -78
  11. package/dist/src/models.js.map +1 -1
  12. package/dist/src/restoration-state-handler.d.ts +9 -2
  13. package/dist/src/restoration-state-handler.js +61 -32
  14. package/dist/src/restoration-state-handler.js.map +1 -1
  15. package/dist/src/sort-filter-bar/sort-filter-bar.d.ts +2 -0
  16. package/dist/src/sort-filter-bar/sort-filter-bar.js +30 -25
  17. package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
  18. package/dist/test/collection-facets/more-facets-content.test.js +25 -0
  19. package/dist/test/collection-facets/more-facets-content.test.js.map +1 -1
  20. package/dist/test/restoration-state-handler.test.js +53 -1
  21. package/dist/test/restoration-state-handler.test.js.map +1 -1
  22. package/package.json +3 -3
  23. package/src/collection-browser.ts +16 -8
  24. package/src/collection-facets/more-facets-content.ts +9 -2
  25. package/src/collection-facets.ts +3 -0
  26. package/src/models.ts +193 -109
  27. package/src/restoration-state-handler.ts +66 -40
  28. package/src/sort-filter-bar/sort-filter-bar.ts +34 -27
  29. package/test/collection-facets/more-facets-content.test.ts +35 -0
  30. package/test/restoration-state-handler.test.ts +68 -1
@@ -11,7 +11,7 @@ import './sort-filter-bar/sort-filter-bar';
11
11
  import './collection-facets';
12
12
  import './circular-activity-indicator';
13
13
  import './sort-filter-bar/sort-filter-bar';
14
- import { SortField, SortFieldToMetadataField, getDefaultSelectedFacets, prefixFilterAggregationKeys, MetadataFieldToSortField, } from './models';
14
+ import { SortField, getDefaultSelectedFacets, prefixFilterAggregationKeys, sortOptionFromAPIString, SORT_OPTIONS, } from './models';
15
15
  import { RestorationStateHandler, } from './restoration-state-handler';
16
16
  import chevronIcon from './assets/img/icons/chevron';
17
17
  import './empty-placeholder';
@@ -442,13 +442,19 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
442
442
  });
443
443
  }
444
444
  selectedSortChanged() {
445
- if ([SortField.default, SortField.relevance].includes(this.selectedSort)) {
445
+ var _a;
446
+ const sortOption = SORT_OPTIONS[this.selectedSort];
447
+ if (!sortOption.handledBySearchService) {
446
448
  this.sortParam = null;
447
449
  return;
448
450
  }
449
- const sortField = SortFieldToMetadataField[this.selectedSort];
451
+ // If the sort option specified in the URL is unrecognized, we just use it as-is
452
+ const urlSortParam = new URL(window.location.href).searchParams.get('sort');
453
+ const sortField = (_a = sortOption.searchServiceKey) !== null && _a !== void 0 ? _a : urlSortParam === null || urlSortParam === void 0 ? void 0 : urlSortParam.replace(/^-/, '');
454
+ // If the sort direction is still null at this point, then we assume ascending
455
+ // (i.e., it was unrecognized and had no directional flag)
450
456
  if (!this.sortDirection)
451
- this.sortDirection = 'desc';
457
+ this.sortDirection = 'asc';
452
458
  if (!sortField)
453
459
  return;
454
460
  this.sortParam = { field: sortField, direction: this.sortDirection };
@@ -567,6 +573,7 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
567
573
  @facetsChanged=${this.facetsChanged}
568
574
  @histogramDateRangeUpdated=${this.histogramDateRangeUpdated}
569
575
  .collectionPagePath=${this.collectionPagePath}
576
+ .withinCollection=${this.withinCollection}
570
577
  .searchService=${this.searchService}
571
578
  .featureFeedbackService=${this.featureFeedbackService}
572
579
  .recaptchaManager=${this.recaptchaManager}
@@ -952,22 +959,21 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
952
959
  }
953
960
  }
954
961
  persistState() {
955
- var _a, _b, _c, _d, _e;
962
+ var _a, _b, _c, _d;
956
963
  const restorationState = {
957
964
  displayMode: this.displayMode,
958
965
  searchType: this.searchType,
959
- sortParam: (_a = this.sortParam) !== null && _a !== void 0 ? _a : undefined,
960
966
  selectedSort: this.selectedSort,
961
- sortDirection: (_b = this.sortDirection) !== null && _b !== void 0 ? _b : undefined,
962
- selectedFacets: (_c = this.selectedFacets) !== null && _c !== void 0 ? _c : getDefaultSelectedFacets(),
967
+ sortDirection: (_a = this.sortDirection) !== null && _a !== void 0 ? _a : undefined,
968
+ selectedFacets: (_b = this.selectedFacets) !== null && _b !== void 0 ? _b : getDefaultSelectedFacets(),
963
969
  baseQuery: this.baseQuery,
964
970
  currentPage: this.currentPage,
965
971
  titleQuery: this.titleQuery,
966
972
  creatorQuery: this.creatorQuery,
967
973
  minSelectedDate: this.minSelectedDate,
968
974
  maxSelectedDate: this.maxSelectedDate,
969
- selectedTitleFilter: (_d = this.selectedTitleFilter) !== null && _d !== void 0 ? _d : undefined,
970
- selectedCreatorFilter: (_e = this.selectedCreatorFilter) !== null && _e !== void 0 ? _e : undefined,
975
+ selectedTitleFilter: (_c = this.selectedTitleFilter) !== null && _c !== void 0 ? _c : undefined,
976
+ selectedCreatorFilter: (_d = this.selectedCreatorFilter) !== null && _d !== void 0 ? _d : undefined,
971
977
  };
972
978
  this.restorationStateHandler.persistState(restorationState);
973
979
  }
@@ -1428,7 +1434,8 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
1428
1434
  else if (!['asc', 'desc'].includes(dir)) {
1429
1435
  dir = 'asc';
1430
1436
  }
1431
- const sortField = MetadataFieldToSortField[field];
1437
+ const sortOption = sortOptionFromAPIString(field);
1438
+ const sortField = sortOption.field;
1432
1439
  if (sortField && sortField !== SortField.default) {
1433
1440
  this.defaultSortField = sortField;
1434
1441
  this.defaultSortDirection = dir;