@internetarchive/collection-browser 2.6.0 → 2.6.2-alpha.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 (40) hide show
  1. package/dist/src/collection-browser.d.ts +6 -3
  2. package/dist/src/collection-browser.js +21 -21
  3. package/dist/src/collection-browser.js.map +1 -1
  4. package/dist/src/collection-facets/facet-row.js +3 -0
  5. package/dist/src/collection-facets/facet-row.js.map +1 -1
  6. package/dist/src/collection-facets/facets-template.js +3 -1
  7. package/dist/src/collection-facets/facets-template.js.map +1 -1
  8. package/dist/src/collection-facets.js +20 -2
  9. package/dist/src/collection-facets.js.map +1 -1
  10. package/dist/src/data-source/collection-browser-data-source.js +2 -2
  11. package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
  12. package/dist/src/data-source/collection-browser-query-state.d.ts +1 -1
  13. package/dist/src/data-source/collection-browser-query-state.js.map +1 -1
  14. package/dist/src/empty-placeholder.js +18 -5
  15. package/dist/src/empty-placeholder.js.map +1 -1
  16. package/dist/src/sort-filter-bar/sort-filter-bar.d.ts +1 -0
  17. package/dist/src/sort-filter-bar/sort-filter-bar.js +4 -0
  18. package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
  19. package/dist/src/tiles/base-tile-component.js +3 -2
  20. package/dist/src/tiles/base-tile-component.js.map +1 -1
  21. package/dist/src/tiles/grid/item-tile.d.ts +4 -0
  22. package/dist/src/tiles/grid/item-tile.js +12 -3
  23. package/dist/src/tiles/grid/item-tile.js.map +1 -1
  24. package/dist/src/tiles/grid/tile-stats.d.ts +1 -1
  25. package/dist/src/tiles/grid/tile-stats.js.map +1 -1
  26. package/dist/src/tiles/tile-dispatcher.js +8 -4
  27. package/dist/src/tiles/tile-dispatcher.js.map +1 -1
  28. package/package.json +1 -1
  29. package/src/collection-browser.ts +20 -16
  30. package/src/collection-facets/facet-row.ts +3 -0
  31. package/src/collection-facets/facets-template.ts +3 -1
  32. package/src/collection-facets.ts +20 -2
  33. package/src/data-source/collection-browser-data-source.ts +2 -3
  34. package/src/data-source/collection-browser-query-state.ts +1 -1
  35. package/src/empty-placeholder.ts +18 -5
  36. package/src/sort-filter-bar/sort-filter-bar.ts +4 -0
  37. package/src/tiles/base-tile-component.ts +2 -1
  38. package/src/tiles/grid/item-tile.ts +13 -3
  39. package/src/tiles/grid/tile-stats.ts +1 -1
  40. package/src/tiles/tile-dispatcher.ts +8 -4
@@ -46,11 +46,12 @@ export declare class CollectionBrowser extends LitElement implements InfiniteScr
46
46
  * Which mode to display result tiles in (grid, extended list, or compact list)
47
47
  */
48
48
  displayMode?: CollectionDisplayMode;
49
- defaultSortParam: SortParam | null;
50
49
  selectedSort: SortField;
51
50
  selectedTitleFilter: string | null;
52
51
  selectedCreatorFilter: string | null;
53
52
  sortDirection: SortDirection | null;
53
+ defaultSortField: Exclude<SortField, SortField.default>;
54
+ defaultSortDirection: SortDirection | null;
54
55
  pageSize: number;
55
56
  currentPage?: number;
56
57
  minSelectedDate?: string;
@@ -153,8 +154,6 @@ export declare class CollectionBrowser extends LitElement implements InfiniteScr
153
154
  private mobileView;
154
155
  private collapsibleFacetsVisible;
155
156
  private contentWidth?;
156
- private defaultSortField;
157
- private defaultSortDirection;
158
157
  private placeholderType;
159
158
  private contentContainer;
160
159
  private leftColumn?;
@@ -333,6 +332,10 @@ export declare class CollectionBrowser extends LitElement implements InfiniteScr
333
332
  * An object representing the current sort field & direction.
334
333
  */
335
334
  get sortParam(): SortParam | null;
335
+ /**
336
+ * An object representing the default sort field & direction, if none are explicitly set.
337
+ */
338
+ get defaultSortParam(): SortParam | null;
336
339
  /**
337
340
  * Handler for when the display mode option is changed (grid/list/compact-list views).
338
341
  */
@@ -31,11 +31,12 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
31
31
  * Which backend should be targeted by searches (e.g., metadata or FTS)
32
32
  */
33
33
  this.searchType = SearchType.METADATA;
34
- this.defaultSortParam = null;
35
34
  this.selectedSort = SortField.default;
36
35
  this.selectedTitleFilter = null;
37
36
  this.selectedCreatorFilter = null;
38
37
  this.sortDirection = null;
38
+ this.defaultSortField = SortField.relevance;
39
+ this.defaultSortDirection = null;
39
40
  this.pageSize = 50;
40
41
  /**
41
42
  * Whether to show the date picker (above the facets)
@@ -131,8 +132,6 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
131
132
  this.facetsLoading = false;
132
133
  this.mobileView = false;
133
134
  this.collapsibleFacetsVisible = false;
134
- this.defaultSortField = SortField.relevance;
135
- this.defaultSortDirection = null;
136
135
  this.placeholderType = null;
137
136
  /** Whether layout size analytics have been sent already. */
138
137
  this.layoutSizeAnalyticsSent = false;
@@ -452,8 +451,9 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
452
451
  const shouldShowSearching = this.searchResultsLoading || this.totalResults === undefined;
453
452
  const resultsCount = (_a = this.totalResults) === null || _a === void 0 ? void 0 : _a.toLocaleString();
454
453
  const resultsLabel = this.totalResults === 1 ? 'Result' : 'Results';
454
+ // Added data-testid for Playwright testing
455
455
  return html `
456
- <div id="results-total">
456
+ <div id="results-total" data-testid="results-total">
457
457
  <span id="big-results-count">
458
458
  ${shouldShowSearching ? html `Searching&hellip;` : resultsCount}
459
459
  </span>
@@ -642,6 +642,17 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
642
642
  return null;
643
643
  return { field: sortField, direction: this.sortDirection };
644
644
  }
645
+ /**
646
+ * An object representing the default sort field & direction, if none are explicitly set.
647
+ */
648
+ get defaultSortParam() {
649
+ var _a;
650
+ const direction = (_a = this.defaultSortDirection) !== null && _a !== void 0 ? _a : 'asc';
651
+ const field = SORT_OPTIONS[this.defaultSortField].searchServiceKey;
652
+ if (!field)
653
+ return null;
654
+ return { field, direction };
655
+ }
645
656
  /**
646
657
  * Handler for when the display mode option is changed (grid/list/compact-list views).
647
658
  */
@@ -1487,10 +1498,6 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
1487
1498
  if (sortField && sortField !== SortField.default) {
1488
1499
  this.defaultSortField = sortField;
1489
1500
  this.defaultSortDirection = dir;
1490
- this.defaultSortParam = {
1491
- field: this.defaultSortField,
1492
- direction: this.defaultSortDirection,
1493
- };
1494
1501
  }
1495
1502
  }
1496
1503
  /**
@@ -1505,10 +1512,6 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
1505
1512
  this.defaultSortField = SortField.weeklyview;
1506
1513
  }
1507
1514
  this.defaultSortDirection = 'desc';
1508
- this.defaultSortParam = {
1509
- field: this.defaultSortField,
1510
- direction: this.defaultSortDirection,
1511
- };
1512
1515
  }
1513
1516
  /**
1514
1517
  * This is useful for determining whether we need to reload the scroller.
@@ -2023,9 +2026,6 @@ __decorate([
2023
2026
  __decorate([
2024
2027
  property({ type: String })
2025
2028
  ], CollectionBrowser.prototype, "displayMode", void 0);
2026
- __decorate([
2027
- property({ type: Object })
2028
- ], CollectionBrowser.prototype, "defaultSortParam", void 0);
2029
2029
  __decorate([
2030
2030
  property({ type: String })
2031
2031
  ], CollectionBrowser.prototype, "selectedSort", void 0);
@@ -2038,6 +2038,12 @@ __decorate([
2038
2038
  __decorate([
2039
2039
  property({ type: String })
2040
2040
  ], CollectionBrowser.prototype, "sortDirection", void 0);
2041
+ __decorate([
2042
+ property({ type: String })
2043
+ ], CollectionBrowser.prototype, "defaultSortField", void 0);
2044
+ __decorate([
2045
+ property({ type: String })
2046
+ ], CollectionBrowser.prototype, "defaultSortDirection", void 0);
2041
2047
  __decorate([
2042
2048
  property({ type: Number })
2043
2049
  ], CollectionBrowser.prototype, "pageSize", void 0);
@@ -2143,12 +2149,6 @@ __decorate([
2143
2149
  __decorate([
2144
2150
  state()
2145
2151
  ], CollectionBrowser.prototype, "contentWidth", void 0);
2146
- __decorate([
2147
- state()
2148
- ], CollectionBrowser.prototype, "defaultSortField", void 0);
2149
- __decorate([
2150
- state()
2151
- ], CollectionBrowser.prototype, "defaultSortDirection", void 0);
2152
2152
  __decorate([
2153
2153
  state()
2154
2154
  ], CollectionBrowser.prototype, "placeholderType", void 0);