@internetarchive/collection-browser 4.1.0 → 4.2.0-alpha-webdev8164.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +29 -29
- package/.github/workflows/ci.yml +27 -27
- 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 +1 -1
- package/.prettierignore +1 -1
- package/LICENSE +661 -661
- package/README.md +83 -83
- package/dist/src/collection-browser.js +761 -761
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/collection-facets/facets-template.js +5 -0
- package/dist/src/collection-facets/facets-template.js.map +1 -1
- package/dist/src/collection-facets/more-facets-content.d.ts +92 -8
- package/dist/src/collection-facets/more-facets-content.js +526 -84
- package/dist/src/collection-facets/more-facets-content.js.map +1 -1
- package/dist/src/collection-facets/more-facets-pagination.d.ts +12 -3
- package/dist/src/collection-facets/more-facets-pagination.js +69 -8
- package/dist/src/collection-facets/more-facets-pagination.js.map +1 -1
- package/dist/src/collection-facets/toggle-switch.js +1 -0
- package/dist/src/collection-facets/toggle-switch.js.map +1 -1
- package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
- package/dist/src/data-source/collection-browser-query-state.js.map +1 -1
- package/dist/src/sort-filter-bar/sort-filter-bar.js +280 -280
- package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
- package/dist/test/collection-browser.test.js +189 -189
- package/dist/test/collection-browser.test.js.map +1 -1
- package/dist/test/collection-facets/more-facets-content.test.js +162 -3
- package/dist/test/collection-facets/more-facets-content.test.js.map +1 -1
- package/dist/test/collection-facets/more-facets-pagination.test.js +63 -3
- package/dist/test/collection-facets/more-facets-pagination.test.js.map +1 -1
- package/dist/test/mocks/mock-search-responses.d.ts +5 -0
- package/dist/test/mocks/mock-search-responses.js +44 -0
- package/dist/test/mocks/mock-search-responses.js.map +1 -1
- package/dist/test/mocks/mock-search-service.js +2 -1
- package/dist/test/mocks/mock-search-service.js.map +1 -1
- package/dist/test/sort-filter-bar/sort-filter-bar.test.js +22 -22
- package/dist/test/sort-filter-bar/sort-filter-bar.test.js.map +1 -1
- package/eslint.config.mjs +53 -53
- package/index.html +24 -24
- package/local.archive.org.cert +86 -86
- package/local.archive.org.key +27 -27
- package/package.json +121 -120
- package/renovate.json +6 -6
- package/src/collection-browser.ts +3070 -3070
- package/src/collection-facets/facets-template.ts +5 -0
- package/src/collection-facets/more-facets-content.ts +566 -96
- package/src/collection-facets/more-facets-pagination.ts +80 -9
- package/src/collection-facets/toggle-switch.ts +1 -0
- package/src/data-source/collection-browser-data-source.ts +1444 -1444
- package/src/data-source/collection-browser-query-state.ts +60 -60
- package/src/sort-filter-bar/sort-filter-bar.ts +733 -733
- package/test/collection-browser.test.ts +2402 -2402
- package/test/collection-facets/more-facets-content.test.ts +251 -4
- package/test/collection-facets/more-facets-pagination.test.ts +87 -3
- package/test/mocks/mock-search-responses.ts +48 -0
- package/test/mocks/mock-search-service.ts +2 -0
- package/test/sort-filter-bar/sort-filter-bar.test.ts +443 -443
- package/tsconfig.json +25 -25
- package/web-dev-server.config.mjs +30 -30
- package/web-test-runner.config.mjs +52 -52
- package/.claude/settings.local.json +0 -8
|
@@ -25,19 +25,24 @@ export class MoreFacetsPagination extends LitElement {
|
|
|
25
25
|
|
|
26
26
|
@property({ type: Number }) currentPage: number = 1;
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
/**
|
|
29
|
+
* When true, shows a more compact set of page numbers
|
|
30
|
+
* (only 1 neighbor on each side of the current page).
|
|
31
|
+
*/
|
|
32
|
+
@property({ type: Boolean }) compact = false;
|
|
29
33
|
|
|
30
|
-
|
|
31
|
-
this.observePageCount();
|
|
32
|
-
}
|
|
34
|
+
@state() pages?: number[] = [];
|
|
33
35
|
|
|
34
36
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
35
|
-
override
|
|
36
|
-
if (
|
|
37
|
-
|
|
37
|
+
override willUpdate(changed: Map<string, any>) {
|
|
38
|
+
if (
|
|
39
|
+
changed.has('size') ||
|
|
40
|
+
changed.has('compact') ||
|
|
41
|
+
changed.has('currentPage')
|
|
42
|
+
) {
|
|
43
|
+
this.updatePages();
|
|
38
44
|
}
|
|
39
45
|
if (changed.has('currentPage')) {
|
|
40
|
-
this.observePageCount();
|
|
41
46
|
this.emitPageClick();
|
|
42
47
|
}
|
|
43
48
|
}
|
|
@@ -50,9 +55,14 @@ export class MoreFacetsPagination extends LitElement {
|
|
|
50
55
|
* - outlier: last page selected, show 1 ... N-2 N-1 _N_
|
|
51
56
|
* - outlier: if page count = 7, & selected is either [2, 3, 4, 5, 6], show all pages
|
|
52
57
|
*/
|
|
53
|
-
|
|
58
|
+
updatePages() {
|
|
54
59
|
this.pages = []; /* `0` is elipses marker */
|
|
55
60
|
|
|
61
|
+
if (this.compact) {
|
|
62
|
+
this.updatePagesCompact();
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
56
66
|
const paginatorMaxPagesToShow = 7;
|
|
57
67
|
const atMinThreshold = this.size <= paginatorMaxPagesToShow;
|
|
58
68
|
|
|
@@ -166,6 +176,52 @@ export class MoreFacetsPagination extends LitElement {
|
|
|
166
176
|
}
|
|
167
177
|
}
|
|
168
178
|
|
|
179
|
+
/**
|
|
180
|
+
* Compact page calculation: shows first, ..., prev, current, next, ..., last.
|
|
181
|
+
* Only 1 neighbor on each side of the current page for minimal width.
|
|
182
|
+
*/
|
|
183
|
+
private updatePagesCompact() {
|
|
184
|
+
if (this.size <= 3) {
|
|
185
|
+
this.pages = [...Array(this.size).keys()].map(i => i + 1);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const pages: number[] = [];
|
|
190
|
+
|
|
191
|
+
// First page
|
|
192
|
+
pages.push(1);
|
|
193
|
+
|
|
194
|
+
// Ellipsis after first if current is far enough away
|
|
195
|
+
if (this.currentPage > 3) {
|
|
196
|
+
pages.push(0);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
// Previous page (if not already shown as first)
|
|
200
|
+
if (this.currentPage - 1 > 1) {
|
|
201
|
+
pages.push(this.currentPage - 1);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Current page (if not first or last)
|
|
205
|
+
if (this.currentPage !== 1 && this.currentPage !== this.size) {
|
|
206
|
+
pages.push(this.currentPage);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
// Next page (if not already the last)
|
|
210
|
+
if (this.currentPage + 1 < this.size) {
|
|
211
|
+
pages.push(this.currentPage + 1);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// Ellipsis before last if current is far enough away
|
|
215
|
+
if (this.currentPage < this.size - 2) {
|
|
216
|
+
pages.push(0);
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// Last page
|
|
220
|
+
pages.push(this.size);
|
|
221
|
+
|
|
222
|
+
this.pages = pages;
|
|
223
|
+
}
|
|
224
|
+
|
|
169
225
|
private get getEllipsisTemplate() {
|
|
170
226
|
return html`<i class="ellipses">...</i>`;
|
|
171
227
|
}
|
|
@@ -250,6 +306,10 @@ export class MoreFacetsPagination extends LitElement {
|
|
|
250
306
|
margin-top: 10px;
|
|
251
307
|
background-color: #eee;
|
|
252
308
|
text-align: center;
|
|
309
|
+
display: flex;
|
|
310
|
+
align-items: center;
|
|
311
|
+
justify-content: center;
|
|
312
|
+
flex-wrap: nowrap;
|
|
253
313
|
}
|
|
254
314
|
.facets-pagination button {
|
|
255
315
|
border: none;
|
|
@@ -276,6 +336,7 @@ export class MoreFacetsPagination extends LitElement {
|
|
|
276
336
|
vertical-align: baseline;
|
|
277
337
|
display: inline-block;
|
|
278
338
|
min-width: 2.5rem;
|
|
339
|
+
font-family: inherit;
|
|
279
340
|
}
|
|
280
341
|
.facets-pagination i {
|
|
281
342
|
cursor: auto;
|
|
@@ -288,6 +349,16 @@ export class MoreFacetsPagination extends LitElement {
|
|
|
288
349
|
.page-numbers {
|
|
289
350
|
display: inline-block;
|
|
290
351
|
}
|
|
352
|
+
|
|
353
|
+
@media (max-width: 560px) {
|
|
354
|
+
.facets-pagination button,
|
|
355
|
+
.facets-pagination i {
|
|
356
|
+
margin: 5px 2px;
|
|
357
|
+
padding: 3px;
|
|
358
|
+
min-width: 2rem;
|
|
359
|
+
font-size: 1.2rem;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
291
362
|
`,
|
|
292
363
|
];
|
|
293
364
|
}
|