@internetarchive/collection-browser 4.1.1-alpha-webdev8185.0 → 4.1.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.
package/index.ts CHANGED
@@ -6,15 +6,10 @@ export { SortFilterBar } from './src/sort-filter-bar/sort-filter-bar';
6
6
  export {
7
7
  CollectionDisplayMode,
8
8
  SortField,
9
- ExplicitSortField,
10
9
  TileModel,
11
10
  FacetOption,
12
11
  SelectedFacets,
13
12
  getDefaultSelectedFacets,
14
- sortOptionFromAPIString,
15
- resolveCollectionDefaultSort,
16
- SORT_OPTIONS,
17
- defaultProfileElementSorts,
18
13
  } from './src/models';
19
14
  export { CollectionBrowserLoadingTile } from './src/tiles/collection-browser-loading-tile';
20
15
  export { CollectionTile } from './src/tiles/grid/collection-tile';
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "The Internet Archive Collection Browser.",
4
4
  "license": "AGPL-3.0-only",
5
5
  "author": "Internet Archive",
6
- "version": "4.1.1-alpha-webdev8185.0",
6
+ "version": "4.1.1",
7
7
  "main": "dist/index.js",
8
8
  "module": "dist/index.js",
9
9
  "scripts": {
@@ -36,7 +36,6 @@ import type { IAComboBox } from '@internetarchive/elements/ia-combo-box/ia-combo
36
36
  import {
37
37
  SelectedFacets,
38
38
  SortField,
39
- type ExplicitSortField,
40
39
  CollectionBrowserContext,
41
40
  getDefaultSelectedFacets,
42
41
  TileModel,
@@ -152,8 +151,10 @@ export class CollectionBrowser
152
151
 
153
152
  @property({ type: String }) sortDirection: SortDirection | null = null;
154
153
 
155
- @property({ type: String }) defaultSortField: ExplicitSortField =
156
- SortField.relevance;
154
+ @property({ type: String }) defaultSortField: Exclude<
155
+ SortField,
156
+ SortField.default
157
+ > = SortField.relevance;
157
158
 
158
159
  @property({ type: String }) defaultSortDirection: SortDirection | null = null;
159
160
 
@@ -1645,12 +1646,6 @@ export class CollectionBrowser
1645
1646
  this.maxSelectedDate = queryState.maxSelectedDate;
1646
1647
  this.selectedSort = queryState.selectedSort ?? SortField.default;
1647
1648
  this.sortDirection = queryState.sortDirection;
1648
- if (queryState.defaultSortField) {
1649
- this.defaultSortField = queryState.defaultSortField;
1650
- }
1651
- if (queryState.defaultSortDirection !== undefined) {
1652
- this.defaultSortDirection = queryState.defaultSortDirection;
1653
- }
1654
1649
  this.selectedTitleFilter = queryState.selectedTitleFilter;
1655
1650
  this.selectedCreatorFilter = queryState.selectedCreatorFilter;
1656
1651
 
@@ -2088,22 +2083,6 @@ export class CollectionBrowser
2088
2083
  );
2089
2084
  }
2090
2085
 
2091
- /**
2092
- * Emits a `collectionExtraInfoLoaded` event when the data source has received
2093
- * collection metadata from the backend. This allows parent components to react
2094
- * to the metadata (e.g., to update their default sort based on the collection's
2095
- * `sort-by` metadata field).
2096
- */
2097
- emitCollectionExtraInfoLoaded(
2098
- collectionExtraInfo?: CollectionExtraInfo,
2099
- ): void {
2100
- this.dispatchEvent(
2101
- new CustomEvent('collectionExtraInfoLoaded', {
2102
- detail: collectionExtraInfo,
2103
- }),
2104
- );
2105
- }
2106
-
2107
2086
  /**
2108
2087
  * Emits a `queryStateChanged` event indicating that one or more of this component's
2109
2088
  * properties have changed in a way that could affect the set of search results.
@@ -1198,7 +1198,6 @@ export class CollectionBrowserDataSource
1198
1198
  // which can be specified in metadata, or otherwise assumed to be week:desc
1199
1199
  if (this.activeOnHost) {
1200
1200
  this.host.applyDefaultCollectionSort(this.collectionExtraInfo);
1201
- this.host.emitCollectionExtraInfoLoaded(this.collectionExtraInfo);
1202
1201
  }
1203
1202
 
1204
1203
  if (this.collectionExtraInfo) {
@@ -6,12 +6,7 @@ import type {
6
6
  SortDirection,
7
7
  SortParam,
8
8
  } from '@internetarchive/search-service';
9
- import type {
10
- ExplicitSortField,
11
- FacetLoadStrategy,
12
- SelectedFacets,
13
- SortField,
14
- } from '../models';
9
+ import type { FacetLoadStrategy, SelectedFacets, SortField } from '../models';
15
10
  import type { CollectionBrowserDataSourceInterface } from './collection-browser-data-source-interface';
16
11
 
17
12
  /**
@@ -32,8 +27,6 @@ export interface CollectionBrowserQueryState {
32
27
  selectedCreatorFilter: string | null;
33
28
  selectedSort?: SortField;
34
29
  sortDirection: SortDirection | null;
35
- defaultSortField?: ExplicitSortField;
36
- defaultSortDirection?: SortDirection | null;
37
30
  }
38
31
 
39
32
  /**
@@ -45,7 +38,7 @@ export interface CollectionBrowserSearchInterface
45
38
  searchService?: SearchServiceInterface;
46
39
  isTVCollection: boolean;
47
40
  readonly sortParam: SortParam | null;
48
- readonly defaultSortField: ExplicitSortField;
41
+ readonly defaultSortField: SortField | null;
49
42
  readonly defaultSortDirection: SortDirection | null;
50
43
  readonly facetLoadStrategy: FacetLoadStrategy;
51
44
  readonly initialPageNumber: number;
@@ -60,9 +53,6 @@ export interface CollectionBrowserSearchInterface
60
53
  setTotalResultCount(count: number): void;
61
54
  setTileCount(count: number): void;
62
55
  applyDefaultCollectionSort(collectionInfo?: CollectionExtraInfo): void;
63
- emitCollectionExtraInfoLoaded(
64
- collectionExtraInfo?: CollectionExtraInfo,
65
- ): void;
66
56
  emitEmptyResults(): void;
67
57
  emitSearchError(): void;
68
58
  emitQueryStateChanged(): void;
package/src/models.ts CHANGED
@@ -3,7 +3,6 @@ import { msg } from '@lit/localize';
3
3
  import type { MediaType } from '@internetarchive/field-parsers';
4
4
  import {
5
5
  AggregationSortType,
6
- CollectionExtraInfo,
7
6
  HitType,
8
7
  SearchReview,
9
8
  SearchResult,
@@ -323,9 +322,6 @@ export enum SortField {
323
322
  'creator' = 'creator',
324
323
  }
325
324
 
326
- /** A sort field excluding the abstract "default" placeholder. */
327
- export type ExplicitSortField = Exclude<SortField, SortField.default>;
328
-
329
325
  /**
330
326
  * Views-related sort fields
331
327
  */
@@ -557,47 +553,6 @@ export function sortOptionFromAPIString(sortName?: string | null): SortOption {
557
553
  );
558
554
  }
559
555
 
560
- /**
561
- * Resolves the default sort option for a collection based on its metadata.
562
- *
563
- * - Favorite collections (`fav-*`) default to Date Favorited descending.
564
- * - Other collections default to Weekly Views descending.
565
- * - If the collection metadata specifies a `sort-by` field, that overrides the above.
566
- *
567
- * Supports both `-field` (dash prefix = desc) and `field:dir` metadata formats.
568
- *
569
- * Note: This does NOT handle the "relevance when a query is present" rule,
570
- * which is managed separately by collection-browser itself.
571
- */
572
- export function resolveCollectionDefaultSort(
573
- collectionInfo?: CollectionExtraInfo,
574
- ): { field: ExplicitSortField; direction: SortDirection } {
575
- const isFav = collectionInfo?.public_metadata?.identifier?.startsWith('fav-');
576
- const baseDefaultSort: string = isFav ? '-favoritedate' : '-week';
577
- const metadataSort: string | undefined =
578
- collectionInfo?.public_metadata?.['sort-by'];
579
- const defaultSortToApply = metadataSort ?? baseDefaultSort;
580
-
581
- // Account for both -field and field:dir formats
582
- let [field, dir] = defaultSortToApply.split(':');
583
- if (field.startsWith('-')) {
584
- field = field.slice(1);
585
- dir = 'desc';
586
- } else if (!['asc', 'desc'].includes(dir)) {
587
- dir = 'asc';
588
- }
589
-
590
- const sortOption = sortOptionFromAPIString(field);
591
- const sortField = sortOption.field;
592
- if (sortField && sortField !== SortField.default) {
593
- return {
594
- field: sortField as ExplicitSortField,
595
- direction: dir as SortDirection,
596
- };
597
- }
598
- return { field: SortField.weeklyview, direction: 'desc' };
599
- }
600
-
601
556
  export const defaultSortAvailability: Record<SortField, boolean> = {
602
557
  [SortField.relevance]: true,
603
558
  [SortField.weeklyview]: true,
@@ -625,7 +580,10 @@ export const tvSortAvailability: Record<SortField, boolean> = {
625
580
  [SortField.dateadded]: false,
626
581
  };
627
582
 
628
- export const defaultProfileElementSorts: Record<string, ExplicitSortField> = {
583
+ export const defaultProfileElementSorts: Record<
584
+ string,
585
+ Exclude<SortField, SortField.default>
586
+ > = {
629
587
  uploads: SortField.datearchived,
630
588
  reviews: SortField.datereviewed,
631
589
  collections: SortField.datearchived,