@internetarchive/collection-browser 1.14.17-alpha.2 → 1.14.17-alpha.21
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 +1 -1
- package/dist/index.js.map +1 -1
- package/dist/src/app-root.d.ts +1 -0
- package/dist/src/app-root.js +38 -0
- package/dist/src/app-root.js.map +1 -1
- package/dist/src/collection-browser.d.ts +2 -15
- package/dist/src/collection-browser.js +22 -29
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/data-source/collection-browser-data-source.d.ts +55 -32
- package/dist/src/data-source/collection-browser-data-source.js +155 -162
- package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
- package/dist/src/data-source/models.d.ts +6 -3
- package/dist/src/data-source/models.js.map +1 -1
- package/dist/src/manage/manage-bar.d.ts +1 -1
- package/dist/src/manage/manage-bar.js.map +1 -1
- package/dist/src/models.d.ts +20 -4
- package/dist/src/models.js +105 -0
- package/dist/src/models.js.map +1 -1
- package/dist/src/sort-filter-bar/sort-filter-bar.js +25 -16
- package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
- package/dist/src/tiles/grid/item-tile.d.ts +1 -0
- package/dist/src/tiles/grid/item-tile.js +28 -1
- package/dist/src/tiles/grid/item-tile.js.map +1 -1
- package/dist/src/tiles/grid/tile-stats.js +13 -8
- package/dist/src/tiles/grid/tile-stats.js.map +1 -1
- package/dist/src/tiles/list/tile-list-compact.js +1 -1
- package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
- package/dist/src/tiles/list/tile-list.d.ts +1 -0
- package/dist/src/tiles/list/tile-list.js +32 -1
- package/dist/src/tiles/list/tile-list.js.map +1 -1
- package/dist/src/tiles/tile-dispatcher.js +3 -2
- package/dist/src/tiles/tile-dispatcher.js.map +1 -1
- package/dist/src/tiles/tile-display-value-provider.d.ts +6 -2
- package/dist/src/tiles/tile-display-value-provider.js +15 -1
- package/dist/src/tiles/tile-display-value-provider.js.map +1 -1
- package/dist/src/utils/collapse-repeated-quotes.d.ts +11 -0
- package/dist/src/utils/collapse-repeated-quotes.js +14 -0
- package/dist/src/utils/collapse-repeated-quotes.js.map +1 -0
- package/dist/src/utils/resolve-mediatype.d.ts +8 -0
- package/dist/src/utils/resolve-mediatype.js +24 -0
- package/dist/src/utils/resolve-mediatype.js.map +1 -0
- package/dist/test/collection-browser.test.js +39 -19
- package/dist/test/collection-browser.test.js.map +1 -1
- package/dist/test/collection-facets/more-facets-content.test.js +2 -2
- package/dist/test/collection-facets/more-facets-content.test.js.map +1 -1
- package/dist/test/collection-facets.test.js +5 -0
- package/dist/test/collection-facets.test.js.map +1 -1
- package/dist/test/item-image.test.js +33 -34
- package/dist/test/item-image.test.js.map +1 -1
- package/dist/test/mocks/mock-search-responses.d.ts +1 -0
- package/dist/test/mocks/mock-search-responses.js +62 -0
- package/dist/test/mocks/mock-search-responses.js.map +1 -1
- package/dist/test/sort-filter-bar/sort-filter-bar.test.js +41 -4
- package/dist/test/sort-filter-bar/sort-filter-bar.test.js.map +1 -1
- package/dist/test/tiles/hover/hover-pane-controller.test.js +18 -17
- package/dist/test/tiles/hover/hover-pane-controller.test.js.map +1 -1
- package/package.json +2 -2
- package/src/app-root.ts +39 -0
- package/src/collection-browser.ts +24 -40
- package/src/data-source/collection-browser-data-source.ts +160 -132
- package/src/data-source/models.ts +6 -2
- package/src/manage/manage-bar.ts +1 -1
- package/src/models.ts +154 -3
- package/src/sort-filter-bar/sort-filter-bar.ts +26 -16
- package/src/tiles/grid/item-tile.ts +36 -1
- package/src/tiles/grid/tile-stats.ts +12 -7
- package/src/tiles/list/tile-list-compact.ts +1 -1
- package/src/tiles/list/tile-list.ts +43 -5
- package/src/tiles/tile-dispatcher.ts +2 -1
- package/src/tiles/tile-display-value-provider.ts +20 -2
- package/src/utils/collapse-repeated-quotes.ts +13 -0
- package/src/utils/resolve-mediatype.ts +26 -0
- package/test/collection-browser.test.ts +74 -19
- package/test/collection-facets/more-facets-content.test.ts +4 -2
- package/test/collection-facets.test.ts +5 -0
- package/test/item-image.test.ts +34 -36
- package/test/mocks/mock-search-responses.ts +66 -0
- package/test/sort-filter-bar/sort-filter-bar.test.ts +50 -4
- package/test/tiles/hover/hover-pane-controller.test.ts +19 -17
- package/dist/src/data-source/data-source-fetch-provider.d.ts +0 -13
- package/dist/src/data-source/data-source-fetch-provider.js +0 -61
- package/dist/src/data-source/data-source-fetch-provider.js.map +0 -1
- package/dist/src/selected-facets.d.ts +0 -67
- package/dist/src/selected-facets.js +0 -149
- package/dist/src/selected-facets.js.map +0 -1
- package/src/data-source/data-source-fetch-provider.ts +0 -79
- package/src/selected-facets.ts +0 -216
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the input string, but removing one set of quotes from all instances of
|
|
3
|
+
* ""clauses wrapped in two sets of quotes"". This assumes the quotes are already
|
|
4
|
+
* URL-encoded.
|
|
5
|
+
*
|
|
6
|
+
* This should be a temporary measure to address the fact that the __href__ field
|
|
7
|
+
* sometimes acquires extra quotation marks during query rewriting. Once there is a
|
|
8
|
+
* full Lucene parser in place that handles quoted queries correctly, this can likely
|
|
9
|
+
* be removed.
|
|
10
|
+
*/
|
|
11
|
+
export function collapseRepeatedQuotes(str) {
|
|
12
|
+
return str === null || str === void 0 ? void 0 : str.replace(/%22%22(?!%22%22)(.+?)%22%22/g, '%22$1%22');
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=collapse-repeated-quotes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collapse-repeated-quotes.js","sourceRoot":"","sources":["../../../src/utils/collapse-repeated-quotes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,MAAM,UAAU,sBAAsB,CAAC,GAAY;IACjD,OAAO,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,OAAO,CAAC,8BAA8B,EAAE,UAAU,CAAC,CAAC;AAClE,CAAC","sourcesContent":["/**\n * Returns the input string, but removing one set of quotes from all instances of\n * \"\"clauses wrapped in two sets of quotes\"\". This assumes the quotes are already\n * URL-encoded.\n *\n * This should be a temporary measure to address the fact that the __href__ field\n * sometimes acquires extra quotation marks during query rewriting. Once there is a\n * full Lucene parser in place that handles quoted queries correctly, this can likely\n * be removed.\n */\nexport function collapseRepeatedQuotes(str?: string): string | undefined {\n return str?.replace(/%22%22(?!%22%22)(.+?)%22%22/g, '%22$1%22');\n}\n"]}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { MediaType } from '@internetarchive/field-parsers';
|
|
2
|
+
import type { SearchResult } from '@internetarchive/search-service';
|
|
3
|
+
/**
|
|
4
|
+
* Returns the mediatype string for the given search result, taking into account
|
|
5
|
+
* the special `favorited_search` hit type.
|
|
6
|
+
* @param result The search result to extract a mediatype from
|
|
7
|
+
*/
|
|
8
|
+
export declare function resolveMediatype(result: SearchResult): MediaType;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns the mediatype string for the given search result, taking into account
|
|
3
|
+
* the special `favorited_search` hit type.
|
|
4
|
+
* @param result The search result to extract a mediatype from
|
|
5
|
+
*/
|
|
6
|
+
export function resolveMediatype(result) {
|
|
7
|
+
var _a, _b, _c;
|
|
8
|
+
/**
|
|
9
|
+
* hit_type == 'favorited_search' is basically a new hit_type
|
|
10
|
+
* - we are getting from PPS.
|
|
11
|
+
* - which gives response for fav- collection
|
|
12
|
+
* - having favorited items like account/collection/item etc..
|
|
13
|
+
* - as user can also favorite a search result (a search page)
|
|
14
|
+
* - so we need to have response (having fav- items and fav- search results)
|
|
15
|
+
*
|
|
16
|
+
* if backend hit_type == 'favorited_search'
|
|
17
|
+
* - let's assume a "search" as new mediatype
|
|
18
|
+
*/
|
|
19
|
+
if (((_a = result === null || result === void 0 ? void 0 : result.rawMetadata) === null || _a === void 0 ? void 0 : _a.hit_type) === 'favorited_search') {
|
|
20
|
+
return 'search';
|
|
21
|
+
}
|
|
22
|
+
return (_c = (_b = result.mediatype) === null || _b === void 0 ? void 0 : _b.value) !== null && _c !== void 0 ? _c : 'data';
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=resolve-mediatype.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-mediatype.js","sourceRoot":"","sources":["../../../src/utils/resolve-mediatype.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,MAAM,UAAU,gBAAgB,CAAC,MAAoB;;IACnD;;;;;;;;;;OAUG;IACH,IAAI,CAAA,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,WAAW,0CAAE,QAAQ,MAAK,kBAAkB,EAAE;QACxD,OAAO,QAAQ,CAAC;KACjB;IAED,OAAO,MAAA,MAAA,MAAM,CAAC,SAAS,0CAAE,KAAK,mCAAI,MAAM,CAAC;AAC3C,CAAC","sourcesContent":["import type { MediaType } from '@internetarchive/field-parsers';\nimport type { SearchResult } from '@internetarchive/search-service';\n\n/**\n * Returns the mediatype string for the given search result, taking into account\n * the special `favorited_search` hit type.\n * @param result The search result to extract a mediatype from\n */\nexport function resolveMediatype(result: SearchResult): MediaType {\n /**\n * hit_type == 'favorited_search' is basically a new hit_type\n * - we are getting from PPS.\n * - which gives response for fav- collection\n * - having favorited items like account/collection/item etc..\n * - as user can also favorite a search result (a search page)\n * - so we need to have response (having fav- items and fav- search results)\n *\n * if backend hit_type == 'favorited_search'\n * - let's assume a \"search\" as new mediatype\n */\n if (result?.rawMetadata?.hit_type === 'favorited_search') {\n return 'search';\n }\n\n return result.mediatype?.value ?? 'data';\n}\n"]}
|
|
@@ -209,12 +209,13 @@ describe('Collection Browser', () => {
|
|
|
209
209
|
</collection-browser>`);
|
|
210
210
|
el.baseQuery = 'hello';
|
|
211
211
|
await el.updateComplete;
|
|
212
|
+
await nextTick();
|
|
212
213
|
const facets = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('collection-facets');
|
|
213
214
|
const sortBar = (_b = el.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('sort-filter-bar');
|
|
214
215
|
const infiniteScroller = (_c = el.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('infinite-scroller');
|
|
215
|
-
expect(facets).to.exist;
|
|
216
|
-
expect(sortBar).to.exist;
|
|
217
|
-
expect(infiniteScroller).to.exist;
|
|
216
|
+
expect(facets, 'facets').to.exist;
|
|
217
|
+
expect(sortBar, 'sort bar').to.exist;
|
|
218
|
+
expect(infiniteScroller, 'infinite scroller').to.exist;
|
|
218
219
|
});
|
|
219
220
|
it('queries the search service when given a base query', async () => {
|
|
220
221
|
var _a, _b, _c;
|
|
@@ -332,6 +333,18 @@ describe('Collection Browser', () => {
|
|
|
332
333
|
</collection-browser>`);
|
|
333
334
|
expect(el.searchType).to.equal(SearchType.FULLTEXT);
|
|
334
335
|
});
|
|
336
|
+
it('can construct tile models with many fields present', async () => {
|
|
337
|
+
const searchService = new MockSearchService();
|
|
338
|
+
const el = await fixture(html `<collection-browser .searchService=${searchService}>
|
|
339
|
+
</collection-browser>`);
|
|
340
|
+
el.baseQuery = 'many-fields';
|
|
341
|
+
await el.updateComplete;
|
|
342
|
+
await el.initialSearchComplete;
|
|
343
|
+
const cellTemplate = el.cellForIndex(0);
|
|
344
|
+
expect(cellTemplate).to.exist;
|
|
345
|
+
const cell = await fixture(cellTemplate);
|
|
346
|
+
expect(cell).to.exist;
|
|
347
|
+
});
|
|
335
348
|
it('applies loggedin flag to tile models if needed', async () => {
|
|
336
349
|
var _a;
|
|
337
350
|
const searchService = new MockSearchService();
|
|
@@ -558,9 +571,10 @@ describe('Collection Browser', () => {
|
|
|
558
571
|
expect(el.selectedSort).to.equal(SortField.default);
|
|
559
572
|
el.baseQuery = 'foo';
|
|
560
573
|
await el.updateComplete;
|
|
561
|
-
|
|
574
|
+
await nextTick();
|
|
575
|
+
const sortBar = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#content-container sort-filter-bar');
|
|
562
576
|
const sortSelector = (_b = sortBar === null || sortBar === void 0 ? void 0 : sortBar.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('#desktop-sort-selector');
|
|
563
|
-
expect(sortSelector).to.exist;
|
|
577
|
+
expect(sortSelector, 'sort bar').to.exist;
|
|
564
578
|
// Click the title sorter
|
|
565
579
|
(_d = (_c = [...sortSelector === null || sortSelector === void 0 ? void 0 : sortSelector.children] // tsc doesn't know children is iterable
|
|
566
580
|
.find(child => { var _a; return ((_a = child.textContent) === null || _a === void 0 ? void 0 : _a.trim()) === 'Title'; })) === null || _c === void 0 ? void 0 : _c.querySelector('button')) === null || _d === void 0 ? void 0 : _d.click();
|
|
@@ -654,7 +668,10 @@ describe('Collection Browser', () => {
|
|
|
654
668
|
it('sets date range query when date picker selection changed', async () => {
|
|
655
669
|
var _a, _b, _c;
|
|
656
670
|
const searchService = new MockSearchService();
|
|
657
|
-
const el = await fixture(html `<collection-browser
|
|
671
|
+
const el = await fixture(html `<collection-browser
|
|
672
|
+
.searchService=${searchService}
|
|
673
|
+
.suppressPlaceholders=${true}
|
|
674
|
+
>
|
|
658
675
|
</collection-browser>`);
|
|
659
676
|
el.baseQuery = 'years'; // Includes year_histogram aggregation in response
|
|
660
677
|
el.showHistogramDatePicker = true;
|
|
@@ -664,7 +681,7 @@ describe('Collection Browser', () => {
|
|
|
664
681
|
// Wait for the date picker to be rendered (which may take until the next tick)
|
|
665
682
|
await nextTick();
|
|
666
683
|
const histogram = (_b = facets === null || facets === void 0 ? void 0 : facets.shadowRoot) === null || _b === void 0 ? void 0 : _b.querySelector('histogram-date-range');
|
|
667
|
-
expect(histogram).to.exist;
|
|
684
|
+
expect(histogram, 'histogram exists').to.exist;
|
|
668
685
|
// Enter a new min date into the date picker
|
|
669
686
|
const minDateInput = (_c = histogram.shadowRoot) === null || _c === void 0 ? void 0 : _c.querySelector('#date-min');
|
|
670
687
|
const pressEnterEvent = new KeyboardEvent('keyup', {
|
|
@@ -804,13 +821,14 @@ describe('Collection Browser', () => {
|
|
|
804
821
|
// infinite scroller does exist.
|
|
805
822
|
el.baseQuery = 'collection:foo';
|
|
806
823
|
await el.updateComplete;
|
|
824
|
+
await nextTick();
|
|
807
825
|
const infiniteScroller = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('infinite-scroller');
|
|
808
826
|
expect(infiniteScroller).to.exist;
|
|
809
827
|
const oldScrollToCell = infiniteScroller.scrollToCell;
|
|
810
828
|
const spy = sinon.spy();
|
|
811
829
|
infiniteScroller.scrollToCell = spy;
|
|
812
830
|
await el.goToPage(1);
|
|
813
|
-
expect(spy.callCount).to.equal(1);
|
|
831
|
+
expect(spy.callCount, 'scroll to page fires once').to.equal(1);
|
|
814
832
|
infiniteScroller.scrollToCell = oldScrollToCell;
|
|
815
833
|
});
|
|
816
834
|
it('shows mobile facets in mobile view', async () => {
|
|
@@ -858,6 +876,7 @@ describe('Collection Browser', () => {
|
|
|
858
876
|
// Infinite scroller won't exist unless there's a base query
|
|
859
877
|
el.baseQuery = 'collection:foo';
|
|
860
878
|
await el.updateComplete;
|
|
879
|
+
await nextTick();
|
|
861
880
|
const infiniteScroller = (_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('infinite-scroller');
|
|
862
881
|
infiniteScroller.reload = infiniteScrollerRefreshSpy;
|
|
863
882
|
expect(infiniteScrollerRefreshSpy.called).to.be.false;
|
|
@@ -865,33 +884,34 @@ describe('Collection Browser', () => {
|
|
|
865
884
|
// testing: `loggedIn`
|
|
866
885
|
el.loggedIn = true;
|
|
867
886
|
await el.updateComplete;
|
|
868
|
-
expect(infiniteScrollerRefreshSpy.called).to.be
|
|
869
|
-
|
|
887
|
+
expect(infiniteScrollerRefreshSpy.called, 'Infinite Scroller Refresh').to.be
|
|
888
|
+
.true;
|
|
889
|
+
expect(infiniteScrollerRefreshSpy.callCount, 'Infinite Scroller Refresh call count').to.equal(1);
|
|
870
890
|
el.loggedIn = false;
|
|
871
891
|
await el.updateComplete;
|
|
872
|
-
expect(infiniteScrollerRefreshSpy.callCount).to.equal(2);
|
|
892
|
+
expect(infiniteScrollerRefreshSpy.callCount, '2nd Infinite Scroller Refresh').to.equal(2);
|
|
873
893
|
// testing: `displayMode`
|
|
874
894
|
el.displayMode = 'list-compact';
|
|
875
895
|
el.searchContext = 'beta-search';
|
|
876
896
|
await el.updateComplete;
|
|
877
|
-
expect(infiniteScrollerRefreshSpy.callCount).to.equal(3);
|
|
897
|
+
expect(infiniteScrollerRefreshSpy.callCount, '3rd Infinite Scroller Refresh').to.equal(3);
|
|
878
898
|
expect(mockAnalyticsHandler.callCategory).to.equal('beta-search');
|
|
879
899
|
expect(mockAnalyticsHandler.callAction).to.equal('displayMode');
|
|
880
900
|
expect(mockAnalyticsHandler.callLabel).to.equal('list-compact');
|
|
881
901
|
el.displayMode = 'list-detail';
|
|
882
902
|
await el.updateComplete;
|
|
883
|
-
expect(infiniteScrollerRefreshSpy.callCount).to.equal(4);
|
|
903
|
+
expect(infiniteScrollerRefreshSpy.callCount, '4th Infinite Scroller Refresh').to.equal(4);
|
|
884
904
|
expect(mockAnalyticsHandler.callCategory).to.equal('beta-search');
|
|
885
905
|
expect(mockAnalyticsHandler.callAction).to.equal('displayMode');
|
|
886
906
|
expect(mockAnalyticsHandler.callLabel).to.equal('list-detail');
|
|
887
907
|
// testing: `baseNavigationUrl`
|
|
888
908
|
el.baseNavigationUrl = 'https://funtestsite.com';
|
|
889
909
|
await el.updateComplete;
|
|
890
|
-
expect(infiniteScrollerRefreshSpy.callCount).to.equal(5);
|
|
910
|
+
expect(infiniteScrollerRefreshSpy.callCount, '5th Infinite Scroller Refresh').to.equal(5);
|
|
891
911
|
// testing: `baseImageUrl`
|
|
892
912
|
el.baseImageUrl = 'https://funtestsiteforimages.com';
|
|
893
913
|
await el.updateComplete;
|
|
894
|
-
expect(infiniteScrollerRefreshSpy.callCount).to.equal(6);
|
|
914
|
+
expect(infiniteScrollerRefreshSpy.callCount, '6th Infinite Scroller Refresh').to.equal(6);
|
|
895
915
|
});
|
|
896
916
|
it('query the search service for single result', async () => {
|
|
897
917
|
var _a, _b;
|
|
@@ -1102,7 +1122,7 @@ describe('Collection Browser', () => {
|
|
|
1102
1122
|
expect(el.displayMode).to.equal('grid');
|
|
1103
1123
|
});
|
|
1104
1124
|
it('can remove all checked tiles', async () => {
|
|
1105
|
-
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
1125
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
1106
1126
|
const searchService = new MockSearchService();
|
|
1107
1127
|
const el = await fixture(html `<collection-browser
|
|
1108
1128
|
.searchService=${searchService}
|
|
@@ -1136,10 +1156,10 @@ describe('Collection Browser', () => {
|
|
|
1136
1156
|
// Remove checked tiles and verify that we only kept the second tile
|
|
1137
1157
|
el.removeCheckedTiles();
|
|
1138
1158
|
await el.updateComplete;
|
|
1139
|
-
|
|
1159
|
+
expect((_g = el === null || el === void 0 ? void 0 : el.dataSource) === null || _g === void 0 ? void 0 : _g.size, 'data source count').to.equal(1);
|
|
1160
|
+
tiles = (_j = (_h = el.shadowRoot) === null || _h === void 0 ? void 0 : _h.querySelector('infinite-scroller').shadowRoot) === null || _j === void 0 ? void 0 : _j.querySelectorAll('tile-dispatcher');
|
|
1140
1161
|
expect(tiles).to.exist;
|
|
1141
|
-
expect(tiles
|
|
1142
|
-
expect((_h = tiles[0].model) === null || _h === void 0 ? void 0 : _h.identifier).to.equal('bar');
|
|
1162
|
+
expect(tiles.length, 'tile count after `el.removeCheckedTiles()`').to.equal(1);
|
|
1143
1163
|
});
|
|
1144
1164
|
it('can check/uncheck all tiles', async () => {
|
|
1145
1165
|
const searchService = new MockSearchService();
|