@internetarchive/collection-browser 2.19.1-alpha-webdev7818.0 → 2.20.1-alpha-webdev7822.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 (44) hide show
  1. package/dist/src/app-root.js +606 -605
  2. package/dist/src/app-root.js.map +1 -1
  3. package/dist/src/collection-browser.d.ts +5 -0
  4. package/dist/src/collection-browser.js +36 -11
  5. package/dist/src/collection-browser.js.map +1 -1
  6. package/dist/src/collection-facets/smart-facets/smart-facet-bar.js +75 -75
  7. package/dist/src/collection-facets/smart-facets/smart-facet-bar.js.map +1 -1
  8. package/dist/src/collection-facets/smart-facets/smart-facet-dropdown.js +54 -54
  9. package/dist/src/collection-facets/smart-facets/smart-facet-dropdown.js.map +1 -1
  10. package/dist/src/collection-facets.js +263 -263
  11. package/dist/src/collection-facets.js.map +1 -1
  12. package/dist/src/expanded-date-picker.js +52 -52
  13. package/dist/src/expanded-date-picker.js.map +1 -1
  14. package/dist/src/models.d.ts +13 -0
  15. package/dist/src/models.js +41 -0
  16. package/dist/src/models.js.map +1 -1
  17. package/dist/src/sort-filter-bar/sort-filter-bar.d.ts +79 -24
  18. package/dist/src/sort-filter-bar/sort-filter-bar.js +201 -119
  19. package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
  20. package/dist/src/tiles/grid/item-tile.js +139 -139
  21. package/dist/src/tiles/grid/item-tile.js.map +1 -1
  22. package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js +118 -118
  23. package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js.map +1 -1
  24. package/dist/src/tiles/list/tile-list.js +289 -289
  25. package/dist/src/tiles/list/tile-list.js.map +1 -1
  26. package/dist/src/tiles/tile-dispatcher.js +200 -200
  27. package/dist/src/tiles/tile-dispatcher.js.map +1 -1
  28. package/dist/test/sort-filter-bar/sort-filter-bar.test.js +157 -11
  29. package/dist/test/sort-filter-bar/sort-filter-bar.test.js.map +1 -1
  30. package/package.json +1 -1
  31. package/src/app-root.ts +1140 -1140
  32. package/src/collection-browser.ts +38 -10
  33. package/src/collection-facets/smart-facets/smart-facet-bar.ts +437 -437
  34. package/src/collection-facets/smart-facets/smart-facet-dropdown.ts +185 -185
  35. package/src/collection-facets.ts +990 -990
  36. package/src/expanded-date-picker.ts +191 -191
  37. package/src/models.ts +48 -0
  38. package/src/sort-filter-bar/sort-filter-bar.ts +220 -126
  39. package/src/tiles/grid/item-tile.ts +339 -339
  40. package/src/tiles/grid/styles/tile-grid-shared-styles.ts +129 -129
  41. package/src/tiles/list/tile-list.ts +688 -688
  42. package/src/tiles/tile-dispatcher.ts +486 -486
  43. package/test/sort-filter-bar/sort-filter-bar.test.ts +205 -12
  44. package/tsconfig.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC,OAAO,EACL,mBAAmB,GAKpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAe/D,MAAM,CAAC,MAAM,iBAAiB,GAAoC;IAChE,gBAAgB,EAAE,GAAG,CAAC,0BAA0B,CAAC;IACjD,iBAAiB,EAAE,GAAG,CAAC,8BAA8B,CAAC;CACvD,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAA4C;IACzE,gBAAgB,EAAE,iBAAiB;IACnC,iBAAiB,EAAE,cAAc;CAClC,CAAC;AAeF;;GAEG;AACH,MAAM,OAAO,SAAS;IA2FpB,YACE,MAAoB,EACpB,mBAAqC,SAAS;;QAE9C,MAAM,KAAK,GAAG,IAAI,CAAC,QAA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AmB,EAAE,IAAI;IACzB,YAAY,EAAE,KAAK;IACnB,mBAAmB,EAAE,KAAK;IAC1B,WAAW,EAAE,IAAI;IACjB,qBAAqB,EAAE,KAAK;CAC7B,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAEjC;IACF,WAAW,EAAE,iBAAiB;IAC9B,mBAAmB,EAAE,gBAAgB;IACrC,WAAW,EAAE,kBAAkB;CAChC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAA4B;IAC5D,WAAW,EAAE,IAAI;IACjB,SAAS,EAAE,IAAI;IACf,WAAW,EAAE,IAAI;IACjB,YAAY,EAAE,IAAI;IAClB,eAAe,EAAE,IAAI;IACrB,aAAa,EAAE,IAAI;IACnB,gBAAgB,EAAE,IAAI;IACtB,wBAAwB,EAAE,IAAI;IAC9B,KAAK,EAAE,IAAI;IACX,SAAS,EAAE,IAAI;IACf,OAAO,EAAE,IAAI;CACd,CAAC","sourcesContent":["import type { TemplateResult } from 'lit';\r\nimport { msg } from '@lit/localize';\r\nimport type { MediaType } from '@internetarchive/field-parsers';\r\nimport {\r\n AggregationSortType,\r\n HitType,\r\n SearchReview,\r\n SearchResult,\r\n SortDirection,\r\n} from '@internetarchive/search-service';\r\nimport { collapseRepeatedQuotes } from './utils/collapse-repeated-quotes';\r\nimport { resolveMediatype } from './utils/resolve-mediatype';\r\n\r\nimport { loginRequiredIcon } from './assets/img/icons/login-required';\r\nimport { restrictedIcon } from './assets/img/icons/restricted';\r\n\r\n/**\r\n * Flags that can affect the visibility of content on a tile\r\n */\r\ninterface TileFlags {\r\n loginRequired: boolean;\r\n contentWarning: boolean;\r\n}\r\n\r\n/**\r\n * Different types of tile overlays, corresponding to the above flags.\r\n */\r\nexport type TileOverlayType = 'login-required' | 'content-warning';\r\n\r\nexport const TILE_OVERLAY_TEXT: Record<TileOverlayType, string> = {\r\n 'login-required': msg('Log in to view this item'),\r\n 'content-warning': msg('Content may be inappropriate'),\r\n};\r\n\r\nexport const TILE_OVERLAY_ICONS: Record<TileOverlayType, TemplateResult> = {\r\n 'login-required': loginRequiredIcon,\r\n 'content-warning': restrictedIcon,\r\n};\r\n\r\n/**\r\n * What type of request produced a given set of hits:\r\n * - `search_query`: Hits produced by an explicit user query and/or applied filters on any page\r\n * - `collection_members`: Hits produced for a collection page without any query or filters\r\n * - `profile_tab`: Hits produced for a tab of the profile page without any query or filters\r\n * - `unknown`: Hits produced via any other means\r\n */\r\nexport type HitRequestSource =\r\n | 'search_query'\r\n | 'collection_members'\r\n | 'profile_tab'\r\n | 'unknown';\r\n\r\n/**\r\n * Class for converting & storing raw search results in the correct format for UI tiles.\r\n */\r\nexport class TileModel {\r\n /** For TV hits. List of identifiers for any commercials contained. */\r\n adIds?: string[];\r\n\r\n averageRating?: number;\r\n\r\n /** For Web Archive hits on profile pages. List of capture dates for the current URL. */\r\n captureDates?: Date[];\r\n\r\n /** Whether this tile is currently checked for item management functions */\r\n checked: boolean;\r\n\r\n collectionIdentifier?: string;\r\n\r\n collectionName?: string;\r\n\r\n collectionFilesCount: number;\r\n\r\n collections: string[];\r\n\r\n collectionSize: number;\r\n\r\n commentCount: number;\r\n\r\n creator?: string;\r\n\r\n creators: string[];\r\n\r\n /** A string representation of the publication date, used strictly for passing preformatted dates to the parent */\r\n dateStr?: string;\r\n\r\n /** Date added to public search (software-defined) [from MD field: addeddate] */\r\n dateAdded?: Date;\r\n\r\n /** Date archived (software-defined) item created on archive.org [from MD field: publicdate] */\r\n dateArchived?: Date;\r\n\r\n /** Date work published in the world (user-defined) [from MD field: date] */\r\n datePublished?: Date;\r\n\r\n /** Date reviewed (user-created) most recent review [from MD field: reviewdate] */\r\n dateReviewed?: Date;\r\n\r\n description?: string;\r\n\r\n /** For TV hits. List of URLs for any fact-checks of the contained clips. */\r\n factChecks?: string[];\r\n\r\n favCount: number;\r\n\r\n hitRequestSource: HitRequestSource;\r\n\r\n hitType?: HitType;\r\n\r\n href?: string;\r\n\r\n identifier?: string;\r\n\r\n /** Whether this model represents a TV clip */\r\n isClip?: boolean;\r\n\r\n issue?: string;\r\n\r\n itemCount: number;\r\n\r\n mediatype: MediaType;\r\n\r\n review?: SearchReview;\r\n\r\n source?: string;\r\n\r\n snippets?: string[];\r\n\r\n subjects: string[];\r\n\r\n thumbnailUrl?: string;\r\n\r\n title: string;\r\n\r\n tvClipCount?: number;\r\n\r\n viewCount?: number;\r\n\r\n volume?: string;\r\n\r\n weeklyViewCount?: number;\r\n\r\n loginRequired: boolean;\r\n\r\n contentWarning: boolean;\r\n\r\n constructor(\r\n result: SearchResult,\r\n hitRequestSource: HitRequestSource = 'unknown',\r\n ) {\r\n const flags = this.getFlags(result);\r\n\r\n this.adIds = result.ad_id?.values;\r\n this.averageRating = result.avg_rating?.value;\r\n this.captureDates = result.capture_dates?.values;\r\n this.checked = false;\r\n this.collections = result.collection?.values ?? [];\r\n this.collectionFilesCount = result.collection_files_count?.value ?? 0;\r\n this.collectionSize = result.collection_size?.value ?? 0;\r\n this.commentCount = result.num_reviews?.value ?? 0;\r\n this.creator = result.creator?.value;\r\n this.creators = result.creator?.values ?? [];\r\n this.dateAdded = result.addeddate?.value;\r\n this.dateArchived = result.publicdate?.value;\r\n this.datePublished = result.date?.value;\r\n this.dateReviewed = result.reviewdate?.value;\r\n this.description = result.description?.values.join('\\n');\r\n this.factChecks = result.factcheck?.values;\r\n this.favCount = result.num_favorites?.value ?? 0;\r\n this.hitRequestSource = hitRequestSource;\r\n this.hitType = result.rawMetadata?.hit_type;\r\n this.href = collapseRepeatedQuotes(\r\n result.review?.__href__ ?? result.__href__?.value,\r\n );\r\n this.identifier = TileModel.cleanIdentifier(result.identifier);\r\n this.isClip = result.is_clip?.value;\r\n this.issue = result.issue?.value;\r\n this.itemCount = result.item_count?.value ?? 0;\r\n this.mediatype = resolveMediatype(result);\r\n this.review = result.review;\r\n this.snippets = result.highlight?.values ?? [];\r\n this.source = result.source?.value;\r\n this.subjects = result.subject?.values ?? [];\r\n this.thumbnailUrl = result.__img__?.value;\r\n this.title = result.title?.value ?? '';\r\n this.tvClipCount = result.num_clips?.value ?? 0;\r\n this.volume = result.volume?.value;\r\n this.viewCount = result.downloads?.value;\r\n this.weeklyViewCount = result.week?.value;\r\n this.loginRequired = flags.loginRequired;\r\n this.contentWarning = flags.contentWarning;\r\n }\r\n\r\n /**\r\n * Copies the contents of this TileModel onto a new instance\r\n */\r\n clone(): TileModel {\r\n const cloned = new TileModel({});\r\n cloned.adIds = this.adIds;\r\n cloned.averageRating = this.averageRating;\r\n cloned.captureDates = this.captureDates;\r\n cloned.checked = this.checked;\r\n cloned.collections = this.collections;\r\n cloned.collectionFilesCount = this.collectionFilesCount;\r\n cloned.collectionSize = this.collectionSize;\r\n cloned.commentCount = this.commentCount;\r\n cloned.creator = this.creator;\r\n cloned.creators = this.creators;\r\n cloned.dateStr = this.dateStr;\r\n cloned.dateAdded = this.dateAdded;\r\n cloned.dateArchived = this.dateArchived;\r\n cloned.datePublished = this.datePublished;\r\n cloned.dateReviewed = this.dateReviewed;\r\n cloned.description = this.description;\r\n cloned.factChecks = this.factChecks;\r\n cloned.favCount = this.favCount;\r\n cloned.hitRequestSource = this.hitRequestSource;\r\n cloned.hitType = this.hitType;\r\n cloned.href = this.href;\r\n cloned.identifier = this.identifier;\r\n cloned.isClip = this.isClip;\r\n cloned.issue = this.issue;\r\n cloned.itemCount = this.itemCount;\r\n cloned.mediatype = this.mediatype;\r\n cloned.snippets = this.snippets;\r\n cloned.source = this.source;\r\n cloned.subjects = this.subjects;\r\n cloned.thumbnailUrl = this.thumbnailUrl;\r\n cloned.title = this.title;\r\n cloned.tvClipCount = this.tvClipCount;\r\n cloned.volume = this.volume;\r\n cloned.viewCount = this.viewCount;\r\n cloned.weeklyViewCount = this.weeklyViewCount;\r\n cloned.loginRequired = this.loginRequired;\r\n cloned.contentWarning = this.contentWarning;\r\n return cloned;\r\n }\r\n\r\n /**\r\n * Whether this model represents the result of a TV search query.\r\n */\r\n get isTvSearchResult(): boolean {\r\n return (\r\n this.hitType === 'tv_clip' && this.hitRequestSource === 'search_query'\r\n );\r\n }\r\n\r\n /**\r\n * Determines the appropriate tile flags for the given search result\r\n * (login required and/or content warning)\r\n */\r\n private getFlags(result: SearchResult): TileFlags {\r\n const flags: TileFlags = {\r\n loginRequired: false,\r\n contentWarning: false,\r\n };\r\n\r\n // Check if item and item in \"modifying\" collection, setting above flags\r\n if (\r\n result.collection?.values.length &&\r\n result.mediatype?.value !== 'collection'\r\n ) {\r\n for (const collection of result.collection?.values ?? []) {\r\n if (collection === 'loggedin') {\r\n flags.loginRequired = true;\r\n if (flags.contentWarning) break;\r\n }\r\n if (collection === 'no-preview') {\r\n flags.contentWarning = true;\r\n if (flags.loginRequired) break;\r\n }\r\n }\r\n }\r\n\r\n return flags;\r\n }\r\n\r\n private static cleanIdentifier(\r\n identifier: string | undefined,\r\n ): string | undefined {\r\n // Some identifiers (e.g., from Whisper) represent documents rather than items, and\r\n // are suffixed with values that need to be stripped. Those values are separated\r\n // from the item identifier itself with '|'.\r\n const barIndex = identifier?.indexOf('|') ?? -1;\r\n const cleaned = barIndex > 0 ? identifier?.slice(0, barIndex) : identifier;\r\n return cleaned;\r\n }\r\n}\r\n\r\nexport type RequestKind = 'full' | 'hits' | 'aggregations';\r\n\r\nexport type CollectionDisplayMode = 'grid' | 'list-compact' | 'list-detail';\r\n\r\nexport type TileDisplayMode =\r\n | 'grid'\r\n | 'list-compact'\r\n | 'list-detail'\r\n | 'list-header';\r\n\r\n/**\r\n * This is mainly used to set the cookies for the collection display mode.\r\n *\r\n * It allows the user to set different modes for different contexts (collection page, search page, profile page etc).\r\n */\r\nexport type CollectionBrowserContext = 'collection' | 'search' | 'profile';\r\n\r\n/**\r\n * The sort fields shown in the sort filter bar\r\n */\r\nexport enum SortField {\r\n 'default' = 'default',\r\n 'unrecognized' = 'unrecognized',\r\n 'relevance' = 'relevance',\r\n 'alltimeview' = 'alltimeview',\r\n 'weeklyview' = 'weeklyview',\r\n 'title' = 'title',\r\n 'date' = 'date',\r\n 'datearchived' = 'datearchived',\r\n 'datereviewed' = 'datereviewed',\r\n 'dateadded' = 'dateadded',\r\n 'datefavorited' = 'datefavorited',\r\n 'creator' = 'creator',\r\n}\r\n\r\nexport interface SortOption {\r\n /**\r\n * The SortField enum member corresponding to this option.\r\n */\r\n field: SortField;\r\n\r\n /**\r\n * The default sort direction to apply when this sort option is first selected.\r\n */\r\n defaultSortDirection: SortDirection | null;\r\n\r\n /**\r\n * Whether this sort option allows its sort direction to be changed from the default.\r\n */\r\n canSetDirection: boolean;\r\n\r\n /**\r\n * Whether this sort option may appear in the sort bar.\r\n */\r\n shownInSortBar: boolean;\r\n\r\n /**\r\n * Whether this sort option should be saved to the URL.\r\n * If false, then no `sort` param will be added to the URL when this sort option\r\n * is selected.\r\n */\r\n shownInURL: boolean;\r\n\r\n /**\r\n * Whether this sort option is passed to the search service.\r\n * If false, then no sort param will be passed to the search service at all when\r\n * this sort option is selected.\r\n */\r\n handledBySearchService: boolean;\r\n\r\n /**\r\n * The string identifying this sort field to the search service & backend API.\r\n */\r\n searchServiceKey?: string;\r\n\r\n /**\r\n * The human-readable name to use for this option in the sort bar (if applicable).\r\n */\r\n displayName: string;\r\n\r\n /**\r\n * A list of URL param keys that should be mapped to this sort option.\r\n * E.g., both `title` and `titleSorter` in the URL map to the `SortField.title` option.\r\n */\r\n urlNames: (string | null | undefined)[];\r\n}\r\n\r\nexport const SORT_OPTIONS: Record<SortField, SortOption> = {\r\n // Default sort is the case where the user has not specified a sort option via the sort bar or URL.\r\n // In these cases, we defer to whatever sort the backend chooses.\r\n // For the search page, the default is always relevance sort.\r\n // For collection pages _without a query_, the default is usually weekly views, but this can be\r\n // overridden by the collection's `sort-by` metadata entry. If a query _is_ specified, then the\r\n // default is again relevance sort.\r\n // For fav-* collections only, the default is instead sorting by date favorited.\r\n [SortField.default]: {\r\n field: SortField.default,\r\n defaultSortDirection: null,\r\n canSetDirection: false,\r\n shownInSortBar: false,\r\n shownInURL: false,\r\n handledBySearchService: false, // We rely on the PPS default sort handling in these cases\r\n displayName: '',\r\n urlNames: ['', null, undefined], // Empty or nullish sort params result in default sorting\r\n },\r\n // Unrecognized sort is the case where the user has specified a sort in the URL, but it is not\r\n // one of the options listed in this map. We still want these unrecognized sorts to be applied\r\n // when searching, but they are not displayed in the sort bar and we do not actively manage\r\n // their URL param beyond flipping the direction as needed.\r\n [SortField.unrecognized]: {\r\n field: SortField.unrecognized,\r\n defaultSortDirection: null,\r\n canSetDirection: true,\r\n shownInSortBar: false,\r\n shownInURL: false,\r\n handledBySearchService: true, // The unrecognized sort param is passed along as-is\r\n displayName: '',\r\n urlNames: [],\r\n },\r\n // Relevance sort is unique in that it does not produce a URL param when it is set.\r\n // It is only available when there is a user-specified query that relevancy can be scored against.\r\n // Therefore, it does not appear as a sort bar option when browsing a collection with no query set.\r\n [SortField.relevance]: {\r\n field: SortField.relevance,\r\n defaultSortDirection: null,\r\n canSetDirection: false,\r\n shownInSortBar: true,\r\n shownInURL: false,\r\n handledBySearchService: false,\r\n displayName: 'Relevance',\r\n urlNames: ['_score'],\r\n },\r\n [SortField.alltimeview]: {\r\n field: SortField.alltimeview,\r\n defaultSortDirection: 'desc',\r\n canSetDirection: true,\r\n shownInSortBar: true,\r\n shownInURL: true,\r\n handledBySearchService: true,\r\n searchServiceKey: 'downloads',\r\n displayName: 'All-time views',\r\n urlNames: ['downloads'],\r\n },\r\n [SortField.weeklyview]: {\r\n field: SortField.weeklyview,\r\n defaultSortDirection: 'desc',\r\n canSetDirection: true,\r\n shownInSortBar: true,\r\n shownInURL: true,\r\n handledBySearchService: true,\r\n searchServiceKey: 'week',\r\n displayName: 'Weekly views',\r\n urlNames: ['week'],\r\n },\r\n [SortField.title]: {\r\n field: SortField.title,\r\n defaultSortDirection: 'asc',\r\n canSetDirection: true,\r\n shownInSortBar: true,\r\n shownInURL: true,\r\n handledBySearchService: true,\r\n searchServiceKey: 'titleSorter',\r\n displayName: 'Title',\r\n urlNames: ['title', 'titleSorter'],\r\n },\r\n [SortField.date]: {\r\n field: SortField.date,\r\n defaultSortDirection: 'desc',\r\n canSetDirection: true,\r\n shownInSortBar: true,\r\n shownInURL: true,\r\n handledBySearchService: true,\r\n searchServiceKey: 'date',\r\n displayName: 'Date published',\r\n urlNames: ['date'],\r\n },\r\n [SortField.datearchived]: {\r\n field: SortField.datearchived,\r\n defaultSortDirection: 'desc',\r\n canSetDirection: true,\r\n shownInSortBar: true,\r\n shownInURL: true,\r\n handledBySearchService: true,\r\n searchServiceKey: 'publicdate',\r\n displayName: 'Date archived',\r\n urlNames: ['publicdate'],\r\n },\r\n [SortField.datereviewed]: {\r\n field: SortField.datereviewed,\r\n defaultSortDirection: 'desc',\r\n canSetDirection: true,\r\n shownInSortBar: true,\r\n shownInURL: true,\r\n handledBySearchService: true,\r\n searchServiceKey: 'reviewdate',\r\n displayName: 'Date reviewed',\r\n urlNames: ['reviewdate'],\r\n },\r\n [SortField.dateadded]: {\r\n field: SortField.dateadded,\r\n defaultSortDirection: 'desc',\r\n canSetDirection: true,\r\n shownInSortBar: true,\r\n shownInURL: true,\r\n handledBySearchService: true,\r\n searchServiceKey: 'addeddate',\r\n displayName: 'Date added',\r\n urlNames: ['addeddate'],\r\n },\r\n [SortField.datefavorited]: {\r\n field: SortField.datefavorited,\r\n defaultSortDirection: 'desc',\r\n canSetDirection: false,\r\n shownInSortBar: true, // But only when viewing fav-* collections\r\n shownInURL: false,\r\n handledBySearchService: false,\r\n searchServiceKey: 'favoritedate',\r\n displayName: 'Date favorited',\r\n urlNames: ['favoritedate'],\r\n },\r\n [SortField.creator]: {\r\n field: SortField.creator,\r\n defaultSortDirection: 'asc',\r\n canSetDirection: true,\r\n shownInSortBar: true,\r\n shownInURL: true,\r\n handledBySearchService: true,\r\n searchServiceKey: 'creatorSorter',\r\n displayName: 'Creator',\r\n urlNames: ['creator', 'creatorSorter'],\r\n },\r\n};\r\n\r\n/**\r\n * Returns the SortOption corresponding to the given API sort name, or\r\n * the \"unrecognized\" SortOption if none matches.\r\n */\r\nexport function sortOptionFromAPIString(sortName?: string | null): SortOption {\r\n return (\r\n Object.values(SORT_OPTIONS).find(opt =>\r\n opt.urlNames.some(name => sortName === name),\r\n ) ?? SORT_OPTIONS[SortField.unrecognized]\r\n );\r\n}\r\n\r\nexport const defaultProfileElementSorts: Record<\r\n string,\r\n Exclude<SortField, SortField.default>\r\n> = {\r\n uploads: SortField.datearchived,\r\n reviews: SortField.datereviewed,\r\n collections: SortField.datearchived,\r\n web_archives: SortField.datearchived,\r\n};\r\n\r\n/** A union of the fields that permit prefix filtering (e.g., alphabetical filtering) */\r\nexport type PrefixFilterType = 'title' | 'creator';\r\n\r\n/** A map from prefixes (e.g., initial letters) to the number of items matching that prefix */\r\nexport type PrefixFilterCounts = Record<string, number>;\r\n\r\n/**\r\n * A map from prefix filter types to the corresponding aggregation keys\r\n * that are needed to fetch the filter counts from the backend.\r\n */\r\nexport const prefixFilterAggregationKeys: Record<PrefixFilterType, string> = {\r\n title: 'firstTitle',\r\n creator: 'firstCreator',\r\n};\r\n\r\n/**\r\n * Different facet loading strategies that can be used with collection browser.\r\n * - `eager`: Facet data is always loaded as soon as a search is performed\r\n * - `lazy-mobile`: In the desktop layout, functions exactly as `eager`.\r\n * In the mobile layout, facet data will only be loaded once the \"Filters\" accordion is opened.\r\n * - `opt-in-or-login`: Same as `opt-in` for guest users not logged into an account, but same as `eager` for\r\n * any logged in user.\r\n * - `opt-in`: In the desktop layout, facet data will only be loaded after the user presses a \"Load Facets\" button.\r\n * In the mobile layout, functions exactly as `lazy-mobile`.\r\n * - `off`: Facet data will never be loaded, and a message will be displayed in place of facets\r\n * indicating that they are unavailable.\r\n */\r\nexport type FacetLoadStrategy =\r\n | 'eager'\r\n | 'lazy-mobile'\r\n | 'opt-in-or-login'\r\n | 'opt-in'\r\n | 'off';\r\n\r\n/**\r\n * Union of the facet types that are available in the sidebar.\r\n */\r\nexport type FacetOption =\r\n | 'subject'\r\n | 'lending'\r\n | 'mediatype'\r\n | 'language'\r\n | 'creator'\r\n | 'collection'\r\n | 'year'\r\n // TV-specific facet options:\r\n | 'program'\r\n | 'person'\r\n | 'sponsor';\r\n\r\nexport type SelectedFacetState = 'selected' | 'hidden';\r\n\r\nexport type FacetState = SelectedFacetState | 'none';\r\n\r\nexport interface FacetBucket {\r\n key: string;\r\n count: number;\r\n state: FacetState;\r\n // for some facets, we augment the key with a display value\r\n displayText?: string;\r\n // for TV channel facets, we add a parenthesized secondary name\r\n extraNote?: string;\r\n}\r\n\r\nexport interface FacetGroup {\r\n title: string;\r\n key: FacetOption;\r\n buckets: FacetBucket[];\r\n}\r\n\r\n/**\r\n * Information about a user interaction event on a facet.\r\n */\r\nexport type FacetEventDetails = {\r\n /**\r\n * The type of facet that was interacted with (e.g., 'mediatype', 'language', ...).\r\n */\r\n facetType: FacetOption;\r\n /**\r\n * The bucket corresponding to the facet that was interacted with, including the\r\n * updated state of the facet after the interaction.\r\n */\r\n bucket: FacetBucket;\r\n /**\r\n * Whether the interaction occurred on a negative facet.\r\n */\r\n negative: boolean;\r\n};\r\n\r\nexport type FacetValue = string;\r\n\r\nexport type SelectedFacets = Partial<\r\n Record<FacetOption, Record<FacetValue, FacetBucket>>\r\n>;\r\n\r\nexport const getDefaultSelectedFacets = (): Required<SelectedFacets> => ({\r\n subject: {},\r\n lending: {},\r\n mediatype: {},\r\n language: {},\r\n creator: {},\r\n collection: {},\r\n year: {},\r\n program: {},\r\n person: {},\r\n sponsor: {},\r\n});\r\n\r\n/**\r\n * For TV search results, what types of TV clips to restrict the results to.\r\n */\r\nexport type TvClipFilterType = 'all' | 'commercials' | 'factchecks' | 'quotes';\r\n\r\n/**\r\n * Map from TV clip filter types to their corresponding URL params\r\n */\r\nexport const tvClipFiltersToURLParams: Record<TvClipFilterType, string> = {\r\n all: '',\r\n commercials: 'only_commercials',\r\n factchecks: 'only_factchecks',\r\n quotes: 'only_quotes',\r\n};\r\n\r\n/**\r\n * Map from allowed TV filtering parameters in the URL to their corresponding filter type\r\n */\r\nexport const tvClipURLParamsToFilters: Record<string, TvClipFilterType> = {\r\n only_commercials: 'commercials',\r\n only_factchecks: 'factchecks',\r\n only_quotes: 'quotes',\r\n};\r\n\r\n/**\r\n * Facet display order when presenting results for all search types *except* TV (see below).\r\n */\r\nexport const defaultFacetDisplayOrder: FacetOption[] = [\r\n 'mediatype',\r\n // 'lending', Commenting this out removes the lending facet from the sidebar for now\r\n 'year',\r\n 'subject',\r\n 'collection',\r\n 'creator',\r\n 'language',\r\n];\r\n\r\n/**\r\n * Specialized facet ordering when displaying TV search results\r\n */\r\nexport const tvFacetDisplayOrder: FacetOption[] = [\r\n 'program',\r\n 'creator',\r\n 'year',\r\n 'subject',\r\n 'collection',\r\n 'person',\r\n 'sponsor',\r\n 'language',\r\n];\r\n\r\n/**\r\n * Human-readable titles for each facet group.\r\n */\r\nexport const facetTitles: Record<FacetOption, string> = {\r\n subject: 'Subject',\r\n lending: 'Availability',\r\n mediatype: 'Media Type',\r\n language: 'Language',\r\n creator: 'Creator',\r\n collection: 'Collection',\r\n year: 'Year',\r\n program: 'Program',\r\n person: 'Person',\r\n sponsor: 'Sponsor',\r\n};\r\n\r\n/**\r\n * The default sort type to use for each facet type\r\n */\r\nexport const defaultFacetSort: Record<FacetOption, AggregationSortType> = {\r\n subject: AggregationSortType.COUNT,\r\n lending: AggregationSortType.COUNT,\r\n mediatype: AggregationSortType.COUNT,\r\n language: AggregationSortType.COUNT,\r\n creator: AggregationSortType.COUNT,\r\n collection: AggregationSortType.COUNT,\r\n year: AggregationSortType.NUMERIC, // Year facets are ordered by their numeric value by default\r\n program: AggregationSortType.COUNT,\r\n person: AggregationSortType.COUNT,\r\n sponsor: AggregationSortType.COUNT,\r\n};\r\n\r\n/**\r\n * The sort type corresponding to facet bucket values, for each facet type\r\n * (i.e., the opposite of \"sort by count\" for that type).\r\n */\r\nexport const valueFacetSort: Record<FacetOption, AggregationSortType> = {\r\n subject: AggregationSortType.ALPHABETICAL,\r\n lending: AggregationSortType.ALPHABETICAL,\r\n mediatype: AggregationSortType.ALPHABETICAL,\r\n language: AggregationSortType.ALPHABETICAL,\r\n creator: AggregationSortType.ALPHABETICAL,\r\n collection: AggregationSortType.ALPHABETICAL,\r\n year: AggregationSortType.NUMERIC, // Year facets' values should be compared numerically, not lexicographically (year 2001 > year 3)\r\n program: AggregationSortType.ALPHABETICAL,\r\n person: AggregationSortType.ALPHABETICAL,\r\n sponsor: AggregationSortType.ALPHABETICAL,\r\n};\r\n\r\nexport type LendingFacetKey =\r\n | 'is_lendable'\r\n | 'is_borrowable'\r\n | 'available_to_borrow'\r\n | 'is_browsable'\r\n | 'available_to_browse'\r\n | 'is_readable'\r\n | 'available_to_waitlist';\r\n\r\n/**\r\n * Maps valid lending keys to whether they should be visible in the facet sidebar\r\n */\r\nexport const lendingFacetKeysVisibility: Record<LendingFacetKey, boolean> = {\r\n is_lendable: true,\r\n is_borrowable: false,\r\n available_to_borrow: true,\r\n is_browsable: false,\r\n available_to_browse: false,\r\n is_readable: true,\r\n available_to_waitlist: false,\r\n};\r\n\r\n/**\r\n * Maps valid, visible lending keys to their facet sidebar display text\r\n */\r\nexport const lendingFacetDisplayNames: Partial<\r\n Record<LendingFacetKey, string>\r\n> = {\r\n is_lendable: 'Lending Library',\r\n available_to_borrow: 'Borrow 14 Days',\r\n is_readable: 'Always Available',\r\n};\r\n\r\n/**\r\n * A record of which admin-only collections should be suppressed from being displayed\r\n * as facets or in an item's list of collections.\r\n */\r\nexport const suppressedCollections: Record<string, boolean> = {\r\n deemphasize: true,\r\n community: true,\r\n stream_only: true,\r\n samples_only: true,\r\n test_collection: true,\r\n printdisabled: true,\r\n 'openlibrary-ol': true,\r\n nationalemergencylibrary: true,\r\n china: true,\r\n americana: true,\r\n toronto: true,\r\n};\r\n\r\n/**\r\n * A record of manageable item\r\n */\r\nexport interface ManageableItem {\r\n identifier: string;\r\n title?: string;\r\n dateStr?: string;\r\n date?: string;\r\n}\r\n\r\n/**\r\n * Possible states for whether & how the user has overridden their user preference\r\n * for blurring behavior on tiles with sensitive content.\r\n * - `no-override`: The user has not overridden their user preference, so simply\r\n * respect the preference as given.\r\n * - `on`: The user has overridden their preference and wants tile blurring enabled.\r\n * - `off`: The user has overridden their preference and wants tile blurring disabled.\r\n */\r\nexport type TileBlurOverrideState = 'no-override' | 'on' | 'off';\r\n"]}
1
+ {"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC,OAAO,EACL,mBAAmB,GAKpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAe/D,MAAM,CAAC,MAAM,iBAAiB,GAAoC;IAChE,gBAAgB,EAAE,GAAG,CAAC,0BAA0B,CAAC;IACjD,iBAAiB,EAAE,GAAG,CAAC,8BAA8B,CAAC;CACvD,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAA4C;IACzE,gBAAgB,EAAE,iBAAiB;IACnC,iBAAiB,EAAE,cAAc;CAClC,CAAC;AAeF;;GAEG;AACH,MAAM,OAAO,SAAS;IA2FpB,YACE,MAAoB,EACpB,mBAAqC,SAAS;;QAE9C,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAEpC,IAAI,CAAC,KAAK,GAAG,MAAA,MAAM,CAAC,KAAK,0CAAE,MAAM,CAAC;QAClC,IAAI,CAAC,aAAa,GAAG,MAAA,MAAM,CAAC,UAAU,0CAAE,KAAK,CAAC;QAC9C,IAAI,CAAC,YAAY,GAAG,MAAA,MAAM,CAAC,aAAa,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,EAAE,iBAAiB;IAC9B,mBAAmB,EAAE,gBAAgB;IACrC,WAAW,EAAE,kBAAkB;CAChC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAA4B;IAC5D,WAAW,EAAE,IAAI;IACjB,SAAS,EAAE,IAAI;IACf,WAAW,EAAE,IAAI;IACjB,YAAY,EAAE,IAAI;IAClB,eAAe,EAAE,IAAI;IACrB,aAAa,EAAE,IAAI;IACnB,gBAAgB,EAAE,IAAI;IACtB,wBAAwB,EAAE,IAAI;IAC9B,KAAK,EAAE,IAAI;IACX,SAAS,EAAE,IAAI;IACf,OAAO,EAAE,IAAI;CACd,CAAC","sourcesContent":["import type { TemplateResult } from 'lit';\r\nimport { msg } from '@lit/localize';\r\nimport type { MediaType } from '@internetarchive/field-parsers';\r\nimport {\r\n AggregationSortType,\r\n HitType,\r\n SearchReview,\r\n SearchResult,\r\n SortDirection,\r\n} from '@internetarchive/search-service';\r\nimport { collapseRepeatedQuotes } from './utils/collapse-repeated-quotes';\r\nimport { resolveMediatype } from './utils/resolve-mediatype';\r\n\r\nimport { loginRequiredIcon } from './assets/img/icons/login-required';\r\nimport { restrictedIcon } from './assets/img/icons/restricted';\r\n\r\n/**\r\n * Flags that can affect the visibility of content on a tile\r\n */\r\ninterface TileFlags {\r\n loginRequired: boolean;\r\n contentWarning: boolean;\r\n}\r\n\r\n/**\r\n * Different types of tile overlays, corresponding to the above flags.\r\n */\r\nexport type TileOverlayType = 'login-required' | 'content-warning';\r\n\r\nexport const TILE_OVERLAY_TEXT: Record<TileOverlayType, string> = {\r\n 'login-required': msg('Log in to view this item'),\r\n 'content-warning': msg('Content may be inappropriate'),\r\n};\r\n\r\nexport const TILE_OVERLAY_ICONS: Record<TileOverlayType, TemplateResult> = {\r\n 'login-required': loginRequiredIcon,\r\n 'content-warning': restrictedIcon,\r\n};\r\n\r\n/**\r\n * What type of request produced a given set of hits:\r\n * - `search_query`: Hits produced by an explicit user query and/or applied filters on any page\r\n * - `collection_members`: Hits produced for a collection page without any query or filters\r\n * - `profile_tab`: Hits produced for a tab of the profile page without any query or filters\r\n * - `unknown`: Hits produced via any other means\r\n */\r\nexport type HitRequestSource =\r\n | 'search_query'\r\n | 'collection_members'\r\n | 'profile_tab'\r\n | 'unknown';\r\n\r\n/**\r\n * Class for converting & storing raw search results in the correct format for UI tiles.\r\n */\r\nexport class TileModel {\r\n /** For TV hits. List of identifiers for any commercials contained. */\r\n adIds?: string[];\r\n\r\n averageRating?: number;\r\n\r\n /** For Web Archive hits on profile pages. List of capture dates for the current URL. */\r\n captureDates?: Date[];\r\n\r\n /** Whether this tile is currently checked for item management functions */\r\n checked: boolean;\r\n\r\n collectionIdentifier?: string;\r\n\r\n collectionName?: string;\r\n\r\n collectionFilesCount: number;\r\n\r\n collections: string[];\r\n\r\n collectionSize: number;\r\n\r\n commentCount: number;\r\n\r\n creator?: string;\r\n\r\n creators: string[];\r\n\r\n /** A string representation of the publication date, used strictly for passing preformatted dates to the parent */\r\n dateStr?: string;\r\n\r\n /** Date added to public search (software-defined) [from MD field: addeddate] */\r\n dateAdded?: Date;\r\n\r\n /** Date archived (software-defined) item created on archive.org [from MD field: publicdate] */\r\n dateArchived?: Date;\r\n\r\n /** Date work published in the world (user-defined) [from MD field: date] */\r\n datePublished?: Date;\r\n\r\n /** Date reviewed (user-created) most recent review [from MD field: reviewdate] */\r\n dateReviewed?: Date;\r\n\r\n description?: string;\r\n\r\n /** For TV hits. List of URLs for any fact-checks of the contained clips. */\r\n factChecks?: string[];\r\n\r\n favCount: number;\r\n\r\n hitRequestSource: HitRequestSource;\r\n\r\n hitType?: HitType;\r\n\r\n href?: string;\r\n\r\n identifier?: string;\r\n\r\n /** Whether this model represents a TV clip */\r\n isClip?: boolean;\r\n\r\n issue?: string;\r\n\r\n itemCount: number;\r\n\r\n mediatype: MediaType;\r\n\r\n review?: SearchReview;\r\n\r\n source?: string;\r\n\r\n snippets?: string[];\r\n\r\n subjects: string[];\r\n\r\n thumbnailUrl?: string;\r\n\r\n title: string;\r\n\r\n tvClipCount?: number;\r\n\r\n viewCount?: number;\r\n\r\n volume?: string;\r\n\r\n weeklyViewCount?: number;\r\n\r\n loginRequired: boolean;\r\n\r\n contentWarning: boolean;\r\n\r\n constructor(\r\n result: SearchResult,\r\n hitRequestSource: HitRequestSource = 'unknown',\r\n ) {\r\n const flags = this.getFlags(result);\r\n\r\n this.adIds = result.ad_id?.values;\r\n this.averageRating = result.avg_rating?.value;\r\n this.captureDates = result.capture_dates?.values;\r\n this.checked = false;\r\n this.collections = result.collection?.values ?? [];\r\n this.collectionFilesCount = result.collection_files_count?.value ?? 0;\r\n this.collectionSize = result.collection_size?.value ?? 0;\r\n this.commentCount = result.num_reviews?.value ?? 0;\r\n this.creator = result.creator?.value;\r\n this.creators = result.creator?.values ?? [];\r\n this.dateAdded = result.addeddate?.value;\r\n this.dateArchived = result.publicdate?.value;\r\n this.datePublished = result.date?.value;\r\n this.dateReviewed = result.reviewdate?.value;\r\n this.description = result.description?.values.join('\\n');\r\n this.factChecks = result.factcheck?.values;\r\n this.favCount = result.num_favorites?.value ?? 0;\r\n this.hitRequestSource = hitRequestSource;\r\n this.hitType = result.rawMetadata?.hit_type;\r\n this.href = collapseRepeatedQuotes(\r\n result.review?.__href__ ?? result.__href__?.value,\r\n );\r\n this.identifier = TileModel.cleanIdentifier(result.identifier);\r\n this.isClip = result.is_clip?.value;\r\n this.issue = result.issue?.value;\r\n this.itemCount = result.item_count?.value ?? 0;\r\n this.mediatype = resolveMediatype(result);\r\n this.review = result.review;\r\n this.snippets = result.highlight?.values ?? [];\r\n this.source = result.source?.value;\r\n this.subjects = result.subject?.values ?? [];\r\n this.thumbnailUrl = result.__img__?.value;\r\n this.title = result.title?.value ?? '';\r\n this.tvClipCount = result.num_clips?.value ?? 0;\r\n this.volume = result.volume?.value;\r\n this.viewCount = result.downloads?.value;\r\n this.weeklyViewCount = result.week?.value;\r\n this.loginRequired = flags.loginRequired;\r\n this.contentWarning = flags.contentWarning;\r\n }\r\n\r\n /**\r\n * Copies the contents of this TileModel onto a new instance\r\n */\r\n clone(): TileModel {\r\n const cloned = new TileModel({});\r\n cloned.adIds = this.adIds;\r\n cloned.averageRating = this.averageRating;\r\n cloned.captureDates = this.captureDates;\r\n cloned.checked = this.checked;\r\n cloned.collections = this.collections;\r\n cloned.collectionFilesCount = this.collectionFilesCount;\r\n cloned.collectionSize = this.collectionSize;\r\n cloned.commentCount = this.commentCount;\r\n cloned.creator = this.creator;\r\n cloned.creators = this.creators;\r\n cloned.dateStr = this.dateStr;\r\n cloned.dateAdded = this.dateAdded;\r\n cloned.dateArchived = this.dateArchived;\r\n cloned.datePublished = this.datePublished;\r\n cloned.dateReviewed = this.dateReviewed;\r\n cloned.description = this.description;\r\n cloned.factChecks = this.factChecks;\r\n cloned.favCount = this.favCount;\r\n cloned.hitRequestSource = this.hitRequestSource;\r\n cloned.hitType = this.hitType;\r\n cloned.href = this.href;\r\n cloned.identifier = this.identifier;\r\n cloned.isClip = this.isClip;\r\n cloned.issue = this.issue;\r\n cloned.itemCount = this.itemCount;\r\n cloned.mediatype = this.mediatype;\r\n cloned.snippets = this.snippets;\r\n cloned.source = this.source;\r\n cloned.subjects = this.subjects;\r\n cloned.thumbnailUrl = this.thumbnailUrl;\r\n cloned.title = this.title;\r\n cloned.tvClipCount = this.tvClipCount;\r\n cloned.volume = this.volume;\r\n cloned.viewCount = this.viewCount;\r\n cloned.weeklyViewCount = this.weeklyViewCount;\r\n cloned.loginRequired = this.loginRequired;\r\n cloned.contentWarning = this.contentWarning;\r\n return cloned;\r\n }\r\n\r\n /**\r\n * Whether this model represents the result of a TV search query.\r\n */\r\n get isTvSearchResult(): boolean {\r\n return (\r\n this.hitType === 'tv_clip' && this.hitRequestSource === 'search_query'\r\n );\r\n }\r\n\r\n /**\r\n * Determines the appropriate tile flags for the given search result\r\n * (login required and/or content warning)\r\n */\r\n private getFlags(result: SearchResult): TileFlags {\r\n const flags: TileFlags = {\r\n loginRequired: false,\r\n contentWarning: false,\r\n };\r\n\r\n // Check if item and item in \"modifying\" collection, setting above flags\r\n if (\r\n result.collection?.values.length &&\r\n result.mediatype?.value !== 'collection'\r\n ) {\r\n for (const collection of result.collection?.values ?? []) {\r\n if (collection === 'loggedin') {\r\n flags.loginRequired = true;\r\n if (flags.contentWarning) break;\r\n }\r\n if (collection === 'no-preview') {\r\n flags.contentWarning = true;\r\n if (flags.loginRequired) break;\r\n }\r\n }\r\n }\r\n\r\n return flags;\r\n }\r\n\r\n private static cleanIdentifier(\r\n identifier: string | undefined,\r\n ): string | undefined {\r\n // Some identifiers (e.g., from Whisper) represent documents rather than items, and\r\n // are suffixed with values that need to be stripped. Those values are separated\r\n // from the item identifier itself with '|'.\r\n const barIndex = identifier?.indexOf('|') ?? -1;\r\n const cleaned = barIndex > 0 ? identifier?.slice(0, barIndex) : identifier;\r\n return cleaned;\r\n }\r\n}\r\n\r\nexport type RequestKind = 'full' | 'hits' | 'aggregations';\r\n\r\nexport type CollectionDisplayMode = 'grid' | 'list-compact' | 'list-detail';\r\n\r\nexport type TileDisplayMode =\r\n | 'grid'\r\n | 'list-compact'\r\n | 'list-detail'\r\n | 'list-header';\r\n\r\n/**\r\n * This is mainly used to set the cookies for the collection display mode.\r\n *\r\n * It allows the user to set different modes for different contexts (collection page, search page, profile page etc).\r\n */\r\nexport type CollectionBrowserContext = 'collection' | 'search' | 'profile';\r\n\r\n/**\r\n * The sort fields shown in the sort filter bar\r\n */\r\nexport enum SortField {\r\n 'default' = 'default',\r\n 'unrecognized' = 'unrecognized',\r\n 'relevance' = 'relevance',\r\n 'alltimeview' = 'alltimeview',\r\n 'weeklyview' = 'weeklyview',\r\n 'title' = 'title',\r\n 'date' = 'date',\r\n 'datearchived' = 'datearchived',\r\n 'datereviewed' = 'datereviewed',\r\n 'dateadded' = 'dateadded',\r\n 'datefavorited' = 'datefavorited',\r\n 'creator' = 'creator',\r\n}\r\n\r\n/**\r\n * Views-related sort fields\r\n */\r\nexport const ALL_VIEWS_SORT_FIELDS = [\r\n SortField.weeklyview,\r\n SortField.alltimeview,\r\n] as const;\r\nexport type ViewsSortField = (typeof ALL_VIEWS_SORT_FIELDS)[number];\r\n\r\n/**\r\n * Date-related sort fields\r\n */\r\nexport const ALL_DATE_SORT_FIELDS = [\r\n SortField.datefavorited,\r\n SortField.date,\r\n SortField.datearchived,\r\n SortField.datereviewed,\r\n SortField.dateadded,\r\n] as const;\r\nexport type DateSortField = (typeof ALL_DATE_SORT_FIELDS)[number];\r\n\r\nexport interface SortOption {\r\n /**\r\n * The SortField enum member corresponding to this option.\r\n */\r\n field: SortField;\r\n\r\n /**\r\n * The default sort direction to apply when this sort option is first selected.\r\n */\r\n defaultSortDirection: SortDirection | null;\r\n\r\n /**\r\n * Whether this sort option allows its sort direction to be changed from the default.\r\n */\r\n canSetDirection: boolean;\r\n\r\n /**\r\n * Whether this sort option may appear in the sort bar.\r\n */\r\n shownInSortBar: boolean;\r\n\r\n /**\r\n * Whether this sort option should be saved to the URL.\r\n * If false, then no `sort` param will be added to the URL when this sort option\r\n * is selected.\r\n */\r\n shownInURL: boolean;\r\n\r\n /**\r\n * Whether this sort option is passed to the search service.\r\n * If false, then no sort param will be passed to the search service at all when\r\n * this sort option is selected.\r\n */\r\n handledBySearchService: boolean;\r\n\r\n /**\r\n * The string identifying this sort field to the search service & backend API.\r\n */\r\n searchServiceKey?: string;\r\n\r\n /**\r\n * The human-readable name to use for this option in the sort bar (if applicable).\r\n */\r\n displayName: string;\r\n\r\n /**\r\n * A list of URL param keys that should be mapped to this sort option.\r\n * E.g., both `title` and `titleSorter` in the URL map to the `SortField.title` option.\r\n */\r\n urlNames: (string | null | undefined)[];\r\n}\r\n\r\nexport const SORT_OPTIONS: Record<SortField, SortOption> = {\r\n // Default sort is the case where the user has not specified a sort option via the sort bar or URL.\r\n // In these cases, we defer to whatever sort the backend chooses.\r\n // For the search page, the default is always relevance sort.\r\n // For collection pages _without a query_, the default is usually weekly views, but this can be\r\n // overridden by the collection's `sort-by` metadata entry. If a query _is_ specified, then the\r\n // default is again relevance sort.\r\n // For fav-* collections only, the default is instead sorting by date favorited.\r\n [SortField.default]: {\r\n field: SortField.default,\r\n defaultSortDirection: null,\r\n canSetDirection: false,\r\n shownInSortBar: false,\r\n shownInURL: false,\r\n handledBySearchService: false, // We rely on the PPS default sort handling in these cases\r\n displayName: '',\r\n urlNames: ['', null, undefined], // Empty or nullish sort params result in default sorting\r\n },\r\n // Unrecognized sort is the case where the user has specified a sort in the URL, but it is not\r\n // one of the options listed in this map. We still want these unrecognized sorts to be applied\r\n // when searching, but they are not displayed in the sort bar and we do not actively manage\r\n // their URL param beyond flipping the direction as needed.\r\n [SortField.unrecognized]: {\r\n field: SortField.unrecognized,\r\n defaultSortDirection: null,\r\n canSetDirection: true,\r\n shownInSortBar: false,\r\n shownInURL: false,\r\n handledBySearchService: true, // The unrecognized sort param is passed along as-is\r\n displayName: '',\r\n urlNames: [],\r\n },\r\n // Relevance sort is unique in that it does not produce a URL param when it is set.\r\n // It is only available when there is a user-specified query that relevancy can be scored against.\r\n // Therefore, it does not appear as a sort bar option when browsing a collection with no query set.\r\n [SortField.relevance]: {\r\n field: SortField.relevance,\r\n defaultSortDirection: null,\r\n canSetDirection: false,\r\n shownInSortBar: true,\r\n shownInURL: false,\r\n handledBySearchService: false,\r\n displayName: 'Relevance',\r\n urlNames: ['_score'],\r\n },\r\n [SortField.alltimeview]: {\r\n field: SortField.alltimeview,\r\n defaultSortDirection: 'desc',\r\n canSetDirection: true,\r\n shownInSortBar: true,\r\n shownInURL: true,\r\n handledBySearchService: true,\r\n searchServiceKey: 'downloads',\r\n displayName: 'All-time views',\r\n urlNames: ['downloads'],\r\n },\r\n [SortField.weeklyview]: {\r\n field: SortField.weeklyview,\r\n defaultSortDirection: 'desc',\r\n canSetDirection: true,\r\n shownInSortBar: true,\r\n shownInURL: true,\r\n handledBySearchService: true,\r\n searchServiceKey: 'week',\r\n displayName: 'Weekly views',\r\n urlNames: ['week'],\r\n },\r\n [SortField.title]: {\r\n field: SortField.title,\r\n defaultSortDirection: 'asc',\r\n canSetDirection: true,\r\n shownInSortBar: true,\r\n shownInURL: true,\r\n handledBySearchService: true,\r\n searchServiceKey: 'titleSorter',\r\n displayName: 'Title',\r\n urlNames: ['title', 'titleSorter'],\r\n },\r\n [SortField.date]: {\r\n field: SortField.date,\r\n defaultSortDirection: 'desc',\r\n canSetDirection: true,\r\n shownInSortBar: true,\r\n shownInURL: true,\r\n handledBySearchService: true,\r\n searchServiceKey: 'date',\r\n displayName: 'Date published',\r\n urlNames: ['date'],\r\n },\r\n [SortField.datearchived]: {\r\n field: SortField.datearchived,\r\n defaultSortDirection: 'desc',\r\n canSetDirection: true,\r\n shownInSortBar: true,\r\n shownInURL: true,\r\n handledBySearchService: true,\r\n searchServiceKey: 'publicdate',\r\n displayName: 'Date archived',\r\n urlNames: ['publicdate'],\r\n },\r\n [SortField.datereviewed]: {\r\n field: SortField.datereviewed,\r\n defaultSortDirection: 'desc',\r\n canSetDirection: true,\r\n shownInSortBar: true,\r\n shownInURL: true,\r\n handledBySearchService: true,\r\n searchServiceKey: 'reviewdate',\r\n displayName: 'Date reviewed',\r\n urlNames: ['reviewdate'],\r\n },\r\n [SortField.dateadded]: {\r\n field: SortField.dateadded,\r\n defaultSortDirection: 'desc',\r\n canSetDirection: true,\r\n shownInSortBar: true,\r\n shownInURL: true,\r\n handledBySearchService: true,\r\n searchServiceKey: 'addeddate',\r\n displayName: 'Date added',\r\n urlNames: ['addeddate'],\r\n },\r\n [SortField.datefavorited]: {\r\n field: SortField.datefavorited,\r\n defaultSortDirection: 'desc',\r\n canSetDirection: false,\r\n shownInSortBar: true, // But only when viewing fav-* collections\r\n shownInURL: false,\r\n handledBySearchService: false,\r\n searchServiceKey: 'favoritedate',\r\n displayName: 'Date favorited',\r\n urlNames: ['favoritedate'],\r\n },\r\n [SortField.creator]: {\r\n field: SortField.creator,\r\n defaultSortDirection: 'asc',\r\n canSetDirection: true,\r\n shownInSortBar: true,\r\n shownInURL: true,\r\n handledBySearchService: true,\r\n searchServiceKey: 'creatorSorter',\r\n displayName: 'Creator',\r\n urlNames: ['creator', 'creatorSorter'],\r\n },\r\n};\r\n\r\n/**\r\n * Returns the SortOption corresponding to the given API sort name, or\r\n * the \"unrecognized\" SortOption if none matches.\r\n */\r\nexport function sortOptionFromAPIString(sortName?: string | null): SortOption {\r\n return (\r\n Object.values(SORT_OPTIONS).find(opt =>\r\n opt.urlNames.some(name => sortName === name),\r\n ) ?? SORT_OPTIONS[SortField.unrecognized]\r\n );\r\n}\r\n\r\nexport const defaultSortAvailability: Record<SortField, boolean> = {\r\n [SortField.relevance]: true,\r\n [SortField.weeklyview]: true,\r\n [SortField.alltimeview]: true,\r\n [SortField.title]: true,\r\n [SortField.datefavorited]: false,\r\n [SortField.date]: true,\r\n [SortField.datearchived]: true,\r\n [SortField.datereviewed]: true,\r\n [SortField.dateadded]: true,\r\n [SortField.creator]: true,\r\n [SortField.default]: false,\r\n [SortField.unrecognized]: false,\r\n};\r\n\r\nexport const favoritesSortAvailability: Record<SortField, boolean> = {\r\n ...defaultSortAvailability,\r\n [SortField.datefavorited]: true,\r\n};\r\n\r\nexport const tvSortAvailability: Record<SortField, boolean> = {\r\n ...defaultSortAvailability,\r\n [SortField.date]: false,\r\n [SortField.datereviewed]: false,\r\n [SortField.dateadded]: false,\r\n};\r\n\r\nexport const defaultProfileElementSorts: Record<\r\n string,\r\n Exclude<SortField, SortField.default>\r\n> = {\r\n uploads: SortField.datearchived,\r\n reviews: SortField.datereviewed,\r\n collections: SortField.datearchived,\r\n web_archives: SortField.datearchived,\r\n};\r\n\r\n/** A union of the fields that permit prefix filtering (e.g., alphabetical filtering) */\r\nexport type PrefixFilterType = 'title' | 'creator';\r\n\r\n/** A map from prefixes (e.g., initial letters) to the number of items matching that prefix */\r\nexport type PrefixFilterCounts = Record<string, number>;\r\n\r\n/**\r\n * A map from prefix filter types to the corresponding aggregation keys\r\n * that are needed to fetch the filter counts from the backend.\r\n */\r\nexport const prefixFilterAggregationKeys: Record<PrefixFilterType, string> = {\r\n title: 'firstTitle',\r\n creator: 'firstCreator',\r\n};\r\n\r\n/**\r\n * Different facet loading strategies that can be used with collection browser.\r\n * - `eager`: Facet data is always loaded as soon as a search is performed\r\n * - `lazy-mobile`: In the desktop layout, functions exactly as `eager`.\r\n * In the mobile layout, facet data will only be loaded once the \"Filters\" accordion is opened.\r\n * - `opt-in-or-login`: Same as `opt-in` for guest users not logged into an account, but same as `eager` for\r\n * any logged in user.\r\n * - `opt-in`: In the desktop layout, facet data will only be loaded after the user presses a \"Load Facets\" button.\r\n * In the mobile layout, functions exactly as `lazy-mobile`.\r\n * - `off`: Facet data will never be loaded, and a message will be displayed in place of facets\r\n * indicating that they are unavailable.\r\n */\r\nexport type FacetLoadStrategy =\r\n | 'eager'\r\n | 'lazy-mobile'\r\n | 'opt-in-or-login'\r\n | 'opt-in'\r\n | 'off';\r\n\r\n/**\r\n * Union of the facet types that are available in the sidebar.\r\n */\r\nexport type FacetOption =\r\n | 'subject'\r\n | 'lending'\r\n | 'mediatype'\r\n | 'language'\r\n | 'creator'\r\n | 'collection'\r\n | 'year'\r\n // TV-specific facet options:\r\n | 'program'\r\n | 'person'\r\n | 'sponsor';\r\n\r\nexport type SelectedFacetState = 'selected' | 'hidden';\r\n\r\nexport type FacetState = SelectedFacetState | 'none';\r\n\r\nexport interface FacetBucket {\r\n key: string;\r\n count: number;\r\n state: FacetState;\r\n // for some facets, we augment the key with a display value\r\n displayText?: string;\r\n // for TV channel facets, we add a parenthesized secondary name\r\n extraNote?: string;\r\n}\r\n\r\nexport interface FacetGroup {\r\n title: string;\r\n key: FacetOption;\r\n buckets: FacetBucket[];\r\n}\r\n\r\n/**\r\n * Information about a user interaction event on a facet.\r\n */\r\nexport type FacetEventDetails = {\r\n /**\r\n * The type of facet that was interacted with (e.g., 'mediatype', 'language', ...).\r\n */\r\n facetType: FacetOption;\r\n /**\r\n * The bucket corresponding to the facet that was interacted with, including the\r\n * updated state of the facet after the interaction.\r\n */\r\n bucket: FacetBucket;\r\n /**\r\n * Whether the interaction occurred on a negative facet.\r\n */\r\n negative: boolean;\r\n};\r\n\r\nexport type FacetValue = string;\r\n\r\nexport type SelectedFacets = Partial<\r\n Record<FacetOption, Record<FacetValue, FacetBucket>>\r\n>;\r\n\r\nexport const getDefaultSelectedFacets = (): Required<SelectedFacets> => ({\r\n subject: {},\r\n lending: {},\r\n mediatype: {},\r\n language: {},\r\n creator: {},\r\n collection: {},\r\n year: {},\r\n program: {},\r\n person: {},\r\n sponsor: {},\r\n});\r\n\r\n/**\r\n * For TV search results, what types of TV clips to restrict the results to.\r\n */\r\nexport type TvClipFilterType = 'all' | 'commercials' | 'factchecks' | 'quotes';\r\n\r\n/**\r\n * Map from TV clip filter types to their corresponding URL params\r\n */\r\nexport const tvClipFiltersToURLParams: Record<TvClipFilterType, string> = {\r\n all: '',\r\n commercials: 'only_commercials',\r\n factchecks: 'only_factchecks',\r\n quotes: 'only_quotes',\r\n};\r\n\r\n/**\r\n * Map from allowed TV filtering parameters in the URL to their corresponding filter type\r\n */\r\nexport const tvClipURLParamsToFilters: Record<string, TvClipFilterType> = {\r\n only_commercials: 'commercials',\r\n only_factchecks: 'factchecks',\r\n only_quotes: 'quotes',\r\n};\r\n\r\n/**\r\n * Facet display order when presenting results for all search types *except* TV (see below).\r\n */\r\nexport const defaultFacetDisplayOrder: FacetOption[] = [\r\n 'mediatype',\r\n // 'lending', Commenting this out removes the lending facet from the sidebar for now\r\n 'year',\r\n 'subject',\r\n 'collection',\r\n 'creator',\r\n 'language',\r\n];\r\n\r\n/**\r\n * Specialized facet ordering when displaying TV search results\r\n */\r\nexport const tvFacetDisplayOrder: FacetOption[] = [\r\n 'program',\r\n 'creator',\r\n 'year',\r\n 'subject',\r\n 'collection',\r\n 'person',\r\n 'sponsor',\r\n 'language',\r\n];\r\n\r\n/**\r\n * Human-readable titles for each facet group.\r\n */\r\nexport const facetTitles: Record<FacetOption, string> = {\r\n subject: 'Subject',\r\n lending: 'Availability',\r\n mediatype: 'Media Type',\r\n language: 'Language',\r\n creator: 'Creator',\r\n collection: 'Collection',\r\n year: 'Year',\r\n program: 'Program',\r\n person: 'Person',\r\n sponsor: 'Sponsor',\r\n};\r\n\r\n/**\r\n * The default sort type to use for each facet type\r\n */\r\nexport const defaultFacetSort: Record<FacetOption, AggregationSortType> = {\r\n subject: AggregationSortType.COUNT,\r\n lending: AggregationSortType.COUNT,\r\n mediatype: AggregationSortType.COUNT,\r\n language: AggregationSortType.COUNT,\r\n creator: AggregationSortType.COUNT,\r\n collection: AggregationSortType.COUNT,\r\n year: AggregationSortType.NUMERIC, // Year facets are ordered by their numeric value by default\r\n program: AggregationSortType.COUNT,\r\n person: AggregationSortType.COUNT,\r\n sponsor: AggregationSortType.COUNT,\r\n};\r\n\r\n/**\r\n * The sort type corresponding to facet bucket values, for each facet type\r\n * (i.e., the opposite of \"sort by count\" for that type).\r\n */\r\nexport const valueFacetSort: Record<FacetOption, AggregationSortType> = {\r\n subject: AggregationSortType.ALPHABETICAL,\r\n lending: AggregationSortType.ALPHABETICAL,\r\n mediatype: AggregationSortType.ALPHABETICAL,\r\n language: AggregationSortType.ALPHABETICAL,\r\n creator: AggregationSortType.ALPHABETICAL,\r\n collection: AggregationSortType.ALPHABETICAL,\r\n year: AggregationSortType.NUMERIC, // Year facets' values should be compared numerically, not lexicographically (year 2001 > year 3)\r\n program: AggregationSortType.ALPHABETICAL,\r\n person: AggregationSortType.ALPHABETICAL,\r\n sponsor: AggregationSortType.ALPHABETICAL,\r\n};\r\n\r\nexport type LendingFacetKey =\r\n | 'is_lendable'\r\n | 'is_borrowable'\r\n | 'available_to_borrow'\r\n | 'is_browsable'\r\n | 'available_to_browse'\r\n | 'is_readable'\r\n | 'available_to_waitlist';\r\n\r\n/**\r\n * Maps valid lending keys to whether they should be visible in the facet sidebar\r\n */\r\nexport const lendingFacetKeysVisibility: Record<LendingFacetKey, boolean> = {\r\n is_lendable: true,\r\n is_borrowable: false,\r\n available_to_borrow: true,\r\n is_browsable: false,\r\n available_to_browse: false,\r\n is_readable: true,\r\n available_to_waitlist: false,\r\n};\r\n\r\n/**\r\n * Maps valid, visible lending keys to their facet sidebar display text\r\n */\r\nexport const lendingFacetDisplayNames: Partial<\r\n Record<LendingFacetKey, string>\r\n> = {\r\n is_lendable: 'Lending Library',\r\n available_to_borrow: 'Borrow 14 Days',\r\n is_readable: 'Always Available',\r\n};\r\n\r\n/**\r\n * A record of which admin-only collections should be suppressed from being displayed\r\n * as facets or in an item's list of collections.\r\n */\r\nexport const suppressedCollections: Record<string, boolean> = {\r\n deemphasize: true,\r\n community: true,\r\n stream_only: true,\r\n samples_only: true,\r\n test_collection: true,\r\n printdisabled: true,\r\n 'openlibrary-ol': true,\r\n nationalemergencylibrary: true,\r\n china: true,\r\n americana: true,\r\n toronto: true,\r\n};\r\n\r\n/**\r\n * A record of manageable item\r\n */\r\nexport interface ManageableItem {\r\n identifier: string;\r\n title?: string;\r\n dateStr?: string;\r\n date?: string;\r\n}\r\n\r\n/**\r\n * Possible states for whether & how the user has overridden their user preference\r\n * for blurring behavior on tiles with sensitive content.\r\n * - `no-override`: The user has not overridden their user preference, so simply\r\n * respect the preference as given.\r\n * - `on`: The user has overridden their preference and wants tile blurring enabled.\r\n * - `off`: The user has overridden their preference and wants tile blurring disabled.\r\n */\r\nexport type TileBlurOverrideState = 'no-override' | 'on' | 'off';\r\n"]}
@@ -2,7 +2,7 @@ import { LitElement, PropertyValues, TemplateResult } from 'lit';
2
2
  import type { SharedResizeObserverInterface, SharedResizeObserverResizeHandlerInterface } from '@internetarchive/shared-resize-observer';
3
3
  import '@internetarchive/ia-dropdown';
4
4
  import type { SortDirection } from '@internetarchive/search-service';
5
- import { CollectionDisplayMode, PrefixFilterCounts, PrefixFilterType, SortField } from '../models';
5
+ import { CollectionDisplayMode, DateSortField, PrefixFilterCounts, PrefixFilterType, SortField, ViewsSortField } from '../models';
6
6
  import './alpha-bar';
7
7
  type AlphaSelector = 'creator' | 'title';
8
8
  export declare class SortFilterBar extends LitElement implements SharedResizeObserverResizeHandlerInterface {
@@ -12,6 +12,10 @@ export declare class SortFilterBar extends LitElement implements SharedResizeObs
12
12
  defaultSortDirection: SortDirection | null;
13
13
  /** The default sort field to use if none is set */
14
14
  defaultSortField: Exclude<SortField, SortField.default>;
15
+ /** Which view sort option to expose by default. */
16
+ defaultViewSort: ViewsSortField;
17
+ /** Which date sort option to expose by default */
18
+ defaultDateSort: DateSortField;
15
19
  /** The current sort direction (asc/desc), or null if none is set */
16
20
  sortDirection: SortDirection | null;
17
21
  /** The field currently being sorted on (e.g., 'title'). Defaults to relevance. */
@@ -20,10 +24,20 @@ export declare class SortFilterBar extends LitElement implements SharedResizeObs
20
24
  selectedTitleFilter: string | null;
21
25
  /** The currently selected creator letter filter, or null if none is set */
22
26
  selectedCreatorFilter: string | null;
23
- /** Whether to show the Relevance sort option (default `true`) */
24
- showRelevance: boolean;
25
- /** Whether to show the Date Favorited sort option instead of Date Published/Archived/Reviewed (default `false`) */
26
- showDateFavorited: boolean;
27
+ /**
28
+ * Map defining which sortable fields should be included on the sort bar.
29
+ *
30
+ * E.g.,
31
+ * ```
32
+ * {
33
+ * [SortField.relevance]: true,
34
+ * [SortField.date]: false,
35
+ * [SortField.title]: true,
36
+ * ...
37
+ * }
38
+ * ```
39
+ */
40
+ sortFieldAvailability: Record<SortField, boolean>;
27
41
  /** Whether to replace the default sort options with a slot for customization (default `false`) */
28
42
  enableSortOptionsSlot: boolean;
29
43
  /** Whether to suppress showing the three display mode options on the right of the bar (default `false`) */
@@ -70,9 +84,9 @@ export declare class SortFilterBar extends LitElement implements SharedResizeObs
70
84
  */
71
85
  private sortSelectorContainer;
72
86
  /** The dropdown component containing options for weekly and all-time views */
73
- private viewsDropdown;
74
- /** The dropdown component containing the four date options */
75
- private dateDropdown;
87
+ private viewsDropdown?;
88
+ /** The dropdown component containing all the available date options */
89
+ private dateDropdown?;
76
90
  /** The single, consolidated dropdown component shown in mobile view */
77
91
  private mobileDropdown;
78
92
  render(): TemplateResult<1>;
@@ -104,19 +118,16 @@ export declare class SortFilterBar extends LitElement implements SharedResizeObs
104
118
  /** The template to render all the sort options in mobile view */
105
119
  private get mobileSortSelectorTemplate();
106
120
  /**
107
- * This generates each of the non-dropdown sort option links.
121
+ * This generates each of the non-dropdown sort option buttons.
108
122
  *
109
123
  * It manages the display value and the selected state of the option.
110
124
  *
111
- * @param sortField
112
- * @param options {
113
- * onClick?: (e: Event) => void; If this is provided, it will also be called when the option is clicked.
114
- * displayName?: TemplateResult; The name to display for the option. Defaults to the sortField display name.
115
- * selected?: boolean; true if the option is selected. Defaults to the selectedSort === sortField.
116
- * }
117
- * @returns
125
+ * @param sortField Which sort field the button represents
126
+ * @param options Additional options:
127
+ * - `onSelected?: (e: Event) => void;` If this is provided, it will also be called when the option is selected.
128
+ * Default is to clear any selected alphabetical filters.
118
129
  */
119
- private getSortDisplayOption;
130
+ private getSortSelectorButton;
120
131
  /**
121
132
  * Generates a dropdown component containing multiple grouped sort options.
122
133
  *
@@ -136,10 +147,51 @@ export declare class SortFilterBar extends LitElement implements SharedResizeObs
136
147
  private getDropdownOption;
137
148
  /** Handler for when any sort dropdown option is selected */
138
149
  private dropdownOptionSelected;
139
- /** The template to render for the views dropdown */
150
+ /**
151
+ * Template for the Relevance sort selector button, or `nothing` if the relevance
152
+ * field is not available for display.
153
+ */
154
+ private get relevanceSortSelectorTemplate();
155
+ /**
156
+ * Template for the Views sort selector button.
157
+ * This is shown instead of the views dropdown when only a single views sort field
158
+ * is available.
159
+ */
160
+ private get viewsSortSelectorTemplate();
161
+ /**
162
+ * Template for the Title sort selector button, or `nothing` if the title field is
163
+ * not available for display.
164
+ */
165
+ private get titleSortSelectorTemplate();
166
+ /**
167
+ * Template for the Date sort selector button.
168
+ * This is shown instead of the dates dropdown when only a single date sort field
169
+ * is available.
170
+ */
171
+ private get dateSortSelectorTemplate();
172
+ /**
173
+ * Template for the Creator sort selector button, or `nothing` if the creator field
174
+ * is not available for display.
175
+ */
176
+ private get creatorSortSelectorTemplate();
177
+ /**
178
+ * Template for the Views dropdown, shown when 2+ views sort fields are available.
179
+ */
140
180
  private get viewsDropdownTemplate();
141
- /** The template to render for the date dropdown */
181
+ /**
182
+ * Template for the Date dropdown, shown when 2+ date sort fields are available.
183
+ */
142
184
  private get dateDropdownTemplate();
185
+ /**
186
+ * Provides the appropriate template to use for Views sorting, depending on how many
187
+ * views sort fields are available.
188
+ */
189
+ private get allViewsSortOptionsTemplate();
190
+ /**
191
+ * Provides the appropriate template to use for Date sorting, depending on how many
192
+ * date sort fields are available.
193
+ */
194
+ private get allDateSortOptionsTemplate();
143
195
  /** Handler for when a new mobile sort dropdown option is selected */
144
196
  private mobileSortChanged;
145
197
  /** Template for rendering the three display mode options */
@@ -187,11 +239,6 @@ export declare class SortFilterBar extends LitElement implements SharedResizeObs
187
239
  * @memberof SortFilterBar
188
240
  */
189
241
  private get viewOptionSelected();
190
- /**
191
- * The default field for the date sort dropdown.
192
- * This is Date Favorited when that option is available, or Date Published otherwise.
193
- */
194
- private get defaultDateSortField();
195
242
  /**
196
243
  * The display name of the last selected date field
197
244
  *
@@ -210,6 +257,14 @@ export declare class SortFilterBar extends LitElement implements SharedResizeObs
210
257
  * @memberof SortFilterBar
211
258
  */
212
259
  private get viewSortDisplayName();
260
+ /**
261
+ * Array of all the views sorts that should be shown
262
+ */
263
+ private get availableViewsFields();
264
+ /**
265
+ * Array of all the date sorts that should be shown
266
+ */
267
+ private get availableDateFields();
213
268
  private get titleSelectorBar();
214
269
  private get creatorSelectorBar();
215
270
  private titleLetterChanged;