@internetarchive/collection-browser 1.5.0 → 1.5.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.
Files changed (67) hide show
  1. package/dist/src/collection-browser.js +3 -1
  2. package/dist/src/collection-browser.js.map +1 -1
  3. package/dist/src/styles/item-image-styles.js +13 -13
  4. package/dist/src/styles/item-image-styles.js.map +1 -1
  5. package/dist/src/tiles/base-tile-component.d.ts +18 -0
  6. package/dist/src/tiles/base-tile-component.js +60 -0
  7. package/dist/src/tiles/base-tile-component.js.map +1 -0
  8. package/dist/src/tiles/grid/account-tile.d.ts +3 -5
  9. package/dist/src/tiles/grid/account-tile.js +19 -11
  10. package/dist/src/tiles/grid/account-tile.js.map +1 -1
  11. package/dist/src/tiles/grid/collection-tile.d.ts +3 -5
  12. package/dist/src/tiles/grid/collection-tile.js +18 -9
  13. package/dist/src/tiles/grid/collection-tile.js.map +1 -1
  14. package/dist/src/tiles/grid/item-tile.d.ts +4 -9
  15. package/dist/src/tiles/grid/item-tile.js +24 -22
  16. package/dist/src/tiles/grid/item-tile.js.map +1 -1
  17. package/dist/src/tiles/list/tile-list-compact-header.d.ts +2 -8
  18. package/dist/src/tiles/list/tile-list-compact-header.js +23 -26
  19. package/dist/src/tiles/list/tile-list-compact-header.js.map +1 -1
  20. package/dist/src/tiles/list/tile-list-compact.d.ts +4 -13
  21. package/dist/src/tiles/list/tile-list-compact.js +34 -48
  22. package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
  23. package/dist/src/tiles/list/tile-list.d.ts +3 -13
  24. package/dist/src/tiles/list/tile-list.js +36 -60
  25. package/dist/src/tiles/list/tile-list.js.map +1 -1
  26. package/dist/src/tiles/tile-dispatcher.d.ts +4 -13
  27. package/dist/src/tiles/tile-dispatcher.js +28 -38
  28. package/dist/src/tiles/tile-dispatcher.js.map +1 -1
  29. package/dist/src/tiles/tile-display-value-provider.d.ts +43 -0
  30. package/dist/src/tiles/tile-display-value-provider.js +81 -0
  31. package/dist/src/tiles/tile-display-value-provider.js.map +1 -0
  32. package/dist/test/collection-browser.test.js +1 -1
  33. package/dist/test/collection-browser.test.js.map +1 -1
  34. package/dist/test/tiles/grid/item-tile.test.js +13 -0
  35. package/dist/test/tiles/grid/item-tile.test.js.map +1 -1
  36. package/dist/test/tiles/list/tile-list-compact.test.js +14 -0
  37. package/dist/test/tiles/list/tile-list-compact.test.js.map +1 -1
  38. package/dist/test/tiles/list/tile-list.test.js +4 -2
  39. package/dist/test/tiles/list/tile-list.test.js.map +1 -1
  40. package/dist/test/tiles/tile-display-value-provider.test.d.ts +1 -0
  41. package/dist/test/tiles/tile-display-value-provider.test.js +142 -0
  42. package/dist/test/tiles/tile-display-value-provider.test.js.map +1 -0
  43. package/package.json +1 -1
  44. package/src/collection-browser.ts +3 -1
  45. package/src/styles/item-image-styles.ts +13 -13
  46. package/src/tiles/base-tile-component.ts +48 -0
  47. package/src/tiles/grid/account-tile.ts +19 -8
  48. package/src/tiles/grid/collection-tile.ts +18 -14
  49. package/src/tiles/grid/item-tile.ts +25 -24
  50. package/src/tiles/list/tile-list-compact-header.ts +23 -18
  51. package/src/tiles/list/tile-list-compact.ts +34 -29
  52. package/src/tiles/list/tile-list.ts +47 -61
  53. package/src/tiles/tile-dispatcher.ts +34 -27
  54. package/src/tiles/tile-display-value-provider.ts +106 -0
  55. package/test/collection-browser.test.ts +1 -1
  56. package/test/tiles/grid/item-tile.test.ts +15 -0
  57. package/test/tiles/list/tile-list-compact.test.ts +16 -0
  58. package/test/tiles/list/tile-list.test.ts +4 -2
  59. package/test/tiles/tile-display-value-provider.test.ts +172 -0
  60. package/dist/src/tiles/list/account-label.d.ts +0 -1
  61. package/dist/src/tiles/list/account-label.js +0 -7
  62. package/dist/src/tiles/list/account-label.js.map +0 -1
  63. package/dist/src/tiles/list/date-label.d.ts +0 -1
  64. package/dist/src/tiles/list/date-label.js +0 -13
  65. package/dist/src/tiles/list/date-label.js.map +0 -1
  66. package/src/tiles/list/account-label.ts +0 -6
  67. package/src/tiles/list/date-label.ts +0 -12
@@ -1,22 +1,31 @@
1
1
  import { __decorate } from "tslib";
2
- import { css, html, LitElement } from 'lit';
3
- import { customElement, property } from 'lit/decorators.js';
4
- import { dateLabel } from './date-label';
5
- let TileListCompactHeader = class TileListCompactHeader extends LitElement {
6
- constructor() {
7
- super(...arguments);
8
- this.sortParam = null;
9
- }
2
+ import { css, html } from 'lit';
3
+ import { customElement } from 'lit/decorators.js';
4
+ import { msg } from '@lit/localize';
5
+ import { BaseTileComponent } from '../base-tile-component';
6
+ let TileListCompactHeader = class TileListCompactHeader extends BaseTileComponent {
7
+ /*
8
+ * Reactive properties inherited from BaseTileComponent:
9
+ * - model?: TileModel;
10
+ * - currentWidth?: number;
11
+ * - currentHeight?: number;
12
+ * - baseNavigationUrl?: string;
13
+ * - baseImageUrl?: string;
14
+ * - collectionPagePath?: string;
15
+ * - sortParam: SortParam | null = null;
16
+ * - creatorFilter?: string;
17
+ * - mobileBreakpoint?: number;
18
+ * - loggedIn = false;
19
+ */
10
20
  render() {
11
- var _a;
12
21
  return html `
13
22
  <div id="list-line-header" class="${this.classSize}">
14
23
  <div id="thumb"></div>
15
- <div id="title">Title</div>
16
- <div id="creator">Creator</div>
17
- <div id="date">${dateLabel((_a = this.sortParam) === null || _a === void 0 ? void 0 : _a.field)}</div>
18
- <div id="icon">Type</div>
19
- <div id="views">Views</div>
24
+ <div id="title">${msg('Title')}</div>
25
+ <div id="creator">${msg('Creator')}</div>
26
+ <div id="date">${this.displayValueProvider.dateLabel}</div>
27
+ <div id="icon">${msg('Type')}</div>
28
+ <div id="views">${msg('Views')}</div>
20
29
  </div>
21
30
  `;
22
31
  }
@@ -66,18 +75,6 @@ let TileListCompactHeader = class TileListCompactHeader extends LitElement {
66
75
  `;
67
76
  }
68
77
  };
69
- __decorate([
70
- property({ type: Object })
71
- ], TileListCompactHeader.prototype, "model", void 0);
72
- __decorate([
73
- property({ type: Number })
74
- ], TileListCompactHeader.prototype, "currentWidth", void 0);
75
- __decorate([
76
- property({ type: Object })
77
- ], TileListCompactHeader.prototype, "sortParam", void 0);
78
- __decorate([
79
- property({ type: Number })
80
- ], TileListCompactHeader.prototype, "mobileBreakpoint", void 0);
81
78
  TileListCompactHeader = __decorate([
82
79
  customElement('tile-list-compact-header')
83
80
  ], TileListCompactHeader);
@@ -1 +1 @@
1
- {"version":3,"file":"tile-list-compact-header.js","sourceRoot":"","sources":["../../../../src/tiles/list/tile-list-compact-header.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAE5D,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAIzC,IAAa,qBAAqB,GAAlC,MAAa,qBAAsB,SAAQ,UAAU;IAArD;;QAK8B,cAAS,GAAqB,IAAI,CAAC;IAiEjE,CAAC;IA7DC,MAAM;;QACJ,OAAO,IAAI,CAAA;0CAC2B,IAAI,CAAC,SAAS;;;;yBAI/B,SAAS,CAAC,MAAA,IAAI,CAAC,SAAS,0CAAE,KAAK,CAAC;;;;KAIpD,CAAC;IACJ,CAAC;IAED,IAAY,SAAS;QACnB,IACE,IAAI,CAAC,gBAAgB;YACrB,IAAI,CAAC,YAAY;YACjB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,gBAAgB,EACzC;YACA,OAAO,QAAQ,CAAC;SACjB;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAkCT,CAAC;IACJ,CAAC;CACF,CAAA;AArE6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oDAAmB;AAElB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2DAAuB;AAEtB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;wDAAoC;AAEnC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;+DAA2B;AAP3C,qBAAqB;IADjC,aAAa,CAAC,0BAA0B,CAAC;GAC7B,qBAAqB,CAsEjC;SAtEY,qBAAqB","sourcesContent":["import { css, html, LitElement } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport type { SortParam } from '@internetarchive/search-service';\nimport { dateLabel } from './date-label';\nimport type { TileModel } from '../../models';\n\n@customElement('tile-list-compact-header')\nexport class TileListCompactHeader extends LitElement {\n @property({ type: Object }) model?: TileModel;\n\n @property({ type: Number }) currentWidth?: number;\n\n @property({ type: Object }) sortParam: SortParam | null = null;\n\n @property({ type: Number }) mobileBreakpoint?: number;\n\n render() {\n return html`\n <div id=\"list-line-header\" class=\"${this.classSize}\">\n <div id=\"thumb\"></div>\n <div id=\"title\">Title</div>\n <div id=\"creator\">Creator</div>\n <div id=\"date\">${dateLabel(this.sortParam?.field)}</div>\n <div id=\"icon\">Type</div>\n <div id=\"views\">Views</div>\n </div>\n `;\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 static get styles() {\n return css`\n html {\n font-size: unset;\n }\n\n div {\n font-size: 14px;\n font-weight: bold;\n line-height: 20px;\n }\n\n .mobile #views {\n display: none;\n }\n\n #views {\n text-align: right;\n padding-right: 8px;\n }\n\n #list-line-header {\n display: grid;\n column-gap: 10px;\n align-items: flex-end;\n padding-bottom: 2px;\n }\n\n #list-line-header.mobile {\n grid-template-columns: 36px 3fr 2fr 68px 35px;\n }\n\n #list-line-header.desktop {\n grid-template-columns: 51px 3fr 2fr 95px 30px 60px;\n }\n `;\n }\n}\n"]}
1
+ {"version":3,"file":"tile-list-compact-header.js","sourceRoot":"","sources":["../../../../src/tiles/list/tile-list-compact-header.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAG3D,IAAa,qBAAqB,GAAlC,MAAa,qBAAsB,SAAQ,iBAAiB;IAC1D;;;;;;;;;;;;OAYG;IAEH,MAAM;QACJ,OAAO,IAAI,CAAA;0CAC2B,IAAI,CAAC,SAAS;;0BAE9B,GAAG,CAAC,OAAO,CAAC;4BACV,GAAG,CAAC,SAAS,CAAC;yBACjB,IAAI,CAAC,oBAAoB,CAAC,SAAS;yBACnC,GAAG,CAAC,MAAM,CAAC;0BACV,GAAG,CAAC,OAAO,CAAC;;KAEjC,CAAC;IACJ,CAAC;IAED,IAAY,SAAS;QACnB,IACE,IAAI,CAAC,gBAAgB;YACrB,IAAI,CAAC,YAAY;YACjB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,gBAAgB,EACzC;YACA,OAAO,QAAQ,CAAC;SACjB;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAkCT,CAAC;IACJ,CAAC;CACF,CAAA;AA5EY,qBAAqB;IADjC,aAAa,CAAC,0BAA0B,CAAC;GAC7B,qBAAqB,CA4EjC;SA5EY,qBAAqB","sourcesContent":["import { css, html } from 'lit';\nimport { customElement } from 'lit/decorators.js';\nimport { msg } from '@lit/localize';\nimport { BaseTileComponent } from '../base-tile-component';\n\n@customElement('tile-list-compact-header')\nexport class TileListCompactHeader 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 * - creatorFilter?: string;\n * - mobileBreakpoint?: number;\n * - loggedIn = false;\n */\n\n render() {\n return html`\n <div id=\"list-line-header\" class=\"${this.classSize}\">\n <div id=\"thumb\"></div>\n <div id=\"title\">${msg('Title')}</div>\n <div id=\"creator\">${msg('Creator')}</div>\n <div id=\"date\">${this.displayValueProvider.dateLabel}</div>\n <div id=\"icon\">${msg('Type')}</div>\n <div id=\"views\">${msg('Views')}</div>\n </div>\n `;\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 static get styles() {\n return css`\n html {\n font-size: unset;\n }\n\n div {\n font-size: 14px;\n font-weight: bold;\n line-height: 20px;\n }\n\n .mobile #views {\n display: none;\n }\n\n #views {\n text-align: right;\n padding-right: 8px;\n }\n\n #list-line-header {\n display: grid;\n column-gap: 10px;\n align-items: flex-end;\n padding-bottom: 2px;\n }\n\n #list-line-header.mobile {\n grid-template-columns: 36px 3fr 2fr 68px 35px;\n }\n\n #list-line-header.desktop {\n grid-template-columns: 51px 3fr 2fr 95px 30px 60px;\n }\n `;\n }\n}\n"]}
@@ -1,24 +1,15 @@
1
- import { LitElement } from 'lit';
2
- import type { SortParam } from '@internetarchive/search-service';
3
- import type { TileModel } from '../../models';
1
+ import { BaseTileComponent } from '../base-tile-component';
4
2
  import '../image-block';
5
3
  import '../mediatype-icon';
6
- export declare class TileListCompact extends LitElement {
7
- model?: TileModel;
8
- baseNavigationUrl?: string;
9
- currentWidth?: number;
10
- currentHeight?: number;
11
- sortParam: SortParam | null;
12
- mobileBreakpoint?: number;
13
- baseImageUrl?: string;
14
- loggedIn: boolean;
15
- collectionPagePath: string;
4
+ export declare class TileListCompact extends BaseTileComponent {
16
5
  render(): import("lit-html").TemplateResult<1>;
17
6
  private get href();
7
+ private get creator();
18
8
  private get date();
19
9
  private get views();
20
10
  private get classSize();
21
11
  private get dateFormatSize();
22
12
  private get formatSize();
13
+ private get isSortedByDate();
23
14
  static get styles(): import("lit").CSSResult;
24
15
  }
@@ -1,22 +1,29 @@
1
1
  import { __decorate } from "tslib";
2
- import { css, html, LitElement, nothing } from 'lit';
3
- import { customElement, property } from 'lit/decorators.js';
2
+ import { css, html, nothing } from 'lit';
3
+ import { customElement } from 'lit/decorators.js';
4
4
  import DOMPurify from 'dompurify';
5
+ import { BaseTileComponent } from '../base-tile-component';
5
6
  import { formatCount } from '../../utils/format-count';
6
7
  import { formatDate } from '../../utils/format-date';
7
8
  import { isFirstMillisecondOfUTCYear } from '../../utils/local-date-from-utc';
8
- import { accountLabel } from './account-label';
9
9
  import '../image-block';
10
10
  import '../mediatype-icon';
11
- let TileListCompact = class TileListCompact extends LitElement {
12
- constructor() {
13
- super(...arguments);
14
- this.sortParam = null;
15
- this.loggedIn = false;
16
- this.collectionPagePath = '/details/';
17
- }
11
+ let TileListCompact = class TileListCompact extends BaseTileComponent {
12
+ /*
13
+ * Reactive properties inherited from BaseTileComponent:
14
+ * - model?: TileModel;
15
+ * - currentWidth?: number;
16
+ * - currentHeight?: number;
17
+ * - baseNavigationUrl?: string;
18
+ * - baseImageUrl?: string;
19
+ * - collectionPagePath?: string;
20
+ * - sortParam: SortParam | null = null;
21
+ * - creatorFilter?: string;
22
+ * - mobileBreakpoint?: number;
23
+ * - loggedIn = false;
24
+ */
18
25
  render() {
19
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
26
+ var _a, _b, _c, _d, _e, _f;
20
27
  return html `
21
28
  <div id="list-line" class="${this.classSize}">
22
29
  <image-block
@@ -33,23 +40,23 @@ let TileListCompact = class TileListCompact extends LitElement {
33
40
  >
34
41
  <div id="creator">
35
42
  ${((_c = this.model) === null || _c === void 0 ? void 0 : _c.mediatype) === 'account'
36
- ? accountLabel((_d = this.model) === null || _d === void 0 ? void 0 : _d.dateAdded)
37
- : DOMPurify.sanitize((_f = (_e = this.model) === null || _e === void 0 ? void 0 : _e.creator) !== null && _f !== void 0 ? _f : '')}
43
+ ? this.displayValueProvider.accountLabel
44
+ : this.creator}
38
45
  </div>
39
46
  <div id="date">${formatDate(this.date, this.dateFormatSize)}</div>
40
47
  <div id="icon">
41
48
  <mediatype-icon
42
- .mediatype=${(_g = this.model) === null || _g === void 0 ? void 0 : _g.mediatype}
43
- .collections=${(_h = this.model) === null || _h === void 0 ? void 0 : _h.collections}
49
+ .mediatype=${(_d = this.model) === null || _d === void 0 ? void 0 : _d.mediatype}
50
+ .collections=${(_e = this.model) === null || _e === void 0 ? void 0 : _e.collections}
44
51
  >
45
52
  </mediatype-icon>
46
53
  </div>
47
- <div id="views">${formatCount((_j = this.views) !== null && _j !== void 0 ? _j : 0, this.formatSize)}</div>
54
+ <div id="views">${formatCount((_f = this.views) !== null && _f !== void 0 ? _f : 0, this.formatSize)}</div>
48
55
  </div>
49
56
  `;
50
57
  }
51
58
  get href() {
52
- var _a, _b;
59
+ var _a;
53
60
  if (!((_a = this.model) === null || _a === void 0 ? void 0 : _a.identifier) || this.baseNavigationUrl == null)
54
61
  return nothing;
55
62
  // Use the server-specified href if available.
@@ -57,9 +64,11 @@ let TileListCompact = class TileListCompact extends LitElement {
57
64
  if (this.model.href) {
58
65
  return `${this.baseNavigationUrl}${this.model.href}`;
59
66
  }
60
- const isCollection = ((_b = this.model) === null || _b === void 0 ? void 0 : _b.mediatype) === 'collection';
61
- const basePath = isCollection ? this.collectionPagePath : '/details/';
62
- return `${this.baseNavigationUrl}${basePath}${this.model.identifier}`;
67
+ return this.displayValueProvider.itemPageUrl(this.model.identifier, this.model.mediatype === 'collection');
68
+ }
69
+ get creator() {
70
+ var _a;
71
+ return (_a = this.displayValueProvider.firstCreatorMatchingFilter) !== null && _a !== void 0 ? _a : nothing;
63
72
  }
64
73
  /*
65
74
  * TODO: fix field names to match model in src/collection-browser.ts
@@ -104,7 +113,7 @@ let TileListCompact = class TileListCompact extends LitElement {
104
113
  // If we're showing a date published of Jan 1 at midnight, only show the year.
105
114
  // This is because items with only a year for their publication date are normalized to
106
115
  // Jan 1 at midnight timestamps in the search engine documents.
107
- if ((!((_a = this.sortParam) === null || _a === void 0 ? void 0 : _a.field) || this.sortParam.field === 'date') && // No sort or date published
116
+ if ((!this.isSortedByDate || ((_a = this.sortParam) === null || _a === void 0 ? void 0 : _a.field) === 'date') && // Any sort except dates that aren't published date
108
117
  isFirstMillisecondOfUTCYear((_b = this.model) === null || _b === void 0 ? void 0 : _b.datePublished)) {
109
118
  return 'year-only';
110
119
  }
@@ -118,6 +127,10 @@ let TileListCompact = class TileListCompact extends LitElement {
118
127
  }
119
128
  return 'long';
120
129
  }
130
+ get isSortedByDate() {
131
+ var _a;
132
+ return ['date', 'reviewdate', 'addeddate', 'publicdate'].includes((_a = this.sortParam) === null || _a === void 0 ? void 0 : _a.field);
133
+ }
121
134
  static get styles() {
122
135
  return css `
123
136
  html {
@@ -195,33 +208,6 @@ let TileListCompact = class TileListCompact extends LitElement {
195
208
  `;
196
209
  }
197
210
  };
198
- __decorate([
199
- property({ type: Object })
200
- ], TileListCompact.prototype, "model", void 0);
201
- __decorate([
202
- property({ type: String })
203
- ], TileListCompact.prototype, "baseNavigationUrl", void 0);
204
- __decorate([
205
- property({ type: Number })
206
- ], TileListCompact.prototype, "currentWidth", void 0);
207
- __decorate([
208
- property({ type: Number })
209
- ], TileListCompact.prototype, "currentHeight", void 0);
210
- __decorate([
211
- property({ type: Object })
212
- ], TileListCompact.prototype, "sortParam", void 0);
213
- __decorate([
214
- property({ type: Number })
215
- ], TileListCompact.prototype, "mobileBreakpoint", void 0);
216
- __decorate([
217
- property({ type: String })
218
- ], TileListCompact.prototype, "baseImageUrl", void 0);
219
- __decorate([
220
- property({ type: Boolean })
221
- ], TileListCompact.prototype, "loggedIn", void 0);
222
- __decorate([
223
- property({ type: String })
224
- ], TileListCompact.prototype, "collectionPagePath", void 0);
225
211
  TileListCompact = __decorate([
226
212
  customElement('tile-list-compact')
227
213
  ], TileListCompact);
@@ -1 +1 @@
1
- {"version":3,"file":"tile-list-compact.js","sourceRoot":"","sources":["../../../../src/tiles/list/tile-list-compact.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,SAAS,MAAM,WAAW,CAAC;AAIlC,OAAO,EAAE,WAAW,EAAgB,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,UAAU,EAAc,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,OAAO,gBAAgB,CAAC;AACxB,OAAO,mBAAmB,CAAC;AAG3B,IAAa,eAAe,GAA5B,MAAa,eAAgB,SAAQ,UAAU;IAA/C;;QAS8B,cAAS,GAAqB,IAAI,CAAC;QAMlC,aAAQ,GAAG,KAAK,CAAC;QAElB,uBAAkB,GAAW,WAAW,CAAC;IA+LvE,CAAC;IA7LC,MAAM;;QACJ,OAAO,IAAI,CAAA;mCACoB,IAAI,CAAC,SAAS;;mBAE9B,IAAI,CAAC,KAAK;0BACH,IAAI,CAAC,YAAY;2BAChB,IAAI;wBACP,IAAI;sBACN,IAAI,CAAC,SAAS;sBACd,IAAI,CAAC,QAAQ;;;kBAGjB,IAAI,CAAC,IAAI;aACd,SAAS,CAAC,QAAQ,CAAC,MAAA,MAAA,IAAI,CAAC,KAAK,0CAAE,KAAK,mCAAI,EAAE,CAAC;;;YAG5C,CAAA,MAAA,IAAI,CAAC,KAAK,0CAAE,SAAS,MAAK,SAAS;YACnC,CAAC,CAAC,YAAY,CAAC,MAAA,IAAI,CAAC,KAAK,0CAAE,SAAS,CAAC;Y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M,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAyET,CAAC;IACJ,CAAC;CACF,CAAA;AA/M6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;8CAAmB;AAElB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0DAA4B;AAE3B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qDAAuB;AAEtB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;sDAAwB;AAEvB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDAAoC;AAEnC;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;yDAA2B;AAE1B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;qDAAuB;AAErB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;iDAAkB;AAElB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2DAA0C;AAjB1D,eAAe;IAD3B,aAAa,CAAC,mBAAmB,CAAC;GACtB,eAAe,CAgN3B;SAhNY,eAAe","sourcesContent":["import { css, html, LitElement, nothing } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport DOMPurify from 'dompurify';\nimport type { SortParam } from '@internetarchive/search-service';\nimport type { TileModel } from '../../models';\n\nimport { formatCount, NumberFormat } from '../../utils/format-count';\nimport { formatDate, DateFormat } from '../../utils/format-date';\nimport { isFirstMillisecondOfUTCYear } from '../../utils/local-date-from-utc';\nimport { accountLabel } from './account-label';\n\nimport '../image-block';\nimport '../mediatype-icon';\n\n@customElement('tile-list-compact')\nexport class TileListCompact extends LitElement {\n @property({ type: Object }) model?: TileModel;\n\n @property({ type: String }) baseNavigationUrl?: string;\n\n @property({ type: Number }) currentWidth?: number;\n\n @property({ type: Number }) currentHeight?: number;\n\n @property({ type: Object }) sortParam: SortParam | null = null;\n\n @property({ type: Number }) mobileBreakpoint?: number;\n\n @property({ type: String }) baseImageUrl?: string;\n\n @property({ type: Boolean }) loggedIn = false;\n\n @property({ type: String }) collectionPagePath: string = '/details/';\n\n render() {\n return html`\n <div id=\"list-line\" class=\"${this.classSize}\">\n <image-block\n .model=${this.model}\n .baseImageUrl=${this.baseImageUrl}\n .isCompactTile=${true}\n .isListTile=${true}\n .viewSize=${this.classSize}\n .loggedIn=${this.loggedIn}\n >\n </image-block>\n <a href=${this.href} id=\"title\"\n >${DOMPurify.sanitize(this.model?.title ?? '')}</a\n >\n <div id=\"creator\">\n ${this.model?.mediatype === 'account'\n ? accountLabel(this.model?.dateAdded)\n : DOMPurify.sanitize(this.model?.creator ?? '')}\n </div>\n <div id=\"date\">${formatDate(this.date, this.dateFormatSize)}</div>\n <div id=\"icon\">\n <mediatype-icon\n .mediatype=${this.model?.mediatype}\n .collections=${this.model?.collections}\n >\n </mediatype-icon>\n </div>\n <div id=\"views\">${formatCount(this.views ?? 0, this.formatSize)}</div>\n </div>\n `;\n }\n\n private get href(): string | typeof nothing {\n if (!this.model?.identifier || this.baseNavigationUrl == null)\n return nothing;\n\n // Use the server-specified href if available.\n // Otherwise, construct a details page URL from the item identifier.\n if (this.model.href) {\n return `${this.baseNavigationUrl}${this.model.href}`;\n }\n\n const isCollection = this.model?.mediatype === 'collection';\n const basePath = isCollection ? this.collectionPagePath : '/details/';\n return `${this.baseNavigationUrl}${basePath}${this.model.identifier}`;\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 // Note on 'publicdate' vs. 'date':\n // The search engine metadata uses 'publicdate' as the key for the date the item\n // was created on archive.org, which in the UI is referred to as \"Date Archived\".\n // In contrast, the search engine metadata uses 'date' to refer to the actual\n // publication date of the underlying media (\"Date Published\" in the UI).\n // Refer to the full metadata schema for more info.\n switch (this.sortParam?.field) {\n case 'publicdate':\n return this.model?.dateArchived;\n case 'reviewdate':\n return this.model?.dateReviewed;\n case 'addeddate':\n return this.model?.dateAdded;\n default:\n return this.model?.datePublished;\n }\n }\n\n private get views(): number | undefined {\n return this.sortParam?.field === 'week'\n ? this.model?.weeklyViewCount // weekly views\n : this.model?.viewCount; // all-time views\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 dateFormatSize(): DateFormat {\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 if (\n (!this.sortParam?.field || this.sortParam.field === 'date') && // No sort or date published\n isFirstMillisecondOfUTCYear(this.model?.datePublished)\n ) {\n return 'year-only';\n }\n return this.formatSize;\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 #list-line {\n display: grid;\n column-gap: 10px;\n border-top: 1px solid #ddd;\n align-items: center;\n line-height: 20px;\n padding-top: 5px;\n padding-bottom: 5px;\n }\n\n #list-line.mobile {\n grid-template-columns: 36px 3fr 2fr 68px 35px;\n }\n\n #list-line.desktop {\n grid-template-columns: 51px 3fr 2fr 95px 30px 60px;\n }\n\n #list-line:hover #title {\n text-decoration: underline;\n }\n\n #title {\n text-decoration: none;\n }\n\n #title:link {\n color: var(--ia-theme-link-color, #4b64ff);\n }\n\n #title,\n #creator {\n text-overflow: ellipsis;\n overflow: hidden;\n white-space: nowrap;\n }\n\n #icon {\n margin-left: 2px;\n }\n\n #views {\n text-align: right;\n padding-right: 8px;\n }\n\n .mobile #views {\n display: none;\n }\n\n .mobile mediatype-icon {\n --iconHeight: 14px;\n --iconWidth: 14px;\n }\n\n .desktop #icon {\n --iconHeight: 20px;\n --iconWidth: 20px;\n }\n\n item-image {\n --imgHeight: 100%;\n --imgWidth: 100%;\n }\n `;\n }\n}\n"]}
1
+ {"version":3,"file":"tile-list-compact.js","sourceRoot":"","sources":["../../../../src/tiles/list/tile-list-compact.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,WAAW,EAAgB,MAAM,0BAA0B,CAAC;AACrE,OAAO,EAAE,UAAU,EAAc,MAAM,yBAAyB,CAAC;AACjE,OAAO,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AAE9E,OAAO,gBAAgB,CAAC;AACxB,OAAO,mBAAmB,CAAC;AAG3B,IAAa,eAAe,GAA5B,MAAa,eAAgB,SAAQ,iBAAiB;IACpD;;;;;;;;;;;;OAYG;IAEH,MAAM;;QACJ,OAAO,IAAI,CAAA;mCACoB,IAAI,CAAC,SAAS;;mBAE9B,IAAI,CAAC,KAAK;0BACH,IAAI,CAAC,YAAY;2BAChB,IAAI;wBACP,IAAI;sBACN,IAAI,CAAC,SAAS;sBACd,IAAI,CAAC,QAAQ;;;kBAGjB,IAAI,CAAC,IAAI;aACd,SAAS,CAAC,QAAQ,CAAC,MAAA,MAAA,IAAI,CAAC,KAAK,0CAAE,KAAK,mCAAI,EAAE,CAAC;;;YAG5C,CAAA,MAAA,IAAI,CAAC,KAAK,0CAAE,SAAS,MAAK,SAAS;YACnC,CAAC,CAAC,IAAI,CAAC,oB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,SAAS,0CAAE,KAAe,CAChC,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,MAAM;QACf,OAAO,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAyET,CAAC;IACJ,CAAC;CACF,CAAA;AAvNY,eAAe;IAD3B,aAAa,CAAC,mBAAmB,CAAC;GACtB,eAAe,CAuN3B;SAvNY,eAAe","sourcesContent":["import { css, html, nothing } from 'lit';\nimport { customElement } from 'lit/decorators.js';\nimport DOMPurify from 'dompurify';\nimport { BaseTileComponent } from '../base-tile-component';\n\nimport { formatCount, NumberFormat } from '../../utils/format-count';\nimport { formatDate, DateFormat } from '../../utils/format-date';\nimport { isFirstMillisecondOfUTCYear } from '../../utils/local-date-from-utc';\n\nimport '../image-block';\nimport '../mediatype-icon';\n\n@customElement('tile-list-compact')\nexport class TileListCompact 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 * - creatorFilter?: string;\n * - mobileBreakpoint?: number;\n * - loggedIn = false;\n */\n\n render() {\n return html`\n <div id=\"list-line\" class=\"${this.classSize}\">\n <image-block\n .model=${this.model}\n .baseImageUrl=${this.baseImageUrl}\n .isCompactTile=${true}\n .isListTile=${true}\n .viewSize=${this.classSize}\n .loggedIn=${this.loggedIn}\n >\n </image-block>\n <a href=${this.href} id=\"title\"\n >${DOMPurify.sanitize(this.model?.title ?? '')}</a\n >\n <div id=\"creator\">\n ${this.model?.mediatype === 'account'\n ? this.displayValueProvider.accountLabel\n : this.creator}\n </div>\n <div id=\"date\">${formatDate(this.date, this.dateFormatSize)}</div>\n <div id=\"icon\">\n <mediatype-icon\n .mediatype=${this.model?.mediatype}\n .collections=${this.model?.collections}\n >\n </mediatype-icon>\n </div>\n <div id=\"views\">${formatCount(this.views ?? 0, this.formatSize)}</div>\n </div>\n `;\n }\n\n private get href(): string | typeof nothing {\n if (!this.model?.identifier || this.baseNavigationUrl == null)\n return nothing;\n\n // Use the server-specified href if available.\n // Otherwise, construct a details page URL from the item identifier.\n if (this.model.href) {\n return `${this.baseNavigationUrl}${this.model.href}`;\n }\n\n return this.displayValueProvider.itemPageUrl(\n this.model.identifier,\n this.model.mediatype === 'collection'\n );\n }\n\n private get creator(): string | typeof nothing {\n return this.displayValueProvider.firstCreatorMatchingFilter ?? nothing;\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 // Note on 'publicdate' vs. 'date':\n // The search engine metadata uses 'publicdate' as the key for the date the item\n // was created on archive.org, which in the UI is referred to as \"Date Archived\".\n // In contrast, the search engine metadata uses 'date' to refer to the actual\n // publication date of the underlying media (\"Date Published\" in the UI).\n // Refer to the full metadata schema for more info.\n switch (this.sortParam?.field) {\n case 'publicdate':\n return this.model?.dateArchived;\n case 'reviewdate':\n return this.model?.dateReviewed;\n case 'addeddate':\n return this.model?.dateAdded;\n default:\n return this.model?.datePublished;\n }\n }\n\n private get views(): number | undefined {\n return this.sortParam?.field === 'week'\n ? this.model?.weeklyViewCount // weekly views\n : this.model?.viewCount; // all-time views\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 dateFormatSize(): DateFormat {\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 if (\n (!this.isSortedByDate || this.sortParam?.field === 'date') && // Any sort except dates that aren't published date\n isFirstMillisecondOfUTCYear(this.model?.datePublished)\n ) {\n return 'year-only';\n }\n return this.formatSize;\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 private get isSortedByDate(): boolean {\n return ['date', 'reviewdate', 'addeddate', 'publicdate'].includes(\n this.sortParam?.field as string\n );\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 #list-line {\n display: grid;\n column-gap: 10px;\n border-top: 1px solid #ddd;\n align-items: center;\n line-height: 20px;\n padding-top: 5px;\n padding-bottom: 5px;\n }\n\n #list-line.mobile {\n grid-template-columns: 36px 3fr 2fr 68px 35px;\n }\n\n #list-line.desktop {\n grid-template-columns: 51px 3fr 2fr 95px 30px 60px;\n }\n\n #list-line:hover #title {\n text-decoration: underline;\n }\n\n #title {\n text-decoration: none;\n }\n\n #title:link {\n color: var(--ia-theme-link-color, #4b64ff);\n }\n\n #title,\n #creator {\n text-overflow: ellipsis;\n overflow: hidden;\n white-space: nowrap;\n }\n\n #icon {\n margin-left: 2px;\n }\n\n #views {\n text-align: right;\n padding-right: 8px;\n }\n\n .mobile #views {\n display: none;\n }\n\n .mobile mediatype-icon {\n --iconHeight: 14px;\n --iconWidth: 14px;\n }\n\n .desktop #icon {\n --iconHeight: 20px;\n --iconWidth: 20px;\n }\n\n item-image {\n --imgHeight: 100%;\n --imgWidth: 100%;\n }\n `;\n }\n}\n"]}
@@ -1,21 +1,11 @@
1
- import { LitElement, PropertyValues, TemplateResult } from 'lit';
1
+ import { PropertyValues, TemplateResult } from 'lit';
2
2
  import type { CollectionNameCacheInterface } from '@internetarchive/collection-name-cache';
3
- import type { SortParam } from '@internetarchive/search-service';
4
- import { TileModel } from '../../models';
3
+ import { BaseTileComponent } from '../base-tile-component';
5
4
  import '../image-block';
6
5
  import '../mediatype-icon';
7
- export declare class TileList extends LitElement {
8
- model?: TileModel;
9
- baseNavigationUrl?: string;
6
+ export declare class TileList extends BaseTileComponent {
10
7
  collectionNameCache?: CollectionNameCacheInterface;
11
- currentWidth?: number;
12
- currentHeight?: number;
13
- sortParam: SortParam | null;
14
- mobileBreakpoint?: number;
15
8
  private collectionLinks;
16
- baseImageUrl?: string;
17
- loggedIn: boolean;
18
- collectionPagePath: string;
19
9
  render(): TemplateResult<1>;
20
10
  /**
21
11
  * Templates
@@ -1,26 +1,36 @@
1
1
  import { __decorate } from "tslib";
2
- import { css, html, LitElement, nothing, } from 'lit';
2
+ import { css, html, nothing } from 'lit';
3
3
  import { ifDefined } from 'lit/directives/if-defined.js';
4
4
  import { join } from 'lit/directives/join.js';
5
5
  import { map } from 'lit/directives/map.js';
6
6
  import { unsafeHTML } from 'lit/directives/unsafe-html.js';
7
7
  import { customElement, property, state } from 'lit/decorators.js';
8
+ import { msg } from '@lit/localize';
8
9
  import DOMPurify from 'dompurify';
9
10
  import { suppressedCollections } from '../../models';
10
- import { dateLabel } from './date-label';
11
- import { accountLabel } from './account-label';
11
+ import { BaseTileComponent } from '../base-tile-component';
12
12
  import { formatCount } from '../../utils/format-count';
13
13
  import { formatDate } from '../../utils/format-date';
14
14
  import { isFirstMillisecondOfUTCYear } from '../../utils/local-date-from-utc';
15
15
  import '../image-block';
16
16
  import '../mediatype-icon';
17
- let TileList = class TileList extends LitElement {
17
+ let TileList = class TileList extends BaseTileComponent {
18
18
  constructor() {
19
+ /*
20
+ * Reactive properties inherited from BaseTileComponent:
21
+ * - model?: TileModel;
22
+ * - currentWidth?: number;
23
+ * - currentHeight?: number;
24
+ * - baseNavigationUrl?: string;
25
+ * - baseImageUrl?: string;
26
+ * - collectionPagePath?: string;
27
+ * - sortParam: SortParam | null = null;
28
+ * - creatorFilter?: string;
29
+ * - mobileBreakpoint?: number;
30
+ * - loggedIn = false;
31
+ */
19
32
  super(...arguments);
20
- this.sortParam = null;
21
33
  this.collectionLinks = [];
22
- this.loggedIn = false;
23
- this.collectionPagePath = '/details/';
24
34
  }
25
35
  render() {
26
36
  return html `
@@ -64,10 +74,7 @@ let TileList = class TileList extends LitElement {
64
74
  if (!this.model)
65
75
  return nothing;
66
76
  const isCollection = this.model.mediatype === 'collection';
67
- const hrefBasePath = isCollection ? this.collectionPagePath : '/details/';
68
- const href = this.model.identifier && this.baseNavigationUrl != null
69
- ? `${this.baseNavigationUrl}${hrefBasePath}${encodeURI(this.model.identifier)}`
70
- : nothing;
77
+ const href = this.displayValueProvider.itemPageUrl(this.model.identifier, isCollection);
71
78
  return html `<a href=${href}>
72
79
  <image-block
73
80
  .model=${this.model}
@@ -135,18 +142,18 @@ let TileList = class TileList extends LitElement {
135
142
  }
136
143
  return html `
137
144
  <div id="source" class="metadata">
138
- ${this.labelTemplate('Source')}
145
+ ${this.labelTemplate(msg('Source'))}
139
146
  ${this.searchLink('source', this.model.source)}
140
147
  </div>
141
148
  `;
142
149
  }
143
150
  get volumeTemplate() {
144
151
  var _a;
145
- return this.metadataTemplate((_a = this.model) === null || _a === void 0 ? void 0 : _a.volume, 'Volume');
152
+ return this.metadataTemplate((_a = this.model) === null || _a === void 0 ? void 0 : _a.volume, msg('Volume'));
146
153
  }
147
154
  get issueTemplate() {
148
155
  var _a;
149
- return this.metadataTemplate((_a = this.model) === null || _a === void 0 ? void 0 : _a.issue, 'Issue');
156
+ return this.metadataTemplate((_a = this.model) === null || _a === void 0 ? void 0 : _a.issue, msg('Issue'));
150
157
  }
151
158
  get creatorTemplate() {
152
159
  var _a, _b, _c;
@@ -154,7 +161,9 @@ let TileList = class TileList extends LitElement {
154
161
  if (((_a = this.model) === null || _a === void 0 ? void 0 : _a.mediatype) === 'account') {
155
162
  return html `
156
163
  <div id="creator" class="metadata">
157
- <span class="label"> ${accountLabel((_b = this.model) === null || _b === void 0 ? void 0 : _b.dateAdded)} </span>
164
+ <span class="label"
165
+ >${(_b = this.displayValueProvider.accountLabel) !== null && _b !== void 0 ? _b : nothing}</span
166
+ >
158
167
  </div>
159
168
  `;
160
169
  }
@@ -164,7 +173,7 @@ let TileList = class TileList extends LitElement {
164
173
  }
165
174
  return html `
166
175
  <div id="creator" class="metadata">
167
- ${this.labelTemplate('By')}
176
+ ${this.labelTemplate(msg('By'))}
168
177
  ${join(map(this.model.creators, id => this.searchLink('creator', id)), html `, `)}
169
178
  </div>
170
179
  `;
@@ -179,7 +188,7 @@ let TileList = class TileList extends LitElement {
179
188
  if (isFirstMillisecondOfUTCYear(date)) {
180
189
  format = 'year-only';
181
190
  }
182
- return this.metadataTemplate(formatDate(date, format), 'Published');
191
+ return this.metadataTemplate(formatDate(date, format), msg('Published'));
183
192
  }
184
193
  // Show date label/value when sorted by date type
185
194
  // Except datePublished which is always shown
@@ -188,7 +197,7 @@ let TileList = class TileList extends LitElement {
188
197
  (this.sortParam.field === 'addeddate' ||
189
198
  this.sortParam.field === 'reviewdate' ||
190
199
  this.sortParam.field === 'publicdate')) {
191
- return this.metadataTemplate(formatDate(this.date, 'long'), dateLabel(this.sortParam.field));
200
+ return this.metadataTemplate(formatDate(this.date, 'long'), this.displayValueProvider.dateLabel);
192
201
  }
193
202
  return nothing;
194
203
  }
@@ -197,15 +206,15 @@ let TileList = class TileList extends LitElement {
197
206
  const viewCount = ((_a = this.sortParam) === null || _a === void 0 ? void 0 : _a.field) === 'week'
198
207
  ? (_b = this.model) === null || _b === void 0 ? void 0 : _b.weeklyViewCount // weekly views
199
208
  : (_c = this.model) === null || _c === void 0 ? void 0 : _c.viewCount; // all-time views
200
- return this.metadataTemplate(`${formatCount(viewCount !== null && viewCount !== void 0 ? viewCount : 0, this.formatSize)}`, 'Views');
209
+ return this.metadataTemplate(`${formatCount(viewCount !== null && viewCount !== void 0 ? viewCount : 0, this.formatSize)}`, msg('Views'));
201
210
  }
202
211
  get ratingTemplate() {
203
212
  var _a;
204
- return this.metadataTemplate((_a = this.model) === null || _a === void 0 ? void 0 : _a.averageRating, 'Avg Rating');
213
+ return this.metadataTemplate((_a = this.model) === null || _a === void 0 ? void 0 : _a.averageRating, msg('Avg Rating'));
205
214
  }
206
215
  get reviewsTemplate() {
207
216
  var _a;
208
- return this.metadataTemplate((_a = this.model) === null || _a === void 0 ? void 0 : _a.commentCount, 'Reviews');
217
+ return this.metadataTemplate((_a = this.model) === null || _a === void 0 ? void 0 : _a.commentCount, msg('Reviews'));
209
218
  }
210
219
  get topicsTemplate() {
211
220
  var _a;
@@ -214,7 +223,7 @@ let TileList = class TileList extends LitElement {
214
223
  }
215
224
  return html `
216
225
  <div id="topics" class="metadata">
217
- ${this.labelTemplate('Topics')}
226
+ ${this.labelTemplate(msg('Topics'))}
218
227
  ${join(map(this.model.subjects, id => this.searchLink('subject', id)), html `, `)}
219
228
  </div>
220
229
  `;
@@ -225,7 +234,7 @@ let TileList = class TileList extends LitElement {
225
234
  }
226
235
  return html `
227
236
  <div id="collections" class="metadata">
228
- ${this.labelTemplate('Collections')}
237
+ ${this.labelTemplate(msg('Collections'))}
229
238
  ${join(this.collectionLinks, html `, `)}
230
239
  </div>
231
240
  `;
@@ -281,16 +290,10 @@ let TileList = class TileList extends LitElement {
281
290
  >`;
282
291
  /* eslint-enable lit/no-invalid-html */
283
292
  }
284
- detailsLink(identifier, text, collection = false) {
293
+ detailsLink(identifier, text, isCollection = false) {
285
294
  const linkText = text !== null && text !== void 0 ? text : identifier;
286
- // No whitespace after closing tag
287
- // identifiers (all ASCII in their creation) should be safe to use in href, but sanitize anyway
288
- return html `<a
289
- href="${this.baseNavigationUrl}${collection
290
- ? this.collectionPagePath
291
- : '/details/'}${encodeURI(identifier)}"
292
- >${DOMPurify.sanitize(linkText)}</a
293
- >`;
295
+ const linkHref = this.displayValueProvider.itemPageUrl(identifier, isCollection);
296
+ return html `<a href=${linkHref}> ${DOMPurify.sanitize(linkText)} </a>`;
294
297
  }
295
298
  /** The URL of this item's mediatype collection, if defined. */
296
299
  get mediatypeURL() {
@@ -305,7 +308,7 @@ let TileList = class TileList extends LitElement {
305
308
  case 'account':
306
309
  return nothing;
307
310
  default:
308
- return `${this.baseNavigationUrl}${this.collectionPagePath}${encodeURI(this.model.mediatype)}`;
311
+ return this.displayValueProvider.itemPageUrl(this.model.mediatype, true);
309
312
  }
310
313
  }
311
314
  updated(changed) {
@@ -541,39 +544,12 @@ let TileList = class TileList extends LitElement {
541
544
  `;
542
545
  }
543
546
  };
544
- __decorate([
545
- property({ type: Object })
546
- ], TileList.prototype, "model", void 0);
547
- __decorate([
548
- property({ type: String })
549
- ], TileList.prototype, "baseNavigationUrl", void 0);
550
547
  __decorate([
551
548
  property({ type: Object })
552
549
  ], TileList.prototype, "collectionNameCache", void 0);
553
- __decorate([
554
- property({ type: Number })
555
- ], TileList.prototype, "currentWidth", void 0);
556
- __decorate([
557
- property({ type: Number })
558
- ], TileList.prototype, "currentHeight", void 0);
559
- __decorate([
560
- property({ type: Object })
561
- ], TileList.prototype, "sortParam", void 0);
562
- __decorate([
563
- property({ type: Number })
564
- ], TileList.prototype, "mobileBreakpoint", void 0);
565
550
  __decorate([
566
551
  state()
567
552
  ], TileList.prototype, "collectionLinks", void 0);
568
- __decorate([
569
- property({ type: String })
570
- ], TileList.prototype, "baseImageUrl", void 0);
571
- __decorate([
572
- property({ type: Boolean })
573
- ], TileList.prototype, "loggedIn", void 0);
574
- __decorate([
575
- property({ type: String })
576
- ], TileList.prototype, "collectionPagePath", void 0);
577
553
  TileList = __decorate([
578
554
  customElement('tile-list')
579
555
  ], TileList);