@internetarchive/collection-browser 0.2.10-a1 → 0.2.10

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.
Files changed (189) hide show
  1. package/package.json +1 -1
  2. package/dist/index.d.ts +0 -9
  3. package/dist/index.js.map +0 -1
  4. package/dist/src/app-root.d.ts +0 -32
  5. package/dist/src/app-root.js +0 -285
  6. package/dist/src/app-root.js.map +0 -1
  7. package/dist/src/assets/img/icons/chevron.d.ts +0 -2
  8. package/dist/src/assets/img/icons/chevron.js +0 -4
  9. package/dist/src/assets/img/icons/chevron.js.map +0 -1
  10. package/dist/src/assets/img/icons/eye-closed.d.ts +0 -2
  11. package/dist/src/assets/img/icons/eye-closed.js +0 -5
  12. package/dist/src/assets/img/icons/eye-closed.js.map +0 -1
  13. package/dist/src/assets/img/icons/eye.d.ts +0 -2
  14. package/dist/src/assets/img/icons/eye.js +0 -5
  15. package/dist/src/assets/img/icons/eye.js.map +0 -1
  16. package/dist/src/assets/img/icons/favorite-filled.d.ts +0 -1
  17. package/dist/src/assets/img/icons/favorite-filled.js +0 -11
  18. package/dist/src/assets/img/icons/favorite-filled.js.map +0 -1
  19. package/dist/src/assets/img/icons/mediatype/account.d.ts +0 -1
  20. package/dist/src/assets/img/icons/mediatype/account.js +0 -14
  21. package/dist/src/assets/img/icons/mediatype/account.js.map +0 -1
  22. package/dist/src/assets/img/icons/mediatype/audio.d.ts +0 -1
  23. package/dist/src/assets/img/icons/mediatype/audio.js +0 -14
  24. package/dist/src/assets/img/icons/mediatype/audio.js.map +0 -1
  25. package/dist/src/assets/img/icons/mediatype/collection.d.ts +0 -1
  26. package/dist/src/assets/img/icons/mediatype/collection.js +0 -12
  27. package/dist/src/assets/img/icons/mediatype/collection.js.map +0 -1
  28. package/dist/src/assets/img/icons/mediatype/data.d.ts +0 -1
  29. package/dist/src/assets/img/icons/mediatype/data.js +0 -15
  30. package/dist/src/assets/img/icons/mediatype/data.js.map +0 -1
  31. package/dist/src/assets/img/icons/mediatype/etree.d.ts +0 -1
  32. package/dist/src/assets/img/icons/mediatype/etree.js +0 -14
  33. package/dist/src/assets/img/icons/mediatype/etree.js.map +0 -1
  34. package/dist/src/assets/img/icons/mediatype/film.d.ts +0 -1
  35. package/dist/src/assets/img/icons/mediatype/film.js +0 -14
  36. package/dist/src/assets/img/icons/mediatype/film.js.map +0 -1
  37. package/dist/src/assets/img/icons/mediatype/images.d.ts +0 -1
  38. package/dist/src/assets/img/icons/mediatype/images.js +0 -13
  39. package/dist/src/assets/img/icons/mediatype/images.js.map +0 -1
  40. package/dist/src/assets/img/icons/mediatype/radio.d.ts +0 -1
  41. package/dist/src/assets/img/icons/mediatype/radio.js +0 -15
  42. package/dist/src/assets/img/icons/mediatype/radio.js.map +0 -1
  43. package/dist/src/assets/img/icons/mediatype/software.d.ts +0 -1
  44. package/dist/src/assets/img/icons/mediatype/software.js +0 -13
  45. package/dist/src/assets/img/icons/mediatype/software.js.map +0 -1
  46. package/dist/src/assets/img/icons/mediatype/texts.d.ts +0 -1
  47. package/dist/src/assets/img/icons/mediatype/texts.js +0 -13
  48. package/dist/src/assets/img/icons/mediatype/texts.js.map +0 -1
  49. package/dist/src/assets/img/icons/mediatype/tv.d.ts +0 -1
  50. package/dist/src/assets/img/icons/mediatype/tv.js +0 -14
  51. package/dist/src/assets/img/icons/mediatype/tv.js.map +0 -1
  52. package/dist/src/assets/img/icons/mediatype/video.d.ts +0 -1
  53. package/dist/src/assets/img/icons/mediatype/video.js +0 -14
  54. package/dist/src/assets/img/icons/mediatype/video.js.map +0 -1
  55. package/dist/src/assets/img/icons/mediatype/web.d.ts +0 -1
  56. package/dist/src/assets/img/icons/mediatype/web.js +0 -13
  57. package/dist/src/assets/img/icons/mediatype/web.js.map +0 -1
  58. package/dist/src/assets/img/icons/restricted.d.ts +0 -1
  59. package/dist/src/assets/img/icons/restricted.js +0 -29
  60. package/dist/src/assets/img/icons/restricted.js.map +0 -1
  61. package/dist/src/assets/img/icons/reviews.d.ts +0 -1
  62. package/dist/src/assets/img/icons/reviews.js +0 -11
  63. package/dist/src/assets/img/icons/reviews.js.map +0 -1
  64. package/dist/src/assets/img/icons/upload.d.ts +0 -1
  65. package/dist/src/assets/img/icons/upload.js +0 -12
  66. package/dist/src/assets/img/icons/upload.js.map +0 -1
  67. package/dist/src/assets/img/icons/views.d.ts +0 -1
  68. package/dist/src/assets/img/icons/views.js +0 -11
  69. package/dist/src/assets/img/icons/views.js.map +0 -1
  70. package/dist/src/circular-activity-indicator.d.ts +0 -5
  71. package/dist/src/circular-activity-indicator.js +0 -66
  72. package/dist/src/circular-activity-indicator.js.map +0 -1
  73. package/dist/src/collection-browser.d.ts +0 -207
  74. package/dist/src/collection-browser.js +0 -1210
  75. package/dist/src/collection-browser.js.map +0 -1
  76. package/dist/src/collection-facets.d.ts +0 -63
  77. package/dist/src/collection-facets.js +0 -560
  78. package/dist/src/collection-facets.js.map +0 -1
  79. package/dist/src/language-code-handler/language-code-handler.d.ts +0 -37
  80. package/dist/src/language-code-handler/language-code-handler.js +0 -27
  81. package/dist/src/language-code-handler/language-code-handler.js.map +0 -1
  82. package/dist/src/language-code-handler/language-code-mapping.d.ts +0 -1
  83. package/dist/src/language-code-handler/language-code-mapping.js +0 -563
  84. package/dist/src/language-code-handler/language-code-mapping.js.map +0 -1
  85. package/dist/src/mediatype/mediatype-config.d.ts +0 -3
  86. package/dist/src/mediatype/mediatype-config.js +0 -86
  87. package/dist/src/mediatype/mediatype-config.js.map +0 -1
  88. package/dist/src/models.d.ts +0 -84
  89. package/dist/src/models.js +0 -58
  90. package/dist/src/models.js.map +0 -1
  91. package/dist/src/restoration-state-handler.d.ts +0 -38
  92. package/dist/src/restoration-state-handler.js +0 -204
  93. package/dist/src/restoration-state-handler.js.map +0 -1
  94. package/dist/src/sort-filter-bar/alpha-bar.d.ts +0 -9
  95. package/dist/src/sort-filter-bar/alpha-bar.js +0 -98
  96. package/dist/src/sort-filter-bar/alpha-bar.js.map +0 -1
  97. package/dist/src/sort-filter-bar/img/compact.d.ts +0 -1
  98. package/dist/src/sort-filter-bar/img/compact.js +0 -5
  99. package/dist/src/sort-filter-bar/img/compact.js.map +0 -1
  100. package/dist/src/sort-filter-bar/img/list.d.ts +0 -1
  101. package/dist/src/sort-filter-bar/img/list.js +0 -5
  102. package/dist/src/sort-filter-bar/img/list.js.map +0 -1
  103. package/dist/src/sort-filter-bar/img/sort-triangle.d.ts +0 -1
  104. package/dist/src/sort-filter-bar/img/sort-triangle.js +0 -5
  105. package/dist/src/sort-filter-bar/img/sort-triangle.js.map +0 -1
  106. package/dist/src/sort-filter-bar/img/tile.d.ts +0 -1
  107. package/dist/src/sort-filter-bar/img/tile.js +0 -5
  108. package/dist/src/sort-filter-bar/img/tile.js.map +0 -1
  109. package/dist/src/sort-filter-bar/sort-filter-bar.d.ts +0 -85
  110. package/dist/src/sort-filter-bar/sort-filter-bar.js +0 -698
  111. package/dist/src/sort-filter-bar/sort-filter-bar.js.map +0 -1
  112. package/dist/src/styles/item-image-styles.d.ts +0 -8
  113. package/dist/src/styles/item-image-styles.js +0 -101
  114. package/dist/src/styles/item-image-styles.js.map +0 -1
  115. package/dist/src/tiles/collection-browser-loading-tile.d.ts +0 -5
  116. package/dist/src/tiles/collection-browser-loading-tile.js +0 -32
  117. package/dist/src/tiles/collection-browser-loading-tile.js.map +0 -1
  118. package/dist/src/tiles/grid/account-tile.d.ts +0 -8
  119. package/dist/src/tiles/grid/account-tile.js +0 -126
  120. package/dist/src/tiles/grid/account-tile.js.map +0 -1
  121. package/dist/src/tiles/grid/collection-tile.d.ts +0 -7
  122. package/dist/src/tiles/grid/collection-tile.js +0 -159
  123. package/dist/src/tiles/grid/collection-tile.js.map +0 -1
  124. package/dist/src/tiles/grid/item-tile.d.ts +0 -16
  125. package/dist/src/tiles/grid/item-tile.js +0 -174
  126. package/dist/src/tiles/grid/item-tile.js.map +0 -1
  127. package/dist/src/tiles/grid/tile-stats.d.ts +0 -10
  128. package/dist/src/tiles/grid/tile-stats.js +0 -134
  129. package/dist/src/tiles/grid/tile-stats.js.map +0 -1
  130. package/dist/src/tiles/item-image.d.ts +0 -31
  131. package/dist/src/tiles/item-image.js +0 -117
  132. package/dist/src/tiles/item-image.js.map +0 -1
  133. package/dist/src/tiles/item-tile-image.d.ts +0 -15
  134. package/dist/src/tiles/item-tile-image.js +0 -68
  135. package/dist/src/tiles/item-tile-image.js.map +0 -1
  136. package/dist/src/tiles/list/account-label.d.ts +0 -1
  137. package/dist/src/tiles/list/account-label.js +0 -7
  138. package/dist/src/tiles/list/account-label.js.map +0 -1
  139. package/dist/src/tiles/list/date-label.d.ts +0 -1
  140. package/dist/src/tiles/list/date-label.js +0 -13
  141. package/dist/src/tiles/list/date-label.js.map +0 -1
  142. package/dist/src/tiles/list/tile-list-compact-header.d.ts +0 -12
  143. package/dist/src/tiles/list/tile-list-compact-header.js +0 -84
  144. package/dist/src/tiles/list/tile-list-compact-header.js.map +0 -1
  145. package/dist/src/tiles/list/tile-list-compact.d.ts +0 -20
  146. package/dist/src/tiles/list/tile-list-compact.js +0 -215
  147. package/dist/src/tiles/list/tile-list-compact.js.map +0 -1
  148. package/dist/src/tiles/list/tile-list.d.ts +0 -47
  149. package/dist/src/tiles/list/tile-list.js +0 -492
  150. package/dist/src/tiles/list/tile-list.js.map +0 -1
  151. package/dist/src/tiles/mediatype-icon.d.ts +0 -9
  152. package/dist/src/tiles/mediatype-icon.js +0 -82
  153. package/dist/src/tiles/mediatype-icon.js.map +0 -1
  154. package/dist/src/tiles/tile-dispatcher.d.ts +0 -35
  155. package/dist/src/tiles/tile-dispatcher.js +0 -204
  156. package/dist/src/tiles/tile-dispatcher.js.map +0 -1
  157. package/dist/src/utils/format-count.d.ts +0 -7
  158. package/dist/src/utils/format-count.js +0 -76
  159. package/dist/src/utils/format-count.js.map +0 -1
  160. package/dist/src/utils/format-date.d.ts +0 -2
  161. package/dist/src/utils/format-date.js +0 -24
  162. package/dist/src/utils/format-date.js.map +0 -1
  163. package/dist/test/collection-browser.test.d.ts +0 -1
  164. package/dist/test/collection-browser.test.js +0 -45
  165. package/dist/test/collection-browser.test.js.map +0 -1
  166. package/dist/test/mediatype-config.test.d.ts +0 -1
  167. package/dist/test/mediatype-config.test.js +0 -17
  168. package/dist/test/mediatype-config.test.js.map +0 -1
  169. package/dist/test/mocks/mock-collection-name-cache.d.ts +0 -7
  170. package/dist/test/mocks/mock-collection-name-cache.js +0 -14
  171. package/dist/test/mocks/mock-collection-name-cache.js.map +0 -1
  172. package/dist/test/mocks/mock-search-responses.d.ts +0 -3
  173. package/dist/test/mocks/mock-search-responses.js +0 -32
  174. package/dist/test/mocks/mock-search-responses.js.map +0 -1
  175. package/dist/test/mocks/mock-search-service.d.ts +0 -8
  176. package/dist/test/mocks/mock-search-service.js +0 -16
  177. package/dist/test/mocks/mock-search-service.js.map +0 -1
  178. package/dist/test/tile-stats.test.d.ts +0 -1
  179. package/dist/test/tile-stats.test.js +0 -42
  180. package/dist/test/tile-stats.test.js.map +0 -1
  181. package/dist/test/tiles/grid/item-tile.test.d.ts +0 -1
  182. package/dist/test/tiles/grid/item-tile.test.js +0 -96
  183. package/dist/test/tiles/grid/item-tile.test.js.map +0 -1
  184. package/dist/test/utils/format-count.test.d.ts +0 -1
  185. package/dist/test/utils/format-count.test.js +0 -24
  186. package/dist/test/utils/format-count.test.js.map +0 -1
  187. package/dist/test/utils/format-date.test.d.ts +0 -1
  188. package/dist/test/utils/format-date.test.js +0 -18
  189. package/dist/test/utils/format-date.test.js.map +0 -1
@@ -1,1210 +0,0 @@
1
- import { __decorate } from "tslib";
2
- /* eslint-disable import/no-duplicates */
3
- import { html, css, LitElement, nothing, } from 'lit';
4
- import { customElement, property, query, state } from 'lit/decorators.js';
5
- import { ifDefined } from 'lit/directives/if-defined.js';
6
- import '@internetarchive/infinite-scroller';
7
- import './tiles/tile-dispatcher';
8
- import './tiles/collection-browser-loading-tile';
9
- import './sort-filter-bar/sort-filter-bar';
10
- import './collection-facets';
11
- import './circular-activity-indicator';
12
- import './sort-filter-bar/sort-filter-bar';
13
- import { SortField, SortFieldToMetadataField, defaultSelectedFacets, } from './models';
14
- import { RestorationStateHandler, } from './restoration-state-handler';
15
- import chevronIcon from './assets/img/icons/chevron';
16
- import { LanguageCodeHandler } from './language-code-handler/language-code-handler';
17
- let CollectionBrowser = class CollectionBrowser extends LitElement {
18
- constructor() {
19
- super(...arguments);
20
- this.baseImageUrl = 'https://archive.org';
21
- this.sortParam = null;
22
- this.selectedSort = SortField.relevance;
23
- this.selectedTitleFilter = null;
24
- this.selectedCreatorFilter = null;
25
- this.sortDirection = null;
26
- this.pageSize = 50;
27
- this.showHistogramDatePicker = false;
28
- this.pageContext = 'search';
29
- this.restorationStateHandler = new RestorationStateHandler({
30
- context: this.pageContext,
31
- });
32
- this.mobileBreakpoint = 600;
33
- this.loggedIn = false;
34
- /**
35
- * If item management UI active
36
- */
37
- this.isManageView = false;
38
- /**
39
- * The page that the consumer wants to load.
40
- */
41
- this.initialPageNumber = 1;
42
- /**
43
- * This the the number of pages that we want to show.
44
- *
45
- * The data isn't necessarily loaded for all of the pages, but this lets us
46
- * know how many cells we should render.
47
- */
48
- this.pagesToRender = this.initialPageNumber;
49
- this.searchResultsLoading = false;
50
- this.facetsLoading = false;
51
- this.fullYearAggregationLoading = false;
52
- this.mobileView = false;
53
- this.mobileFacetsVisible = false;
54
- this.languageCodeHandler = new LanguageCodeHandler();
55
- /**
56
- * When we're animated scrolling to the page, we don't want to fetch
57
- * all of the pages as it scrolls so this lets us know if we're scrolling
58
- */
59
- this.isScrollingToCell = false;
60
- /**
61
- * When we've reached the end of the data, stop trying to fetch more
62
- */
63
- this.endOfDataReached = false;
64
- /**
65
- * When page width resizes from desktop to mobile, set true to
66
- * disable expand/collapse transition when loading.
67
- */
68
- this.isResizeToMobile = false;
69
- this.placeholderCellTemplate = html `<collection-browser-loading-tile></collection-browser-loading-tile>`;
70
- /**
71
- * The results per page so we can paginate.
72
- *
73
- * This allows us to start in the middle of the search results and
74
- * fetch data before or after the current page. If we don't have a key
75
- * for the previous/next page, we'll fetch the next/previous page to populate it
76
- */
77
- this.dataSource = {};
78
- // we only want to scroll on the very first query change
79
- // so this keeps track of whether we've already set the initial query
80
- this.initialQueryChangeHappened = false;
81
- this.historyPopOccurred = false;
82
- // this maps the query to the pages being fetched for that query
83
- this.pageFetchesInProgress = {};
84
- }
85
- tileModelAtCellIndex(index) {
86
- var _a;
87
- const pageNumber = Math.floor(index / this.pageSize) + 1;
88
- const itemIndex = index % this.pageSize;
89
- const model = (_a = this.dataSource[pageNumber]) === null || _a === void 0 ? void 0 : _a[itemIndex];
90
- /**
91
- * If we encounter a model we don't have yet and we're not in the middle of an
92
- * automated scroll, fetch the page and just return undefined.
93
- * The datasource will be updated once the page is loaded and the cell will be rendered.
94
- *
95
- * We disable it during the automated scroll since we may fetch pages for cells the
96
- * user may never see.
97
- */
98
- if (!model && !this.isScrollingToCell) {
99
- this.fetchPage(pageNumber);
100
- }
101
- return model;
102
- }
103
- get sortFilterQueries() {
104
- const queries = [this.titleQuery, this.creatorQuery];
105
- return queries.filter(q => q).join(' AND ');
106
- }
107
- // this is the total number of tiles we expect if
108
- // the data returned is a full page worth
109
- // this is useful for putting in placeholders for the expected number of tiles
110
- get estimatedTileCount() {
111
- return this.pagesToRender * this.pageSize;
112
- }
113
- // this is the actual number of tiles in the datasource,
114
- // which is useful for removing excess placeholder tiles
115
- // once we reached the end of the data
116
- get actualTileCount() {
117
- return Object.keys(this.dataSource).reduce((acc, page) => acc + this.dataSource[page].length, 0);
118
- }
119
- /**
120
- * Go to the given page of results
121
- *
122
- * @param pageNumber
123
- */
124
- goToPage(pageNumber) {
125
- this.initialPageNumber = pageNumber;
126
- this.pagesToRender = pageNumber;
127
- this.scrollToPage(pageNumber);
128
- }
129
- clearFilters() {
130
- this.selectedFacets = defaultSelectedFacets;
131
- this.sortParam = null;
132
- this.selectedTitleFilter = null;
133
- this.selectedCreatorFilter = null;
134
- this.titleQuery = undefined;
135
- this.creatorQuery = undefined;
136
- this.selectedSort = SortField.relevance;
137
- this.sortDirection = null;
138
- }
139
- render() {
140
- return html `
141
- <div id="content-container" class=${this.mobileView ? 'mobile' : ''}>
142
- <div
143
- id="left-column"
144
- class="column${this.isResizeToMobile ? ' preload' : ''}"
145
- >
146
- <div id="mobile-header-container">
147
- ${this.mobileView ? this.mobileFacetsTemplate : nothing}
148
- <div id="results-total">
149
- <span id="big-results-count"
150
- >${this.totalResults !== undefined
151
- ? this.totalResults.toLocaleString()
152
- : '-'}</span
153
- >
154
- <span id="big-results-label">Results</span>
155
- </div>
156
- </div>
157
- <div
158
- id="facets-container"
159
- class=${!this.mobileView || this.mobileFacetsVisible
160
- ? 'expanded'
161
- : ''}
162
- >
163
- ${this.facetsTemplate}
164
- </div>
165
- </div>
166
- <div id="right-column" class="column">
167
- ${this.searchResultsLoading ? this.loadingTemplate : nothing}
168
- <sort-filter-bar
169
- .selectedSort=${this.selectedSort}
170
- .sortDirection=${this.sortDirection}
171
- .displayMode=${this.displayMode}
172
- .selectedTitleFilter=${this.selectedTitleFilter}
173
- .selectedCreatorFilter=${this.selectedCreatorFilter}
174
- .resizeObserver=${this.resizeObserver}
175
- @sortChanged=${this.userChangedSort}
176
- @displayModeChanged=${this.displayModeChanged}
177
- @titleLetterChanged=${this.titleLetterSelected}
178
- @creatorLetterChanged=${this.creatorLetterSelected}
179
- ></sort-filter-bar>
180
-
181
- ${this.displayMode === `list-compact`
182
- ? this.listHeaderTemplate
183
- : nothing}
184
- ${!this.searchResultsLoading && this.totalResults === 0
185
- ? html `
186
- <h2>
187
- Your search did not match any items in the Archive. Try
188
- different keywords or a more general search.
189
- </h2>
190
- `
191
- : nothing}
192
-
193
- <infinite-scroller
194
- class="${ifDefined(this.displayMode)}"
195
- .cellProvider=${this}
196
- .placeholderCellTemplate=${this.placeholderCellTemplate}
197
- @scrollThresholdReached=${this.scrollThresholdReached}
198
- @visibleCellsChanged=${this.visibleCellsChanged}
199
- >
200
- </infinite-scroller>
201
- </div>
202
- </div>
203
- `;
204
- }
205
- userChangedSort(e) {
206
- var _a;
207
- const { selectedSort, sortDirection } = e.detail;
208
- this.selectedSort = selectedSort;
209
- this.sortDirection = sortDirection;
210
- if (((_a = this.currentPage) !== null && _a !== void 0 ? _a : 1) > 1) {
211
- this.goToPage(1);
212
- }
213
- this.currentPage = 1;
214
- }
215
- selectedSortChanged() {
216
- if (this.selectedSort === 'relevance' || this.sortDirection === null) {
217
- this.sortParam = null;
218
- return;
219
- }
220
- const sortField = SortFieldToMetadataField[this.selectedSort];
221
- if (!sortField)
222
- return;
223
- this.sortParam = { field: sortField, direction: this.sortDirection };
224
- }
225
- displayModeChanged(e) {
226
- this.displayMode = e.detail.displayMode;
227
- }
228
- selectedTitleLetterChanged() {
229
- this.titleQuery = this.selectedTitleFilter
230
- ? `firstTitle:${this.selectedTitleFilter}`
231
- : undefined;
232
- }
233
- selectedCreatorLetterChanged() {
234
- this.creatorQuery = this.selectedCreatorFilter
235
- ? `firstCreator:${this.selectedCreatorFilter}`
236
- : undefined;
237
- }
238
- titleLetterSelected(e) {
239
- this.selectedCreatorFilter = null;
240
- this.selectedTitleFilter = e.detail.selectedLetter;
241
- }
242
- creatorLetterSelected(e) {
243
- this.selectedTitleFilter = null;
244
- this.selectedCreatorFilter = e.detail.selectedLetter;
245
- }
246
- get facetDataLoading() {
247
- return this.facetsLoading || this.fullYearAggregationLoading;
248
- }
249
- get mobileFacetsTemplate() {
250
- return html `
251
- <div id="mobile-filter-collapse">
252
- <h1
253
- @click=${() => {
254
- this.isResizeToMobile = false;
255
- this.mobileFacetsVisible = !this.mobileFacetsVisible;
256
- }}
257
- @keyup=${() => {
258
- this.isResizeToMobile = false;
259
- this.mobileFacetsVisible = !this.mobileFacetsVisible;
260
- }}
261
- >
262
- <span class="collapser ${this.mobileFacetsVisible ? 'open' : ''}">
263
- ${chevronIcon}
264
- </span>
265
- Filters
266
- </h1>
267
- </div>
268
- `;
269
- }
270
- get facetsTemplate() {
271
- return html `
272
- ${this.facetsLoading ? this.loadingTemplate : nothing}
273
- <collection-facets
274
- @facetsChanged=${this.facetsChanged}
275
- @histogramDateRangeUpdated=${this.histogramDateRangeUpdated}
276
- .aggregations=${this.aggregations}
277
- .fullYearsHistogramAggregation=${this.fullYearsHistogramAggregation}
278
- .minSelectedDate=${this.minSelectedDate}
279
- .maxSelectedDate=${this.maxSelectedDate}
280
- .selectedFacets=${this.selectedFacets}
281
- .collectionNameCache=${this.collectionNameCache}
282
- .languageCodeHandler=${this.languageCodeHandler}
283
- .showHistogramDatePicker=${this.showHistogramDatePicker}
284
- ?collapsableFacets=${this.mobileView}
285
- ?facetsLoading=${this.facetDataLoading}
286
- ?fullYearAggregationLoading=${this.fullYearAggregationLoading}
287
- ></collection-facets>
288
- `;
289
- }
290
- get loadingTemplate() {
291
- return html `
292
- <div class="loading-cover">
293
- <circular-activity-indicator></circular-activity-indicator>
294
- </div>
295
- `;
296
- }
297
- get listHeaderTemplate() {
298
- return html `
299
- <div id="list-header">
300
- <tile-dispatcher
301
- .tileDisplayMode=${'list-header'}
302
- .resizeObserver=${this.resizeObserver}
303
- .sortParam=${this.sortParam}
304
- .mobileBreakpoint=${this.mobileBreakpoint}
305
- >
306
- </tile-dispatcher>
307
- </div>
308
- `;
309
- }
310
- get queryDebuggingTemplate() {
311
- var _a, _b;
312
- return html `
313
- <div>
314
- <ul>
315
- <li>Base Query: ${this.baseQuery}</li>
316
- <li>Facet Query: ${this.facetQuery}</li>
317
- <li>Sort Filter Query: ${this.sortFilterQueries}</li>
318
- <li>Date Range Query: ${this.dateRangeQueryClause}</li>
319
- <li>Sort: ${(_a = this.sortParam) === null || _a === void 0 ? void 0 : _a.field} ${(_b = this.sortParam) === null || _b === void 0 ? void 0 : _b.direction}</li>
320
- <li>Full Query: ${this.fullQuery}</li>
321
- </ul>
322
- </div>
323
- `;
324
- }
325
- histogramDateRangeUpdated(e) {
326
- const { minDate, maxDate } = e.detail;
327
- this.dateRangeQueryClause = `year:[${minDate} TO ${maxDate}]`;
328
- }
329
- firstUpdated() {
330
- this.setupStateRestorationObserver();
331
- this.restoreState();
332
- }
333
- updated(changed) {
334
- if (changed.has('displayMode') ||
335
- changed.has('baseNavigationUrl') ||
336
- changed.has('baseImageUrl')) {
337
- this.infiniteScroller.reload();
338
- }
339
- if (changed.has('baseQuery')) {
340
- this.emitBaseQueryChanged();
341
- }
342
- if (changed.has('currentPage') || changed.has('displayMode')) {
343
- this.persistState();
344
- }
345
- if (changed.has('baseQuery') ||
346
- changed.has('titleQuery') ||
347
- changed.has('creatorQuery') ||
348
- changed.has('dateRangeQueryClause') ||
349
- changed.has('sortParam') ||
350
- changed.has('selectedFacets') ||
351
- changed.has('searchService')) {
352
- this.handleQueryChange();
353
- }
354
- if (changed.has('selectedSort') || changed.has('sortDirection')) {
355
- this.selectedSortChanged();
356
- }
357
- if (changed.has('selectedTitleFilter')) {
358
- this.selectedTitleLetterChanged();
359
- }
360
- if (changed.has('selectedCreatorFilter')) {
361
- this.selectedCreatorLetterChanged();
362
- }
363
- if (changed.has('pagesToRender')) {
364
- if (!this.endOfDataReached) {
365
- this.infiniteScroller.itemCount = this.estimatedTileCount;
366
- }
367
- }
368
- if (changed.has('resizeObserver')) {
369
- const oldObserver = changed.get('resizeObserver');
370
- if (oldObserver)
371
- this.disconnectResizeObserver(oldObserver);
372
- this.setupResizeObserver();
373
- }
374
- }
375
- disconnectedCallback() {
376
- if (this.resizeObserver) {
377
- this.disconnectResizeObserver(this.resizeObserver);
378
- }
379
- if (this.boundNavigationHandler) {
380
- window.removeEventListener('popstate', this.boundNavigationHandler);
381
- }
382
- }
383
- handleResize(entry) {
384
- const previousView = this.mobileView;
385
- if (entry.target === this.contentContainer) {
386
- this.mobileView = entry.contentRect.width < this.mobileBreakpoint;
387
- // If changing from desktop to mobile disable transition
388
- if (this.mobileView && !previousView) {
389
- this.isResizeToMobile = true;
390
- }
391
- }
392
- }
393
- emitBaseQueryChanged() {
394
- this.dispatchEvent(new CustomEvent('baseQueryChanged', {
395
- detail: {
396
- baseQuery: this.baseQuery,
397
- },
398
- }));
399
- }
400
- disconnectResizeObserver(resizeObserver) {
401
- resizeObserver.removeObserver({
402
- target: this.contentContainer,
403
- handler: this,
404
- });
405
- }
406
- setupResizeObserver() {
407
- if (!this.resizeObserver)
408
- return;
409
- this.resizeObserver.addObserver({
410
- target: this.contentContainer,
411
- handler: this,
412
- });
413
- }
414
- /**
415
- * When the visible cells change from the infinite scroller, we want to emit
416
- * which page is currently visible so the consumer can update its UI or the URL
417
- *
418
- * @param e
419
- * @returns
420
- */
421
- visibleCellsChanged(e) {
422
- if (this.isScrollingToCell)
423
- return;
424
- const { visibleCellIndices } = e.detail;
425
- if (visibleCellIndices.length === 0)
426
- return;
427
- const lastVisibleCellIndex = visibleCellIndices[visibleCellIndices.length - 1];
428
- const lastVisibleCellPage = Math.floor(lastVisibleCellIndex / this.pageSize) + 1;
429
- if (this.currentPage !== lastVisibleCellPage) {
430
- this.currentPage = lastVisibleCellPage;
431
- }
432
- const event = new CustomEvent('visiblePageChanged', {
433
- detail: {
434
- pageNumber: lastVisibleCellPage,
435
- },
436
- });
437
- this.dispatchEvent(event);
438
- }
439
- async handleQueryChange() {
440
- // only reset if the query has actually changed
441
- if (!this.searchService || this.pageFetchQueryKey === this.previousQueryKey)
442
- return;
443
- this.previousQueryKey = this.pageFetchQueryKey;
444
- this.dataSource = {};
445
- this.pageFetchesInProgress = {};
446
- this.endOfDataReached = false;
447
- this.pagesToRender = this.initialPageNumber;
448
- if (!this.initialQueryChangeHappened && this.initialPageNumber > 1) {
449
- this.scrollToPage(this.initialPageNumber);
450
- }
451
- this.initialQueryChangeHappened = true;
452
- // if the query changed as part of a window.history pop event, we don't want to
453
- // persist the state because it overwrites the forward history
454
- if (!this.historyPopOccurred) {
455
- this.persistState();
456
- this.historyPopOccurred = false;
457
- }
458
- await Promise.all([
459
- this.doInitialPageFetch(),
460
- this.fetchFacets(),
461
- this.fetchFullYearHistogram(),
462
- ]);
463
- }
464
- setupStateRestorationObserver() {
465
- if (this.boundNavigationHandler)
466
- return;
467
- this.boundNavigationHandler = this.historyNavigationHandler.bind(this);
468
- // when the user navigates back, we want to update the UI to match the URL
469
- window.addEventListener('popstate', this.boundNavigationHandler);
470
- }
471
- historyNavigationHandler() {
472
- this.historyPopOccurred = true;
473
- this.restoreState();
474
- }
475
- restoreState() {
476
- var _a, _b, _c, _d, _e, _f;
477
- const restorationState = this.restorationStateHandler.getRestorationState();
478
- this.displayMode = restorationState.displayMode;
479
- this.selectedSort = (_a = restorationState.selectedSort) !== null && _a !== void 0 ? _a : SortField.relevance;
480
- this.sortDirection = (_b = restorationState.sortDirection) !== null && _b !== void 0 ? _b : null;
481
- this.selectedTitleFilter = (_c = restorationState.selectedTitleFilter) !== null && _c !== void 0 ? _c : null;
482
- this.selectedCreatorFilter = (_d = restorationState.selectedCreatorFilter) !== null && _d !== void 0 ? _d : null;
483
- this.selectedFacets = restorationState.selectedFacets;
484
- this.baseQuery = restorationState.baseQuery;
485
- this.titleQuery = restorationState.titleQuery;
486
- this.creatorQuery = restorationState.creatorQuery;
487
- this.dateRangeQueryClause = restorationState.dateRangeQueryClause;
488
- this.sortParam = (_e = restorationState.sortParam) !== null && _e !== void 0 ? _e : null;
489
- this.currentPage = (_f = restorationState.currentPage) !== null && _f !== void 0 ? _f : 1;
490
- this.minSelectedDate = restorationState.minSelectedDate;
491
- this.maxSelectedDate = restorationState.maxSelectedDate;
492
- if (this.currentPage > 1) {
493
- this.goToPage(this.currentPage);
494
- }
495
- }
496
- persistState() {
497
- var _a, _b, _c, _d, _e;
498
- const restorationState = {
499
- displayMode: this.displayMode,
500
- sortParam: (_a = this.sortParam) !== null && _a !== void 0 ? _a : undefined,
501
- selectedSort: this.selectedSort,
502
- sortDirection: (_b = this.sortDirection) !== null && _b !== void 0 ? _b : undefined,
503
- selectedFacets: (_c = this.selectedFacets) !== null && _c !== void 0 ? _c : defaultSelectedFacets,
504
- baseQuery: this.baseQuery,
505
- currentPage: this.currentPage,
506
- dateRangeQueryClause: this.dateRangeQueryClause,
507
- titleQuery: this.titleQuery,
508
- creatorQuery: this.creatorQuery,
509
- minSelectedDate: this.minSelectedDate,
510
- maxSelectedDate: this.maxSelectedDate,
511
- selectedTitleFilter: (_d = this.selectedTitleFilter) !== null && _d !== void 0 ? _d : undefined,
512
- selectedCreatorFilter: (_e = this.selectedCreatorFilter) !== null && _e !== void 0 ? _e : undefined,
513
- };
514
- this.restorationStateHandler.persistState(restorationState);
515
- }
516
- async doInitialPageFetch() {
517
- this.searchResultsLoading = true;
518
- await this.fetchPage(this.initialPageNumber);
519
- this.searchResultsLoading = false;
520
- }
521
- get fullQuery() {
522
- let { fullQueryWithoutDate } = this;
523
- const { dateRangeQueryClause } = this;
524
- if (dateRangeQueryClause) {
525
- fullQueryWithoutDate += ` AND ${dateRangeQueryClause}`;
526
- }
527
- return fullQueryWithoutDate;
528
- }
529
- get fullQueryWithoutDate() {
530
- if (!this.baseQuery)
531
- return undefined;
532
- let fullQuery = this.baseQuery;
533
- const { facetQuery, sortFilterQueries } = this;
534
- if (facetQuery) {
535
- fullQuery += ` AND ${facetQuery}`;
536
- }
537
- if (sortFilterQueries) {
538
- fullQuery += ` AND ${sortFilterQueries}`;
539
- }
540
- return fullQuery;
541
- }
542
- /**
543
- * Generates a query string for the given facets
544
- *
545
- * Example: `mediatype:("collection" OR "audio" OR -"etree") AND year:("2000" OR "2001")`
546
- */
547
- get facetQuery() {
548
- if (!this.selectedFacets)
549
- return undefined;
550
- const facetQuery = [];
551
- for (const [facetName, facetValues] of Object.entries(this.selectedFacets)) {
552
- const facetEntries = Object.entries(facetValues);
553
- // eslint-disable-next-line no-continue
554
- if (facetEntries.length === 0)
555
- continue;
556
- const facetValuesArray = [];
557
- for (const [key, facetState] of facetEntries) {
558
- const plusMinusPrefix = facetState === 'hidden' ? '-' : '';
559
- if (facetName === 'language') {
560
- const languages = this.languageCodeHandler.getCodeArrayFromCodeString(key);
561
- for (const language of languages) {
562
- facetValuesArray.push(`${plusMinusPrefix}"${language}"`);
563
- }
564
- }
565
- else {
566
- facetValuesArray.push(`${plusMinusPrefix}"${key}"`);
567
- }
568
- }
569
- const valueQuery = facetValuesArray.join(` OR `);
570
- facetQuery.push(`${facetName}:(${valueQuery})`);
571
- }
572
- return facetQuery.length > 0 ? `(${facetQuery.join(' AND ')})` : undefined;
573
- }
574
- facetsChanged(e) {
575
- this.selectedFacets = e.detail;
576
- }
577
- async fetchFacets() {
578
- var _a, _b;
579
- if (!this.fullQuery)
580
- return;
581
- const aggregations = {
582
- advancedParams: [
583
- {
584
- field: 'subjectSorter',
585
- size: 6,
586
- },
587
- {
588
- field: 'mediatypeSorter',
589
- size: 6,
590
- },
591
- {
592
- field: 'languageSorter',
593
- size: 6,
594
- },
595
- {
596
- field: 'creatorSorter',
597
- size: 6,
598
- },
599
- {
600
- field: 'collection',
601
- size: 12,
602
- },
603
- {
604
- field: 'year',
605
- size: 50,
606
- },
607
- ],
608
- };
609
- const params = {
610
- query: this.fullQuery,
611
- fields: ['identifier'],
612
- aggregations,
613
- rows: 1,
614
- };
615
- this.facetsLoading = true;
616
- const results = await ((_a = this.searchService) === null || _a === void 0 ? void 0 : _a.search(params));
617
- this.facetsLoading = false;
618
- this.aggregations = (_b = results === null || results === void 0 ? void 0 : results.success) === null || _b === void 0 ? void 0 : _b.response.aggregations;
619
- }
620
- /**
621
- * The query key is a string that uniquely identifies the current query
622
- * without the date range.
623
- *
624
- * If this doesn't change, we don't need to re-fetch the histogram date range
625
- */
626
- get fullQueryNoDateKey() {
627
- var _a, _b;
628
- return `${this.fullQueryWithoutDate}-${(_a = this.sortParam) === null || _a === void 0 ? void 0 : _a.field}-${(_b = this.sortParam) === null || _b === void 0 ? void 0 : _b.direction}`;
629
- }
630
- /**
631
- * This method is similar to fetching the facets above,
632
- * but only fetching the year histogram. There is a subtle difference
633
- * in how you have to fetch the year histogram where you can't use the
634
- * advanced JSON syntax like the other aggregations. It's a special
635
- * case that @ximm put it place.
636
- */
637
- async fetchFullYearHistogram() {
638
- var _a, _b, _c, _d;
639
- const { fullQueryNoDateKey } = this;
640
- if (!this.fullQueryWithoutDate ||
641
- fullQueryNoDateKey === this.previousFullQueryNoDate)
642
- return;
643
- this.previousFullQueryNoDate = fullQueryNoDateKey;
644
- const aggregations = {
645
- simpleParams: ['year'],
646
- };
647
- const params = {
648
- query: this.fullQueryWithoutDate,
649
- fields: ['identifier'],
650
- aggregations,
651
- rows: 1,
652
- };
653
- this.fullYearAggregationLoading = true;
654
- const results = await ((_a = this.searchService) === null || _a === void 0 ? void 0 : _a.search(params));
655
- this.fullYearAggregationLoading = false;
656
- this.fullYearsHistogramAggregation =
657
- (_d = (_c = (_b = results === null || results === void 0 ? void 0 : results.success) === null || _b === void 0 ? void 0 : _b.response) === null || _c === void 0 ? void 0 : _c.aggregations) === null || _d === void 0 ? void 0 : _d.year_histogram;
658
- }
659
- scrollToPage(pageNumber) {
660
- const cellIndexToScrollTo = this.pageSize * (pageNumber - 1);
661
- // without this setTimeout, Safari just pauses until the `fetchPage` is complete
662
- // then scrolls to the cell
663
- setTimeout(() => {
664
- this.isScrollingToCell = true;
665
- this.infiniteScroller.scrollToCell(cellIndexToScrollTo, true);
666
- // This timeout is to give the scroll animation time to finish
667
- // then updating the infinite scroller once we're done scrolling
668
- // There's no scroll animation completion callback so we're
669
- // giving it 0.5s to finish.
670
- setTimeout(() => {
671
- this.isScrollingToCell = false;
672
- this.infiniteScroller.reload();
673
- }, 500);
674
- }, 0);
675
- }
676
- /**
677
- * The query key is a string that uniquely identifies the current query
678
- *
679
- * This lets us keep track of queries so we don't persist data that's
680
- * no longer relevant.
681
- */
682
- get pageFetchQueryKey() {
683
- var _a, _b;
684
- return `${this.fullQuery}-${(_a = this.sortParam) === null || _a === void 0 ? void 0 : _a.field}-${(_b = this.sortParam) === null || _b === void 0 ? void 0 : _b.direction}`;
685
- }
686
- async fetchPage(pageNumber) {
687
- var _a, _b, _c, _d, _e;
688
- if (!this.fullQuery)
689
- return;
690
- // if we already have data, don't fetch again
691
- if (this.dataSource[pageNumber])
692
- return;
693
- if (this.endOfDataReached)
694
- return;
695
- // if a fetch is already in progress for this query and page, don't fetch again
696
- const { pageFetchQueryKey } = this;
697
- const pageFetches = (_a = this.pageFetchesInProgress[pageFetchQueryKey]) !== null && _a !== void 0 ? _a : new Set();
698
- if (pageFetches.has(pageNumber))
699
- return;
700
- pageFetches.add(pageNumber);
701
- this.pageFetchesInProgress[pageFetchQueryKey] = pageFetches;
702
- const sortParams = this.sortParam ? [this.sortParam] : [];
703
- const params = {
704
- query: this.fullQuery,
705
- fields: [
706
- 'addeddate',
707
- 'avg_rating',
708
- 'collections_raw',
709
- 'creator',
710
- 'date',
711
- 'description',
712
- 'downloads',
713
- 'identifier',
714
- 'issue',
715
- 'item_count',
716
- 'mediatype',
717
- 'num_favorites',
718
- 'num_reviews',
719
- 'publicdate',
720
- 'reviewdate',
721
- 'source',
722
- 'subject',
723
- 'title',
724
- 'volume',
725
- ],
726
- page: pageNumber,
727
- rows: this.pageSize,
728
- sort: sortParams,
729
- };
730
- const results = await ((_b = this.searchService) === null || _b === void 0 ? void 0 : _b.search(params));
731
- const success = results === null || results === void 0 ? void 0 : results.success;
732
- if (!success)
733
- return;
734
- this.totalResults = success.response.numFound;
735
- // this is checking to see if the query has changed since the data was fetched
736
- // if so, we just want to discard the data since there should be a new query
737
- // right behind it
738
- const searchQuery = success.responseHeader.params.qin;
739
- const searchSort = success.responseHeader.params.sort;
740
- let sortChanged = false;
741
- if (!searchSort) {
742
- // if we went from no sort to sort, the sort has changed
743
- if (this.sortParam) {
744
- sortChanged = true;
745
- }
746
- }
747
- else {
748
- // check if the sort has changed
749
- const split = searchSort.split(' ');
750
- if (split.length > 1) {
751
- const field = searchSort.split(' ')[0];
752
- const direction = searchSort.split(' ')[1];
753
- if (field !== ((_c = this.sortParam) === null || _c === void 0 ? void 0 : _c.field) ||
754
- direction !== ((_d = this.sortParam) === null || _d === void 0 ? void 0 : _d.direction)) {
755
- sortChanged = true;
756
- }
757
- }
758
- }
759
- const queryChangedSinceFetch = searchQuery !== this.fullQuery || sortChanged;
760
- if (queryChangedSinceFetch)
761
- return;
762
- const { docs } = success.response;
763
- if (docs && docs.length > 0) {
764
- this.preloadCollectionNames(docs);
765
- this.updateDataSource(pageNumber, docs);
766
- }
767
- if (docs.length < this.pageSize) {
768
- this.endOfDataReached = true;
769
- // this updates the infinite scroller to show the actual size
770
- this.infiniteScroller.itemCount = this.actualTileCount;
771
- }
772
- (_e = this.pageFetchesInProgress[pageFetchQueryKey]) === null || _e === void 0 ? void 0 : _e.delete(pageNumber);
773
- this.searchResultsLoading = false;
774
- }
775
- preloadCollectionNames(docs) {
776
- var _a;
777
- const collectionIds = docs.map(doc => { var _a; return (_a = doc.collections_raw) === null || _a === void 0 ? void 0 : _a.values; }).flat();
778
- const collectionIdsArray = Array.from(new Set(collectionIds));
779
- (_a = this.collectionNameCache) === null || _a === void 0 ? void 0 : _a.preloadIdentifiers(collectionIdsArray);
780
- }
781
- /**
782
- * This is useful for determining whether we need to reload the scroller.
783
- *
784
- * When the fetch completes, we need to reload the scroller if the cells for that
785
- * page are visible, but if the page is not currenlty visible, we don't need to reload
786
- */
787
- get currentVisiblePageNumbers() {
788
- const visibleCells = this.infiniteScroller.getVisibleCellIndices();
789
- const visiblePages = new Set();
790
- visibleCells.forEach(cellIndex => {
791
- const visiblePage = Math.floor(cellIndex / this.pageSize) + 1;
792
- visiblePages.add(visiblePage);
793
- });
794
- return Array.from(visiblePages);
795
- }
796
- /**
797
- * Update the datasource from the fetch response
798
- *
799
- * @param pageNumber
800
- * @param docs
801
- */
802
- updateDataSource(pageNumber, docs) {
803
- // copy our existing datasource so when we set it below, it gets set
804
- // instead of modifying the existing dataSource since object changes
805
- // don't trigger a re-render
806
- const datasource = { ...this.dataSource };
807
- const tiles = [];
808
- docs === null || docs === void 0 ? void 0 : docs.forEach(doc => {
809
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7;
810
- if (!doc.identifier)
811
- return;
812
- let loginRequired = false;
813
- let contentWarning = false;
814
- // Check if item and item in "modifying" collection, setting above flags
815
- if (((_a = doc.collections_raw) === null || _a === void 0 ? void 0 : _a.values.length) &&
816
- ((_b = doc.mediatype) === null || _b === void 0 ? void 0 : _b.value) !== 'collection') {
817
- for (const collection of (_c = doc.collections_raw) === null || _c === void 0 ? void 0 : _c.values) {
818
- if (collection === 'loggedin') {
819
- loginRequired = true;
820
- if (contentWarning)
821
- break;
822
- }
823
- if (collection === 'no-preview') {
824
- contentWarning = true;
825
- if (loginRequired)
826
- break;
827
- }
828
- }
829
- }
830
- tiles.push({
831
- averageRating: (_d = doc.avg_rating) === null || _d === void 0 ? void 0 : _d.value,
832
- collections: (_f = (_e = doc.collections_raw) === null || _e === void 0 ? void 0 : _e.values) !== null && _f !== void 0 ? _f : [],
833
- commentCount: (_h = (_g = doc.num_reviews) === null || _g === void 0 ? void 0 : _g.value) !== null && _h !== void 0 ? _h : 0,
834
- creator: (_j = doc.creator) === null || _j === void 0 ? void 0 : _j.value,
835
- creators: (_l = (_k = doc.creator) === null || _k === void 0 ? void 0 : _k.values) !== null && _l !== void 0 ? _l : [],
836
- dateAdded: (_m = doc.addeddate) === null || _m === void 0 ? void 0 : _m.value,
837
- dateArchived: (_o = doc.publicdate) === null || _o === void 0 ? void 0 : _o.value,
838
- datePublished: (_p = doc.date) === null || _p === void 0 ? void 0 : _p.value,
839
- dateReviewed: (_q = doc.reviewdate) === null || _q === void 0 ? void 0 : _q.value,
840
- description: (_r = doc.description) === null || _r === void 0 ? void 0 : _r.value,
841
- favCount: (_t = (_s = doc.num_favorites) === null || _s === void 0 ? void 0 : _s.value) !== null && _t !== void 0 ? _t : 0,
842
- identifier: doc.identifier,
843
- issue: (_u = doc.issue) === null || _u === void 0 ? void 0 : _u.value,
844
- itemCount: (_w = (_v = doc.item_count) === null || _v === void 0 ? void 0 : _v.value) !== null && _w !== void 0 ? _w : 0,
845
- mediatype: (_y = (_x = doc.mediatype) === null || _x === void 0 ? void 0 : _x.value) !== null && _y !== void 0 ? _y : 'data',
846
- source: (_z = doc.source) === null || _z === void 0 ? void 0 : _z.value,
847
- subjects: (_1 = (_0 = doc.subject) === null || _0 === void 0 ? void 0 : _0.values) !== null && _1 !== void 0 ? _1 : [],
848
- title: this.etreeTitle((_2 = doc.title) === null || _2 === void 0 ? void 0 : _2.value, (_3 = doc.mediatype) === null || _3 === void 0 ? void 0 : _3.value, (_4 = doc.collection) === null || _4 === void 0 ? void 0 : _4.values),
849
- volume: (_5 = doc.volume) === null || _5 === void 0 ? void 0 : _5.value,
850
- viewCount: (_7 = (_6 = doc.downloads) === null || _6 === void 0 ? void 0 : _6.value) !== null && _7 !== void 0 ? _7 : 0,
851
- loginRequired,
852
- contentWarning,
853
- });
854
- });
855
- datasource[pageNumber] = tiles;
856
- this.dataSource = datasource;
857
- const visiblePages = this.currentVisiblePageNumbers;
858
- const needsReload = visiblePages.includes(pageNumber);
859
- if (needsReload) {
860
- this.infiniteScroller.reload();
861
- }
862
- }
863
- /*
864
- * Convert etree titles
865
- * "[Creator] Live at [Place] on [Date]" => "[Date]: [Place]"
866
- *
867
- * Todo: Check collection(s) for etree, need to get as array.
868
- * Current search-service only returns first collection as string.
869
- */
870
- etreeTitle(title, mediatype, collections) {
871
- if (mediatype === 'etree' || (collections === null || collections === void 0 ? void 0 : collections.includes('etree'))) {
872
- const regex = /^(.*) Live at (.*) on (\d\d\d\d-\d\d-\d\d)$/;
873
- const newTitle = title === null || title === void 0 ? void 0 : title.replace(regex, '$3: $2');
874
- if (newTitle) {
875
- return `${newTitle}`;
876
- }
877
- }
878
- return title !== null && title !== void 0 ? title : '';
879
- }
880
- cellForIndex(index) {
881
- const model = this.tileModelAtCellIndex(index);
882
- if (!model)
883
- return undefined;
884
- return html ` <tile-dispatcher
885
- .baseNavigationUrl=${this.baseNavigationUrl}
886
- .baseImageUrl=${this.baseImageUrl}
887
- .model=${model}
888
- .tileDisplayMode=${this.displayMode}
889
- .resizeObserver=${this.resizeObserver}
890
- .collectionNameCache=${this.collectionNameCache}
891
- .sortParam=${this.sortParam}
892
- .mobileBreakpoint=${this.mobileBreakpoint}
893
- ></tile-dispatcher>`;
894
- }
895
- /**
896
- * When the user scrolls near to the bottom of the page, fetch the next page
897
- * increase the number of pages to render and start fetching data for the new page
898
- */
899
- scrollThresholdReached() {
900
- this.pagesToRender += 1;
901
- this.fetchPage(this.pagesToRender);
902
- }
903
- };
904
- CollectionBrowser.styles = css `
905
- :host {
906
- display: block;
907
- }
908
-
909
- /**
910
- * When page width resizes from desktop to mobile, use this class to
911
- * disable expand/collapse transition when loading.
912
- */
913
- .preload * {
914
- transition: none !important;
915
- -webkit-transition: none !important;
916
- -moz-transition: none !important;
917
- -ms-transition: none !important;
918
- -o-transition: none !important;
919
- }
920
-
921
- #content-container {
922
- display: flex;
923
- }
924
-
925
- .collapser {
926
- display: inline-block;
927
- }
928
-
929
- .collapser svg {
930
- width: 10px;
931
- height: 10px;
932
- transition: transform 0.2s ease-out;
933
- }
934
-
935
- .collapser.open svg {
936
- transform: rotate(90deg);
937
- }
938
-
939
- #mobile-filter-collapse h1 {
940
- cursor: pointer;
941
- }
942
-
943
- #content-container.mobile {
944
- display: block;
945
- }
946
-
947
- .column {
948
- padding-top: 2rem;
949
- }
950
-
951
- #right-column {
952
- flex: 1;
953
- position: relative;
954
- border-left: 1px solid rgb(232, 232, 232);
955
- padding-left: 1rem;
956
- }
957
-
958
- .mobile #right-column {
959
- border-left: none;
960
- padding: 0;
961
- }
962
-
963
- #left-column {
964
- width: 18rem;
965
- padding-right: 12px;
966
- padding-right: 1rem;
967
- }
968
-
969
- .mobile #left-column {
970
- width: 100%;
971
- padding: 0;
972
- }
973
-
974
- #mobile-header-container {
975
- display: flex;
976
- justify-content: space-between;
977
- }
978
-
979
- #facets-container {
980
- position: relative;
981
- max-height: 0;
982
- transition: max-height 0.2s ease-in-out;
983
- z-index: 1;
984
- }
985
-
986
- .mobile #facets-container {
987
- overflow: hidden;
988
- }
989
-
990
- #facets-container.expanded {
991
- max-height: 2000px;
992
- }
993
-
994
- #results-total {
995
- display: flex;
996
- align-items: center;
997
- margin-bottom: 5rem;
998
- }
999
-
1000
- .mobile #results-total {
1001
- margin-bottom: 0;
1002
- }
1003
-
1004
- #big-results-count {
1005
- font-size: 2.4rem;
1006
- font-weight: 500;
1007
- margin-right: 5px;
1008
- }
1009
-
1010
- #big-results-label {
1011
- font-size: 1rem;
1012
- font-weight: 200;
1013
- text-transform: uppercase;
1014
- }
1015
-
1016
- #list-header {
1017
- max-height: 4.2rem;
1018
- }
1019
-
1020
- .loading-cover {
1021
- position: absolute;
1022
- top: 0;
1023
- left: 0;
1024
- width: 100%;
1025
- height: 100%;
1026
- display: flex;
1027
- justify-content: center;
1028
- z-index: 1;
1029
- padding-top: 50px;
1030
- }
1031
-
1032
- circular-activity-indicator {
1033
- width: 30px;
1034
- height: 30px;
1035
- }
1036
-
1037
- sort-filter-bar {
1038
- display: block;
1039
- margin-bottom: 4rem;
1040
- }
1041
-
1042
- infinite-scroller {
1043
- display: block;
1044
- --infiniteScrollerRowGap: var(--collectionBrowserRowGap, 1.7rem);
1045
- --infiniteScrollerColGap: var(--collectionBrowserColGap, 1.7rem);
1046
- }
1047
-
1048
- infinite-scroller.list-compact {
1049
- --infiniteScrollerCellMinWidth: var(
1050
- --collectionBrowserCellMinWidth,
1051
- 100%
1052
- );
1053
- --infiniteScrollerCellMinHeight: 34px; /* override infinite scroller component */
1054
- --infiniteScrollerCellMaxHeight: 56px;
1055
- --infiniteScrollerRowGap: 0px;
1056
- }
1057
-
1058
- infinite-scroller.list-detail {
1059
- --infiniteScrollerCellMinWidth: var(
1060
- --collectionBrowserCellMinWidth,
1061
- 100%
1062
- );
1063
- --infiniteScrollerCellMinHeight: var(
1064
- --collectionBrowserCellMinHeight,
1065
- 5rem
1066
- );
1067
- /*
1068
- 30px in spec, compensating for a -4px margin
1069
- to align title with top of item image
1070
- src/tiles/list/tile-list.ts
1071
- */
1072
- --infiniteScrollerRowGap: 34px;
1073
- }
1074
-
1075
- .mobile infinite-scroller.list-detail {
1076
- --infiniteScrollerRowGap: 24px;
1077
- }
1078
-
1079
- infinite-scroller.grid {
1080
- --infiniteScrollerCellMinWidth: var(
1081
- --collectionBrowserCellMinWidth,
1082
- 18rem
1083
- );
1084
- --infiniteScrollerCellMaxWidth: var(--collectionBrowserCellMaxWidth, 1fr);
1085
- --infiniteScrollerCellMinHeight: var(
1086
- --collectionBrowserCellMinHeight,
1087
- 29rem
1088
- );
1089
- --infiniteScrollerCellMaxHeight: var(
1090
- --collectionBrowserCellMaxHeight,
1091
- 29rem
1092
- );
1093
- }
1094
- `;
1095
- __decorate([
1096
- property({ type: String })
1097
- ], CollectionBrowser.prototype, "baseNavigationUrl", void 0);
1098
- __decorate([
1099
- property({ type: String })
1100
- ], CollectionBrowser.prototype, "baseImageUrl", void 0);
1101
- __decorate([
1102
- property({ type: Object })
1103
- ], CollectionBrowser.prototype, "searchService", void 0);
1104
- __decorate([
1105
- property({ type: String })
1106
- ], CollectionBrowser.prototype, "baseQuery", void 0);
1107
- __decorate([
1108
- property({ type: String })
1109
- ], CollectionBrowser.prototype, "displayMode", void 0);
1110
- __decorate([
1111
- property({ type: Object })
1112
- ], CollectionBrowser.prototype, "sortParam", void 0);
1113
- __decorate([
1114
- property({ type: String })
1115
- ], CollectionBrowser.prototype, "selectedSort", void 0);
1116
- __decorate([
1117
- property({ type: String })
1118
- ], CollectionBrowser.prototype, "selectedTitleFilter", void 0);
1119
- __decorate([
1120
- property({ type: String })
1121
- ], CollectionBrowser.prototype, "selectedCreatorFilter", void 0);
1122
- __decorate([
1123
- property({ type: String })
1124
- ], CollectionBrowser.prototype, "sortDirection", void 0);
1125
- __decorate([
1126
- property({ type: String })
1127
- ], CollectionBrowser.prototype, "dateRangeQueryClause", void 0);
1128
- __decorate([
1129
- property({ type: Number })
1130
- ], CollectionBrowser.prototype, "pageSize", void 0);
1131
- __decorate([
1132
- property({ type: Object })
1133
- ], CollectionBrowser.prototype, "resizeObserver", void 0);
1134
- __decorate([
1135
- property({ type: String })
1136
- ], CollectionBrowser.prototype, "titleQuery", void 0);
1137
- __decorate([
1138
- property({ type: String })
1139
- ], CollectionBrowser.prototype, "creatorQuery", void 0);
1140
- __decorate([
1141
- property({ type: Number })
1142
- ], CollectionBrowser.prototype, "currentPage", void 0);
1143
- __decorate([
1144
- property({ type: String })
1145
- ], CollectionBrowser.prototype, "minSelectedDate", void 0);
1146
- __decorate([
1147
- property({ type: String })
1148
- ], CollectionBrowser.prototype, "maxSelectedDate", void 0);
1149
- __decorate([
1150
- property({ type: Object })
1151
- ], CollectionBrowser.prototype, "selectedFacets", void 0);
1152
- __decorate([
1153
- property({ type: Boolean })
1154
- ], CollectionBrowser.prototype, "showHistogramDatePicker", void 0);
1155
- __decorate([
1156
- property({ type: Object })
1157
- ], CollectionBrowser.prototype, "collectionNameCache", void 0);
1158
- __decorate([
1159
- property({ type: String })
1160
- ], CollectionBrowser.prototype, "pageContext", void 0);
1161
- __decorate([
1162
- property({ type: Object })
1163
- ], CollectionBrowser.prototype, "restorationStateHandler", void 0);
1164
- __decorate([
1165
- property({ type: Number })
1166
- ], CollectionBrowser.prototype, "mobileBreakpoint", void 0);
1167
- __decorate([
1168
- property({ type: Boolean })
1169
- ], CollectionBrowser.prototype, "loggedIn", void 0);
1170
- __decorate([
1171
- property({ type: Boolean })
1172
- ], CollectionBrowser.prototype, "isManageView", void 0);
1173
- __decorate([
1174
- state()
1175
- ], CollectionBrowser.prototype, "pagesToRender", void 0);
1176
- __decorate([
1177
- state()
1178
- ], CollectionBrowser.prototype, "searchResultsLoading", void 0);
1179
- __decorate([
1180
- state()
1181
- ], CollectionBrowser.prototype, "facetsLoading", void 0);
1182
- __decorate([
1183
- state()
1184
- ], CollectionBrowser.prototype, "fullYearAggregationLoading", void 0);
1185
- __decorate([
1186
- state()
1187
- ], CollectionBrowser.prototype, "aggregations", void 0);
1188
- __decorate([
1189
- state()
1190
- ], CollectionBrowser.prototype, "fullYearsHistogramAggregation", void 0);
1191
- __decorate([
1192
- state()
1193
- ], CollectionBrowser.prototype, "totalResults", void 0);
1194
- __decorate([
1195
- state()
1196
- ], CollectionBrowser.prototype, "mobileView", void 0);
1197
- __decorate([
1198
- state()
1199
- ], CollectionBrowser.prototype, "mobileFacetsVisible", void 0);
1200
- __decorate([
1201
- query('#content-container')
1202
- ], CollectionBrowser.prototype, "contentContainer", void 0);
1203
- __decorate([
1204
- query('infinite-scroller')
1205
- ], CollectionBrowser.prototype, "infiniteScroller", void 0);
1206
- CollectionBrowser = __decorate([
1207
- customElement('collection-browser')
1208
- ], CollectionBrowser);
1209
- export { CollectionBrowser };
1210
- //# sourceMappingURL=collection-browser.js.map