@internetarchive/collection-browser 2.7.12 → 2.7.13-alpha1

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 (498) hide show
  1. package/.editorconfig +29 -29
  2. package/.github/workflows/ci.yml +3 -3
  3. package/.github/workflows/gh-pages-main.yml +2 -2
  4. package/.github/workflows/pr-preview.yml +2 -2
  5. package/.husky/pre-commit +4 -4
  6. package/.prettierignore +1 -0
  7. package/LICENSE +661 -661
  8. package/README.md +83 -83
  9. package/dist/index.d.ts +13 -13
  10. package/dist/index.js +11 -13
  11. package/dist/index.js.map +1 -1
  12. package/dist/src/app-root.d.ts +108 -107
  13. package/dist/src/app-root.js +541 -531
  14. package/dist/src/app-root.js.map +1 -1
  15. package/dist/src/assets/img/icons/arrow-left.d.ts +2 -2
  16. package/dist/src/assets/img/icons/arrow-left.js +2 -2
  17. package/dist/src/assets/img/icons/arrow-right.d.ts +2 -2
  18. package/dist/src/assets/img/icons/arrow-right.js +2 -2
  19. package/dist/src/assets/img/icons/chevron.d.ts +2 -2
  20. package/dist/src/assets/img/icons/chevron.js +2 -2
  21. package/dist/src/assets/img/icons/contract.d.ts +2 -2
  22. package/dist/src/assets/img/icons/contract.js +2 -2
  23. package/dist/src/assets/img/icons/empty-query.d.ts +2 -2
  24. package/dist/src/assets/img/icons/empty-query.js +2 -2
  25. package/dist/src/assets/img/icons/expand.d.ts +2 -2
  26. package/dist/src/assets/img/icons/expand.js +2 -2
  27. package/dist/src/assets/img/icons/eye-closed.d.ts +2 -2
  28. package/dist/src/assets/img/icons/eye-closed.js +2 -2
  29. package/dist/src/assets/img/icons/eye.d.ts +2 -2
  30. package/dist/src/assets/img/icons/eye.js +2 -2
  31. package/dist/src/assets/img/icons/favorite-filled.d.ts +1 -1
  32. package/dist/src/assets/img/icons/favorite-filled.js +2 -2
  33. package/dist/src/assets/img/icons/favorite-unfilled.d.ts +1 -1
  34. package/dist/src/assets/img/icons/favorite-unfilled.js +2 -2
  35. package/dist/src/assets/img/icons/filter.d.ts +2 -2
  36. package/dist/src/assets/img/icons/filter.js +2 -2
  37. package/dist/src/assets/img/icons/login-required.d.ts +1 -1
  38. package/dist/src/assets/img/icons/login-required.js +2 -2
  39. package/dist/src/assets/img/icons/mediatype/account.d.ts +1 -1
  40. package/dist/src/assets/img/icons/mediatype/account.js +2 -2
  41. package/dist/src/assets/img/icons/mediatype/audio.d.ts +1 -1
  42. package/dist/src/assets/img/icons/mediatype/audio.js +2 -2
  43. package/dist/src/assets/img/icons/mediatype/collection.d.ts +1 -1
  44. package/dist/src/assets/img/icons/mediatype/collection.js +2 -2
  45. package/dist/src/assets/img/icons/mediatype/data.d.ts +1 -1
  46. package/dist/src/assets/img/icons/mediatype/data.js +2 -2
  47. package/dist/src/assets/img/icons/mediatype/etree.d.ts +1 -1
  48. package/dist/src/assets/img/icons/mediatype/etree.js +2 -2
  49. package/dist/src/assets/img/icons/mediatype/film.d.ts +1 -1
  50. package/dist/src/assets/img/icons/mediatype/film.js +2 -2
  51. package/dist/src/assets/img/icons/mediatype/images.d.ts +1 -1
  52. package/dist/src/assets/img/icons/mediatype/images.js +2 -2
  53. package/dist/src/assets/img/icons/mediatype/radio.d.ts +1 -1
  54. package/dist/src/assets/img/icons/mediatype/radio.js +2 -2
  55. package/dist/src/assets/img/icons/mediatype/search.d.ts +1 -1
  56. package/dist/src/assets/img/icons/mediatype/search.js +2 -2
  57. package/dist/src/assets/img/icons/mediatype/software.d.ts +1 -1
  58. package/dist/src/assets/img/icons/mediatype/software.js +2 -2
  59. package/dist/src/assets/img/icons/mediatype/texts.d.ts +1 -1
  60. package/dist/src/assets/img/icons/mediatype/texts.js +2 -2
  61. package/dist/src/assets/img/icons/mediatype/tv.d.ts +1 -1
  62. package/dist/src/assets/img/icons/mediatype/tv.js +2 -2
  63. package/dist/src/assets/img/icons/mediatype/video.d.ts +1 -1
  64. package/dist/src/assets/img/icons/mediatype/video.js +2 -2
  65. package/dist/src/assets/img/icons/mediatype/web.d.ts +1 -1
  66. package/dist/src/assets/img/icons/mediatype/web.js +2 -2
  67. package/dist/src/assets/img/icons/null-result.d.ts +2 -2
  68. package/dist/src/assets/img/icons/null-result.js +2 -2
  69. package/dist/src/assets/img/icons/restricted.d.ts +1 -1
  70. package/dist/src/assets/img/icons/restricted.js +2 -2
  71. package/dist/src/assets/img/icons/reviews.d.ts +1 -1
  72. package/dist/src/assets/img/icons/reviews.js +2 -2
  73. package/dist/src/assets/img/icons/upload.d.ts +1 -1
  74. package/dist/src/assets/img/icons/upload.js +2 -2
  75. package/dist/src/assets/img/icons/views.d.ts +1 -1
  76. package/dist/src/assets/img/icons/views.js +2 -2
  77. package/dist/src/circular-activity-indicator.d.ts +5 -5
  78. package/dist/src/circular-activity-indicator.js +17 -17
  79. package/dist/src/circular-activity-indicator.js.map +1 -1
  80. package/dist/src/collection-browser.d.ts +611 -606
  81. package/dist/src/collection-browser.js +1688 -1679
  82. package/dist/src/collection-browser.js.map +1 -1
  83. package/dist/src/collection-facets/facet-row.d.ts +30 -30
  84. package/dist/src/collection-facets/facet-row.js +118 -118
  85. package/dist/src/collection-facets/facet-row.js.map +1 -1
  86. package/dist/src/collection-facets/facet-tombstone-row.d.ts +5 -5
  87. package/dist/src/collection-facets/facet-tombstone-row.js +15 -15
  88. package/dist/src/collection-facets/facet-tombstone-row.js.map +1 -1
  89. package/dist/src/collection-facets/facets-template.d.ts +13 -13
  90. package/dist/src/collection-facets/facets-template.js +49 -49
  91. package/dist/src/collection-facets/facets-template.js.map +1 -1
  92. package/dist/src/collection-facets/more-facets-content.d.ts +106 -106
  93. package/dist/src/collection-facets/more-facets-content.js +406 -408
  94. package/dist/src/collection-facets/more-facets-content.js.map +1 -1
  95. package/dist/src/collection-facets/more-facets-pagination.d.ts +36 -36
  96. package/dist/src/collection-facets/more-facets-pagination.js +197 -196
  97. package/dist/src/collection-facets/more-facets-pagination.js.map +1 -1
  98. package/dist/src/collection-facets/smart-facets/dedupe.d.ts +10 -10
  99. package/dist/src/collection-facets/smart-facets/dedupe.js +33 -33
  100. package/dist/src/collection-facets/smart-facets/dedupe.js.map +1 -1
  101. package/dist/src/collection-facets/smart-facets/heuristics/browser-language-heuristic.d.ts +5 -5
  102. package/dist/src/collection-facets/smart-facets/heuristics/browser-language-heuristic.js +23 -23
  103. package/dist/src/collection-facets/smart-facets/heuristics/query-keywords-heuristic.d.ts +5 -5
  104. package/dist/src/collection-facets/smart-facets/heuristics/query-keywords-heuristic.js +44 -44
  105. package/dist/src/collection-facets/smart-facets/heuristics/query-keywords-heuristic.js.map +1 -1
  106. package/dist/src/collection-facets/smart-facets/heuristics/wikidata-heuristic.d.ts +5 -5
  107. package/dist/src/collection-facets/smart-facets/heuristics/wikidata-heuristic.js +172 -172
  108. package/dist/src/collection-facets/smart-facets/heuristics/wikidata-heuristic.js.map +1 -1
  109. package/dist/src/collection-facets/smart-facets/models.d.ts +26 -26
  110. package/dist/src/collection-facets/smart-facets/models.js +1 -1
  111. package/dist/src/collection-facets/smart-facets/smart-facet-bar.d.ts +31 -31
  112. package/dist/src/collection-facets/smart-facets/smart-facet-bar.js +237 -240
  113. package/dist/src/collection-facets/smart-facets/smart-facet-bar.js.map +1 -1
  114. package/dist/src/collection-facets/smart-facets/smart-facet-button.d.ts +11 -11
  115. package/dist/src/collection-facets/smart-facets/smart-facet-button.js +86 -86
  116. package/dist/src/collection-facets/smart-facets/smart-facet-button.js.map +1 -1
  117. package/dist/src/collection-facets/smart-facets/smart-facet-dropdown.d.ts +16 -16
  118. package/dist/src/collection-facets/smart-facets/smart-facet-dropdown.js +100 -100
  119. package/dist/src/collection-facets/smart-facets/smart-facet-dropdown.js.map +1 -1
  120. package/dist/src/collection-facets/smart-facets/smart-facet-equals.d.ts +2 -2
  121. package/dist/src/collection-facets/smart-facets/smart-facet-equals.js +12 -12
  122. package/dist/src/collection-facets/smart-facets/smart-facet-heuristics.d.ts +5 -5
  123. package/dist/src/collection-facets/smart-facets/smart-facet-heuristics.js +15 -15
  124. package/dist/src/collection-facets/smart-facets/smart-facet-heuristics.js.map +1 -1
  125. package/dist/src/collection-facets/toggle-switch.d.ts +41 -41
  126. package/dist/src/collection-facets/toggle-switch.js +94 -94
  127. package/dist/src/collection-facets/toggle-switch.js.map +1 -1
  128. package/dist/src/collection-facets.d.ts +103 -103
  129. package/dist/src/collection-facets.js +521 -522
  130. package/dist/src/collection-facets.js.map +1 -1
  131. package/dist/src/data-source/collection-browser-data-source-interface.d.ts +245 -245
  132. package/dist/src/data-source/collection-browser-data-source-interface.js +1 -1
  133. package/dist/src/data-source/collection-browser-data-source-interface.js.map +1 -1
  134. package/dist/src/data-source/collection-browser-data-source.d.ts +377 -377
  135. package/dist/src/data-source/collection-browser-data-source.js +1003 -1001
  136. package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
  137. package/dist/src/data-source/collection-browser-query-state.d.ts +44 -44
  138. package/dist/src/data-source/collection-browser-query-state.js +1 -1
  139. package/dist/src/data-source/models.d.ts +28 -28
  140. package/dist/src/data-source/models.js +8 -8
  141. package/dist/src/empty-placeholder.d.ts +23 -23
  142. package/dist/src/empty-placeholder.js +87 -88
  143. package/dist/src/empty-placeholder.js.map +1 -1
  144. package/dist/src/expanded-date-picker.d.ts +43 -43
  145. package/dist/src/expanded-date-picker.js +109 -109
  146. package/dist/src/expanded-date-picker.js.map +1 -1
  147. package/dist/src/language-code-handler/language-code-handler.d.ts +37 -37
  148. package/dist/src/language-code-handler/language-code-handler.js +26 -26
  149. package/dist/src/language-code-handler/language-code-handler.js.map +1 -1
  150. package/dist/src/language-code-handler/language-code-mapping.d.ts +1 -1
  151. package/dist/src/language-code-handler/language-code-mapping.js +562 -562
  152. package/dist/src/language-code-handler/language-code-mapping.js.map +1 -1
  153. package/dist/src/manage/manage-bar.d.ts +58 -58
  154. package/dist/src/manage/manage-bar.js +175 -175
  155. package/dist/src/manage/manage-bar.js.map +1 -1
  156. package/dist/src/manage/remove-items-modal-content.d.ts +9 -9
  157. package/dist/src/manage/remove-items-modal-content.js +34 -34
  158. package/dist/src/manage/remove-items-modal-content.js.map +1 -1
  159. package/dist/src/mediatype/mediatype-config.d.ts +3 -3
  160. package/dist/src/mediatype/mediatype-config.js +92 -91
  161. package/dist/src/mediatype/mediatype-config.js.map +1 -1
  162. package/dist/src/models.d.ts +228 -228
  163. package/dist/src/models.js +401 -401
  164. package/dist/src/models.js.map +1 -1
  165. package/dist/src/restoration-state-handler.d.ts +70 -70
  166. package/dist/src/restoration-state-handler.js +362 -363
  167. package/dist/src/restoration-state-handler.js.map +1 -1
  168. package/dist/src/sort-filter-bar/alpha-bar-tooltip.d.ts +6 -6
  169. package/dist/src/sort-filter-bar/alpha-bar-tooltip.js +24 -24
  170. package/dist/src/sort-filter-bar/alpha-bar-tooltip.js.map +1 -1
  171. package/dist/src/sort-filter-bar/alpha-bar.d.ts +21 -21
  172. package/dist/src/sort-filter-bar/alpha-bar.js +136 -136
  173. package/dist/src/sort-filter-bar/alpha-bar.js.map +1 -1
  174. package/dist/src/sort-filter-bar/img/compact.d.ts +1 -1
  175. package/dist/src/sort-filter-bar/img/compact.js +2 -2
  176. package/dist/src/sort-filter-bar/img/list.d.ts +1 -1
  177. package/dist/src/sort-filter-bar/img/list.js +2 -2
  178. package/dist/src/sort-filter-bar/img/sort-toggle-disabled.d.ts +1 -1
  179. package/dist/src/sort-filter-bar/img/sort-toggle-disabled.js +2 -2
  180. package/dist/src/sort-filter-bar/img/sort-toggle-down.d.ts +1 -1
  181. package/dist/src/sort-filter-bar/img/sort-toggle-down.js +2 -2
  182. package/dist/src/sort-filter-bar/img/sort-toggle-up.d.ts +1 -1
  183. package/dist/src/sort-filter-bar/img/sort-toggle-up.js +2 -2
  184. package/dist/src/sort-filter-bar/img/sort-triangle.d.ts +1 -1
  185. package/dist/src/sort-filter-bar/img/sort-triangle.js +2 -2
  186. package/dist/src/sort-filter-bar/img/tile.d.ts +1 -1
  187. package/dist/src/sort-filter-bar/img/tile.js +2 -2
  188. package/dist/src/sort-filter-bar/sort-filter-bar.d.ts +223 -223
  189. package/dist/src/sort-filter-bar/sort-filter-bar.js +696 -697
  190. package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
  191. package/dist/src/styles/ia-button.d.ts +2 -2
  192. package/dist/src/styles/ia-button.js +17 -17
  193. package/dist/src/styles/item-image-styles.d.ts +8 -8
  194. package/dist/src/styles/item-image-styles.js +9 -9
  195. package/dist/src/styles/sr-only.d.ts +1 -1
  196. package/dist/src/styles/sr-only.js +2 -2
  197. package/dist/src/tiles/base-tile-component.d.ts +19 -19
  198. package/dist/src/tiles/base-tile-component.js +64 -64
  199. package/dist/src/tiles/base-tile-component.js.map +1 -1
  200. package/dist/src/tiles/collection-browser-loading-tile.d.ts +5 -5
  201. package/dist/src/tiles/collection-browser-loading-tile.js +15 -15
  202. package/dist/src/tiles/collection-browser-loading-tile.js.map +1 -1
  203. package/dist/src/tiles/grid/account-tile.d.ts +18 -18
  204. package/dist/src/tiles/grid/account-tile.js +72 -72
  205. package/dist/src/tiles/grid/account-tile.js.map +1 -1
  206. package/dist/src/tiles/grid/collection-tile.d.ts +15 -15
  207. package/dist/src/tiles/grid/collection-tile.js +80 -80
  208. package/dist/src/tiles/grid/collection-tile.js.map +1 -1
  209. package/dist/src/tiles/grid/item-tile.d.ts +34 -34
  210. package/dist/src/tiles/grid/item-tile.js +159 -160
  211. package/dist/src/tiles/grid/item-tile.js.map +1 -1
  212. package/dist/src/tiles/grid/search-tile.d.ts +10 -10
  213. package/dist/src/tiles/grid/search-tile.js +51 -51
  214. package/dist/src/tiles/grid/search-tile.js.map +1 -1
  215. package/dist/src/tiles/grid/styles/tile-grid-shared-styles.d.ts +1 -1
  216. package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js +8 -8
  217. package/dist/src/tiles/grid/tile-stats.d.ts +11 -11
  218. package/dist/src/tiles/grid/tile-stats.js +54 -54
  219. package/dist/src/tiles/grid/tile-stats.js.map +1 -1
  220. package/dist/src/tiles/hover/hover-pane-controller.d.ts +219 -219
  221. package/dist/src/tiles/hover/hover-pane-controller.js +352 -352
  222. package/dist/src/tiles/hover/hover-pane-controller.js.map +1 -1
  223. package/dist/src/tiles/hover/tile-hover-pane.d.ts +18 -18
  224. package/dist/src/tiles/hover/tile-hover-pane.js +72 -70
  225. package/dist/src/tiles/hover/tile-hover-pane.js.map +1 -1
  226. package/dist/src/tiles/image-block.d.ts +18 -18
  227. package/dist/src/tiles/image-block.js +89 -89
  228. package/dist/src/tiles/image-block.js.map +1 -1
  229. package/dist/src/tiles/item-image.d.ts +39 -39
  230. package/dist/src/tiles/item-image.js +154 -154
  231. package/dist/src/tiles/item-image.js.map +1 -1
  232. package/dist/src/tiles/list/tile-list-compact-header.d.ts +6 -6
  233. package/dist/src/tiles/list/tile-list-compact-header.js +38 -38
  234. package/dist/src/tiles/list/tile-list-compact-header.js.map +1 -1
  235. package/dist/src/tiles/list/tile-list-compact.d.ts +19 -19
  236. package/dist/src/tiles/list/tile-list-compact.js +122 -122
  237. package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
  238. package/dist/src/tiles/list/tile-list.d.ts +54 -54
  239. package/dist/src/tiles/list/tile-list.js +324 -326
  240. package/dist/src/tiles/list/tile-list.js.map +1 -1
  241. package/dist/src/tiles/mediatype-icon.d.ts +9 -9
  242. package/dist/src/tiles/mediatype-icon.js +47 -47
  243. package/dist/src/tiles/mediatype-icon.js.map +1 -1
  244. package/dist/src/tiles/overlay/icon-overlay.d.ts +8 -8
  245. package/dist/src/tiles/overlay/icon-overlay.js +25 -25
  246. package/dist/src/tiles/overlay/icon-overlay.js.map +1 -1
  247. package/dist/src/tiles/overlay/text-overlay.d.ts +9 -9
  248. package/dist/src/tiles/overlay/text-overlay.js +31 -31
  249. package/dist/src/tiles/overlay/text-overlay.js.map +1 -1
  250. package/dist/src/tiles/review-block.d.ts +12 -12
  251. package/dist/src/tiles/review-block.js +56 -56
  252. package/dist/src/tiles/review-block.js.map +1 -1
  253. package/dist/src/tiles/text-snippet-block.d.ts +27 -27
  254. package/dist/src/tiles/text-snippet-block.js +73 -73
  255. package/dist/src/tiles/text-snippet-block.js.map +1 -1
  256. package/dist/src/tiles/tile-dispatcher.d.ts +64 -64
  257. package/dist/src/tiles/tile-dispatcher.js +230 -230
  258. package/dist/src/tiles/tile-dispatcher.js.map +1 -1
  259. package/dist/src/tiles/tile-display-value-provider.d.ts +47 -47
  260. package/dist/src/tiles/tile-display-value-provider.js +94 -94
  261. package/dist/src/tiles/tile-display-value-provider.js.map +1 -1
  262. package/dist/src/utils/analytics-events.d.ts +28 -28
  263. package/dist/src/utils/analytics-events.js +30 -30
  264. package/dist/src/utils/array-equals.d.ts +4 -4
  265. package/dist/src/utils/array-equals.js +10 -10
  266. package/dist/src/utils/collapse-repeated-quotes.d.ts +11 -11
  267. package/dist/src/utils/collapse-repeated-quotes.js +13 -13
  268. package/dist/src/utils/facet-utils.d.ts +83 -83
  269. package/dist/src/utils/facet-utils.js +145 -145
  270. package/dist/src/utils/facet-utils.js.map +1 -1
  271. package/dist/src/utils/format-count.d.ts +7 -7
  272. package/dist/src/utils/format-count.js +75 -76
  273. package/dist/src/utils/format-count.js.map +1 -1
  274. package/dist/src/utils/format-date.d.ts +2 -2
  275. package/dist/src/utils/format-date.js +27 -27
  276. package/dist/src/utils/format-date.js.map +1 -1
  277. package/dist/src/utils/format-unit-size.d.ts +2 -2
  278. package/dist/src/utils/format-unit-size.js +33 -33
  279. package/dist/src/utils/format-unit-size.js.map +1 -1
  280. package/dist/src/utils/local-date-from-utc.d.ts +9 -9
  281. package/dist/src/utils/local-date-from-utc.js +15 -15
  282. package/dist/src/utils/log.d.ts +7 -7
  283. package/dist/src/utils/log.js +13 -15
  284. package/dist/src/utils/log.js.map +1 -1
  285. package/dist/src/utils/resolve-mediatype.d.ts +8 -8
  286. package/dist/src/utils/resolve-mediatype.js +23 -23
  287. package/dist/src/utils/resolve-mediatype.js.map +1 -1
  288. package/dist/src/utils/sha1.d.ts +2 -2
  289. package/dist/src/utils/sha1.js +8 -8
  290. package/dist/test/collection-browser.test.d.ts +1 -1
  291. package/dist/test/collection-browser.test.js +1309 -1308
  292. package/dist/test/collection-browser.test.js.map +1 -1
  293. package/dist/test/collection-facets/facet-row.test.d.ts +1 -1
  294. package/dist/test/collection-facets/facet-row.test.js +230 -227
  295. package/dist/test/collection-facets/facet-row.test.js.map +1 -1
  296. package/dist/test/collection-facets/facets-template.test.d.ts +1 -1
  297. package/dist/test/collection-facets/facets-template.test.js +91 -91
  298. package/dist/test/collection-facets/facets-template.test.js.map +1 -1
  299. package/dist/test/collection-facets/more-facets-content.test.d.ts +1 -1
  300. package/dist/test/collection-facets/more-facets-content.test.js +140 -141
  301. package/dist/test/collection-facets/more-facets-content.test.js.map +1 -1
  302. package/dist/test/collection-facets/more-facets-pagination.test.d.ts +1 -1
  303. package/dist/test/collection-facets/more-facets-pagination.test.js +116 -117
  304. package/dist/test/collection-facets/more-facets-pagination.test.js.map +1 -1
  305. package/dist/test/collection-facets/toggle-switch.test.d.ts +1 -1
  306. package/dist/test/collection-facets/toggle-switch.test.js +82 -73
  307. package/dist/test/collection-facets/toggle-switch.test.js.map +1 -1
  308. package/dist/test/collection-facets.test.d.ts +2 -2
  309. package/dist/test/collection-facets.test.js +692 -692
  310. package/dist/test/collection-facets.test.js.map +1 -1
  311. package/dist/test/data-source/collection-browser-data-source.test.d.ts +1 -1
  312. package/dist/test/data-source/collection-browser-data-source.test.js +89 -89
  313. package/dist/test/data-source/collection-browser-data-source.test.js.map +1 -1
  314. package/dist/test/empty-placeholder.test.d.ts +1 -1
  315. package/dist/test/empty-placeholder.test.js +62 -63
  316. package/dist/test/empty-placeholder.test.js.map +1 -1
  317. package/dist/test/expanded-date-picker.test.d.ts +1 -1
  318. package/dist/test/expanded-date-picker.test.js +97 -96
  319. package/dist/test/expanded-date-picker.test.js.map +1 -1
  320. package/dist/test/icon-overlay.test.d.ts +1 -1
  321. package/dist/test/icon-overlay.test.js +23 -24
  322. package/dist/test/icon-overlay.test.js.map +1 -1
  323. package/dist/test/image-block.test.d.ts +1 -1
  324. package/dist/test/image-block.test.js +106 -107
  325. package/dist/test/image-block.test.js.map +1 -1
  326. package/dist/test/item-image.test.d.ts +1 -1
  327. package/dist/test/item-image.test.js +84 -85
  328. package/dist/test/item-image.test.js.map +1 -1
  329. package/dist/test/manage/manage-bar.test.d.ts +2 -2
  330. package/dist/test/manage/manage-bar.test.js +100 -101
  331. package/dist/test/manage/manage-bar.test.js.map +1 -1
  332. package/dist/test/manage/remove-items-modal-content.test.d.ts +1 -1
  333. package/dist/test/manage/remove-items-modal-content.test.js +44 -45
  334. package/dist/test/manage/remove-items-modal-content.test.js.map +1 -1
  335. package/dist/test/mediatype-config.test.d.ts +1 -1
  336. package/dist/test/mediatype-config.test.js +16 -16
  337. package/dist/test/mocks/mock-analytics-handler.d.ts +10 -10
  338. package/dist/test/mocks/mock-analytics-handler.js +15 -15
  339. package/dist/test/mocks/mock-search-responses.d.ts +25 -25
  340. package/dist/test/mocks/mock-search-responses.js +942 -942
  341. package/dist/test/mocks/mock-search-responses.js.map +1 -1
  342. package/dist/test/mocks/mock-search-service.d.ts +15 -15
  343. package/dist/test/mocks/mock-search-service.js +54 -54
  344. package/dist/test/mocks/mock-search-service.js.map +1 -1
  345. package/dist/test/restoration-state-handler.test.d.ts +1 -1
  346. package/dist/test/restoration-state-handler.test.js +270 -270
  347. package/dist/test/restoration-state-handler.test.js.map +1 -1
  348. package/dist/test/review-block.test.d.ts +1 -1
  349. package/dist/test/review-block.test.js +43 -44
  350. package/dist/test/review-block.test.js.map +1 -1
  351. package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.d.ts +1 -1
  352. package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.js +12 -12
  353. package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.js.map +1 -1
  354. package/dist/test/sort-filter-bar/alpha-bar.test.d.ts +1 -1
  355. package/dist/test/sort-filter-bar/alpha-bar.test.js +73 -73
  356. package/dist/test/sort-filter-bar/alpha-bar.test.js.map +1 -1
  357. package/dist/test/sort-filter-bar/sort-filter-bar.test.d.ts +1 -1
  358. package/dist/test/sort-filter-bar/sort-filter-bar.test.js +425 -426
  359. package/dist/test/sort-filter-bar/sort-filter-bar.test.js.map +1 -1
  360. package/dist/test/text-overlay.test.d.ts +1 -1
  361. package/dist/test/text-overlay.test.js +37 -38
  362. package/dist/test/text-overlay.test.js.map +1 -1
  363. package/dist/test/text-snippet-block.test.d.ts +1 -1
  364. package/dist/test/text-snippet-block.test.js +56 -57
  365. package/dist/test/text-snippet-block.test.js.map +1 -1
  366. package/dist/test/tile-stats.test.d.ts +1 -1
  367. package/dist/test/tile-stats.test.js +98 -99
  368. package/dist/test/tile-stats.test.js.map +1 -1
  369. package/dist/test/tiles/grid/account-tile.test.d.ts +1 -1
  370. package/dist/test/tiles/grid/account-tile.test.js +75 -76
  371. package/dist/test/tiles/grid/account-tile.test.js.map +1 -1
  372. package/dist/test/tiles/grid/collection-tile.test.d.ts +1 -1
  373. package/dist/test/tiles/grid/collection-tile.test.js +72 -73
  374. package/dist/test/tiles/grid/collection-tile.test.js.map +1 -1
  375. package/dist/test/tiles/grid/item-tile.test.d.ts +1 -1
  376. package/dist/test/tiles/grid/item-tile.test.js +311 -312
  377. package/dist/test/tiles/grid/item-tile.test.js.map +1 -1
  378. package/dist/test/tiles/grid/search-tile.test.d.ts +1 -1
  379. package/dist/test/tiles/grid/search-tile.test.js +50 -51
  380. package/dist/test/tiles/grid/search-tile.test.js.map +1 -1
  381. package/dist/test/tiles/hover/hover-pane-controller.test.d.ts +1 -1
  382. package/dist/test/tiles/hover/hover-pane-controller.test.js +259 -259
  383. package/dist/test/tiles/hover/hover-pane-controller.test.js.map +1 -1
  384. package/dist/test/tiles/hover/tile-hover-pane.test.d.ts +1 -1
  385. package/dist/test/tiles/hover/tile-hover-pane.test.js +56 -56
  386. package/dist/test/tiles/hover/tile-hover-pane.test.js.map +1 -1
  387. package/dist/test/tiles/list/tile-list-compact.test.d.ts +1 -1
  388. package/dist/test/tiles/list/tile-list-compact.test.js +142 -143
  389. package/dist/test/tiles/list/tile-list-compact.test.js.map +1 -1
  390. package/dist/test/tiles/list/tile-list.test.d.ts +1 -1
  391. package/dist/test/tiles/list/tile-list.test.js +296 -297
  392. package/dist/test/tiles/list/tile-list.test.js.map +1 -1
  393. package/dist/test/tiles/tile-dispatcher.test.d.ts +1 -1
  394. package/dist/test/tiles/tile-dispatcher.test.js +100 -100
  395. package/dist/test/tiles/tile-dispatcher.test.js.map +1 -1
  396. package/dist/test/tiles/tile-display-value-provider.test.d.ts +1 -1
  397. package/dist/test/tiles/tile-display-value-provider.test.js +141 -141
  398. package/dist/test/utils/array-equals.test.d.ts +1 -1
  399. package/dist/test/utils/array-equals.test.js +26 -26
  400. package/dist/test/utils/format-count.test.d.ts +1 -1
  401. package/dist/test/utils/format-count.test.js +23 -23
  402. package/dist/test/utils/format-count.test.js.map +1 -1
  403. package/dist/test/utils/format-date.test.d.ts +1 -1
  404. package/dist/test/utils/format-date.test.js +30 -30
  405. package/dist/test/utils/format-date.test.js.map +1 -1
  406. package/dist/test/utils/format-unit-size.test.d.ts +1 -1
  407. package/dist/test/utils/format-unit-size.test.js +17 -17
  408. package/dist/test/utils/local-date-from-utc.test.d.ts +1 -1
  409. package/dist/test/utils/local-date-from-utc.test.js +26 -26
  410. package/dist/test/utils/local-date-from-utc.test.js.map +1 -1
  411. package/eslint.config.mjs +53 -0
  412. package/index.html +0 -3
  413. package/local.archive.org.cert +86 -86
  414. package/local.archive.org.key +27 -27
  415. package/package.json +41 -39
  416. package/renovate.json +6 -6
  417. package/src/app-root.ts +33 -24
  418. package/src/collection-browser.ts +62 -53
  419. package/src/collection-facets/facets-template.ts +7 -6
  420. package/src/collection-facets/more-facets-content.ts +11 -13
  421. package/src/collection-facets/more-facets-pagination.ts +3 -2
  422. package/src/collection-facets/smart-facets/dedupe.ts +2 -2
  423. package/src/collection-facets/smart-facets/heuristics/query-keywords-heuristic.ts +1 -1
  424. package/src/collection-facets/smart-facets/heuristics/wikidata-heuristic.ts +6 -6
  425. package/src/collection-facets/smart-facets/smart-facet-bar.ts +6 -8
  426. package/src/collection-facets/smart-facets/smart-facet-button.ts +5 -3
  427. package/src/collection-facets/smart-facets/smart-facet-dropdown.ts +4 -4
  428. package/src/collection-facets/smart-facets/smart-facet-heuristics.ts +1 -1
  429. package/src/collection-facets/toggle-switch.ts +2 -2
  430. package/src/collection-facets.ts +18 -19
  431. package/src/data-source/collection-browser-data-source-interface.ts +5 -1
  432. package/src/data-source/collection-browser-data-source.ts +42 -35
  433. package/src/empty-placeholder.ts +19 -16
  434. package/src/expanded-date-picker.ts +1 -1
  435. package/src/language-code-handler/language-code-handler.ts +1 -1
  436. package/src/manage/manage-bar.ts +23 -20
  437. package/src/manage/remove-items-modal-content.ts +2 -2
  438. package/src/mediatype/mediatype-config.ts +1 -0
  439. package/src/models.ts +3 -3
  440. package/src/restoration-state-handler.ts +14 -15
  441. package/src/sort-filter-bar/alpha-bar.ts +16 -17
  442. package/src/sort-filter-bar/sort-filter-bar.ts +14 -15
  443. package/src/tiles/grid/account-tile.ts +1 -1
  444. package/src/tiles/grid/collection-tile.ts +1 -1
  445. package/src/tiles/grid/item-tile.ts +9 -9
  446. package/src/tiles/grid/tile-stats.ts +4 -4
  447. package/src/tiles/hover/hover-pane-controller.ts +1 -1
  448. package/src/tiles/hover/tile-hover-pane.ts +4 -2
  449. package/src/tiles/item-image.ts +1 -1
  450. package/src/tiles/list/tile-list-compact.ts +2 -2
  451. package/src/tiles/list/tile-list.ts +22 -24
  452. package/src/tiles/tile-dispatcher.ts +5 -5
  453. package/src/tiles/tile-display-value-provider.ts +4 -4
  454. package/src/utils/facet-utils.ts +6 -6
  455. package/src/utils/format-count.ts +2 -3
  456. package/src/utils/format-date.ts +1 -1
  457. package/src/utils/format-unit-size.ts +1 -1
  458. package/src/utils/log.ts +1 -3
  459. package/test/collection-browser.test.ts +135 -134
  460. package/test/collection-facets/facet-row.test.ts +31 -28
  461. package/test/collection-facets/facets-template.test.ts +9 -9
  462. package/test/collection-facets/more-facets-content.test.ts +14 -15
  463. package/test/collection-facets/more-facets-pagination.test.ts +18 -19
  464. package/test/collection-facets/toggle-switch.test.ts +28 -18
  465. package/test/collection-facets.test.ts +46 -39
  466. package/test/data-source/collection-browser-data-source.test.ts +2 -2
  467. package/test/empty-placeholder.test.ts +6 -7
  468. package/test/expanded-date-picker.test.ts +25 -20
  469. package/test/icon-overlay.test.ts +0 -1
  470. package/test/image-block.test.ts +6 -7
  471. package/test/item-image.test.ts +0 -1
  472. package/test/manage/manage-bar.test.ts +19 -16
  473. package/test/manage/remove-items-modal-content.test.ts +4 -5
  474. package/test/mocks/mock-search-responses.ts +2 -1
  475. package/test/mocks/mock-search-service.ts +1 -1
  476. package/test/restoration-state-handler.test.ts +12 -12
  477. package/test/review-block.test.ts +1 -2
  478. package/test/sort-filter-bar/alpha-bar-tooltip.test.ts +1 -1
  479. package/test/sort-filter-bar/alpha-bar.test.ts +5 -5
  480. package/test/sort-filter-bar/sort-filter-bar.test.ts +38 -39
  481. package/test/text-overlay.test.ts +0 -1
  482. package/test/text-snippet-block.test.ts +5 -6
  483. package/test/tile-stats.test.ts +26 -35
  484. package/test/tiles/grid/account-tile.test.ts +2 -3
  485. package/test/tiles/grid/collection-tile.test.ts +3 -4
  486. package/test/tiles/grid/item-tile.test.ts +13 -14
  487. package/test/tiles/grid/search-tile.test.ts +1 -2
  488. package/test/tiles/hover/hover-pane-controller.test.ts +15 -15
  489. package/test/tiles/hover/tile-hover-pane.test.ts +5 -5
  490. package/test/tiles/list/tile-list-compact.test.ts +1 -2
  491. package/test/tiles/list/tile-list.test.ts +10 -11
  492. package/test/tiles/tile-dispatcher.test.ts +5 -5
  493. package/test/utils/format-count.test.ts +1 -1
  494. package/test/utils/format-date.test.ts +1 -1
  495. package/test/utils/local-date-from-utc.test.ts +1 -1
  496. package/tsconfig.json +0 -1
  497. package/web-dev-server.config.mjs +30 -30
  498. package/web-test-runner.config.mjs +41 -41
@@ -1,340 +1,344 @@
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 { classMap } from 'lit/directives/class-map.js';
6
- import { msg } from '@lit/localize';
7
- import { SearchType, } from '@internetarchive/search-service';
8
- import '@internetarchive/infinite-scroller';
9
- import { SortField, getDefaultSelectedFacets, sortOptionFromAPIString, SORT_OPTIONS, defaultProfileElementSorts, } from './models';
10
- import { RestorationStateHandler, } from './restoration-state-handler';
11
- import { CollectionBrowserDataSource } from './data-source/collection-browser-data-source';
12
- import { FACETLESS_PAGE_ELEMENTS } from './data-source/models';
13
- import { analyticsActions, analyticsCategories, } from './utils/analytics-events';
14
- import chevronIcon from './assets/img/icons/chevron';
15
- import { srOnlyStyle } from './styles/sr-only';
16
- import { sha1 } from './utils/sha1';
17
- import { log } from './utils/log';
18
- import './empty-placeholder';
19
- import './tiles/tile-dispatcher';
20
- import './tiles/collection-browser-loading-tile';
21
- import './sort-filter-bar/sort-filter-bar';
22
- import './manage/manage-bar';
23
- import './collection-facets';
24
- import './circular-activity-indicator';
25
- import './collection-facets/smart-facets/smart-facet-bar';
26
- let CollectionBrowser = class CollectionBrowser extends LitElement {
27
- constructor() {
28
- super();
29
- this.baseImageUrl = 'https://archive.org';
30
- /**
31
- * Which backend should be targeted by searches (e.g., metadata or FTS)
32
- */
33
- this.searchType = SearchType.METADATA;
34
- this.selectedSort = SortField.default;
35
- this.selectedTitleFilter = null;
36
- this.selectedCreatorFilter = null;
37
- this.sortDirection = null;
38
- this.defaultSortField = SortField.relevance;
39
- this.defaultSortDirection = null;
40
- this.pageSize = 50;
41
- this.showSmartFacetBar = false;
42
- /**
43
- * Whether to show the date picker (above the facets)
44
- */
45
- this.showHistogramDatePicker = false;
46
- /**
47
- * Whether placeholder views should be suppressed. If true, searches that produce an
48
- * error or empty result set will simply show a blank results view instead of a placeholder.
49
- */
50
- this.suppressPlaceholders = false;
51
- /**
52
- * Whether the result count text should be suppressed.
53
- * If true, no "X Results" message will be shown.
54
- */
55
- this.suppressResultCount = false;
56
- /**
57
- * Whether the scrolling result view should be suppressed entirely.
58
- * If true, no infinite scroller (and thus no result tiles) will be rendered.
59
- */
60
- this.suppressResultTiles = false;
61
- /**
62
- * Whether to suppress persistence of the query to the URL.
63
- * If true, the `query` param will not be added to the URL or updated on query changes.
64
- */
65
- this.suppressURLQuery = false;
66
- /**
67
- * Whether to suppress display of the sort bar.
68
- * If true, the entire sort bar (incl. display modes) will be omitted from rendering.
69
- */
70
- this.suppressSortBar = false;
71
- /**
72
- * Whether to suppress showing the display mode options in the sort bar.
73
- * If true, those options will be omitted (though the rest of the sort bar may still render).
74
- */
75
- this.suppressDisplayModes = false;
76
- /**
77
- * What strategy to use for when/whether to load facet data for a search.
78
- *
79
- * Defaults to `eager`, always loading facets immediately alongside search results.
80
- *
81
- * To eliminate facets that are never seen, this can be reduced to `lazy-mobile`, which
82
- * will delay loading facets in the mobile view until the "Filters" accordion is opened.
83
- * Facets are still loaded eagerly when viewing the desktop layout.
84
- *
85
- * To further reduce facet requests for patrons who do not need to use them, this can be
86
- * again reduced to `opt-in`, which will also require desktop users to explicitly request
87
- * that they be loaded (in addition to the lazy mobile behavior described above).
88
- *
89
- * To entirely suppress facets from being loaded, this may be set to `off`.
90
- */
91
- this.facetLoadStrategy = 'eager';
92
- this.facetPaneVisible = false;
93
- this.clearResultsOnEmptyQuery = false;
94
- this.collectionPagePath = '/details/';
95
- /** describes where this component is being used */
96
- this.searchContext = analyticsCategories.default;
97
- this.pageContext = 'search';
98
- this.restorationStateHandler = new RestorationStateHandler({
99
- context: this.pageContext,
100
- });
101
- this.mobileBreakpoint = 600;
102
- this.loggedIn = false;
103
- this.modalManager = undefined;
104
- /**
105
- * If item management UI active
106
- */
107
- this.isManageView = false;
108
- this.manageViewLabel = 'Select items to remove';
109
- /** Whether to replace the default sort options with a slot for customization (default: false) */
110
- this.enableSortOptionsSlot = false;
111
- /** Whether to display a smart results carousel above the full results */
112
- this.showSmartResults = false;
113
- /**
114
- * The maximum number of pages we will load when a privileged user clicks
115
- * the "Manage" button on the search page. Limited to 15 pages.
116
- */
117
- this.maxPagesToManage = 15;
118
- /**
119
- * The results per page so we can paginate.
120
- *
121
- * This allows us to start in the middle of the search results and
122
- * fetch data before or after the current page. If we don't have a key
123
- * for the previous/next page, we'll fetch the next/previous page to populate it
124
- */
125
- this.dataSource = new CollectionBrowserDataSource(this, this.pageSize);
126
- /**
127
- * The page that the consumer wants to load.
128
- */
129
- this.initialPageNumber = 1;
130
- /**
131
- * This the the number of pages that we want to show.
132
- *
133
- * The data isn't necessarily loaded for all of the pages, but this lets us
134
- * know how many cells we should render.
135
- */
136
- this.pagesToRender = this.initialPageNumber;
137
- /**
138
- * Whether the initial page fetch for a new query is currently in progress.
139
- */
140
- this.searchResultsLoading = false;
141
- this.facetsLoading = false;
142
- this.mobileView = false;
143
- this.collapsibleFacetsVisible = false;
144
- this.placeholderType = null;
145
- /** Whether layout size analytics have been sent already. */
146
- this.layoutSizeAnalyticsSent = false;
147
- /**
148
- * When we're animated scrolling to the page, we don't want to fetch
149
- * all of the pages as it scrolls so this lets us know if we're scrolling
150
- */
151
- this.isScrollingToCell = false;
152
- /**
153
- * When page width resizes from desktop to mobile, set true to
154
- * disable expand/collapse transition when loading.
155
- */
156
- this.isResizeToMobile = false;
157
- /**
158
- * Flag indicating that a new data source is currently being installed.
159
- * During the install, any URL persistence operation should replace the current entry
160
- * instead of creating a new one.
161
- */
162
- this.dataSourceInstallInProgress = false;
163
- this.placeholderCellTemplate = html `<collection-browser-loading-tile></collection-browser-loading-tile>`;
164
- /**
165
- * Updates the height of the left column according to its position on the page.
166
- * Arrow function ensures proper `this` binding.
167
- */
168
- this.updateLeftColumnHeight = () => {
169
- var _a, _b, _c, _d, _e;
170
- if (this.mobileView) {
171
- (_b = (_a = this.leftColumn) === null || _a === void 0 ? void 0 : _a.style) === null || _b === void 0 ? void 0 : _b.removeProperty('height');
172
- }
173
- else {
174
- const clientTop = (_c = this.leftColumn) === null || _c === void 0 ? void 0 : _c.getBoundingClientRect().top;
175
- const columnHeight = window.innerHeight - (clientTop !== null && clientTop !== void 0 ? clientTop : 0);
176
- const cssHeightValue = clientTop === 0
177
- ? null
178
- : // Subtract off the column's top padding so that it doesn't overflow
179
- `calc(${columnHeight}px - var(--leftColumnPaddingTop, 2rem))`;
180
- (_e = (_d = this.leftColumn) === null || _d === void 0 ? void 0 : _d.style) === null || _e === void 0 ? void 0 : _e.setProperty('height', cssHeightValue);
181
- }
182
- };
183
- /**
184
- * Toggles whether the fade-out is visible at the bottom of the facets.
185
- * It should only be visible if the facets are not scrolled to the bottom.
186
- * Arrow function ensures proper `this` binding.
187
- */
188
- this.updateFacetFadeOut = (entries) => {
189
- var _a, _b;
190
- const fadeElmt = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.getElementById('facets-bottom-fade');
191
- fadeElmt === null || fadeElmt === void 0 ? void 0 : fadeElmt.classList.toggle('hidden', (_b = entries === null || entries === void 0 ? void 0 : entries[0]) === null || _b === void 0 ? void 0 : _b.isIntersecting);
192
- };
193
- // we only want to scroll on the very first query change
194
- // so this keeps track of whether we've already set the initial query
195
- this.initialQueryChangeHappened = false;
196
- this.historyPopOccurred = false;
197
- this.addController(this.dataSource);
198
- }
199
- tileModelAtCellIndex(index) {
200
- const model = this.dataSource.getTileModelAt(index);
201
- /**
202
- * If we encounter a model we don't have yet and we're not in the middle of an
203
- * automated scroll, fetch the page and just return undefined.
204
- * The datasource will be updated once the page is loaded and the cell will be rendered.
205
- *
206
- * We disable it during the automated scroll since we don't want to fetch pages for intervening cells the
207
- * user may never see.
208
- */
209
- if (!model && !this.isScrollingToCell && this.dataSource.queryInitialized) {
210
- const pageNumber = Math.floor(index / this.pageSize) + 1;
211
- this.dataSource.fetchPage(pageNumber);
212
- }
213
- return model;
214
- }
215
- // this is the total number of tiles we expect if
216
- // the data returned is a full page worth
217
- // this is useful for putting in placeholders for the expected number of tiles
218
- get estimatedTileCount() {
219
- return this.pagesToRender * this.pageSize;
220
- }
221
- /**
222
- * Returns a promise resolving to a unique string that persists for the current browser session.
223
- * Used in generating unique IDs for search requests, so that multiple requests coming from the
224
- * same browser session can be identified.
225
- */
226
- async getSessionId() {
227
- try {
228
- const storedSessionId = sessionStorage === null || sessionStorage === void 0 ? void 0 : sessionStorage.getItem('cb-session');
229
- if (storedSessionId) {
230
- return storedSessionId;
231
- }
232
- // If we enter this method a second time while a first session ID is already being generated,
233
- // ensure we produce the same ID from both calls instead of generating another one.
234
- if (this.sessionIdGenPromise) {
235
- return this.sessionIdGenPromise;
236
- }
237
- this.sessionIdGenPromise = sha1(Math.random().toString());
238
- const newSessionId = await this.sessionIdGenPromise;
239
- sessionStorage === null || sessionStorage === void 0 ? void 0 : sessionStorage.setItem('cb-session', newSessionId);
240
- return newSessionId;
241
- }
242
- catch (err) {
243
- // Either we can't generate the hash or we're restricted from accessing sessionStorage
244
- return '';
245
- }
246
- }
247
- /**
248
- * Go to the given page of results
249
- *
250
- * @param pageNumber
251
- */
252
- goToPage(pageNumber) {
253
- this.initialPageNumber = pageNumber;
254
- this.pagesToRender = pageNumber;
255
- return this.scrollToPage(pageNumber);
256
- }
257
- /**
258
- * Sets the state for whether the initial set of search results is loading in.
259
- */
260
- setSearchResultsLoading(loading) {
261
- this.searchResultsLoading = loading;
262
- }
263
- /**
264
- * Sets the state for whether facet data is loading in
265
- */
266
- setFacetsLoading(loading) {
267
- this.facetsLoading = loading;
268
- }
269
- /**
270
- * Sets the total number of results to be displayed for the current search
271
- */
272
- setTotalResultCount(totalResults) {
273
- this.totalResults = totalResults;
274
- }
275
- /**
276
- * Clears all selected/negated facets, date ranges, and letter filters.
277
- *
278
- * By default, the current sort field/direction are not cleared,
279
- * but this can be overridden by setting the `sort` option to `true`.
280
- *
281
- * Similarly, it is possible to finely control what is cleared by
282
- * setting any of the `facets`, `dateRange`, or `letterFilters` flags
283
- * in the options object.
284
- */
285
- clearFilters({ facets = true, dateRange = true, letterFilters = true, sort = false, } = {}) {
286
- // Don't bother clearing facets if none are checked, so that we don't
287
- // trigger unnecessary update cycles.
288
- if (facets && this.hasCheckedFacets) {
289
- this.selectedFacets = getDefaultSelectedFacets();
290
- }
291
- if (dateRange) {
292
- this.minSelectedDate = undefined;
293
- this.maxSelectedDate = undefined;
294
- }
295
- if (letterFilters) {
296
- this.selectedTitleFilter = null;
297
- this.selectedCreatorFilter = null;
298
- }
299
- if (sort) {
300
- this.sortDirection = null;
301
- this.selectedSort = SortField.default;
302
- }
303
- }
304
- /**
305
- * Returns true if the current value of `this.selectedFacets` contains
306
- * any facet buckets than have been selected or negated, or false otherwise.
307
- */
308
- get hasCheckedFacets() {
309
- if (!this.selectedFacets)
310
- return false;
311
- for (const facetGroup of Object.values(this.selectedFacets)) {
312
- for (const bucket of Object.values(facetGroup)) {
313
- if (bucket.state !== 'none')
314
- return true;
315
- }
316
- }
317
- return false;
318
- }
319
- /**
320
- * Returns true if there are any currently selected/negated facet buckets,
321
- * any selected date range, or any selected letter filters. False otherwise.
322
- *
323
- * Ignores sorting options.
324
- */
325
- get hasActiveFilters() {
326
- return !!(this.hasCheckedFacets ||
327
- this.minSelectedDate ||
328
- this.maxSelectedDate ||
329
- this.selectedTitleFilter ||
330
- this.selectedCreatorFilter);
331
- }
332
- willUpdate() {
333
- this.setPlaceholderType();
334
- }
335
- render() {
1
+ import { __decorate } from "tslib";
2
+ import { html, css, LitElement, nothing, } from 'lit';
3
+ import { customElement, property, query, state } from 'lit/decorators.js';
4
+ import { classMap } from 'lit/directives/class-map.js';
5
+ import { msg } from '@lit/localize';
6
+ import { SearchType, } from '@internetarchive/search-service';
7
+ import '@internetarchive/infinite-scroller';
8
+ import { SortField, getDefaultSelectedFacets, sortOptionFromAPIString, SORT_OPTIONS, defaultProfileElementSorts, } from './models';
9
+ import { RestorationStateHandler, } from './restoration-state-handler';
10
+ import { CollectionBrowserDataSource } from './data-source/collection-browser-data-source';
11
+ import { FACETLESS_PAGE_ELEMENTS } from './data-source/models';
12
+ import { analyticsActions, analyticsCategories, } from './utils/analytics-events';
13
+ import chevronIcon from './assets/img/icons/chevron';
14
+ import { srOnlyStyle } from './styles/sr-only';
15
+ import { sha1 } from './utils/sha1';
16
+ import { log } from './utils/log';
17
+ import './empty-placeholder';
18
+ import './tiles/tile-dispatcher';
19
+ import './tiles/collection-browser-loading-tile';
20
+ import './sort-filter-bar/sort-filter-bar';
21
+ import './manage/manage-bar';
22
+ import './collection-facets';
23
+ import './circular-activity-indicator';
24
+ import './collection-facets/smart-facets/smart-facet-bar';
25
+ let CollectionBrowser = class CollectionBrowser extends LitElement {
26
+ constructor() {
27
+ super();
28
+ this.baseImageUrl = 'https://archive.org';
29
+ /**
30
+ * Which backend should be targeted by searches (e.g., metadata or FTS)
31
+ */
32
+ this.searchType = SearchType.METADATA;
33
+ this.selectedSort = SortField.default;
34
+ this.selectedTitleFilter = null;
35
+ this.selectedCreatorFilter = null;
36
+ this.sortDirection = null;
37
+ this.defaultSortField = SortField.relevance;
38
+ this.defaultSortDirection = null;
39
+ this.pageSize = 50;
40
+ this.showSmartFacetBar = false;
41
+ /**
42
+ * Whether to show the date picker (above the facets)
43
+ */
44
+ this.showHistogramDatePicker = false;
45
+ /**
46
+ * Whether placeholder views should be suppressed. If true, searches that produce an
47
+ * error or empty result set will simply show a blank results view instead of a placeholder.
48
+ */
49
+ this.suppressPlaceholders = false;
50
+ /**
51
+ * Whether the result count text should be suppressed.
52
+ * If true, no "X Results" message will be shown.
53
+ */
54
+ this.suppressResultCount = false;
55
+ /**
56
+ * Whether the scrolling result view should be suppressed entirely.
57
+ * If true, no infinite scroller (and thus no result tiles) will be rendered.
58
+ */
59
+ this.suppressResultTiles = false;
60
+ /**
61
+ * Whether to suppress persistence of the query to the URL.
62
+ * If true, the `query` param will not be added to the URL or updated on query changes.
63
+ */
64
+ this.suppressURLQuery = false;
65
+ /**
66
+ * Whether to suppress display of the sort bar.
67
+ * If true, the entire sort bar (incl. display modes) will be omitted from rendering.
68
+ */
69
+ this.suppressSortBar = false;
70
+ /**
71
+ * Whether to suppress showing the display mode options in the sort bar.
72
+ * If true, those options will be omitted (though the rest of the sort bar may still render).
73
+ */
74
+ this.suppressDisplayModes = false;
75
+ /**
76
+ * What strategy to use for when/whether to load facet data for a search.
77
+ *
78
+ * Defaults to `eager`, always loading facets immediately alongside search results.
79
+ *
80
+ * To eliminate facets that are never seen, this can be reduced to `lazy-mobile`, which
81
+ * will delay loading facets in the mobile view until the "Filters" accordion is opened.
82
+ * Facets are still loaded eagerly when viewing the desktop layout.
83
+ *
84
+ * To further reduce facet requests for patrons who do not need to use them, this can be
85
+ * again reduced to `opt-in`, which will also require desktop users to explicitly request
86
+ * that they be loaded (in addition to the lazy mobile behavior described above).
87
+ *
88
+ * To entirely suppress facets from being loaded, this may be set to `off`.
89
+ */
90
+ this.facetLoadStrategy = 'eager';
91
+ this.facetPaneVisible = false;
92
+ this.clearResultsOnEmptyQuery = false;
93
+ this.collectionPagePath = '/details/';
94
+ /** describes where this component is being used */
95
+ this.searchContext = analyticsCategories.default;
96
+ this.pageContext = 'search';
97
+ this.restorationStateHandler = new RestorationStateHandler({
98
+ context: this.pageContext,
99
+ });
100
+ this.mobileBreakpoint = 600;
101
+ this.loggedIn = false;
102
+ this.modalManager = undefined;
103
+ /**
104
+ * If item management UI active
105
+ */
106
+ /**
107
+ * The current mode for item management UI:
108
+ * - 'initial': Initial mode activated through &manage=1 parameter
109
+ * - 'manual': Manual mode activated through user interaction eg. Manage|Remove items button
110
+ */
111
+ this.manageViewMode = '';
112
+ this.manageViewLabel = 'Select items to remove';
113
+ /** Whether to replace the default sort options with a slot for customization (default: false) */
114
+ this.enableSortOptionsSlot = false;
115
+ /** Whether to display a smart results carousel above the full results */
116
+ this.showSmartResults = false;
117
+ /**
118
+ * The maximum number of pages we will load when a privileged user clicks
119
+ * the "Manage" button on the search page. Limited to 15 pages.
120
+ */
121
+ this.maxPagesToManage = 15;
122
+ /**
123
+ * The results per page so we can paginate.
124
+ *
125
+ * This allows us to start in the middle of the search results and
126
+ * fetch data before or after the current page. If we don't have a key
127
+ * for the previous/next page, we'll fetch the next/previous page to populate it
128
+ */
129
+ this.dataSource = new CollectionBrowserDataSource(this, this.pageSize);
130
+ /**
131
+ * The page that the consumer wants to load.
132
+ */
133
+ this.initialPageNumber = 1;
134
+ /**
135
+ * This the the number of pages that we want to show.
136
+ *
137
+ * The data isn't necessarily loaded for all of the pages, but this lets us
138
+ * know how many cells we should render.
139
+ */
140
+ this.pagesToRender = this.initialPageNumber;
141
+ /**
142
+ * Whether the initial page fetch for a new query is currently in progress.
143
+ */
144
+ this.searchResultsLoading = false;
145
+ this.facetsLoading = false;
146
+ this.mobileView = false;
147
+ this.collapsibleFacetsVisible = false;
148
+ this.placeholderType = null;
149
+ /** Whether layout size analytics have been sent already. */
150
+ this.layoutSizeAnalyticsSent = false;
151
+ /**
152
+ * When we're animated scrolling to the page, we don't want to fetch
153
+ * all of the pages as it scrolls so this lets us know if we're scrolling
154
+ */
155
+ this.isScrollingToCell = false;
156
+ /**
157
+ * When page width resizes from desktop to mobile, set true to
158
+ * disable expand/collapse transition when loading.
159
+ */
160
+ this.isResizeToMobile = false;
161
+ /**
162
+ * Flag indicating that a new data source is currently being installed.
163
+ * During the install, any URL persistence operation should replace the current entry
164
+ * instead of creating a new one.
165
+ */
166
+ this.dataSourceInstallInProgress = false;
167
+ this.placeholderCellTemplate = html `<collection-browser-loading-tile></collection-browser-loading-tile>`;
168
+ /**
169
+ * Updates the height of the left column according to its position on the page.
170
+ * Arrow function ensures proper `this` binding.
171
+ */
172
+ this.updateLeftColumnHeight = () => {
173
+ var _a, _b, _c, _d, _e;
174
+ if (this.mobileView) {
175
+ (_b = (_a = this.leftColumn) === null || _a === void 0 ? void 0 : _a.style) === null || _b === void 0 ? void 0 : _b.removeProperty('height');
176
+ }
177
+ else {
178
+ const clientTop = (_c = this.leftColumn) === null || _c === void 0 ? void 0 : _c.getBoundingClientRect().top;
179
+ const columnHeight = window.innerHeight - (clientTop !== null && clientTop !== void 0 ? clientTop : 0);
180
+ const cssHeightValue = clientTop === 0
181
+ ? null
182
+ : // Subtract off the column's top padding so that it doesn't overflow
183
+ `calc(${columnHeight}px - var(--leftColumnPaddingTop, 2rem))`;
184
+ (_e = (_d = this.leftColumn) === null || _d === void 0 ? void 0 : _d.style) === null || _e === void 0 ? void 0 : _e.setProperty('height', cssHeightValue);
185
+ }
186
+ };
187
+ /**
188
+ * Toggles whether the fade-out is visible at the bottom of the facets.
189
+ * It should only be visible if the facets are not scrolled to the bottom.
190
+ * Arrow function ensures proper `this` binding.
191
+ */
192
+ this.updateFacetFadeOut = (entries) => {
193
+ var _a, _b;
194
+ const fadeElmt = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.getElementById('facets-bottom-fade');
195
+ fadeElmt === null || fadeElmt === void 0 ? void 0 : fadeElmt.classList.toggle('hidden', (_b = entries === null || entries === void 0 ? void 0 : entries[0]) === null || _b === void 0 ? void 0 : _b.isIntersecting);
196
+ };
197
+ // we only want to scroll on the very first query change
198
+ // so this keeps track of whether we've already set the initial query
199
+ this.initialQueryChangeHappened = false;
200
+ this.historyPopOccurred = false;
201
+ this.addController(this.dataSource);
202
+ }
203
+ tileModelAtCellIndex(index) {
204
+ const model = this.dataSource.getTileModelAt(index);
205
+ /**
206
+ * If we encounter a model we don't have yet and we're not in the middle of an
207
+ * automated scroll, fetch the page and just return undefined.
208
+ * The datasource will be updated once the page is loaded and the cell will be rendered.
209
+ *
210
+ * We disable it during the automated scroll since we don't want to fetch pages for intervening cells the
211
+ * user may never see.
212
+ */
213
+ if (!model && !this.isScrollingToCell && this.dataSource.queryInitialized) {
214
+ const pageNumber = Math.floor(index / this.pageSize) + 1;
215
+ this.dataSource.fetchPage(pageNumber);
216
+ }
217
+ return model;
218
+ }
219
+ // this is the total number of tiles we expect if
220
+ // the data returned is a full page worth
221
+ // this is useful for putting in placeholders for the expected number of tiles
222
+ get estimatedTileCount() {
223
+ return this.pagesToRender * this.pageSize;
224
+ }
225
+ /**
226
+ * Returns a promise resolving to a unique string that persists for the current browser session.
227
+ * Used in generating unique IDs for search requests, so that multiple requests coming from the
228
+ * same browser session can be identified.
229
+ */
230
+ async getSessionId() {
231
+ try {
232
+ const storedSessionId = sessionStorage === null || sessionStorage === void 0 ? void 0 : sessionStorage.getItem('cb-session');
233
+ if (storedSessionId) {
234
+ return storedSessionId;
235
+ }
236
+ // If we enter this method a second time while a first session ID is already being generated,
237
+ // ensure we produce the same ID from both calls instead of generating another one.
238
+ if (this.sessionIdGenPromise) {
239
+ return this.sessionIdGenPromise;
240
+ }
241
+ this.sessionIdGenPromise = sha1(Math.random().toString());
242
+ const newSessionId = await this.sessionIdGenPromise;
243
+ sessionStorage === null || sessionStorage === void 0 ? void 0 : sessionStorage.setItem('cb-session', newSessionId);
244
+ return newSessionId;
245
+ }
246
+ catch (_a) {
247
+ // Either we can't generate the hash or we're restricted from accessing sessionStorage
248
+ return '';
249
+ }
250
+ }
251
+ /**
252
+ * Go to the given page of results
253
+ *
254
+ * @param pageNumber
255
+ */
256
+ goToPage(pageNumber) {
257
+ this.initialPageNumber = pageNumber;
258
+ this.pagesToRender = pageNumber;
259
+ return this.scrollToPage(pageNumber);
260
+ }
261
+ /**
262
+ * Sets the state for whether the initial set of search results is loading in.
263
+ */
264
+ setSearchResultsLoading(loading) {
265
+ this.searchResultsLoading = loading;
266
+ }
267
+ /**
268
+ * Sets the state for whether facet data is loading in
269
+ */
270
+ setFacetsLoading(loading) {
271
+ this.facetsLoading = loading;
272
+ }
273
+ /**
274
+ * Sets the total number of results to be displayed for the current search
275
+ */
276
+ setTotalResultCount(totalResults) {
277
+ this.totalResults = totalResults;
278
+ }
279
+ /**
280
+ * Clears all selected/negated facets, date ranges, and letter filters.
281
+ *
282
+ * By default, the current sort field/direction are not cleared,
283
+ * but this can be overridden by setting the `sort` option to `true`.
284
+ *
285
+ * Similarly, it is possible to finely control what is cleared by
286
+ * setting any of the `facets`, `dateRange`, or `letterFilters` flags
287
+ * in the options object.
288
+ */
289
+ clearFilters({ facets = true, dateRange = true, letterFilters = true, sort = false, } = {}) {
290
+ // Don't bother clearing facets if none are checked, so that we don't
291
+ // trigger unnecessary update cycles.
292
+ if (facets && this.hasCheckedFacets) {
293
+ this.selectedFacets = getDefaultSelectedFacets();
294
+ }
295
+ if (dateRange) {
296
+ this.minSelectedDate = undefined;
297
+ this.maxSelectedDate = undefined;
298
+ }
299
+ if (letterFilters) {
300
+ this.selectedTitleFilter = null;
301
+ this.selectedCreatorFilter = null;
302
+ }
303
+ if (sort) {
304
+ this.sortDirection = null;
305
+ this.selectedSort = SortField.default;
306
+ }
307
+ }
308
+ /**
309
+ * Returns true if the current value of `this.selectedFacets` contains
310
+ * any facet buckets than have been selected or negated, or false otherwise.
311
+ */
312
+ get hasCheckedFacets() {
313
+ if (!this.selectedFacets)
314
+ return false;
315
+ for (const facetGroup of Object.values(this.selectedFacets)) {
316
+ for (const bucket of Object.values(facetGroup)) {
317
+ if (bucket.state !== 'none')
318
+ return true;
319
+ }
320
+ }
321
+ return false;
322
+ }
323
+ /**
324
+ * Returns true if there are any currently selected/negated facet buckets,
325
+ * any selected date range, or any selected letter filters. False otherwise.
326
+ *
327
+ * Ignores sorting options.
328
+ */
329
+ get hasActiveFilters() {
330
+ return !!(this.hasCheckedFacets ||
331
+ this.minSelectedDate ||
332
+ this.maxSelectedDate ||
333
+ this.selectedTitleFilter ||
334
+ this.selectedCreatorFilter);
335
+ }
336
+ willUpdate() {
337
+ this.setPlaceholderType();
338
+ }
339
+ render() {
336
340
  return html `
337
- ${this.showSmartFacetBar
341
+ ${this.showSmartFacetBar
338
342
  ? html ` <smart-facet-bar
339
343
  .query=${this.baseQuery}
340
344
  .aggregations=${this.dataSource.aggregations}
@@ -342,59 +346,59 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
342
346
  .collectionTitles=${this.dataSource.collectionTitles}
343
347
  .filterToggleActive=${this.facetPaneVisible}
344
348
  @facetsChanged=${this.facetsChanged}
345
- @filtersToggled=${() => {
346
- this.facetPaneVisible = !this.facetPaneVisible;
349
+ @filtersToggled=${() => {
350
+ this.facetPaneVisible = !this.facetPaneVisible;
347
351
  }}
348
- ></smart-facet-bar>`
352
+ ></smart-facet-bar>`
349
353
  : nothing}
350
354
 
351
355
  <div
352
356
  id="content-container"
353
357
  class=${this.mobileView ? 'mobile' : 'desktop'}
354
358
  >
355
- ${this.placeholderType
356
- ? this.emptyPlaceholderTemplate
359
+ ${this.placeholderType
360
+ ? this.emptyPlaceholderTemplate
357
361
  : this.collectionBrowserTemplate}
358
362
  </div>
359
- `;
360
- }
361
- /**
362
- * Determines what type of placeholder content should be shown instead of result tiles, if applicable.
363
- * The placeholders indicate states where we have no results to show, which could be the result of:
364
- * - No query is set (on the search page)
365
- * - No results were returned for the most recent search
366
- * - The collection being searched within has no viewable items
367
- * - An error occurred on the most recent search attempt
368
- */
369
- setPlaceholderType() {
370
- var _a;
371
- const hasQuery = !!((_a = this.baseQuery) === null || _a === void 0 ? void 0 : _a.trim());
372
- const isCollection = !!this.withinCollection;
373
- const isProfile = !!this.withinProfile;
374
- const noResults = !this.searchResultsLoading &&
375
- (this.dataSource.size === 0 || !this.searchService);
376
- this.placeholderType = null;
377
- if (this.suppressPlaceholders)
378
- return;
379
- if (!hasQuery && !isCollection && !isProfile) {
380
- this.placeholderType = 'empty-query';
381
- }
382
- else if (noResults) {
383
- // Within a collection, no query + no results means the collection simply has no viewable items.
384
- // Otherwise, we must have a user query that produced 0 results.
385
- this.placeholderType =
386
- !hasQuery && isCollection ? 'empty-collection' : 'no-results';
387
- }
388
- if (this.dataSource.queryErrorMessage) {
389
- this.placeholderType =
390
- !hasQuery && isCollection ? 'collection-error' : 'query-error';
391
- }
392
- }
393
- /**
394
- * Template for the placeholder content to show when no results are available.
395
- */
396
- get emptyPlaceholderTemplate() {
397
- var _a;
363
+ `;
364
+ }
365
+ /**
366
+ * Determines what type of placeholder content should be shown instead of result tiles, if applicable.
367
+ * The placeholders indicate states where we have no results to show, which could be the result of:
368
+ * - No query is set (on the search page)
369
+ * - No results were returned for the most recent search
370
+ * - The collection being searched within has no viewable items
371
+ * - An error occurred on the most recent search attempt
372
+ */
373
+ setPlaceholderType() {
374
+ var _a;
375
+ const hasQuery = !!((_a = this.baseQuery) === null || _a === void 0 ? void 0 : _a.trim());
376
+ const isCollection = !!this.withinCollection;
377
+ const isProfile = !!this.withinProfile;
378
+ const noResults = !this.searchResultsLoading &&
379
+ (this.dataSource.size === 0 || !this.searchService);
380
+ this.placeholderType = null;
381
+ if (this.suppressPlaceholders)
382
+ return;
383
+ if (!hasQuery && !isCollection && !isProfile) {
384
+ this.placeholderType = 'empty-query';
385
+ }
386
+ else if (noResults && this.manageViewMode !== 'initial') {
387
+ // Within a collection, no query + no results means the collection simply has no viewable items.
388
+ // Otherwise, we must have a user query that produced 0 results.
389
+ this.placeholderType =
390
+ !hasQuery && isCollection ? 'empty-collection' : 'no-results';
391
+ }
392
+ if (this.dataSource.queryErrorMessage) {
393
+ this.placeholderType =
394
+ !hasQuery && isCollection ? 'collection-error' : 'query-error';
395
+ }
396
+ }
397
+ /**
398
+ * Template for the placeholder content to show when no results are available.
399
+ */
400
+ get emptyPlaceholderTemplate() {
401
+ var _a;
398
402
  return html `
399
403
  <empty-placeholder
400
404
  .placeholderType=${this.placeholderType}
@@ -403,33 +407,33 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
403
407
  .detailMessage=${(_a = this.dataSource.queryErrorMessage) !== null && _a !== void 0 ? _a : ''}
404
408
  .baseNavigationUrl=${this.baseNavigationUrl}
405
409
  ></empty-placeholder>
406
- `;
407
- }
408
- /**
409
- * Top-level template for rendering the left (facets) and right (results) columns.
410
- */
411
- get collectionBrowserTemplate() {
410
+ `;
411
+ }
412
+ /**
413
+ * Top-level template for rendering the left (facets) and right (results) columns.
414
+ */
415
+ get collectionBrowserTemplate() {
412
416
  return html `
413
417
  <div id="left-column-scroll-sentinel"></div>
414
418
  ${this.leftColumnTemplate} ${this.rightColumnTemplate}
415
- `;
416
- }
417
- /**
418
- * Template for either the mobile or desktop version of the left column, depending
419
- * on current component state.
420
- */
421
- get leftColumnTemplate() {
422
- if (this.mobileView) {
423
- return this.mobileLeftColumnTemplate;
424
- }
425
- return this.desktopLeftColumnTemplate;
426
- }
427
- /**
428
- * Template for the mobile version of the "left column" (which in this case, appears
429
- * *above* the search results rather than beside them), for rendering the
430
- * accordion-style facets.
431
- */
432
- get mobileLeftColumnTemplate() {
419
+ `;
420
+ }
421
+ /**
422
+ * Template for either the mobile or desktop version of the left column, depending
423
+ * on current component state.
424
+ */
425
+ get leftColumnTemplate() {
426
+ if (this.mobileView) {
427
+ return this.mobileLeftColumnTemplate;
428
+ }
429
+ return this.desktopLeftColumnTemplate;
430
+ }
431
+ /**
432
+ * Template for the mobile version of the "left column" (which in this case, appears
433
+ * *above* the search results rather than beside them), for rendering the
434
+ * accordion-style facets.
435
+ */
436
+ get mobileLeftColumnTemplate() {
433
437
  return html `
434
438
  <div
435
439
  id="left-column"
@@ -438,12 +442,12 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
438
442
  ${this.facetTopViewSlot} ${this.resultsCountTemplate}
439
443
  <div id="facets-header-container">${this.mobileFacetsTemplate}</div>
440
444
  </div>
441
- `;
442
- }
443
- /**
444
- * Template for the desktop version of the left column, displaying the facets sidebar.
445
- */
446
- get desktopLeftColumnTemplate() {
445
+ `;
446
+ }
447
+ /**
448
+ * Template for the desktop version of the left column, displaying the facets sidebar.
449
+ */
450
+ get desktopLeftColumnTemplate() {
447
451
  return html `
448
452
  <div
449
453
  id="left-column"
@@ -461,29 +465,29 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
461
465
  </div>
462
466
  <div id="facets-bottom-fade"></div>
463
467
  </div>
464
- `;
465
- }
466
- /**
467
- * Slot which is placed at top of the facets area for user-profile page
468
- * - mainly used to render userlists
469
- */
470
- get facetTopViewSlot() {
468
+ `;
469
+ }
470
+ /**
471
+ * Slot which is placed at top of the facets area for user-profile page
472
+ * - mainly used to render userlists
473
+ */
474
+ get facetTopViewSlot() {
471
475
  return html `<div id="facet-top-view">
472
476
  <slot name="facet-top-slot"></slot>
473
- </div>`;
474
- }
475
- /**
476
- * Template for the "X Results" count at the top of the search results.
477
- * Changes to the "Searching..." label if the search results are still loading.
478
- */
479
- get resultsCountTemplate() {
480
- var _a;
481
- if (this.suppressResultCount)
482
- return nothing;
483
- const shouldShowSearching = this.searchResultsLoading || this.totalResults === undefined;
484
- const resultsCount = (_a = this.totalResults) === null || _a === void 0 ? void 0 : _a.toLocaleString();
485
- const resultsLabel = this.totalResults === 1 ? 'Result' : 'Results';
486
- // Added data-testid for Playwright testing
477
+ </div>`;
478
+ }
479
+ /**
480
+ * Template for the "X Results" count at the top of the search results.
481
+ * Changes to the "Searching..." label if the search results are still loading.
482
+ */
483
+ get resultsCountTemplate() {
484
+ var _a;
485
+ if (this.suppressResultCount)
486
+ return nothing;
487
+ const shouldShowSearching = this.searchResultsLoading || this.totalResults === undefined;
488
+ const resultsCount = (_a = this.totalResults) === null || _a === void 0 ? void 0 : _a.toLocaleString();
489
+ const resultsLabel = this.totalResults === 1 ? 'Result' : 'Results';
490
+ // Added data-testid for Playwright testing
487
491
  return html `
488
492
  <div id="results-total" data-testid="results-total">
489
493
  <span id="big-results-count">
@@ -493,46 +497,46 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
493
497
  ${shouldShowSearching ? nothing : resultsLabel}
494
498
  </span>
495
499
  </div>
496
- `;
497
- }
498
- /**
499
- * Template for the right column of the collection browser, where the result
500
- * tiles and sort/filter bar are shown.
501
- */
502
- get rightColumnTemplate() {
500
+ `;
501
+ }
502
+ /**
503
+ * Template for the right column of the collection browser, where the result
504
+ * tiles and sort/filter bar are shown.
505
+ */
506
+ get rightColumnTemplate() {
503
507
  return html `
504
508
  <div
505
509
  id="right-column"
506
510
  class="column ${this.showSmartResults ? 'smart-results-spacing' : ''}"
507
511
  >
508
- ${this.showSmartResults
509
- ? html `<slot name="smart-results"></slot>`
512
+ ${this.showSmartResults
513
+ ? html `<slot name="smart-results"></slot>`
510
514
  : nothing}
511
515
  <section id="results">
512
- ${this.showSmartResults
516
+ ${this.showSmartResults
513
517
  ? html `<h2 class="results-section-heading">
514
518
  ${msg('All results')}
515
- </h2>`
519
+ </h2>`
516
520
  : nothing}
517
521
  <div id="cb-top-view">
518
522
  <slot name="cb-top-slot"></slot>
519
523
  </div>
520
- ${this.isManageView
521
- ? this.manageBarTemplate
524
+ ${this.manageViewMode
525
+ ? this.manageBarTemplate
522
526
  : this.sortFilterBarTemplate}
523
527
  <slot name="cb-results"></slot>
524
- ${this.displayMode === `list-compact` && this.totalResults
525
- ? this.listHeaderTemplate
528
+ ${this.displayMode === `list-compact` && this.totalResults
529
+ ? this.listHeaderTemplate
526
530
  : nothing}
527
531
  ${this.suppressResultTiles ? nothing : this.infiniteScrollerTemplate}
528
532
  </section>
529
533
  </div>
530
- `;
531
- }
532
- /**
533
- * Template for the infinite scroller widget that contains the result tiles.
534
- */
535
- get infiniteScrollerTemplate() {
534
+ `;
535
+ }
536
+ /**
537
+ * Template for the infinite scroller widget that contains the result tiles.
538
+ */
539
+ get infiniteScrollerTemplate() {
536
540
  return html `<infinite-scroller
537
541
  class=${this.infiniteScrollerClasses}
538
542
  itemCount=${this.placeholderType ? 0 : nothing}
@@ -541,29 +545,29 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
541
545
  .placeholderCellTemplate=${this.placeholderCellTemplate}
542
546
  @scrollThresholdReached=${this.scrollThresholdReached}
543
547
  @visibleCellsChanged=${this.visibleCellsChanged}
544
- >${this.displayMode === 'grid'
545
- ? html `<slot name="result-last-tile" slot="result-last-tile"></slot>`
548
+ >${this.displayMode === 'grid'
549
+ ? html `<slot name="result-last-tile" slot="result-last-tile"></slot>`
546
550
  : nothing}
547
- </infinite-scroller>`;
548
- }
549
- /**
550
- * Produces a `classMap` indicating which classes the infinite scroller should have
551
- * given the current display mode & placeholder case.
552
- */
553
- get infiniteScrollerClasses() {
554
- var _a;
555
- return classMap({
556
- [(_a = this.displayMode) !== null && _a !== void 0 ? _a : '']: !!this.displayMode,
557
- hidden: !!this.placeholderType,
558
- });
559
- }
560
- /**
561
- * Template for the sort & filtering bar that appears atop the search results.
562
- */
563
- get sortFilterBarTemplate() {
564
- var _a;
565
- if (this.suppressSortBar)
566
- return nothing;
551
+ </infinite-scroller>`;
552
+ }
553
+ /**
554
+ * Produces a `classMap` indicating which classes the infinite scroller should have
555
+ * given the current display mode & placeholder case.
556
+ */
557
+ get infiniteScrollerClasses() {
558
+ var _a;
559
+ return classMap({
560
+ [(_a = this.displayMode) !== null && _a !== void 0 ? _a : '']: !!this.displayMode,
561
+ hidden: !!this.placeholderType,
562
+ });
563
+ }
564
+ /**
565
+ * Template for the sort & filtering bar that appears atop the search results.
566
+ */
567
+ get sortFilterBarTemplate() {
568
+ var _a;
569
+ if (this.suppressSortBar)
570
+ return nothing;
567
571
  return html `
568
572
  <sort-filter-bar
569
573
  .defaultSortField=${this.defaultSortField}
@@ -588,16 +592,16 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
588
592
  <slot name="sort-options" slot="sort-options"></slot>
589
593
  <slot name="sort-options-right" slot="sort-options-right"></slot>
590
594
  </sort-filter-bar>
591
- `;
592
- }
593
- /**
594
- * Template for the manage bar UI that appears atop the search results when we are
595
- * showing the management view. This generally replaces the sort bar when present.
596
- */
597
- get manageBarTemplate() {
598
- const manageViewModalMsg = this.profileElement === 'uploads'
599
- ? 'Note: it may take a few minutes for these items to stop appearing in your uploads list.'
600
- : nothing;
595
+ `;
596
+ }
597
+ /**
598
+ * Template for the manage bar UI that appears atop the search results when we are
599
+ * showing the management view. This generally replaces the sort bar when present.
600
+ */
601
+ get manageBarTemplate() {
602
+ const manageViewModalMsg = this.profileElement === 'uploads'
603
+ ? 'Note: it may take a few minutes for these items to stop appearing in your uploads list.'
604
+ : nothing;
601
605
  return html `
602
606
  <manage-bar
603
607
  .label=${this.manageViewLabel}
@@ -612,222 +616,222 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
612
616
  @manageItems=${this.handleManageItems}
613
617
  @selectAll=${() => this.dataSource.checkAllTiles()}
614
618
  @unselectAll=${() => this.dataSource.uncheckAllTiles()}
615
- @cancel=${() => {
616
- this.isManageView = false;
617
- this.dataSource.uncheckAllTiles();
618
- if (this.searchResultsLoading)
619
- this.dataSource.resetPages();
619
+ @cancel=${() => {
620
+ this.manageViewMode = '';
621
+ this.dataSource.uncheckAllTiles();
622
+ if (this.searchResultsLoading)
623
+ this.dataSource.resetPages();
620
624
  }}
621
625
  ></manage-bar>
622
- `;
623
- }
624
- /**
625
- * Handler for when the user requests to remove all checked items via the manage bar.
626
- * Emits an `itemRemovalRequested` event with all checked tile models.
627
- */
628
- handleRemoveItems() {
629
- this.dispatchEvent(new CustomEvent('itemRemovalRequested', {
630
- detail: {
631
- items: this.dataSource.checkedTileModels.map(model => (model === null || model === void 0 ? void 0 : model.identifier) ? model.identifier : ''),
632
- },
633
- }));
634
- }
635
- /**
636
- * Handler when user request to bulk edit from /search/ page
637
- */
638
- handleManageItems() {
639
- this.dispatchEvent(new CustomEvent('itemManagerRequested', {
640
- detail: {
641
- items: this.dataSource.checkedTileModels.map(model => (model === null || model === void 0 ? void 0 : model.identifier) ? model.identifier : ''),
642
- },
643
- }));
644
- }
645
- /**
646
- * Handler to show processing modal while removing item
647
- */
648
- showRemoveItemsProcessingModal() {
649
- var _a;
650
- (_a = this.manageBar) === null || _a === void 0 ? void 0 : _a.showRemoveItemsProcessingModal();
651
- }
652
- /**
653
- * Handler to show error modal when item removal failed
654
- */
655
- showRemoveItemsErrorModal() {
656
- var _a;
657
- (_a = this.manageBar) === null || _a === void 0 ? void 0 : _a.showRemoveItemsErrorModal();
658
- }
659
- /**
660
- * Removes all tile models that are currently checked & adjusts the paging
661
- * of the data source to account for any new gaps in the data.
662
- */
663
- removeCheckedTiles() {
664
- this.dataSource.removeCheckedTiles();
665
- }
666
- /**
667
- * Handler for when the user changes the selected sort option or direction.
668
- */
669
- userChangedSort(e) {
670
- var _a;
671
- const { selectedSort, sortDirection } = e.detail;
672
- this.selectedSort = selectedSort;
673
- this.sortDirection = sortDirection;
674
- if (((_a = this.currentPage) !== null && _a !== void 0 ? _a : 1) > 1) {
675
- this.goToPage(1);
676
- }
677
- this.currentPage = 1;
678
- }
679
- /**
680
- * Fires an analytics event for sorting changes.
681
- * @param prevSortDirection Which sort direction was previously set.
682
- */
683
- sendSortByAnalytics(prevSortDirection) {
684
- var _a;
685
- const directionCleared = prevSortDirection && !this.sortDirection;
686
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
687
- category: this.searchContext,
688
- action: analyticsActions.sortBy,
689
- label: `${this.selectedSort}${this.sortDirection || directionCleared ? `-${this.sortDirection}` : ''}`,
690
- });
691
- }
692
- /**
693
- * Handler for when the selected sort option is updated, whether by the user
694
- * themselves or programmatically.
695
- */
696
- selectedSortChanged() {
697
- // Lazy-load the alphabet counts for title/creator sort bar as needed
698
- this.dataSource.updatePrefixFiltersForCurrentSort();
699
- }
700
- /**
701
- * An object representing the current sort field & direction.
702
- */
703
- get sortParam() {
704
- var _a;
705
- const sortOption = SORT_OPTIONS[this.selectedSort];
706
- if (!(sortOption === null || sortOption === void 0 ? void 0 : sortOption.handledBySearchService)) {
707
- return null;
708
- }
709
- // If the sort option specified in the URL is unrecognized, we just use it as-is
710
- const urlSortParam = new URL(window.location.href).searchParams.get('sort');
711
- const sortField = (_a = sortOption.searchServiceKey) !== null && _a !== void 0 ? _a : urlSortParam === null || urlSortParam === void 0 ? void 0 : urlSortParam.replace(/^-/, '');
712
- // If the sort direction is still null at this point, then we assume ascending
713
- // (i.e., it was unrecognized and had no directional flag)
714
- if (!this.sortDirection)
715
- this.sortDirection = 'asc';
716
- if (!sortField)
717
- return null;
718
- return { field: sortField, direction: this.sortDirection };
719
- }
720
- /**
721
- * An object representing the default sort field & direction, if none are explicitly set.
722
- */
723
- get defaultSortParam() {
724
- var _a;
725
- const direction = (_a = this.defaultSortDirection) !== null && _a !== void 0 ? _a : 'asc';
726
- const field = SORT_OPTIONS[this.defaultSortField].searchServiceKey;
727
- if (!field)
728
- return null;
729
- return { field, direction };
730
- }
731
- /**
732
- * Handler for when the display mode option is changed (grid/list/compact-list views).
733
- */
734
- displayModeChanged(e) {
735
- var _a;
736
- this.displayMode = e.detail.displayMode;
737
- if (this.displayMode) {
738
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
739
- category: this.searchContext,
740
- action: analyticsActions.displayMode,
741
- label: this.displayMode,
742
- });
743
- }
744
- }
745
- /**
746
- * Returns a query clause identifying the currently selected title filter,
747
- * e.g., `firstTitle:X`.
748
- */
749
- get titleQuery() {
750
- return this.selectedTitleFilter
751
- ? `firstTitle:${this.selectedTitleFilter}`
752
- : undefined;
753
- }
754
- /**
755
- * Returns a query clause identifying the currently selected creator filter,
756
- * e.g., `firstCreator:X`.
757
- */
758
- get creatorQuery() {
759
- return this.selectedCreatorFilter
760
- ? `firstCreator:${this.selectedCreatorFilter}`
761
- : undefined;
762
- }
763
- /**
764
- * Send Analytics when sorting by title's first letter
765
- * labels: 'start-<ToLetter>' | 'clear-<FromLetter>' | '<FromLetter>-<ToLetter>'
766
- */
767
- sendFilterByTitleAnalytics(prevSelectedLetter) {
768
- var _a;
769
- if (!prevSelectedLetter && !this.selectedTitleFilter) {
770
- return;
771
- }
772
- const cleared = prevSelectedLetter && !this.selectedTitleFilter;
773
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
774
- category: this.searchContext,
775
- action: analyticsActions.filterByTitle,
776
- label: cleared
777
- ? `clear-${prevSelectedLetter}`
778
- : `${prevSelectedLetter || 'start'}-${this.selectedTitleFilter}`,
779
- });
780
- }
781
- /**
782
- * Send Analytics when filtering by creator's first letter
783
- * labels: 'start-<ToLetter>' | 'clear-<FromLetter>' | '<FromLetter>-<ToLetter>'
784
- */
785
- sendFilterByCreatorAnalytics(prevSelectedLetter) {
786
- var _a;
787
- if (!prevSelectedLetter && !this.selectedCreatorFilter) {
788
- return;
789
- }
790
- const cleared = prevSelectedLetter && !this.selectedCreatorFilter;
791
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
792
- category: this.searchContext,
793
- action: analyticsActions.filterByCreator,
794
- label: cleared
795
- ? `clear-${prevSelectedLetter}`
796
- : `${prevSelectedLetter || 'start'}-${this.selectedCreatorFilter}`,
797
- });
798
- }
799
- /**
800
- * Handler for changes to which letter is selected in the title alphabet bar.
801
- */
802
- titleLetterSelected(e) {
803
- this.selectedCreatorFilter = null;
804
- this.selectedTitleFilter = e.detail.selectedLetter;
805
- }
806
- /**
807
- * Handler for changes to which letter is selected in the creator alphabet bar.
808
- */
809
- creatorLetterSelected(e) {
810
- this.selectedTitleFilter = null;
811
- this.selectedCreatorFilter = e.detail.selectedLetter;
812
- }
813
- /**
814
- * The full template for how the facets should be structured in mobile view,
815
- * including the collapsible container (with header) and the facets themselves.
816
- */
817
- get mobileFacetsTemplate() {
818
- if (FACETLESS_PAGE_ELEMENTS.includes(this.profileElement))
819
- return nothing;
820
- const toggleFacetsVisible = (e) => {
821
- var _a;
822
- const target = e.target;
823
- this.isResizeToMobile = false;
824
- this.collapsibleFacetsVisible = target.open;
825
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
826
- category: this.searchContext,
827
- action: analyticsActions.mobileFacetsToggled,
828
- label: target.open ? 'open' : 'closed',
829
- });
830
- };
626
+ `;
627
+ }
628
+ /**
629
+ * Handler for when the user requests to remove all checked items via the manage bar.
630
+ * Emits an `itemRemovalRequested` event with all checked tile models.
631
+ */
632
+ handleRemoveItems() {
633
+ this.dispatchEvent(new CustomEvent('itemRemovalRequested', {
634
+ detail: {
635
+ items: this.dataSource.checkedTileModels.map(model => (model === null || model === void 0 ? void 0 : model.identifier) ? model.identifier : ''),
636
+ },
637
+ }));
638
+ }
639
+ /**
640
+ * Handler when user request to bulk edit from /search/ page
641
+ */
642
+ handleManageItems() {
643
+ this.dispatchEvent(new CustomEvent('itemManagerRequested', {
644
+ detail: {
645
+ items: this.dataSource.checkedTileModels.map(model => (model === null || model === void 0 ? void 0 : model.identifier) ? model.identifier : ''),
646
+ },
647
+ }));
648
+ }
649
+ /**
650
+ * Handler to show processing modal while removing item
651
+ */
652
+ showRemoveItemsProcessingModal() {
653
+ var _a;
654
+ (_a = this.manageBar) === null || _a === void 0 ? void 0 : _a.showRemoveItemsProcessingModal();
655
+ }
656
+ /**
657
+ * Handler to show error modal when item removal failed
658
+ */
659
+ showRemoveItemsErrorModal() {
660
+ var _a;
661
+ (_a = this.manageBar) === null || _a === void 0 ? void 0 : _a.showRemoveItemsErrorModal();
662
+ }
663
+ /**
664
+ * Removes all tile models that are currently checked & adjusts the paging
665
+ * of the data source to account for any new gaps in the data.
666
+ */
667
+ removeCheckedTiles() {
668
+ this.dataSource.removeCheckedTiles();
669
+ }
670
+ /**
671
+ * Handler for when the user changes the selected sort option or direction.
672
+ */
673
+ userChangedSort(e) {
674
+ var _a;
675
+ const { selectedSort, sortDirection } = e.detail;
676
+ this.selectedSort = selectedSort;
677
+ this.sortDirection = sortDirection;
678
+ if (((_a = this.currentPage) !== null && _a !== void 0 ? _a : 1) > 1) {
679
+ this.goToPage(1);
680
+ }
681
+ this.currentPage = 1;
682
+ }
683
+ /**
684
+ * Fires an analytics event for sorting changes.
685
+ * @param prevSortDirection Which sort direction was previously set.
686
+ */
687
+ sendSortByAnalytics(prevSortDirection) {
688
+ var _a;
689
+ const directionCleared = prevSortDirection && !this.sortDirection;
690
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
691
+ category: this.searchContext,
692
+ action: analyticsActions.sortBy,
693
+ label: `${this.selectedSort}${this.sortDirection || directionCleared ? `-${this.sortDirection}` : ''}`,
694
+ });
695
+ }
696
+ /**
697
+ * Handler for when the selected sort option is updated, whether by the user
698
+ * themselves or programmatically.
699
+ */
700
+ selectedSortChanged() {
701
+ // Lazy-load the alphabet counts for title/creator sort bar as needed
702
+ this.dataSource.updatePrefixFiltersForCurrentSort();
703
+ }
704
+ /**
705
+ * An object representing the current sort field & direction.
706
+ */
707
+ get sortParam() {
708
+ var _a;
709
+ const sortOption = SORT_OPTIONS[this.selectedSort];
710
+ if (!(sortOption === null || sortOption === void 0 ? void 0 : sortOption.handledBySearchService)) {
711
+ return null;
712
+ }
713
+ // If the sort option specified in the URL is unrecognized, we just use it as-is
714
+ const urlSortParam = new URL(window.location.href).searchParams.get('sort');
715
+ const sortField = (_a = sortOption.searchServiceKey) !== null && _a !== void 0 ? _a : urlSortParam === null || urlSortParam === void 0 ? void 0 : urlSortParam.replace(/^-/, '');
716
+ // If the sort direction is still null at this point, then we assume ascending
717
+ // (i.e., it was unrecognized and had no directional flag)
718
+ if (!this.sortDirection)
719
+ this.sortDirection = 'asc';
720
+ if (!sortField)
721
+ return null;
722
+ return { field: sortField, direction: this.sortDirection };
723
+ }
724
+ /**
725
+ * An object representing the default sort field & direction, if none are explicitly set.
726
+ */
727
+ get defaultSortParam() {
728
+ var _a;
729
+ const direction = (_a = this.defaultSortDirection) !== null && _a !== void 0 ? _a : 'asc';
730
+ const field = SORT_OPTIONS[this.defaultSortField].searchServiceKey;
731
+ if (!field)
732
+ return null;
733
+ return { field, direction };
734
+ }
735
+ /**
736
+ * Handler for when the display mode option is changed (grid/list/compact-list views).
737
+ */
738
+ displayModeChanged(e) {
739
+ var _a;
740
+ this.displayMode = e.detail.displayMode;
741
+ if (this.displayMode) {
742
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
743
+ category: this.searchContext,
744
+ action: analyticsActions.displayMode,
745
+ label: this.displayMode,
746
+ });
747
+ }
748
+ }
749
+ /**
750
+ * Returns a query clause identifying the currently selected title filter,
751
+ * e.g., `firstTitle:X`.
752
+ */
753
+ get titleQuery() {
754
+ return this.selectedTitleFilter
755
+ ? `firstTitle:${this.selectedTitleFilter}`
756
+ : undefined;
757
+ }
758
+ /**
759
+ * Returns a query clause identifying the currently selected creator filter,
760
+ * e.g., `firstCreator:X`.
761
+ */
762
+ get creatorQuery() {
763
+ return this.selectedCreatorFilter
764
+ ? `firstCreator:${this.selectedCreatorFilter}`
765
+ : undefined;
766
+ }
767
+ /**
768
+ * Send Analytics when sorting by title's first letter
769
+ * labels: 'start-<ToLetter>' | 'clear-<FromLetter>' | '<FromLetter>-<ToLetter>'
770
+ */
771
+ sendFilterByTitleAnalytics(prevSelectedLetter) {
772
+ var _a;
773
+ if (!prevSelectedLetter && !this.selectedTitleFilter) {
774
+ return;
775
+ }
776
+ const cleared = prevSelectedLetter && !this.selectedTitleFilter;
777
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
778
+ category: this.searchContext,
779
+ action: analyticsActions.filterByTitle,
780
+ label: cleared
781
+ ? `clear-${prevSelectedLetter}`
782
+ : `${prevSelectedLetter || 'start'}-${this.selectedTitleFilter}`,
783
+ });
784
+ }
785
+ /**
786
+ * Send Analytics when filtering by creator's first letter
787
+ * labels: 'start-<ToLetter>' | 'clear-<FromLetter>' | '<FromLetter>-<ToLetter>'
788
+ */
789
+ sendFilterByCreatorAnalytics(prevSelectedLetter) {
790
+ var _a;
791
+ if (!prevSelectedLetter && !this.selectedCreatorFilter) {
792
+ return;
793
+ }
794
+ const cleared = prevSelectedLetter && !this.selectedCreatorFilter;
795
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
796
+ category: this.searchContext,
797
+ action: analyticsActions.filterByCreator,
798
+ label: cleared
799
+ ? `clear-${prevSelectedLetter}`
800
+ : `${prevSelectedLetter || 'start'}-${this.selectedCreatorFilter}`,
801
+ });
802
+ }
803
+ /**
804
+ * Handler for changes to which letter is selected in the title alphabet bar.
805
+ */
806
+ titleLetterSelected(e) {
807
+ this.selectedCreatorFilter = null;
808
+ this.selectedTitleFilter = e.detail.selectedLetter;
809
+ }
810
+ /**
811
+ * Handler for changes to which letter is selected in the creator alphabet bar.
812
+ */
813
+ creatorLetterSelected(e) {
814
+ this.selectedTitleFilter = null;
815
+ this.selectedCreatorFilter = e.detail.selectedLetter;
816
+ }
817
+ /**
818
+ * The full template for how the facets should be structured in mobile view,
819
+ * including the collapsible container (with header) and the facets themselves.
820
+ */
821
+ get mobileFacetsTemplate() {
822
+ if (FACETLESS_PAGE_ELEMENTS.includes(this.profileElement))
823
+ return nothing;
824
+ const toggleFacetsVisible = (e) => {
825
+ var _a;
826
+ const target = e.target;
827
+ this.isResizeToMobile = false;
828
+ this.collapsibleFacetsVisible = target.open;
829
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
830
+ category: this.searchContext,
831
+ action: analyticsActions.mobileFacetsToggled,
832
+ label: target.open ? 'open' : 'closed',
833
+ });
834
+ };
831
835
  return html `
832
836
  <details id="mobile-filter-collapse" @toggle=${toggleFacetsVisible}>
833
837
  <summary>
@@ -837,21 +841,21 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
837
841
  </summary>
838
842
  ${this.facetsTemplate}
839
843
  </details>
840
- `;
841
- }
842
- /**
843
- * The template for the facets component alone, without any surrounding wrappers.
844
- */
845
- get facetsTemplate() {
846
- if (FACETLESS_PAGE_ELEMENTS.includes(this.profileElement))
847
- return nothing;
848
- if (this.facetLoadStrategy === 'off') {
844
+ `;
845
+ }
846
+ /**
847
+ * The template for the facets component alone, without any surrounding wrappers.
848
+ */
849
+ get facetsTemplate() {
850
+ if (FACETLESS_PAGE_ELEMENTS.includes(this.profileElement))
851
+ return nothing;
852
+ if (this.facetLoadStrategy === 'off') {
849
853
  return html `
850
854
  <p class="facets-message">
851
855
  ${msg('Facets are temporarily unavailable.')}
852
856
  </p>
853
- `;
854
- }
857
+ `;
858
+ }
855
859
  const facets = html `
856
860
  <collection-facets
857
861
  @facetsChanged=${this.facetsChanged}
@@ -865,7 +869,7 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
865
869
  .resizeObserver=${this.resizeObserver}
866
870
  .searchType=${this.searchType}
867
871
  .aggregations=${this.dataSource.aggregations}
868
- .fullYearsHistogramAggregation=${this.dataSource
872
+ .fullYearsHistogramAggregation=${this.dataSource
869
873
  .yearHistogramAggregation}
870
874
  .minSelectedDate=${this.minSelectedDate}
871
875
  .maxSelectedDate=${this.maxSelectedDate}
@@ -877,7 +881,7 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
877
881
  .contentWidth=${this.contentWidth}
878
882
  .query=${this.baseQuery}
879
883
  .filterMap=${this.dataSource.filterMap}
880
- .isManageView=${this.isManageView}
884
+ .isManageView=${!!this.manageViewMode}
881
885
  .modalManager=${this.modalManager}
882
886
  ?collapsableFacets=${this.mobileView}
883
887
  ?facetsLoading=${this.facetsLoading}
@@ -886,19 +890,19 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
886
890
  .analyticsHandler=${this.analyticsHandler}
887
891
  >
888
892
  </collection-facets>
889
- `;
890
- // If we are using one of the opt-in facet load strategies, we may need to wrap the
891
- // desktop view facets in a <details> widget so that patrons can opt into loading them.
892
- // In the `opt-in-or-login` case, we only do this if they are not logged in.
893
- const showDesktopOptInWidget = this.facetLoadStrategy === 'opt-in' ||
894
- (this.facetLoadStrategy === 'opt-in-or-login' && !this.loggedIn);
895
- if (showDesktopOptInWidget && !this.mobileView) {
893
+ `;
894
+ // If we are using one of the opt-in facet load strategies, we may need to wrap the
895
+ // desktop view facets in a <details> widget so that patrons can opt into loading them.
896
+ // In the `opt-in-or-login` case, we only do this if they are not logged in.
897
+ const showDesktopOptInWidget = this.facetLoadStrategy === 'opt-in' ||
898
+ (this.facetLoadStrategy === 'opt-in-or-login' && !this.loggedIn);
899
+ if (showDesktopOptInWidget && !this.mobileView) {
896
900
  return html `
897
901
  <details
898
902
  class="desktop-facets-dropdown"
899
- @toggle=${(e) => {
900
- const target = e.target;
901
- this.collapsibleFacetsVisible = target.open;
903
+ @toggle=${(e) => {
904
+ const target = e.target;
905
+ this.collapsibleFacetsVisible = target.open;
902
906
  }}
903
907
  >
904
908
  <summary>
@@ -907,40 +911,40 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
907
911
  </summary>
908
912
  ${facets}
909
913
  </button>
910
- `;
911
- }
912
- // Otherwise, just render the facets component bare
913
- return facets;
914
- }
915
- /**
916
- * The HTML template for the "Clear all filters" button, or `nothing` if no
917
- * filters are currently active.
918
- *
919
- * @param mobile Whether to style/shorten the button for mobile view
920
- */
921
- clearFiltersBtnTemplate(mobile) {
922
- if (!this.hasActiveFilters)
923
- return nothing;
924
- const buttonClasses = classMap({
925
- 'clear-filters-btn': true,
926
- mobile,
927
- });
928
- const buttonText = mobile ? 'Clear all' : 'Clear all filters';
914
+ `;
915
+ }
916
+ // Otherwise, just render the facets component bare
917
+ return facets;
918
+ }
919
+ /**
920
+ * The HTML template for the "Clear all filters" button, or `nothing` if no
921
+ * filters are currently active.
922
+ *
923
+ * @param mobile Whether to style/shorten the button for mobile view
924
+ */
925
+ clearFiltersBtnTemplate(mobile) {
926
+ if (!this.hasActiveFilters)
927
+ return nothing;
928
+ const buttonClasses = classMap({
929
+ 'clear-filters-btn': true,
930
+ mobile,
931
+ });
932
+ const buttonText = mobile ? 'Clear all' : 'Clear all filters';
929
933
  return html `
930
934
  <div class="clear-filters-btn-row">
931
- ${mobile
932
- ? html `<span class="clear-filters-btn-separator">&nbsp;</span>`
935
+ ${mobile
936
+ ? html `<span class="clear-filters-btn-separator">&nbsp;</span>`
933
937
  : nothing}
934
938
  <button class=${buttonClasses} @click=${this.clearFilters}>
935
939
  ${buttonText}
936
940
  </button>
937
941
  </div>
938
- `;
939
- }
940
- /**
941
- * Template for the table header content that appears atop the compact list view.
942
- */
943
- get listHeaderTemplate() {
942
+ `;
943
+ }
944
+ /**
945
+ * Template for the table header content that appears atop the compact list view.
946
+ */
947
+ get listHeaderTemplate() {
944
948
  return html `
945
949
  <div id="list-header">
946
950
  <tile-dispatcher
@@ -953,711 +957,714 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
953
957
  >
954
958
  </tile-dispatcher>
955
959
  </div>
956
- `;
957
- }
958
- /**
959
- * Handler for when the date picker's date range is changed.
960
- */
961
- histogramDateRangeUpdated(e) {
962
- var _a;
963
- const { minDate, maxDate } = e.detail;
964
- [this.minSelectedDate, this.maxSelectedDate] = [minDate, maxDate];
965
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
966
- category: this.searchContext,
967
- action: analyticsActions.histogramChanged,
968
- label: this.dateRangeQueryClause,
969
- });
970
- }
971
- /**
972
- * The Lucene query corresponding to the current date range.
973
- */
974
- get dateRangeQueryClause() {
975
- if (!this.minSelectedDate || !this.maxSelectedDate) {
976
- return undefined;
977
- }
978
- return `year:[${this.minSelectedDate} TO ${this.maxSelectedDate}]`;
979
- }
980
- /**
981
- * Emits an event indicating a change in whether the manage mode is shown.
982
- */
983
- emitManageModeChangedEvent() {
984
- this.dispatchEvent(new CustomEvent('manageModeChanged', {
985
- detail: this.isManageView,
986
- }));
987
- }
988
- /**
989
- * Installs a new data source component and associated query state parameters into
990
- * this component, causing it to efficiently update its views to represent the
991
- * newly-provided data. In this way, one can reuse a single instance of
992
- * <collection-browser> to handle multiple different sets of search results on
993
- * a single page, each set of results being loaded & updated by its own data
994
- * source.
995
- *
996
- * @param dataSource The data source component containing (or prepared to fetch)
997
- * the tile data to be displayed.
998
- * @param queryState The new query-related state that this component should
999
- * represent, such as the search query, sort option, and any filters applied.
1000
- */
1001
- async installDataSourceAndQueryState(dataSource, queryState) {
1002
- var _a, _b;
1003
- log('Installing data source & query state in CB:', dataSource, queryState);
1004
- if (this.dataSource)
1005
- this.removeController(this.dataSource);
1006
- this.dataSource = dataSource;
1007
- this.addController(this.dataSource);
1008
- this.baseQuery = queryState.baseQuery;
1009
- this.profileElement = queryState.profileElement;
1010
- this.searchType = queryState.searchType;
1011
- this.selectedFacets =
1012
- (_a = queryState.selectedFacets) !== null && _a !== void 0 ? _a : getDefaultSelectedFacets();
1013
- this.minSelectedDate = queryState.minSelectedDate;
1014
- this.maxSelectedDate = queryState.maxSelectedDate;
1015
- this.selectedSort = (_b = queryState.selectedSort) !== null && _b !== void 0 ? _b : SortField.default;
1016
- this.sortDirection = queryState.sortDirection;
1017
- this.selectedTitleFilter = queryState.selectedTitleFilter;
1018
- this.selectedCreatorFilter = queryState.selectedCreatorFilter;
1019
- // We set this flag during the update to prevent the URL state persistence
1020
- // from creating an unwanted extra history entry.
1021
- this.dataSourceInstallInProgress = true;
1022
- this.requestUpdate();
1023
- await this.updateComplete;
1024
- this.dataSourceInstallInProgress = false;
1025
- if (!this.searchResultsLoading) {
1026
- this.setTotalResultCount(this.dataSource.totalResults);
1027
- this.setTileCount(this.dataSource.size);
1028
- }
1029
- this.refreshVisibleResults();
1030
- }
1031
- firstUpdated() {
1032
- this.restoreState();
1033
- this.setInitialSize();
1034
- }
1035
- /**
1036
- * Determines the initial size of the content container and whether or not
1037
- * the mobile layout should be used.
1038
- */
1039
- setInitialSize() {
1040
- this.contentWidth = this.contentContainer.getBoundingClientRect().width;
1041
- this.mobileView =
1042
- this.contentWidth > 0 && this.contentWidth < this.mobileBreakpoint;
1043
- this.sendLayoutSizeAnalytics();
1044
- }
1045
- /**
1046
- * Fires an analytics event indicating which type of layout was rendered:
1047
- * mobile or desktop.
1048
- */
1049
- sendLayoutSizeAnalytics() {
1050
- if (this.analyticsHandler) {
1051
- this.layoutSizeAnalyticsSent = true;
1052
- this.analyticsHandler.sendEvent({
1053
- category: this.searchContext,
1054
- action: this.mobileView
1055
- ? analyticsActions.loadMobileView
1056
- : analyticsActions.loadDesktopView,
1057
- });
1058
- }
1059
- }
1060
- updated(changed) {
1061
- var _a, _b, _c;
1062
- if (changed.has('placeholderType') && this.placeholderType === null) {
1063
- if (!this.leftColIntersectionObserver) {
1064
- this.setupLeftColumnScrollListeners();
1065
- }
1066
- if (!this.facetsIntersectionObserver) {
1067
- this.setupFacetsScrollListeners();
1068
- }
1069
- this.updateLeftColumnHeight();
1070
- }
1071
- if (changed.has('analyticsHandler') && !this.layoutSizeAnalyticsSent) {
1072
- this.sendLayoutSizeAnalytics();
1073
- }
1074
- if (changed.has('displayMode') ||
1075
- changed.has('baseNavigationUrl') ||
1076
- changed.has('baseImageUrl') ||
1077
- changed.has('loggedIn')) {
1078
- (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.reload();
1079
- }
1080
- if (changed.has('baseQuery') ||
1081
- changed.has('searchType') ||
1082
- changed.has('withinCollection')) {
1083
- // Unless this query/search type update is from the initial page load or the
1084
- // result of hitting the back button,
1085
- // we need to clear any existing filters since they may no longer be valid for
1086
- // the new set of search results.
1087
- if (!this.historyPopOccurred && this.initialQueryChangeHappened) {
1088
- // Ordinarily, we leave the sort param unchanged between searches.
1089
- // However, if we are changing the target collection itself, we want the sort cleared too,
1090
- // since different collections may have different sorting options available.
1091
- const shouldClearSort = changed.has('withinCollection') &&
1092
- !changed.has('selectedSort') &&
1093
- !changed.has('sortDirection');
1094
- // Otherwise, only clear filters that haven't been simultaneously applied in this update
1095
- this.clearFilters({
1096
- sort: shouldClearSort,
1097
- facets: !changed.has('selectedFacets'),
1098
- dateRange: !(changed.has('minSelectedDate') || changed.has('maxSelectedDate')),
1099
- letterFilters: !(changed.has('selectedTitleFilter') ||
1100
- changed.has('selectedCreatorFilter')),
1101
- });
1102
- }
1103
- }
1104
- if (changed.has('profileElement')) {
1105
- this.applyDefaultProfileSort();
1106
- }
1107
- if (changed.has('baseQuery')) {
1108
- this.emitBaseQueryChanged();
1109
- }
1110
- if (changed.has('searchType')) {
1111
- this.emitSearchTypeChanged();
1112
- }
1113
- if (changed.has('currentPage') || changed.has('displayMode')) {
1114
- this.persistState();
1115
- }
1116
- if (changed.has('baseQuery') ||
1117
- changed.has('minSelectedDate') ||
1118
- changed.has('maxSelectedDate') ||
1119
- changed.has('selectedFacets') ||
1120
- changed.has('searchService') ||
1121
- changed.has('withinCollection') ||
1122
- changed.has('withinProfile') ||
1123
- changed.has('profileElement')) {
1124
- this.dataSource.refreshLetterCounts();
1125
- }
1126
- if (changed.has('selectedSort') || changed.has('sortDirection')) {
1127
- const prevSortDirection = changed.get('sortDirection');
1128
- this.sendSortByAnalytics(prevSortDirection);
1129
- this.selectedSortChanged();
1130
- }
1131
- if (changed.has('selectedTitleFilter')) {
1132
- this.sendFilterByTitleAnalytics(changed.get('selectedTitleFilter'));
1133
- }
1134
- if (changed.has('selectedCreatorFilter')) {
1135
- this.sendFilterByCreatorAnalytics(changed.get('selectedCreatorFilter'));
1136
- }
1137
- this.updateFacetReadiness();
1138
- if (changed.has('baseQuery') ||
1139
- changed.has('searchType') ||
1140
- changed.has('selectedTitleFilter') ||
1141
- changed.has('selectedCreatorFilter') ||
1142
- changed.has('minSelectedDate') ||
1143
- changed.has('maxSelectedDate') ||
1144
- changed.has('selectedSort') ||
1145
- changed.has('sortDirection') ||
1146
- changed.has('selectedFacets') ||
1147
- changed.has('searchService') ||
1148
- changed.has('withinCollection') ||
1149
- changed.has('withinProfile') ||
1150
- changed.has('profileElement')) {
1151
- this.handleQueryChange();
1152
- }
1153
- if (changed.has('searchResultsLoading')) {
1154
- this.emitSearchResultsLoadingChanged();
1155
- }
1156
- if (changed.has('facetsLoading') &&
1157
- this.facetsLoading &&
1158
- this.collectionFacets) {
1159
- this.collectionFacets.moreLinksVisible =
1160
- this.searchType !== SearchType.FULLTEXT;
1161
- }
1162
- if (changed.has('pagesToRender')) {
1163
- if (!this.dataSource.endOfDataReached && this.infiniteScroller) {
1164
- this.infiniteScroller.itemCount = this.estimatedTileCount;
1165
- }
1166
- }
1167
- if (changed.has('isManageView')) {
1168
- if (this.isManageView) {
1169
- this.displayMode = 'grid';
1170
- this.fetchManagableSearchResults();
1171
- }
1172
- else if (this.pageContext === 'search')
1173
- (_b = this.infiniteScroller) === null || _b === void 0 ? void 0 : _b.reload();
1174
- (_c = this.infiniteScroller) === null || _c === void 0 ? void 0 : _c.refreshAllVisibleCells();
1175
- this.emitManageModeChangedEvent();
1176
- }
1177
- if (changed.has('resizeObserver')) {
1178
- const oldObserver = changed.get('resizeObserver');
1179
- if (oldObserver)
1180
- this.disconnectResizeObserver(oldObserver);
1181
- this.setupResizeObserver();
1182
- }
1183
- this.ensureAvailableTilesDisplayed();
1184
- }
1185
- connectedCallback() {
1186
- var _a;
1187
- (_a = super.connectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
1188
- this.setupStateRestorationObserver();
1189
- this.setupResizeObserver();
1190
- }
1191
- disconnectedCallback() {
1192
- var _a, _b;
1193
- if (this.resizeObserver) {
1194
- this.disconnectResizeObserver(this.resizeObserver);
1195
- }
1196
- if (this.boundNavigationHandler) {
1197
- window.removeEventListener('popstate', this.boundNavigationHandler);
1198
- }
1199
- (_a = this.leftColIntersectionObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
1200
- (_b = this.facetsIntersectionObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
1201
- window.removeEventListener('resize', this.updateLeftColumnHeight);
1202
- }
1203
- handleResize(entry) {
1204
- const previousView = this.mobileView;
1205
- if (entry.target === this.contentContainer) {
1206
- this.contentWidth = entry.contentRect.width;
1207
- this.mobileView =
1208
- this.contentWidth > 0 && this.contentWidth < this.mobileBreakpoint;
1209
- // If changing from desktop to mobile disable transition
1210
- if (this.mobileView && !previousView) {
1211
- this.isResizeToMobile = true;
1212
- }
1213
- }
1214
- // Ensure the facet sidebar remains sized correctly
1215
- this.updateLeftColumnHeight();
1216
- }
1217
- /**
1218
- * Ensures that if we have new results from the data source that are not yet
1219
- * displayed in the infinite scroller, that they are immediately reflected
1220
- * in the tile count.
1221
- */
1222
- ensureAvailableTilesDisplayed() {
1223
- if (this.infiniteScroller &&
1224
- this.infiniteScroller.itemCount < this.dataSource.size) {
1225
- this.setTileCount(this.dataSource.endOfDataReached
1226
- ? this.dataSource.size
1227
- : this.estimatedTileCount);
1228
- }
1229
- }
1230
- /**
1231
- * Updates the data source with the current state of facet readiness for loading,
1232
- * so that they will begin to load in at the appropriate time according to the
1233
- * current facet loading strategy.
1234
- */
1235
- updateFacetReadiness() {
1236
- // There are two ways to opt into facet production:
1237
- // (1) have the facets dropdown open, or
1238
- // (2) if using the `opt-in-or-login` strategy, be logged into an account
1239
- const optedIn = this.collapsibleFacetsVisible ||
1240
- (this.facetLoadStrategy === 'opt-in-or-login' && this.loggedIn);
1241
- // In desktop view, we are always ready to load facets *unless* we are using one of the
1242
- // `opt-in` strategies and have not opted in (whether by login or UI interaction).
1243
- const usingOptInStrategy = ['opt-in', 'opt-in-or-login'].includes(this.facetLoadStrategy);
1244
- const desktopFacetsReady = !this.mobileView && (!usingOptInStrategy || optedIn);
1245
- // In the mobile view, facets are considered ready provided we have opted in (whether by
1246
- // login or UI interaction).
1247
- const mobileFacetsReady = this.mobileView && optedIn;
1248
- this.dataSource.handleFacetReadinessChange(desktopFacetsReady || mobileFacetsReady);
1249
- }
1250
- /**
1251
- * Sets up listeners for events that may require updating the left column height.
1252
- */
1253
- setupLeftColumnScrollListeners() {
1254
- var _a;
1255
- // We observe intersections between the left column's scroll sentinel and
1256
- // the viewport, so that we can ensure the left column is always sized to
1257
- // match the _available_ viewport height. This should generally be more
1258
- // performant than listening to scroll events on the page or column.
1259
- const leftColumnSentinel = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#left-column-scroll-sentinel');
1260
- if (leftColumnSentinel) {
1261
- this.leftColIntersectionObserver = new IntersectionObserver(this.updateLeftColumnHeight, {
1262
- threshold: [...Array(201).keys()].map(n => n / 200), // Threshold every 0.5%
1263
- });
1264
- this.leftColIntersectionObserver.observe(leftColumnSentinel);
1265
- }
1266
- // We also listen for window resize events, as they are not always captured
1267
- // by the resize observer and can affect the desired height of the left column.
1268
- window.addEventListener('resize', this.updateLeftColumnHeight);
1269
- }
1270
- /**
1271
- * Sets up listeners to control whether the facet sidebar shows its bottom fade-out.
1272
- * Note this uses a separate IntersectionObserver from the left column, because we
1273
- * don't need granular intersection thresholds for this.
1274
- */
1275
- setupFacetsScrollListeners() {
1276
- var _a;
1277
- const facetsSentinel = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#facets-scroll-sentinel');
1278
- if (facetsSentinel) {
1279
- this.facetsIntersectionObserver = new IntersectionObserver(this.updateFacetFadeOut);
1280
- this.facetsIntersectionObserver.observe(facetsSentinel);
1281
- }
1282
- }
1283
- /**
1284
- * Emits a `baseQueryChanged` event indicating an update to the search query.
1285
- */
1286
- emitBaseQueryChanged() {
1287
- this.dispatchEvent(new CustomEvent('baseQueryChanged', {
1288
- detail: {
1289
- baseQuery: this.baseQuery,
1290
- },
1291
- }));
1292
- }
1293
- /**
1294
- * Emits a `searchTypeChanged` event indicating an update to the search type
1295
- * (e.g., metadata vs. full-text).
1296
- */
1297
- emitSearchTypeChanged() {
1298
- this.dispatchEvent(new CustomEvent('searchTypeChanged', {
1299
- detail: this.searchType,
1300
- }));
1301
- }
1302
- /**
1303
- * Emits a `queryStateChanged` event indicating that one or more of this component's
1304
- * properties have changed in a way that could affect the set of search results.
1305
- */
1306
- emitQueryStateChanged() {
1307
- this.dispatchEvent(new CustomEvent('queryStateChanged', {
1308
- detail: {
1309
- baseQuery: this.baseQuery,
1310
- withinCollection: this.withinCollection,
1311
- withinProfile: this.withinProfile,
1312
- profileElement: this.profileElement,
1313
- searchType: this.searchType,
1314
- selectedFacets: this.selectedFacets,
1315
- minSelectedDate: this.minSelectedDate,
1316
- maxSelectedDate: this.maxSelectedDate,
1317
- selectedSort: this.selectedSort,
1318
- sortDirection: this.sortDirection,
1319
- selectedTitleFilter: this.selectedTitleFilter,
1320
- selectedCreatorFilter: this.selectedCreatorFilter,
1321
- },
1322
- }));
1323
- }
1324
- /**
1325
- * Emits an `emptyResults` event indicating that we have received an empty result set
1326
- * for the most recent query.
1327
- */
1328
- emitEmptyResults() {
1329
- this.dispatchEvent(new Event('emptyResults'));
1330
- }
1331
- disconnectResizeObserver(resizeObserver) {
1332
- resizeObserver.removeObserver({
1333
- target: this.contentContainer,
1334
- handler: this,
1335
- });
1336
- }
1337
- setupResizeObserver() {
1338
- if (!this.resizeObserver || !this.contentContainer)
1339
- return;
1340
- this.resizeObserver.addObserver({
1341
- target: this.contentContainer,
1342
- handler: this,
1343
- });
1344
- }
1345
- /**
1346
- * When the visible cells change from the infinite scroller, we want to emit
1347
- * which page is currently visible so the consumer can update its UI or the URL
1348
- *
1349
- * @param e
1350
- * @returns
1351
- */
1352
- visibleCellsChanged(e) {
1353
- if (this.isScrollingToCell)
1354
- return;
1355
- const { visibleCellIndices } = e.detail;
1356
- if (visibleCellIndices.length === 0)
1357
- return;
1358
- // For page determination, do not count more than a single page of visible cells,
1359
- // since otherwise patrons using very tall screens will be treated as one page
1360
- // further than they actually are.
1361
- const lastIndexWithinCurrentPage = Math.min(this.pageSize, visibleCellIndices.length) - 1;
1362
- const lastVisibleCellIndex = visibleCellIndices[lastIndexWithinCurrentPage];
1363
- const lastVisibleCellPage = Math.floor(lastVisibleCellIndex / this.pageSize) + 1;
1364
- if (this.currentPage !== lastVisibleCellPage) {
1365
- this.currentPage = lastVisibleCellPage;
1366
- }
1367
- const event = new CustomEvent('visiblePageChanged', {
1368
- detail: {
1369
- pageNumber: lastVisibleCellPage,
1370
- },
1371
- });
1372
- this.dispatchEvent(event);
1373
- }
1374
- /**
1375
- * A Promise which, after each query change, resolves once the fetches for the initial
1376
- * search have completed. Waits for *both* the hits and aggregations fetches to finish.
1377
- *
1378
- * Ensure you await this component's `updateComplete` promise before awaiting this
1379
- * one, to ensure you do not await an obsolete promise from the previous update.
1380
- */
1381
- get initialSearchComplete() {
1382
- return this.dataSource.initialSearchComplete;
1383
- }
1384
- /**
1385
- * Handler for whenever the component's properties change in a way that may require
1386
- * fetching new results.
1387
- */
1388
- async handleQueryChange() {
1389
- var _a;
1390
- // only reset if the query has actually changed
1391
- if (!this.searchService ||
1392
- this.dataSource.pageFetchQueryKey === this.previousQueryKey) {
1393
- return;
1394
- }
1395
- // If the new state prevents us from updating the search results, don't reset
1396
- if (this.baseQuery && !this.dataSource.canPerformSearch) {
1397
- return;
1398
- }
1399
- this.previousQueryKey = this.dataSource.pageFetchQueryKey;
1400
- this.totalResults = undefined;
1401
- this.pagesToRender =
1402
- this.initialPageNumber === 1
1403
- ? 2 // First two pages are batched into one request when starting from page 1
1404
- : this.initialPageNumber;
1405
- // Reset the infinite scroller's item count, so that it
1406
- // shows tile placeholders until the new query's results load in
1407
- if (this.infiniteScroller) {
1408
- this.infiniteScroller.itemCount = this.estimatedTileCount;
1409
- this.infiniteScroller.reload();
1410
- }
1411
- if (this.withinCollection && ((_a = this.baseQuery) === null || _a === void 0 ? void 0 : _a.trim())) {
1412
- this.defaultSortField = SortField.relevance;
1413
- this.defaultSortDirection = null;
1414
- }
1415
- if (!this.initialQueryChangeHappened && this.initialPageNumber > 1) {
1416
- this.scrollToPage(this.initialPageNumber);
1417
- }
1418
- this.initialQueryChangeHappened = true;
1419
- // if the query changed as part of a window.history pop event, we don't want to
1420
- // persist the state because it overwrites the forward history
1421
- if (!this.historyPopOccurred) {
1422
- this.persistState();
1423
- }
1424
- this.historyPopOccurred = false;
1425
- }
1426
- setupStateRestorationObserver() {
1427
- if (!this.boundNavigationHandler) {
1428
- this.boundNavigationHandler = this.historyNavigationHandler.bind(this);
1429
- }
1430
- // when the user navigates back, we want to update the UI to match the URL
1431
- window.addEventListener('popstate', this.boundNavigationHandler);
1432
- }
1433
- historyNavigationHandler() {
1434
- this.historyPopOccurred = true;
1435
- this.restoreState();
1436
- }
1437
- restoreState() {
1438
- var _a, _b, _c, _d, _e;
1439
- const restorationState = this.restorationStateHandler.getRestorationState();
1440
- this.displayMode = restorationState.displayMode;
1441
- if (restorationState.searchType != null)
1442
- this.searchType = restorationState.searchType;
1443
- this.selectedSort = (_a = restorationState.selectedSort) !== null && _a !== void 0 ? _a : SortField.default;
1444
- this.sortDirection = (_b = restorationState.sortDirection) !== null && _b !== void 0 ? _b : null;
1445
- this.selectedTitleFilter = (_c = restorationState.selectedTitleFilter) !== null && _c !== void 0 ? _c : null;
1446
- this.selectedCreatorFilter = (_d = restorationState.selectedCreatorFilter) !== null && _d !== void 0 ? _d : null;
1447
- this.selectedFacets = restorationState.selectedFacets;
1448
- if (!this.suppressURLQuery)
1449
- this.baseQuery = restorationState.baseQuery;
1450
- this.currentPage = (_e = restorationState.currentPage) !== null && _e !== void 0 ? _e : 1;
1451
- this.minSelectedDate = restorationState.minSelectedDate;
1452
- this.maxSelectedDate = restorationState.maxSelectedDate;
1453
- if (this.currentPage > 1) {
1454
- this.goToPage(this.currentPage);
1455
- }
1456
- }
1457
- persistState() {
1458
- var _a, _b, _c, _d;
1459
- const restorationState = {
1460
- displayMode: this.displayMode,
1461
- searchType: this.searchType,
1462
- selectedSort: this.selectedSort,
1463
- sortDirection: (_a = this.sortDirection) !== null && _a !== void 0 ? _a : undefined,
1464
- selectedFacets: (_b = this.selectedFacets) !== null && _b !== void 0 ? _b : getDefaultSelectedFacets(),
1465
- baseQuery: this.suppressURLQuery ? undefined : this.baseQuery,
1466
- currentPage: this.currentPage,
1467
- titleQuery: this.titleQuery,
1468
- creatorQuery: this.creatorQuery,
1469
- minSelectedDate: this.minSelectedDate,
1470
- maxSelectedDate: this.maxSelectedDate,
1471
- selectedTitleFilter: (_c = this.selectedTitleFilter) !== null && _c !== void 0 ? _c : undefined,
1472
- selectedCreatorFilter: (_d = this.selectedCreatorFilter) !== null && _d !== void 0 ? _d : undefined,
1473
- };
1474
- this.restorationStateHandler.persistState(restorationState, this.dataSourceInstallInProgress);
1475
- }
1476
- /**
1477
- * Emits a `searchResultsLoadingChanged` event indicating that our loading state has
1478
- * changed (either we have started loading new results, or we have finished loading them).
1479
- */
1480
- emitSearchResultsLoadingChanged() {
1481
- this.dispatchEvent(new CustomEvent('searchResultsLoadingChanged', {
1482
- detail: {
1483
- loading: this.searchResultsLoading,
1484
- },
1485
- }));
1486
- }
1487
- /**
1488
- * Handler for when the set of selected facets changes.
1489
- */
1490
- facetsChanged(e) {
1491
- this.selectedFacets = e.detail;
1492
- }
1493
- /**
1494
- * Handler for when any facet is selected/unselected/hidden/unhidden.
1495
- * Fires analytics indicating the type of facet event that took place.
1496
- */
1497
- facetClickHandler({ detail: { facetType, bucket, negative }, }) {
1498
- var _a;
1499
- let action;
1500
- if (negative) {
1501
- action =
1502
- bucket.state !== 'none'
1503
- ? analyticsActions.facetNegativeSelected
1504
- : analyticsActions.facetNegativeDeselected;
1505
- }
1506
- else {
1507
- action =
1508
- bucket.state !== 'none'
1509
- ? analyticsActions.facetSelected
1510
- : analyticsActions.facetDeselected;
1511
- }
1512
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
1513
- category: this.searchContext,
1514
- action,
1515
- label: facetType,
1516
- });
1517
- }
1518
- scrollToPage(pageNumber) {
1519
- return new Promise(resolve => {
1520
- const cellIndexToScrollTo = this.pageSize * (pageNumber - 1);
1521
- // without this setTimeout, Safari just pauses until the `fetchPage` is complete
1522
- // then scrolls to the cell
1523
- setTimeout(() => {
1524
- var _a;
1525
- this.isScrollingToCell = true;
1526
- (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.scrollToCell(cellIndexToScrollTo, true);
1527
- // This timeout is to give the scroll animation time to finish
1528
- // then updating the infinite scroller once we're done scrolling
1529
- // There's no scroll animation completion callback so we're
1530
- // giving it 0.5s to finish.
1531
- setTimeout(() => {
1532
- var _a;
1533
- this.isScrollingToCell = false;
1534
- (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.refreshAllVisibleCells();
1535
- resolve();
1536
- }, 500);
1537
- }, 0);
1538
- });
1539
- }
1540
- /**
1541
- * Whether sorting by relevance makes sense for the current state.
1542
- * Currently equivalent to having a non-empty query.
1543
- */
1544
- get isRelevanceSortAvailable() {
1545
- var _a;
1546
- return !!((_a = this.baseQuery) === null || _a === void 0 ? void 0 : _a.trim());
1547
- }
1548
- /**
1549
- * Sets the total number of tiles displayed in the infinite scroller.
1550
- */
1551
- setTileCount(count) {
1552
- if (this.infiniteScroller) {
1553
- this.infiniteScroller.itemCount = count;
1554
- }
1555
- }
1556
- /**
1557
- * Applies any default sort option for the current collection, by checking
1558
- * for one in the collection's metadata. If none is found, defaults to sorting
1559
- * descending by:
1560
- * - Date Favorited for fav-* collections
1561
- * - Weekly views for all other collections
1562
- */
1563
- applyDefaultCollectionSort(collectionInfo) {
1564
- var _a, _b, _c;
1565
- if (this.baseQuery) {
1566
- // If there's a query set, then we default to relevance sorting regardless of
1567
- // the collection metadata-specified sort.
1568
- this.defaultSortField = SortField.relevance;
1569
- this.defaultSortDirection = null;
1570
- return;
1571
- }
1572
- // Favorite collections sort on Date Favorited by default.
1573
- // Other collections fall back to sorting on weekly views.
1574
- const baseDefaultSort = ((_b = (_a = collectionInfo === null || collectionInfo === void 0 ? void 0 : collectionInfo.public_metadata) === null || _a === void 0 ? void 0 : _a.identifier) === null || _b === void 0 ? void 0 : _b.startsWith('fav-'))
1575
- ? '-favoritedate'
1576
- : '-week';
1577
- // The collection metadata may override the default sorting with something else
1578
- const metadataSort = (_c = collectionInfo === null || collectionInfo === void 0 ? void 0 : collectionInfo.public_metadata) === null || _c === void 0 ? void 0 : _c['sort-by'];
1579
- // Prefer the metadata-specified sort if one exists
1580
- const defaultSortToApply = metadataSort !== null && metadataSort !== void 0 ? metadataSort : baseDefaultSort;
1581
- // Account for both -field and field:dir formats
1582
- let [field, dir] = defaultSortToApply.split(':');
1583
- if (field.startsWith('-')) {
1584
- field = field.slice(1);
1585
- dir = 'desc';
1586
- }
1587
- else if (!['asc', 'desc'].includes(dir)) {
1588
- dir = 'asc';
1589
- }
1590
- const sortOption = sortOptionFromAPIString(field);
1591
- const sortField = sortOption.field;
1592
- if (sortField && sortField !== SortField.default) {
1593
- this.defaultSortField = sortField;
1594
- this.defaultSortDirection = dir;
1595
- }
1596
- }
1597
- /**
1598
- * Applies the default sort option for the current profile element
1599
- */
1600
- applyDefaultProfileSort() {
1601
- if (this.profileElement) {
1602
- const defaultSortField = defaultProfileElementSorts[this.profileElement];
1603
- this.defaultSortField = defaultSortField !== null && defaultSortField !== void 0 ? defaultSortField : SortField.weeklyview;
1604
- }
1605
- else {
1606
- this.defaultSortField = SortField.weeklyview;
1607
- }
1608
- this.defaultSortDirection = 'desc';
1609
- }
1610
- /**
1611
- * This is useful for determining whether we need to reload the scroller.
1612
- *
1613
- * When the fetch completes, we need to reload the scroller if the cells for that
1614
- * page are visible, but if the page is not currenlty visible, we don't need to reload
1615
- */
1616
- get currentVisiblePageNumbers() {
1617
- var _a, _b;
1618
- const visibleCells = (_b = (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.getVisibleCellIndices()) !== null && _b !== void 0 ? _b : [];
1619
- const visiblePages = new Set();
1620
- visibleCells.forEach(cellIndex => {
1621
- const visiblePage = Math.floor(cellIndex / this.pageSize) + 1;
1622
- visiblePages.add(visiblePage);
1623
- });
1624
- return Array.from(visiblePages);
1625
- }
1626
- /**
1627
- * Refreshes all visible result cells in the infinite scroller.
1628
- */
1629
- refreshVisibleResults() {
1630
- var _a;
1631
- (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.refreshAllVisibleCells();
1632
- }
1633
- /**
1634
- * Callback when a result is selected
1635
- */
1636
- resultSelected(event) {
1637
- var _a, _b, _c;
1638
- if (this.isManageView) {
1639
- // Checked/unchecked state change -- rerender to ensure it propagates
1640
- // this.mapDataSource(model => ({ ...model }));
1641
- const cellIndex = this.dataSource.indexOf(event.detail);
1642
- if (cellIndex >= 0)
1643
- (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.refreshCell(cellIndex);
1644
- this.requestUpdate();
1645
- }
1646
- (_b = this.analyticsHandler) === null || _b === void 0 ? void 0 : _b.sendEvent({
1647
- category: this.searchContext,
1648
- action: analyticsActions.resultSelected,
1649
- label: event.detail.mediatype,
1650
- });
1651
- (_c = this.analyticsHandler) === null || _c === void 0 ? void 0 : _c.sendEvent({
1652
- category: this.searchContext,
1653
- action: analyticsActions.resultSelected,
1654
- label: `page-${this.currentPage}`,
1655
- });
1656
- }
1657
- cellForIndex(index) {
1658
- const model = this.tileModelAtCellIndex(index);
1659
- if (!model)
1660
- return undefined;
960
+ `;
961
+ }
962
+ /**
963
+ * Handler for when the date picker's date range is changed.
964
+ */
965
+ histogramDateRangeUpdated(e) {
966
+ var _a;
967
+ const { minDate, maxDate } = e.detail;
968
+ [this.minSelectedDate, this.maxSelectedDate] = [minDate, maxDate];
969
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
970
+ category: this.searchContext,
971
+ action: analyticsActions.histogramChanged,
972
+ label: this.dateRangeQueryClause,
973
+ });
974
+ }
975
+ /**
976
+ * The Lucene query corresponding to the current date range.
977
+ */
978
+ get dateRangeQueryClause() {
979
+ if (!this.minSelectedDate || !this.maxSelectedDate) {
980
+ return undefined;
981
+ }
982
+ return `year:[${this.minSelectedDate} TO ${this.maxSelectedDate}]`;
983
+ }
984
+ /**
985
+ * Emits an event indicating a change in whether the manage mode is shown.
986
+ */
987
+ emitManageModeChangedEvent() {
988
+ this.dispatchEvent(new CustomEvent('manageModeChanged', {
989
+ detail: this.manageViewMode,
990
+ }));
991
+ }
992
+ /**
993
+ * Installs a new data source component and associated query state parameters into
994
+ * this component, causing it to efficiently update its views to represent the
995
+ * newly-provided data. In this way, one can reuse a single instance of
996
+ * <collection-browser> to handle multiple different sets of search results on
997
+ * a single page, each set of results being loaded & updated by its own data
998
+ * source.
999
+ *
1000
+ * @param dataSource The data source component containing (or prepared to fetch)
1001
+ * the tile data to be displayed.
1002
+ * @param queryState The new query-related state that this component should
1003
+ * represent, such as the search query, sort option, and any filters applied.
1004
+ */
1005
+ async installDataSourceAndQueryState(dataSource, queryState) {
1006
+ var _a, _b;
1007
+ log('Installing data source & query state in CB:', dataSource, queryState);
1008
+ if (this.dataSource)
1009
+ this.removeController(this.dataSource);
1010
+ this.dataSource = dataSource;
1011
+ this.addController(this.dataSource);
1012
+ this.baseQuery = queryState.baseQuery;
1013
+ this.profileElement = queryState.profileElement;
1014
+ this.searchType = queryState.searchType;
1015
+ this.selectedFacets =
1016
+ (_a = queryState.selectedFacets) !== null && _a !== void 0 ? _a : getDefaultSelectedFacets();
1017
+ this.minSelectedDate = queryState.minSelectedDate;
1018
+ this.maxSelectedDate = queryState.maxSelectedDate;
1019
+ this.selectedSort = (_b = queryState.selectedSort) !== null && _b !== void 0 ? _b : SortField.default;
1020
+ this.sortDirection = queryState.sortDirection;
1021
+ this.selectedTitleFilter = queryState.selectedTitleFilter;
1022
+ this.selectedCreatorFilter = queryState.selectedCreatorFilter;
1023
+ // We set this flag during the update to prevent the URL state persistence
1024
+ // from creating an unwanted extra history entry.
1025
+ this.dataSourceInstallInProgress = true;
1026
+ this.requestUpdate();
1027
+ await this.updateComplete;
1028
+ this.dataSourceInstallInProgress = false;
1029
+ if (!this.searchResultsLoading) {
1030
+ this.setTotalResultCount(this.dataSource.totalResults);
1031
+ this.setTileCount(this.dataSource.size);
1032
+ }
1033
+ this.refreshVisibleResults();
1034
+ }
1035
+ firstUpdated() {
1036
+ this.restoreState();
1037
+ this.setInitialSize();
1038
+ }
1039
+ /**
1040
+ * Determines the initial size of the content container and whether or not
1041
+ * the mobile layout should be used.
1042
+ */
1043
+ setInitialSize() {
1044
+ this.contentWidth = this.contentContainer.getBoundingClientRect().width;
1045
+ this.mobileView =
1046
+ this.contentWidth > 0 && this.contentWidth < this.mobileBreakpoint;
1047
+ this.sendLayoutSizeAnalytics();
1048
+ }
1049
+ /**
1050
+ * Fires an analytics event indicating which type of layout was rendered:
1051
+ * mobile or desktop.
1052
+ */
1053
+ sendLayoutSizeAnalytics() {
1054
+ if (this.analyticsHandler) {
1055
+ this.layoutSizeAnalyticsSent = true;
1056
+ this.analyticsHandler.sendEvent({
1057
+ category: this.searchContext,
1058
+ action: this.mobileView
1059
+ ? analyticsActions.loadMobileView
1060
+ : analyticsActions.loadDesktopView,
1061
+ });
1062
+ }
1063
+ }
1064
+ updated(changed) {
1065
+ var _a, _b, _c;
1066
+ if (changed.has('placeholderType') && this.placeholderType === null) {
1067
+ if (!this.leftColIntersectionObserver) {
1068
+ this.setupLeftColumnScrollListeners();
1069
+ }
1070
+ if (!this.facetsIntersectionObserver) {
1071
+ this.setupFacetsScrollListeners();
1072
+ }
1073
+ this.updateLeftColumnHeight();
1074
+ }
1075
+ if (changed.has('analyticsHandler') && !this.layoutSizeAnalyticsSent) {
1076
+ this.sendLayoutSizeAnalytics();
1077
+ }
1078
+ if (changed.has('displayMode') ||
1079
+ changed.has('baseNavigationUrl') ||
1080
+ changed.has('baseImageUrl') ||
1081
+ changed.has('loggedIn')) {
1082
+ (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.reload();
1083
+ }
1084
+ if (changed.has('baseQuery') ||
1085
+ changed.has('searchType') ||
1086
+ changed.has('withinCollection')) {
1087
+ // Unless this query/search type update is from the initial page load or the
1088
+ // result of hitting the back button,
1089
+ // we need to clear any existing filters since they may no longer be valid for
1090
+ // the new set of search results.
1091
+ if (!this.historyPopOccurred && this.initialQueryChangeHappened) {
1092
+ // Ordinarily, we leave the sort param unchanged between searches.
1093
+ // However, if we are changing the target collection itself, we want the sort cleared too,
1094
+ // since different collections may have different sorting options available.
1095
+ const shouldClearSort = changed.has('withinCollection') &&
1096
+ !changed.has('selectedSort') &&
1097
+ !changed.has('sortDirection');
1098
+ // Otherwise, only clear filters that haven't been simultaneously applied in this update
1099
+ this.clearFilters({
1100
+ sort: shouldClearSort,
1101
+ facets: !changed.has('selectedFacets'),
1102
+ dateRange: !(changed.has('minSelectedDate') || changed.has('maxSelectedDate')),
1103
+ letterFilters: !(changed.has('selectedTitleFilter') ||
1104
+ changed.has('selectedCreatorFilter')),
1105
+ });
1106
+ }
1107
+ }
1108
+ if (changed.has('profileElement')) {
1109
+ this.applyDefaultProfileSort();
1110
+ }
1111
+ if (changed.has('baseQuery')) {
1112
+ this.emitBaseQueryChanged();
1113
+ }
1114
+ if (changed.has('searchType')) {
1115
+ this.emitSearchTypeChanged();
1116
+ }
1117
+ if (changed.has('currentPage') || changed.has('displayMode')) {
1118
+ this.persistState();
1119
+ }
1120
+ if (changed.has('baseQuery') ||
1121
+ changed.has('minSelectedDate') ||
1122
+ changed.has('maxSelectedDate') ||
1123
+ changed.has('selectedFacets') ||
1124
+ changed.has('searchService') ||
1125
+ changed.has('withinCollection') ||
1126
+ changed.has('withinProfile') ||
1127
+ changed.has('profileElement')) {
1128
+ this.dataSource.refreshLetterCounts();
1129
+ }
1130
+ if (changed.has('selectedSort') || changed.has('sortDirection')) {
1131
+ const prevSortDirection = changed.get('sortDirection');
1132
+ this.sendSortByAnalytics(prevSortDirection);
1133
+ this.selectedSortChanged();
1134
+ }
1135
+ if (changed.has('selectedTitleFilter')) {
1136
+ this.sendFilterByTitleAnalytics(changed.get('selectedTitleFilter'));
1137
+ }
1138
+ if (changed.has('selectedCreatorFilter')) {
1139
+ this.sendFilterByCreatorAnalytics(changed.get('selectedCreatorFilter'));
1140
+ }
1141
+ this.updateFacetReadiness();
1142
+ if (changed.has('baseQuery') ||
1143
+ changed.has('searchType') ||
1144
+ changed.has('selectedTitleFilter') ||
1145
+ changed.has('selectedCreatorFilter') ||
1146
+ changed.has('minSelectedDate') ||
1147
+ changed.has('maxSelectedDate') ||
1148
+ changed.has('selectedSort') ||
1149
+ changed.has('sortDirection') ||
1150
+ changed.has('selectedFacets') ||
1151
+ changed.has('searchService') ||
1152
+ changed.has('withinCollection') ||
1153
+ changed.has('withinProfile') ||
1154
+ changed.has('profileElement')) {
1155
+ this.handleQueryChange();
1156
+ }
1157
+ if (changed.has('searchResultsLoading')) {
1158
+ this.emitSearchResultsLoadingChanged();
1159
+ }
1160
+ if (changed.has('facetsLoading') &&
1161
+ this.facetsLoading &&
1162
+ this.collectionFacets) {
1163
+ this.collectionFacets.moreLinksVisible =
1164
+ this.searchType !== SearchType.FULLTEXT;
1165
+ }
1166
+ if (changed.has('pagesToRender')) {
1167
+ if (!this.dataSource.endOfDataReached && this.infiniteScroller) {
1168
+ this.infiniteScroller.itemCount = this.estimatedTileCount;
1169
+ }
1170
+ }
1171
+ if (changed.has('manageViewMode')) {
1172
+ console.log('here1');
1173
+ if (this.infiniteScroller)
1174
+ this.infiniteScroller.itemCount = this.estimatedTileCount;
1175
+ if (this.manageViewMode) {
1176
+ this.displayMode = 'grid';
1177
+ this.fetchManagableSearchResults();
1178
+ }
1179
+ else if (this.pageContext === 'search')
1180
+ (_b = this.infiniteScroller) === null || _b === void 0 ? void 0 : _b.reload();
1181
+ (_c = this.infiniteScroller) === null || _c === void 0 ? void 0 : _c.refreshAllVisibleCells();
1182
+ this.emitManageModeChangedEvent();
1183
+ }
1184
+ if (changed.has('resizeObserver')) {
1185
+ const oldObserver = changed.get('resizeObserver');
1186
+ if (oldObserver)
1187
+ this.disconnectResizeObserver(oldObserver);
1188
+ // this.setupResizeObserver();
1189
+ }
1190
+ this.ensureAvailableTilesDisplayed();
1191
+ }
1192
+ connectedCallback() {
1193
+ var _a;
1194
+ (_a = super.connectedCallback) === null || _a === void 0 ? void 0 : _a.call(this);
1195
+ this.setupStateRestorationObserver();
1196
+ this.setupResizeObserver();
1197
+ }
1198
+ disconnectedCallback() {
1199
+ var _a, _b;
1200
+ if (this.resizeObserver) {
1201
+ this.disconnectResizeObserver(this.resizeObserver);
1202
+ }
1203
+ if (this.boundNavigationHandler) {
1204
+ window.removeEventListener('popstate', this.boundNavigationHandler);
1205
+ }
1206
+ (_a = this.leftColIntersectionObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
1207
+ (_b = this.facetsIntersectionObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
1208
+ window.removeEventListener('resize', this.updateLeftColumnHeight);
1209
+ }
1210
+ handleResize(entry) {
1211
+ const previousView = this.mobileView;
1212
+ if (entry.target === this.contentContainer) {
1213
+ this.contentWidth = entry.contentRect.width;
1214
+ this.mobileView =
1215
+ this.contentWidth > 0 && this.contentWidth < this.mobileBreakpoint;
1216
+ // If changing from desktop to mobile disable transition
1217
+ if (this.mobileView && !previousView) {
1218
+ this.isResizeToMobile = true;
1219
+ }
1220
+ }
1221
+ // Ensure the facet sidebar remains sized correctly
1222
+ this.updateLeftColumnHeight();
1223
+ }
1224
+ /**
1225
+ * Ensures that if we have new results from the data source that are not yet
1226
+ * displayed in the infinite scroller, that they are immediately reflected
1227
+ * in the tile count.
1228
+ */
1229
+ ensureAvailableTilesDisplayed() {
1230
+ if (this.infiniteScroller &&
1231
+ this.infiniteScroller.itemCount < this.dataSource.size) {
1232
+ this.setTileCount(this.dataSource.endOfDataReached
1233
+ ? this.dataSource.size
1234
+ : this.estimatedTileCount);
1235
+ }
1236
+ }
1237
+ /**
1238
+ * Updates the data source with the current state of facet readiness for loading,
1239
+ * so that they will begin to load in at the appropriate time according to the
1240
+ * current facet loading strategy.
1241
+ */
1242
+ updateFacetReadiness() {
1243
+ // There are two ways to opt into facet production:
1244
+ // (1) have the facets dropdown open, or
1245
+ // (2) if using the `opt-in-or-login` strategy, be logged into an account
1246
+ const optedIn = this.collapsibleFacetsVisible ||
1247
+ (this.facetLoadStrategy === 'opt-in-or-login' && this.loggedIn);
1248
+ // In desktop view, we are always ready to load facets *unless* we are using one of the
1249
+ // `opt-in` strategies and have not opted in (whether by login or UI interaction).
1250
+ const usingOptInStrategy = ['opt-in', 'opt-in-or-login'].includes(this.facetLoadStrategy);
1251
+ const desktopFacetsReady = !this.mobileView && (!usingOptInStrategy || optedIn);
1252
+ // In the mobile view, facets are considered ready provided we have opted in (whether by
1253
+ // login or UI interaction).
1254
+ const mobileFacetsReady = this.mobileView && optedIn;
1255
+ this.dataSource.handleFacetReadinessChange(desktopFacetsReady || mobileFacetsReady);
1256
+ }
1257
+ /**
1258
+ * Sets up listeners for events that may require updating the left column height.
1259
+ */
1260
+ setupLeftColumnScrollListeners() {
1261
+ var _a;
1262
+ // We observe intersections between the left column's scroll sentinel and
1263
+ // the viewport, so that we can ensure the left column is always sized to
1264
+ // match the _available_ viewport height. This should generally be more
1265
+ // performant than listening to scroll events on the page or column.
1266
+ const leftColumnSentinel = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#left-column-scroll-sentinel');
1267
+ if (leftColumnSentinel) {
1268
+ this.leftColIntersectionObserver = new IntersectionObserver(this.updateLeftColumnHeight, {
1269
+ threshold: [...Array(201).keys()].map(n => n / 200), // Threshold every 0.5%
1270
+ });
1271
+ this.leftColIntersectionObserver.observe(leftColumnSentinel);
1272
+ }
1273
+ // We also listen for window resize events, as they are not always captured
1274
+ // by the resize observer and can affect the desired height of the left column.
1275
+ window.addEventListener('resize', this.updateLeftColumnHeight);
1276
+ }
1277
+ /**
1278
+ * Sets up listeners to control whether the facet sidebar shows its bottom fade-out.
1279
+ * Note this uses a separate IntersectionObserver from the left column, because we
1280
+ * don't need granular intersection thresholds for this.
1281
+ */
1282
+ setupFacetsScrollListeners() {
1283
+ var _a;
1284
+ const facetsSentinel = (_a = this.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('#facets-scroll-sentinel');
1285
+ if (facetsSentinel) {
1286
+ this.facetsIntersectionObserver = new IntersectionObserver(this.updateFacetFadeOut);
1287
+ this.facetsIntersectionObserver.observe(facetsSentinel);
1288
+ }
1289
+ }
1290
+ /**
1291
+ * Emits a `baseQueryChanged` event indicating an update to the search query.
1292
+ */
1293
+ emitBaseQueryChanged() {
1294
+ this.dispatchEvent(new CustomEvent('baseQueryChanged', {
1295
+ detail: {
1296
+ baseQuery: this.baseQuery,
1297
+ },
1298
+ }));
1299
+ }
1300
+ /**
1301
+ * Emits a `searchTypeChanged` event indicating an update to the search type
1302
+ * (e.g., metadata vs. full-text).
1303
+ */
1304
+ emitSearchTypeChanged() {
1305
+ this.dispatchEvent(new CustomEvent('searchTypeChanged', {
1306
+ detail: this.searchType,
1307
+ }));
1308
+ }
1309
+ /**
1310
+ * Emits a `queryStateChanged` event indicating that one or more of this component's
1311
+ * properties have changed in a way that could affect the set of search results.
1312
+ */
1313
+ emitQueryStateChanged() {
1314
+ this.dispatchEvent(new CustomEvent('queryStateChanged', {
1315
+ detail: {
1316
+ baseQuery: this.baseQuery,
1317
+ withinCollection: this.withinCollection,
1318
+ withinProfile: this.withinProfile,
1319
+ profileElement: this.profileElement,
1320
+ searchType: this.searchType,
1321
+ selectedFacets: this.selectedFacets,
1322
+ minSelectedDate: this.minSelectedDate,
1323
+ maxSelectedDate: this.maxSelectedDate,
1324
+ selectedSort: this.selectedSort,
1325
+ sortDirection: this.sortDirection,
1326
+ selectedTitleFilter: this.selectedTitleFilter,
1327
+ selectedCreatorFilter: this.selectedCreatorFilter,
1328
+ },
1329
+ }));
1330
+ }
1331
+ /**
1332
+ * Emits an `emptyResults` event indicating that we have received an empty result set
1333
+ * for the most recent query.
1334
+ */
1335
+ emitEmptyResults() {
1336
+ this.dispatchEvent(new Event('emptyResults'));
1337
+ }
1338
+ disconnectResizeObserver(resizeObserver) {
1339
+ resizeObserver.removeObserver({
1340
+ target: this.contentContainer,
1341
+ handler: this,
1342
+ });
1343
+ }
1344
+ setupResizeObserver() {
1345
+ if (!this.resizeObserver || !this.contentContainer)
1346
+ return;
1347
+ this.resizeObserver.addObserver({
1348
+ target: this.contentContainer,
1349
+ handler: this,
1350
+ });
1351
+ }
1352
+ /**
1353
+ * When the visible cells change from the infinite scroller, we want to emit
1354
+ * which page is currently visible so the consumer can update its UI or the URL
1355
+ *
1356
+ * @param e
1357
+ * @returns
1358
+ */
1359
+ visibleCellsChanged(e) {
1360
+ if (this.isScrollingToCell)
1361
+ return;
1362
+ const { visibleCellIndices } = e.detail;
1363
+ if (visibleCellIndices.length === 0)
1364
+ return;
1365
+ // For page determination, do not count more than a single page of visible cells,
1366
+ // since otherwise patrons using very tall screens will be treated as one page
1367
+ // further than they actually are.
1368
+ const lastIndexWithinCurrentPage = Math.min(this.pageSize, visibleCellIndices.length) - 1;
1369
+ const lastVisibleCellIndex = visibleCellIndices[lastIndexWithinCurrentPage];
1370
+ const lastVisibleCellPage = Math.floor(lastVisibleCellIndex / this.pageSize) + 1;
1371
+ if (this.currentPage !== lastVisibleCellPage) {
1372
+ this.currentPage = lastVisibleCellPage;
1373
+ }
1374
+ const event = new CustomEvent('visiblePageChanged', {
1375
+ detail: {
1376
+ pageNumber: lastVisibleCellPage,
1377
+ },
1378
+ });
1379
+ this.dispatchEvent(event);
1380
+ }
1381
+ /**
1382
+ * A Promise which, after each query change, resolves once the fetches for the initial
1383
+ * search have completed. Waits for *both* the hits and aggregations fetches to finish.
1384
+ *
1385
+ * Ensure you await this component's `updateComplete` promise before awaiting this
1386
+ * one, to ensure you do not await an obsolete promise from the previous update.
1387
+ */
1388
+ get initialSearchComplete() {
1389
+ return this.dataSource.initialSearchComplete;
1390
+ }
1391
+ /**
1392
+ * Handler for whenever the component's properties change in a way that may require
1393
+ * fetching new results.
1394
+ */
1395
+ async handleQueryChange() {
1396
+ var _a;
1397
+ // only reset if the query has actually changed
1398
+ if (!this.searchService ||
1399
+ this.dataSource.pageFetchQueryKey === this.previousQueryKey) {
1400
+ return;
1401
+ }
1402
+ // If the new state prevents us from updating the search results, don't reset
1403
+ if (this.baseQuery && !this.dataSource.canPerformSearch) {
1404
+ return;
1405
+ }
1406
+ this.previousQueryKey = this.dataSource.pageFetchQueryKey;
1407
+ this.totalResults = undefined;
1408
+ this.pagesToRender =
1409
+ this.initialPageNumber === 1
1410
+ ? 2 // First two pages are batched into one request when starting from page 1
1411
+ : this.initialPageNumber;
1412
+ // Reset the infinite scroller's item count, so that it
1413
+ // shows tile placeholders until the new query's results load in
1414
+ if (this.infiniteScroller) {
1415
+ this.infiniteScroller.itemCount = this.estimatedTileCount;
1416
+ this.infiniteScroller.reload();
1417
+ }
1418
+ if (this.withinCollection && ((_a = this.baseQuery) === null || _a === void 0 ? void 0 : _a.trim())) {
1419
+ this.defaultSortField = SortField.relevance;
1420
+ this.defaultSortDirection = null;
1421
+ }
1422
+ if (!this.initialQueryChangeHappened && this.initialPageNumber > 1) {
1423
+ this.scrollToPage(this.initialPageNumber);
1424
+ }
1425
+ this.initialQueryChangeHappened = true;
1426
+ // if the query changed as part of a window.history pop event, we don't want to
1427
+ // persist the state because it overwrites the forward history
1428
+ if (!this.historyPopOccurred) {
1429
+ this.persistState();
1430
+ }
1431
+ this.historyPopOccurred = false;
1432
+ }
1433
+ setupStateRestorationObserver() {
1434
+ if (!this.boundNavigationHandler) {
1435
+ this.boundNavigationHandler = this.historyNavigationHandler.bind(this);
1436
+ }
1437
+ // when the user navigates back, we want to update the UI to match the URL
1438
+ window.addEventListener('popstate', this.boundNavigationHandler);
1439
+ }
1440
+ historyNavigationHandler() {
1441
+ this.historyPopOccurred = true;
1442
+ this.restoreState();
1443
+ }
1444
+ restoreState() {
1445
+ var _a, _b, _c, _d, _e;
1446
+ const restorationState = this.restorationStateHandler.getRestorationState();
1447
+ this.displayMode = restorationState.displayMode;
1448
+ if (restorationState.searchType != null)
1449
+ this.searchType = restorationState.searchType;
1450
+ this.selectedSort = (_a = restorationState.selectedSort) !== null && _a !== void 0 ? _a : SortField.default;
1451
+ this.sortDirection = (_b = restorationState.sortDirection) !== null && _b !== void 0 ? _b : null;
1452
+ this.selectedTitleFilter = (_c = restorationState.selectedTitleFilter) !== null && _c !== void 0 ? _c : null;
1453
+ this.selectedCreatorFilter = (_d = restorationState.selectedCreatorFilter) !== null && _d !== void 0 ? _d : null;
1454
+ this.selectedFacets = restorationState.selectedFacets;
1455
+ if (!this.suppressURLQuery)
1456
+ this.baseQuery = restorationState.baseQuery;
1457
+ this.currentPage = (_e = restorationState.currentPage) !== null && _e !== void 0 ? _e : 1;
1458
+ this.minSelectedDate = restorationState.minSelectedDate;
1459
+ this.maxSelectedDate = restorationState.maxSelectedDate;
1460
+ if (this.currentPage > 1) {
1461
+ this.goToPage(this.currentPage);
1462
+ }
1463
+ }
1464
+ persistState() {
1465
+ var _a, _b, _c, _d;
1466
+ const restorationState = {
1467
+ displayMode: this.displayMode,
1468
+ searchType: this.searchType,
1469
+ selectedSort: this.selectedSort,
1470
+ sortDirection: (_a = this.sortDirection) !== null && _a !== void 0 ? _a : undefined,
1471
+ selectedFacets: (_b = this.selectedFacets) !== null && _b !== void 0 ? _b : getDefaultSelectedFacets(),
1472
+ baseQuery: this.suppressURLQuery ? undefined : this.baseQuery,
1473
+ currentPage: this.currentPage,
1474
+ titleQuery: this.titleQuery,
1475
+ creatorQuery: this.creatorQuery,
1476
+ minSelectedDate: this.minSelectedDate,
1477
+ maxSelectedDate: this.maxSelectedDate,
1478
+ selectedTitleFilter: (_c = this.selectedTitleFilter) !== null && _c !== void 0 ? _c : undefined,
1479
+ selectedCreatorFilter: (_d = this.selectedCreatorFilter) !== null && _d !== void 0 ? _d : undefined,
1480
+ };
1481
+ this.restorationStateHandler.persistState(restorationState, this.dataSourceInstallInProgress);
1482
+ }
1483
+ /**
1484
+ * Emits a `searchResultsLoadingChanged` event indicating that our loading state has
1485
+ * changed (either we have started loading new results, or we have finished loading them).
1486
+ */
1487
+ emitSearchResultsLoadingChanged() {
1488
+ this.dispatchEvent(new CustomEvent('searchResultsLoadingChanged', {
1489
+ detail: {
1490
+ loading: this.searchResultsLoading,
1491
+ },
1492
+ }));
1493
+ }
1494
+ /**
1495
+ * Handler for when the set of selected facets changes.
1496
+ */
1497
+ facetsChanged(e) {
1498
+ this.selectedFacets = e.detail;
1499
+ }
1500
+ /**
1501
+ * Handler for when any facet is selected/unselected/hidden/unhidden.
1502
+ * Fires analytics indicating the type of facet event that took place.
1503
+ */
1504
+ facetClickHandler({ detail: { facetType, bucket, negative }, }) {
1505
+ var _a;
1506
+ let action;
1507
+ if (negative) {
1508
+ action =
1509
+ bucket.state !== 'none'
1510
+ ? analyticsActions.facetNegativeSelected
1511
+ : analyticsActions.facetNegativeDeselected;
1512
+ }
1513
+ else {
1514
+ action =
1515
+ bucket.state !== 'none'
1516
+ ? analyticsActions.facetSelected
1517
+ : analyticsActions.facetDeselected;
1518
+ }
1519
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
1520
+ category: this.searchContext,
1521
+ action,
1522
+ label: facetType,
1523
+ });
1524
+ }
1525
+ scrollToPage(pageNumber) {
1526
+ return new Promise(resolve => {
1527
+ const cellIndexToScrollTo = this.pageSize * (pageNumber - 1);
1528
+ // without this setTimeout, Safari just pauses until the `fetchPage` is complete
1529
+ // then scrolls to the cell
1530
+ setTimeout(() => {
1531
+ var _a;
1532
+ this.isScrollingToCell = true;
1533
+ (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.scrollToCell(cellIndexToScrollTo, true);
1534
+ // This timeout is to give the scroll animation time to finish
1535
+ // then updating the infinite scroller once we're done scrolling
1536
+ // There's no scroll animation completion callback so we're
1537
+ // giving it 0.5s to finish.
1538
+ setTimeout(() => {
1539
+ var _a;
1540
+ this.isScrollingToCell = false;
1541
+ (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.refreshAllVisibleCells();
1542
+ resolve();
1543
+ }, 500);
1544
+ }, 0);
1545
+ });
1546
+ }
1547
+ /**
1548
+ * Whether sorting by relevance makes sense for the current state.
1549
+ * Currently equivalent to having a non-empty query.
1550
+ */
1551
+ get isRelevanceSortAvailable() {
1552
+ var _a;
1553
+ return !!((_a = this.baseQuery) === null || _a === void 0 ? void 0 : _a.trim());
1554
+ }
1555
+ /**
1556
+ * Sets the total number of tiles displayed in the infinite scroller.
1557
+ */
1558
+ setTileCount(count) {
1559
+ if (this.infiniteScroller) {
1560
+ this.infiniteScroller.itemCount = count;
1561
+ }
1562
+ }
1563
+ /**
1564
+ * Applies any default sort option for the current collection, by checking
1565
+ * for one in the collection's metadata. If none is found, defaults to sorting
1566
+ * descending by:
1567
+ * - Date Favorited for fav-* collections
1568
+ * - Weekly views for all other collections
1569
+ */
1570
+ applyDefaultCollectionSort(collectionInfo) {
1571
+ var _a, _b, _c;
1572
+ if (this.baseQuery) {
1573
+ // If there's a query set, then we default to relevance sorting regardless of
1574
+ // the collection metadata-specified sort.
1575
+ this.defaultSortField = SortField.relevance;
1576
+ this.defaultSortDirection = null;
1577
+ return;
1578
+ }
1579
+ // Favorite collections sort on Date Favorited by default.
1580
+ // Other collections fall back to sorting on weekly views.
1581
+ const baseDefaultSort = ((_b = (_a = collectionInfo === null || collectionInfo === void 0 ? void 0 : collectionInfo.public_metadata) === null || _a === void 0 ? void 0 : _a.identifier) === null || _b === void 0 ? void 0 : _b.startsWith('fav-'))
1582
+ ? '-favoritedate'
1583
+ : '-week';
1584
+ // The collection metadata may override the default sorting with something else
1585
+ const metadataSort = (_c = collectionInfo === null || collectionInfo === void 0 ? void 0 : collectionInfo.public_metadata) === null || _c === void 0 ? void 0 : _c['sort-by'];
1586
+ // Prefer the metadata-specified sort if one exists
1587
+ const defaultSortToApply = metadataSort !== null && metadataSort !== void 0 ? metadataSort : baseDefaultSort;
1588
+ // Account for both -field and field:dir formats
1589
+ let [field, dir] = defaultSortToApply.split(':');
1590
+ if (field.startsWith('-')) {
1591
+ field = field.slice(1);
1592
+ dir = 'desc';
1593
+ }
1594
+ else if (!['asc', 'desc'].includes(dir)) {
1595
+ dir = 'asc';
1596
+ }
1597
+ const sortOption = sortOptionFromAPIString(field);
1598
+ const sortField = sortOption.field;
1599
+ if (sortField && sortField !== SortField.default) {
1600
+ this.defaultSortField = sortField;
1601
+ this.defaultSortDirection = dir;
1602
+ }
1603
+ }
1604
+ /**
1605
+ * Applies the default sort option for the current profile element
1606
+ */
1607
+ applyDefaultProfileSort() {
1608
+ if (this.profileElement) {
1609
+ const defaultSortField = defaultProfileElementSorts[this.profileElement];
1610
+ this.defaultSortField = defaultSortField !== null && defaultSortField !== void 0 ? defaultSortField : SortField.weeklyview;
1611
+ }
1612
+ else {
1613
+ this.defaultSortField = SortField.weeklyview;
1614
+ }
1615
+ this.defaultSortDirection = 'desc';
1616
+ }
1617
+ /**
1618
+ * This is useful for determining whether we need to reload the scroller.
1619
+ *
1620
+ * When the fetch completes, we need to reload the scroller if the cells for that
1621
+ * page are visible, but if the page is not currenlty visible, we don't need to reload
1622
+ */
1623
+ get currentVisiblePageNumbers() {
1624
+ var _a, _b;
1625
+ const visibleCells = (_b = (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.getVisibleCellIndices()) !== null && _b !== void 0 ? _b : [];
1626
+ const visiblePages = new Set();
1627
+ visibleCells.forEach(cellIndex => {
1628
+ const visiblePage = Math.floor(cellIndex / this.pageSize) + 1;
1629
+ visiblePages.add(visiblePage);
1630
+ });
1631
+ return Array.from(visiblePages);
1632
+ }
1633
+ /**
1634
+ * Refreshes all visible result cells in the infinite scroller.
1635
+ */
1636
+ refreshVisibleResults() {
1637
+ var _a;
1638
+ (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.refreshAllVisibleCells();
1639
+ }
1640
+ /**
1641
+ * Callback when a result is selected
1642
+ */
1643
+ resultSelected(event) {
1644
+ var _a, _b, _c;
1645
+ if (this.manageViewMode) {
1646
+ // Checked/unchecked state change -- rerender to ensure it propagates
1647
+ // this.mapDataSource(model => ({ ...model }));
1648
+ const cellIndex = this.dataSource.indexOf(event.detail);
1649
+ if (cellIndex >= 0)
1650
+ (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.refreshCell(cellIndex);
1651
+ this.requestUpdate();
1652
+ }
1653
+ (_b = this.analyticsHandler) === null || _b === void 0 ? void 0 : _b.sendEvent({
1654
+ category: this.searchContext,
1655
+ action: analyticsActions.resultSelected,
1656
+ label: event.detail.mediatype,
1657
+ });
1658
+ (_c = this.analyticsHandler) === null || _c === void 0 ? void 0 : _c.sendEvent({
1659
+ category: this.searchContext,
1660
+ action: analyticsActions.resultSelected,
1661
+ label: `page-${this.currentPage}`,
1662
+ });
1663
+ }
1664
+ cellForIndex(index) {
1665
+ const model = this.tileModelAtCellIndex(index);
1666
+ if (!model)
1667
+ return undefined;
1661
1668
  return html `
1662
1669
  <tile-dispatcher
1663
1670
  .collectionPagePath=${this.collectionPagePath}
@@ -1672,45 +1679,47 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
1672
1679
  .creatorFilter=${this.selectedCreatorFilter}
1673
1680
  .mobileBreakpoint=${this.mobileBreakpoint}
1674
1681
  .loggedIn=${this.loggedIn}
1675
- .isManageView=${this.isManageView}
1682
+ .isManageView=${!!this.manageViewMode}
1676
1683
  ?enableHoverPane=${true}
1677
1684
  @resultSelected=${(e) => this.resultSelected(e)}
1678
1685
  >
1679
1686
  </tile-dispatcher>
1680
- `;
1681
- }
1682
- /**
1683
- * When the user scrolls near to the bottom of the page, fetch the next page
1684
- * increase the number of pages to render and start fetching data for the new page
1685
- */
1686
- scrollThresholdReached() {
1687
- if (!this.dataSource.endOfDataReached && this.dataSource.queryInitialized) {
1688
- this.pagesToRender += 1;
1689
- this.dataSource.fetchPage(this.pagesToRender);
1690
- }
1691
- }
1692
- /**
1693
- * Fetches search results for privileged users when in manage view.
1694
- *
1695
- * This method:
1696
- * 1. Checks if we're in search context with > 100 results and not currently loading
1697
- * 2. Resets the datasource pagination state
1698
- * 3. Fetches first page with limit based on maxPagesToManage threshold
1699
- * 4. Reloads the infinite scroller to display new results
1700
- */
1701
- fetchManagableSearchResults() {
1702
- var _a;
1703
- if (this.pageContext === 'search' &&
1704
- this.dataSource.totalResults > 100 &&
1705
- !this.searchResultsLoading) {
1706
- this.dataSource.resetPages();
1707
- this.dataSource.fetchPage(1, this.maxPagesToManage);
1708
- (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.reload();
1709
- }
1710
- }
1711
- static get styles() {
1712
- return [
1713
- srOnlyStyle,
1687
+ `;
1688
+ }
1689
+ /**
1690
+ * When the user scrolls near to the bottom of the page, fetch the next page
1691
+ * increase the number of pages to render and start fetching data for the new page
1692
+ */
1693
+ scrollThresholdReached() {
1694
+ if (!this.dataSource.endOfDataReached && this.dataSource.queryInitialized) {
1695
+ this.pagesToRender += 1;
1696
+ this.dataSource.fetchPage(this.pagesToRender);
1697
+ }
1698
+ }
1699
+ /**
1700
+ * Fetches search results for privileged users when in manage view.
1701
+ *
1702
+ * This method:
1703
+ * 1. Checks if we're in search context with > 100 results and not currently loading
1704
+ * 2. Resets the datasource pagination state
1705
+ * 3. Fetches first page with limit based on maxPagesToManage threshold
1706
+ * 4. Reloads the infinite scroller to display new results
1707
+ */
1708
+ fetchManagableSearchResults() {
1709
+ var _a;
1710
+ if ((this.pageContext === 'search' &&
1711
+ this.dataSource.totalResults > 100 &&
1712
+ !this.searchResultsLoading) ||
1713
+ this.manageViewMode === 'initial') {
1714
+ console.log('here22');
1715
+ this.dataSource.resetPages();
1716
+ this.dataSource.fetchPage(1, this.maxPagesToManage);
1717
+ (_a = this.infiniteScroller) === null || _a === void 0 ? void 0 : _a.reload();
1718
+ }
1719
+ }
1720
+ static get styles() {
1721
+ return [
1722
+ srOnlyStyle,
1714
1723
  css `
1715
1724
  :host {
1716
1725
  display: block;
@@ -2133,195 +2142,195 @@ let CollectionBrowser = class CollectionBrowser extends LitElement {
2133
2142
  infinite-scroller.hidden {
2134
2143
  display: none;
2135
2144
  }
2136
- `,
2137
- ];
2138
- }
2139
- };
2140
- __decorate([
2141
- property({ type: String })
2142
- ], CollectionBrowser.prototype, "baseNavigationUrl", void 0);
2143
- __decorate([
2144
- property({ type: String })
2145
- ], CollectionBrowser.prototype, "baseImageUrl", void 0);
2146
- __decorate([
2147
- property({ type: Object })
2148
- ], CollectionBrowser.prototype, "searchService", void 0);
2149
- __decorate([
2150
- property({ type: Number })
2151
- ], CollectionBrowser.prototype, "searchType", void 0);
2152
- __decorate([
2153
- property({ type: String })
2154
- ], CollectionBrowser.prototype, "withinCollection", void 0);
2155
- __decorate([
2156
- property({ type: String })
2157
- ], CollectionBrowser.prototype, "withinProfile", void 0);
2158
- __decorate([
2159
- property({ type: String })
2160
- ], CollectionBrowser.prototype, "profileElement", void 0);
2161
- __decorate([
2162
- property({ type: String })
2163
- ], CollectionBrowser.prototype, "baseQuery", void 0);
2164
- __decorate([
2165
- property({ type: String })
2166
- ], CollectionBrowser.prototype, "displayMode", void 0);
2167
- __decorate([
2168
- property({ type: String })
2169
- ], CollectionBrowser.prototype, "selectedSort", void 0);
2170
- __decorate([
2171
- property({ type: String })
2172
- ], CollectionBrowser.prototype, "selectedTitleFilter", void 0);
2173
- __decorate([
2174
- property({ type: String })
2175
- ], CollectionBrowser.prototype, "selectedCreatorFilter", void 0);
2176
- __decorate([
2177
- property({ type: String })
2178
- ], CollectionBrowser.prototype, "sortDirection", void 0);
2179
- __decorate([
2180
- property({ type: String })
2181
- ], CollectionBrowser.prototype, "defaultSortField", void 0);
2182
- __decorate([
2183
- property({ type: String })
2184
- ], CollectionBrowser.prototype, "defaultSortDirection", void 0);
2185
- __decorate([
2186
- property({ type: Number })
2187
- ], CollectionBrowser.prototype, "pageSize", void 0);
2188
- __decorate([
2189
- property({ type: Number })
2190
- ], CollectionBrowser.prototype, "currentPage", void 0);
2191
- __decorate([
2192
- property({ type: String })
2193
- ], CollectionBrowser.prototype, "minSelectedDate", void 0);
2194
- __decorate([
2195
- property({ type: String })
2196
- ], CollectionBrowser.prototype, "maxSelectedDate", void 0);
2197
- __decorate([
2198
- property({ type: Object })
2199
- ], CollectionBrowser.prototype, "selectedFacets", void 0);
2200
- __decorate([
2201
- property({ type: Boolean })
2202
- ], CollectionBrowser.prototype, "showSmartFacetBar", void 0);
2203
- __decorate([
2204
- property({ type: Boolean })
2205
- ], CollectionBrowser.prototype, "showHistogramDatePicker", void 0);
2206
- __decorate([
2207
- property({ type: Boolean })
2208
- ], CollectionBrowser.prototype, "suppressPlaceholders", void 0);
2209
- __decorate([
2210
- property({ type: Boolean })
2211
- ], CollectionBrowser.prototype, "suppressResultCount", void 0);
2212
- __decorate([
2213
- property({ type: Boolean })
2214
- ], CollectionBrowser.prototype, "suppressResultTiles", void 0);
2215
- __decorate([
2216
- property({ type: Boolean })
2217
- ], CollectionBrowser.prototype, "suppressURLQuery", void 0);
2218
- __decorate([
2219
- property({ type: Boolean })
2220
- ], CollectionBrowser.prototype, "suppressSortBar", void 0);
2221
- __decorate([
2222
- property({ type: Boolean })
2223
- ], CollectionBrowser.prototype, "suppressDisplayModes", void 0);
2224
- __decorate([
2225
- property({ type: String })
2226
- ], CollectionBrowser.prototype, "facetLoadStrategy", void 0);
2227
- __decorate([
2228
- property({ type: Boolean })
2229
- ], CollectionBrowser.prototype, "facetPaneVisible", void 0);
2230
- __decorate([
2231
- property({ type: Boolean })
2232
- ], CollectionBrowser.prototype, "clearResultsOnEmptyQuery", void 0);
2233
- __decorate([
2234
- property({ type: String })
2235
- ], CollectionBrowser.prototype, "collectionPagePath", void 0);
2236
- __decorate([
2237
- property({ type: String, reflect: true })
2238
- ], CollectionBrowser.prototype, "searchContext", void 0);
2239
- __decorate([
2240
- property({ type: String })
2241
- ], CollectionBrowser.prototype, "pageContext", void 0);
2242
- __decorate([
2243
- property({ type: Object })
2244
- ], CollectionBrowser.prototype, "restorationStateHandler", void 0);
2245
- __decorate([
2246
- property({ type: Number })
2247
- ], CollectionBrowser.prototype, "mobileBreakpoint", void 0);
2248
- __decorate([
2249
- property({ type: Boolean })
2250
- ], CollectionBrowser.prototype, "loggedIn", void 0);
2251
- __decorate([
2252
- property({ type: Object })
2253
- ], CollectionBrowser.prototype, "resizeObserver", void 0);
2254
- __decorate([
2255
- property({ type: Object })
2256
- ], CollectionBrowser.prototype, "modalManager", void 0);
2257
- __decorate([
2258
- property({ type: Object })
2259
- ], CollectionBrowser.prototype, "featureFeedbackService", void 0);
2260
- __decorate([
2261
- property({ type: Object })
2262
- ], CollectionBrowser.prototype, "recaptchaManager", void 0);
2263
- __decorate([
2264
- property({ type: Boolean })
2265
- ], CollectionBrowser.prototype, "isManageView", void 0);
2266
- __decorate([
2267
- property({ type: String })
2268
- ], CollectionBrowser.prototype, "manageViewLabel", void 0);
2269
- __decorate([
2270
- property({ type: Boolean })
2271
- ], CollectionBrowser.prototype, "enableSortOptionsSlot", void 0);
2272
- __decorate([
2273
- property({ type: Boolean, reflect: true })
2274
- ], CollectionBrowser.prototype, "showSmartResults", void 0);
2275
- __decorate([
2276
- property({ type: Number })
2277
- ], CollectionBrowser.prototype, "maxPagesToManage", void 0);
2278
- __decorate([
2279
- property({ type: Object })
2280
- ], CollectionBrowser.prototype, "dataSource", void 0);
2281
- __decorate([
2282
- state()
2283
- ], CollectionBrowser.prototype, "pagesToRender", void 0);
2284
- __decorate([
2285
- state()
2286
- ], CollectionBrowser.prototype, "searchResultsLoading", void 0);
2287
- __decorate([
2288
- state()
2289
- ], CollectionBrowser.prototype, "facetsLoading", void 0);
2290
- __decorate([
2291
- state()
2292
- ], CollectionBrowser.prototype, "totalResults", void 0);
2293
- __decorate([
2294
- state()
2295
- ], CollectionBrowser.prototype, "mobileView", void 0);
2296
- __decorate([
2297
- state()
2298
- ], CollectionBrowser.prototype, "collapsibleFacetsVisible", void 0);
2299
- __decorate([
2300
- state()
2301
- ], CollectionBrowser.prototype, "contentWidth", void 0);
2302
- __decorate([
2303
- state()
2304
- ], CollectionBrowser.prototype, "placeholderType", void 0);
2305
- __decorate([
2306
- query('#content-container')
2307
- ], CollectionBrowser.prototype, "contentContainer", void 0);
2308
- __decorate([
2309
- query('#left-column')
2310
- ], CollectionBrowser.prototype, "leftColumn", void 0);
2311
- __decorate([
2312
- query('collection-facets')
2313
- ], CollectionBrowser.prototype, "collectionFacets", void 0);
2314
- __decorate([
2315
- query('manage-bar')
2316
- ], CollectionBrowser.prototype, "manageBar", void 0);
2317
- __decorate([
2318
- property({ type: Object, attribute: false })
2319
- ], CollectionBrowser.prototype, "analyticsHandler", void 0);
2320
- __decorate([
2321
- query('infinite-scroller')
2322
- ], CollectionBrowser.prototype, "infiniteScroller", void 0);
2323
- CollectionBrowser = __decorate([
2324
- customElement('collection-browser')
2325
- ], CollectionBrowser);
2326
- export { CollectionBrowser };
2145
+ `,
2146
+ ];
2147
+ }
2148
+ };
2149
+ __decorate([
2150
+ property({ type: String })
2151
+ ], CollectionBrowser.prototype, "baseNavigationUrl", void 0);
2152
+ __decorate([
2153
+ property({ type: String })
2154
+ ], CollectionBrowser.prototype, "baseImageUrl", void 0);
2155
+ __decorate([
2156
+ property({ type: Object })
2157
+ ], CollectionBrowser.prototype, "searchService", void 0);
2158
+ __decorate([
2159
+ property({ type: Number })
2160
+ ], CollectionBrowser.prototype, "searchType", void 0);
2161
+ __decorate([
2162
+ property({ type: String })
2163
+ ], CollectionBrowser.prototype, "withinCollection", void 0);
2164
+ __decorate([
2165
+ property({ type: String })
2166
+ ], CollectionBrowser.prototype, "withinProfile", void 0);
2167
+ __decorate([
2168
+ property({ type: String })
2169
+ ], CollectionBrowser.prototype, "profileElement", void 0);
2170
+ __decorate([
2171
+ property({ type: String })
2172
+ ], CollectionBrowser.prototype, "baseQuery", void 0);
2173
+ __decorate([
2174
+ property({ type: String })
2175
+ ], CollectionBrowser.prototype, "displayMode", void 0);
2176
+ __decorate([
2177
+ property({ type: String })
2178
+ ], CollectionBrowser.prototype, "selectedSort", void 0);
2179
+ __decorate([
2180
+ property({ type: String })
2181
+ ], CollectionBrowser.prototype, "selectedTitleFilter", void 0);
2182
+ __decorate([
2183
+ property({ type: String })
2184
+ ], CollectionBrowser.prototype, "selectedCreatorFilter", void 0);
2185
+ __decorate([
2186
+ property({ type: String })
2187
+ ], CollectionBrowser.prototype, "sortDirection", void 0);
2188
+ __decorate([
2189
+ property({ type: String })
2190
+ ], CollectionBrowser.prototype, "defaultSortField", void 0);
2191
+ __decorate([
2192
+ property({ type: String })
2193
+ ], CollectionBrowser.prototype, "defaultSortDirection", void 0);
2194
+ __decorate([
2195
+ property({ type: Number })
2196
+ ], CollectionBrowser.prototype, "pageSize", void 0);
2197
+ __decorate([
2198
+ property({ type: Number })
2199
+ ], CollectionBrowser.prototype, "currentPage", void 0);
2200
+ __decorate([
2201
+ property({ type: String })
2202
+ ], CollectionBrowser.prototype, "minSelectedDate", void 0);
2203
+ __decorate([
2204
+ property({ type: String })
2205
+ ], CollectionBrowser.prototype, "maxSelectedDate", void 0);
2206
+ __decorate([
2207
+ property({ type: Object })
2208
+ ], CollectionBrowser.prototype, "selectedFacets", void 0);
2209
+ __decorate([
2210
+ property({ type: Boolean })
2211
+ ], CollectionBrowser.prototype, "showSmartFacetBar", void 0);
2212
+ __decorate([
2213
+ property({ type: Boolean })
2214
+ ], CollectionBrowser.prototype, "showHistogramDatePicker", void 0);
2215
+ __decorate([
2216
+ property({ type: Boolean })
2217
+ ], CollectionBrowser.prototype, "suppressPlaceholders", void 0);
2218
+ __decorate([
2219
+ property({ type: Boolean })
2220
+ ], CollectionBrowser.prototype, "suppressResultCount", void 0);
2221
+ __decorate([
2222
+ property({ type: Boolean })
2223
+ ], CollectionBrowser.prototype, "suppressResultTiles", void 0);
2224
+ __decorate([
2225
+ property({ type: Boolean })
2226
+ ], CollectionBrowser.prototype, "suppressURLQuery", void 0);
2227
+ __decorate([
2228
+ property({ type: Boolean })
2229
+ ], CollectionBrowser.prototype, "suppressSortBar", void 0);
2230
+ __decorate([
2231
+ property({ type: Boolean })
2232
+ ], CollectionBrowser.prototype, "suppressDisplayModes", void 0);
2233
+ __decorate([
2234
+ property({ type: String })
2235
+ ], CollectionBrowser.prototype, "facetLoadStrategy", void 0);
2236
+ __decorate([
2237
+ property({ type: Boolean })
2238
+ ], CollectionBrowser.prototype, "facetPaneVisible", void 0);
2239
+ __decorate([
2240
+ property({ type: Boolean })
2241
+ ], CollectionBrowser.prototype, "clearResultsOnEmptyQuery", void 0);
2242
+ __decorate([
2243
+ property({ type: String })
2244
+ ], CollectionBrowser.prototype, "collectionPagePath", void 0);
2245
+ __decorate([
2246
+ property({ type: String, reflect: true })
2247
+ ], CollectionBrowser.prototype, "searchContext", void 0);
2248
+ __decorate([
2249
+ property({ type: String })
2250
+ ], CollectionBrowser.prototype, "pageContext", void 0);
2251
+ __decorate([
2252
+ property({ type: Object })
2253
+ ], CollectionBrowser.prototype, "restorationStateHandler", void 0);
2254
+ __decorate([
2255
+ property({ type: Number })
2256
+ ], CollectionBrowser.prototype, "mobileBreakpoint", void 0);
2257
+ __decorate([
2258
+ property({ type: Boolean })
2259
+ ], CollectionBrowser.prototype, "loggedIn", void 0);
2260
+ __decorate([
2261
+ property({ type: Object })
2262
+ ], CollectionBrowser.prototype, "resizeObserver", void 0);
2263
+ __decorate([
2264
+ property({ type: Object })
2265
+ ], CollectionBrowser.prototype, "modalManager", void 0);
2266
+ __decorate([
2267
+ property({ type: Object })
2268
+ ], CollectionBrowser.prototype, "featureFeedbackService", void 0);
2269
+ __decorate([
2270
+ property({ type: Object })
2271
+ ], CollectionBrowser.prototype, "recaptchaManager", void 0);
2272
+ __decorate([
2273
+ property({ type: String })
2274
+ ], CollectionBrowser.prototype, "manageViewMode", void 0);
2275
+ __decorate([
2276
+ property({ type: String })
2277
+ ], CollectionBrowser.prototype, "manageViewLabel", void 0);
2278
+ __decorate([
2279
+ property({ type: Boolean })
2280
+ ], CollectionBrowser.prototype, "enableSortOptionsSlot", void 0);
2281
+ __decorate([
2282
+ property({ type: Boolean, reflect: true })
2283
+ ], CollectionBrowser.prototype, "showSmartResults", void 0);
2284
+ __decorate([
2285
+ property({ type: Number })
2286
+ ], CollectionBrowser.prototype, "maxPagesToManage", void 0);
2287
+ __decorate([
2288
+ property({ type: Object })
2289
+ ], CollectionBrowser.prototype, "dataSource", void 0);
2290
+ __decorate([
2291
+ state()
2292
+ ], CollectionBrowser.prototype, "pagesToRender", void 0);
2293
+ __decorate([
2294
+ state()
2295
+ ], CollectionBrowser.prototype, "searchResultsLoading", void 0);
2296
+ __decorate([
2297
+ state()
2298
+ ], CollectionBrowser.prototype, "facetsLoading", void 0);
2299
+ __decorate([
2300
+ state()
2301
+ ], CollectionBrowser.prototype, "totalResults", void 0);
2302
+ __decorate([
2303
+ state()
2304
+ ], CollectionBrowser.prototype, "mobileView", void 0);
2305
+ __decorate([
2306
+ state()
2307
+ ], CollectionBrowser.prototype, "collapsibleFacetsVisible", void 0);
2308
+ __decorate([
2309
+ state()
2310
+ ], CollectionBrowser.prototype, "contentWidth", void 0);
2311
+ __decorate([
2312
+ state()
2313
+ ], CollectionBrowser.prototype, "placeholderType", void 0);
2314
+ __decorate([
2315
+ query('#content-container')
2316
+ ], CollectionBrowser.prototype, "contentContainer", void 0);
2317
+ __decorate([
2318
+ query('#left-column')
2319
+ ], CollectionBrowser.prototype, "leftColumn", void 0);
2320
+ __decorate([
2321
+ query('collection-facets')
2322
+ ], CollectionBrowser.prototype, "collectionFacets", void 0);
2323
+ __decorate([
2324
+ query('manage-bar')
2325
+ ], CollectionBrowser.prototype, "manageBar", void 0);
2326
+ __decorate([
2327
+ property({ type: Object, attribute: false })
2328
+ ], CollectionBrowser.prototype, "analyticsHandler", void 0);
2329
+ __decorate([
2330
+ query('infinite-scroller')
2331
+ ], CollectionBrowser.prototype, "infiniteScroller", void 0);
2332
+ CollectionBrowser = __decorate([
2333
+ customElement('collection-browser')
2334
+ ], CollectionBrowser);
2335
+ export { CollectionBrowser };
2327
2336
  //# sourceMappingURL=collection-browser.js.map