@internetarchive/collection-browser 4.1.0 → 4.2.0-alpha-webdev8164.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.
- 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 +95 -8
- package/dist/src/collection-facets/more-facets-content.js +576 -102
- 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 +71 -9
- 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 +625 -113
- package/src/collection-facets/more-facets-pagination.ts +84 -10
- 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,27 @@ 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
|
-
if (
|
|
40
|
-
|
|
45
|
+
if (
|
|
46
|
+
changed.has('currentPage') &&
|
|
47
|
+
changed.get('currentPage') !== undefined
|
|
48
|
+
) {
|
|
41
49
|
this.emitPageClick();
|
|
42
50
|
}
|
|
43
51
|
}
|
|
@@ -50,9 +58,14 @@ export class MoreFacetsPagination extends LitElement {
|
|
|
50
58
|
* - outlier: last page selected, show 1 ... N-2 N-1 _N_
|
|
51
59
|
* - outlier: if page count = 7, & selected is either [2, 3, 4, 5, 6], show all pages
|
|
52
60
|
*/
|
|
53
|
-
|
|
61
|
+
updatePages() {
|
|
54
62
|
this.pages = []; /* `0` is elipses marker */
|
|
55
63
|
|
|
64
|
+
if (this.compact) {
|
|
65
|
+
this.updatePagesCompact();
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
|
|
56
69
|
const paginatorMaxPagesToShow = 7;
|
|
57
70
|
const atMinThreshold = this.size <= paginatorMaxPagesToShow;
|
|
58
71
|
|
|
@@ -166,6 +179,52 @@ export class MoreFacetsPagination extends LitElement {
|
|
|
166
179
|
}
|
|
167
180
|
}
|
|
168
181
|
|
|
182
|
+
/**
|
|
183
|
+
* Compact page calculation: shows first, ..., prev, current, next, ..., last.
|
|
184
|
+
* Only 1 neighbor on each side of the current page for minimal width.
|
|
185
|
+
*/
|
|
186
|
+
private updatePagesCompact() {
|
|
187
|
+
if (this.size <= 3) {
|
|
188
|
+
this.pages = [...Array(this.size).keys()].map(i => i + 1);
|
|
189
|
+
return;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const pages: number[] = [];
|
|
193
|
+
|
|
194
|
+
// First page
|
|
195
|
+
pages.push(1);
|
|
196
|
+
|
|
197
|
+
// Ellipsis after first if current is far enough away
|
|
198
|
+
if (this.currentPage > 3) {
|
|
199
|
+
pages.push(0);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Previous page (if not already shown as first)
|
|
203
|
+
if (this.currentPage - 1 > 1) {
|
|
204
|
+
pages.push(this.currentPage - 1);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
// Current page (if not first or last)
|
|
208
|
+
if (this.currentPage !== 1 && this.currentPage !== this.size) {
|
|
209
|
+
pages.push(this.currentPage);
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Next page (if not already the last)
|
|
213
|
+
if (this.currentPage + 1 < this.size) {
|
|
214
|
+
pages.push(this.currentPage + 1);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// Ellipsis before last if current is far enough away
|
|
218
|
+
if (this.currentPage < this.size - 2) {
|
|
219
|
+
pages.push(0);
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// Last page
|
|
223
|
+
pages.push(this.size);
|
|
224
|
+
|
|
225
|
+
this.pages = pages;
|
|
226
|
+
}
|
|
227
|
+
|
|
169
228
|
private get getEllipsisTemplate() {
|
|
170
229
|
return html`<i class="ellipses">...</i>`;
|
|
171
230
|
}
|
|
@@ -250,6 +309,10 @@ export class MoreFacetsPagination extends LitElement {
|
|
|
250
309
|
margin-top: 10px;
|
|
251
310
|
background-color: #eee;
|
|
252
311
|
text-align: center;
|
|
312
|
+
display: flex;
|
|
313
|
+
align-items: center;
|
|
314
|
+
justify-content: center;
|
|
315
|
+
flex-wrap: nowrap;
|
|
253
316
|
}
|
|
254
317
|
.facets-pagination button {
|
|
255
318
|
border: none;
|
|
@@ -276,6 +339,7 @@ export class MoreFacetsPagination extends LitElement {
|
|
|
276
339
|
vertical-align: baseline;
|
|
277
340
|
display: inline-block;
|
|
278
341
|
min-width: 2.5rem;
|
|
342
|
+
font-family: inherit;
|
|
279
343
|
}
|
|
280
344
|
.facets-pagination i {
|
|
281
345
|
cursor: auto;
|
|
@@ -288,6 +352,16 @@ export class MoreFacetsPagination extends LitElement {
|
|
|
288
352
|
.page-numbers {
|
|
289
353
|
display: inline-block;
|
|
290
354
|
}
|
|
355
|
+
|
|
356
|
+
@media (max-width: 560px) {
|
|
357
|
+
.facets-pagination button,
|
|
358
|
+
.facets-pagination i {
|
|
359
|
+
margin: 5px 2px;
|
|
360
|
+
padding: 3px;
|
|
361
|
+
min-width: 2rem;
|
|
362
|
+
font-size: 1.2rem;
|
|
363
|
+
}
|
|
364
|
+
}
|
|
291
365
|
`,
|
|
292
366
|
];
|
|
293
367
|
}
|