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