@internetarchive/collection-browser 4.2.1-alpha-webdev7004.0 → 4.3.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 (27) hide show
  1. package/dist/src/data-source/collection-browser-data-source.js +3 -3
  2. package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
  3. package/dist/src/tiles/list/tile-list-compact-header.js +45 -45
  4. package/dist/src/tiles/list/tile-list-compact-header.js.map +1 -1
  5. package/dist/src/tiles/list/tile-list-compact.js +99 -99
  6. package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
  7. package/dist/src/tiles/list/tile-list.js +300 -299
  8. package/dist/src/tiles/list/tile-list.js.map +1 -1
  9. package/dist/src/tiles/tile-display-value-provider.d.ts +5 -0
  10. package/dist/src/tiles/tile-display-value-provider.js +9 -0
  11. package/dist/src/tiles/tile-display-value-provider.js.map +1 -1
  12. package/dist/test/data-source/collection-browser-data-source.test.js +2 -2
  13. package/dist/test/data-source/collection-browser-data-source.test.js.map +1 -1
  14. package/dist/test/tiles/list/tile-list-compact-header.test.d.ts +1 -0
  15. package/dist/test/tiles/list/tile-list-compact-header.test.js +36 -0
  16. package/dist/test/tiles/list/tile-list-compact-header.test.js.map +1 -0
  17. package/dist/test/tiles/list/tile-list.test.js +147 -127
  18. package/dist/test/tiles/list/tile-list.test.js.map +1 -1
  19. package/package.json +1 -1
  20. package/src/data-source/collection-browser-data-source.ts +1465 -1465
  21. package/src/tiles/list/tile-list-compact-header.ts +86 -86
  22. package/src/tiles/list/tile-list-compact.ts +239 -239
  23. package/src/tiles/list/tile-list.ts +700 -700
  24. package/src/tiles/tile-display-value-provider.ts +134 -124
  25. package/test/data-source/collection-browser-data-source.test.ts +193 -193
  26. package/test/tiles/list/tile-list-compact-header.test.ts +43 -0
  27. package/test/tiles/list/tile-list.test.ts +576 -552
@@ -1 +1 @@
1
- {"version":3,"file":"tile-list.js","sourceRoot":"","sources":["../../../../src/tiles/list/tile-list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E,MAAM,EAAE,CAAC;kDACS;AAEnB;IAAhB,KAAK,EAAE;iDAAmE;AArBhE,QAAQ;IADpB,aAAa,CAAC,WAAW,CAAC;GACd,QAAQ,CAmqBpB","sourcesContent":["import { css, html, nothing, PropertyValues, TemplateResult } from 'lit';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { join } from 'lit/directives/join.js';\nimport { map } from 'lit/directives/map.js';\nimport { unsafeHTML } from 'lit/directives/unsafe-html.js';\nimport { customElement, property, state } from 'lit/decorators.js';\nimport { msg, str } from '@lit/localize';\nimport DOMPurify from 'dompurify';\n\nimport type { SortParam } from '@internetarchive/search-service';\nimport { suppressedCollections } from '../../models';\nimport type { CollectionTitles } from '../../data-source/models';\nimport { BaseTileComponent } from '../base-tile-component';\n\nimport { formatCount, NumberFormat } from '../../utils/format-count';\nimport type { DateFormat } from '../../utils/format-date';\nimport { isFirstMillisecondOfUTCYear } from '../../utils/local-date-from-utc';\n\nimport '../image-block';\nimport '../review-block';\nimport '../text-snippet-block';\nimport '../tile-mediatype-icon';\n\n@customElement('tile-list')\nexport class TileList extends BaseTileComponent {\n /*\n * Reactive properties inherited from BaseTileComponent:\n * - model?: TileModel;\n * - currentWidth?: number;\n * - currentHeight?: number;\n * - baseNavigationUrl?: string;\n * - baseImageUrl?: string;\n * - collectionPagePath?: string;\n * - sortParam: SortParam | null = null;\n * - defaultSortParam: SortParam | null = null;\n * - creatorFilter?: string;\n * - mobileBreakpoint?: number;\n * - loggedIn = false;\n * - suppressBlurring = false;\n * - useLocalTime = false;\n */\n\n @property({ type: Object })\n collectionTitles?: CollectionTitles;\n\n @state() private collectionLinks: (TemplateResult | typeof nothing)[] = [];\n\n render() {\n return html`\n <div id=\"list-line\" class=\"${this.classSize}\">\n ${this.classSize === 'mobile'\n ? this.mobileTemplate\n : this.desktopTemplate}\n </div>\n `;\n }\n\n /**\n * Templates\n */\n private get mobileTemplate() {\n return html`\n <div id=\"list-line-top\">\n <div id=\"list-line-left\">${this.imageBlockTemplate}</div>\n <div id=\"list-line-right\">\n <div id=\"title-line\">\n <div id=\"title\">${this.titleTemplate}</div>\n ${this.iconRightTemplate}\n </div>\n </div>\n </div>\n <div id=\"list-line-bottom\">${this.detailsTemplate}</div>\n `;\n }\n\n private get desktopTemplate() {\n return html`\n <div id=\"list-line-left\">${this.imageBlockTemplate}</div>\n <div id=\"list-line-right\">\n <div id=\"title-line\">\n <div id=\"title\">${this.titleTemplate}</div>\n ${this.iconRightTemplate}\n </div>\n ${this.detailsTemplate}\n </div>\n `;\n }\n\n private get imageBlockTemplate() {\n if (!this.model) return nothing;\n\n const isCollection = this.model.mediatype === 'collection';\n const href = this.displayValueProvider.itemPageUrl(\n this.model.identifier,\n isCollection,\n );\n\n return html`<a\n id=\"image-link\"\n title=${msg(str`View ${this.model?.title}`)}\n href=${href}\n >\n <image-block\n .model=${this.model}\n .baseImageUrl=${this.baseImageUrl}\n .isCompactTile=${false}\n .isListTile=${true}\n .viewSize=${this.classSize}\n .loggedIn=${this.loggedIn}\n .suppressBlurring=${this.suppressBlurring}\n >\n </image-block>\n </a> `;\n }\n\n private get detailsTemplate() {\n return html`\n ${this.itemLineTemplate} ${this.creatorTemplate}\n <div id=\"dates-line\">\n ${this.datePublishedTemplate} ${this.dateSortByTemplate}\n ${this.webArchivesCaptureDatesTemplate}\n </div>\n <div id=\"views-line\">\n ${this.viewsTemplate} ${this.ratingTemplate} ${this.reviewsTemplate}\n </div>\n ${this.topicsTemplate} ${this.collectionsTemplate}\n ${this.descriptionTemplate} ${this.textSnippetsTemplate}\n ${this.reviewBlockTemplate}\n `;\n }\n\n // Data templates\n private get iconRightTemplate() {\n return html`\n <a\n id=\"icon-right\"\n href=${this.mediatypeURL}\n title=${msg(str`See more: ${this.model?.mediatype}`)}\n >\n <tile-mediatype-icon .model=${this.model}> </tile-mediatype-icon>\n </a>\n `;\n }\n\n private get titleTemplate() {\n if (!this.model?.title) {\n return nothing;\n }\n\n // If the model has a server-specified href, use it\n // Otherwise construct a details link using the identifier\n return this.model?.href\n ? html`<a href=\"${this.baseNavigationUrl}${this.model.href}\"\n >${this.model.title ?? this.model.identifier}</a\n >`\n : this.detailsLink(\n this.model.identifier,\n this.model.title,\n this.model.mediatype === 'collection',\n );\n }\n\n private get itemLineTemplate() {\n const source = this.sourceTemplate;\n const volume = this.volumeTemplate;\n const issue = this.issueTemplate;\n if (!source && !volume && !issue) {\n return nothing;\n }\n return html` <div id=\"item-line\">${source} ${volume} ${issue}</div> `;\n }\n\n private get sourceTemplate() {\n if (!this.model?.source) {\n return nothing;\n }\n return html`\n <div id=\"source\" class=\"metadata\">\n ${this.labelTemplate(msg('Source'))}\n ${this.searchLink('source', this.model.source)}\n </div>\n `;\n }\n\n private get volumeTemplate() {\n return this.metadataTemplate(this.model?.volume, msg('Volume'));\n }\n\n private get issueTemplate() {\n return this.metadataTemplate(this.model?.issue, msg('Issue'));\n }\n\n private get creatorTemplate() {\n // \"Archivist since\" if account\n if (this.model?.mediatype === 'account') {\n return html`\n <div id=\"creator\" class=\"metadata\">\n <span class=\"label\"\n >${this.displayValueProvider.accountLabel ?? nothing}</span\n >\n </div>\n `;\n }\n // \"Creator\" if not account tile\n if (!this.model?.creators || this.model.creators.length === 0) {\n return nothing;\n }\n return html`\n <div id=\"creator\" class=\"metadata\">\n ${this.labelTemplate(msg('By'))}\n ${join(\n map(this.model.creators, id => this.searchLink('creator', id)),\n ', ',\n )}\n </div>\n `;\n }\n\n private get datePublishedTemplate() {\n // If we're showing a date published of Jan 1 at midnight, only show the year.\n // This is because items with only a year for their publication date are normalized to\n // Jan 1 at midnight timestamps in the search engine documents.\n const date: Date | undefined = this.model?.datePublished;\n let format: DateFormat = 'long';\n if (isFirstMillisecondOfUTCYear(date)) {\n format = 'year-only';\n }\n\n return this.metadataTemplate(\n this.getFormattedDate(date, format),\n msg('Published'),\n );\n }\n\n // Show date label/value when sorted by date type\n // Except datePublished which is always shown\n private get dateSortByTemplate() {\n if (\n this.effectiveSort &&\n (this.effectiveSort.field === 'addeddate' ||\n this.effectiveSort.field === 'reviewdate' ||\n this.effectiveSort.field === 'publicdate')\n ) {\n return this.metadataTemplate(\n this.getFormattedDate(this.date, 'long'),\n this.displayValueProvider.dateLabel,\n );\n }\n return nothing;\n }\n\n private get viewsTemplate() {\n const viewCount =\n this.effectiveSort?.field === 'week'\n ? this.model?.weeklyViewCount // weekly views\n : this.model?.viewCount; // all-time views\n if (viewCount == null) return nothing;\n\n // when its a search-tile, we don't have any stats to show\n if (this.model?.mediatype === 'search') {\n return this.metadataTemplate('(Favorited search query)', '');\n }\n\n return this.metadataTemplate(\n `${formatCount(viewCount, this.formatSize)}`,\n msg('Views'),\n );\n }\n\n private get ratingTemplate() {\n return this.metadataTemplate(this.model?.averageRating, msg('Avg Rating'));\n }\n\n private get reviewsTemplate() {\n return this.metadataTemplate(this.model?.commentCount, msg('Reviews'));\n }\n\n private get topicsTemplate() {\n if (!this.model?.subjects || this.model.subjects.length === 0) {\n return nothing;\n }\n return html`\n <div id=\"topics\" class=\"metadata\">\n ${this.labelTemplate(msg('Topics'))}\n ${join(\n map(this.model.subjects, id => this.searchLink('subject', id)),\n ', ',\n )}\n </div>\n `;\n }\n\n private get collectionsTemplate() {\n if (!this.collectionLinks || this.collectionLinks.length === 0) {\n return nothing;\n }\n return html`\n <div id=\"collections\" class=\"metadata\">\n ${this.labelTemplate(msg('Collections'))}\n ${join(this.collectionLinks, ', ')}\n </div>\n `;\n }\n\n private get descriptionTemplate() {\n return this.metadataTemplate(\n // Sanitize away any HTML tags and convert line breaks to spaces.\n unsafeHTML(\n DOMPurify.sanitize(this.model?.description?.replace(/\\n/g, ' ') ?? ''),\n ),\n '',\n 'description',\n );\n }\n\n private get reviewBlockTemplate(): TemplateResult | typeof nothing {\n if (!this.model?.review) return nothing;\n\n const { reviewtitle, reviewbody, stars } = this.model.review;\n return html`\n <review-block\n viewsize=\"list\"\n title=${ifDefined(reviewtitle)}\n body=${ifDefined(reviewbody)}\n starRating=${ifDefined(stars)}\n >\n </review-block>\n `;\n }\n\n private get textSnippetsTemplate(): TemplateResult | typeof nothing {\n if (!this.hasSnippets) return nothing;\n\n return html`<text-snippet-block\n viewsize=\"list\"\n .snippets=${this.model?.snippets}\n ></text-snippet-block>`;\n }\n\n private get hasSnippets(): boolean {\n return !!this.model?.snippets?.length;\n }\n\n private get webArchivesCaptureDatesTemplate():\n | TemplateResult\n | typeof nothing {\n if (!this.model?.captureDates || !this.model.title) return nothing;\n\n return html`\n <ul class=\"capture-dates\">\n ${map(\n this.model.captureDates,\n date =>\n html`<li>\n ${this.displayValueProvider.webArchivesCaptureLink(\n this.model!.title,\n date,\n )}\n </li>`,\n )}\n </ul>\n `;\n }\n\n // Utility functions\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n private metadataTemplate(text: any, label = '', id?: string) {\n if (!text) return nothing;\n return html`\n <div id=${ifDefined(id)} class=\"metadata\">\n ${this.labelTemplate(label)} ${text}\n </div>\n `;\n }\n\n private labelTemplate(label: string) {\n return html` ${label\n ? html`<span class=\"label\">${label}: </span>`\n : nothing}`;\n }\n\n private searchLink(field: string, searchTerm: string) {\n if (!field || !searchTerm) {\n return nothing;\n }\n const query = encodeURIComponent(`${field}:\"${searchTerm}\"`);\n // No whitespace after closing tag\n // Note: single ' for href='' to wrap \" in query var gets changed back by yarn format\n return html`<a\n href=\"${this.baseNavigationUrl}/search?query=${query}\"\n rel=\"nofollow\"\n >\n ${DOMPurify.sanitize(searchTerm)}</a\n >`;\n }\n\n private detailsLink(\n identifier?: string,\n text?: string,\n isCollection = false,\n ): TemplateResult | typeof nothing {\n if (!identifier) return nothing;\n\n const linkText = text ?? identifier;\n const linkHref = this.displayValueProvider.itemPageUrl(\n identifier,\n isCollection,\n );\n\n return html`<a href=${linkHref}> ${DOMPurify.sanitize(linkText)} </a>`;\n }\n\n /** The URL of this item's mediatype collection, if defined. */\n private get mediatypeURL(): string | typeof nothing {\n // NB: baseNavigationUrl can be an empty string\n if (this.baseNavigationUrl === undefined || !this.model?.mediatype)\n return nothing;\n\n // Need special handling for certain mediatypes that don't have a top-level collection page\n switch (this.model.mediatype) {\n case 'collection':\n return `${this.baseNavigationUrl}/search?query=mediatype:collection&sort=-downloads`;\n case 'account':\n return nothing;\n default:\n return this.displayValueProvider.itemPageUrl(\n this.model.mediatype,\n true,\n );\n }\n }\n\n protected updated(changed: PropertyValues): void {\n if (changed.has('model') || changed.has('collectionTitles')) {\n this.buildCollectionLinks();\n }\n }\n\n private async buildCollectionLinks() {\n if (!this.model?.collections || this.model.collections.length === 0) {\n return;\n }\n\n // Note: quirk of Lit: need to replace collectionLinks array,\n // otherwise it will not re-render. Can't simply alter the array.\n this.collectionLinks = [];\n const newCollectionLinks: (TemplateResult | typeof nothing)[] = [];\n for (const collection of this.model.collections) {\n // Don't include favorites or collections that are meant to be suppressed\n if (\n !suppressedCollections[collection] &&\n !collection.startsWith('fav-')\n ) {\n newCollectionLinks.push(\n this.detailsLink(\n collection,\n this.collectionTitles?.get(collection) ?? collection,\n true,\n ),\n );\n }\n }\n this.collectionLinks = newCollectionLinks;\n }\n\n /*\n * TODO: fix field names to match model in src/collection-browser.ts\n * private get dateSortSelector()\n * @see src/models.ts\n */\n private get date(): Date | undefined {\n switch (this.effectiveSort?.field) {\n case 'date':\n return this.model?.datePublished;\n case 'reviewdate':\n return this.model?.dateReviewed;\n case 'addeddate':\n return this.model?.dateAdded;\n default:\n return this.model?.dateArchived; // publicdate\n }\n }\n\n /**\n * Returns the active sort param if one is set, or the default sort param otherwise.\n */\n private get effectiveSort(): SortParam | null {\n return this.sortParam ?? this.defaultSortParam;\n }\n\n private get classSize(): string {\n if (\n this.mobileBreakpoint &&\n this.currentWidth &&\n this.currentWidth < this.mobileBreakpoint\n ) {\n return 'mobile';\n }\n return 'desktop';\n }\n\n private get formatSize(): NumberFormat {\n if (\n this.mobileBreakpoint &&\n this.currentWidth &&\n this.currentWidth < this.mobileBreakpoint\n ) {\n return 'short';\n }\n return 'long';\n }\n\n static get styles() {\n return css`\n html {\n font-size: unset;\n }\n\n div {\n font-size: 14px;\n }\n\n div a {\n text-decoration: none;\n }\n\n div a:link {\n color: var(--ia-theme-link-color, #4b64ff);\n }\n\n .label {\n font-weight: bold;\n }\n\n #list-line.mobile {\n --infiniteScrollerRowGap: 20px;\n --infiniteScrollerRowHeight: auto;\n }\n\n #list-line.desktop {\n --infiniteScrollerRowGap: 30px;\n --infiniteScrollerRowHeight: auto;\n }\n\n /* fields */\n #icon-right {\n width: 20px;\n padding-top: 5px;\n --iconHeight: 20px;\n --iconWidth: 20px;\n --iconTextAlign: right;\n margin-top: -8px;\n text-align: right;\n }\n\n #title {\n color: #4b64ff;\n text-decoration: none;\n font-size: 22px;\n font-weight: bold;\n /* align top of text with image */\n line-height: 25px;\n margin-top: -4px;\n padding-bottom: 2px;\n flex-grow: 1;\n\n display: -webkit-box;\n -webkit-box-orient: vertical;\n -webkit-line-clamp: 3;\n overflow: hidden;\n overflow-wrap: anywhere;\n }\n\n .metadata {\n line-height: 20px;\n }\n\n #description,\n #creator,\n #topics,\n #source {\n text-align: left;\n overflow: hidden;\n text-overflow: ellipsis;\n -webkit-box-orient: vertical;\n display: -webkit-box;\n word-break: break-word;\n -webkit-line-clamp: 3; /* number of lines to show */\n line-clamp: 3;\n\n /*\n * Safari doesn't always respect the line-clamping rules above,\n * so we add this to ensure these fields still get truncated\n */\n max-height: 60px;\n }\n\n #collections {\n display: -webkit-box;\n -webkit-box-orient: vertical;\n -webkit-line-clamp: 3;\n overflow: hidden;\n overflow-wrap: anywhere;\n }\n\n #collections > a {\n display: inline-block;\n }\n\n #icon {\n padding-top: 5px;\n }\n\n #description {\n padding-top: 10px;\n }\n\n /* Top level container */\n #list-line {\n display: flex;\n }\n\n #list-line.mobile {\n flex-direction: column;\n }\n\n #list-line.desktop {\n column-gap: 10px;\n }\n\n #list-line-top {\n display: flex;\n column-gap: 7px;\n }\n\n #list-line-bottom {\n padding-top: 4px;\n }\n\n #list-line-right,\n #list-line-top,\n #list-line-bottom {\n width: 100%;\n }\n\n /*\n * If the container becomes very tiny, don't let the thumbnail side take\n * up too much space. Shouldn't make a difference on ordinary viewport sizes.\n */\n #list-line-left {\n max-width: 25%;\n\n display: flex;\n flex-direction: column;\n row-gap: 5px;\n }\n\n div a:hover {\n text-decoration: underline;\n }\n\n /* Lines containing multiple div as row */\n #item-line,\n #dates-line,\n #views-line,\n #title-line {\n display: flex;\n flex-direction: row;\n column-gap: 10px;\n }\n\n /*\n * With the exception of the title line, allow these to wrap if\n * the space becomes too small to accommodate them together.\n *\n * The title line is excluded because it contains the mediatype icon\n * which we don't want to wrap.\n */\n #item-line,\n #dates-line,\n #views-line {\n flex-wrap: wrap;\n }\n\n .capture-dates {\n margin: 0;\n padding: 0;\n list-style-type: none;\n }\n\n .capture-dates a:link {\n text-decoration: none;\n color: var(--ia-theme-link-color, #4b64ff);\n }\n .capture-dates a:hover {\n text-decoration: underline;\n }\n `;\n }\n}\n"]}
1
+ {"version":3,"file":"tile-list.js","sourceRoot":"","sources":["../../../../src/tiles/list/tile-list.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAkC,MAAM,KAAK,CAAC;AACzE,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAC;AAC9C,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,SAAS,MAAM,WAAW,CAAC;AAGlC,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;A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ACrB,IAAI,CAAC,YAAY;YACjB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,gBAAgB,EACzC,CAAC;YACD,OAAO,QAAQ,CAAC;QAClB,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,IAAY,UAAU;QACpB,IACE,IAAI,CAAC,gBAAgB;YACrB,IAAI,CAAC,YAAY;YACjB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,gBAAgB,EACzC,CAAC;YACD,OAAO,OAAO,CAAC;QACjB,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAwLT,CAAC;IACJ,CAAC;CACF,CAAA;AAhpBC;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDACS;AAEnB;IAAhB,KAAK,EAAE;iDAAmE;AArBhE,QAAQ;IADpB,aAAa,CAAC,WAAW,CAAC;GACd,QAAQ,CAmqBpB","sourcesContent":["import { css, html, nothing, PropertyValues, TemplateResult } from 'lit';\r\nimport { ifDefined } from 'lit/directives/if-defined.js';\r\nimport { join } from 'lit/directives/join.js';\r\nimport { map } from 'lit/directives/map.js';\r\nimport { unsafeHTML } from 'lit/directives/unsafe-html.js';\r\nimport { customElement, property, state } from 'lit/decorators.js';\r\nimport { msg, str } from '@lit/localize';\r\nimport DOMPurify from 'dompurify';\r\n\r\nimport type { SortParam } from '@internetarchive/search-service';\r\nimport { suppressedCollections } from '../../models';\r\nimport type { CollectionTitles } from '../../data-source/models';\r\nimport { BaseTileComponent } from '../base-tile-component';\r\n\r\nimport { formatCount, NumberFormat } from '../../utils/format-count';\r\nimport type { DateFormat } from '../../utils/format-date';\r\nimport { isFirstMillisecondOfUTCYear } from '../../utils/local-date-from-utc';\r\n\r\nimport '../image-block';\r\nimport '../review-block';\r\nimport '../text-snippet-block';\r\nimport '../tile-mediatype-icon';\r\n\r\n@customElement('tile-list')\r\nexport class TileList extends BaseTileComponent {\r\n /*\r\n * Reactive properties inherited from BaseTileComponent:\r\n * - model?: TileModel;\r\n * - currentWidth?: number;\r\n * - currentHeight?: number;\r\n * - baseNavigationUrl?: string;\r\n * - baseImageUrl?: string;\r\n * - collectionPagePath?: string;\r\n * - sortParam: SortParam | null = null;\r\n * - defaultSortParam: SortParam | null = null;\r\n * - creatorFilter?: string;\r\n * - mobileBreakpoint?: number;\r\n * - loggedIn = false;\r\n * - suppressBlurring = false;\r\n * - useLocalTime = false;\r\n */\r\n\r\n @property({ type: Object })\r\n collectionTitles?: CollectionTitles;\r\n\r\n @state() private collectionLinks: (TemplateResult | typeof nothing)[] = [];\r\n\r\n render() {\r\n return html`\r\n <div id=\"list-line\" class=\"${this.classSize}\">\r\n ${this.classSize === 'mobile'\r\n ? this.mobileTemplate\r\n : this.desktopTemplate}\r\n </div>\r\n `;\r\n }\r\n\r\n /**\r\n * Templates\r\n */\r\n private get mobileTemplate() {\r\n return html`\r\n <div id=\"list-line-top\">\r\n <div id=\"list-line-left\">${this.imageBlockTemplate}</div>\r\n <div id=\"list-line-right\">\r\n <div id=\"title-line\">\r\n <div id=\"title\">${this.titleTemplate}</div>\r\n ${this.iconRightTemplate}\r\n </div>\r\n </div>\r\n </div>\r\n <div id=\"list-line-bottom\">${this.detailsTemplate}</div>\r\n `;\r\n }\r\n\r\n private get desktopTemplate() {\r\n return html`\r\n <div id=\"list-line-left\">${this.imageBlockTemplate}</div>\r\n <div id=\"list-line-right\">\r\n <div id=\"title-line\">\r\n <div id=\"title\">${this.titleTemplate}</div>\r\n ${this.iconRightTemplate}\r\n </div>\r\n ${this.detailsTemplate}\r\n </div>\r\n `;\r\n }\r\n\r\n private get imageBlockTemplate() {\r\n if (!this.model) return nothing;\r\n\r\n const isCollection = this.model.mediatype === 'collection';\r\n const href = this.displayValueProvider.itemPageUrl(\r\n this.model.identifier,\r\n isCollection,\r\n );\r\n\r\n return html`<a\r\n id=\"image-link\"\r\n title=${msg(str`View ${this.model?.title}`)}\r\n href=${href}\r\n >\r\n <image-block\r\n .model=${this.model}\r\n .baseImageUrl=${this.baseImageUrl}\r\n .isCompactTile=${false}\r\n .isListTile=${true}\r\n .viewSize=${this.classSize}\r\n .loggedIn=${this.loggedIn}\r\n .suppressBlurring=${this.suppressBlurring}\r\n >\r\n </image-block>\r\n </a> `;\r\n }\r\n\r\n private get detailsTemplate() {\r\n return html`\r\n ${this.itemLineTemplate} ${this.creatorTemplate}\r\n <div id=\"dates-line\">\r\n ${this.datePublishedTemplate} ${this.dateSortByTemplate}\r\n ${this.webArchivesCaptureDatesTemplate}\r\n </div>\r\n <div id=\"views-line\">\r\n ${this.viewsTemplate} ${this.ratingTemplate} ${this.reviewsTemplate}\r\n </div>\r\n ${this.topicsTemplate} ${this.collectionsTemplate}\r\n ${this.descriptionTemplate} ${this.textSnippetsTemplate}\r\n ${this.reviewBlockTemplate}\r\n `;\r\n }\r\n\r\n // Data templates\r\n private get iconRightTemplate() {\r\n return html`\r\n <a\r\n id=\"icon-right\"\r\n href=${this.mediatypeURL}\r\n title=${msg(str`See more: ${this.model?.mediatype}`)}\r\n >\r\n <tile-mediatype-icon .model=${this.model}> </tile-mediatype-icon>\r\n </a>\r\n `;\r\n }\r\n\r\n private get titleTemplate() {\r\n if (!this.model?.title) {\r\n return nothing;\r\n }\r\n\r\n // If the model has a server-specified href, use it\r\n // Otherwise construct a details link using the identifier\r\n return this.model?.href\r\n ? html`<a href=\"${this.baseNavigationUrl}${this.model.href}\"\r\n >${this.model.title ?? this.model.identifier}</a\r\n >`\r\n : this.detailsLink(\r\n this.model.identifier,\r\n this.model.title,\r\n this.model.mediatype === 'collection',\r\n );\r\n }\r\n\r\n private get itemLineTemplate() {\r\n const source = this.sourceTemplate;\r\n const volume = this.volumeTemplate;\r\n const issue = this.issueTemplate;\r\n if (!source && !volume && !issue) {\r\n return nothing;\r\n }\r\n return html` <div id=\"item-line\">${source} ${volume} ${issue}</div> `;\r\n }\r\n\r\n private get sourceTemplate() {\r\n if (!this.model?.source) {\r\n return nothing;\r\n }\r\n return html`\r\n <div id=\"source\" class=\"metadata\">\r\n ${this.labelTemplate(msg('Source'))}\r\n ${this.searchLink('source', this.model.source)}\r\n </div>\r\n `;\r\n }\r\n\r\n private get volumeTemplate() {\r\n return this.metadataTemplate(this.model?.volume, msg('Volume'));\r\n }\r\n\r\n private get issueTemplate() {\r\n return this.metadataTemplate(this.model?.issue, msg('Issue'));\r\n }\r\n\r\n private get creatorTemplate() {\r\n // \"Archivist since\" if account\r\n if (this.model?.mediatype === 'account') {\r\n return html`\r\n <div id=\"creator\" class=\"metadata\">\r\n <span class=\"label\"\r\n >${this.displayValueProvider.accountLabel ?? nothing}</span\r\n >\r\n </div>\r\n `;\r\n }\r\n // \"Creator\" if not account tile\r\n if (!this.model?.creators || this.model.creators.length === 0) {\r\n return nothing;\r\n }\r\n return html`\r\n <div id=\"creator\" class=\"metadata\">\r\n ${this.labelTemplate(msg('By'))}\r\n ${join(\r\n map(this.model.creators, id => this.searchLink('creator', id)),\r\n ', ',\r\n )}\r\n </div>\r\n `;\r\n }\r\n\r\n private get datePublishedTemplate() {\r\n // If we're showing a date published of Jan 1 at midnight, only show the year.\r\n // This is because items with only a year for their publication date are normalized to\r\n // Jan 1 at midnight timestamps in the search engine documents.\r\n const date: Date | undefined = this.model?.datePublished;\r\n let format: DateFormat = 'long';\r\n if (isFirstMillisecondOfUTCYear(date)) {\r\n format = 'year-only';\r\n }\r\n\r\n return this.metadataTemplate(\r\n this.getFormattedDate(date, format),\r\n msg('Published'),\r\n );\r\n }\r\n\r\n // Show date label/value when sorted by date type\r\n // Except datePublished which is always shown\r\n private get dateSortByTemplate() {\r\n if (\r\n this.effectiveSort &&\r\n (this.effectiveSort.field === 'addeddate' ||\r\n this.effectiveSort.field === 'reviewdate' ||\r\n this.effectiveSort.field === 'publicdate')\r\n ) {\r\n return this.metadataTemplate(\r\n this.getFormattedDate(this.date, 'long'),\r\n this.displayValueProvider.dateLabel,\r\n );\r\n }\r\n return nothing;\r\n }\r\n\r\n private get viewsTemplate() {\r\n const isWeeklySort = this.effectiveSort?.field === 'week';\r\n const viewCount = isWeeklySort\r\n ? this.model?.weeklyViewCount // weekly views\r\n : this.model?.viewCount; // all-time views\r\n if (viewCount == null) return nothing;\r\n\r\n // when its a search-tile, we don't have any stats to show\r\n if (this.model?.mediatype === 'search') {\r\n return this.metadataTemplate('(Favorited search query)', '');\r\n }\r\n\r\n return this.metadataTemplate(\r\n `${formatCount(viewCount, this.formatSize)}`,\r\n this.displayValueProvider.viewsLabel,\r\n );\r\n }\r\n\r\n private get ratingTemplate() {\r\n return this.metadataTemplate(this.model?.averageRating, msg('Avg Rating'));\r\n }\r\n\r\n private get reviewsTemplate() {\r\n return this.metadataTemplate(this.model?.commentCount, msg('Reviews'));\r\n }\r\n\r\n private get topicsTemplate() {\r\n if (!this.model?.subjects || this.model.subjects.length === 0) {\r\n return nothing;\r\n }\r\n return html`\r\n <div id=\"topics\" class=\"metadata\">\r\n ${this.labelTemplate(msg('Topics'))}\r\n ${join(\r\n map(this.model.subjects, id => this.searchLink('subject', id)),\r\n ', ',\r\n )}\r\n </div>\r\n `;\r\n }\r\n\r\n private get collectionsTemplate() {\r\n if (!this.collectionLinks || this.collectionLinks.length === 0) {\r\n return nothing;\r\n }\r\n return html`\r\n <div id=\"collections\" class=\"metadata\">\r\n ${this.labelTemplate(msg('Collections'))}\r\n ${join(this.collectionLinks, ', ')}\r\n </div>\r\n `;\r\n }\r\n\r\n private get descriptionTemplate() {\r\n return this.metadataTemplate(\r\n // Sanitize away any HTML tags and convert line breaks to spaces.\r\n unsafeHTML(\r\n DOMPurify.sanitize(this.model?.description?.replace(/\\n/g, ' ') ?? ''),\r\n ),\r\n '',\r\n 'description',\r\n );\r\n }\r\n\r\n private get reviewBlockTemplate(): TemplateResult | typeof nothing {\r\n if (!this.model?.review) return nothing;\r\n\r\n const { reviewtitle, reviewbody, stars } = this.model.review;\r\n return html`\r\n <review-block\r\n viewsize=\"list\"\r\n title=${ifDefined(reviewtitle)}\r\n body=${ifDefined(reviewbody)}\r\n starRating=${ifDefined(stars)}\r\n >\r\n </review-block>\r\n `;\r\n }\r\n\r\n private get textSnippetsTemplate(): TemplateResult | typeof nothing {\r\n if (!this.hasSnippets) return nothing;\r\n\r\n return html`<text-snippet-block\r\n viewsize=\"list\"\r\n .snippets=${this.model?.snippets}\r\n ></text-snippet-block>`;\r\n }\r\n\r\n private get hasSnippets(): boolean {\r\n return !!this.model?.snippets?.length;\r\n }\r\n\r\n private get webArchivesCaptureDatesTemplate():\r\n | TemplateResult\r\n | typeof nothing {\r\n if (!this.model?.captureDates || !this.model.title) return nothing;\r\n\r\n return html`\r\n <ul class=\"capture-dates\">\r\n ${map(\r\n this.model.captureDates,\r\n date =>\r\n html`<li>\r\n ${this.displayValueProvider.webArchivesCaptureLink(\r\n this.model!.title,\r\n date,\r\n )}\r\n </li>`,\r\n )}\r\n </ul>\r\n `;\r\n }\r\n\r\n // Utility functions\r\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\r\n private metadataTemplate(text: any, label = '', id?: string) {\r\n if (!text) return nothing;\r\n return html`\r\n <div id=${ifDefined(id)} class=\"metadata\">\r\n ${this.labelTemplate(label)} ${text}\r\n </div>\r\n `;\r\n }\r\n\r\n private labelTemplate(label: string) {\r\n return html` ${label\r\n ? html`<span class=\"label\">${label}: </span>`\r\n : nothing}`;\r\n }\r\n\r\n private searchLink(field: string, searchTerm: string) {\r\n if (!field || !searchTerm) {\r\n return nothing;\r\n }\r\n const query = encodeURIComponent(`${field}:\"${searchTerm}\"`);\r\n // No whitespace after closing tag\r\n // Note: single ' for href='' to wrap \" in query var gets changed back by yarn format\r\n return html`<a\r\n href=\"${this.baseNavigationUrl}/search?query=${query}\"\r\n rel=\"nofollow\"\r\n >\r\n ${DOMPurify.sanitize(searchTerm)}</a\r\n >`;\r\n }\r\n\r\n private detailsLink(\r\n identifier?: string,\r\n text?: string,\r\n isCollection = false,\r\n ): TemplateResult | typeof nothing {\r\n if (!identifier) return nothing;\r\n\r\n const linkText = text ?? identifier;\r\n const linkHref = this.displayValueProvider.itemPageUrl(\r\n identifier,\r\n isCollection,\r\n );\r\n\r\n return html`<a href=${linkHref}> ${DOMPurify.sanitize(linkText)} </a>`;\r\n }\r\n\r\n /** The URL of this item's mediatype collection, if defined. */\r\n private get mediatypeURL(): string | typeof nothing {\r\n // NB: baseNavigationUrl can be an empty string\r\n if (this.baseNavigationUrl === undefined || !this.model?.mediatype)\r\n return nothing;\r\n\r\n // Need special handling for certain mediatypes that don't have a top-level collection page\r\n switch (this.model.mediatype) {\r\n case 'collection':\r\n return `${this.baseNavigationUrl}/search?query=mediatype:collection&sort=-downloads`;\r\n case 'account':\r\n return nothing;\r\n default:\r\n return this.displayValueProvider.itemPageUrl(\r\n this.model.mediatype,\r\n true,\r\n );\r\n }\r\n }\r\n\r\n protected updated(changed: PropertyValues): void {\r\n if (changed.has('model') || changed.has('collectionTitles')) {\r\n this.buildCollectionLinks();\r\n }\r\n }\r\n\r\n private async buildCollectionLinks() {\r\n if (!this.model?.collections || this.model.collections.length === 0) {\r\n return;\r\n }\r\n\r\n // Note: quirk of Lit: need to replace collectionLinks array,\r\n // otherwise it will not re-render. Can't simply alter the array.\r\n this.collectionLinks = [];\r\n const newCollectionLinks: (TemplateResult | typeof nothing)[] = [];\r\n for (const collection of this.model.collections) {\r\n // Don't include favorites or collections that are meant to be suppressed\r\n if (\r\n !suppressedCollections[collection] &&\r\n !collection.startsWith('fav-')\r\n ) {\r\n newCollectionLinks.push(\r\n this.detailsLink(\r\n collection,\r\n this.collectionTitles?.get(collection) ?? collection,\r\n true,\r\n ),\r\n );\r\n }\r\n }\r\n this.collectionLinks = newCollectionLinks;\r\n }\r\n\r\n /*\r\n * TODO: fix field names to match model in src/collection-browser.ts\r\n * private get dateSortSelector()\r\n * @see src/models.ts\r\n */\r\n private get date(): Date | undefined {\r\n switch (this.effectiveSort?.field) {\r\n case 'date':\r\n return this.model?.datePublished;\r\n case 'reviewdate':\r\n return this.model?.dateReviewed;\r\n case 'addeddate':\r\n return this.model?.dateAdded;\r\n default:\r\n return this.model?.dateArchived; // publicdate\r\n }\r\n }\r\n\r\n /**\r\n * Returns the active sort param if one is set, or the default sort param otherwise.\r\n */\r\n private get effectiveSort(): SortParam | null {\r\n return this.sortParam ?? this.defaultSortParam;\r\n }\r\n\r\n private get classSize(): string {\r\n if (\r\n this.mobileBreakpoint &&\r\n this.currentWidth &&\r\n this.currentWidth < this.mobileBreakpoint\r\n ) {\r\n return 'mobile';\r\n }\r\n return 'desktop';\r\n }\r\n\r\n private get formatSize(): NumberFormat {\r\n if (\r\n this.mobileBreakpoint &&\r\n this.currentWidth &&\r\n this.currentWidth < this.mobileBreakpoint\r\n ) {\r\n return 'short';\r\n }\r\n return 'long';\r\n }\r\n\r\n static get styles() {\r\n return css`\r\n html {\r\n font-size: unset;\r\n }\r\n\r\n div {\r\n font-size: 14px;\r\n }\r\n\r\n div a {\r\n text-decoration: none;\r\n }\r\n\r\n div a:link {\r\n color: var(--ia-theme-link-color, #4b64ff);\r\n }\r\n\r\n .label {\r\n font-weight: bold;\r\n }\r\n\r\n #list-line.mobile {\r\n --infiniteScrollerRowGap: 20px;\r\n --infiniteScrollerRowHeight: auto;\r\n }\r\n\r\n #list-line.desktop {\r\n --infiniteScrollerRowGap: 30px;\r\n --infiniteScrollerRowHeight: auto;\r\n }\r\n\r\n /* fields */\r\n #icon-right {\r\n width: 20px;\r\n padding-top: 5px;\r\n --iconHeight: 20px;\r\n --iconWidth: 20px;\r\n --iconTextAlign: right;\r\n margin-top: -8px;\r\n text-align: right;\r\n }\r\n\r\n #title {\r\n color: #4b64ff;\r\n text-decoration: none;\r\n font-size: 22px;\r\n font-weight: bold;\r\n /* align top of text with image */\r\n line-height: 25px;\r\n margin-top: -4px;\r\n padding-bottom: 2px;\r\n flex-grow: 1;\r\n\r\n display: -webkit-box;\r\n -webkit-box-orient: vertical;\r\n -webkit-line-clamp: 3;\r\n overflow: hidden;\r\n overflow-wrap: anywhere;\r\n }\r\n\r\n .metadata {\r\n line-height: 20px;\r\n }\r\n\r\n #description,\r\n #creator,\r\n #topics,\r\n #source {\r\n text-align: left;\r\n overflow: hidden;\r\n text-overflow: ellipsis;\r\n -webkit-box-orient: vertical;\r\n display: -webkit-box;\r\n word-break: break-word;\r\n -webkit-line-clamp: 3; /* number of lines to show */\r\n line-clamp: 3;\r\n\r\n /*\r\n * Safari doesn't always respect the line-clamping rules above,\r\n * so we add this to ensure these fields still get truncated\r\n */\r\n max-height: 60px;\r\n }\r\n\r\n #collections {\r\n display: -webkit-box;\r\n -webkit-box-orient: vertical;\r\n -webkit-line-clamp: 3;\r\n overflow: hidden;\r\n overflow-wrap: anywhere;\r\n }\r\n\r\n #collections > a {\r\n display: inline-block;\r\n }\r\n\r\n #icon {\r\n padding-top: 5px;\r\n }\r\n\r\n #description {\r\n padding-top: 10px;\r\n }\r\n\r\n /* Top level container */\r\n #list-line {\r\n display: flex;\r\n }\r\n\r\n #list-line.mobile {\r\n flex-direction: column;\r\n }\r\n\r\n #list-line.desktop {\r\n column-gap: 10px;\r\n }\r\n\r\n #list-line-top {\r\n display: flex;\r\n column-gap: 7px;\r\n }\r\n\r\n #list-line-bottom {\r\n padding-top: 4px;\r\n }\r\n\r\n #list-line-right,\r\n #list-line-top,\r\n #list-line-bottom {\r\n width: 100%;\r\n }\r\n\r\n /*\r\n * If the container becomes very tiny, don't let the thumbnail side take\r\n * up too much space. Shouldn't make a difference on ordinary viewport sizes.\r\n */\r\n #list-line-left {\r\n max-width: 25%;\r\n\r\n display: flex;\r\n flex-direction: column;\r\n row-gap: 5px;\r\n }\r\n\r\n div a:hover {\r\n text-decoration: underline;\r\n }\r\n\r\n /* Lines containing multiple div as row */\r\n #item-line,\r\n #dates-line,\r\n #views-line,\r\n #title-line {\r\n display: flex;\r\n flex-direction: row;\r\n column-gap: 10px;\r\n }\r\n\r\n /*\r\n * With the exception of the title line, allow these to wrap if\r\n * the space becomes too small to accommodate them together.\r\n *\r\n * The title line is excluded because it contains the mediatype icon\r\n * which we don't want to wrap.\r\n */\r\n #item-line,\r\n #dates-line,\r\n #views-line {\r\n flex-wrap: wrap;\r\n }\r\n\r\n .capture-dates {\r\n margin: 0;\r\n padding: 0;\r\n list-style-type: none;\r\n }\r\n\r\n .capture-dates a:link {\r\n text-decoration: none;\r\n color: var(--ia-theme-link-color, #4b64ff);\r\n }\r\n .capture-dates a:hover {\r\n text-decoration: underline;\r\n }\r\n `;\r\n }\r\n}\r\n"]}
@@ -34,6 +34,11 @@ export declare class TileDisplayValueProvider {
34
34
  * or the empty string otherwise.
35
35
  */
36
36
  get dateLabel(): string;
37
+ /**
38
+ * The readable label for the current views column, based on whether
39
+ * weekly or all-time views are being shown.
40
+ */
41
+ get viewsLabel(): string;
37
42
  /**
38
43
  * Produces a URL pointing at the item page for the given identifier,
39
44
  * using the current base URL and the correct path based on whether the
@@ -63,6 +63,15 @@ export class TileDisplayValueProvider {
63
63
  return '';
64
64
  }
65
65
  }
66
+ /**
67
+ * The readable label for the current views column, based on whether
68
+ * weekly or all-time views are being shown.
69
+ */
70
+ get viewsLabel() {
71
+ return this.sortParam?.field === 'week'
72
+ ? msg('Weekly views')
73
+ : msg('All-time views');
74
+ }
66
75
  /**
67
76
  * Produces a URL pointing at the item page for the given identifier,
68
77
  * using the current base URL and the correct path based on whether the
@@ -1 +1 @@
1
- {"version":3,"file":"tile-display-value-provider.js","sourceRoot":"","sources":["../../../src/tiles/tile-display-value-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CA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","sourcesContent":["import { TemplateResult, html, nothing } from 'lit';\nimport { msg, str } from '@lit/localize';\nimport type { SortParam } from '@internetarchive/search-service';\nimport type { TileModel } from '../models';\nimport { formatDate } from '../utils/format-date';\n\n/**\n * A class encapsulating shared logic for converting model values into display values\n * across different types of tiles.\n */\nexport class TileDisplayValueProvider {\n private model?: TileModel;\n\n private baseNavigationUrl?: string;\n\n private collectionPagePath?: string;\n\n private sortParam?: SortParam;\n\n private creatorFilter?: string;\n\n constructor(\n options: {\n model?: TileModel;\n baseNavigationUrl?: string;\n collectionPagePath?: string;\n sortParam?: SortParam;\n creatorFilter?: string;\n } = {},\n ) {\n this.model = options.model;\n this.baseNavigationUrl = options.baseNavigationUrl;\n this.collectionPagePath = options.collectionPagePath ?? '/details/';\n this.sortParam = options.sortParam;\n this.creatorFilter = options.creatorFilter;\n }\n\n /**\n * Examines the creator(s) for the given tile model, returning\n * the first creator whose name matches the provided filter\n * (or simply the first creator overall if no filter is provided).\n */\n get firstCreatorMatchingFilter(): string | undefined {\n let matchingCreator;\n\n // If we're filtering by creator initial and have multiple creators, we want\n // to surface the first creator who matches the filter.\n if (this.creatorFilter && this.model?.creators.length) {\n const firstLetter = this.creatorFilter; // This is just to satisfy tsc\n matchingCreator = this.model.creators.find(creator =>\n // Decompose combining characters first, so that e.g., filtering on E matches É too.\n // Then remove anything that isn't strictly alphabetic, since our filters currently\n // only handle A-Z. The first such letter (if one exists) is what needs to match.\n creator\n .normalize('NFD')\n .replace(/[^A-Z]+/gi, '')\n .toUpperCase()\n .startsWith(firstLetter),\n );\n }\n\n return matchingCreator ?? this.model?.creator;\n }\n\n /**\n * The label indicating what year an account item was created.\n * E.g., \"Archivist since 2015\"\n */\n get accountLabel(): string {\n return this.model?.dateAdded\n ? msg(str`Archivist since ${this.model.dateAdded.getFullYear()}`)\n : '';\n }\n\n /**\n * The readable label for the current sort if it is a type of date sort,\n * or the empty string otherwise.\n */\n get dateLabel(): string {\n switch (this.sortParam?.field) {\n case 'publicdate':\n return msg('Archived');\n case 'reviewdate':\n return msg('Reviewed');\n case 'addeddate':\n return msg('Added');\n case 'date':\n return msg('Published');\n default:\n return '';\n }\n }\n\n /**\n * Produces a URL pointing at the item page for the given identifier,\n * using the current base URL and the correct path based on whether the\n * item is specified to be a collection (default false).\n */\n itemPageUrl(\n identifier?: string,\n isCollection = false,\n ): string | typeof nothing {\n if (!identifier || this.baseNavigationUrl == null) return nothing;\n const basePath = isCollection ? this.collectionPagePath : '/details/';\n return `${this.baseNavigationUrl}${basePath}${identifier}`;\n }\n\n /**\n * Produces a template for a link to a single web capture of the given URL and date\n */\n webArchivesCaptureLink(url: string, date: Date): TemplateResult {\n // Convert the date into the format used to identify wayback captures (e.g., '20150102124550')\n const captureDateStr = date\n .toISOString()\n .replace(/[TZ:-]/g, '')\n .replace(/\\..*/, '');\n const captureHref = `https://web.archive.org/web/${captureDateStr}/${encodeURIComponent(\n url,\n )}`;\n const captureText = formatDate(date, 'long');\n\n return html` <a href=${captureHref}> ${captureText} </a> `;\n }\n}\n"]}
1
+ {"version":3,"file":"tile-display-value-provider.js","sourceRoot":"","sources":["../../../src/tiles/tile-display-value-provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACpD,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAGzC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD;;;GAGG;AACH,MAAM,OAAO,wBAAwB;IAWnC,YACE,UAMI,EAAE;QAEN,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC3B,IAAI,CAAC,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC;QACnD,IAAI,CAAC,kBAAkB,GAAG,OAAO,CAAC,kBAAkB,IAAI,WAAW,CAAC;QACpE,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAC;QACnC,IAAI,CAAC,aA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;QACd,CAAC;IACH,CAAC;IAED;;;OAGG;IACH,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,SAAS,EAAE,KAAK,KAAK,MAAM;YACrC,CAAC,CAAC,GAAG,CAAC,cAAc,CAAC;YACrB,CAAC,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IAC5B,CAAC;IAED;;;;OAIG;IACH,WAAW,CACT,UAAmB,EACnB,YAAY,GAAG,KAAK;QAEpB,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,iBAAiB,IAAI,IAAI;YAAE,OAAO,OAAO,CAAC;QAClE,MAAM,QAAQ,GAAG,YAAY,CAAC,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,CAAC,WAAW,CAAC;QACtE,OAAO,GAAG,IAAI,CAAC,iBAAiB,GAAG,QAAQ,GAAG,UAAU,EAAE,CAAC;IAC7D,CAAC;IAED;;OAEG;IACH,sBAAsB,CAAC,GAAW,EAAE,IAAU;QAC5C,8FAA8F;QAC9F,MAAM,cAAc,GAAG,IAAI;aACxB,WAAW,EAAE;aACb,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC;aACtB,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QACvB,MAAM,WAAW,GAAG,+BAA+B,cAAc,IAAI,kBAAkB,CACrF,GAAG,CACJ,EAAE,CAAC;QACJ,MAAM,WAAW,GAAG,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAE7C,OAAO,IAAI,CAAA,YAAY,WAAW,KAAK,WAAW,QAAQ,CAAC;IAC7D,CAAC;CACF","sourcesContent":["import { TemplateResult, html, nothing } from 'lit';\r\nimport { msg, str } from '@lit/localize';\r\nimport type { SortParam } from '@internetarchive/search-service';\r\nimport type { TileModel } from '../models';\r\nimport { formatDate } from '../utils/format-date';\r\n\r\n/**\r\n * A class encapsulating shared logic for converting model values into display values\r\n * across different types of tiles.\r\n */\r\nexport class TileDisplayValueProvider {\r\n private model?: TileModel;\r\n\r\n private baseNavigationUrl?: string;\r\n\r\n private collectionPagePath?: string;\r\n\r\n private sortParam?: SortParam;\r\n\r\n private creatorFilter?: string;\r\n\r\n constructor(\r\n options: {\r\n model?: TileModel;\r\n baseNavigationUrl?: string;\r\n collectionPagePath?: string;\r\n sortParam?: SortParam;\r\n creatorFilter?: string;\r\n } = {},\r\n ) {\r\n this.model = options.model;\r\n this.baseNavigationUrl = options.baseNavigationUrl;\r\n this.collectionPagePath = options.collectionPagePath ?? '/details/';\r\n this.sortParam = options.sortParam;\r\n this.creatorFilter = options.creatorFilter;\r\n }\r\n\r\n /**\r\n * Examines the creator(s) for the given tile model, returning\r\n * the first creator whose name matches the provided filter\r\n * (or simply the first creator overall if no filter is provided).\r\n */\r\n get firstCreatorMatchingFilter(): string | undefined {\r\n let matchingCreator;\r\n\r\n // If we're filtering by creator initial and have multiple creators, we want\r\n // to surface the first creator who matches the filter.\r\n if (this.creatorFilter && this.model?.creators.length) {\r\n const firstLetter = this.creatorFilter; // This is just to satisfy tsc\r\n matchingCreator = this.model.creators.find(creator =>\r\n // Decompose combining characters first, so that e.g., filtering on E matches É too.\r\n // Then remove anything that isn't strictly alphabetic, since our filters currently\r\n // only handle A-Z. The first such letter (if one exists) is what needs to match.\r\n creator\r\n .normalize('NFD')\r\n .replace(/[^A-Z]+/gi, '')\r\n .toUpperCase()\r\n .startsWith(firstLetter),\r\n );\r\n }\r\n\r\n return matchingCreator ?? this.model?.creator;\r\n }\r\n\r\n /**\r\n * The label indicating what year an account item was created.\r\n * E.g., \"Archivist since 2015\"\r\n */\r\n get accountLabel(): string {\r\n return this.model?.dateAdded\r\n ? msg(str`Archivist since ${this.model.dateAdded.getFullYear()}`)\r\n : '';\r\n }\r\n\r\n /**\r\n * The readable label for the current sort if it is a type of date sort,\r\n * or the empty string otherwise.\r\n */\r\n get dateLabel(): string {\r\n switch (this.sortParam?.field) {\r\n case 'publicdate':\r\n return msg('Archived');\r\n case 'reviewdate':\r\n return msg('Reviewed');\r\n case 'addeddate':\r\n return msg('Added');\r\n case 'date':\r\n return msg('Published');\r\n default:\r\n return '';\r\n }\r\n }\r\n\r\n /**\r\n * The readable label for the current views column, based on whether\r\n * weekly or all-time views are being shown.\r\n */\r\n get viewsLabel(): string {\r\n return this.sortParam?.field === 'week'\r\n ? msg('Weekly views')\r\n : msg('All-time views');\r\n }\r\n\r\n /**\r\n * Produces a URL pointing at the item page for the given identifier,\r\n * using the current base URL and the correct path based on whether the\r\n * item is specified to be a collection (default false).\r\n */\r\n itemPageUrl(\r\n identifier?: string,\r\n isCollection = false,\r\n ): string | typeof nothing {\r\n if (!identifier || this.baseNavigationUrl == null) return nothing;\r\n const basePath = isCollection ? this.collectionPagePath : '/details/';\r\n return `${this.baseNavigationUrl}${basePath}${identifier}`;\r\n }\r\n\r\n /**\r\n * Produces a template for a link to a single web capture of the given URL and date\r\n */\r\n webArchivesCaptureLink(url: string, date: Date): TemplateResult {\r\n // Convert the date into the format used to identify wayback captures (e.g., '20150102124550')\r\n const captureDateStr = date\r\n .toISOString()\r\n .replace(/[TZ:-]/g, '')\r\n .replace(/\\..*/, '');\r\n const captureHref = `https://web.archive.org/web/${captureDateStr}/${encodeURIComponent(\r\n url,\r\n )}`;\r\n const captureText = formatDate(date, 'long');\r\n\r\n return html` <a href=${captureHref}> ${captureText} </a> `;\r\n }\r\n}\r\n"]}
@@ -21,8 +21,8 @@ const dataPage = [
21
21
  describe('Collection Browser Data Source', () => {
22
22
  let host;
23
23
  beforeEach(async () => {
24
- host = await fixture(html `
25
- <collection-browser></collection-browser>
24
+ host = await fixture(html `
25
+ <collection-browser></collection-browser>
26
26
  `);
27
27
  });
28
28
  it('can add and retrieve data pages', () => {
@@ -1 +1 @@
1
- {"version":3,"file":"collection-browser-data-source.test.js","sourceRoot":"","sources":["../../../test/data-source/collection-browser-data-source.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,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AAK,IAAI,EAAE;YAC/E,MAAM,aAAa,GAAG,IAAI,iBAAiB,EAAE,CAAC;YAC9C,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;YACnC,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC;YAClC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC,QAAQ,CAAC;YACtC,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;YACpB,MAAM,IAAI,CAAC,cAAc,CAAC;YAE1B,MAAM,UAAU,GAAG,IAAI,2BAA2B,CAAC,IAAI,CAAC,CAAC;YACzD,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;YAC/B,MAAM,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;YAChD,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;QACpC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect, fixture } from '@open-wc/testing';\nimport { html } from 'lit';\nimport sinon from 'sinon';\nimport { ItemHit, SearchType } from '@internetarchive/search-service';\nimport { CollectionBrowserDataSource } from '../../src/data-source/collection-browser-data-source';\nimport { TileModel } from '../../src/models';\nimport type { CollectionBrowser } from '../../src/collection-browser';\nimport '../../src/collection-browser';\nimport { MockSearchService } from '../mocks/mock-search-service';\n\nconst dataPage: TileModel[] = [\n new TileModel(\n new ItemHit({\n fields: {\n identifier: 'foo',\n },\n }),\n ),\n new TileModel(\n new ItemHit({\n fields: {\n identifier: 'bar',\n },\n }),\n ),\n];\n\ndescribe('Collection Browser Data Source', () => {\n let host: CollectionBrowser;\n\n beforeEach(async () => {\n host = await fixture<CollectionBrowser>(html`\n <collection-browser></collection-browser>\n `);\n });\n\n it('can add and retrieve data pages', () => {\n const dataSource = new CollectionBrowserDataSource(host);\n dataSource.addPage(1, dataPage);\n\n expect(Object.keys(dataSource.getAllPages()).length).to.equal(1);\n expect(dataSource.getPage(1).length).to.equal(2);\n expect(dataSource.getPage(1)[0].identifier).to.equal('foo');\n expect(dataSource.getPage(1)[1].identifier).to.equal('bar');\n });\n\n it('can add data split across multiple pages', () => {\n const dataSource = new CollectionBrowserDataSource(host, 3);\n const doubledDataPage = [...dataPage, ...dataPage];\n dataSource.addMultiplePages(1, doubledDataPage);\n\n expect(Object.keys(dataSource.getAllPages()).length).to.equal(2);\n expect(dataSource.getPage(1).length).to.equal(3);\n expect(dataSource.getPage(2).length).to.equal(1);\n expect(dataSource.getPage(1)[0].identifier).to.equal('foo');\n expect(dataSource.getPage(1)[1].identifier).to.equal('bar');\n expect(dataSource.getPage(1)[2].identifier).to.equal('foo');\n expect(dataSource.getPage(2)[0].identifier).to.equal('bar');\n });\n\n it('resets data when changing page size', () => {\n const dataSource = new CollectionBrowserDataSource(host);\n dataSource.addPage(1, dataPage);\n\n dataSource.setPageSize(100);\n expect(Object.keys(dataSource.getAllPages()).length).to.equal(0);\n expect(dataSource.getPageSize()).to.equal(100);\n });\n\n it('can be installed on the host', async () => {\n const dataSource = new CollectionBrowserDataSource(host);\n dataSource.addPage(1, dataPage);\n\n host.installDataSourceAndQueryState(dataSource, {\n searchType: SearchType.METADATA,\n sortDirection: null,\n selectedTitleFilter: null,\n selectedCreatorFilter: null,\n baseQuery: 'foobar',\n });\n\n await host.updateComplete;\n\n expect(host.dataSource).to.equal(dataSource);\n expect(host.baseQuery).to.equal('foobar');\n\n host.removeController(dataSource);\n });\n\n it('can suppress further fetches', async () => {\n host.searchService = new MockSearchService();\n\n const pageFetchSpy = sinon.spy();\n const dataSource = new CollectionBrowserDataSource(host);\n dataSource.fetchPage = pageFetchSpy;\n\n dataSource.addPage(1, dataPage);\n dataSource.setFetchesSuppressed(true);\n dataSource.handleQueryChange();\n\n expect(pageFetchSpy.callCount).to.equal(0);\n });\n\n it('can set its initial page batch size', async () => {\n host.searchService = new MockSearchService();\n\n const pageFetchSpy = sinon.spy();\n const dataSource = new CollectionBrowserDataSource(host);\n dataSource.setNumInitialPages(10);\n dataSource.fetchPage = pageFetchSpy;\n\n dataSource.handleQueryChange();\n\n // Uses specified number of initial pages\n expect(pageFetchSpy.args[0][1]).to.equal(10);\n });\n\n it('refreshes prefix filter counts', () => {\n const dataSource = new CollectionBrowserDataSource(host);\n dataSource.addPage(1, dataPage);\n\n dataSource.prefixFilterCountMap = {\n title: {\n X: 10,\n },\n };\n\n dataSource.refreshLetterCounts();\n expect(dataSource.prefixFilterCountMap).to.deep.equal({});\n });\n\n describe('empty FTS query in collection falls back to metadata search', () => {\n it('allows search with empty query and FTS in a collection', async () => {\n const searchService = new MockSearchService();\n host.searchService = searchService;\n host.withinCollection = 'test-collection';\n host.searchType = SearchType.FULLTEXT;\n host.baseQuery = '';\n await host.updateComplete;\n\n const dataSource = new CollectionBrowserDataSource(host);\n host.addController(dataSource);\n expect(dataSource.canPerformSearch).to.be.true;\n host.removeController(dataSource);\n });\n\n it('uses metadata search type for fetch when FTS query is empty in a collection', async () => {\n const searchService = new MockSearchService();\n host.searchService = searchService;\n host.withinCollection = 'test-collection';\n host.searchType = SearchType.FULLTEXT;\n host.baseQuery = '';\n await host.updateComplete;\n\n const dataSource = new CollectionBrowserDataSource(host);\n host.addController(dataSource);\n await dataSource.fetchPage(1);\n\n expect(searchService.searchType).to.equal(SearchType.METADATA);\n host.removeController(dataSource);\n });\n\n it('uses FTS search type for fetch when FTS query is non-empty in a collection', async () => {\n const searchService = new MockSearchService();\n host.searchService = searchService;\n host.withinCollection = 'test-collection';\n host.searchType = SearchType.FULLTEXT;\n host.baseQuery = 'some query';\n await host.updateComplete;\n\n const dataSource = new CollectionBrowserDataSource(host);\n host.addController(dataSource);\n await dataSource.fetchPage(1);\n\n expect(searchService.searchType).to.equal(SearchType.FULLTEXT);\n host.removeController(dataSource);\n });\n\n it('does not allow search with empty FTS query outside a collection', async () => {\n const searchService = new MockSearchService();\n host.searchService = searchService;\n host.withinCollection = undefined;\n host.searchType = SearchType.FULLTEXT;\n host.baseQuery = '';\n await host.updateComplete;\n\n const dataSource = new CollectionBrowserDataSource(host);\n host.addController(dataSource);\n expect(dataSource.canPerformSearch).to.be.false;\n host.removeController(dataSource);\n });\n });\n});\n"]}
1
+ {"version":3,"file":"collection-browser-data-source.test.js","sourceRoot":"","sources":["../../../test/data-source/collection-browser-data-source.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC3B,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,2BAA2B,EAAE,MAAM,sDAAsD,CAAC;AACnG,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,OAAO,8BAA8B,CAAC;AACtC,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AAEjE,MAAM,QAAQ,GAAgB;IAC5B,IAAI,SAAS,CACX,IAAI,OAAO,CAAC;QACV,MAAM,EAAE;YACN,UAAU,EAAE,KAAK;SAClB;KACF,CAAC,CACH;IACD,IAAI,SAAS,CACX,IAAI,OAAO,CAAC;QACV,MAAM,EAAE;YACN,UAAU,EAAE,KAAK;SAClB;KACF,CAAC,CACH;CACF,CAAC;AAEF,QAAQ,CAAC,gCAAgC,EAAE,GAAG,EAAE;IAC9C,IAAI,IAAuB,CAAC;IAE5B,UAAU,CAAC,KAAK,IAAI,EAAE;QACpB,IAAI,GAAG,MAAM,OAAO,CAAoB,IAAI,CAAA;;KAE3C,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE;QACzC,MAAM,UAAU,GAAG,IAAI,2BAA2B,CAAC,IAAI,CAAC,CAAC;QACzD,UAAU,CAAC,OAAO,CAAC,CAAC,EAAE,QAAQ,CAAC,C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I,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;YAC/B,MAAM,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;YAE9B,MAAM,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;YAC/D,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;QACpC,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,iEAAiE,EAAE,KAAK,IAAI,EAAE;YAC/E,MAAM,aAAa,GAAG,IAAI,iBAAiB,EAAE,CAAC;YAC9C,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;YACnC,IAAI,CAAC,gBAAgB,GAAG,SAAS,CAAC;YAClC,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC,QAAQ,CAAC;YACtC,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;YACpB,MAAM,IAAI,CAAC,cAAc,CAAC;YAE1B,MAAM,UAAU,GAAG,IAAI,2BAA2B,CAAC,IAAI,CAAC,CAAC;YACzD,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;YAC/B,MAAM,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC;YAChD,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;QACpC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect, fixture } from '@open-wc/testing';\r\nimport { html } from 'lit';\r\nimport sinon from 'sinon';\r\nimport { ItemHit, SearchType } from '@internetarchive/search-service';\r\nimport { CollectionBrowserDataSource } from '../../src/data-source/collection-browser-data-source';\r\nimport { TileModel } from '../../src/models';\r\nimport type { CollectionBrowser } from '../../src/collection-browser';\r\nimport '../../src/collection-browser';\r\nimport { MockSearchService } from '../mocks/mock-search-service';\r\n\r\nconst dataPage: TileModel[] = [\r\n new TileModel(\r\n new ItemHit({\r\n fields: {\r\n identifier: 'foo',\r\n },\r\n }),\r\n ),\r\n new TileModel(\r\n new ItemHit({\r\n fields: {\r\n identifier: 'bar',\r\n },\r\n }),\r\n ),\r\n];\r\n\r\ndescribe('Collection Browser Data Source', () => {\r\n let host: CollectionBrowser;\r\n\r\n beforeEach(async () => {\r\n host = await fixture<CollectionBrowser>(html`\r\n <collection-browser></collection-browser>\r\n `);\r\n });\r\n\r\n it('can add and retrieve data pages', () => {\r\n const dataSource = new CollectionBrowserDataSource(host);\r\n dataSource.addPage(1, dataPage);\r\n\r\n expect(Object.keys(dataSource.getAllPages()).length).to.equal(1);\r\n expect(dataSource.getPage(1).length).to.equal(2);\r\n expect(dataSource.getPage(1)[0].identifier).to.equal('foo');\r\n expect(dataSource.getPage(1)[1].identifier).to.equal('bar');\r\n });\r\n\r\n it('can add data split across multiple pages', () => {\r\n const dataSource = new CollectionBrowserDataSource(host, 3);\r\n const doubledDataPage = [...dataPage, ...dataPage];\r\n dataSource.addMultiplePages(1, doubledDataPage);\r\n\r\n expect(Object.keys(dataSource.getAllPages()).length).to.equal(2);\r\n expect(dataSource.getPage(1).length).to.equal(3);\r\n expect(dataSource.getPage(2).length).to.equal(1);\r\n expect(dataSource.getPage(1)[0].identifier).to.equal('foo');\r\n expect(dataSource.getPage(1)[1].identifier).to.equal('bar');\r\n expect(dataSource.getPage(1)[2].identifier).to.equal('foo');\r\n expect(dataSource.getPage(2)[0].identifier).to.equal('bar');\r\n });\r\n\r\n it('resets data when changing page size', () => {\r\n const dataSource = new CollectionBrowserDataSource(host);\r\n dataSource.addPage(1, dataPage);\r\n\r\n dataSource.setPageSize(100);\r\n expect(Object.keys(dataSource.getAllPages()).length).to.equal(0);\r\n expect(dataSource.getPageSize()).to.equal(100);\r\n });\r\n\r\n it('can be installed on the host', async () => {\r\n const dataSource = new CollectionBrowserDataSource(host);\r\n dataSource.addPage(1, dataPage);\r\n\r\n host.installDataSourceAndQueryState(dataSource, {\r\n searchType: SearchType.METADATA,\r\n sortDirection: null,\r\n selectedTitleFilter: null,\r\n selectedCreatorFilter: null,\r\n baseQuery: 'foobar',\r\n });\r\n\r\n await host.updateComplete;\r\n\r\n expect(host.dataSource).to.equal(dataSource);\r\n expect(host.baseQuery).to.equal('foobar');\r\n\r\n host.removeController(dataSource);\r\n });\r\n\r\n it('can suppress further fetches', async () => {\r\n host.searchService = new MockSearchService();\r\n\r\n const pageFetchSpy = sinon.spy();\r\n const dataSource = new CollectionBrowserDataSource(host);\r\n dataSource.fetchPage = pageFetchSpy;\r\n\r\n dataSource.addPage(1, dataPage);\r\n dataSource.setFetchesSuppressed(true);\r\n dataSource.handleQueryChange();\r\n\r\n expect(pageFetchSpy.callCount).to.equal(0);\r\n });\r\n\r\n it('can set its initial page batch size', async () => {\r\n host.searchService = new MockSearchService();\r\n\r\n const pageFetchSpy = sinon.spy();\r\n const dataSource = new CollectionBrowserDataSource(host);\r\n dataSource.setNumInitialPages(10);\r\n dataSource.fetchPage = pageFetchSpy;\r\n\r\n dataSource.handleQueryChange();\r\n\r\n // Uses specified number of initial pages\r\n expect(pageFetchSpy.args[0][1]).to.equal(10);\r\n });\r\n\r\n it('refreshes prefix filter counts', () => {\r\n const dataSource = new CollectionBrowserDataSource(host);\r\n dataSource.addPage(1, dataPage);\r\n\r\n dataSource.prefixFilterCountMap = {\r\n title: {\r\n X: 10,\r\n },\r\n };\r\n\r\n dataSource.refreshLetterCounts();\r\n expect(dataSource.prefixFilterCountMap).to.deep.equal({});\r\n });\r\n\r\n describe('empty FTS query in collection falls back to metadata search', () => {\r\n it('allows search with empty query and FTS in a collection', async () => {\r\n const searchService = new MockSearchService();\r\n host.searchService = searchService;\r\n host.withinCollection = 'test-collection';\r\n host.searchType = SearchType.FULLTEXT;\r\n host.baseQuery = '';\r\n await host.updateComplete;\r\n\r\n const dataSource = new CollectionBrowserDataSource(host);\r\n host.addController(dataSource);\r\n expect(dataSource.canPerformSearch).to.be.true;\r\n host.removeController(dataSource);\r\n });\r\n\r\n it('uses metadata search type for fetch when FTS query is empty in a collection', async () => {\r\n const searchService = new MockSearchService();\r\n host.searchService = searchService;\r\n host.withinCollection = 'test-collection';\r\n host.searchType = SearchType.FULLTEXT;\r\n host.baseQuery = '';\r\n await host.updateComplete;\r\n\r\n const dataSource = new CollectionBrowserDataSource(host);\r\n host.addController(dataSource);\r\n await dataSource.fetchPage(1);\r\n\r\n expect(searchService.searchType).to.equal(SearchType.METADATA);\r\n host.removeController(dataSource);\r\n });\r\n\r\n it('uses FTS search type for fetch when FTS query is non-empty in a collection', async () => {\r\n const searchService = new MockSearchService();\r\n host.searchService = searchService;\r\n host.withinCollection = 'test-collection';\r\n host.searchType = SearchType.FULLTEXT;\r\n host.baseQuery = 'some query';\r\n await host.updateComplete;\r\n\r\n const dataSource = new CollectionBrowserDataSource(host);\r\n host.addController(dataSource);\r\n await dataSource.fetchPage(1);\r\n\r\n expect(searchService.searchType).to.equal(SearchType.FULLTEXT);\r\n host.removeController(dataSource);\r\n });\r\n\r\n it('does not allow search with empty FTS query outside a collection', async () => {\r\n const searchService = new MockSearchService();\r\n host.searchService = searchService;\r\n host.withinCollection = undefined;\r\n host.searchType = SearchType.FULLTEXT;\r\n host.baseQuery = '';\r\n await host.updateComplete;\r\n\r\n const dataSource = new CollectionBrowserDataSource(host);\r\n host.addController(dataSource);\r\n expect(dataSource.canPerformSearch).to.be.false;\r\n host.removeController(dataSource);\r\n });\r\n });\r\n});\r\n"]}
@@ -0,0 +1 @@
1
+ import '../../../src/tiles/list/tile-list-compact-header';
@@ -0,0 +1,36 @@
1
+ import { expect, fixture } from '@open-wc/testing';
2
+ import { html } from 'lit';
3
+ import '../../../src/tiles/list/tile-list-compact-header';
4
+ describe('List Tile Compact Header', () => {
5
+ it('should render Weekly views header when sorting by week', async () => {
6
+ const el = await fixture(html `
7
+ <tile-list-compact-header
8
+ .sortParam=${{ field: 'week', direction: 'desc' }}
9
+ >
10
+ </tile-list-compact-header>
11
+ `);
12
+ const viewsColumn = el.shadowRoot?.getElementById('views');
13
+ expect(viewsColumn).to.exist;
14
+ expect(viewsColumn?.textContent?.trim()).to.equal('Weekly views');
15
+ });
16
+ it('should render All-time views header when sorting by non-week field', async () => {
17
+ const el = await fixture(html `
18
+ <tile-list-compact-header
19
+ .sortParam=${{ field: 'downloads', direction: 'desc' }}
20
+ >
21
+ </tile-list-compact-header>
22
+ `);
23
+ const viewsColumn = el.shadowRoot?.getElementById('views');
24
+ expect(viewsColumn).to.exist;
25
+ expect(viewsColumn?.textContent?.trim()).to.equal('All-time views');
26
+ });
27
+ it('should render All-time views header with no sort param', async () => {
28
+ const el = await fixture(html `
29
+ <tile-list-compact-header> </tile-list-compact-header>
30
+ `);
31
+ const viewsColumn = el.shadowRoot?.getElementById('views');
32
+ expect(viewsColumn).to.exist;
33
+ expect(viewsColumn?.textContent?.trim()).to.equal('All-time views');
34
+ });
35
+ });
36
+ //# sourceMappingURL=tile-list-compact-header.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tile-list-compact-header.test.js","sourceRoot":"","sources":["../../../../test/tiles/list/tile-list-compact-header.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAG3B,OAAO,kDAAkD,CAAC;AAE1D,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACxC,EAAE,CAAC,wDAAwD,EAAE,KAAK,IAAI,EAAE;QACtE,MAAM,EAAE,GAAG,MAAM,OAAO,CAAwB,IAAI,CAAA;;qBAEnC,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE;;;KAGpD,CAAC,CAAC;QAEH,MAAM,WAAW,GAAG,EAAE,CAAC,UAAU,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC;QAC3D,MAAM,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QAC7B,MAAM,CAAC,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oEAAoE,EAAE,KAAK,IAAI,EAAE;QAClF,MAAM,EAAE,GAAG,MAAM,OAAO,CAAwB,IAAI,CAAA;;qBAEnC,EAAE,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE;;;KAGzD,CAAC,CAAC;QAEH,MAAM,WAAW,GAAG,EAAE,CAAC,UAAU,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC;QAC3D,MAAM,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QAC7B,MAAM,CAAC,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,wDAAwD,EAAE,KAAK,IAAI,EAAE;QACtE,MAAM,EAAE,GAAG,MAAM,OAAO,CAAwB,IAAI,CAAA;;KAEnD,CAAC,CAAC;QAEH,MAAM,WAAW,GAAG,EAAE,CAAC,UAAU,EAAE,cAAc,CAAC,OAAO,CAAC,CAAC;QAC3D,MAAM,CAAC,WAAW,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC;QAC7B,MAAM,CAAC,WAAW,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { expect, fixture } from '@open-wc/testing';\r\nimport { html } from 'lit';\r\nimport type { TileListCompactHeader } from '../../../src/tiles/list/tile-list-compact-header';\r\n\r\nimport '../../../src/tiles/list/tile-list-compact-header';\r\n\r\ndescribe('List Tile Compact Header', () => {\r\n it('should render Weekly views header when sorting by week', async () => {\r\n const el = await fixture<TileListCompactHeader>(html`\r\n <tile-list-compact-header\r\n .sortParam=${{ field: 'week', direction: 'desc' }}\r\n >\r\n </tile-list-compact-header>\r\n `);\r\n\r\n const viewsColumn = el.shadowRoot?.getElementById('views');\r\n expect(viewsColumn).to.exist;\r\n expect(viewsColumn?.textContent?.trim()).to.equal('Weekly views');\r\n });\r\n\r\n it('should render All-time views header when sorting by non-week field', async () => {\r\n const el = await fixture<TileListCompactHeader>(html`\r\n <tile-list-compact-header\r\n .sortParam=${{ field: 'downloads', direction: 'desc' }}\r\n >\r\n </tile-list-compact-header>\r\n `);\r\n\r\n const viewsColumn = el.shadowRoot?.getElementById('views');\r\n expect(viewsColumn).to.exist;\r\n expect(viewsColumn?.textContent?.trim()).to.equal('All-time views');\r\n });\r\n\r\n it('should render All-time views header with no sort param', async () => {\r\n const el = await fixture<TileListCompactHeader>(html`\r\n <tile-list-compact-header> </tile-list-compact-header>\r\n `);\r\n\r\n const viewsColumn = el.shadowRoot?.getElementById('views');\r\n expect(viewsColumn).to.exist;\r\n expect(viewsColumn?.textContent?.trim()).to.equal('All-time views');\r\n });\r\n});\r\n"]}