@internetarchive/collection-browser 4.3.2-alpha-webdev7939.1 → 4.3.2-alpha-webdev7939.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/index.js.map +1 -1
- package/dist/src/collection-browser.d.ts +10 -0
- package/dist/src/collection-browser.js +34 -16
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/tiles/base-tile-component.js.map +1 -1
- package/dist/src/tiles/grid/item-tile.js +138 -138
- package/dist/src/tiles/grid/item-tile.js.map +1 -1
- package/dist/src/tiles/list/tile-list-compact-header.js +45 -45
- package/dist/src/tiles/list/tile-list-compact-header.js.map +1 -1
- package/dist/src/tiles/list/tile-list-compact.js +99 -99
- package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
- package/dist/src/tiles/list/tile-list.js +297 -297
- package/dist/src/tiles/list/tile-list.js.map +1 -1
- package/dist/src/tiles/models.js.map +1 -1
- package/dist/src/tiles/tile-dispatcher.js +216 -216
- package/dist/src/tiles/tile-dispatcher.js.map +1 -1
- package/index.ts +28 -28
- package/package.json +2 -2
- package/src/collection-browser.ts +43 -16
- package/src/tiles/base-tile-component.ts +65 -65
- package/src/tiles/grid/item-tile.ts +346 -346
- package/src/tiles/list/tile-list-compact-header.ts +86 -86
- package/src/tiles/list/tile-list-compact.ts +239 -239
- package/src/tiles/list/tile-list.ts +700 -700
- package/src/tiles/models.ts +8 -8
- package/src/tiles/tile-dispatcher.ts +527 -527
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,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';\
|
|
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"]}
|
|
@@ -634,6 +634,16 @@ export declare class CollectionBrowser extends LitElement implements InfiniteScr
|
|
|
634
634
|
* @returns
|
|
635
635
|
*/
|
|
636
636
|
private visibleCellsChanged;
|
|
637
|
+
/**
|
|
638
|
+
* Recomputes the current page from the given set of visible cell indices
|
|
639
|
+
* and emits `visiblePageChanged` if the page actually changed.
|
|
640
|
+
*/
|
|
641
|
+
private updateVisiblePage;
|
|
642
|
+
/**
|
|
643
|
+
* Sets the current page number and emits a `visiblePageChanged`
|
|
644
|
+
* event if the new page differs from the previous one.
|
|
645
|
+
*/
|
|
646
|
+
private setCurrentPage;
|
|
637
647
|
private initialQueryChangeHappened;
|
|
638
648
|
private historyPopOccurred;
|
|
639
649
|
private previousQueryKey?;
|
|
@@ -879,7 +879,7 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
879
879
|
if ((this.currentPage ?? 1) > 1) {
|
|
880
880
|
this.goToPage(1);
|
|
881
881
|
}
|
|
882
|
-
this.
|
|
882
|
+
this.setCurrentPage(1);
|
|
883
883
|
}
|
|
884
884
|
/**
|
|
885
885
|
* Fires an analytics event for sorting changes.
|
|
@@ -1696,26 +1696,39 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
1696
1696
|
* @returns
|
|
1697
1697
|
*/
|
|
1698
1698
|
visibleCellsChanged(e) {
|
|
1699
|
+
this.updateVisiblePage(e.detail.visibleCellIndices);
|
|
1700
|
+
}
|
|
1701
|
+
/**
|
|
1702
|
+
* Recomputes the current page from the given set of visible cell indices
|
|
1703
|
+
* and emits `visiblePageChanged` if the page actually changed.
|
|
1704
|
+
*/
|
|
1705
|
+
updateVisiblePage(visibleCellIndices) {
|
|
1699
1706
|
if (this.isScrollingToCell)
|
|
1700
1707
|
return;
|
|
1701
|
-
const { visibleCellIndices } = e.detail;
|
|
1702
1708
|
if (visibleCellIndices.length === 0)
|
|
1703
1709
|
return;
|
|
1710
|
+
// The indices aren't necessarily sorted, so sort them here to ensure our
|
|
1711
|
+
// calculations below find the right cell/page.
|
|
1712
|
+
const sorted = [...visibleCellIndices].sort((a, b) => a - b);
|
|
1704
1713
|
// For page determination, do not count more than a single page of visible cells,
|
|
1705
1714
|
// since otherwise patrons using very tall screens will be treated as one page
|
|
1706
1715
|
// further than they actually are.
|
|
1707
|
-
const lastIndexWithinCurrentPage = Math.min(this.pageSize,
|
|
1708
|
-
const lastVisibleCellIndex =
|
|
1716
|
+
const lastIndexWithinCurrentPage = Math.min(this.pageSize, sorted.length) - 1;
|
|
1717
|
+
const lastVisibleCellIndex = sorted[lastIndexWithinCurrentPage];
|
|
1709
1718
|
const lastVisibleCellPage = Math.floor(lastVisibleCellIndex / this.pageSize) + 1;
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
+
this.setCurrentPage(lastVisibleCellPage);
|
|
1720
|
+
}
|
|
1721
|
+
/**
|
|
1722
|
+
* Sets the current page number and emits a `visiblePageChanged`
|
|
1723
|
+
* event if the new page differs from the previous one.
|
|
1724
|
+
*/
|
|
1725
|
+
setCurrentPage(pageNumber) {
|
|
1726
|
+
if (this.currentPage === pageNumber)
|
|
1727
|
+
return;
|
|
1728
|
+
this.currentPage = pageNumber;
|
|
1729
|
+
this.dispatchEvent(new CustomEvent('visiblePageChanged', {
|
|
1730
|
+
detail: { pageNumber },
|
|
1731
|
+
}));
|
|
1719
1732
|
}
|
|
1720
1733
|
/**
|
|
1721
1734
|
* A Promise which, after each query change, resolves once the fetches for the initial
|
|
@@ -1791,10 +1804,10 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
1791
1804
|
this.selectedFacets = restorationState.selectedFacets;
|
|
1792
1805
|
if (!this.suppressURLQuery)
|
|
1793
1806
|
this.baseQuery = restorationState.baseQuery;
|
|
1794
|
-
this.
|
|
1807
|
+
this.setCurrentPage(restorationState.currentPage ?? 1);
|
|
1795
1808
|
this.minSelectedDate = restorationState.minSelectedDate;
|
|
1796
1809
|
this.maxSelectedDate = restorationState.maxSelectedDate;
|
|
1797
|
-
if (this.currentPage > 1) {
|
|
1810
|
+
if (this.currentPage && this.currentPage > 1) {
|
|
1798
1811
|
this.goToPage(this.currentPage);
|
|
1799
1812
|
}
|
|
1800
1813
|
}
|
|
@@ -1884,9 +1897,14 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
|
|
|
1884
1897
|
setTimeout(resolve, 0);
|
|
1885
1898
|
});
|
|
1886
1899
|
this.isScrollingToCell = true;
|
|
1887
|
-
await this.infiniteScroller.scrollToCell(cellIndexToScrollTo, true);
|
|
1900
|
+
const scrolled = await this.infiniteScroller.scrollToCell(cellIndexToScrollTo, true);
|
|
1888
1901
|
this.isScrollingToCell = false;
|
|
1889
1902
|
this.infiniteScroller.refreshAllVisibleCells();
|
|
1903
|
+
// After we finish scrolling, recompute the visible page from the new state
|
|
1904
|
+
// so that it doesn't fall out of sync.
|
|
1905
|
+
if (scrolled) {
|
|
1906
|
+
this.updateVisiblePage(this.infiniteScroller.getVisibleCellIndices());
|
|
1907
|
+
}
|
|
1890
1908
|
}
|
|
1891
1909
|
/**
|
|
1892
1910
|
* Whether sorting by relevance makes sense for the current state.
|