@internetarchive/collection-browser 0.3.7 → 0.3.9-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (218) hide show
  1. package/.editorconfig +29 -29
  2. package/.github/workflows/ci.yml +26 -26
  3. package/.github/workflows/gh-pages-main.yml +39 -39
  4. package/.github/workflows/npm-publish.yml +39 -39
  5. package/.github/workflows/pr-preview.yml +38 -38
  6. package/.husky/pre-commit +4 -4
  7. package/LICENSE +661 -661
  8. package/README.md +83 -83
  9. package/dist/index.d.ts +9 -9
  10. package/dist/index.js +9 -9
  11. package/dist/src/app-root.d.ts +48 -47
  12. package/dist/src/app-root.js +271 -250
  13. package/dist/src/app-root.js.map +1 -1
  14. package/dist/src/assets/img/icons/arrow-left.d.ts +2 -2
  15. package/dist/src/assets/img/icons/arrow-left.js +2 -2
  16. package/dist/src/assets/img/icons/arrow-right.d.ts +2 -2
  17. package/dist/src/assets/img/icons/arrow-right.js +2 -2
  18. package/dist/src/assets/img/icons/chevron.d.ts +2 -2
  19. package/dist/src/assets/img/icons/chevron.js +2 -2
  20. package/dist/src/assets/img/icons/empty-query.d.ts +2 -2
  21. package/dist/src/assets/img/icons/empty-query.js +2 -2
  22. package/dist/src/assets/img/icons/eye-closed.d.ts +2 -2
  23. package/dist/src/assets/img/icons/eye-closed.js +2 -2
  24. package/dist/src/assets/img/icons/eye.d.ts +2 -2
  25. package/dist/src/assets/img/icons/eye.js +2 -2
  26. package/dist/src/assets/img/icons/favorite-filled.d.ts +1 -1
  27. package/dist/src/assets/img/icons/favorite-filled.js +2 -2
  28. package/dist/src/assets/img/icons/login-required.d.ts +1 -1
  29. package/dist/src/assets/img/icons/login-required.js +2 -2
  30. package/dist/src/assets/img/icons/mediatype/account.d.ts +1 -1
  31. package/dist/src/assets/img/icons/mediatype/account.js +2 -2
  32. package/dist/src/assets/img/icons/mediatype/audio.d.ts +1 -1
  33. package/dist/src/assets/img/icons/mediatype/audio.js +2 -2
  34. package/dist/src/assets/img/icons/mediatype/collection.d.ts +1 -1
  35. package/dist/src/assets/img/icons/mediatype/collection.js +2 -2
  36. package/dist/src/assets/img/icons/mediatype/data.d.ts +1 -1
  37. package/dist/src/assets/img/icons/mediatype/data.js +2 -2
  38. package/dist/src/assets/img/icons/mediatype/etree.d.ts +1 -1
  39. package/dist/src/assets/img/icons/mediatype/etree.js +2 -2
  40. package/dist/src/assets/img/icons/mediatype/film.d.ts +1 -1
  41. package/dist/src/assets/img/icons/mediatype/film.js +2 -2
  42. package/dist/src/assets/img/icons/mediatype/images.d.ts +1 -1
  43. package/dist/src/assets/img/icons/mediatype/images.js +2 -2
  44. package/dist/src/assets/img/icons/mediatype/radio.d.ts +1 -1
  45. package/dist/src/assets/img/icons/mediatype/radio.js +2 -2
  46. package/dist/src/assets/img/icons/mediatype/software.d.ts +1 -1
  47. package/dist/src/assets/img/icons/mediatype/software.js +2 -2
  48. package/dist/src/assets/img/icons/mediatype/texts.d.ts +1 -1
  49. package/dist/src/assets/img/icons/mediatype/texts.js +2 -2
  50. package/dist/src/assets/img/icons/mediatype/tv.d.ts +1 -1
  51. package/dist/src/assets/img/icons/mediatype/tv.js +2 -2
  52. package/dist/src/assets/img/icons/mediatype/video.d.ts +1 -1
  53. package/dist/src/assets/img/icons/mediatype/video.js +2 -2
  54. package/dist/src/assets/img/icons/mediatype/web.d.ts +1 -1
  55. package/dist/src/assets/img/icons/mediatype/web.js +2 -2
  56. package/dist/src/assets/img/icons/null-result.d.ts +2 -2
  57. package/dist/src/assets/img/icons/null-result.js +2 -2
  58. package/dist/src/assets/img/icons/restricted.d.ts +1 -1
  59. package/dist/src/assets/img/icons/restricted.js +2 -2
  60. package/dist/src/assets/img/icons/reviews.d.ts +1 -1
  61. package/dist/src/assets/img/icons/reviews.js +2 -2
  62. package/dist/src/assets/img/icons/upload.d.ts +1 -1
  63. package/dist/src/assets/img/icons/upload.js +2 -2
  64. package/dist/src/assets/img/icons/views.d.ts +1 -1
  65. package/dist/src/assets/img/icons/views.js +2 -2
  66. package/dist/src/circular-activity-indicator.d.ts +5 -5
  67. package/dist/src/circular-activity-indicator.js +17 -17
  68. package/dist/src/collection-browser.d.ts +278 -246
  69. package/dist/src/collection-browser.js +1105 -1031
  70. package/dist/src/collection-browser.js.map +1 -1
  71. package/dist/src/collection-facets/facet-tombstone-row.d.ts +5 -5
  72. package/dist/src/collection-facets/facet-tombstone-row.js +15 -15
  73. package/dist/src/collection-facets/facets-template.d.ts +16 -16
  74. package/dist/src/collection-facets/facets-template.js +125 -125
  75. package/dist/src/collection-facets/more-facets-content.d.ts +76 -76
  76. package/dist/src/collection-facets/more-facets-content.js +353 -353
  77. package/dist/src/collection-facets/more-facets-pagination.d.ts +36 -36
  78. package/dist/src/collection-facets/more-facets-pagination.js +192 -192
  79. package/dist/src/collection-facets.d.ts +77 -77
  80. package/dist/src/collection-facets.js +388 -389
  81. package/dist/src/collection-facets.js.map +1 -1
  82. package/dist/src/empty-placeholder.d.ts +11 -11
  83. package/dist/src/empty-placeholder.js +42 -42
  84. package/dist/src/language-code-handler/language-code-handler.d.ts +37 -37
  85. package/dist/src/language-code-handler/language-code-handler.js +26 -26
  86. package/dist/src/language-code-handler/language-code-mapping.d.ts +1 -1
  87. package/dist/src/language-code-handler/language-code-mapping.js +562 -562
  88. package/dist/src/mediatype/mediatype-config.d.ts +3 -3
  89. package/dist/src/mediatype/mediatype-config.js +85 -85
  90. package/dist/src/models.d.ts +103 -103
  91. package/dist/src/models.js +117 -117
  92. package/dist/src/restoration-state-handler.d.ts +46 -46
  93. package/dist/src/restoration-state-handler.js +230 -230
  94. package/dist/src/sort-filter-bar/alpha-bar.d.ts +9 -9
  95. package/dist/src/sort-filter-bar/alpha-bar.js +41 -41
  96. package/dist/src/sort-filter-bar/img/compact.d.ts +1 -1
  97. package/dist/src/sort-filter-bar/img/compact.js +2 -2
  98. package/dist/src/sort-filter-bar/img/list.d.ts +1 -1
  99. package/dist/src/sort-filter-bar/img/list.js +2 -2
  100. package/dist/src/sort-filter-bar/img/sort-triangle.d.ts +1 -1
  101. package/dist/src/sort-filter-bar/img/sort-triangle.js +2 -2
  102. package/dist/src/sort-filter-bar/img/tile.d.ts +1 -1
  103. package/dist/src/sort-filter-bar/img/tile.js +2 -2
  104. package/dist/src/sort-filter-bar/sort-filter-bar.d.ts +107 -107
  105. package/dist/src/sort-filter-bar/sort-filter-bar.js +423 -423
  106. package/dist/src/styles/item-image-styles.d.ts +8 -8
  107. package/dist/src/styles/item-image-styles.js +9 -9
  108. package/dist/src/tiles/collection-browser-loading-tile.d.ts +5 -5
  109. package/dist/src/tiles/collection-browser-loading-tile.js +15 -15
  110. package/dist/src/tiles/grid/account-tile.d.ts +8 -8
  111. package/dist/src/tiles/grid/account-tile.js +20 -20
  112. package/dist/src/tiles/grid/collection-tile.d.ts +7 -7
  113. package/dist/src/tiles/grid/collection-tile.js +23 -23
  114. package/dist/src/tiles/grid/item-tile.d.ts +24 -24
  115. package/dist/src/tiles/grid/item-tile.js +87 -87
  116. package/dist/src/tiles/grid/tile-stats.d.ts +10 -10
  117. package/dist/src/tiles/grid/tile-stats.js +40 -40
  118. package/dist/src/tiles/image-block.d.ts +17 -17
  119. package/dist/src/tiles/image-block.js +69 -69
  120. package/dist/src/tiles/item-image.d.ts +31 -31
  121. package/dist/src/tiles/item-image.js +103 -103
  122. package/dist/src/tiles/list/account-label.d.ts +1 -1
  123. package/dist/src/tiles/list/account-label.js +6 -6
  124. package/dist/src/tiles/list/date-label.d.ts +1 -1
  125. package/dist/src/tiles/list/date-label.js +12 -12
  126. package/dist/src/tiles/list/tile-list-compact-header.d.ts +12 -12
  127. package/dist/src/tiles/list/tile-list-compact-header.js +41 -41
  128. package/dist/src/tiles/list/tile-list-compact.d.ts +21 -21
  129. package/dist/src/tiles/list/tile-list-compact.js +93 -93
  130. package/dist/src/tiles/list/tile-list.d.ts +50 -50
  131. package/dist/src/tiles/list/tile-list.js +280 -272
  132. package/dist/src/tiles/list/tile-list.js.map +1 -1
  133. package/dist/src/tiles/mediatype-icon.d.ts +9 -9
  134. package/dist/src/tiles/mediatype-icon.js +47 -47
  135. package/dist/src/tiles/overlay/icon-overlay.d.ts +7 -7
  136. package/dist/src/tiles/overlay/icon-overlay.js +30 -30
  137. package/dist/src/tiles/overlay/text-overlay.d.ts +8 -8
  138. package/dist/src/tiles/overlay/text-overlay.js +31 -31
  139. package/dist/src/tiles/text-snippet-block.d.ts +29 -29
  140. package/dist/src/tiles/text-snippet-block.js +81 -81
  141. package/dist/src/tiles/tile-dispatcher.d.ts +36 -36
  142. package/dist/src/tiles/tile-dispatcher.js +128 -128
  143. package/dist/src/utils/analytics-events.d.ts +22 -22
  144. package/dist/src/utils/analytics-events.js +24 -24
  145. package/dist/src/utils/format-count.d.ts +7 -7
  146. package/dist/src/utils/format-count.js +76 -76
  147. package/dist/src/utils/format-date.d.ts +2 -2
  148. package/dist/src/utils/format-date.js +23 -23
  149. package/dist/test/collection-browser.test.d.ts +1 -1
  150. package/dist/test/collection-browser.test.js +583 -444
  151. package/dist/test/collection-browser.test.js.map +1 -1
  152. package/dist/test/collection-facets/facets-template.test.d.ts +1 -1
  153. package/dist/test/collection-facets/facets-template.test.js +62 -62
  154. package/dist/test/collection-facets/more-facets-content.test.d.ts +1 -1
  155. package/dist/test/collection-facets/more-facets-content.test.js +114 -114
  156. package/dist/test/collection-facets/more-facets-pagination.test.d.ts +1 -1
  157. package/dist/test/collection-facets/more-facets-pagination.test.js +117 -117
  158. package/dist/test/collection-facets.test.d.ts +2 -2
  159. package/dist/test/collection-facets.test.js +544 -498
  160. package/dist/test/collection-facets.test.js.map +1 -1
  161. package/dist/test/empty-placeholder.test.d.ts +1 -1
  162. package/dist/test/empty-placeholder.test.js +33 -33
  163. package/dist/test/icon-overlay.test.d.ts +1 -1
  164. package/dist/test/icon-overlay.test.js +24 -24
  165. package/dist/test/image-block.test.d.ts +1 -1
  166. package/dist/test/image-block.test.js +48 -48
  167. package/dist/test/item-image.test.d.ts +1 -1
  168. package/dist/test/item-image.test.js +56 -56
  169. package/dist/test/mediatype-config.test.d.ts +1 -1
  170. package/dist/test/mediatype-config.test.js +16 -16
  171. package/dist/test/mocks/mock-analytics-handler.d.ts +10 -10
  172. package/dist/test/mocks/mock-analytics-handler.js +15 -15
  173. package/dist/test/mocks/mock-collection-name-cache.d.ts +7 -7
  174. package/dist/test/mocks/mock-collection-name-cache.js +13 -13
  175. package/dist/test/mocks/mock-search-responses.d.ts +10 -8
  176. package/dist/test/mocks/mock-search-responses.js +271 -198
  177. package/dist/test/mocks/mock-search-responses.js.map +1 -1
  178. package/dist/test/mocks/mock-search-service.d.ts +13 -13
  179. package/dist/test/mocks/mock-search-service.js +36 -32
  180. package/dist/test/mocks/mock-search-service.js.map +1 -1
  181. package/dist/test/restoration-state-handler.test.d.ts +1 -1
  182. package/dist/test/restoration-state-handler.test.js +126 -126
  183. package/dist/test/sort-filter-bar/sort-filter-bar.test.d.ts +1 -1
  184. package/dist/test/sort-filter-bar/sort-filter-bar.test.js +113 -113
  185. package/dist/test/text-overlay.test.d.ts +1 -1
  186. package/dist/test/text-overlay.test.js +41 -41
  187. package/dist/test/text-snippet-block.test.d.ts +1 -1
  188. package/dist/test/text-snippet-block.test.js +57 -57
  189. package/dist/test/tile-stats.test.d.ts +1 -1
  190. package/dist/test/tile-stats.test.js +33 -33
  191. package/dist/test/tiles/grid/item-tile.test.d.ts +1 -1
  192. package/dist/test/tiles/grid/item-tile.test.js +107 -107
  193. package/dist/test/tiles/list/tile-list-compact.test.d.ts +1 -1
  194. package/dist/test/tiles/list/tile-list-compact.test.js +92 -92
  195. package/dist/test/tiles/list/tile-list.test.d.ts +1 -1
  196. package/dist/test/tiles/list/tile-list.test.js +140 -67
  197. package/dist/test/tiles/list/tile-list.test.js.map +1 -1
  198. package/dist/test/utils/format-count.test.d.ts +1 -1
  199. package/dist/test/utils/format-count.test.js +23 -23
  200. package/dist/test/utils/format-date.test.d.ts +1 -1
  201. package/dist/test/utils/format-date.test.js +17 -17
  202. package/index.html +24 -24
  203. package/local.archive.org.cert +86 -86
  204. package/local.archive.org.key +27 -27
  205. package/package.json +3 -3
  206. package/renovate.json +6 -6
  207. package/src/app-root.ts +32 -9
  208. package/src/collection-browser.ts +130 -35
  209. package/src/collection-facets.ts +2 -3
  210. package/src/tiles/list/tile-list.ts +17 -6
  211. package/test/collection-browser.test.ts +207 -0
  212. package/test/collection-facets.test.ts +67 -0
  213. package/test/mocks/mock-search-responses.ts +82 -0
  214. package/test/mocks/mock-search-service.ts +6 -0
  215. package/test/tiles/list/tile-list.test.ts +91 -0
  216. package/tsconfig.json +21 -21
  217. package/web-dev-server.config.mjs +30 -30
  218. package/web-test-runner.config.mjs +41 -41
@@ -1,62 +1,64 @@
1
- import { __decorate } from "tslib";
2
- import { css, html, LitElement, nothing, } from 'lit';
3
- import { ifDefined } from 'lit/directives/if-defined.js';
4
- import { join } from 'lit/directives/join.js';
5
- import { map } from 'lit/directives/map.js';
6
- import { customElement, property, state } from 'lit/decorators.js';
7
- import DOMPurify from 'dompurify';
8
- import { suppressedCollections } from '../../models';
9
- import { dateLabel } from './date-label';
10
- import { accountLabel } from './account-label';
11
- import { formatCount } from '../../utils/format-count';
12
- import { formatDate } from '../../utils/format-date';
13
- import '../image-block';
14
- import '../mediatype-icon';
15
- let TileList = class TileList extends LitElement {
16
- constructor() {
17
- super(...arguments);
18
- this.sortParam = null;
19
- this.collectionLinks = [];
20
- this.loggedIn = false;
21
- }
22
- updated(changed) {
23
- if (changed.has('model')) {
24
- this.fetchCollectionNames();
25
- }
26
- }
27
- async fetchCollectionNames() {
28
- var _a, _b;
29
- if (!((_a = this.model) === null || _a === void 0 ? void 0 : _a.collections) ||
30
- this.model.collections.length === 0 ||
31
- !this.collectionNameCache) {
32
- return;
33
- }
34
- // Note: quirk of Lit: need to replace collectionLinks array,
35
- // otherwise it will not re-render. Can't simply alter the array.
36
- this.collectionLinks = [];
37
- const newCollectionLinks = [];
38
- const promises = [];
39
- for (const collection of this.model.collections) {
40
- // Don't include collections that are meant to be suppressed
41
- if (!suppressedCollections[collection]) {
42
- promises.push((_b = this.collectionNameCache) === null || _b === void 0 ? void 0 : _b.collectionNameFor(collection).then(name => {
43
- newCollectionLinks.push(this.detailsLink(collection, name !== null && name !== void 0 ? name : collection));
44
- }));
45
- }
46
- }
47
- await Promise.all(promises);
48
- this.collectionLinks = newCollectionLinks;
49
- }
50
- render() {
1
+ import { __decorate } from "tslib";
2
+ import { css, html, LitElement, nothing, } from 'lit';
3
+ import { ifDefined } from 'lit/directives/if-defined.js';
4
+ import { join } from 'lit/directives/join.js';
5
+ import { map } from 'lit/directives/map.js';
6
+ import { unsafeHTML } from 'lit/directives/unsafe-html.js';
7
+ import { customElement, property, state } from 'lit/decorators.js';
8
+ import DOMPurify from 'dompurify';
9
+ import { suppressedCollections } from '../../models';
10
+ import { dateLabel } from './date-label';
11
+ import { accountLabel } from './account-label';
12
+ import { formatCount } from '../../utils/format-count';
13
+ import { formatDate } from '../../utils/format-date';
14
+ import '../image-block';
15
+ import '../mediatype-icon';
16
+ let TileList = class TileList extends LitElement {
17
+ constructor() {
18
+ super(...arguments);
19
+ this.sortParam = null;
20
+ this.collectionLinks = [];
21
+ this.loggedIn = false;
22
+ }
23
+ updated(changed) {
24
+ if (changed.has('model')) {
25
+ this.fetchCollectionNames();
26
+ }
27
+ }
28
+ async fetchCollectionNames() {
29
+ var _a, _b;
30
+ if (!((_a = this.model) === null || _a === void 0 ? void 0 : _a.collections) ||
31
+ this.model.collections.length === 0 ||
32
+ !this.collectionNameCache) {
33
+ return;
34
+ }
35
+ // Note: quirk of Lit: need to replace collectionLinks array,
36
+ // otherwise it will not re-render. Can't simply alter the array.
37
+ this.collectionLinks = [];
38
+ const newCollectionLinks = [];
39
+ const promises = [];
40
+ for (const collection of this.model.collections) {
41
+ // Don't include favorites or collections that are meant to be suppressed
42
+ if (!suppressedCollections[collection] &&
43
+ !collection.startsWith('fav-')) {
44
+ promises.push((_b = this.collectionNameCache) === null || _b === void 0 ? void 0 : _b.collectionNameFor(collection).then(name => {
45
+ newCollectionLinks.push(this.detailsLink(collection, name !== null && name !== void 0 ? name : collection));
46
+ }));
47
+ }
48
+ }
49
+ await Promise.all(promises);
50
+ this.collectionLinks = newCollectionLinks;
51
+ }
52
+ render() {
51
53
  return html `
52
54
  <div id="list-line" class="${this.classSize}">
53
- ${this.classSize === 'mobile'
54
- ? this.mobileTemplate
55
+ ${this.classSize === 'mobile'
56
+ ? this.mobileTemplate
55
57
  : this.desktopTemplate}
56
58
  </div>
57
- `;
58
- }
59
- get mobileTemplate() {
59
+ `;
60
+ }
61
+ get mobileTemplate() {
60
62
  return html `
61
63
  <div id="list-line-top">
62
64
  <div id="list-line-left">${this.imageBlockTemplate}</div>
@@ -68,9 +70,9 @@ let TileList = class TileList extends LitElement {
68
70
  </div>
69
71
  </div>
70
72
  <div id="list-line-bottom">${this.detailsTemplate}</div>
71
- `;
72
- }
73
- get desktopTemplate() {
73
+ `;
74
+ }
75
+ get desktopTemplate() {
74
76
  return html `
75
77
  <div id="list-line-left">${this.imageBlockTemplate}</div>
76
78
  <div id="list-line-right">
@@ -80,9 +82,9 @@ let TileList = class TileList extends LitElement {
80
82
  </div>
81
83
  ${this.detailsTemplate}
82
84
  </div>
83
- `;
84
- }
85
- get imageBlockTemplate() {
85
+ `;
86
+ }
87
+ get imageBlockTemplate() {
86
88
  return html `
87
89
  <image-block
88
90
  .model=${this.model}
@@ -93,9 +95,9 @@ let TileList = class TileList extends LitElement {
93
95
  .loggedIn=${this.loggedIn}
94
96
  >
95
97
  </image-block>
96
- `;
97
- }
98
- get detailsTemplate() {
98
+ `;
99
+ }
100
+ get detailsTemplate() {
99
101
  return html `
100
102
  ${this.itemLineTemplate} ${this.creatorTemplate}
101
103
  <div id="dates-line">
@@ -106,11 +108,11 @@ let TileList = class TileList extends LitElement {
106
108
  </div>
107
109
  ${this.topicsTemplate} ${this.collectionsTemplate}
108
110
  ${this.descriptionTemplate} ${this.textSnippetsTemplate}
109
- `;
110
- }
111
- // Data templates
112
- get iconRightTemplate() {
113
- var _a, _b;
111
+ `;
112
+ }
113
+ // Data templates
114
+ get iconRightTemplate() {
115
+ var _a, _b;
114
116
  return html `
115
117
  <div id="icon-right">
116
118
  <mediatype-icon
@@ -119,207 +121,213 @@ let TileList = class TileList extends LitElement {
119
121
  >
120
122
  </mediatype-icon>
121
123
  </div>
122
- `;
123
- }
124
- get titleTemplate() {
125
- var _a;
126
- if (!((_a = this.model) === null || _a === void 0 ? void 0 : _a.title)) {
127
- return nothing;
128
- }
129
- return html ` ${this.detailsLink(this.model.identifier, this.model.title)} `;
130
- }
131
- get itemLineTemplate() {
132
- const source = this.sourceTemplate;
133
- const volume = this.volumeTemplate;
134
- const issue = this.issueTemplate;
135
- if (!source && !volume && !issue) {
136
- return nothing;
137
- }
138
- return html ` <div id="item-line">${source} ${volume} ${issue}</div> `;
139
- }
140
- get sourceTemplate() {
141
- var _a;
142
- if (!((_a = this.model) === null || _a === void 0 ? void 0 : _a.source)) {
143
- return nothing;
144
- }
124
+ `;
125
+ }
126
+ get titleTemplate() {
127
+ var _a;
128
+ if (!((_a = this.model) === null || _a === void 0 ? void 0 : _a.title)) {
129
+ return nothing;
130
+ }
131
+ return html ` ${this.detailsLink(this.model.identifier, this.model.title)} `;
132
+ }
133
+ get itemLineTemplate() {
134
+ const source = this.sourceTemplate;
135
+ const volume = this.volumeTemplate;
136
+ const issue = this.issueTemplate;
137
+ if (!source && !volume && !issue) {
138
+ return nothing;
139
+ }
140
+ return html ` <div id="item-line">${source} ${volume} ${issue}</div> `;
141
+ }
142
+ get sourceTemplate() {
143
+ var _a;
144
+ if (!((_a = this.model) === null || _a === void 0 ? void 0 : _a.source)) {
145
+ return nothing;
146
+ }
145
147
  return html `
146
148
  <div id="source" class="metadata">
147
149
  ${this.labelTemplate('Source')}
148
150
  ${this.searchLink('source', this.model.source)}
149
151
  </div>
150
- `;
151
- }
152
- get volumeTemplate() {
153
- var _a;
154
- return this.metadataTemplate((_a = this.model) === null || _a === void 0 ? void 0 : _a.volume, 'Volume');
155
- }
156
- get issueTemplate() {
157
- var _a;
158
- return this.metadataTemplate((_a = this.model) === null || _a === void 0 ? void 0 : _a.issue, 'Issue');
159
- }
160
- get creatorTemplate() {
161
- var _a, _b, _c;
162
- // "Achivist since" if account
163
- if (((_a = this.model) === null || _a === void 0 ? void 0 : _a.mediatype) === 'account') {
152
+ `;
153
+ }
154
+ get volumeTemplate() {
155
+ var _a;
156
+ return this.metadataTemplate((_a = this.model) === null || _a === void 0 ? void 0 : _a.volume, 'Volume');
157
+ }
158
+ get issueTemplate() {
159
+ var _a;
160
+ return this.metadataTemplate((_a = this.model) === null || _a === void 0 ? void 0 : _a.issue, 'Issue');
161
+ }
162
+ get creatorTemplate() {
163
+ var _a, _b, _c;
164
+ // "Archivist since" if account
165
+ if (((_a = this.model) === null || _a === void 0 ? void 0 : _a.mediatype) === 'account') {
164
166
  return html `
165
167
  <div id="creator" class="metadata">
166
168
  <span class="label"> ${accountLabel((_b = this.model) === null || _b === void 0 ? void 0 : _b.dateAdded)} </span>
167
169
  </div>
168
- `;
169
- }
170
- // "Creator" if not account tile
171
- if (!((_c = this.model) === null || _c === void 0 ? void 0 : _c.creators) || this.model.creators.length === 0) {
172
- return nothing;
173
- }
170
+ `;
171
+ }
172
+ // "Creator" if not account tile
173
+ if (!((_c = this.model) === null || _c === void 0 ? void 0 : _c.creators) || this.model.creators.length === 0) {
174
+ return nothing;
175
+ }
174
176
  return html `
175
177
  <div id="creator" class="metadata">
176
178
  ${this.labelTemplate('By')}
177
179
  ${join(map(this.model.creators, id => this.searchLink('creator', id)), html `, `)}
178
180
  </div>
179
- `;
180
- }
181
- get datePublishedTemplate() {
182
- var _a;
183
- return this.metadataTemplate(formatDate((_a = this.model) === null || _a === void 0 ? void 0 : _a.datePublished, 'long'), 'Published');
184
- }
185
- // Show date label/value when sorted by date type
186
- // Except datePublished which is always shown
187
- get dateSortByTemplate() {
188
- if (this.sortParam &&
189
- (this.sortParam.field === 'addeddate' ||
190
- this.sortParam.field === 'reviewdate' ||
191
- this.sortParam.field === 'publicdate')) {
192
- return this.metadataTemplate(formatDate(this.date, 'long'), dateLabel(this.sortParam.field));
193
- }
194
- return nothing;
195
- }
196
- get viewsTemplate() {
197
- var _a, _b, _c;
198
- const viewCount = ((_a = this.sortParam) === null || _a === void 0 ? void 0 : _a.field) === 'week'
199
- ? (_b = this.model) === null || _b === void 0 ? void 0 : _b.weeklyViewCount // weekly views
200
- : (_c = this.model) === null || _c === void 0 ? void 0 : _c.viewCount; // all-time views
201
- return this.metadataTemplate(`${formatCount(viewCount !== null && viewCount !== void 0 ? viewCount : 0, this.formatSize)}`, 'Views');
202
- }
203
- get ratingTemplate() {
204
- var _a;
205
- return this.metadataTemplate((_a = this.model) === null || _a === void 0 ? void 0 : _a.averageRating, 'Avg Rating');
206
- }
207
- get reviewsTemplate() {
208
- var _a;
209
- return this.metadataTemplate((_a = this.model) === null || _a === void 0 ? void 0 : _a.commentCount, 'Reviews');
210
- }
211
- get topicsTemplate() {
212
- var _a;
213
- if (!((_a = this.model) === null || _a === void 0 ? void 0 : _a.subjects) || this.model.subjects.length === 0) {
214
- return nothing;
215
- }
181
+ `;
182
+ }
183
+ get datePublishedTemplate() {
184
+ var _a;
185
+ return this.metadataTemplate(formatDate((_a = this.model) === null || _a === void 0 ? void 0 : _a.datePublished, 'long'), 'Published');
186
+ }
187
+ // Show date label/value when sorted by date type
188
+ // Except datePublished which is always shown
189
+ get dateSortByTemplate() {
190
+ if (this.sortParam &&
191
+ (this.sortParam.field === 'addeddate' ||
192
+ this.sortParam.field === 'reviewdate' ||
193
+ this.sortParam.field === 'publicdate')) {
194
+ return this.metadataTemplate(formatDate(this.date, 'long'), dateLabel(this.sortParam.field));
195
+ }
196
+ return nothing;
197
+ }
198
+ get viewsTemplate() {
199
+ var _a, _b, _c;
200
+ const viewCount = ((_a = this.sortParam) === null || _a === void 0 ? void 0 : _a.field) === 'week'
201
+ ? (_b = this.model) === null || _b === void 0 ? void 0 : _b.weeklyViewCount // weekly views
202
+ : (_c = this.model) === null || _c === void 0 ? void 0 : _c.viewCount; // all-time views
203
+ return this.metadataTemplate(`${formatCount(viewCount !== null && viewCount !== void 0 ? viewCount : 0, this.formatSize)}`, 'Views');
204
+ }
205
+ get ratingTemplate() {
206
+ var _a;
207
+ return this.metadataTemplate((_a = this.model) === null || _a === void 0 ? void 0 : _a.averageRating, 'Avg Rating');
208
+ }
209
+ get reviewsTemplate() {
210
+ var _a;
211
+ return this.metadataTemplate((_a = this.model) === null || _a === void 0 ? void 0 : _a.commentCount, 'Reviews');
212
+ }
213
+ get topicsTemplate() {
214
+ var _a;
215
+ if (!((_a = this.model) === null || _a === void 0 ? void 0 : _a.subjects) || this.model.subjects.length === 0) {
216
+ return nothing;
217
+ }
216
218
  return html `
217
219
  <div id="topics" class="metadata">
218
220
  ${this.labelTemplate('Topics')}
219
221
  ${join(map(this.model.subjects, id => this.searchLink('subject', id)), html `, `)}
220
222
  </div>
221
- `;
222
- }
223
- get collectionsTemplate() {
224
- if (!this.collectionLinks || this.collectionLinks.length === 0) {
225
- return nothing;
226
- }
223
+ `;
224
+ }
225
+ get collectionsTemplate() {
226
+ if (!this.collectionLinks || this.collectionLinks.length === 0) {
227
+ return nothing;
228
+ }
227
229
  return html `
228
230
  <div id="collections" class="metadata">
229
231
  ${this.labelTemplate('Collections')}
230
232
  ${join(this.collectionLinks, html `, `)}
231
233
  </div>
232
- `;
233
- }
234
- get descriptionTemplate() {
235
- var _a, _b;
236
- return this.metadataTemplate(DOMPurify.sanitize((_b = (_a = this.model) === null || _a === void 0 ? void 0 : _a.description) !== null && _b !== void 0 ? _b : ''), '', 'description');
237
- }
238
- get textSnippetsTemplate() {
239
- var _a;
240
- if (!this.hasSnippets)
241
- return nothing;
234
+ `;
235
+ }
236
+ get descriptionTemplate() {
237
+ var _a, _b, _c;
238
+ return this.metadataTemplate(
239
+ // Sanitize away any HTML tags and convert line breaks to spaces.
240
+ unsafeHTML(DOMPurify.sanitize((_c = (_b = (_a = this.model) === null || _a === void 0 ? void 0 : _a.description) === null || _b === void 0 ? void 0 : _b.replace(/\n/g, ' ')) !== null && _c !== void 0 ? _c : '')), '', 'description');
241
+ }
242
+ get textSnippetsTemplate() {
243
+ var _a;
244
+ if (!this.hasSnippets)
245
+ return nothing;
242
246
  return html `<text-snippet-block
243
247
  viewsize="list"
244
248
  .snippets=${(_a = this.model) === null || _a === void 0 ? void 0 : _a.snippets}
245
- ></text-snippet-block>`;
246
- }
247
- get hasSnippets() {
248
- var _a, _b;
249
- return !!((_b = (_a = this.model) === null || _a === void 0 ? void 0 : _a.snippets) === null || _b === void 0 ? void 0 : _b.length);
250
- }
251
- // Utility functions
252
- // eslint-disable-next-line default-param-last
253
- metadataTemplate(text, label = '', id) {
254
- if (!text)
255
- return nothing;
249
+ ></text-snippet-block>`;
250
+ }
251
+ get hasSnippets() {
252
+ var _a, _b;
253
+ return !!((_b = (_a = this.model) === null || _a === void 0 ? void 0 : _a.snippets) === null || _b === void 0 ? void 0 : _b.length);
254
+ }
255
+ // Utility functions
256
+ // eslint-disable-next-line default-param-last
257
+ metadataTemplate(text, label = '', id) {
258
+ if (!text)
259
+ return nothing;
256
260
  return html `
257
261
  <div id=${ifDefined(id)} class="metadata">
258
262
  ${this.labelTemplate(label)} ${text}
259
263
  </div>
260
- `;
261
- }
262
- labelTemplate(label) {
263
- return html ` ${label
264
- ? html `<span class="label">${label}: </span>`
265
- : nothing}`;
266
- }
267
- searchLink(field, searchTerm) {
268
- if (!field || !searchTerm) {
269
- return nothing;
270
- }
271
- const query = encodeURIComponent(`${field}:"${searchTerm}"`);
272
- // No whitespace after closing tag
273
- // Note: single ' for href='' to wrap " in query var gets changed back by yarn format
274
- // eslint-disable-next-line lit/no-invalid-html
275
- return html `<a href="${this.baseNavigationUrl}/search.php?query=${query}">
264
+ `;
265
+ }
266
+ labelTemplate(label) {
267
+ return html ` ${label
268
+ ? html `<span class="label">${label}: </span>`
269
+ : nothing}`;
270
+ }
271
+ searchLink(field, searchTerm) {
272
+ if (!field || !searchTerm) {
273
+ return nothing;
274
+ }
275
+ const query = encodeURIComponent(`${field}:"${searchTerm}"`);
276
+ // No whitespace after closing tag
277
+ // Note: single ' for href='' to wrap " in query var gets changed back by yarn format
278
+ /* eslint-disable lit/no-invalid-html */
279
+ return html `<a
280
+ href="${this.baseNavigationUrl}/search?query=${query}"
281
+ rel="nofollow"
282
+ >
276
283
  ${DOMPurify.sanitize(searchTerm)}</a
277
- >`;
278
- }
279
- detailsLink(identifier, text) {
280
- const linkText = text !== null && text !== void 0 ? text : identifier;
281
- // No whitespace after closing tag
282
- // identifiers (all ASCII in their creation) should be safe to use in href, but sanitize anyway
284
+ >`;
285
+ /* eslint-enable lit/no-invalid-html */
286
+ }
287
+ detailsLink(identifier, text) {
288
+ const linkText = text !== null && text !== void 0 ? text : identifier;
289
+ // No whitespace after closing tag
290
+ // identifiers (all ASCII in their creation) should be safe to use in href, but sanitize anyway
283
291
  return html `<a
284
292
  href="${this.baseNavigationUrl}/details/${encodeURI(identifier)}"
285
293
  >${DOMPurify.sanitize(linkText)}</a
286
- >`;
287
- }
288
- /*
289
- * TODO: fix field names to match model in src/collection-browser.ts
290
- * private get dateSortSelector()
291
- * @see src/models.ts
292
- */
293
- get date() {
294
- var _a, _b, _c, _d, _e;
295
- switch ((_a = this.sortParam) === null || _a === void 0 ? void 0 : _a.field) {
296
- case 'date':
297
- return (_b = this.model) === null || _b === void 0 ? void 0 : _b.datePublished;
298
- case 'reviewdate':
299
- return (_c = this.model) === null || _c === void 0 ? void 0 : _c.dateReviewed;
300
- case 'addeddate':
301
- return (_d = this.model) === null || _d === void 0 ? void 0 : _d.dateAdded;
302
- default:
303
- return (_e = this.model) === null || _e === void 0 ? void 0 : _e.dateArchived; // publicdate
304
- }
305
- }
306
- get classSize() {
307
- if (this.mobileBreakpoint &&
308
- this.currentWidth &&
309
- this.currentWidth < this.mobileBreakpoint) {
310
- return 'mobile';
311
- }
312
- return 'desktop';
313
- }
314
- get formatSize() {
315
- if (this.mobileBreakpoint &&
316
- this.currentWidth &&
317
- this.currentWidth < this.mobileBreakpoint) {
318
- return 'short';
319
- }
320
- return 'long';
321
- }
322
- static get styles() {
294
+ >`;
295
+ }
296
+ /*
297
+ * TODO: fix field names to match model in src/collection-browser.ts
298
+ * private get dateSortSelector()
299
+ * @see src/models.ts
300
+ */
301
+ get date() {
302
+ var _a, _b, _c, _d, _e;
303
+ switch ((_a = this.sortParam) === null || _a === void 0 ? void 0 : _a.field) {
304
+ case 'date':
305
+ return (_b = this.model) === null || _b === void 0 ? void 0 : _b.datePublished;
306
+ case 'reviewdate':
307
+ return (_c = this.model) === null || _c === void 0 ? void 0 : _c.dateReviewed;
308
+ case 'addeddate':
309
+ return (_d = this.model) === null || _d === void 0 ? void 0 : _d.dateAdded;
310
+ default:
311
+ return (_e = this.model) === null || _e === void 0 ? void 0 : _e.dateArchived; // publicdate
312
+ }
313
+ }
314
+ get classSize() {
315
+ if (this.mobileBreakpoint &&
316
+ this.currentWidth &&
317
+ this.currentWidth < this.mobileBreakpoint) {
318
+ return 'mobile';
319
+ }
320
+ return 'desktop';
321
+ }
322
+ get formatSize() {
323
+ if (this.mobileBreakpoint &&
324
+ this.currentWidth &&
325
+ this.currentWidth < this.mobileBreakpoint) {
326
+ return 'short';
327
+ }
328
+ return 'long';
329
+ }
330
+ static get styles() {
323
331
  return css `
324
332
  html {
325
333
  font-size: unset;
@@ -438,41 +446,41 @@ let TileList = class TileList extends LitElement {
438
446
  flex-direction: row;
439
447
  gap: 10px;
440
448
  }
441
- `;
442
- }
443
- };
444
- __decorate([
445
- property({ type: Object })
446
- ], TileList.prototype, "model", void 0);
447
- __decorate([
448
- property({ type: String })
449
- ], TileList.prototype, "baseNavigationUrl", void 0);
450
- __decorate([
451
- property({ type: Object })
452
- ], TileList.prototype, "collectionNameCache", void 0);
453
- __decorate([
454
- property({ type: Number })
455
- ], TileList.prototype, "currentWidth", void 0);
456
- __decorate([
457
- property({ type: Number })
458
- ], TileList.prototype, "currentHeight", void 0);
459
- __decorate([
460
- property({ type: Object })
461
- ], TileList.prototype, "sortParam", void 0);
462
- __decorate([
463
- property({ type: Number })
464
- ], TileList.prototype, "mobileBreakpoint", void 0);
465
- __decorate([
466
- state()
467
- ], TileList.prototype, "collectionLinks", void 0);
468
- __decorate([
469
- property({ type: String })
470
- ], TileList.prototype, "baseImageUrl", void 0);
471
- __decorate([
472
- property({ type: Boolean })
473
- ], TileList.prototype, "loggedIn", void 0);
474
- TileList = __decorate([
475
- customElement('tile-list')
476
- ], TileList);
477
- export { TileList };
449
+ `;
450
+ }
451
+ };
452
+ __decorate([
453
+ property({ type: Object })
454
+ ], TileList.prototype, "model", void 0);
455
+ __decorate([
456
+ property({ type: String })
457
+ ], TileList.prototype, "baseNavigationUrl", void 0);
458
+ __decorate([
459
+ property({ type: Object })
460
+ ], TileList.prototype, "collectionNameCache", void 0);
461
+ __decorate([
462
+ property({ type: Number })
463
+ ], TileList.prototype, "currentWidth", void 0);
464
+ __decorate([
465
+ property({ type: Number })
466
+ ], TileList.prototype, "currentHeight", void 0);
467
+ __decorate([
468
+ property({ type: Object })
469
+ ], TileList.prototype, "sortParam", void 0);
470
+ __decorate([
471
+ property({ type: Number })
472
+ ], TileList.prototype, "mobileBreakpoint", void 0);
473
+ __decorate([
474
+ state()
475
+ ], TileList.prototype, "collectionLinks", void 0);
476
+ __decorate([
477
+ property({ type: String })
478
+ ], TileList.prototype, "baseImageUrl", void 0);
479
+ __decorate([
480
+ property({ type: Boolean })
481
+ ], TileList.prototype, "loggedIn", void 0);
482
+ TileList = __decorate([
483
+ customElement('tile-list')
484
+ ], TileList);
485
+ export { TileList };
478
486
  //# sourceMappingURL=tile-list.js.map