@internetarchive/collection-browser 2.2.3-alpha.1 → 2.2.3-alpha.3
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 +1 -2
- package/dist/src/collection-browser.js +56 -31
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/data-source/collection-browser-data-source.d.ts +1 -1
- package/dist/src/data-source/collection-browser-data-source.js +4 -4
- package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
- package/package.json +1 -1
- package/src/collection-browser.ts +56 -31
- package/src/data-source/collection-browser-data-source.ts +4 -4
|
@@ -149,10 +149,9 @@ export declare class CollectionBrowser extends LitElement implements InfiniteScr
|
|
|
149
149
|
*/
|
|
150
150
|
private searchResultsLoading;
|
|
151
151
|
private facetsLoading;
|
|
152
|
-
private facetsOptedIn;
|
|
153
152
|
private totalResults?;
|
|
154
153
|
private mobileView;
|
|
155
|
-
private
|
|
154
|
+
private collapsibleFacetsVisible;
|
|
156
155
|
private contentWidth?;
|
|
157
156
|
private defaultSortField;
|
|
158
157
|
private defaultSortDirection;
|
|
@@ -9,6 +9,7 @@ import '@internetarchive/infinite-scroller';
|
|
|
9
9
|
import { SortField, getDefaultSelectedFacets, sortOptionFromAPIString, SORT_OPTIONS, defaultProfileElementSorts, } from './models';
|
|
10
10
|
import { RestorationStateHandler, } from './restoration-state-handler';
|
|
11
11
|
import { CollectionBrowserDataSource } from './data-source/collection-browser-data-source';
|
|
12
|
+
import { FACETLESS_PAGE_ELEMENTS } from './data-source/models';
|
|
12
13
|
import { analyticsActions, analyticsCategories, } from './utils/analytics-events';
|
|
13
14
|
import chevronIcon from './assets/img/icons/chevron';
|
|
14
15
|
import { srOnlyStyle } from './styles/sr-only';
|
|
@@ -85,7 +86,7 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
85
86
|
*
|
|
86
87
|
* To entirely suppress facets from being loaded, this may be set to `off`.
|
|
87
88
|
*/
|
|
88
|
-
this.facetLoadStrategy = '
|
|
89
|
+
this.facetLoadStrategy = 'eager';
|
|
89
90
|
this.clearResultsOnEmptyQuery = false;
|
|
90
91
|
this.collectionPagePath = '/details/';
|
|
91
92
|
/** describes where this component is being used */
|
|
@@ -128,9 +129,8 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
128
129
|
*/
|
|
129
130
|
this.searchResultsLoading = false;
|
|
130
131
|
this.facetsLoading = false;
|
|
131
|
-
this.facetsOptedIn = false;
|
|
132
132
|
this.mobileView = false;
|
|
133
|
-
this.
|
|
133
|
+
this.collapsibleFacetsVisible = false;
|
|
134
134
|
this.defaultSortField = SortField.relevance;
|
|
135
135
|
this.defaultSortDirection = null;
|
|
136
136
|
this.placeholderType = null;
|
|
@@ -689,11 +689,13 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
689
689
|
* including the collapsible container (with header) and the facets themselves.
|
|
690
690
|
*/
|
|
691
691
|
get mobileFacetsTemplate() {
|
|
692
|
+
if (FACETLESS_PAGE_ELEMENTS.includes(this.profileElement))
|
|
693
|
+
return nothing;
|
|
692
694
|
const toggleFacetsVisible = (e) => {
|
|
693
695
|
var _a;
|
|
694
|
-
this.isResizeToMobile = false;
|
|
695
|
-
this.mobileFacetsVisible = !this.mobileFacetsVisible;
|
|
696
696
|
const target = e.target;
|
|
697
|
+
this.isResizeToMobile = false;
|
|
698
|
+
this.collapsibleFacetsVisible = target.open;
|
|
697
699
|
(_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
|
|
698
700
|
category: this.searchContext,
|
|
699
701
|
action: analyticsActions.mobileFacetsToggled,
|
|
@@ -715,6 +717,8 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
715
717
|
* The template for the facets component alone, without any surrounding wrappers.
|
|
716
718
|
*/
|
|
717
719
|
get facetsTemplate() {
|
|
720
|
+
if (FACETLESS_PAGE_ELEMENTS.includes(this.profileElement))
|
|
721
|
+
return nothing;
|
|
718
722
|
if (this.facetLoadStrategy === 'off') {
|
|
719
723
|
return html `
|
|
720
724
|
<p class="facets-message">
|
|
@@ -722,21 +726,7 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
722
726
|
</p>
|
|
723
727
|
`;
|
|
724
728
|
}
|
|
725
|
-
|
|
726
|
-
!this.mobileView &&
|
|
727
|
-
!this.facetsOptedIn) {
|
|
728
|
-
return html `
|
|
729
|
-
<button
|
|
730
|
-
class="load-facets-btn"
|
|
731
|
-
@click=${() => {
|
|
732
|
-
this.facetsOptedIn = true;
|
|
733
|
-
}}
|
|
734
|
-
>
|
|
735
|
-
${msg('Load facets')}
|
|
736
|
-
</button>
|
|
737
|
-
`;
|
|
738
|
-
}
|
|
739
|
-
return html `
|
|
729
|
+
const facets = html `
|
|
740
730
|
<collection-facets
|
|
741
731
|
@facetsChanged=${this.facetsChanged}
|
|
742
732
|
@histogramDateRangeUpdated=${this.histogramDateRangeUpdated}
|
|
@@ -771,6 +761,27 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
771
761
|
>
|
|
772
762
|
</collection-facets>
|
|
773
763
|
`;
|
|
764
|
+
// In the desktop facets opt-in case, wrap the facet sidebar in a <details> widget
|
|
765
|
+
// that can be opened and closed as needed.
|
|
766
|
+
if (this.facetLoadStrategy === 'opt-in' && !this.mobileView) {
|
|
767
|
+
return html `
|
|
768
|
+
<details
|
|
769
|
+
class="desktop-facets-dropdown"
|
|
770
|
+
@toggle=${(e) => {
|
|
771
|
+
const target = e.target;
|
|
772
|
+
this.collapsibleFacetsVisible = target.open;
|
|
773
|
+
}}
|
|
774
|
+
>
|
|
775
|
+
<summary>
|
|
776
|
+
<span class="collapser-icon">${chevronIcon}</span>
|
|
777
|
+
<h2>${msg('Filters')}</h2>
|
|
778
|
+
</summary>
|
|
779
|
+
${facets}
|
|
780
|
+
</button>
|
|
781
|
+
`;
|
|
782
|
+
}
|
|
783
|
+
// Otherwise, just render the facets component bare
|
|
784
|
+
return facets;
|
|
774
785
|
}
|
|
775
786
|
/**
|
|
776
787
|
* The HTML template for the "Clear all filters" button, or `nothing` if no
|
|
@@ -1053,11 +1064,11 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
1053
1064
|
*/
|
|
1054
1065
|
updateFacetReadiness() {
|
|
1055
1066
|
// In desktop view, we are always ready to load facets *unless* we are
|
|
1056
|
-
// using the `opt-in` strategy and the
|
|
1067
|
+
// using the `opt-in` strategy and the facets dropdown is not open.
|
|
1057
1068
|
const desktopFacetsReady = !this.mobileView &&
|
|
1058
|
-
(this.facetLoadStrategy !== 'opt-in' || this.
|
|
1069
|
+
(this.facetLoadStrategy !== 'opt-in' || this.collapsibleFacetsVisible);
|
|
1059
1070
|
// In mobile view, facets are considered ready provided they are currently visible (their dropdown is opened).
|
|
1060
|
-
const mobileFacetsReady = this.mobileView && this.
|
|
1071
|
+
const mobileFacetsReady = this.mobileView && this.collapsibleFacetsVisible;
|
|
1061
1072
|
this.dataSource.handleFacetReadinessChange(desktopFacetsReady || mobileFacetsReady);
|
|
1062
1073
|
}
|
|
1063
1074
|
/**
|
|
@@ -1655,6 +1666,25 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
1655
1666
|
font-size: 1.4rem;
|
|
1656
1667
|
}
|
|
1657
1668
|
|
|
1669
|
+
.desktop-facets-dropdown > summary {
|
|
1670
|
+
cursor: pointer;
|
|
1671
|
+
list-style: none;
|
|
1672
|
+
}
|
|
1673
|
+
|
|
1674
|
+
.desktop-facets-dropdown h2 {
|
|
1675
|
+
display: inline-block;
|
|
1676
|
+
margin: 0;
|
|
1677
|
+
font-size: 1.6rem;
|
|
1678
|
+
}
|
|
1679
|
+
|
|
1680
|
+
.desktop-facets-dropdown[open] > summary {
|
|
1681
|
+
margin-bottom: 10px;
|
|
1682
|
+
}
|
|
1683
|
+
|
|
1684
|
+
.desktop-facets-dropdown[open] svg {
|
|
1685
|
+
transform: rotate(90deg);
|
|
1686
|
+
}
|
|
1687
|
+
|
|
1658
1688
|
.desktop #left-column-scroll-sentinel {
|
|
1659
1689
|
width: 1px;
|
|
1660
1690
|
height: 100vh;
|
|
@@ -1692,8 +1722,7 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
1692
1722
|
width: 100%;
|
|
1693
1723
|
}
|
|
1694
1724
|
|
|
1695
|
-
.clear-filters-btn
|
|
1696
|
-
.load-facets-btn {
|
|
1725
|
+
.clear-filters-btn {
|
|
1697
1726
|
display: inline-block;
|
|
1698
1727
|
appearance: none;
|
|
1699
1728
|
margin: 0;
|
|
@@ -1706,8 +1735,7 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
1706
1735
|
cursor: pointer;
|
|
1707
1736
|
}
|
|
1708
1737
|
|
|
1709
|
-
.clear-filters-btn:hover
|
|
1710
|
-
.load-facets-btn:hover {
|
|
1738
|
+
.clear-filters-btn:hover {
|
|
1711
1739
|
text-decoration: underline;
|
|
1712
1740
|
}
|
|
1713
1741
|
|
|
@@ -2004,9 +2032,6 @@ __decorate([
|
|
|
2004
2032
|
__decorate([
|
|
2005
2033
|
state()
|
|
2006
2034
|
], CollectionBrowser.prototype, "facetsLoading", void 0);
|
|
2007
|
-
__decorate([
|
|
2008
|
-
state()
|
|
2009
|
-
], CollectionBrowser.prototype, "facetsOptedIn", void 0);
|
|
2010
2035
|
__decorate([
|
|
2011
2036
|
state()
|
|
2012
2037
|
], CollectionBrowser.prototype, "totalResults", void 0);
|
|
@@ -2015,7 +2040,7 @@ __decorate([
|
|
|
2015
2040
|
], CollectionBrowser.prototype, "mobileView", void 0);
|
|
2016
2041
|
__decorate([
|
|
2017
2042
|
state()
|
|
2018
|
-
], CollectionBrowser.prototype, "
|
|
2043
|
+
], CollectionBrowser.prototype, "collapsibleFacetsVisible", void 0);
|
|
2019
2044
|
__decorate([
|
|
2020
2045
|
state()
|
|
2021
2046
|
], CollectionBrowser.prototype, "contentWidth", void 0);
|