@internetarchive/collection-browser 4.1.1-alpha-webdev8185.1 → 4.1.1
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/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/src/collection-browser.d.ts +18 -9
- package/dist/src/collection-browser.js +77 -18
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/data-source/collection-browser-data-source.js +3 -2
- package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
- package/dist/src/data-source/collection-browser-query-state.d.ts +3 -5
- package/dist/src/data-source/collection-browser-query-state.js.map +1 -1
- package/dist/src/models.d.ts +2 -27
- package/dist/src/models.js +0 -36
- package/dist/src/models.js.map +1 -1
- package/dist/src/restoration-state-handler.js +9 -3
- package/dist/src/restoration-state-handler.js.map +1 -1
- package/dist/src/sort-filter-bar/sort-filter-bar.d.ts +2 -2
- package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
- package/dist/test/collection-browser.test.js +17 -15
- package/dist/test/collection-browser.test.js.map +1 -1
- package/index.ts +0 -5
- package/package.json +1 -1
- package/src/collection-browser.ts +94 -25
- package/src/data-source/collection-browser-data-source.ts +3 -2
- package/src/data-source/collection-browser-query-state.ts +3 -12
- package/src/models.ts +4 -53
- package/src/restoration-state-handler.ts +550 -546
- package/src/sort-filter-bar/sort-filter-bar.ts +4 -3
- package/test/collection-browser.test.ts +17 -15
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { CollectionBrowserDataSource } from './src/data-source/collection-browse
|
|
|
3
3
|
export { CollectionBrowserDataSourceInterface } from './src/data-source/collection-browser-data-source-interface';
|
|
4
4
|
export { CollectionBrowserQueryState } from './src/data-source/collection-browser-query-state';
|
|
5
5
|
export { SortFilterBar } from './src/sort-filter-bar/sort-filter-bar';
|
|
6
|
-
export { CollectionDisplayMode, SortField,
|
|
6
|
+
export { CollectionDisplayMode, SortField, TileModel, FacetOption, SelectedFacets, getDefaultSelectedFacets, } from './src/models';
|
|
7
7
|
export { CollectionBrowserLoadingTile } from './src/tiles/collection-browser-loading-tile';
|
|
8
8
|
export { CollectionTile } from './src/tiles/grid/collection-tile';
|
|
9
9
|
export { AccountTile } from './src/tiles/grid/account-tile';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { CollectionBrowser } from './src/collection-browser';
|
|
2
2
|
export { CollectionBrowserDataSource } from './src/data-source/collection-browser-data-source';
|
|
3
3
|
export { SortFilterBar } from './src/sort-filter-bar/sort-filter-bar';
|
|
4
|
-
export { SortField, TileModel, getDefaultSelectedFacets,
|
|
4
|
+
export { SortField, TileModel, getDefaultSelectedFacets, } from './src/models';
|
|
5
5
|
export { CollectionBrowserLoadingTile } from './src/tiles/collection-browser-loading-tile';
|
|
6
6
|
export { CollectionTile } from './src/tiles/grid/collection-tile';
|
|
7
7
|
export { AccountTile } from './src/tiles/grid/account-tile';
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,2BAA2B,EAAE,MAAM,kDAAkD,CAAC;AAG/F,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACtE,OAAO,EAEL,SAAS,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,2BAA2B,EAAE,MAAM,kDAAkD,CAAC;AAG/F,OAAO,EAAE,aAAa,EAAE,MAAM,uCAAuC,CAAC;AACtE,OAAO,EAEL,SAAS,EACT,SAAS,EAGT,wBAAwB,GACzB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,4BAA4B,EAAE,MAAM,6CAA6C,CAAC;AAC3F,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,WAAW,EAAE,MAAM,+BAA+B,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAO7D,cAAc,uDAAuD,CAAC;AACtE,OAAO,EAAE,wBAAwB,EAAE,MAAM,6DAA6D,CAAC","sourcesContent":["export { CollectionBrowser } from './src/collection-browser';\nexport { CollectionBrowserDataSource } from './src/data-source/collection-browser-data-source';\nexport { CollectionBrowserDataSourceInterface } from './src/data-source/collection-browser-data-source-interface';\nexport { CollectionBrowserQueryState } from './src/data-source/collection-browser-query-state';\nexport { SortFilterBar } from './src/sort-filter-bar/sort-filter-bar';\nexport {\n CollectionDisplayMode,\n SortField,\n TileModel,\n FacetOption,\n SelectedFacets,\n getDefaultSelectedFacets,\n} from './src/models';\nexport { CollectionBrowserLoadingTile } from './src/tiles/collection-browser-loading-tile';\nexport { CollectionTile } from './src/tiles/grid/collection-tile';\nexport { AccountTile } from './src/tiles/grid/account-tile';\nexport { ItemTile } from './src/tiles/grid/item-tile';\nexport { TileList } from './src/tiles/list/tile-list';\nexport { TileListCompact } from './src/tiles/list/tile-list-compact';\nexport { TileDispatcher } from './src/tiles/tile-dispatcher';\nexport { LayoutType } from './src/tiles/models';\nexport {\n SmartQueryHeuristic,\n KeywordFacetMap,\n SmartFacet,\n} from './src/collection-facets/smart-facets/models';\nexport * from './src/collection-facets/smart-facets/heuristics/index';\nexport { SmartQueryHeuristicGroup } from './src/collection-facets/smart-facets/smart-facet-heuristics';\n"]}
|
|
@@ -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,
|
|
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';
|
|
@@ -61,7 +61,7 @@ export declare class CollectionBrowser extends LitElement implements InfiniteScr
|
|
|
61
61
|
selectedTitleFilter: string | null;
|
|
62
62
|
selectedCreatorFilter: string | null;
|
|
63
63
|
sortDirection: SortDirection | null;
|
|
64
|
-
defaultSortField:
|
|
64
|
+
defaultSortField: Exclude<SortField, SortField.default>;
|
|
65
65
|
defaultSortDirection: SortDirection | null;
|
|
66
66
|
pageSize: number;
|
|
67
67
|
currentPage?: number;
|
|
@@ -587,13 +587,6 @@ export declare class CollectionBrowser extends LitElement implements InfiniteScr
|
|
|
587
587
|
* an error from the backend.
|
|
588
588
|
*/
|
|
589
589
|
emitSearchError(): void;
|
|
590
|
-
/**
|
|
591
|
-
* Emits a `collectionExtraInfoLoaded` event when the data source has received
|
|
592
|
-
* collection metadata from the backend. This allows parent components to react
|
|
593
|
-
* to the metadata (e.g., to update their default sort based on the collection's
|
|
594
|
-
* `sort-by` metadata field).
|
|
595
|
-
*/
|
|
596
|
-
emitCollectionExtraInfoLoaded(collectionExtraInfo?: CollectionExtraInfo): void;
|
|
597
590
|
/**
|
|
598
591
|
* Emits a `queryStateChanged` event indicating that one or more of this component's
|
|
599
592
|
* properties have changed in a way that could affect the set of search results.
|
|
@@ -659,6 +652,22 @@ export declare class CollectionBrowser extends LitElement implements InfiniteScr
|
|
|
659
652
|
* Sets the total number of tiles displayed in the infinite scroller.
|
|
660
653
|
*/
|
|
661
654
|
setTileCount(count: number): void;
|
|
655
|
+
/**
|
|
656
|
+
* Applies the default sort options for the TV search results page
|
|
657
|
+
*/
|
|
658
|
+
applyDefaultTVSearchSort(): void;
|
|
659
|
+
/**
|
|
660
|
+
* Applies any default sort option for the current collection, by checking
|
|
661
|
+
* for one in the collection's metadata. If none is found, defaults to sorting
|
|
662
|
+
* descending by:
|
|
663
|
+
* - Date Favorited for fav-* collections
|
|
664
|
+
* - Weekly views for all other collections
|
|
665
|
+
*/
|
|
666
|
+
applyDefaultCollectionSort(collectionInfo?: CollectionExtraInfo): void;
|
|
667
|
+
/**
|
|
668
|
+
* Applies the default sort option for the current profile element
|
|
669
|
+
*/
|
|
670
|
+
applyDefaultProfileSort(): void;
|
|
662
671
|
/**
|
|
663
672
|
* This is useful for determining whether we need to reload the scroller.
|
|
664
673
|
*
|
|
@@ -5,7 +5,7 @@ import { classMap } from 'lit/directives/class-map.js';
|
|
|
5
5
|
import { msg } from '@lit/localize';
|
|
6
6
|
import { SearchType, } from '@internetarchive/search-service';
|
|
7
7
|
import '@internetarchive/infinite-scroller';
|
|
8
|
-
import { SortField, getDefaultSelectedFacets, SORT_OPTIONS, defaultFacetDisplayOrder, tvFacetDisplayOrder, defaultSortAvailability, favoritesSortAvailability, tvSortAvailability, } from './models';
|
|
8
|
+
import { SortField, getDefaultSelectedFacets, sortOptionFromAPIString, SORT_OPTIONS, defaultProfileElementSorts, defaultFacetDisplayOrder, tvFacetDisplayOrder, defaultSortAvailability, favoritesSortAvailability, tvSortAvailability, } from './models';
|
|
9
9
|
import { RestorationStateHandler, } from './restoration-state-handler';
|
|
10
10
|
import { CollectionBrowserDataSource } from './data-source/collection-browser-data-source';
|
|
11
11
|
import { FACETLESS_PAGE_ELEMENTS } from './data-source/models';
|
|
@@ -373,6 +373,9 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
373
373
|
}
|
|
374
374
|
willUpdate(changed) {
|
|
375
375
|
this.setPlaceholderType();
|
|
376
|
+
if (changed.has('searchType') && this.searchType === SearchType.TV) {
|
|
377
|
+
this.applyDefaultTVSearchSort();
|
|
378
|
+
}
|
|
376
379
|
}
|
|
377
380
|
render() {
|
|
378
381
|
return html `
|
|
@@ -1271,12 +1274,6 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
1271
1274
|
this.maxSelectedDate = queryState.maxSelectedDate;
|
|
1272
1275
|
this.selectedSort = queryState.selectedSort ?? SortField.default;
|
|
1273
1276
|
this.sortDirection = queryState.sortDirection;
|
|
1274
|
-
if (queryState.defaultSortField) {
|
|
1275
|
-
this.defaultSortField = queryState.defaultSortField;
|
|
1276
|
-
}
|
|
1277
|
-
if (queryState.defaultSortDirection !== undefined) {
|
|
1278
|
-
this.defaultSortDirection = queryState.defaultSortDirection;
|
|
1279
|
-
}
|
|
1280
1277
|
this.selectedTitleFilter = queryState.selectedTitleFilter;
|
|
1281
1278
|
this.selectedCreatorFilter = queryState.selectedCreatorFilter;
|
|
1282
1279
|
this.pagesToRender = this.initialPageNumber;
|
|
@@ -1365,6 +1362,19 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
1365
1362
|
});
|
|
1366
1363
|
}
|
|
1367
1364
|
}
|
|
1365
|
+
if (changed.has('profileElement')) {
|
|
1366
|
+
this.applyDefaultProfileSort();
|
|
1367
|
+
}
|
|
1368
|
+
if (changed.has('withinCollection') && this.withinCollection) {
|
|
1369
|
+
// Set a sensible default collection sort while we load results, which we will later
|
|
1370
|
+
// adjust based on any sort-by metadata once the response arrives.
|
|
1371
|
+
if (!this.baseQuery) {
|
|
1372
|
+
this.defaultSortField = this.withinCollection.startsWith('fav-')
|
|
1373
|
+
? SortField.datefavorited
|
|
1374
|
+
: SortField.weeklyview;
|
|
1375
|
+
this.defaultSortDirection = 'desc';
|
|
1376
|
+
}
|
|
1377
|
+
}
|
|
1368
1378
|
if (changed.has('baseQuery')) {
|
|
1369
1379
|
this.emitBaseQueryChanged();
|
|
1370
1380
|
}
|
|
@@ -1579,17 +1589,6 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
1579
1589
|
detail: this.dataSource.queryErrorMessage,
|
|
1580
1590
|
}));
|
|
1581
1591
|
}
|
|
1582
|
-
/**
|
|
1583
|
-
* Emits a `collectionExtraInfoLoaded` event when the data source has received
|
|
1584
|
-
* collection metadata from the backend. This allows parent components to react
|
|
1585
|
-
* to the metadata (e.g., to update their default sort based on the collection's
|
|
1586
|
-
* `sort-by` metadata field).
|
|
1587
|
-
*/
|
|
1588
|
-
emitCollectionExtraInfoLoaded(collectionExtraInfo) {
|
|
1589
|
-
this.dispatchEvent(new CustomEvent('collectionExtraInfoLoaded', {
|
|
1590
|
-
detail: collectionExtraInfo,
|
|
1591
|
-
}));
|
|
1592
|
-
}
|
|
1593
1592
|
/**
|
|
1594
1593
|
* Emits a `queryStateChanged` event indicating that one or more of this component's
|
|
1595
1594
|
* properties have changed in a way that could affect the set of search results.
|
|
@@ -1843,6 +1842,66 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
1843
1842
|
this.infiniteScroller.itemCount = count;
|
|
1844
1843
|
}
|
|
1845
1844
|
}
|
|
1845
|
+
/**
|
|
1846
|
+
* Applies the default sort options for the TV search results page
|
|
1847
|
+
*/
|
|
1848
|
+
applyDefaultTVSearchSort() {
|
|
1849
|
+
this.defaultSortField = SortField.datearchived;
|
|
1850
|
+
this.defaultSortDirection = 'desc';
|
|
1851
|
+
}
|
|
1852
|
+
/**
|
|
1853
|
+
* Applies any default sort option for the current collection, by checking
|
|
1854
|
+
* for one in the collection's metadata. If none is found, defaults to sorting
|
|
1855
|
+
* descending by:
|
|
1856
|
+
* - Date Favorited for fav-* collections
|
|
1857
|
+
* - Weekly views for all other collections
|
|
1858
|
+
*/
|
|
1859
|
+
applyDefaultCollectionSort(collectionInfo) {
|
|
1860
|
+
if (this.baseQuery) {
|
|
1861
|
+
// If there's a query set, then we default to relevance sorting regardless of
|
|
1862
|
+
// the collection metadata-specified sort.
|
|
1863
|
+
this.defaultSortField = SortField.relevance;
|
|
1864
|
+
this.defaultSortDirection = null;
|
|
1865
|
+
return;
|
|
1866
|
+
}
|
|
1867
|
+
// Favorite collections sort on Date Favorited by default.
|
|
1868
|
+
// Other collections fall back to sorting on weekly views.
|
|
1869
|
+
const baseDefaultSort = collectionInfo?.public_metadata?.identifier?.startsWith('fav-')
|
|
1870
|
+
? '-favoritedate'
|
|
1871
|
+
: '-week';
|
|
1872
|
+
// The collection metadata may override the default sorting with something else
|
|
1873
|
+
const metadataSort = collectionInfo?.public_metadata?.['sort-by'];
|
|
1874
|
+
// Prefer the metadata-specified sort if one exists
|
|
1875
|
+
const defaultSortToApply = metadataSort ?? baseDefaultSort;
|
|
1876
|
+
// Account for both -field and field:dir formats
|
|
1877
|
+
let [field, dir] = defaultSortToApply.split(':');
|
|
1878
|
+
if (field.startsWith('-')) {
|
|
1879
|
+
field = field.slice(1);
|
|
1880
|
+
dir = 'desc';
|
|
1881
|
+
}
|
|
1882
|
+
else if (!['asc', 'desc'].includes(dir)) {
|
|
1883
|
+
dir = 'asc';
|
|
1884
|
+
}
|
|
1885
|
+
const sortOption = sortOptionFromAPIString(field);
|
|
1886
|
+
const sortField = sortOption.field;
|
|
1887
|
+
if (sortField && sortField !== SortField.default) {
|
|
1888
|
+
this.defaultSortField = sortField;
|
|
1889
|
+
this.defaultSortDirection = dir;
|
|
1890
|
+
}
|
|
1891
|
+
}
|
|
1892
|
+
/**
|
|
1893
|
+
* Applies the default sort option for the current profile element
|
|
1894
|
+
*/
|
|
1895
|
+
applyDefaultProfileSort() {
|
|
1896
|
+
if (this.profileElement) {
|
|
1897
|
+
const defaultSortField = defaultProfileElementSorts[this.profileElement];
|
|
1898
|
+
this.defaultSortField = defaultSortField ?? SortField.weeklyview;
|
|
1899
|
+
}
|
|
1900
|
+
else {
|
|
1901
|
+
this.defaultSortField = SortField.weeklyview;
|
|
1902
|
+
}
|
|
1903
|
+
this.defaultSortDirection = 'desc';
|
|
1904
|
+
}
|
|
1846
1905
|
/**
|
|
1847
1906
|
* This is useful for determining whether we need to reload the scroller.
|
|
1848
1907
|
*
|