@internetarchive/collection-browser 1.14.17-alpha.2 → 1.14.17-alpha.21

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 (87) hide show
  1. package/dist/index.js +1 -1
  2. package/dist/index.js.map +1 -1
  3. package/dist/src/app-root.d.ts +1 -0
  4. package/dist/src/app-root.js +38 -0
  5. package/dist/src/app-root.js.map +1 -1
  6. package/dist/src/collection-browser.d.ts +2 -15
  7. package/dist/src/collection-browser.js +22 -29
  8. package/dist/src/collection-browser.js.map +1 -1
  9. package/dist/src/data-source/collection-browser-data-source.d.ts +55 -32
  10. package/dist/src/data-source/collection-browser-data-source.js +155 -162
  11. package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
  12. package/dist/src/data-source/models.d.ts +6 -3
  13. package/dist/src/data-source/models.js.map +1 -1
  14. package/dist/src/manage/manage-bar.d.ts +1 -1
  15. package/dist/src/manage/manage-bar.js.map +1 -1
  16. package/dist/src/models.d.ts +20 -4
  17. package/dist/src/models.js +105 -0
  18. package/dist/src/models.js.map +1 -1
  19. package/dist/src/sort-filter-bar/sort-filter-bar.js +25 -16
  20. package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
  21. package/dist/src/tiles/grid/item-tile.d.ts +1 -0
  22. package/dist/src/tiles/grid/item-tile.js +28 -1
  23. package/dist/src/tiles/grid/item-tile.js.map +1 -1
  24. package/dist/src/tiles/grid/tile-stats.js +13 -8
  25. package/dist/src/tiles/grid/tile-stats.js.map +1 -1
  26. package/dist/src/tiles/list/tile-list-compact.js +1 -1
  27. package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
  28. package/dist/src/tiles/list/tile-list.d.ts +1 -0
  29. package/dist/src/tiles/list/tile-list.js +32 -1
  30. package/dist/src/tiles/list/tile-list.js.map +1 -1
  31. package/dist/src/tiles/tile-dispatcher.js +3 -2
  32. package/dist/src/tiles/tile-dispatcher.js.map +1 -1
  33. package/dist/src/tiles/tile-display-value-provider.d.ts +6 -2
  34. package/dist/src/tiles/tile-display-value-provider.js +15 -1
  35. package/dist/src/tiles/tile-display-value-provider.js.map +1 -1
  36. package/dist/src/utils/collapse-repeated-quotes.d.ts +11 -0
  37. package/dist/src/utils/collapse-repeated-quotes.js +14 -0
  38. package/dist/src/utils/collapse-repeated-quotes.js.map +1 -0
  39. package/dist/src/utils/resolve-mediatype.d.ts +8 -0
  40. package/dist/src/utils/resolve-mediatype.js +24 -0
  41. package/dist/src/utils/resolve-mediatype.js.map +1 -0
  42. package/dist/test/collection-browser.test.js +39 -19
  43. package/dist/test/collection-browser.test.js.map +1 -1
  44. package/dist/test/collection-facets/more-facets-content.test.js +2 -2
  45. package/dist/test/collection-facets/more-facets-content.test.js.map +1 -1
  46. package/dist/test/collection-facets.test.js +5 -0
  47. package/dist/test/collection-facets.test.js.map +1 -1
  48. package/dist/test/item-image.test.js +33 -34
  49. package/dist/test/item-image.test.js.map +1 -1
  50. package/dist/test/mocks/mock-search-responses.d.ts +1 -0
  51. package/dist/test/mocks/mock-search-responses.js +62 -0
  52. package/dist/test/mocks/mock-search-responses.js.map +1 -1
  53. package/dist/test/sort-filter-bar/sort-filter-bar.test.js +41 -4
  54. package/dist/test/sort-filter-bar/sort-filter-bar.test.js.map +1 -1
  55. package/dist/test/tiles/hover/hover-pane-controller.test.js +18 -17
  56. package/dist/test/tiles/hover/hover-pane-controller.test.js.map +1 -1
  57. package/package.json +2 -2
  58. package/src/app-root.ts +39 -0
  59. package/src/collection-browser.ts +24 -40
  60. package/src/data-source/collection-browser-data-source.ts +160 -132
  61. package/src/data-source/models.ts +6 -2
  62. package/src/manage/manage-bar.ts +1 -1
  63. package/src/models.ts +154 -3
  64. package/src/sort-filter-bar/sort-filter-bar.ts +26 -16
  65. package/src/tiles/grid/item-tile.ts +36 -1
  66. package/src/tiles/grid/tile-stats.ts +12 -7
  67. package/src/tiles/list/tile-list-compact.ts +1 -1
  68. package/src/tiles/list/tile-list.ts +43 -5
  69. package/src/tiles/tile-dispatcher.ts +2 -1
  70. package/src/tiles/tile-display-value-provider.ts +20 -2
  71. package/src/utils/collapse-repeated-quotes.ts +13 -0
  72. package/src/utils/resolve-mediatype.ts +26 -0
  73. package/test/collection-browser.test.ts +74 -19
  74. package/test/collection-facets/more-facets-content.test.ts +4 -2
  75. package/test/collection-facets.test.ts +5 -0
  76. package/test/item-image.test.ts +34 -36
  77. package/test/mocks/mock-search-responses.ts +66 -0
  78. package/test/sort-filter-bar/sort-filter-bar.test.ts +50 -4
  79. package/test/tiles/hover/hover-pane-controller.test.ts +19 -17
  80. package/dist/src/data-source/data-source-fetch-provider.d.ts +0 -13
  81. package/dist/src/data-source/data-source-fetch-provider.js +0 -61
  82. package/dist/src/data-source/data-source-fetch-provider.js.map +0 -1
  83. package/dist/src/selected-facets.d.ts +0 -67
  84. package/dist/src/selected-facets.js +0 -149
  85. package/dist/src/selected-facets.js.map +0 -1
  86. package/src/data-source/data-source-fetch-provider.ts +0 -79
  87. package/src/selected-facets.ts +0 -216
package/src/app-root.ts CHANGED
@@ -395,6 +395,31 @@ export class AppRoot extends LitElement {
395
395
  </label>
396
396
  </div>
397
397
  </fieldset>
398
+
399
+ <fieldset class="user-profile-controls">
400
+ <legend>Set Placeholder Types</legend>
401
+ <div class="checkbox-control">
402
+ <input
403
+ id="enable-loading-placeholder"
404
+ type="radio"
405
+ @click=${() => this.setPlaceholderType('loading-placeholder')}
406
+ name="placeholder-radio"
407
+ />
408
+ <label for="enable-loading-placeholder"
409
+ >Loading Placeholder</label
410
+ >
411
+ </div>
412
+ <div class="checkbox-control">
413
+ <input
414
+ id="enable-empty-placeholder"
415
+ type="radio"
416
+ @click=${() => this.setPlaceholderType('error-placeholder')}
417
+ value="empty-placeholder"
418
+ name="placeholder-radio"
419
+ />
420
+ <label for="enable-empty-placeholder">Empty Placeholder</label>
421
+ </div>
422
+ </fieldset>
398
423
  </div>
399
424
  <button id="toggle-dev-tools-btn" @click=${this.toggleDevTools}>
400
425
  Toggle Search Controls
@@ -427,6 +452,20 @@ export class AppRoot extends LitElement {
427
452
  `;
428
453
  }
429
454
 
455
+ private async setPlaceholderType(type: String) {
456
+ switch (type) {
457
+ case 'loading-placeholder':
458
+ this.collectionBrowser.baseQuery = '';
459
+ this.collectionBrowser.suppressPlaceholders = true;
460
+ this.collectionBrowser.clearResultsOnEmptyQuery = true;
461
+ this.requestUpdate();
462
+ await this.collectionBrowser.updateComplete;
463
+ break;
464
+ default:
465
+ break;
466
+ }
467
+ }
468
+
430
469
  private baseQueryChanged(e: CustomEvent<{ baseQuery?: string }>): void {
431
470
  this.searchQuery = e.detail.baseQuery;
432
471
  }
@@ -18,6 +18,7 @@ import type {
18
18
  } from '@internetarchive/infinite-scroller';
19
19
  import {
20
20
  CollectionExtraInfo,
21
+ PageElementName,
21
22
  SearchServiceInterface,
22
23
  SearchType,
23
24
  SortDirection,
@@ -97,7 +98,7 @@ export class CollectionBrowser
97
98
 
98
99
  @property({ type: String }) withinProfile?: string;
99
100
 
100
- @property({ type: String }) profileElement?: string;
101
+ @property({ type: String }) profileElement?: PageElementName;
101
102
 
102
103
  @property({ type: String }) baseQuery?: string;
103
104
 
@@ -236,11 +237,6 @@ export class CollectionBrowser
236
237
  */
237
238
  private isScrollingToCell = false;
238
239
 
239
- /**
240
- * When we've reached the end of the data, stop trying to fetch more
241
- */
242
- private endOfDataReached = false;
243
-
244
240
  /**
245
241
  * When page width resizes from desktop to mobile, set true to
246
242
  * disable expand/collapse transition when loading.
@@ -332,6 +328,7 @@ export class CollectionBrowser
332
328
  * Sets the state for whether the initial set of search results is loading in.
333
329
  */
334
330
  setSearchResultsLoading(loading: boolean): void {
331
+ console.log('setting search results loading to', loading);
335
332
  this.searchResultsLoading = loading;
336
333
  }
337
334
 
@@ -339,6 +336,7 @@ export class CollectionBrowser
339
336
  * Sets the state for whether facet data is loading in
340
337
  */
341
338
  setFacetsLoading(loading: boolean): void {
339
+ console.log('setting facets loading to', loading);
342
340
  this.facetsLoading = loading;
343
341
  }
344
342
 
@@ -645,8 +643,8 @@ export class CollectionBrowser
645
643
  showSelectAll
646
644
  showUnselectAll
647
645
  @removeItems=${this.handleRemoveItems}
648
- @selectAll=${this.dataSource.checkAllTiles}
649
- @unselectAll=${this.dataSource.uncheckAllTiles}
646
+ @selectAll=${() => this.dataSource.checkAllTiles()}
647
+ @unselectAll=${() => this.dataSource.uncheckAllTiles()}
650
648
  @cancel=${() => {
651
649
  this.isManageView = false;
652
650
  this.dataSource.uncheckAllTiles();
@@ -663,10 +661,11 @@ export class CollectionBrowser
663
661
  this.dispatchEvent(
664
662
  new CustomEvent<{ items: ManageableItem[] }>('itemRemovalRequested', {
665
663
  detail: {
666
- items: this.dataSource.checkedTileModels.map(model => ({
667
- ...model,
668
- date: formatDate(model.datePublished, 'long'),
669
- })),
664
+ items: this.dataSource.checkedTileModels.map(model => {
665
+ const cloned = model.clone();
666
+ cloned.dateStr = formatDate(model.datePublished, 'long');
667
+ return cloned as ManageableItem;
668
+ }),
670
669
  },
671
670
  })
672
671
  );
@@ -1048,6 +1047,12 @@ export class CollectionBrowser
1048
1047
  }
1049
1048
  }
1050
1049
 
1050
+ // Ensure obsolete data sources do not linger as reactive controllers indefinitely
1051
+ if (changed.has('dataSource')) {
1052
+ const oldDataSource = changed.get('dataSource');
1053
+ if (oldDataSource) this.removeController(oldDataSource);
1054
+ }
1055
+
1051
1056
  if (changed.has('baseQuery')) {
1052
1057
  this.emitBaseQueryChanged();
1053
1058
  }
@@ -1119,7 +1124,7 @@ export class CollectionBrowser
1119
1124
  }
1120
1125
 
1121
1126
  if (changed.has('pagesToRender')) {
1122
- if (!this.endOfDataReached && this.infiniteScroller) {
1127
+ if (!this.dataSource.endOfDataReached && this.infiniteScroller) {
1123
1128
  this.infiniteScroller.itemCount = this.estimatedTileCount;
1124
1129
  }
1125
1130
  }
@@ -1334,19 +1339,6 @@ export class CollectionBrowser
1334
1339
  // this lets us store the query key so we know if it's actually changed or not
1335
1340
  private previousQueryKey?: string;
1336
1341
 
1337
- /**
1338
- * Internal property to store the `resolve` function for the most recent
1339
- * `initialSearchComplete` promise, allowing us to resolve it at the appropriate time.
1340
- */
1341
- private _initialSearchCompleteResolver!: (val: boolean) => void;
1342
-
1343
- /**
1344
- * Internal property to store the private value backing the `initialSearchComplete` getter.
1345
- */
1346
- private _initialSearchCompletePromise: Promise<boolean> = new Promise(res => {
1347
- this._initialSearchCompleteResolver = res;
1348
- });
1349
-
1350
1342
  /**
1351
1343
  * A Promise which, after each query change, resolves once the fetches for the initial
1352
1344
  * search have completed. Waits for *both* the hits and aggregations fetches to finish.
@@ -1355,7 +1347,7 @@ export class CollectionBrowser
1355
1347
  * one, to ensure you do not await an obsolete promise from the previous update.
1356
1348
  */
1357
1349
  get initialSearchComplete(): Promise<boolean> {
1358
- return this._initialSearchCompletePromise;
1350
+ return this.dataSource.initialSearchComplete;
1359
1351
  }
1360
1352
 
1361
1353
  private async handleQueryChange() {
@@ -1389,7 +1381,6 @@ export class CollectionBrowser
1389
1381
 
1390
1382
  this.tileModelOffset = 0;
1391
1383
  this.totalResults = undefined;
1392
- this.endOfDataReached = false;
1393
1384
  this.pagesToRender =
1394
1385
  this.initialPageNumber === 1
1395
1386
  ? 2 // First two pages are batched into one request when starting from page 1
@@ -1420,16 +1411,8 @@ export class CollectionBrowser
1420
1411
  }
1421
1412
  this.historyPopOccurred = false;
1422
1413
 
1423
- // Reset the `initialSearchComplete` promise with a new value for the imminent search
1424
- this._initialSearchCompletePromise = new Promise(res => {
1425
- this._initialSearchCompleteResolver = res;
1426
- });
1427
-
1428
1414
  // Fire the initial page and facets requests
1429
- await this.dataSource.handleQueryChange();
1430
-
1431
- // Resolve the `initialSearchComplete` promise for this search
1432
- this._initialSearchCompleteResolver(true);
1415
+ //await this.dataSource.handleQueryChange();
1433
1416
  }
1434
1417
 
1435
1418
  private setupStateRestorationObserver() {
@@ -1554,6 +1537,7 @@ export class CollectionBrowser
1554
1537
  * Sets the total number of tiles displayed in the infinite scroller.
1555
1538
  */
1556
1539
  setTileCount(count: number): void {
1540
+ console.log('Setting scroller tile count to', count);
1557
1541
  if (this.infiniteScroller) {
1558
1542
  this.infiniteScroller.itemCount = count;
1559
1543
  }
@@ -1716,7 +1700,7 @@ export class CollectionBrowser
1716
1700
  * increase the number of pages to render and start fetching data for the new page
1717
1701
  */
1718
1702
  private scrollThresholdReached() {
1719
- if (!this.endOfDataReached) {
1703
+ if (!this.dataSource.endOfDataReached) {
1720
1704
  this.pagesToRender += 1;
1721
1705
  this.dataSource.fetchPage(this.pagesToRender);
1722
1706
  }
@@ -2040,9 +2024,9 @@ export class CollectionBrowser
2040
2024
  --collectionBrowserCellMinWidth,
2041
2025
  100%
2042
2026
  );
2043
- --infiniteScrollerCellMinHeight: 34px; /* override infinite scroller component */
2027
+ --infiniteScrollerCellMinHeight: 45px; /* override infinite scroller component */
2044
2028
  --infiniteScrollerCellMaxHeight: 56px;
2045
- --infiniteScrollerRowGap: 0px;
2029
+ --infiniteScrollerRowGap: 10px;
2046
2030
  }
2047
2031
 
2048
2032
  infinite-scroller.list-detail {