@internetarchive/collection-browser 0.4.3-alpha.4 → 0.4.3-alpha.6
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/dist/src/collection-browser.d.ts +4 -4
- package/dist/src/collection-browser.js +23 -43
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/restoration-state-handler.d.ts +0 -1
- package/dist/src/restoration-state-handler.js +12 -50
- package/dist/src/restoration-state-handler.js.map +1 -1
- package/dist/src/sort-filter-bar/sort-filter-bar.js +0 -1
- package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
- package/dist/src/styles/item-image-styles.js +5 -0
- package/dist/src/styles/item-image-styles.js.map +1 -1
- package/dist/src/tiles/grid/account-tile.d.ts +12 -3
- package/dist/src/tiles/grid/account-tile.js +54 -103
- package/dist/src/tiles/grid/account-tile.js.map +1 -1
- package/dist/src/tiles/grid/item-tile.d.ts +7 -2
- package/dist/src/tiles/grid/item-tile.js +79 -119
- package/dist/src/tiles/grid/item-tile.js.map +1 -1
- package/dist/src/tiles/grid/styles/tile-grid-shared-styles.d.ts +1 -0
- package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js +97 -0
- package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js.map +1 -0
- package/dist/src/tiles/grid/tile-stats.js +11 -13
- package/dist/src/tiles/grid/tile-stats.js.map +1 -1
- package/dist/src/tiles/image-block.js +5 -0
- package/dist/src/tiles/image-block.js.map +1 -1
- package/dist/src/tiles/item-image.d.ts +4 -0
- package/dist/src/tiles/item-image.js +10 -0
- package/dist/src/tiles/item-image.js.map +1 -1
- package/dist/src/tiles/list/tile-list.d.ts +5 -2
- package/dist/src/tiles/list/tile-list.js +32 -29
- package/dist/src/tiles/list/tile-list.js.map +1 -1
- package/dist/src/tiles/text-snippet-block.d.ts +0 -2
- package/dist/src/tiles/text-snippet-block.js +22 -24
- package/dist/src/tiles/text-snippet-block.js.map +1 -1
- package/dist/src/tiles/tile-dispatcher.js +1 -0
- package/dist/src/tiles/tile-dispatcher.js.map +1 -1
- package/dist/test/collection-browser.test.js +7 -7
- package/dist/test/collection-browser.test.js.map +1 -1
- package/dist/test/text-snippet-block.test.js +4 -4
- package/dist/test/text-snippet-block.test.js.map +1 -1
- package/dist/test/tiles/grid/account-tile.test.d.ts +1 -0
- package/dist/test/tiles/grid/account-tile.test.js +76 -0
- package/dist/test/tiles/grid/account-tile.test.js.map +1 -0
- package/dist/test/tiles/grid/item-tile.test.js +34 -10
- package/dist/test/tiles/grid/item-tile.test.js.map +1 -1
- package/package.json +2 -2
- package/src/collection-browser.ts +26 -70
- package/src/restoration-state-handler.ts +14 -68
- package/src/sort-filter-bar/sort-filter-bar.ts +0 -1
- package/src/styles/item-image-styles.ts +5 -0
- package/src/tiles/grid/account-tile.ts +52 -100
- package/src/tiles/grid/item-tile.ts +84 -125
- package/src/tiles/grid/styles/tile-grid-shared-styles.ts +99 -0
- package/src/tiles/grid/tile-stats.ts +11 -13
- package/src/tiles/image-block.ts +6 -0
- package/src/tiles/item-image.ts +12 -0
- package/src/tiles/list/tile-list.ts +41 -38
- package/src/tiles/text-snippet-block.ts +22 -26
- package/src/tiles/tile-dispatcher.ts +1 -0
- package/test/collection-browser.test.ts +7 -7
- package/test/text-snippet-block.test.ts +4 -4
- package/test/tiles/grid/account-tile.test.ts +95 -0
- package/test/tiles/grid/item-tile.test.ts +34 -2
- package/dist/src/utils/array-equals.d.ts +0 -4
- package/dist/src/utils/array-equals.js +0 -11
- package/dist/src/utils/array-equals.js.map +0 -1
- package/dist/test/utils/array-equals.test.d.ts +0 -1
- package/dist/test/utils/array-equals.test.js +0 -27
- package/dist/test/utils/array-equals.test.js.map +0 -1
- package/src/utils/array-equals.ts +0 -8
- package/test/utils/array-equals.test.ts +0 -31
|
@@ -21,11 +21,11 @@ export declare class CollectionBrowser extends LitElement implements InfiniteScr
|
|
|
21
21
|
searchType: SearchType;
|
|
22
22
|
baseQuery?: string;
|
|
23
23
|
displayMode?: CollectionDisplayMode;
|
|
24
|
-
sortParam
|
|
25
|
-
sortDirection?: SortDirection;
|
|
24
|
+
sortParam: SortParam | null;
|
|
26
25
|
selectedSort: SortField;
|
|
27
|
-
selectedTitleFilter
|
|
28
|
-
selectedCreatorFilter
|
|
26
|
+
selectedTitleFilter: string | null;
|
|
27
|
+
selectedCreatorFilter: string | null;
|
|
28
|
+
sortDirection: SortDirection | null;
|
|
29
29
|
pageSize: number;
|
|
30
30
|
resizeObserver?: SharedResizeObserverInterface;
|
|
31
31
|
titleQuery?: string;
|
|
@@ -22,7 +22,11 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
22
22
|
super(...arguments);
|
|
23
23
|
this.baseImageUrl = 'https://archive.org';
|
|
24
24
|
this.searchType = SearchType.METADATA;
|
|
25
|
+
this.sortParam = null;
|
|
25
26
|
this.selectedSort = SortField.relevance;
|
|
27
|
+
this.selectedTitleFilter = null;
|
|
28
|
+
this.selectedCreatorFilter = null;
|
|
29
|
+
this.sortDirection = null;
|
|
26
30
|
this.pageSize = 50;
|
|
27
31
|
this.showHistogramDatePicker = false;
|
|
28
32
|
/** describes where this component is being used */
|
|
@@ -133,20 +137,19 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
133
137
|
}
|
|
134
138
|
clearFilters() {
|
|
135
139
|
this.selectedFacets = defaultSelectedFacets;
|
|
136
|
-
this.sortParam =
|
|
137
|
-
this.
|
|
138
|
-
this.
|
|
139
|
-
this.selectedCreatorFilter = undefined;
|
|
140
|
+
this.sortParam = null;
|
|
141
|
+
this.selectedTitleFilter = null;
|
|
142
|
+
this.selectedCreatorFilter = null;
|
|
140
143
|
this.titleQuery = undefined;
|
|
141
144
|
this.creatorQuery = undefined;
|
|
142
145
|
this.selectedSort = SortField.relevance;
|
|
146
|
+
this.sortDirection = null;
|
|
143
147
|
}
|
|
144
148
|
/**
|
|
145
149
|
* Manually requests to perform a search, which will only be executed if one of
|
|
146
150
|
* the query, the search type, or the sort has changed.
|
|
147
151
|
*/
|
|
148
152
|
requestSearch() {
|
|
149
|
-
console.log('handling query change by request');
|
|
150
153
|
this.handleQueryChange();
|
|
151
154
|
}
|
|
152
155
|
render() {
|
|
@@ -264,17 +267,14 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
264
267
|
});
|
|
265
268
|
}
|
|
266
269
|
selectedSortChanged() {
|
|
267
|
-
if (this.selectedSort === 'relevance') {
|
|
268
|
-
this.sortParam =
|
|
270
|
+
if (this.selectedSort === 'relevance' || this.sortDirection === null) {
|
|
271
|
+
this.sortParam = null;
|
|
269
272
|
return;
|
|
270
273
|
}
|
|
271
274
|
const sortField = SortFieldToMetadataField[this.selectedSort];
|
|
272
|
-
if (!this.sortDirection)
|
|
273
|
-
this.sortDirection = 'desc';
|
|
274
275
|
if (!sortField)
|
|
275
276
|
return;
|
|
276
277
|
this.sortParam = { field: sortField, direction: this.sortDirection };
|
|
277
|
-
this.requestUpdate();
|
|
278
278
|
// Lazy-load the alphabet counts for title/creator sort bar as needed
|
|
279
279
|
this.updatePrefixFiltersForCurrentSort();
|
|
280
280
|
}
|
|
@@ -297,7 +297,7 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
297
297
|
if (!prevSelectedLetter && !this.selectedTitleFilter) {
|
|
298
298
|
return;
|
|
299
299
|
}
|
|
300
|
-
const cleared = prevSelectedLetter &&
|
|
300
|
+
const cleared = prevSelectedLetter && this.selectedTitleFilter === null;
|
|
301
301
|
(_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
|
|
302
302
|
category: this.searchContext,
|
|
303
303
|
action: analyticsActions.filterByTitle,
|
|
@@ -319,7 +319,7 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
319
319
|
if (!prevSelectedLetter && !this.selectedCreatorFilter) {
|
|
320
320
|
return;
|
|
321
321
|
}
|
|
322
|
-
const cleared = prevSelectedLetter &&
|
|
322
|
+
const cleared = prevSelectedLetter && this.selectedCreatorFilter === null;
|
|
323
323
|
(_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
|
|
324
324
|
category: this.searchContext,
|
|
325
325
|
action: analyticsActions.filterByCreator,
|
|
@@ -334,11 +334,11 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
334
334
|
: undefined;
|
|
335
335
|
}
|
|
336
336
|
titleLetterSelected(e) {
|
|
337
|
-
this.selectedCreatorFilter =
|
|
337
|
+
this.selectedCreatorFilter = null;
|
|
338
338
|
this.selectedTitleFilter = e.detail.selectedLetter;
|
|
339
339
|
}
|
|
340
340
|
creatorLetterSelected(e) {
|
|
341
|
-
this.selectedTitleFilter =
|
|
341
|
+
this.selectedTitleFilter = null;
|
|
342
342
|
this.selectedCreatorFilter = e.detail.selectedLetter;
|
|
343
343
|
}
|
|
344
344
|
get facetDataLoading() {
|
|
@@ -432,12 +432,10 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
432
432
|
}
|
|
433
433
|
firstUpdated() {
|
|
434
434
|
this.setupStateRestorationObserver();
|
|
435
|
-
console.log('first updated - restoring state');
|
|
436
435
|
this.restoreState();
|
|
437
436
|
}
|
|
438
437
|
updated(changed) {
|
|
439
438
|
var _a;
|
|
440
|
-
console.log('updated', changed);
|
|
441
439
|
if (changed.has('displayMode') ||
|
|
442
440
|
changed.has('baseNavigationUrl') ||
|
|
443
441
|
changed.has('baseImageUrl') ||
|
|
@@ -445,15 +443,12 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
445
443
|
(_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.reload();
|
|
446
444
|
}
|
|
447
445
|
if (changed.has('baseQuery')) {
|
|
448
|
-
console.log('base query changed', changed.get('baseQuery'), this.baseQuery);
|
|
449
446
|
this.emitBaseQueryChanged();
|
|
450
447
|
}
|
|
451
448
|
if (changed.has('searchType')) {
|
|
452
|
-
console.log('search type changed', changed.get('searchType'), this.searchType);
|
|
453
449
|
this.emitSearchTypeChanged();
|
|
454
450
|
}
|
|
455
451
|
if (changed.has('currentPage') || changed.has('displayMode')) {
|
|
456
|
-
console.log('current page or display mode changed', changed.get('currentPage'), this.currentPage, changed.get('displayMode'), this.displayMode);
|
|
457
452
|
this.persistState();
|
|
458
453
|
}
|
|
459
454
|
if (changed.has('baseQuery') ||
|
|
@@ -464,7 +459,6 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
464
459
|
changed.has('sortParam') ||
|
|
465
460
|
changed.has('selectedFacets') ||
|
|
466
461
|
changed.has('searchService')) {
|
|
467
|
-
console.log('handling query change', changed, this.baseQuery, this.sortParam);
|
|
468
462
|
this.handleQueryChange();
|
|
469
463
|
}
|
|
470
464
|
if (changed.has('baseQuery') ||
|
|
@@ -569,7 +563,6 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
569
563
|
}
|
|
570
564
|
async handleQueryChange() {
|
|
571
565
|
var _a;
|
|
572
|
-
console.log('handleQueryChange', this.pageFetchQueryKey, this.previousQueryKey);
|
|
573
566
|
// only reset if the query has actually changed
|
|
574
567
|
if (!this.searchService || this.pageFetchQueryKey === this.previousQueryKey)
|
|
575
568
|
return;
|
|
@@ -613,21 +606,21 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
613
606
|
this.restoreState();
|
|
614
607
|
}
|
|
615
608
|
restoreState() {
|
|
616
|
-
var _a, _b;
|
|
609
|
+
var _a, _b, _c, _d, _e, _f;
|
|
617
610
|
const restorationState = this.restorationStateHandler.getRestorationState();
|
|
618
611
|
this.displayMode = restorationState.displayMode;
|
|
619
612
|
if (restorationState.searchType != null)
|
|
620
613
|
this.searchType = restorationState.searchType;
|
|
621
614
|
this.selectedSort = (_a = restorationState.selectedSort) !== null && _a !== void 0 ? _a : SortField.relevance;
|
|
622
|
-
this.sortDirection = restorationState.sortDirection;
|
|
623
|
-
this.selectedTitleFilter = restorationState.selectedTitleFilter;
|
|
624
|
-
this.selectedCreatorFilter = restorationState.selectedCreatorFilter;
|
|
615
|
+
this.sortDirection = (_b = restorationState.sortDirection) !== null && _b !== void 0 ? _b : null;
|
|
616
|
+
this.selectedTitleFilter = (_c = restorationState.selectedTitleFilter) !== null && _c !== void 0 ? _c : null;
|
|
617
|
+
this.selectedCreatorFilter = (_d = restorationState.selectedCreatorFilter) !== null && _d !== void 0 ? _d : null;
|
|
625
618
|
this.selectedFacets = restorationState.selectedFacets;
|
|
626
619
|
this.baseQuery = restorationState.baseQuery;
|
|
627
620
|
this.titleQuery = restorationState.titleQuery;
|
|
628
621
|
this.creatorQuery = restorationState.creatorQuery;
|
|
629
|
-
this.sortParam = restorationState.sortParam;
|
|
630
|
-
this.currentPage = (
|
|
622
|
+
this.sortParam = (_e = restorationState.sortParam) !== null && _e !== void 0 ? _e : null;
|
|
623
|
+
this.currentPage = (_f = restorationState.currentPage) !== null && _f !== void 0 ? _f : 1;
|
|
631
624
|
this.minSelectedDate = restorationState.minSelectedDate;
|
|
632
625
|
this.maxSelectedDate = restorationState.maxSelectedDate;
|
|
633
626
|
if (this.currentPage > 1) {
|
|
@@ -655,7 +648,6 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
655
648
|
this.restorationStateHandler.persistState(restorationState);
|
|
656
649
|
}
|
|
657
650
|
async doInitialPageFetch() {
|
|
658
|
-
console.log('doInitialPageFetch');
|
|
659
651
|
this.searchResultsLoading = true;
|
|
660
652
|
await this.fetchPage(this.initialPageNumber);
|
|
661
653
|
this.searchResultsLoading = false;
|
|
@@ -881,10 +873,8 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
881
873
|
}
|
|
882
874
|
async fetchFacets() {
|
|
883
875
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
884
|
-
console.log('maybe fetch facets', this.filteredQuery);
|
|
885
876
|
if (!this.filteredQuery)
|
|
886
877
|
return;
|
|
887
|
-
console.log('fetching facets');
|
|
888
878
|
const params = {
|
|
889
879
|
query: this.filteredQuery,
|
|
890
880
|
rows: 0,
|
|
@@ -993,7 +983,6 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
993
983
|
}
|
|
994
984
|
async fetchPage(pageNumber) {
|
|
995
985
|
var _a, _b, _c, _d, _e;
|
|
996
|
-
console.log('maybe fetch page', pageNumber, this.filteredQuery);
|
|
997
986
|
if (!this.filteredQuery)
|
|
998
987
|
return;
|
|
999
988
|
// if we already have data, don't fetch again
|
|
@@ -1008,7 +997,6 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
1008
997
|
return;
|
|
1009
998
|
pageFetches.add(pageNumber);
|
|
1010
999
|
this.pageFetchesInProgress[pageFetchQueryKey] = pageFetches;
|
|
1011
|
-
console.log('fetching page', pageNumber);
|
|
1012
1000
|
const sortParams = this.sortParam ? [this.sortParam] : [];
|
|
1013
1001
|
const params = {
|
|
1014
1002
|
query: this.filteredQuery,
|
|
@@ -1467,14 +1455,6 @@ CollectionBrowser.styles = css `
|
|
|
1467
1455
|
18rem
|
|
1468
1456
|
);
|
|
1469
1457
|
--infiniteScrollerCellMaxWidth: var(--collectionBrowserCellMaxWidth, 1fr);
|
|
1470
|
-
--infiniteScrollerCellMinHeight: var(
|
|
1471
|
-
--collectionBrowserCellMinHeight,
|
|
1472
|
-
29rem
|
|
1473
|
-
);
|
|
1474
|
-
--infiniteScrollerCellMaxHeight: var(
|
|
1475
|
-
--collectionBrowserCellMaxHeight,
|
|
1476
|
-
29rem
|
|
1477
|
-
);
|
|
1478
1458
|
}
|
|
1479
1459
|
`;
|
|
1480
1460
|
__decorate([
|
|
@@ -1498,9 +1478,6 @@ __decorate([
|
|
|
1498
1478
|
__decorate([
|
|
1499
1479
|
property({ type: Object })
|
|
1500
1480
|
], CollectionBrowser.prototype, "sortParam", void 0);
|
|
1501
|
-
__decorate([
|
|
1502
|
-
property({ type: String })
|
|
1503
|
-
], CollectionBrowser.prototype, "sortDirection", void 0);
|
|
1504
1481
|
__decorate([
|
|
1505
1482
|
property({ type: String })
|
|
1506
1483
|
], CollectionBrowser.prototype, "selectedSort", void 0);
|
|
@@ -1510,6 +1487,9 @@ __decorate([
|
|
|
1510
1487
|
__decorate([
|
|
1511
1488
|
property({ type: String })
|
|
1512
1489
|
], CollectionBrowser.prototype, "selectedCreatorFilter", void 0);
|
|
1490
|
+
__decorate([
|
|
1491
|
+
property({ type: String })
|
|
1492
|
+
], CollectionBrowser.prototype, "sortDirection", void 0);
|
|
1513
1493
|
__decorate([
|
|
1514
1494
|
property({ type: Number })
|
|
1515
1495
|
], CollectionBrowser.prototype, "pageSize", void 0);
|