@internetarchive/collection-browser 3.3.1 → 3.3.3

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 (84) hide show
  1. package/.editorconfig +29 -29
  2. package/.github/workflows/ci.yml +27 -27
  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/.prettierignore +1 -1
  8. package/LICENSE +661 -661
  9. package/README.md +83 -83
  10. package/dist/src/collection-browser.js +683 -683
  11. package/dist/src/collection-browser.js.map +1 -1
  12. package/dist/src/collection-facets/more-facets-content.js +118 -118
  13. package/dist/src/collection-facets/more-facets-content.js.map +1 -1
  14. package/dist/src/collection-facets.js +265 -266
  15. package/dist/src/collection-facets.js.map +1 -1
  16. package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
  17. package/dist/src/data-source/collection-browser-query-state.js.map +1 -1
  18. package/dist/src/data-source/models.js.map +1 -1
  19. package/dist/src/tiles/base-tile-component.js.map +1 -1
  20. package/dist/src/tiles/grid/account-tile.js +36 -36
  21. package/dist/src/tiles/grid/account-tile.js.map +1 -1
  22. package/dist/src/tiles/grid/collection-tile.js +77 -77
  23. package/dist/src/tiles/grid/collection-tile.js.map +1 -1
  24. package/dist/src/tiles/grid/item-tile.js +137 -137
  25. package/dist/src/tiles/grid/item-tile.js.map +1 -1
  26. package/dist/src/tiles/hover/hover-pane-controller.d.ts +9 -1
  27. package/dist/src/tiles/hover/hover-pane-controller.js +105 -37
  28. package/dist/src/tiles/hover/hover-pane-controller.js.map +1 -1
  29. package/dist/src/tiles/hover/tile-hover-pane.d.ts +1 -0
  30. package/dist/src/tiles/hover/tile-hover-pane.js +115 -112
  31. package/dist/src/tiles/hover/tile-hover-pane.js.map +1 -1
  32. package/dist/src/tiles/list/tile-list-compact.js +99 -99
  33. package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
  34. package/dist/src/tiles/list/tile-list.js +297 -297
  35. package/dist/src/tiles/list/tile-list.js.map +1 -1
  36. package/dist/src/tiles/tile-dispatcher.d.ts +4 -1
  37. package/dist/src/tiles/tile-dispatcher.js +231 -204
  38. package/dist/src/tiles/tile-dispatcher.js.map +1 -1
  39. package/dist/src/utils/format-date.js.map +1 -1
  40. package/dist/test/collection-browser.test.js +189 -189
  41. package/dist/test/collection-browser.test.js.map +1 -1
  42. package/dist/test/tiles/grid/item-tile.test.js +77 -77
  43. package/dist/test/tiles/grid/item-tile.test.js.map +1 -1
  44. package/dist/test/tiles/hover/hover-pane-controller.test.js +68 -21
  45. package/dist/test/tiles/hover/hover-pane-controller.test.js.map +1 -1
  46. package/dist/test/tiles/list/tile-list-compact.test.js +70 -70
  47. package/dist/test/tiles/list/tile-list-compact.test.js.map +1 -1
  48. package/dist/test/tiles/list/tile-list.test.js +126 -126
  49. package/dist/test/tiles/list/tile-list.test.js.map +1 -1
  50. package/dist/test/tiles/tile-dispatcher.test.js +130 -52
  51. package/dist/test/tiles/tile-dispatcher.test.js.map +1 -1
  52. package/dist/test/utils/format-date.test.js.map +1 -1
  53. package/eslint.config.mjs +53 -53
  54. package/index.html +24 -24
  55. package/local.archive.org.cert +86 -86
  56. package/local.archive.org.key +27 -27
  57. package/package.json +118 -117
  58. package/renovate.json +6 -6
  59. package/src/collection-browser.ts +2829 -2829
  60. package/src/collection-facets/more-facets-content.ts +639 -639
  61. package/src/collection-facets.ts +994 -995
  62. package/src/data-source/collection-browser-data-source.ts +1401 -1401
  63. package/src/data-source/collection-browser-query-state.ts +65 -65
  64. package/src/data-source/models.ts +43 -43
  65. package/src/tiles/base-tile-component.ts +65 -65
  66. package/src/tiles/grid/account-tile.ts +113 -113
  67. package/src/tiles/grid/collection-tile.ts +163 -163
  68. package/src/tiles/grid/item-tile.ts +340 -340
  69. package/src/tiles/hover/hover-pane-controller.ts +613 -517
  70. package/src/tiles/hover/tile-hover-pane.ts +184 -180
  71. package/src/tiles/list/tile-list-compact.ts +239 -239
  72. package/src/tiles/list/tile-list.ts +700 -700
  73. package/src/tiles/tile-dispatcher.ts +517 -490
  74. package/src/utils/format-date.ts +62 -62
  75. package/test/collection-browser.test.ts +2403 -2403
  76. package/test/tiles/grid/item-tile.test.ts +520 -520
  77. package/test/tiles/hover/hover-pane-controller.test.ts +418 -353
  78. package/test/tiles/list/tile-list-compact.test.ts +282 -282
  79. package/test/tiles/list/tile-list.test.ts +552 -552
  80. package/test/tiles/tile-dispatcher.test.ts +283 -187
  81. package/test/utils/format-date.test.ts +89 -89
  82. package/tsconfig.json +20 -20
  83. package/web-dev-server.config.mjs +30 -30
  84. package/web-test-runner.config.mjs +41 -41
@@ -1,239 +1,239 @@
1
- import { css, html, nothing } from 'lit';
2
- import { customElement } from 'lit/decorators.js';
3
- import DOMPurify from 'dompurify';
4
- import type { SortParam } from '@internetarchive/search-service';
5
- import { BaseTileComponent } from '../base-tile-component';
6
-
7
- import { formatCount, NumberFormat } from '../../utils/format-count';
8
- import type { DateFormat } from '../../utils/format-date';
9
- import { isFirstMillisecondOfUTCYear } from '../../utils/local-date-from-utc';
10
-
11
- import '../image-block';
12
- import '../tile-mediatype-icon';
13
-
14
- @customElement('tile-list-compact')
15
- export class TileListCompact extends BaseTileComponent {
16
- /*
17
- * Reactive properties inherited from BaseTileComponent:
18
- * - model?: TileModel;
19
- * - currentWidth?: number;
20
- * - currentHeight?: number;
21
- * - baseNavigationUrl?: string;
22
- * - baseImageUrl?: string;
23
- * - collectionPagePath?: string;
24
- * - sortParam: SortParam | null = null;
25
- * - defaultSortParam: SortParam | null = null;
26
- * - creatorFilter?: string;
27
- * - mobileBreakpoint?: number;
28
- * - loggedIn = false;
29
- * - suppressBlurring = false;
30
- * - useLocalTime = false;
31
- */
32
-
33
- render() {
34
- return html`
35
- <div id="list-line" class="${this.classSize}">
36
- <image-block
37
- .model=${this.model}
38
- .baseImageUrl=${this.baseImageUrl}
39
- .isCompactTile=${true}
40
- .isListTile=${true}
41
- .viewSize=${this.classSize}
42
- .loggedIn=${this.loggedIn}
43
- .suppressBlurring=${this.suppressBlurring}
44
- >
45
- </image-block>
46
- <a href=${this.href} id="title"
47
- >${DOMPurify.sanitize(this.model?.title ?? '')}</a
48
- >
49
- <div id="creator">
50
- ${this.model?.mediatype === 'account'
51
- ? this.displayValueProvider.accountLabel
52
- : this.creator}
53
- </div>
54
- <div id="date">
55
- ${this.getFormattedDate(this.date, this.dateFormatSize)}
56
- </div>
57
- <div id="icon">
58
- <tile-mediatype-icon .model=${this.model}> </tile-mediatype-icon>
59
- </div>
60
- <div id="views">${formatCount(this.views ?? 0, this.formatSize)}</div>
61
- </div>
62
- `;
63
- }
64
-
65
- private get href(): string | typeof nothing {
66
- if (!this.model?.identifier || this.baseNavigationUrl == null)
67
- return nothing;
68
-
69
- // Use the server-specified href if available.
70
- // Otherwise, construct a details page URL from the item identifier.
71
- if (this.model.href) {
72
- return `${this.baseNavigationUrl}${this.model.href}`;
73
- }
74
-
75
- return this.displayValueProvider.itemPageUrl(
76
- this.model.identifier,
77
- this.model.mediatype === 'collection',
78
- );
79
- }
80
-
81
- private get creator(): string | typeof nothing {
82
- return this.displayValueProvider.firstCreatorMatchingFilter ?? nothing;
83
- }
84
-
85
- /*
86
- * TODO: fix field names to match model in src/collection-browser.ts
87
- * private get dateSortSelector()
88
- * @see src/models.ts
89
- */
90
- private get date(): Date | undefined {
91
- // Note on 'publicdate' vs. 'date':
92
- // The search engine metadata uses 'publicdate' as the key for the date the item
93
- // was created on archive.org, which in the UI is referred to as "Date Archived".
94
- // In contrast, the search engine metadata uses 'date' to refer to the actual
95
- // publication date of the underlying media ("Date Published" in the UI).
96
- // Refer to the full metadata schema for more info.
97
- switch (this.effectiveSort?.field) {
98
- case 'publicdate':
99
- return this.model?.dateArchived;
100
- case 'reviewdate':
101
- return this.model?.dateReviewed;
102
- case 'addeddate':
103
- return this.model?.dateAdded;
104
- default:
105
- return this.model?.datePublished;
106
- }
107
- }
108
-
109
- private get views(): number | undefined {
110
- return this.effectiveSort?.field === 'week'
111
- ? this.model?.weeklyViewCount // weekly views
112
- : this.model?.viewCount; // all-time views
113
- }
114
-
115
- /**
116
- * Returns the active sort param if one is set, or the default sort param otherwise.
117
- */
118
- private get effectiveSort(): SortParam | null {
119
- return this.sortParam ?? this.defaultSortParam;
120
- }
121
-
122
- private get classSize(): string {
123
- if (
124
- this.mobileBreakpoint &&
125
- this.currentWidth &&
126
- this.currentWidth < this.mobileBreakpoint
127
- ) {
128
- return 'mobile';
129
- }
130
- return 'desktop';
131
- }
132
-
133
- private get dateFormatSize(): DateFormat {
134
- // If we're showing a date published of Jan 1 at midnight, only show the year.
135
- // This is because items with only a year for their publication date are normalized to
136
- // Jan 1 at midnight timestamps in the search engine documents.
137
- if (
138
- (!this.isSortedByDate || this.effectiveSort?.field === 'date') && // Any sort except dates that aren't published date
139
- isFirstMillisecondOfUTCYear(this.model?.datePublished)
140
- ) {
141
- return 'year-only';
142
- }
143
- return this.formatSize;
144
- }
145
-
146
- private get formatSize(): NumberFormat {
147
- if (
148
- this.mobileBreakpoint &&
149
- this.currentWidth &&
150
- this.currentWidth < this.mobileBreakpoint
151
- ) {
152
- return 'short';
153
- }
154
- return 'long';
155
- }
156
-
157
- private get isSortedByDate(): boolean {
158
- return ['date', 'reviewdate', 'addeddate', 'publicdate'].includes(
159
- this.effectiveSort?.field as string,
160
- );
161
- }
162
-
163
- static get styles() {
164
- return css`
165
- html {
166
- font-size: unset;
167
- }
168
-
169
- div {
170
- font-size: 14px;
171
- }
172
-
173
- #list-line {
174
- display: grid;
175
- column-gap: 10px;
176
- border-top: 1px solid #ddd;
177
- align-items: center;
178
- line-height: 20px;
179
- padding-top: 5px;
180
- margin-bottom: -5px;
181
- }
182
-
183
- #list-line.mobile {
184
- grid-template-columns: 36px 3fr 2fr 68px 35px;
185
- }
186
-
187
- #list-line.desktop {
188
- grid-template-columns: 51px 3fr 2fr 95px 30px 60px;
189
- }
190
-
191
- #list-line:hover #title {
192
- text-decoration: underline;
193
- }
194
-
195
- #title {
196
- text-decoration: none;
197
- }
198
-
199
- #title:link {
200
- color: var(--ia-theme-link-color, #4b64ff);
201
- }
202
-
203
- #title,
204
- #creator {
205
- text-overflow: ellipsis;
206
- overflow: hidden;
207
- white-space: nowrap;
208
- }
209
-
210
- #icon {
211
- margin-left: 2px;
212
- }
213
-
214
- #views {
215
- text-align: right;
216
- padding-right: 8px;
217
- }
218
-
219
- .mobile #views {
220
- display: none;
221
- }
222
-
223
- .mobile tile-mediatype-icon {
224
- --iconHeight: 14px;
225
- --iconWidth: 14px;
226
- }
227
-
228
- .desktop #icon {
229
- --iconHeight: 20px;
230
- --iconWidth: 20px;
231
- }
232
-
233
- item-image {
234
- --imgHeight: 100%;
235
- --imgWidth: 100%;
236
- }
237
- `;
238
- }
239
- }
1
+ import { css, html, nothing } from 'lit';
2
+ import { customElement } from 'lit/decorators.js';
3
+ import DOMPurify from 'dompurify';
4
+ import type { SortParam } from '@internetarchive/search-service';
5
+ import { BaseTileComponent } from '../base-tile-component';
6
+
7
+ import { formatCount, NumberFormat } from '../../utils/format-count';
8
+ import type { DateFormat } from '../../utils/format-date';
9
+ import { isFirstMillisecondOfUTCYear } from '../../utils/local-date-from-utc';
10
+
11
+ import '../image-block';
12
+ import '../tile-mediatype-icon';
13
+
14
+ @customElement('tile-list-compact')
15
+ export class TileListCompact extends BaseTileComponent {
16
+ /*
17
+ * Reactive properties inherited from BaseTileComponent:
18
+ * - model?: TileModel;
19
+ * - currentWidth?: number;
20
+ * - currentHeight?: number;
21
+ * - baseNavigationUrl?: string;
22
+ * - baseImageUrl?: string;
23
+ * - collectionPagePath?: string;
24
+ * - sortParam: SortParam | null = null;
25
+ * - defaultSortParam: SortParam | null = null;
26
+ * - creatorFilter?: string;
27
+ * - mobileBreakpoint?: number;
28
+ * - loggedIn = false;
29
+ * - suppressBlurring = false;
30
+ * - useLocalTime = false;
31
+ */
32
+
33
+ render() {
34
+ return html`
35
+ <div id="list-line" class="${this.classSize}">
36
+ <image-block
37
+ .model=${this.model}
38
+ .baseImageUrl=${this.baseImageUrl}
39
+ .isCompactTile=${true}
40
+ .isListTile=${true}
41
+ .viewSize=${this.classSize}
42
+ .loggedIn=${this.loggedIn}
43
+ .suppressBlurring=${this.suppressBlurring}
44
+ >
45
+ </image-block>
46
+ <a href=${this.href} id="title"
47
+ >${DOMPurify.sanitize(this.model?.title ?? '')}</a
48
+ >
49
+ <div id="creator">
50
+ ${this.model?.mediatype === 'account'
51
+ ? this.displayValueProvider.accountLabel
52
+ : this.creator}
53
+ </div>
54
+ <div id="date">
55
+ ${this.getFormattedDate(this.date, this.dateFormatSize)}
56
+ </div>
57
+ <div id="icon">
58
+ <tile-mediatype-icon .model=${this.model}> </tile-mediatype-icon>
59
+ </div>
60
+ <div id="views">${formatCount(this.views ?? 0, this.formatSize)}</div>
61
+ </div>
62
+ `;
63
+ }
64
+
65
+ private get href(): string | typeof nothing {
66
+ if (!this.model?.identifier || this.baseNavigationUrl == null)
67
+ return nothing;
68
+
69
+ // Use the server-specified href if available.
70
+ // Otherwise, construct a details page URL from the item identifier.
71
+ if (this.model.href) {
72
+ return `${this.baseNavigationUrl}${this.model.href}`;
73
+ }
74
+
75
+ return this.displayValueProvider.itemPageUrl(
76
+ this.model.identifier,
77
+ this.model.mediatype === 'collection',
78
+ );
79
+ }
80
+
81
+ private get creator(): string | typeof nothing {
82
+ return this.displayValueProvider.firstCreatorMatchingFilter ?? nothing;
83
+ }
84
+
85
+ /*
86
+ * TODO: fix field names to match model in src/collection-browser.ts
87
+ * private get dateSortSelector()
88
+ * @see src/models.ts
89
+ */
90
+ private get date(): Date | undefined {
91
+ // Note on 'publicdate' vs. 'date':
92
+ // The search engine metadata uses 'publicdate' as the key for the date the item
93
+ // was created on archive.org, which in the UI is referred to as "Date Archived".
94
+ // In contrast, the search engine metadata uses 'date' to refer to the actual
95
+ // publication date of the underlying media ("Date Published" in the UI).
96
+ // Refer to the full metadata schema for more info.
97
+ switch (this.effectiveSort?.field) {
98
+ case 'publicdate':
99
+ return this.model?.dateArchived;
100
+ case 'reviewdate':
101
+ return this.model?.dateReviewed;
102
+ case 'addeddate':
103
+ return this.model?.dateAdded;
104
+ default:
105
+ return this.model?.datePublished;
106
+ }
107
+ }
108
+
109
+ private get views(): number | undefined {
110
+ return this.effectiveSort?.field === 'week'
111
+ ? this.model?.weeklyViewCount // weekly views
112
+ : this.model?.viewCount; // all-time views
113
+ }
114
+
115
+ /**
116
+ * Returns the active sort param if one is set, or the default sort param otherwise.
117
+ */
118
+ private get effectiveSort(): SortParam | null {
119
+ return this.sortParam ?? this.defaultSortParam;
120
+ }
121
+
122
+ private get classSize(): string {
123
+ if (
124
+ this.mobileBreakpoint &&
125
+ this.currentWidth &&
126
+ this.currentWidth < this.mobileBreakpoint
127
+ ) {
128
+ return 'mobile';
129
+ }
130
+ return 'desktop';
131
+ }
132
+
133
+ private get dateFormatSize(): DateFormat {
134
+ // If we're showing a date published of Jan 1 at midnight, only show the year.
135
+ // This is because items with only a year for their publication date are normalized to
136
+ // Jan 1 at midnight timestamps in the search engine documents.
137
+ if (
138
+ (!this.isSortedByDate || this.effectiveSort?.field === 'date') && // Any sort except dates that aren't published date
139
+ isFirstMillisecondOfUTCYear(this.model?.datePublished)
140
+ ) {
141
+ return 'year-only';
142
+ }
143
+ return this.formatSize;
144
+ }
145
+
146
+ private get formatSize(): NumberFormat {
147
+ if (
148
+ this.mobileBreakpoint &&
149
+ this.currentWidth &&
150
+ this.currentWidth < this.mobileBreakpoint
151
+ ) {
152
+ return 'short';
153
+ }
154
+ return 'long';
155
+ }
156
+
157
+ private get isSortedByDate(): boolean {
158
+ return ['date', 'reviewdate', 'addeddate', 'publicdate'].includes(
159
+ this.effectiveSort?.field as string,
160
+ );
161
+ }
162
+
163
+ static get styles() {
164
+ return css`
165
+ html {
166
+ font-size: unset;
167
+ }
168
+
169
+ div {
170
+ font-size: 14px;
171
+ }
172
+
173
+ #list-line {
174
+ display: grid;
175
+ column-gap: 10px;
176
+ border-top: 1px solid #ddd;
177
+ align-items: center;
178
+ line-height: 20px;
179
+ padding-top: 5px;
180
+ margin-bottom: -5px;
181
+ }
182
+
183
+ #list-line.mobile {
184
+ grid-template-columns: 36px 3fr 2fr 68px 35px;
185
+ }
186
+
187
+ #list-line.desktop {
188
+ grid-template-columns: 51px 3fr 2fr 95px 30px 60px;
189
+ }
190
+
191
+ #list-line:hover #title {
192
+ text-decoration: underline;
193
+ }
194
+
195
+ #title {
196
+ text-decoration: none;
197
+ }
198
+
199
+ #title:link {
200
+ color: var(--ia-theme-link-color, #4b64ff);
201
+ }
202
+
203
+ #title,
204
+ #creator {
205
+ text-overflow: ellipsis;
206
+ overflow: hidden;
207
+ white-space: nowrap;
208
+ }
209
+
210
+ #icon {
211
+ margin-left: 2px;
212
+ }
213
+
214
+ #views {
215
+ text-align: right;
216
+ padding-right: 8px;
217
+ }
218
+
219
+ .mobile #views {
220
+ display: none;
221
+ }
222
+
223
+ .mobile tile-mediatype-icon {
224
+ --iconHeight: 14px;
225
+ --iconWidth: 14px;
226
+ }
227
+
228
+ .desktop #icon {
229
+ --iconHeight: 20px;
230
+ --iconWidth: 20px;
231
+ }
232
+
233
+ item-image {
234
+ --imgHeight: 100%;
235
+ --imgWidth: 100%;
236
+ }
237
+ `;
238
+ }
239
+ }