@internetarchive/collection-browser 2.6.3 → 2.6.4-alpha.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.
@@ -1,5 +1,12 @@
1
+ import type { TemplateResult } from 'lit';
1
2
  import type { MediaType } from '@internetarchive/field-parsers';
2
3
  import { AggregationSortType, Review, SearchResult, SortDirection } from '@internetarchive/search-service';
4
+ /**
5
+ * Different types of tile overlays, corresponding to the above flags.
6
+ */
7
+ export declare type TileOverlayType = 'login-required' | 'content-warning';
8
+ export declare const TILE_OVERLAY_TEXT: Record<TileOverlayType, string>;
9
+ export declare const TILE_OVERLAY_ICONS: Record<TileOverlayType, TemplateResult>;
3
10
  /**
4
11
  * Class for converting & storing raw search results in the correct format for UI tiles.
5
12
  */
@@ -1,6 +1,17 @@
1
+ import { msg } from '@lit/localize';
1
2
  import { AggregationSortType, } from '@internetarchive/search-service';
2
3
  import { collapseRepeatedQuotes } from './utils/collapse-repeated-quotes';
3
4
  import { resolveMediatype } from './utils/resolve-mediatype';
5
+ import { loginRequiredIcon } from './assets/img/icons/login-required';
6
+ import { restrictedIcon } from './assets/img/icons/restricted';
7
+ export const TILE_OVERLAY_TEXT = {
8
+ 'login-required': msg('Log in to view this item'),
9
+ 'content-warning': msg('Content may be inappropriate'),
10
+ };
11
+ export const TILE_OVERLAY_ICONS = {
12
+ 'login-required': loginRequiredIcon,
13
+ 'content-warning': restrictedIcon,
14
+ };
4
15
  /**
5
16
  * Class for converting & storing raw search results in the correct format for UI tiles.
6
17
  */
@@ -1 +1 @@
1
- {"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,GAIpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAU7D;;GAEG;AACH,MAAM,OAAO,SAA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AA0B,GAAqC;IAC1E,WAAW,EAAE,IAAI;IACjB,aAAa,EAAE,KAAK;IACpB,mBAAmB,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 { MediaType } from '@internetarchive/field-parsers';\nimport {\n AggregationSortType,\n Review,\n SearchResult,\n SortDirection,\n} from '@internetarchive/search-service';\nimport { collapseRepeatedQuotes } from './utils/collapse-repeated-quotes';\nimport { resolveMediatype } from './utils/resolve-mediatype';\n\n/**\n * Flags that can affect the visibility of content on a tile\n */\ninterface TileFlags {\n loginRequired: boolean;\n contentWarning: boolean;\n}\n\n/**\n * Class for converting & storing raw search results in the correct format for UI tiles.\n */\nexport class TileModel {\n averageRating?: number;\n\n captureDates?: Date[]; // List of capture dates for a URL, used on profile Web Archives tiles\n\n checked: boolean; // Whether this tile is currently checked for item management functions\n\n collectionIdentifier?: string;\n\n collectionName?: string;\n\n collectionFilesCount: number;\n\n collections: string[];\n\n collectionSize: number;\n\n commentCount: number;\n\n creator?: string;\n\n creators: string[];\n\n dateStr?: string; // A string representation of the publication date, used strictly for passing preformatted dates to the parent\n\n dateAdded?: Date; // Date added to public search (software-defined) [from: addeddate]\n\n dateArchived?: Date; // Date archived (software-defined) item created on archive.org [from: publicdate]\n\n datePublished?: Date; // Date work published in the world (user-defined) [from: date]\n\n dateReviewed?: Date; // Date reviewed (user-created) most recent review [from: reviewdate]\n\n description?: string;\n\n favCount: number;\n\n href?: string;\n\n identifier?: string;\n\n issue?: string;\n\n itemCount: number;\n\n mediatype: MediaType;\n\n review?: Review;\n\n source?: string;\n\n snippets?: string[];\n\n subjects: string[];\n\n title: string;\n\n viewCount?: number;\n\n volume?: string;\n\n weeklyViewCount?: number;\n\n loginRequired: boolean;\n\n contentWarning: boolean;\n\n constructor(result: SearchResult) {\n const flags = this.getFlags(result);\n\n this.averageRating = result.avg_rating?.value;\n this.captureDates = result.capture_dates?.values;\n this.checked = false;\n this.collections = result.collection?.values ?? [];\n this.collectionFilesCount = result.collection_files_count?.value ?? 0;\n this.collectionSize = result.collection_size?.value ?? 0;\n this.commentCount = result.num_reviews?.value ?? 0;\n this.creator = result.creator?.value;\n this.creators = result.creator?.values ?? [];\n this.dateAdded = result.addeddate?.value;\n this.dateArchived = result.publicdate?.value;\n this.datePublished = result.date?.value;\n this.dateReviewed = result.reviewdate?.value;\n this.description = result.description?.values.join('\\n');\n this.favCount = result.num_favorites?.value ?? 0;\n this.href = collapseRepeatedQuotes(\n result.review?.__href__ ?? result.__href__?.value\n );\n this.identifier = result.identifier;\n this.issue = result.issue?.value;\n this.itemCount = result.item_count?.value ?? 0;\n this.mediatype = resolveMediatype(result);\n this.review = result.review;\n this.snippets = result.highlight?.values ?? [];\n this.source = result.source?.value;\n this.subjects = result.subject?.values ?? [];\n this.title = result.title?.value ?? '';\n this.volume = result.volume?.value;\n this.viewCount = result.downloads?.value;\n this.weeklyViewCount = result.week?.value;\n this.loginRequired = flags.loginRequired;\n this.contentWarning = flags.contentWarning;\n }\n\n /**\n * Copies the contents of this TileModel onto a new instance\n */\n clone(): TileModel {\n const cloned = new TileModel({});\n cloned.averageRating = this.averageRating;\n cloned.captureDates = this.captureDates;\n cloned.checked = this.checked;\n cloned.collections = this.collections;\n cloned.collectionFilesCount = this.collectionFilesCount;\n cloned.collectionSize = this.collectionSize;\n cloned.commentCount = this.commentCount;\n cloned.creator = this.creator;\n cloned.creators = this.creators;\n cloned.dateStr = this.dateStr;\n cloned.dateAdded = this.dateAdded;\n cloned.dateArchived = this.dateArchived;\n cloned.datePublished = this.datePublished;\n cloned.dateReviewed = this.dateReviewed;\n cloned.description = this.description;\n cloned.favCount = this.favCount;\n cloned.href = this.href;\n cloned.identifier = this.identifier;\n cloned.issue = this.issue;\n cloned.itemCount = this.itemCount;\n cloned.mediatype = this.mediatype;\n cloned.snippets = this.snippets;\n cloned.source = this.source;\n cloned.subjects = this.subjects;\n cloned.title = this.title;\n cloned.volume = this.volume;\n cloned.viewCount = this.viewCount;\n cloned.weeklyViewCount = this.weeklyViewCount;\n cloned.loginRequired = this.loginRequired;\n cloned.contentWarning = this.contentWarning;\n return cloned;\n }\n\n /**\n * Determines the appropriate tile flags for the given search result\n * (login required and/or content warning)\n */\n private getFlags(result: SearchResult): TileFlags {\n const flags: TileFlags = {\n loginRequired: false,\n contentWarning: false,\n };\n\n // Check if item and item in \"modifying\" collection, setting above flags\n if (\n result.collection?.values.length &&\n result.mediatype?.value !== 'collection'\n ) {\n for (const collection of result.collection?.values ?? []) {\n if (collection === 'loggedin') {\n flags.loginRequired = true;\n if (flags.contentWarning) break;\n }\n if (collection === 'no-preview') {\n flags.contentWarning = true;\n if (flags.loginRequired) break;\n }\n }\n }\n\n return flags;\n }\n}\n\nexport type RequestKind = 'full' | 'hits' | 'aggregations';\n\nexport type CollectionDisplayMode = 'grid' | 'list-compact' | 'list-detail';\n\nexport type TileDisplayMode =\n | 'grid'\n | 'list-compact'\n | 'list-detail'\n | 'list-header';\n\n/**\n * This is mainly used to set the cookies for the collection display mode.\n *\n * It allows the user to set different modes for different contexts (collection page, search page, etc).\n */\nexport type CollectionBrowserContext = 'collection' | 'search';\n\n/**\n * The sort fields shown in the sort filter bar\n */\nexport enum SortField {\n 'default' = 'default',\n 'unrecognized' = 'unrecognized',\n 'relevance' = 'relevance',\n 'alltimeview' = 'alltimeview',\n 'weeklyview' = 'weeklyview',\n 'title' = 'title',\n 'date' = 'date',\n 'datearchived' = 'datearchived',\n 'datereviewed' = 'datereviewed',\n 'dateadded' = 'dateadded',\n 'datefavorited' = 'datefavorited',\n 'creator' = 'creator',\n}\n\nexport interface SortOption {\n /**\n * The SortField enum member corresponding to this option.\n */\n field: SortField;\n\n /**\n * The default sort direction to apply when this sort option is first selected.\n */\n defaultSortDirection: SortDirection | null;\n\n /**\n * Whether this sort option allows its sort direction to be changed from the default.\n */\n canSetDirection: boolean;\n\n /**\n * Whether this sort option may appear in the sort bar.\n */\n shownInSortBar: boolean;\n\n /**\n * Whether this sort option should be saved to the URL.\n * If false, then no `sort` param will be added to the URL when this sort option\n * is selected.\n */\n shownInURL: boolean;\n\n /**\n * Whether this sort option is passed to the search service.\n * If false, then no sort param will be passed to the search service at all when\n * this sort option is selected.\n */\n handledBySearchService: boolean;\n\n /**\n * The string identifying this sort field to the search service & backend API.\n */\n searchServiceKey?: string;\n\n /**\n * The human-readable name to use for this option in the sort bar (if applicable).\n */\n displayName: string;\n\n /**\n * A list of URL param keys that should be mapped to this sort option.\n * E.g., both `title` and `titleSorter` in the URL map to the `SortField.title` option.\n */\n urlNames: (string | null | undefined)[];\n}\n\nexport const SORT_OPTIONS: Record<SortField, SortOption> = {\n // Default sort is the case where the user has not specified a sort option via the sort bar or URL.\n // In these cases, we defer to whatever sort the backend chooses.\n // For the search page, the default is always relevance sort.\n // For collection pages _without a query_, the default is usually weekly views, but this can be\n // overridden by the collection's `sort-by` metadata entry. If a query _is_ specified, then the\n // default is again relevance sort.\n // For fav-* collections only, the default is instead sorting by date favorited.\n [SortField.default]: {\n field: SortField.default,\n defaultSortDirection: null,\n canSetDirection: false,\n shownInSortBar: false,\n shownInURL: false,\n handledBySearchService: false, // We rely on the PPS default sort handling in these cases\n displayName: '',\n urlNames: ['', null, undefined], // Empty or nullish sort params result in default sorting\n },\n // Unrecognized sort is the case where the user has specified a sort in the URL, but it is not\n // one of the options listed in this map. We still want these unrecognized sorts to be applied\n // when searching, but they are not displayed in the sort bar and we do not actively manage\n // their URL param beyond flipping the direction as needed.\n [SortField.unrecognized]: {\n field: SortField.unrecognized,\n defaultSortDirection: null,\n canSetDirection: true,\n shownInSortBar: false,\n shownInURL: false,\n handledBySearchService: true, // The unrecognized sort param is passed along as-is\n displayName: '',\n urlNames: [],\n },\n // Relevance sort is unique in that it does not produce a URL param when it is set.\n // It is only available when there is a user-specified query that relevancy can be scored against.\n // Therefore, it does not appear as a sort bar option when browsing a collection with no query set.\n [SortField.relevance]: {\n field: SortField.relevance,\n defaultSortDirection: null,\n canSetDirection: false,\n shownInSortBar: true,\n shownInURL: false,\n handledBySearchService: false,\n displayName: 'Relevance',\n urlNames: ['_score'],\n },\n [SortField.alltimeview]: {\n field: SortField.alltimeview,\n defaultSortDirection: 'desc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'downloads',\n displayName: 'All-time views',\n urlNames: ['downloads'],\n },\n [SortField.weeklyview]: {\n field: SortField.weeklyview,\n defaultSortDirection: 'desc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'week',\n displayName: 'Weekly views',\n urlNames: ['week'],\n },\n [SortField.title]: {\n field: SortField.title,\n defaultSortDirection: 'asc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'titleSorter',\n displayName: 'Title',\n urlNames: ['title', 'titleSorter'],\n },\n [SortField.date]: {\n field: SortField.date,\n defaultSortDirection: 'desc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'date',\n displayName: 'Date published',\n urlNames: ['date'],\n },\n [SortField.datearchived]: {\n field: SortField.datearchived,\n defaultSortDirection: 'desc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'publicdate',\n displayName: 'Date archived',\n urlNames: ['publicdate'],\n },\n [SortField.datereviewed]: {\n field: SortField.datereviewed,\n defaultSortDirection: 'desc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'reviewdate',\n displayName: 'Date reviewed',\n urlNames: ['reviewdate'],\n },\n [SortField.dateadded]: {\n field: SortField.dateadded,\n defaultSortDirection: 'desc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'addeddate',\n displayName: 'Date added',\n urlNames: ['addeddate'],\n },\n [SortField.datefavorited]: {\n field: SortField.datefavorited,\n defaultSortDirection: 'desc',\n canSetDirection: false,\n shownInSortBar: true, // But only when viewing fav-* collections\n shownInURL: false,\n handledBySearchService: false,\n searchServiceKey: 'favoritedate',\n displayName: 'Date favorited',\n urlNames: ['favoritedate'],\n },\n [SortField.creator]: {\n field: SortField.creator,\n defaultSortDirection: 'asc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'creatorSorter',\n displayName: 'Creator',\n urlNames: ['creator', 'creatorSorter'],\n },\n};\n\n/**\n * Returns the SortOption corresponding to the given API sort name, or\n * the \"unrecognized\" SortOption if none matches.\n */\nexport function sortOptionFromAPIString(sortName?: string | null): SortOption {\n return (\n Object.values(SORT_OPTIONS).find(opt =>\n opt.urlNames.some(name => sortName === name)\n ) ?? SORT_OPTIONS[SortField.unrecognized]\n );\n}\n\nexport const defaultProfileElementSorts: Record<\n string,\n Exclude<SortField, SortField.default>\n> = {\n uploads: SortField.datearchived,\n reviews: SortField.datereviewed,\n collections: SortField.datearchived,\n web_archives: SortField.datearchived,\n};\n\n/** A union of the fields that permit prefix filtering (e.g., alphabetical filtering) */\nexport type PrefixFilterType = 'title' | 'creator';\n\n/** A map from prefixes (e.g., initial letters) to the number of items matching that prefix */\nexport type PrefixFilterCounts = Record<string, number>;\n\n/**\n * A map from prefix filter types to the corresponding aggregation keys\n * that are needed to fetch the filter counts from the backend.\n */\nexport const prefixFilterAggregationKeys: Record<PrefixFilterType, string> = {\n title: 'firstTitle',\n creator: 'firstCreator',\n};\n\n/**\n * Different facet loading strategies that can be used with collection browser.\n * - `eager`: Facet data is always loaded as soon as a search is performed\n * - `lazy-mobile`: In the desktop layout, functions exactly as `eager`.\n * In the mobile layout, facet data will only be loaded once the \"Filters\" accordion is opened.\n * - `opt-in-or-login`: Same as `opt-in` for guest users not logged into an account, but same as `eager` for\n * any logged in user.\n * - `opt-in`: In the desktop layout, facet data will only be loaded after the user presses a \"Load Facets\" button.\n * In the mobile layout, functions exactly as `lazy-mobile`.\n * - `off`: Facet data will never be loaded, and a message will be displayed in place of facets\n * indicating that they are unavailable.\n */\nexport type FacetLoadStrategy =\n | 'eager'\n | 'lazy-mobile'\n | 'opt-in-or-login'\n | 'opt-in'\n | 'off';\n\n/**\n * Union of the facet types that are available in the sidebar.\n */\nexport type FacetOption =\n | 'subject'\n | 'lending'\n | 'mediatype'\n | 'language'\n | 'creator'\n | 'collection'\n | 'year';\n\nexport type SelectedFacetState = 'selected' | 'hidden';\n\nexport type FacetState = SelectedFacetState | 'none';\n\nexport interface FacetBucket {\n // for some facets, we augment the key with a display value\n displayText?: string;\n key: string;\n count: number;\n state: FacetState;\n}\n\nexport interface FacetGroup {\n title: string;\n key: FacetOption;\n buckets: FacetBucket[];\n}\n\n/**\n * Information about a user interaction event on a facet.\n */\nexport type FacetEventDetails = {\n /**\n * The type of facet that was interacted with (e.g., 'mediatype', 'language', ...).\n */\n facetType: FacetOption;\n /**\n * The bucket corresponding to the facet that was interacted with, including the\n * updated state of the facet after the interaction.\n */\n bucket: FacetBucket;\n /**\n * Whether the interaction occurred on a negative facet.\n */\n negative: boolean;\n};\n\nexport type FacetValue = string;\n\nexport type SelectedFacets = Record<\n FacetOption,\n Record<FacetValue, FacetBucket>\n>;\n\nexport const getDefaultSelectedFacets = (): SelectedFacets => ({\n subject: {},\n lending: {},\n mediatype: {},\n language: {},\n creator: {},\n collection: {},\n year: {},\n});\n\nexport const facetDisplayOrder: FacetOption[] = [\n 'mediatype',\n 'lending',\n 'year',\n 'subject',\n 'collection',\n 'creator',\n 'language',\n];\n\nexport const facetTitles: Record<FacetOption, string> = {\n subject: 'Subject',\n lending: 'Availability',\n mediatype: 'Media Type',\n language: 'Language',\n creator: 'Creator',\n collection: 'Collection',\n year: 'Year',\n};\n\n/**\n * The default sort type to use for each facet type\n */\nexport const defaultFacetSort: Record<FacetOption, AggregationSortType> = {\n subject: AggregationSortType.COUNT,\n lending: AggregationSortType.COUNT,\n mediatype: AggregationSortType.COUNT,\n language: AggregationSortType.COUNT,\n creator: AggregationSortType.COUNT,\n collection: AggregationSortType.COUNT,\n year: AggregationSortType.NUMERIC,\n};\n\n/**\n * The sort type corresponding to facet bucket values, for each facet type\n * (i.e., the opposite of \"sort by count\" for that type).\n */\nexport const valueFacetSort: Record<FacetOption, AggregationSortType> = {\n subject: AggregationSortType.ALPHABETICAL,\n lending: AggregationSortType.ALPHABETICAL,\n mediatype: AggregationSortType.ALPHABETICAL,\n language: AggregationSortType.ALPHABETICAL,\n creator: AggregationSortType.ALPHABETICAL,\n collection: AggregationSortType.ALPHABETICAL,\n year: AggregationSortType.NUMERIC,\n};\n\nexport type LendingFacetKey =\n | 'is_lendable'\n | 'is_borrowable'\n | 'available_to_borrow'\n | 'is_browsable'\n | 'available_to_browse'\n | 'is_readable'\n | 'available_to_waitlist';\n\n/**\n * Maps valid lending keys to whether they should be visible in the facet sidebar\n */\nexport const lendingFacetKeysVisibility: Record<LendingFacetKey, boolean> = {\n is_lendable: true,\n is_borrowable: false,\n available_to_borrow: true,\n is_browsable: false,\n available_to_browse: false,\n is_readable: true,\n available_to_waitlist: false,\n};\n\n/**\n * Maps valid, visible lending keys to their facet sidebar display text\n */\nexport const lendingFacetDisplayNames: Partial<\n Record<LendingFacetKey, string>\n> = {\n is_lendable: 'Lending Library',\n available_to_borrow: 'Borrow 14 Days',\n is_readable: 'Always Available',\n};\n\n/**\n * A record of which admin-only collections should be suppressed from being displayed\n * as facets or in an item's list of collections.\n */\nexport const suppressedCollections: Record<string, boolean> = {\n deemphasize: true,\n community: true,\n stream_only: true,\n samples_only: true,\n test_collection: true,\n printdisabled: true,\n 'openlibrary-ol': true,\n nationalemergencylibrary: true,\n china: true,\n americana: true,\n toronto: true,\n};\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,GAIpB,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;IAmEpB,YAAY,MAAoB;;QAC9B,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAEpC,IAAI,CAAC,aAAa,GAAG,MAAA,MAAM,CAAC,UAAU,0CAAE,KAAK,CAAC;QAC9C,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qB,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';\nimport { msg } from '@lit/localize';\nimport type { MediaType } from '@internetarchive/field-parsers';\nimport {\n AggregationSortType,\n Review,\n SearchResult,\n SortDirection,\n} from '@internetarchive/search-service';\nimport { collapseRepeatedQuotes } from './utils/collapse-repeated-quotes';\nimport { resolveMediatype } from './utils/resolve-mediatype';\n\nimport { loginRequiredIcon } from './assets/img/icons/login-required';\nimport { restrictedIcon } from './assets/img/icons/restricted';\n\n/**\n * Flags that can affect the visibility of content on a tile\n */\ninterface TileFlags {\n loginRequired: boolean;\n contentWarning: boolean;\n}\n\n/**\n * Different types of tile overlays, corresponding to the above flags.\n */\nexport type TileOverlayType = 'login-required' | 'content-warning';\n\nexport const TILE_OVERLAY_TEXT: Record<TileOverlayType, string> = {\n 'login-required': msg('Log in to view this item'),\n 'content-warning': msg('Content may be inappropriate'),\n};\n\nexport const TILE_OVERLAY_ICONS: Record<TileOverlayType, TemplateResult> = {\n 'login-required': loginRequiredIcon,\n 'content-warning': restrictedIcon,\n};\n\n/**\n * Class for converting & storing raw search results in the correct format for UI tiles.\n */\nexport class TileModel {\n averageRating?: number;\n\n captureDates?: Date[]; // List of capture dates for a URL, used on profile Web Archives tiles\n\n checked: boolean; // Whether this tile is currently checked for item management functions\n\n collectionIdentifier?: string;\n\n collectionName?: string;\n\n collectionFilesCount: number;\n\n collections: string[];\n\n collectionSize: number;\n\n commentCount: number;\n\n creator?: string;\n\n creators: string[];\n\n dateStr?: string; // A string representation of the publication date, used strictly for passing preformatted dates to the parent\n\n dateAdded?: Date; // Date added to public search (software-defined) [from: addeddate]\n\n dateArchived?: Date; // Date archived (software-defined) item created on archive.org [from: publicdate]\n\n datePublished?: Date; // Date work published in the world (user-defined) [from: date]\n\n dateReviewed?: Date; // Date reviewed (user-created) most recent review [from: reviewdate]\n\n description?: string;\n\n favCount: number;\n\n href?: string;\n\n identifier?: string;\n\n issue?: string;\n\n itemCount: number;\n\n mediatype: MediaType;\n\n review?: Review;\n\n source?: string;\n\n snippets?: string[];\n\n subjects: string[];\n\n title: string;\n\n viewCount?: number;\n\n volume?: string;\n\n weeklyViewCount?: number;\n\n loginRequired: boolean;\n\n contentWarning: boolean;\n\n constructor(result: SearchResult) {\n const flags = this.getFlags(result);\n\n this.averageRating = result.avg_rating?.value;\n this.captureDates = result.capture_dates?.values;\n this.checked = false;\n this.collections = result.collection?.values ?? [];\n this.collectionFilesCount = result.collection_files_count?.value ?? 0;\n this.collectionSize = result.collection_size?.value ?? 0;\n this.commentCount = result.num_reviews?.value ?? 0;\n this.creator = result.creator?.value;\n this.creators = result.creator?.values ?? [];\n this.dateAdded = result.addeddate?.value;\n this.dateArchived = result.publicdate?.value;\n this.datePublished = result.date?.value;\n this.dateReviewed = result.reviewdate?.value;\n this.description = result.description?.values.join('\\n');\n this.favCount = result.num_favorites?.value ?? 0;\n this.href = collapseRepeatedQuotes(\n result.review?.__href__ ?? result.__href__?.value\n );\n this.identifier = result.identifier;\n this.issue = result.issue?.value;\n this.itemCount = result.item_count?.value ?? 0;\n this.mediatype = resolveMediatype(result);\n this.review = result.review;\n this.snippets = result.highlight?.values ?? [];\n this.source = result.source?.value;\n this.subjects = result.subject?.values ?? [];\n this.title = result.title?.value ?? '';\n this.volume = result.volume?.value;\n this.viewCount = result.downloads?.value;\n this.weeklyViewCount = result.week?.value;\n this.loginRequired = flags.loginRequired;\n this.contentWarning = flags.contentWarning;\n }\n\n /**\n * Copies the contents of this TileModel onto a new instance\n */\n clone(): TileModel {\n const cloned = new TileModel({});\n cloned.averageRating = this.averageRating;\n cloned.captureDates = this.captureDates;\n cloned.checked = this.checked;\n cloned.collections = this.collections;\n cloned.collectionFilesCount = this.collectionFilesCount;\n cloned.collectionSize = this.collectionSize;\n cloned.commentCount = this.commentCount;\n cloned.creator = this.creator;\n cloned.creators = this.creators;\n cloned.dateStr = this.dateStr;\n cloned.dateAdded = this.dateAdded;\n cloned.dateArchived = this.dateArchived;\n cloned.datePublished = this.datePublished;\n cloned.dateReviewed = this.dateReviewed;\n cloned.description = this.description;\n cloned.favCount = this.favCount;\n cloned.href = this.href;\n cloned.identifier = this.identifier;\n cloned.issue = this.issue;\n cloned.itemCount = this.itemCount;\n cloned.mediatype = this.mediatype;\n cloned.snippets = this.snippets;\n cloned.source = this.source;\n cloned.subjects = this.subjects;\n cloned.title = this.title;\n cloned.volume = this.volume;\n cloned.viewCount = this.viewCount;\n cloned.weeklyViewCount = this.weeklyViewCount;\n cloned.loginRequired = this.loginRequired;\n cloned.contentWarning = this.contentWarning;\n return cloned;\n }\n\n /**\n * Determines the appropriate tile flags for the given search result\n * (login required and/or content warning)\n */\n private getFlags(result: SearchResult): TileFlags {\n const flags: TileFlags = {\n loginRequired: false,\n contentWarning: false,\n };\n\n // Check if item and item in \"modifying\" collection, setting above flags\n if (\n result.collection?.values.length &&\n result.mediatype?.value !== 'collection'\n ) {\n for (const collection of result.collection?.values ?? []) {\n if (collection === 'loggedin') {\n flags.loginRequired = true;\n if (flags.contentWarning) break;\n }\n if (collection === 'no-preview') {\n flags.contentWarning = true;\n if (flags.loginRequired) break;\n }\n }\n }\n\n return flags;\n }\n}\n\nexport type RequestKind = 'full' | 'hits' | 'aggregations';\n\nexport type CollectionDisplayMode = 'grid' | 'list-compact' | 'list-detail';\n\nexport type TileDisplayMode =\n | 'grid'\n | 'list-compact'\n | 'list-detail'\n | 'list-header';\n\n/**\n * This is mainly used to set the cookies for the collection display mode.\n *\n * It allows the user to set different modes for different contexts (collection page, search page, etc).\n */\nexport type CollectionBrowserContext = 'collection' | 'search';\n\n/**\n * The sort fields shown in the sort filter bar\n */\nexport enum SortField {\n 'default' = 'default',\n 'unrecognized' = 'unrecognized',\n 'relevance' = 'relevance',\n 'alltimeview' = 'alltimeview',\n 'weeklyview' = 'weeklyview',\n 'title' = 'title',\n 'date' = 'date',\n 'datearchived' = 'datearchived',\n 'datereviewed' = 'datereviewed',\n 'dateadded' = 'dateadded',\n 'datefavorited' = 'datefavorited',\n 'creator' = 'creator',\n}\n\nexport interface SortOption {\n /**\n * The SortField enum member corresponding to this option.\n */\n field: SortField;\n\n /**\n * The default sort direction to apply when this sort option is first selected.\n */\n defaultSortDirection: SortDirection | null;\n\n /**\n * Whether this sort option allows its sort direction to be changed from the default.\n */\n canSetDirection: boolean;\n\n /**\n * Whether this sort option may appear in the sort bar.\n */\n shownInSortBar: boolean;\n\n /**\n * Whether this sort option should be saved to the URL.\n * If false, then no `sort` param will be added to the URL when this sort option\n * is selected.\n */\n shownInURL: boolean;\n\n /**\n * Whether this sort option is passed to the search service.\n * If false, then no sort param will be passed to the search service at all when\n * this sort option is selected.\n */\n handledBySearchService: boolean;\n\n /**\n * The string identifying this sort field to the search service & backend API.\n */\n searchServiceKey?: string;\n\n /**\n * The human-readable name to use for this option in the sort bar (if applicable).\n */\n displayName: string;\n\n /**\n * A list of URL param keys that should be mapped to this sort option.\n * E.g., both `title` and `titleSorter` in the URL map to the `SortField.title` option.\n */\n urlNames: (string | null | undefined)[];\n}\n\nexport const SORT_OPTIONS: Record<SortField, SortOption> = {\n // Default sort is the case where the user has not specified a sort option via the sort bar or URL.\n // In these cases, we defer to whatever sort the backend chooses.\n // For the search page, the default is always relevance sort.\n // For collection pages _without a query_, the default is usually weekly views, but this can be\n // overridden by the collection's `sort-by` metadata entry. If a query _is_ specified, then the\n // default is again relevance sort.\n // For fav-* collections only, the default is instead sorting by date favorited.\n [SortField.default]: {\n field: SortField.default,\n defaultSortDirection: null,\n canSetDirection: false,\n shownInSortBar: false,\n shownInURL: false,\n handledBySearchService: false, // We rely on the PPS default sort handling in these cases\n displayName: '',\n urlNames: ['', null, undefined], // Empty or nullish sort params result in default sorting\n },\n // Unrecognized sort is the case where the user has specified a sort in the URL, but it is not\n // one of the options listed in this map. We still want these unrecognized sorts to be applied\n // when searching, but they are not displayed in the sort bar and we do not actively manage\n // their URL param beyond flipping the direction as needed.\n [SortField.unrecognized]: {\n field: SortField.unrecognized,\n defaultSortDirection: null,\n canSetDirection: true,\n shownInSortBar: false,\n shownInURL: false,\n handledBySearchService: true, // The unrecognized sort param is passed along as-is\n displayName: '',\n urlNames: [],\n },\n // Relevance sort is unique in that it does not produce a URL param when it is set.\n // It is only available when there is a user-specified query that relevancy can be scored against.\n // Therefore, it does not appear as a sort bar option when browsing a collection with no query set.\n [SortField.relevance]: {\n field: SortField.relevance,\n defaultSortDirection: null,\n canSetDirection: false,\n shownInSortBar: true,\n shownInURL: false,\n handledBySearchService: false,\n displayName: 'Relevance',\n urlNames: ['_score'],\n },\n [SortField.alltimeview]: {\n field: SortField.alltimeview,\n defaultSortDirection: 'desc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'downloads',\n displayName: 'All-time views',\n urlNames: ['downloads'],\n },\n [SortField.weeklyview]: {\n field: SortField.weeklyview,\n defaultSortDirection: 'desc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'week',\n displayName: 'Weekly views',\n urlNames: ['week'],\n },\n [SortField.title]: {\n field: SortField.title,\n defaultSortDirection: 'asc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'titleSorter',\n displayName: 'Title',\n urlNames: ['title', 'titleSorter'],\n },\n [SortField.date]: {\n field: SortField.date,\n defaultSortDirection: 'desc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'date',\n displayName: 'Date published',\n urlNames: ['date'],\n },\n [SortField.datearchived]: {\n field: SortField.datearchived,\n defaultSortDirection: 'desc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'publicdate',\n displayName: 'Date archived',\n urlNames: ['publicdate'],\n },\n [SortField.datereviewed]: {\n field: SortField.datereviewed,\n defaultSortDirection: 'desc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'reviewdate',\n displayName: 'Date reviewed',\n urlNames: ['reviewdate'],\n },\n [SortField.dateadded]: {\n field: SortField.dateadded,\n defaultSortDirection: 'desc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'addeddate',\n displayName: 'Date added',\n urlNames: ['addeddate'],\n },\n [SortField.datefavorited]: {\n field: SortField.datefavorited,\n defaultSortDirection: 'desc',\n canSetDirection: false,\n shownInSortBar: true, // But only when viewing fav-* collections\n shownInURL: false,\n handledBySearchService: false,\n searchServiceKey: 'favoritedate',\n displayName: 'Date favorited',\n urlNames: ['favoritedate'],\n },\n [SortField.creator]: {\n field: SortField.creator,\n defaultSortDirection: 'asc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'creatorSorter',\n displayName: 'Creator',\n urlNames: ['creator', 'creatorSorter'],\n },\n};\n\n/**\n * Returns the SortOption corresponding to the given API sort name, or\n * the \"unrecognized\" SortOption if none matches.\n */\nexport function sortOptionFromAPIString(sortName?: string | null): SortOption {\n return (\n Object.values(SORT_OPTIONS).find(opt =>\n opt.urlNames.some(name => sortName === name)\n ) ?? SORT_OPTIONS[SortField.unrecognized]\n );\n}\n\nexport const defaultProfileElementSorts: Record<\n string,\n Exclude<SortField, SortField.default>\n> = {\n uploads: SortField.datearchived,\n reviews: SortField.datereviewed,\n collections: SortField.datearchived,\n web_archives: SortField.datearchived,\n};\n\n/** A union of the fields that permit prefix filtering (e.g., alphabetical filtering) */\nexport type PrefixFilterType = 'title' | 'creator';\n\n/** A map from prefixes (e.g., initial letters) to the number of items matching that prefix */\nexport type PrefixFilterCounts = Record<string, number>;\n\n/**\n * A map from prefix filter types to the corresponding aggregation keys\n * that are needed to fetch the filter counts from the backend.\n */\nexport const prefixFilterAggregationKeys: Record<PrefixFilterType, string> = {\n title: 'firstTitle',\n creator: 'firstCreator',\n};\n\n/**\n * Different facet loading strategies that can be used with collection browser.\n * - `eager`: Facet data is always loaded as soon as a search is performed\n * - `lazy-mobile`: In the desktop layout, functions exactly as `eager`.\n * In the mobile layout, facet data will only be loaded once the \"Filters\" accordion is opened.\n * - `opt-in-or-login`: Same as `opt-in` for guest users not logged into an account, but same as `eager` for\n * any logged in user.\n * - `opt-in`: In the desktop layout, facet data will only be loaded after the user presses a \"Load Facets\" button.\n * In the mobile layout, functions exactly as `lazy-mobile`.\n * - `off`: Facet data will never be loaded, and a message will be displayed in place of facets\n * indicating that they are unavailable.\n */\nexport type FacetLoadStrategy =\n | 'eager'\n | 'lazy-mobile'\n | 'opt-in-or-login'\n | 'opt-in'\n | 'off';\n\n/**\n * Union of the facet types that are available in the sidebar.\n */\nexport type FacetOption =\n | 'subject'\n | 'lending'\n | 'mediatype'\n | 'language'\n | 'creator'\n | 'collection'\n | 'year';\n\nexport type SelectedFacetState = 'selected' | 'hidden';\n\nexport type FacetState = SelectedFacetState | 'none';\n\nexport interface FacetBucket {\n // for some facets, we augment the key with a display value\n displayText?: string;\n key: string;\n count: number;\n state: FacetState;\n}\n\nexport interface FacetGroup {\n title: string;\n key: FacetOption;\n buckets: FacetBucket[];\n}\n\n/**\n * Information about a user interaction event on a facet.\n */\nexport type FacetEventDetails = {\n /**\n * The type of facet that was interacted with (e.g., 'mediatype', 'language', ...).\n */\n facetType: FacetOption;\n /**\n * The bucket corresponding to the facet that was interacted with, including the\n * updated state of the facet after the interaction.\n */\n bucket: FacetBucket;\n /**\n * Whether the interaction occurred on a negative facet.\n */\n negative: boolean;\n};\n\nexport type FacetValue = string;\n\nexport type SelectedFacets = Record<\n FacetOption,\n Record<FacetValue, FacetBucket>\n>;\n\nexport const getDefaultSelectedFacets = (): SelectedFacets => ({\n subject: {},\n lending: {},\n mediatype: {},\n language: {},\n creator: {},\n collection: {},\n year: {},\n});\n\nexport const facetDisplayOrder: FacetOption[] = [\n 'mediatype',\n 'lending',\n 'year',\n 'subject',\n 'collection',\n 'creator',\n 'language',\n];\n\nexport const facetTitles: Record<FacetOption, string> = {\n subject: 'Subject',\n lending: 'Availability',\n mediatype: 'Media Type',\n language: 'Language',\n creator: 'Creator',\n collection: 'Collection',\n year: 'Year',\n};\n\n/**\n * The default sort type to use for each facet type\n */\nexport const defaultFacetSort: Record<FacetOption, AggregationSortType> = {\n subject: AggregationSortType.COUNT,\n lending: AggregationSortType.COUNT,\n mediatype: AggregationSortType.COUNT,\n language: AggregationSortType.COUNT,\n creator: AggregationSortType.COUNT,\n collection: AggregationSortType.COUNT,\n year: AggregationSortType.NUMERIC,\n};\n\n/**\n * The sort type corresponding to facet bucket values, for each facet type\n * (i.e., the opposite of \"sort by count\" for that type).\n */\nexport const valueFacetSort: Record<FacetOption, AggregationSortType> = {\n subject: AggregationSortType.ALPHABETICAL,\n lending: AggregationSortType.ALPHABETICAL,\n mediatype: AggregationSortType.ALPHABETICAL,\n language: AggregationSortType.ALPHABETICAL,\n creator: AggregationSortType.ALPHABETICAL,\n collection: AggregationSortType.ALPHABETICAL,\n year: AggregationSortType.NUMERIC,\n};\n\nexport type LendingFacetKey =\n | 'is_lendable'\n | 'is_borrowable'\n | 'available_to_borrow'\n | 'is_browsable'\n | 'available_to_browse'\n | 'is_readable'\n | 'available_to_waitlist';\n\n/**\n * Maps valid lending keys to whether they should be visible in the facet sidebar\n */\nexport const lendingFacetKeysVisibility: Record<LendingFacetKey, boolean> = {\n is_lendable: true,\n is_borrowable: false,\n available_to_borrow: true,\n is_browsable: false,\n available_to_browse: false,\n is_readable: true,\n available_to_waitlist: false,\n};\n\n/**\n * Maps valid, visible lending keys to their facet sidebar display text\n */\nexport const lendingFacetDisplayNames: Partial<\n Record<LendingFacetKey, string>\n> = {\n is_lendable: 'Lending Library',\n available_to_borrow: 'Borrow 14 Days',\n is_readable: 'Always Available',\n};\n\n/**\n * A record of which admin-only collections should be suppressed from being displayed\n * as facets or in an item's list of collections.\n */\nexport const suppressedCollections: Record<string, boolean> = {\n deemphasize: true,\n community: true,\n stream_only: true,\n samples_only: true,\n test_collection: true,\n printdisabled: true,\n 'openlibrary-ol': true,\n nationalemergencylibrary: true,\n china: true,\n americana: true,\n toronto: true,\n};\n"]}
@@ -13,5 +13,6 @@ export declare class ImageBlock extends LitElement {
13
13
  private get baseClass();
14
14
  private get iconOverlayTemplate();
15
15
  private get textOverlayTemplate();
16
+ private get overlayType();
16
17
  static get styles(): CSSResultGroup;
17
18
  }
@@ -42,35 +42,46 @@ let ImageBlock = class ImageBlock extends LitElement {
42
42
  };
43
43
  }
44
44
  get iconOverlayTemplate() {
45
- var _a, _b, _c;
45
+ // Only list tiles use the icon overlay
46
46
  if (!this.isListTile)
47
47
  return nothing;
48
- if (!((_a = this.model) === null || _a === void 0 ? void 0 : _a.loginRequired) && !((_b = this.model) === null || _b === void 0 ? void 0 : _b.contentWarning))
48
+ const { overlayType } = this;
49
+ if (!overlayType)
49
50
  return nothing;
50
51
  return html `
51
52
  <icon-overlay
52
- .loggedIn=${this.loggedIn}
53
- .loginRequired=${(_c = this.model) === null || _c === void 0 ? void 0 : _c.loginRequired}
54
- .isCompactTile=${this.isCompactTile}
53
+ class=${this.isCompactTile ? 'list-compact' : 'list-detail'}
54
+ .type=${this.overlayType}
55
55
  >
56
56
  </icon-overlay>
57
57
  `;
58
58
  }
59
59
  get textOverlayTemplate() {
60
- var _a, _b, _c;
60
+ // List tiles do not require the text overlay
61
61
  if (this.isListTile)
62
62
  return nothing;
63
- if (!((_a = this.model) === null || _a === void 0 ? void 0 : _a.loginRequired) && !((_b = this.model) === null || _b === void 0 ? void 0 : _b.contentWarning))
63
+ const { overlayType } = this;
64
+ if (!overlayType)
64
65
  return nothing;
65
66
  return html `
66
- <text-overlay
67
- .loggedIn=${this.loggedIn}
68
- .loginRequired=${(_c = this.model) === null || _c === void 0 ? void 0 : _c.loginRequired}
69
- ?iconRequired=${true}
70
- >
71
- </text-overlay>
67
+ <text-overlay .type=${this.overlayType}></text-overlay>
72
68
  `;
73
69
  }
70
+ get overlayType() {
71
+ var _a, _b;
72
+ // Prioritize showing the login-required overlay if needed.
73
+ // Otherwise, if a content warning is required, show that overlay instead.
74
+ // If neither flag is present, no overlay should be shown.
75
+ if (((_a = this.model) === null || _a === void 0 ? void 0 : _a.loginRequired) && !this.loggedIn) {
76
+ return 'login-required';
77
+ }
78
+ else if ((_b = this.model) === null || _b === void 0 ? void 0 : _b.contentWarning) {
79
+ return 'content-warning';
80
+ }
81
+ else {
82
+ return undefined;
83
+ }
84
+ }
74
85
  static get styles() {
75
86
  const imageBlockBackgroundColor = css `var(--imageBlockBackgroundColor, #f1f1f4)`;
76
87
  return css `
@@ -1 +1 @@
1
- {"version":3,"file":"image-block.js","sourceRoot":"","sources":["../../../src/tiles/image-block.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAkB,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAa,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAIlE,OAAO,wBAAwB,CAAC;AAChC,OAAO,wBAAwB,CAAC;AAGhC,IAAa,UAAU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ement, nothing } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { ClassInfo, classMap } from 'lit/directives/class-map.js';\n\nimport type { TileModel } from '../models';\n\nimport './overlay/icon-overlay';\nimport './overlay/text-overlay';\n\n@customElement('image-block')\nexport class ImageBlock extends LitElement {\n @property({ type: String }) baseImageUrl?: string;\n\n @property({ type: Boolean }) isCompactTile = false;\n\n @property({ type: Boolean }) isListTile = false;\n\n @property({ type: Boolean }) loggedIn = false;\n\n @property({ type: Object }) model?: TileModel;\n\n @property({ type: String }) viewSize: string = 'desktop';\n\n render() {\n if (!this.model?.identifier) return nothing;\n\n return html`\n <div class=${classMap(this.baseClass)}>\n <item-image\n .model=${this.model}\n .baseImageUrl=${this.baseImageUrl}\n .isListTile=${this.isListTile}\n .isCompactTile=${this.isCompactTile}\n .loggedIn=${this.loggedIn}\n style=\"--imgHeight: 100%; --imgWidth: 100%\"\n >\n </item-image>\n ${this.textOverlayTemplate} ${this.iconOverlayTemplate}\n </div>\n `;\n }\n\n private get baseClass(): ClassInfo {\n return {\n list: this.isListTile && !this.isCompactTile,\n 'list-compact': this.isListTile && this.isCompactTile,\n collection: this.model?.mediatype === 'collection', // fill the image in container\n [this.viewSize]: true,\n 'search-image': this.model?.mediatype === 'search',\n };\n }\n\n private get iconOverlayTemplate() {\n if (!this.isListTile) return nothing;\n\n if (!this.model?.loginRequired && !this.model?.contentWarning)\n return nothing;\n\n return html`\n <icon-overlay\n .loggedIn=${this.loggedIn}\n .loginRequired=${this.model?.loginRequired}\n .isCompactTile=${this.isCompactTile}\n >\n </icon-overlay>\n `;\n }\n\n private get textOverlayTemplate() {\n if (this.isListTile) return nothing;\n\n if (!this.model?.loginRequired && !this.model?.contentWarning)\n return nothing;\n\n return html`\n <text-overlay\n .loggedIn=${this.loggedIn}\n .loginRequired=${this.model?.loginRequired}\n ?iconRequired=${true}\n >\n </text-overlay>\n `;\n }\n\n static get styles(): CSSResultGroup {\n const imageBlockBackgroundColor = css`var(--imageBlockBackgroundColor, #f1f1f4)`;\n\n return css`\n div {\n display: flex;\n justify-content: center;\n position: relative;\n background-color: ${imageBlockBackgroundColor};\n border-radius: 4px;\n }\n\n .grid {\n height: var(--imgBlockHeight, 16rem);\n flex: 1;\n position: initial;\n padding: 5px;\n border-radius: 4px 4px 0 0;\n }\n\n .collection.grid,\n .grid.search-image {\n display: block;\n }\n\n /** tile-list view */\n .list {\n border-radius: 0;\n background-color: var(--imageBlockListBackgroundColor, #ebebee);\n box-shadow: 1px 1px 2px rgb(0, 0, 0, 0.2);\n }\n\n .list.desktop {\n width: 100px;\n max-width: 100%;\n height: 100px;\n max-width: 100%;\n display: inline-block;\n position: relative;\n text-align: center;\n }\n\n .list.mobile {\n width: var(--image-width, 90px);\n height: 90px;\n }\n\n /** tile-list-compact view */\n .list-compact {\n display: block;\n text-align: center;\n }\n\n .list-compact.desktop {\n width: 45px;\n height: 45px;\n }\n\n .list-compact.mobile {\n width: 30px;\n height: 30px;\n }\n `;\n }\n}\n"]}
1
+ {"version":3,"file":"image-block.js","sourceRoot":"","sources":["../../../src/tiles/image-block.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAkB,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAa,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AAIlE,OAAO,wBAAwB,CAAC;AAChC,OAAO,wBAAwB,CAAC;AAGhC,IAAa,UAAU,GAAvB,MAAa,UAAW,SAAQ,UAAU;IAA1C;;QAG+B,kBAAa,GAAG,KAAK,CAAC;QAEtB,eAAU,GAAG,KAAK,CAAC;QAEnB,aAAQ,GAAG,KAAK,CAAC;QAIlB,aAAQ,GAAW,SAAS,CAAC;IAwI3D,CAAC;IAtIC,MAAM;;QACJ,IAAI,CAAC,CAAA,MAAA,IAAI,CAAC,KAAK,0CAAE,UAAU,CAA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IAAI,CAAA;4BACa,IAAI,CAAC,WAAW;KACvC,CAAC;IACJ,CAAC;IAED,IAAY,WAAW;;QACrB,2DAA2D;QAC3D,0EAA0E;QAC1E,0DAA0D;QAC1D,IAAI,CAAA,MAAA,IAAI,CAAC,KAAK,0CAAE,aAAa,KAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;YAC/C,OAAO,gBAAgB,CAAC;SACzB;aAAM,IAAI,MAAA,IAAI,CAAC,KAAK,0CAAE,cAAc,EAAE;YACrC,OAAO,iBAAiB,CAAA;SACzB;aAAM;YACL,OAAO,SAAS,CAAC;SAClB;IACH,CAAC;IAED,MAAM,KAAK,MAAM;QACf,MAAM,yBAAyB,GAAG,GAAG,CAAA,2CAA2C,CAAC;QAEjF,OAAO,GAAG,CAAA;;;;;4BAKc,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAsDhD,CAAC;IACJ,CAAC;CACF,CAAA;AAlJ6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;gDAAuB;AAErB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;iDAAuB;AAEtB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;8CAAoB;AAEnB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;4CAAkB;AAElB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yCAAmB;AAElB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAA8B;AAX9C,UAAU;IADtB,aAAa,CAAC,aAAa,CAAC;GAChB,UAAU,CAmJtB;SAnJY,UAAU","sourcesContent":["import { css, CSSResultGroup, html, LitElement, nothing } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { ClassInfo, classMap } from 'lit/directives/class-map.js';\n\nimport type { TileModel, TileOverlayType } from '../models';\n\nimport './overlay/icon-overlay';\nimport './overlay/text-overlay';\n\n@customElement('image-block')\nexport class ImageBlock extends LitElement {\n @property({ type: String }) baseImageUrl?: string;\n\n @property({ type: Boolean }) isCompactTile = false;\n\n @property({ type: Boolean }) isListTile = false;\n\n @property({ type: Boolean }) loggedIn = false;\n\n @property({ type: Object }) model?: TileModel;\n\n @property({ type: String }) viewSize: string = 'desktop';\n\n render() {\n if (!this.model?.identifier) return nothing;\n\n return html`\n <div class=${classMap(this.baseClass)}>\n <item-image\n .model=${this.model}\n .baseImageUrl=${this.baseImageUrl}\n .isListTile=${this.isListTile}\n .isCompactTile=${this.isCompactTile}\n .loggedIn=${this.loggedIn}\n style=\"--imgHeight: 100%; --imgWidth: 100%\"\n >\n </item-image>\n ${this.textOverlayTemplate} ${this.iconOverlayTemplate}\n </div>\n `;\n }\n\n private get baseClass(): ClassInfo {\n return {\n list: this.isListTile && !this.isCompactTile,\n 'list-compact': this.isListTile && this.isCompactTile,\n collection: this.model?.mediatype === 'collection', // fill the image in container\n [this.viewSize]: true,\n 'search-image': this.model?.mediatype === 'search',\n };\n }\n\n private get iconOverlayTemplate() {\n // Only list tiles use the icon overlay\n if (!this.isListTile) return nothing;\n\n const { overlayType } = this;\n if (!overlayType) return nothing;\n\n return html`\n <icon-overlay\n class=${this.isCompactTile ? 'list-compact' : 'list-detail'}\n .type=${this.overlayType}\n >\n </icon-overlay>\n `;\n }\n\n private get textOverlayTemplate() {\n // List tiles do not require the text overlay\n if (this.isListTile) return nothing;\n\n const { overlayType } = this;\n if (!overlayType) return nothing;\n\n return html`\n <text-overlay .type=${this.overlayType}></text-overlay>\n `;\n }\n\n private get overlayType(): TileOverlayType | undefined {\n // Prioritize showing the login-required overlay if needed.\n // Otherwise, if a content warning is required, show that overlay instead.\n // If neither flag is present, no overlay should be shown.\n if (this.model?.loginRequired && !this.loggedIn) {\n return 'login-required';\n } else if (this.model?.contentWarning) {\n return 'content-warning'\n } else {\n return undefined;\n }\n }\n\n static get styles(): CSSResultGroup {\n const imageBlockBackgroundColor = css`var(--imageBlockBackgroundColor, #f1f1f4)`;\n\n return css`\n div {\n display: flex;\n justify-content: center;\n position: relative;\n background-color: ${imageBlockBackgroundColor};\n border-radius: 4px;\n }\n\n .grid {\n height: var(--imgBlockHeight, 16rem);\n flex: 1;\n position: initial;\n padding: 5px;\n border-radius: 4px 4px 0 0;\n }\n\n .collection.grid,\n .grid.search-image {\n display: block;\n }\n\n /** tile-list view */\n .list {\n border-radius: 0;\n background-color: var(--imageBlockListBackgroundColor, #ebebee);\n box-shadow: 1px 1px 2px rgb(0, 0, 0, 0.2);\n }\n\n .list.desktop {\n width: 100px;\n max-width: 100%;\n height: 100px;\n max-width: 100%;\n display: inline-block;\n position: relative;\n text-align: center;\n }\n\n .list.mobile {\n width: var(--image-width, 90px);\n height: 90px;\n }\n\n /** tile-list-compact view */\n .list-compact {\n display: block;\n text-align: center;\n }\n\n .list-compact.desktop {\n width: 45px;\n height: 45px;\n }\n\n .list-compact.mobile {\n width: 30px;\n height: 30px;\n }\n `;\n }\n}\n"]}
@@ -1,10 +1,8 @@
1
- import { CSSResultGroup, LitElement } from 'lit';
1
+ import { CSSResultGroup, LitElement, TemplateResult } from 'lit';
2
+ import { TileOverlayType } from '../../models';
2
3
  export declare class IconOverlay extends LitElement {
3
- loggedIn: boolean;
4
- loginRequired: boolean;
5
- isCompactTile: boolean;
6
- render(): import("lit-html").TemplateResult<1>;
7
- private get getClass();
8
- private get iconDisplay();
4
+ type?: TileOverlayType;
5
+ render(): TemplateResult<1>;
6
+ private get iconTemplate();
9
7
  static get styles(): CSSResultGroup;
10
8
  }
@@ -1,27 +1,18 @@
1
1
  import { __decorate } from "tslib";
2
- import { css, html, LitElement } from 'lit';
2
+ import { css, html, LitElement, nothing } from 'lit';
3
3
  import { customElement, property } from 'lit/decorators.js';
4
- import { restrictedIcon } from '../../assets/img/icons/restricted';
5
- import { loginRequiredIcon } from '../../assets/img/icons/login-required';
4
+ import { TILE_OVERLAY_ICONS } from '../../models';
6
5
  let IconOverlay = class IconOverlay extends LitElement {
7
- constructor() {
8
- super(...arguments);
9
- this.loggedIn = false;
10
- this.loginRequired = false;
11
- this.isCompactTile = false;
12
- }
13
6
  render() {
14
- return html `<div class="icon-overlay ${this.getClass}">
15
- ${this.iconDisplay}
7
+ return html `<div class="icon-overlay">
8
+ ${this.iconTemplate}
16
9
  </div>`;
17
10
  }
18
- get getClass() {
19
- return this.isCompactTile ? 'list-compact' : 'list-detail';
20
- }
21
- get iconDisplay() {
22
- return this.loginRequired && !this.loggedIn
23
- ? html `${loginRequiredIcon}`
24
- : html `${restrictedIcon}`;
11
+ get iconTemplate() {
12
+ var _a;
13
+ if (!this.type)
14
+ return nothing;
15
+ return html `${(_a = TILE_OVERLAY_ICONS[this.type]) !== null && _a !== void 0 ? _a : nothing}`;
25
16
  }
26
17
  static get styles() {
27
18
  return css `
@@ -45,11 +36,11 @@ let IconOverlay = class IconOverlay extends LitElement {
45
36
  padding: 2px;
46
37
  }
47
38
 
48
- .list-detail {
39
+ :host(.list-detail) .icon-overlay {
49
40
  height: 20px;
50
41
  width: 20px;
51
42
  }
52
- .list-compact {
43
+ :host(.list-compact) .icon-overlay {
53
44
  height: 15px;
54
45
  width: 15px;
55
46
  }
@@ -57,14 +48,8 @@ let IconOverlay = class IconOverlay extends LitElement {
57
48
  }
58
49
  };
59
50
  __decorate([
60
- property({ type: Boolean })
61
- ], IconOverlay.prototype, "loggedIn", void 0);
62
- __decorate([
63
- property({ type: Boolean })
64
- ], IconOverlay.prototype, "loginRequired", void 0);
65
- __decorate([
66
- property({ type: Boolean })
67
- ], IconOverlay.prototype, "isCompactTile", void 0);
51
+ property({ type: String })
52
+ ], IconOverlay.prototype, "type", void 0);
68
53
  IconOverlay = __decorate([
69
54
  customElement('icon-overlay')
70
55
  ], IconOverlay);
@@ -1 +1 @@
1
- {"version":3,"file":"icon-overlay.js","sourceRoot":"","sources":["../../../../src/t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AAC,cAAc,CAAC;GACjB,WAAW,CAuDvB;SAvDY,WAAW","sourcesContent":["import { css, CSSResultGroup, html, LitElement } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\n\nimport { restrictedIcon } from '../../assets/img/icons/restricted';\nimport { loginRequiredIcon } from '../../assets/img/icons/login-required';\n\n@customElement('icon-overlay')\nexport class IconOverlay extends LitElement {\n @property({ type: Boolean }) loggedIn = false;\n\n @property({ type: Boolean }) loginRequired = false;\n\n @property({ type: Boolean }) isCompactTile = false;\n\n render() {\n return html`<div class=\"icon-overlay ${this.getClass}\">\n ${this.iconDisplay}\n </div>`;\n }\n\n private get getClass() {\n return this.isCompactTile ? 'list-compact' : 'list-detail';\n }\n\n private get iconDisplay() {\n return this.loginRequired && !this.loggedIn\n ? html`${loginRequiredIcon}`\n : html`${restrictedIcon}`;\n }\n\n static get styles(): CSSResultGroup {\n return css`\n :host {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n width: 100%;\n z-index: 2;\n background-color: rgb(255, 254, 203);\n display: flex;\n justify-content: center;\n border: 1px solid #2c2c2c;\n }\n\n .icon-overlay {\n height: 20px;\n width: 20px;\n padding: 2px;\n padding: 2px;\n }\n\n .list-detail {\n height: 20px;\n width: 20px;\n }\n .list-compact {\n height: 15px;\n width: 15px;\n }\n `;\n }\n}\n"]}
1
+ {"version":3,"file":"icon-overlay.js","sourceRoot":"","sources":["../../../../src/tiles/overlay/icon-overlay.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAkB,IAAI,EAAE,UAAU,EAAE,OAAO,EAAkB,MAAM,KAAK,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAmB,MAAM,cAAc,CAAC;AAGnE,IAAa,WAAW,GAAxB,MAAa,WAAY,SAAQ,UAAU;IAGzC,MAAM;QACJ,OAAO,IAAI,CAAA;QACP,IAAI,CAAC,YAAY;WACd,CAAC;IACV,CAAC;IAED,IAAY,YAAY;;QACtB,IAAI,CAAC,IAAI,CAAC,IAAI;YAAE,OAAO,OAAO,CAAC;QAC/B,OAAO,IAAI,CAAA,GAAG,MAAA,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,mCAAI,OAAO,EAAE,CAAC;IAC3D,CAAC;IAED,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KA6BT,CAAC;IACJ,CAAC;CACF,CAAA;AA7C6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yCAAwB;AADxC,WAAW;IADvB,aAAa,CAAC,cAAc,CAAC;GACjB,WAAW,CA8CvB;SA9CY,WAAW","sourcesContent":["import { css, CSSResultGroup, html, LitElement, nothing, TemplateResult } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { TILE_OVERLAY_ICONS, TileOverlayType } from '../../models';\n\n@customElement('icon-overlay')\nexport class IconOverlay extends LitElement {\n @property({ type: String }) type?: TileOverlayType;\n\n render() {\n return html`<div class=\"icon-overlay\">\n ${this.iconTemplate}\n </div>`;\n }\n\n private get iconTemplate(): TemplateResult | typeof nothing {\n if (!this.type) return nothing;\n return html`${TILE_OVERLAY_ICONS[this.type] ?? nothing}`;\n }\n\n static get styles(): CSSResultGroup {\n return css`\n :host {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n width: 100%;\n z-index: 2;\n background-color: rgb(255, 254, 203);\n display: flex;\n justify-content: center;\n border: 1px solid #2c2c2c;\n }\n\n .icon-overlay {\n height: 20px;\n width: 20px;\n padding: 2px;\n padding: 2px;\n }\n\n :host(.list-detail) .icon-overlay {\n height: 20px;\n width: 20px;\n }\n :host(.list-compact) .icon-overlay {\n height: 15px;\n width: 15px;\n }\n `;\n }\n}\n"]}
@@ -1,10 +1,9 @@
1
- import { CSSResultGroup, LitElement } from 'lit';
1
+ import { CSSResultGroup, LitElement, TemplateResult } from 'lit';
2
+ import { TileOverlayType } from '../../models';
2
3
  export declare class TextOverlay extends LitElement {
3
- loggedIn: boolean;
4
- loginRequired: boolean;
5
- iconRequired: boolean;
6
- render(): import("lit-html").TemplateResult<1>;
7
- private get iconDisplay();
8
- private get textDisplay();
4
+ type?: TileOverlayType;
5
+ render(): TemplateResult<1>;
6
+ private get iconTemplate();
7
+ private get textTemplate();
9
8
  static get styles(): CSSResultGroup;
10
9
  }
@@ -1,32 +1,27 @@
1
1
  import { __decorate } from "tslib";
2
- import { css, html, LitElement } from 'lit';
2
+ import { css, html, LitElement, nothing } from 'lit';
3
3
  import { customElement, property } from 'lit/decorators.js';
4
- import { loginRequiredIcon } from '../../assets/img/icons/login-required';
5
- import { restrictedIcon } from '../../assets/img/icons/restricted';
4
+ import { TILE_OVERLAY_ICONS, TILE_OVERLAY_TEXT } from '../../models';
6
5
  let TextOverlay = class TextOverlay extends LitElement {
7
- constructor() {
8
- super(...arguments);
9
- this.loggedIn = false;
10
- this.loginRequired = false;
11
- this.iconRequired = false;
12
- }
13
6
  render() {
14
7
  return html `
15
8
  <div class="overlay no-preview">
16
- <div class="icon-overlay">${this.iconDisplay}</div>
17
- <p class="text-overlay">${this.textDisplay}</p>
9
+ <div class="icon-overlay">${this.iconTemplate}</div>
10
+ <p class="text-overlay">${this.textTemplate}</p>
18
11
  </div>
19
12
  `;
20
13
  }
21
- get iconDisplay() {
22
- return this.loginRequired && !this.loggedIn
23
- ? html `${loginRequiredIcon}`
24
- : html `${restrictedIcon}`;
14
+ get iconTemplate() {
15
+ var _a;
16
+ if (!this.type)
17
+ return nothing;
18
+ return html `${(_a = TILE_OVERLAY_ICONS[this.type]) !== null && _a !== void 0 ? _a : nothing}`;
25
19
  }
26
- get textDisplay() {
27
- return this.loginRequired && !this.loggedIn
28
- ? html `Log in to view this item`
29
- : html `Content may be inappropriate`;
20
+ get textTemplate() {
21
+ var _a;
22
+ if (!this.type)
23
+ return nothing;
24
+ return html `${(_a = TILE_OVERLAY_TEXT[this.type]) !== null && _a !== void 0 ? _a : nothing}`;
30
25
  }
31
26
  static get styles() {
32
27
  return css `
@@ -70,14 +65,8 @@ let TextOverlay = class TextOverlay extends LitElement {
70
65
  }
71
66
  };
72
67
  __decorate([
73
- property({ type: Boolean })
74
- ], TextOverlay.prototype, "loggedIn", void 0);
75
- __decorate([
76
- property({ type: Boolean })
77
- ], TextOverlay.prototype, "loginRequired", void 0);
78
- __decorate([
79
- property({ type: Boolean })
80
- ], TextOverlay.prototype, "iconRequired", void 0);
68
+ property({ type: String })
69
+ ], TextOverlay.prototype, "type", void 0);
81
70
  TextOverlay = __decorate([
82
71
  customElement('text-overlay')
83
72
  ], TextOverlay);
@@ -1 +1 @@
1
- {"version":3,"file":"text-overlay.js","sourceRoot":"","sources":["../../../../src/tiles/overlay/text-overlay.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAkB,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAGnE,IAAa,WAAW,GAAxB,MAAa,WAAY,SAAQ,UAAU;IAA3C;;QAC+B,aAAQ,GAAG,KAAK,CAAC;QAEjB,kBAAa,GAAG,KAAK,CAAC;QAEtB,iBAAY,GAAG,KAAK,CAAC;IA+DpD,CAAC;IA7DC,MAAM;QACJ,OAAO,IAAI,CAAA;;oCAEqB,IAAI,CAAC,WAAW;kCAClB,IAAI,CAAC,WAAW;;KAE7C,CAAC;IACJ,CAAC;IAED,IAAY,WAAW;QACrB,OAAO,IAAI,CAAC,aAAa,IAAI,CAAC,IAAI,CAAC,QAAQ;YACzC,CAAC,CAAC,IAAI,CAAA,GAAG,iBAAiB,EAAE;YAC5B,CAAC,CAAC,IAAI,CAAA,GAAG,cAAc,EAAE,CAAC;IAC9B,CAAC;IAED,IAAY,WAAW;QACrB,OAAO,IAAI,CAAC,aAAa,IAAI,CAAC,IAAI,CAAC,QAAQ;YACzC,CAAC,CAAC,IAAI,CAAA,0BAA0B;YAChC,CAAC,CAAC,IAAI,CAAA,8BAA8B,CAAC;IACzC,CAAC;IAED,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAqCT,CAAC;IACJ,CAAC;CACF,CAAA;AAnE8B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;6CAAkB;AAEjB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;kDAAuB;AAEtB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;iDAAsB;AALvC,WAAW;IADvB,aAAa,CAAC,cAAc,CAAC;GACjB,WAAW,CAoEvB;SApEY,WAAW","sourcesContent":["import { css, CSSResultGroup, html, LitElement } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { loginRequiredIcon } from '../../assets/img/icons/login-required';\nimport { restrictedIcon } from '../../assets/img/icons/restricted';\n\n@customElement('text-overlay')\nexport class TextOverlay extends LitElement {\n @property({ type: Boolean }) loggedIn = false;\n\n @property({ type: Boolean }) loginRequired = false;\n\n @property({ type: Boolean }) iconRequired = false;\n\n render() {\n return html`\n <div class=\"overlay no-preview\">\n <div class=\"icon-overlay\">${this.iconDisplay}</div>\n <p class=\"text-overlay\">${this.textDisplay}</p>\n </div>\n `;\n }\n\n private get iconDisplay() {\n return this.loginRequired && !this.loggedIn\n ? html`${loginRequiredIcon}`\n : html`${restrictedIcon}`;\n }\n\n private get textDisplay() {\n return this.loginRequired && !this.loggedIn\n ? html`Log in to view this item`\n : html`Content may be inappropriate`;\n }\n\n static get styles(): CSSResultGroup {\n return css`\n :host {\n align-items: center;\n display: flex;\n }\n\n .overlay {\n border: 1px solid #2c2c2c;\n border-radius: 1px;\n position: absolute;\n right: 0;\n left: 0;\n top: 50%;\n transform: translate(0px, -50%);\n width: auto;\n height: auto;\n padding: 5px;\n background-color: #fffecb;\n display: flex;\n align-items: center;\n border-radius: 1px;\n }\n\n .icon-overlay {\n width: 40px;\n height: 40px;\n display: inherit;\n }\n .text-overlay {\n margin: 0;\n vertical-align: bottom;\n padding-left: 5px;\n text-align: center;\n color: #2c2c2c;\n font-size: 1.4rem;\n line-height: 2rem;\n }\n `;\n }\n}\n"]}
1
+ {"version":3,"file":"text-overlay.js","sourceRoot":"","sources":["../../../../src/tiles/overlay/text-overlay.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAkB,IAAI,EAAE,UAAU,EAAE,OAAO,EAAkB,MAAM,KAAK,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAmB,MAAM,cAAc,CAAC;AAGtF,IAAa,WAAW,GAAxB,MAAa,WAAY,SAAQ,UAAU;IAGzC,MAAM;QACJ,OAAO,IAAI,CAAA;;oCAEqB,IAAI,CAAC,YAAY;kCACnB,IAAI,CAAC,YAAY;;KAE9C,CAAC;IACJ,CAAC;IAED,IAAY,YAAY;;QACtB,IAAI,CAAC,IAAI,CAAC,IAAI;YAAE,OAAO,OAAO,CAAC;QAC/B,OAAO,IAAI,CAAA,GAAG,MAAA,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,mCAAI,OAAO,EAAE,CAAC;IAC3D,CAAC;IAED,IAAY,YAAY;;QACtB,IAAI,CAAC,IAAI,CAAC,IAAI;YAAE,OAAO,OAAO,CAAC;QAC/B,OAAO,IAAI,CAAA,GAAG,MAAA,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,mCAAI,OAAO,EAAE,CAAC;IAC1D,CAAC;IAED,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAqCT,CAAC;IACJ,CAAC;CACF,CAAA;AA7D6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yCAAwB;AADxC,WAAW;IADvB,aAAa,CAAC,cAAc,CAAC;GACjB,WAAW,CA8DvB;SA9DY,WAAW","sourcesContent":["import { css, CSSResultGroup, html, LitElement, nothing, TemplateResult } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { TILE_OVERLAY_ICONS, TILE_OVERLAY_TEXT, TileOverlayType } from '../../models';\n\n@customElement('text-overlay')\nexport class TextOverlay extends LitElement {\n @property({ type: String }) type?: TileOverlayType;\n\n render() {\n return html`\n <div class=\"overlay no-preview\">\n <div class=\"icon-overlay\">${this.iconTemplate}</div>\n <p class=\"text-overlay\">${this.textTemplate}</p>\n </div>\n `;\n }\n\n private get iconTemplate(): TemplateResult | typeof nothing {\n if (!this.type) return nothing;\n return html`${TILE_OVERLAY_ICONS[this.type] ?? nothing}`;\n }\n\n private get textTemplate(): TemplateResult | typeof nothing {\n if (!this.type) return nothing;\n return html`${TILE_OVERLAY_TEXT[this.type] ?? nothing}`;\n }\n\n static get styles(): CSSResultGroup {\n return css`\n :host {\n align-items: center;\n display: flex;\n }\n\n .overlay {\n border: 1px solid #2c2c2c;\n border-radius: 1px;\n position: absolute;\n right: 0;\n left: 0;\n top: 50%;\n transform: translate(0px, -50%);\n width: auto;\n height: auto;\n padding: 5px;\n background-color: #fffecb;\n display: flex;\n align-items: center;\n border-radius: 1px;\n }\n\n .icon-overlay {\n width: 40px;\n height: 40px;\n display: inherit;\n }\n .text-overlay {\n margin: 0;\n vertical-align: bottom;\n padding-left: 5px;\n text-align: center;\n color: #2c2c2c;\n font-size: 1.4rem;\n line-height: 2rem;\n }\n `;\n }\n}\n"]}
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": "2.6.3",
6
+ "version": "2.6.4-alpha.1",
7
7
  "main": "dist/index.js",
8
8
  "module": "dist/index.js",
9
9
  "scripts": {
package/src/models.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import type { TemplateResult } from 'lit';
2
+ import { msg } from '@lit/localize';
1
3
  import type { MediaType } from '@internetarchive/field-parsers';
2
4
  import {
3
5
  AggregationSortType,
@@ -8,6 +10,9 @@ import {
8
10
  import { collapseRepeatedQuotes } from './utils/collapse-repeated-quotes';
9
11
  import { resolveMediatype } from './utils/resolve-mediatype';
10
12
 
13
+ import { loginRequiredIcon } from './assets/img/icons/login-required';
14
+ import { restrictedIcon } from './assets/img/icons/restricted';
15
+
11
16
  /**
12
17
  * Flags that can affect the visibility of content on a tile
13
18
  */
@@ -16,6 +21,21 @@ interface TileFlags {
16
21
  contentWarning: boolean;
17
22
  }
18
23
 
24
+ /**
25
+ * Different types of tile overlays, corresponding to the above flags.
26
+ */
27
+ export type TileOverlayType = 'login-required' | 'content-warning';
28
+
29
+ export const TILE_OVERLAY_TEXT: Record<TileOverlayType, string> = {
30
+ 'login-required': msg('Log in to view this item'),
31
+ 'content-warning': msg('Content may be inappropriate'),
32
+ };
33
+
34
+ export const TILE_OVERLAY_ICONS: Record<TileOverlayType, TemplateResult> = {
35
+ 'login-required': loginRequiredIcon,
36
+ 'content-warning': restrictedIcon,
37
+ };
38
+
19
39
  /**
20
40
  * Class for converting & storing raw search results in the correct format for UI tiles.
21
41
  */
@@ -2,7 +2,7 @@ import { css, CSSResultGroup, html, LitElement, nothing } from 'lit';
2
2
  import { customElement, property } from 'lit/decorators.js';
3
3
  import { ClassInfo, classMap } from 'lit/directives/class-map.js';
4
4
 
5
- import type { TileModel } from '../models';
5
+ import type { TileModel, TileOverlayType } from '../models';
6
6
 
7
7
  import './overlay/icon-overlay';
8
8
  import './overlay/text-overlay';
@@ -51,37 +51,46 @@ export class ImageBlock extends LitElement {
51
51
  }
52
52
 
53
53
  private get iconOverlayTemplate() {
54
+ // Only list tiles use the icon overlay
54
55
  if (!this.isListTile) return nothing;
55
56
 
56
- if (!this.model?.loginRequired && !this.model?.contentWarning)
57
- return nothing;
57
+ const { overlayType } = this;
58
+ if (!overlayType) return nothing;
58
59
 
59
60
  return html`
60
61
  <icon-overlay
61
- .loggedIn=${this.loggedIn}
62
- .loginRequired=${this.model?.loginRequired}
63
- .isCompactTile=${this.isCompactTile}
62
+ class=${this.isCompactTile ? 'list-compact' : 'list-detail'}
63
+ .type=${this.overlayType}
64
64
  >
65
65
  </icon-overlay>
66
66
  `;
67
67
  }
68
68
 
69
69
  private get textOverlayTemplate() {
70
+ // List tiles do not require the text overlay
70
71
  if (this.isListTile) return nothing;
71
72
 
72
- if (!this.model?.loginRequired && !this.model?.contentWarning)
73
- return nothing;
73
+ const { overlayType } = this;
74
+ if (!overlayType) return nothing;
74
75
 
75
76
  return html`
76
- <text-overlay
77
- .loggedIn=${this.loggedIn}
78
- .loginRequired=${this.model?.loginRequired}
79
- ?iconRequired=${true}
80
- >
81
- </text-overlay>
77
+ <text-overlay .type=${this.overlayType}></text-overlay>
82
78
  `;
83
79
  }
84
80
 
81
+ private get overlayType(): TileOverlayType | undefined {
82
+ // Prioritize showing the login-required overlay if needed.
83
+ // Otherwise, if a content warning is required, show that overlay instead.
84
+ // If neither flag is present, no overlay should be shown.
85
+ if (this.model?.loginRequired && !this.loggedIn) {
86
+ return 'login-required';
87
+ } else if (this.model?.contentWarning) {
88
+ return 'content-warning'
89
+ } else {
90
+ return undefined;
91
+ }
92
+ }
93
+
85
94
  static get styles(): CSSResultGroup {
86
95
  const imageBlockBackgroundColor = css`var(--imageBlockBackgroundColor, #f1f1f4)`;
87
96
 
@@ -1,31 +1,20 @@
1
- import { css, CSSResultGroup, html, LitElement } from 'lit';
1
+ import { css, CSSResultGroup, html, LitElement, nothing, TemplateResult } from 'lit';
2
2
  import { customElement, property } from 'lit/decorators.js';
3
-
4
- import { restrictedIcon } from '../../assets/img/icons/restricted';
5
- import { loginRequiredIcon } from '../../assets/img/icons/login-required';
3
+ import { TILE_OVERLAY_ICONS, TileOverlayType } from '../../models';
6
4
 
7
5
  @customElement('icon-overlay')
8
6
  export class IconOverlay extends LitElement {
9
- @property({ type: Boolean }) loggedIn = false;
10
-
11
- @property({ type: Boolean }) loginRequired = false;
12
-
13
- @property({ type: Boolean }) isCompactTile = false;
7
+ @property({ type: String }) type?: TileOverlayType;
14
8
 
15
9
  render() {
16
- return html`<div class="icon-overlay ${this.getClass}">
17
- ${this.iconDisplay}
10
+ return html`<div class="icon-overlay">
11
+ ${this.iconTemplate}
18
12
  </div>`;
19
13
  }
20
14
 
21
- private get getClass() {
22
- return this.isCompactTile ? 'list-compact' : 'list-detail';
23
- }
24
-
25
- private get iconDisplay() {
26
- return this.loginRequired && !this.loggedIn
27
- ? html`${loginRequiredIcon}`
28
- : html`${restrictedIcon}`;
15
+ private get iconTemplate(): TemplateResult | typeof nothing {
16
+ if (!this.type) return nothing;
17
+ return html`${TILE_OVERLAY_ICONS[this.type] ?? nothing}`;
29
18
  }
30
19
 
31
20
  static get styles(): CSSResultGroup {
@@ -50,11 +39,11 @@ export class IconOverlay extends LitElement {
50
39
  padding: 2px;
51
40
  }
52
41
 
53
- .list-detail {
42
+ :host(.list-detail) .icon-overlay {
54
43
  height: 20px;
55
44
  width: 20px;
56
45
  }
57
- .list-compact {
46
+ :host(.list-compact) .icon-overlay {
58
47
  height: 15px;
59
48
  width: 15px;
60
49
  }
@@ -1,35 +1,28 @@
1
- import { css, CSSResultGroup, html, LitElement } from 'lit';
1
+ import { css, CSSResultGroup, html, LitElement, nothing, TemplateResult } from 'lit';
2
2
  import { customElement, property } from 'lit/decorators.js';
3
- import { loginRequiredIcon } from '../../assets/img/icons/login-required';
4
- import { restrictedIcon } from '../../assets/img/icons/restricted';
3
+ import { TILE_OVERLAY_ICONS, TILE_OVERLAY_TEXT, TileOverlayType } from '../../models';
5
4
 
6
5
  @customElement('text-overlay')
7
6
  export class TextOverlay extends LitElement {
8
- @property({ type: Boolean }) loggedIn = false;
9
-
10
- @property({ type: Boolean }) loginRequired = false;
11
-
12
- @property({ type: Boolean }) iconRequired = false;
7
+ @property({ type: String }) type?: TileOverlayType;
13
8
 
14
9
  render() {
15
10
  return html`
16
11
  <div class="overlay no-preview">
17
- <div class="icon-overlay">${this.iconDisplay}</div>
18
- <p class="text-overlay">${this.textDisplay}</p>
12
+ <div class="icon-overlay">${this.iconTemplate}</div>
13
+ <p class="text-overlay">${this.textTemplate}</p>
19
14
  </div>
20
15
  `;
21
16
  }
22
17
 
23
- private get iconDisplay() {
24
- return this.loginRequired && !this.loggedIn
25
- ? html`${loginRequiredIcon}`
26
- : html`${restrictedIcon}`;
18
+ private get iconTemplate(): TemplateResult | typeof nothing {
19
+ if (!this.type) return nothing;
20
+ return html`${TILE_OVERLAY_ICONS[this.type] ?? nothing}`;
27
21
  }
28
22
 
29
- private get textDisplay() {
30
- return this.loginRequired && !this.loggedIn
31
- ? html`Log in to view this item`
32
- : html`Content may be inappropriate`;
23
+ private get textTemplate(): TemplateResult | typeof nothing {
24
+ if (!this.type) return nothing;
25
+ return html`${TILE_OVERLAY_TEXT[this.type] ?? nothing}`;
33
26
  }
34
27
 
35
28
  static get styles(): CSSResultGroup {
@@ -1,9 +0,0 @@
1
- import { CSSResultGroup, LitElement } from 'lit';
2
- export declare class IconTextOverlay extends LitElement {
3
- loggedIn: boolean;
4
- loginRequired: boolean;
5
- render(): import("lit-html").TemplateResult<1>;
6
- private get iconDisplay();
7
- private get textDisplay();
8
- static get styles(): CSSResultGroup;
9
- }
@@ -1,83 +0,0 @@
1
- import { __decorate } from "tslib";
2
- import { css, html, LitElement } from 'lit';
3
- import { customElement, property } from 'lit/decorators.js';
4
- import { loginRequiredIcon } from '../../assets/img/icons/login-required';
5
- import { restrictedIcon } from '../../assets/img/icons/restricted';
6
- let IconTextOverlay = class IconTextOverlay extends LitElement {
7
- constructor() {
8
- super(...arguments);
9
- this.loggedIn = false;
10
- this.loginRequired = false;
11
- }
12
- render() {
13
- return html `
14
- <div class="overlay no-preview">
15
- <div class="icon-overlay">${this.iconDisplay}</div>
16
- <p class="text-overlay">${this.textDisplay}</p>
17
- </div>
18
- `;
19
- }
20
- get iconDisplay() {
21
- return this.loginRequired && !this.loggedIn
22
- ? html `${loginRequiredIcon}`
23
- : html `${restrictedIcon}`;
24
- }
25
- get textDisplay() {
26
- return this.loginRequired && !this.loggedIn
27
- ? 'Log in\nto view this item'
28
- : 'Content may be inappropriate';
29
- }
30
- static get styles() {
31
- return css `
32
- :host {
33
- align-items: center;
34
- display: flex;
35
- }
36
-
37
- .overlay {
38
- border: 1px solid #2c2c2c;
39
- border-radius: 1px;
40
- position: absolute;
41
- right: 0;
42
- left: 0;
43
- width: auto;
44
- height: auto;
45
- padding: 5px;
46
- display: flex;
47
- align-items: center;
48
- border-radius: 1px;
49
- text-align: center;
50
- }
51
-
52
- .icon-overlay {
53
- width: 40px;
54
- height: 40px;
55
- display: inherit;
56
- }
57
- .text-overlay {
58
- margin: 0;
59
- vertical-align: bottom;
60
- padding-left: 5px;
61
- }
62
-
63
- .no-preview {
64
- background-color: #fffecb;
65
- border: 1px solid #2c2c2c;
66
- color: #2c2c2c;
67
- font-size: 1.4rem;
68
- line-height: 2rem;
69
- }
70
- `;
71
- }
72
- };
73
- __decorate([
74
- property({ type: Boolean })
75
- ], IconTextOverlay.prototype, "loggedIn", void 0);
76
- __decorate([
77
- property({ type: Boolean })
78
- ], IconTextOverlay.prototype, "loginRequired", void 0);
79
- IconTextOverlay = __decorate([
80
- customElement('icon-text-overlay')
81
- ], IconTextOverlay);
82
- export { IconTextOverlay };
83
- //# sourceMappingURL=icon-text-overlay.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"icon-text-overlay.js","sourceRoot":"","sources":["../../../../src/tiles/overlay/icon-text-overlay.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,E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'lit/decorators.js';\nimport { loginRequiredIcon } from '../../assets/img/icons/login-required';\nimport { restrictedIcon } from '../../assets/img/icons/restricted';\n\n@customElement('icon-text-overlay')\nexport class IconTextOverlay extends LitElement {\n @property({ type: Boolean }) loggedIn = false;\n\n @property({ type: Boolean }) loginRequired = false;\n\n render() {\n return html`\n <div class=\"overlay no-preview\">\n <div class=\"icon-overlay\">${this.iconDisplay}</div>\n <p class=\"text-overlay\">${this.textDisplay}</p>\n </div>\n `;\n }\n\n private get iconDisplay() {\n return this.loginRequired && !this.loggedIn\n ? html`${loginRequiredIcon}`\n : html`${restrictedIcon}`;\n }\n\n private get textDisplay() {\n return this.loginRequired && !this.loggedIn\n ? 'Log in\\nto view this item'\n : 'Content may be inappropriate';\n }\n\n static get styles(): CSSResultGroup {\n return css`\n :host {\n align-items: center;\n display: flex;\n }\n\n .overlay {\n border: 1px solid #2c2c2c;\n border-radius: 1px;\n position: absolute;\n right: 0;\n left: 0;\n width: auto;\n height: auto;\n padding: 5px;\n display: flex;\n align-items: center;\n border-radius: 1px;\n text-align: center;\n }\n\n .icon-overlay {\n width: 40px;\n height: 40px;\n display: inherit;\n }\n .text-overlay {\n margin: 0;\n vertical-align: bottom;\n padding-left: 5px;\n }\n\n .no-preview {\n background-color: #fffecb;\n border: 1px solid #2c2c2c;\n color: #2c2c2c;\n font-size: 1.4rem;\n line-height: 2rem;\n }\n `;\n }\n}\n"]}
@@ -1,75 +0,0 @@
1
- import { css, CSSResultGroup, html, LitElement } from 'lit';
2
- import { customElement, property } from 'lit/decorators.js';
3
- import { loginRequiredIcon } from '../../assets/img/icons/login-required';
4
- import { restrictedIcon } from '../../assets/img/icons/restricted';
5
-
6
- @customElement('icon-text-overlay')
7
- export class IconTextOverlay extends LitElement {
8
- @property({ type: Boolean }) loggedIn = false;
9
-
10
- @property({ type: Boolean }) loginRequired = false;
11
-
12
- render() {
13
- return html`
14
- <div class="overlay no-preview">
15
- <div class="icon-overlay">${this.iconDisplay}</div>
16
- <p class="text-overlay">${this.textDisplay}</p>
17
- </div>
18
- `;
19
- }
20
-
21
- private get iconDisplay() {
22
- return this.loginRequired && !this.loggedIn
23
- ? html`${loginRequiredIcon}`
24
- : html`${restrictedIcon}`;
25
- }
26
-
27
- private get textDisplay() {
28
- return this.loginRequired && !this.loggedIn
29
- ? 'Log in\nto view this item'
30
- : 'Content may be inappropriate';
31
- }
32
-
33
- static get styles(): CSSResultGroup {
34
- return css`
35
- :host {
36
- align-items: center;
37
- display: flex;
38
- }
39
-
40
- .overlay {
41
- border: 1px solid #2c2c2c;
42
- border-radius: 1px;
43
- position: absolute;
44
- right: 0;
45
- left: 0;
46
- width: auto;
47
- height: auto;
48
- padding: 5px;
49
- display: flex;
50
- align-items: center;
51
- border-radius: 1px;
52
- text-align: center;
53
- }
54
-
55
- .icon-overlay {
56
- width: 40px;
57
- height: 40px;
58
- display: inherit;
59
- }
60
- .text-overlay {
61
- margin: 0;
62
- vertical-align: bottom;
63
- padding-left: 5px;
64
- }
65
-
66
- .no-preview {
67
- background-color: #fffecb;
68
- border: 1px solid #2c2c2c;
69
- color: #2c2c2c;
70
- font-size: 1.4rem;
71
- line-height: 2rem;
72
- }
73
- `;
74
- }
75
- }