@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.
Files changed (62) 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 +1 -1
  7. package/.prettierignore +1 -1
  8. package/LICENSE +661 -661
  9. package/README.md +83 -83
  10. package/dist/src/collection-browser.js +761 -761
  11. package/dist/src/collection-browser.js.map +1 -1
  12. package/dist/src/collection-facets/facets-template.js +5 -0
  13. package/dist/src/collection-facets/facets-template.js.map +1 -1
  14. package/dist/src/collection-facets/more-facets-content.d.ts +92 -8
  15. package/dist/src/collection-facets/more-facets-content.js +526 -84
  16. package/dist/src/collection-facets/more-facets-content.js.map +1 -1
  17. package/dist/src/collection-facets/more-facets-pagination.d.ts +12 -3
  18. package/dist/src/collection-facets/more-facets-pagination.js +69 -8
  19. package/dist/src/collection-facets/more-facets-pagination.js.map +1 -1
  20. package/dist/src/collection-facets/toggle-switch.js +1 -0
  21. package/dist/src/collection-facets/toggle-switch.js.map +1 -1
  22. package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
  23. package/dist/src/data-source/collection-browser-query-state.js.map +1 -1
  24. package/dist/src/sort-filter-bar/sort-filter-bar.js +280 -280
  25. package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
  26. package/dist/test/collection-browser.test.js +189 -189
  27. package/dist/test/collection-browser.test.js.map +1 -1
  28. package/dist/test/collection-facets/more-facets-content.test.js +162 -3
  29. package/dist/test/collection-facets/more-facets-content.test.js.map +1 -1
  30. package/dist/test/collection-facets/more-facets-pagination.test.js +63 -3
  31. package/dist/test/collection-facets/more-facets-pagination.test.js.map +1 -1
  32. package/dist/test/mocks/mock-search-responses.d.ts +5 -0
  33. package/dist/test/mocks/mock-search-responses.js +44 -0
  34. package/dist/test/mocks/mock-search-responses.js.map +1 -1
  35. package/dist/test/mocks/mock-search-service.js +2 -1
  36. package/dist/test/mocks/mock-search-service.js.map +1 -1
  37. package/dist/test/sort-filter-bar/sort-filter-bar.test.js +22 -22
  38. package/dist/test/sort-filter-bar/sort-filter-bar.test.js.map +1 -1
  39. package/eslint.config.mjs +53 -53
  40. package/index.html +24 -24
  41. package/local.archive.org.cert +86 -86
  42. package/local.archive.org.key +27 -27
  43. package/package.json +121 -120
  44. package/renovate.json +6 -6
  45. package/src/collection-browser.ts +3070 -3070
  46. package/src/collection-facets/facets-template.ts +5 -0
  47. package/src/collection-facets/more-facets-content.ts +566 -96
  48. package/src/collection-facets/more-facets-pagination.ts +80 -9
  49. package/src/collection-facets/toggle-switch.ts +1 -0
  50. package/src/data-source/collection-browser-data-source.ts +1444 -1444
  51. package/src/data-source/collection-browser-query-state.ts +60 -60
  52. package/src/sort-filter-bar/sort-filter-bar.ts +733 -733
  53. package/test/collection-browser.test.ts +2402 -2402
  54. package/test/collection-facets/more-facets-content.test.ts +251 -4
  55. package/test/collection-facets/more-facets-pagination.test.ts +87 -3
  56. package/test/mocks/mock-search-responses.ts +48 -0
  57. package/test/mocks/mock-search-service.ts +2 -0
  58. package/test/sort-filter-bar/sort-filter-bar.test.ts +443 -443
  59. package/tsconfig.json +25 -25
  60. package/web-dev-server.config.mjs +30 -30
  61. package/web-test-runner.config.mjs +52 -52
  62. 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
- @state() pages?: number[] = [];
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
- firstUpdated() {
31
- this.observePageCount();
32
- }
34
+ @state() pages?: number[] = [];
33
35
 
34
36
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
35
- override updated(changed: Map<string, any>) {
36
- if (changed.has('size')) {
37
- this.observePageCount();
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
- observePageCount() {
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
  }
@@ -62,6 +62,7 @@ export class ToggleSwitch extends LitElement {
62
62
  id="switch-button"
63
63
  class=${this.side}
64
64
  aria-hidden="true"
65
+ tabindex="-1"
65
66
  @click=${this.handleClick}
66
67
  >
67
68
  <div id="knob"></div>