@internetarchive/collection-browser 2.2.2-alpha.0 → 2.2.3-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.
- package/dist/src/collection-browser.d.ts +22 -12
- package/dist/src/collection-browser.js +53 -22
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/data-source/collection-browser-data-source-interface.d.ts +2 -2
- package/dist/src/data-source/collection-browser-data-source-interface.js.map +1 -1
- package/dist/src/data-source/collection-browser-data-source.d.ts +2 -2
- package/dist/src/data-source/collection-browser-data-source.js +8 -7
- package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
- package/dist/src/data-source/collection-browser-query-state.d.ts +2 -3
- package/dist/src/data-source/collection-browser-query-state.js.map +1 -1
- package/dist/src/models.d.ts +11 -0
- package/dist/src/models.js.map +1 -1
- package/package.json +1 -1
- package/src/collection-browser.ts +58 -21
- package/src/data-source/collection-browser-data-source-interface.ts +2 -2
- package/src/data-source/collection-browser-data-source.ts +11 -7
- package/src/data-source/collection-browser-query-state.ts +2 -3
- package/src/models.ts +12 -0
|
@@ -7,7 +7,7 @@ import '@internetarchive/infinite-scroller';
|
|
|
7
7
|
import type { ModalManagerInterface } from '@internetarchive/modal-manager';
|
|
8
8
|
import type { FeatureFeedbackServiceInterface } from '@internetarchive/feature-feedback';
|
|
9
9
|
import type { RecaptchaManagerInterface } from '@internetarchive/recaptcha-manager';
|
|
10
|
-
import { SelectedFacets, SortField, CollectionBrowserContext, TileModel, CollectionDisplayMode, FacetEventDetails } from './models';
|
|
10
|
+
import { SelectedFacets, SortField, CollectionBrowserContext, TileModel, CollectionDisplayMode, FacetEventDetails, FacetLoadStrategy } from './models';
|
|
11
11
|
import { RestorationStateHandlerInterface } from './restoration-state-handler';
|
|
12
12
|
import type { CollectionBrowserQueryState, CollectionBrowserSearchInterface } from './data-source/collection-browser-query-state';
|
|
13
13
|
import type { CollectionBrowserDataSourceInterface } from './data-source/collection-browser-data-source-interface';
|
|
@@ -80,12 +80,6 @@ export declare class CollectionBrowser extends LitElement implements InfiniteScr
|
|
|
80
80
|
* If true, the `query` param will not be added to the URL or updated on query changes.
|
|
81
81
|
*/
|
|
82
82
|
suppressURLQuery: boolean;
|
|
83
|
-
/**
|
|
84
|
-
* Whether to suppress the display of facets entirely.
|
|
85
|
-
* If true, the facet sidebar content will be replaced by a message that facets are
|
|
86
|
-
* temporarily unavailable.
|
|
87
|
-
*/
|
|
88
|
-
suppressFacets: boolean;
|
|
89
83
|
/**
|
|
90
84
|
* Whether to suppress display of the sort bar.
|
|
91
85
|
* If true, the entire sort bar (incl. display modes) will be omitted from rendering.
|
|
@@ -97,12 +91,21 @@ export declare class CollectionBrowser extends LitElement implements InfiniteScr
|
|
|
97
91
|
*/
|
|
98
92
|
suppressDisplayModes: boolean;
|
|
99
93
|
/**
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
94
|
+
* What strategy to use for when/whether to load facet data for a search.
|
|
95
|
+
*
|
|
96
|
+
* Defaults to `eager`, always loading facets immediately alongside search results.
|
|
97
|
+
*
|
|
98
|
+
* To eliminate facets that are never seen, this can be reduced to `lazy-mobile`, which
|
|
99
|
+
* will delay loading facets in the mobile view until the "Filters" accordion is opened.
|
|
100
|
+
* Facets are still loaded eagerly when viewing the desktop layout.
|
|
101
|
+
*
|
|
102
|
+
* To further reduce facet requests for patrons who do not need to use them, this can be
|
|
103
|
+
* again reduced to `opt-in`, which will also require desktop users to explicitly request
|
|
104
|
+
* that they be loaded (in addition to the lazy mobile behavior described above).
|
|
105
|
+
*
|
|
106
|
+
* To entirely suppress facets from being loaded, this may be set to `off`.
|
|
104
107
|
*/
|
|
105
|
-
|
|
108
|
+
facetLoadStrategy: FacetLoadStrategy;
|
|
106
109
|
clearResultsOnEmptyQuery: boolean;
|
|
107
110
|
collectionPagePath: string;
|
|
108
111
|
/** describes where this component is being used */
|
|
@@ -146,6 +149,7 @@ export declare class CollectionBrowser extends LitElement implements InfiniteScr
|
|
|
146
149
|
*/
|
|
147
150
|
private searchResultsLoading;
|
|
148
151
|
private facetsLoading;
|
|
152
|
+
private facetsOptedIn;
|
|
149
153
|
private totalResults?;
|
|
150
154
|
private mobileView;
|
|
151
155
|
private mobileFacetsVisible;
|
|
@@ -355,6 +359,12 @@ export declare class CollectionBrowser extends LitElement implements InfiniteScr
|
|
|
355
359
|
connectedCallback(): void;
|
|
356
360
|
disconnectedCallback(): void;
|
|
357
361
|
handleResize(entry: ResizeObserverEntry): void;
|
|
362
|
+
/**
|
|
363
|
+
* Updates the data source with the current state of facet readiness for loading,
|
|
364
|
+
* so that they will begin to load in at the appropriate time according to the
|
|
365
|
+
* current facet loading strategy.
|
|
366
|
+
*/
|
|
367
|
+
private updateFacetReadiness;
|
|
358
368
|
/**
|
|
359
369
|
* Sets up listeners for events that may require updating the left column height.
|
|
360
370
|
*/
|
|
@@ -60,12 +60,6 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
60
60
|
* If true, the `query` param will not be added to the URL or updated on query changes.
|
|
61
61
|
*/
|
|
62
62
|
this.suppressURLQuery = false;
|
|
63
|
-
/**
|
|
64
|
-
* Whether to suppress the display of facets entirely.
|
|
65
|
-
* If true, the facet sidebar content will be replaced by a message that facets are
|
|
66
|
-
* temporarily unavailable.
|
|
67
|
-
*/
|
|
68
|
-
this.suppressFacets = false;
|
|
69
63
|
/**
|
|
70
64
|
* Whether to suppress display of the sort bar.
|
|
71
65
|
* If true, the entire sort bar (incl. display modes) will be omitted from rendering.
|
|
@@ -77,12 +71,21 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
77
71
|
*/
|
|
78
72
|
this.suppressDisplayModes = false;
|
|
79
73
|
/**
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
74
|
+
* What strategy to use for when/whether to load facet data for a search.
|
|
75
|
+
*
|
|
76
|
+
* Defaults to `eager`, always loading facets immediately alongside search results.
|
|
77
|
+
*
|
|
78
|
+
* To eliminate facets that are never seen, this can be reduced to `lazy-mobile`, which
|
|
79
|
+
* will delay loading facets in the mobile view until the "Filters" accordion is opened.
|
|
80
|
+
* Facets are still loaded eagerly when viewing the desktop layout.
|
|
81
|
+
*
|
|
82
|
+
* To further reduce facet requests for patrons who do not need to use them, this can be
|
|
83
|
+
* again reduced to `opt-in`, which will also require desktop users to explicitly request
|
|
84
|
+
* that they be loaded (in addition to the lazy mobile behavior described above).
|
|
85
|
+
*
|
|
86
|
+
* To entirely suppress facets from being loaded, this may be set to `off`.
|
|
84
87
|
*/
|
|
85
|
-
this.
|
|
88
|
+
this.facetLoadStrategy = 'eager';
|
|
86
89
|
this.clearResultsOnEmptyQuery = false;
|
|
87
90
|
this.collectionPagePath = '/details/';
|
|
88
91
|
/** describes where this component is being used */
|
|
@@ -125,6 +128,7 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
125
128
|
*/
|
|
126
129
|
this.searchResultsLoading = false;
|
|
127
130
|
this.facetsLoading = false;
|
|
131
|
+
this.facetsOptedIn = false;
|
|
128
132
|
this.mobileView = false;
|
|
129
133
|
this.mobileFacetsVisible = false;
|
|
130
134
|
this.defaultSortField = SortField.relevance;
|
|
@@ -711,11 +715,23 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
711
715
|
* The template for the facets component alone, without any surrounding wrappers.
|
|
712
716
|
*/
|
|
713
717
|
get facetsTemplate() {
|
|
714
|
-
if (this.
|
|
718
|
+
if (this.facetLoadStrategy === 'off') {
|
|
715
719
|
return html `
|
|
716
720
|
<p class="facets-message">
|
|
717
721
|
${msg('Facets are temporarily unavailable.')}
|
|
718
722
|
</p>
|
|
723
|
+
`;
|
|
724
|
+
}
|
|
725
|
+
if (this.facetLoadStrategy === 'opt-in' && !this.facetsOptedIn) {
|
|
726
|
+
return html `
|
|
727
|
+
<button
|
|
728
|
+
class="facets-opt-in"
|
|
729
|
+
@click=${() => {
|
|
730
|
+
this.facetsOptedIn = true;
|
|
731
|
+
}}
|
|
732
|
+
>
|
|
733
|
+
${msg('Load facets')}
|
|
734
|
+
</button>
|
|
719
735
|
`;
|
|
720
736
|
}
|
|
721
737
|
return html `
|
|
@@ -953,10 +969,7 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
953
969
|
if (changed.has('selectedCreatorFilter')) {
|
|
954
970
|
this.sendFilterByCreatorAnalytics(changed.get('selectedCreatorFilter'));
|
|
955
971
|
}
|
|
956
|
-
|
|
957
|
-
// But in the mobile view, their visibility state can be toggled by the user.
|
|
958
|
-
// In either case, inform the data source so that it can determine whether/when to fetch facets.
|
|
959
|
-
this.dataSource.handleFacetVisibilityChange(!this.mobileView || this.mobileFacetsVisible);
|
|
972
|
+
this.updateFacetReadiness();
|
|
960
973
|
if (changed.has('baseQuery') ||
|
|
961
974
|
changed.has('searchType') ||
|
|
962
975
|
changed.has('selectedTitleFilter') ||
|
|
@@ -1031,6 +1044,20 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
1031
1044
|
// Ensure the facet sidebar remains sized correctly
|
|
1032
1045
|
this.updateLeftColumnHeight();
|
|
1033
1046
|
}
|
|
1047
|
+
/**
|
|
1048
|
+
* Updates the data source with the current state of facet readiness for loading,
|
|
1049
|
+
* so that they will begin to load in at the appropriate time according to the
|
|
1050
|
+
* current facet loading strategy.
|
|
1051
|
+
*/
|
|
1052
|
+
updateFacetReadiness() {
|
|
1053
|
+
// In desktop view, we are always ready to load facets *unless* we are
|
|
1054
|
+
// using the `opt-in` strategy and the opt-in has not yet occurred.
|
|
1055
|
+
const desktopFacetsReady = !this.mobileView &&
|
|
1056
|
+
(this.facetLoadStrategy !== 'opt-in' || this.facetsOptedIn);
|
|
1057
|
+
// In mobile view, facets are considered ready provided they are currently visible (their dropdown is opened).
|
|
1058
|
+
const mobileFacetsReady = this.mobileView && this.mobileFacetsVisible;
|
|
1059
|
+
this.dataSource.handleFacetReadinessChange(desktopFacetsReady || mobileFacetsReady);
|
|
1060
|
+
}
|
|
1034
1061
|
/**
|
|
1035
1062
|
* Sets up listeners for events that may require updating the left column height.
|
|
1036
1063
|
*/
|
|
@@ -1124,7 +1151,11 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
1124
1151
|
const { visibleCellIndices } = e.detail;
|
|
1125
1152
|
if (visibleCellIndices.length === 0)
|
|
1126
1153
|
return;
|
|
1127
|
-
|
|
1154
|
+
// For page determination, do not count more than a single page of visible cells,
|
|
1155
|
+
// since otherwise patrons using very tall screens will be treated as one page
|
|
1156
|
+
// further than they actually are.
|
|
1157
|
+
const lastIndexWithinCurrentPage = Math.min(this.pageSize, visibleCellIndices.length) - 1;
|
|
1158
|
+
const lastVisibleCellIndex = visibleCellIndices[lastIndexWithinCurrentPage];
|
|
1128
1159
|
const lastVisibleCellPage = Math.floor(lastVisibleCellIndex / this.pageSize) + 1;
|
|
1129
1160
|
if (this.currentPage !== lastVisibleCellPage) {
|
|
1130
1161
|
this.currentPage = lastVisibleCellPage;
|
|
@@ -1906,9 +1937,6 @@ __decorate([
|
|
|
1906
1937
|
__decorate([
|
|
1907
1938
|
property({ type: Boolean })
|
|
1908
1939
|
], CollectionBrowser.prototype, "suppressURLQuery", void 0);
|
|
1909
|
-
__decorate([
|
|
1910
|
-
property({ type: Boolean })
|
|
1911
|
-
], CollectionBrowser.prototype, "suppressFacets", void 0);
|
|
1912
1940
|
__decorate([
|
|
1913
1941
|
property({ type: Boolean })
|
|
1914
1942
|
], CollectionBrowser.prototype, "suppressSortBar", void 0);
|
|
@@ -1916,8 +1944,8 @@ __decorate([
|
|
|
1916
1944
|
property({ type: Boolean })
|
|
1917
1945
|
], CollectionBrowser.prototype, "suppressDisplayModes", void 0);
|
|
1918
1946
|
__decorate([
|
|
1919
|
-
property({ type:
|
|
1920
|
-
], CollectionBrowser.prototype, "
|
|
1947
|
+
property({ type: String })
|
|
1948
|
+
], CollectionBrowser.prototype, "facetLoadStrategy", void 0);
|
|
1921
1949
|
__decorate([
|
|
1922
1950
|
property({ type: Boolean })
|
|
1923
1951
|
], CollectionBrowser.prototype, "clearResultsOnEmptyQuery", void 0);
|
|
@@ -1972,6 +2000,9 @@ __decorate([
|
|
|
1972
2000
|
__decorate([
|
|
1973
2001
|
state()
|
|
1974
2002
|
], CollectionBrowser.prototype, "facetsLoading", void 0);
|
|
2003
|
+
__decorate([
|
|
2004
|
+
state()
|
|
2005
|
+
], CollectionBrowser.prototype, "facetsOptedIn", void 0);
|
|
1975
2006
|
__decorate([
|
|
1976
2007
|
state()
|
|
1977
2008
|
], CollectionBrowser.prototype, "totalResults", void 0);
|