@internetarchive/collection-browser 4.8.0 → 4.8.1-webdev-9227.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (381) hide show
  1. package/README.md +33 -0
  2. package/dist/src/collection-browser.d.ts +2 -1
  3. package/dist/src/collection-browser.js +3 -3
  4. package/dist/src/collection-browser.js.map +1 -1
  5. package/dist/src/collection-facets/more-facets-content.js +3 -2
  6. package/dist/src/collection-facets/more-facets-content.js.map +1 -1
  7. package/dist/src/collection-facets/more-facets-scroller.js +3 -2
  8. package/dist/src/collection-facets/more-facets-scroller.js.map +1 -1
  9. package/dist/src/collection-facets.js +3 -2
  10. package/dist/src/collection-facets.js.map +1 -1
  11. package/dist/src/empty-placeholder.d.ts +7 -7
  12. package/dist/src/empty-placeholder.js +29 -15
  13. package/dist/src/empty-placeholder.js.map +1 -1
  14. package/dist/src/expanded-date-picker.js +3 -2
  15. package/dist/src/expanded-date-picker.js.map +1 -1
  16. package/dist/src/locales/es.d.ts +94 -0
  17. package/dist/src/locales/es.js +109 -0
  18. package/dist/src/locales/es.js.map +1 -0
  19. package/dist/src/manage/manage-bar.d.ts +3 -2
  20. package/dist/src/manage/manage-bar.js +6 -7
  21. package/dist/src/manage/manage-bar.js.map +1 -1
  22. package/dist/src/manage/remove-items-modal-content.js +3 -2
  23. package/dist/src/manage/remove-items-modal-content.js.map +1 -1
  24. package/dist/src/models.js +6 -2
  25. package/dist/src/models.js.map +1 -1
  26. package/dist/src/sort-filter-bar/sort-filter-bar.js +3 -2
  27. package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
  28. package/dist/src/tiles/grid/account-tile.js +3 -2
  29. package/dist/src/tiles/grid/account-tile.js.map +1 -1
  30. package/dist/src/tiles/grid/collection-tile.js +3 -2
  31. package/dist/src/tiles/grid/collection-tile.js.map +1 -1
  32. package/dist/src/tiles/grid/item-tile.js +3 -2
  33. package/dist/src/tiles/grid/item-tile.js.map +1 -1
  34. package/dist/src/tiles/grid/tile-stats.js +3 -2
  35. package/dist/src/tiles/grid/tile-stats.js.map +1 -1
  36. package/dist/src/tiles/list/tile-list-compact-header.js +3 -2
  37. package/dist/src/tiles/list/tile-list-compact-header.js.map +1 -1
  38. package/dist/src/tiles/list/tile-list-compact.js +3 -1
  39. package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
  40. package/dist/src/tiles/list/tile-list.js +3 -2
  41. package/dist/src/tiles/list/tile-list.js.map +1 -1
  42. package/dist/src/tiles/overlay/text-overlay.js +3 -1
  43. package/dist/src/tiles/overlay/text-overlay.js.map +1 -1
  44. package/dist/src/tiles/review-block.js +3 -2
  45. package/dist/src/tiles/review-block.js.map +1 -1
  46. package/dist/src/tiles/tile-dispatcher.d.ts +2 -1
  47. package/dist/src/tiles/tile-dispatcher.js +5 -4
  48. package/dist/src/tiles/tile-dispatcher.js.map +1 -1
  49. package/locales/es.d.ts +1 -0
  50. package/locales/es.js +1 -0
  51. package/package.json +13 -1
  52. package/.editorconfig +0 -29
  53. package/.github/workflows/ci.yml +0 -29
  54. package/.github/workflows/gh-pages-main.yml +0 -41
  55. package/.github/workflows/npm-publish.yml +0 -42
  56. package/.github/workflows/pr-preview.yml +0 -40
  57. package/.husky/pre-commit +0 -1
  58. package/.prettierignore +0 -1
  59. package/dist/test/collection-browser.test.d.ts +0 -1
  60. package/dist/test/collection-browser.test.js +0 -1815
  61. package/dist/test/collection-browser.test.js.map +0 -1
  62. package/dist/test/collection-facets/facet-row.test.d.ts +0 -1
  63. package/dist/test/collection-facets/facet-row.test.js +0 -291
  64. package/dist/test/collection-facets/facet-row.test.js.map +0 -1
  65. package/dist/test/collection-facets/facets-template.test.d.ts +0 -1
  66. package/dist/test/collection-facets/facets-template.test.js +0 -95
  67. package/dist/test/collection-facets/facets-template.test.js.map +0 -1
  68. package/dist/test/collection-facets/more-facets-content.test.d.ts +0 -1
  69. package/dist/test/collection-facets/more-facets-content.test.js +0 -509
  70. package/dist/test/collection-facets/more-facets-content.test.js.map +0 -1
  71. package/dist/test/collection-facets/more-facets-scroller.test.d.ts +0 -1
  72. package/dist/test/collection-facets/more-facets-scroller.test.js +0 -288
  73. package/dist/test/collection-facets/more-facets-scroller.test.js.map +0 -1
  74. package/dist/test/collection-facets/page-window.test.d.ts +0 -1
  75. package/dist/test/collection-facets/page-window.test.js +0 -175
  76. package/dist/test/collection-facets/page-window.test.js.map +0 -1
  77. package/dist/test/collection-facets/toggle-switch.test.d.ts +0 -1
  78. package/dist/test/collection-facets/toggle-switch.test.js +0 -99
  79. package/dist/test/collection-facets/toggle-switch.test.js.map +0 -1
  80. package/dist/test/collection-facets.test.d.ts +0 -2
  81. package/dist/test/collection-facets.test.js +0 -728
  82. package/dist/test/collection-facets.test.js.map +0 -1
  83. package/dist/test/data-source/collection-browser-data-source.test.d.ts +0 -1
  84. package/dist/test/data-source/collection-browser-data-source.test.js +0 -154
  85. package/dist/test/data-source/collection-browser-data-source.test.js.map +0 -1
  86. package/dist/test/empty-placeholder.test.d.ts +0 -1
  87. package/dist/test/empty-placeholder.test.js +0 -57
  88. package/dist/test/empty-placeholder.test.js.map +0 -1
  89. package/dist/test/expanded-date-picker.test.d.ts +0 -1
  90. package/dist/test/expanded-date-picker.test.js +0 -124
  91. package/dist/test/expanded-date-picker.test.js.map +0 -1
  92. package/dist/test/icon-overlay.test.d.ts +0 -1
  93. package/dist/test/icon-overlay.test.js +0 -31
  94. package/dist/test/icon-overlay.test.js.map +0 -1
  95. package/dist/test/image-block.test.d.ts +0 -1
  96. package/dist/test/image-block.test.js +0 -208
  97. package/dist/test/image-block.test.js.map +0 -1
  98. package/dist/test/item-image.test.d.ts +0 -1
  99. package/dist/test/item-image.test.js +0 -187
  100. package/dist/test/item-image.test.js.map +0 -1
  101. package/dist/test/manage/manage-bar.test.d.ts +0 -3
  102. package/dist/test/manage/manage-bar.test.js +0 -216
  103. package/dist/test/manage/manage-bar.test.js.map +0 -1
  104. package/dist/test/manage/remove-items-modal-content.test.d.ts +0 -1
  105. package/dist/test/manage/remove-items-modal-content.test.js +0 -60
  106. package/dist/test/manage/remove-items-modal-content.test.js.map +0 -1
  107. package/dist/test/mediatype-config.test.d.ts +0 -1
  108. package/dist/test/mediatype-config.test.js +0 -11
  109. package/dist/test/mediatype-config.test.js.map +0 -1
  110. package/dist/test/mocks/mock-analytics-handler.d.ts +0 -10
  111. package/dist/test/mocks/mock-analytics-handler.js +0 -16
  112. package/dist/test/mocks/mock-analytics-handler.js.map +0 -1
  113. package/dist/test/mocks/mock-search-responses.d.ts +0 -37
  114. package/dist/test/mocks/mock-search-responses.js +0 -1293
  115. package/dist/test/mocks/mock-search-responses.js.map +0 -1
  116. package/dist/test/mocks/mock-search-service.d.ts +0 -16
  117. package/dist/test/mocks/mock-search-service.js +0 -65
  118. package/dist/test/mocks/mock-search-service.js.map +0 -1
  119. package/dist/test/restoration-state-handler.test.d.ts +0 -1
  120. package/dist/test/restoration-state-handler.test.js +0 -335
  121. package/dist/test/restoration-state-handler.test.js.map +0 -1
  122. package/dist/test/review-block.test.d.ts +0 -1
  123. package/dist/test/review-block.test.js +0 -46
  124. package/dist/test/review-block.test.js.map +0 -1
  125. package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.d.ts +0 -1
  126. package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.js +0 -12
  127. package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.js.map +0 -1
  128. package/dist/test/sort-filter-bar/alpha-bar.test.d.ts +0 -1
  129. package/dist/test/sort-filter-bar/alpha-bar.test.js +0 -68
  130. package/dist/test/sort-filter-bar/alpha-bar.test.js.map +0 -1
  131. package/dist/test/sort-filter-bar/sort-filter-bar.test.d.ts +0 -1
  132. package/dist/test/sort-filter-bar/sort-filter-bar.test.js +0 -304
  133. package/dist/test/sort-filter-bar/sort-filter-bar.test.js.map +0 -1
  134. package/dist/test/text-overlay.test.d.ts +0 -1
  135. package/dist/test/text-overlay.test.js +0 -43
  136. package/dist/test/text-overlay.test.js.map +0 -1
  137. package/dist/test/text-snippet-block.test.d.ts +0 -1
  138. package/dist/test/text-snippet-block.test.js +0 -58
  139. package/dist/test/text-snippet-block.test.js.map +0 -1
  140. package/dist/test/tile-stats.test.d.ts +0 -1
  141. package/dist/test/tile-stats.test.js +0 -167
  142. package/dist/test/tile-stats.test.js.map +0 -1
  143. package/dist/test/tiles/grid/account-tile.test.d.ts +0 -1
  144. package/dist/test/tiles/grid/account-tile.test.js +0 -96
  145. package/dist/test/tiles/grid/account-tile.test.js.map +0 -1
  146. package/dist/test/tiles/grid/collection-tile.test.d.ts +0 -1
  147. package/dist/test/tiles/grid/collection-tile.test.js +0 -90
  148. package/dist/test/tiles/grid/collection-tile.test.js.map +0 -1
  149. package/dist/test/tiles/grid/item-tile.test.d.ts +0 -1
  150. package/dist/test/tiles/grid/item-tile.test.js +0 -400
  151. package/dist/test/tiles/grid/item-tile.test.js.map +0 -1
  152. package/dist/test/tiles/grid/search-tile.test.d.ts +0 -1
  153. package/dist/test/tiles/grid/search-tile.test.js +0 -62
  154. package/dist/test/tiles/grid/search-tile.test.js.map +0 -1
  155. package/dist/test/tiles/hover/hover-pane-controller.test.d.ts +0 -1
  156. package/dist/test/tiles/hover/hover-pane-controller.test.js +0 -351
  157. package/dist/test/tiles/hover/hover-pane-controller.test.js.map +0 -1
  158. package/dist/test/tiles/hover/tile-hover-pane.test.d.ts +0 -1
  159. package/dist/test/tiles/hover/tile-hover-pane.test.js +0 -53
  160. package/dist/test/tiles/hover/tile-hover-pane.test.js.map +0 -1
  161. package/dist/test/tiles/list/tile-list-compact-header.test.d.ts +0 -1
  162. package/dist/test/tiles/list/tile-list-compact-header.test.js +0 -36
  163. package/dist/test/tiles/list/tile-list-compact-header.test.js.map +0 -1
  164. package/dist/test/tiles/list/tile-list-compact.test.d.ts +0 -1
  165. package/dist/test/tiles/list/tile-list-compact.test.js +0 -237
  166. package/dist/test/tiles/list/tile-list-compact.test.js.map +0 -1
  167. package/dist/test/tiles/list/tile-list.test.d.ts +0 -1
  168. package/dist/test/tiles/list/tile-list.test.js +0 -460
  169. package/dist/test/tiles/list/tile-list.test.js.map +0 -1
  170. package/dist/test/tiles/tile-dispatcher.test.d.ts +0 -1
  171. package/dist/test/tiles/tile-dispatcher.test.js +0 -246
  172. package/dist/test/tiles/tile-dispatcher.test.js.map +0 -1
  173. package/dist/test/tiles/tile-display-value-provider.test.d.ts +0 -1
  174. package/dist/test/tiles/tile-display-value-provider.test.js +0 -142
  175. package/dist/test/tiles/tile-display-value-provider.test.js.map +0 -1
  176. package/dist/test/tiles/tile-mediatype-icon.test.d.ts +0 -1
  177. package/dist/test/tiles/tile-mediatype-icon.test.js +0 -133
  178. package/dist/test/tiles/tile-mediatype-icon.test.js.map +0 -1
  179. package/dist/test/utils/array-equals.test.d.ts +0 -1
  180. package/dist/test/utils/array-equals.test.js +0 -27
  181. package/dist/test/utils/array-equals.test.js.map +0 -1
  182. package/dist/test/utils/format-count.test.d.ts +0 -1
  183. package/dist/test/utils/format-count.test.js +0 -24
  184. package/dist/test/utils/format-count.test.js.map +0 -1
  185. package/dist/test/utils/format-date.test.d.ts +0 -1
  186. package/dist/test/utils/format-date.test.js +0 -61
  187. package/dist/test/utils/format-date.test.js.map +0 -1
  188. package/dist/test/utils/format-unit-size.test.d.ts +0 -1
  189. package/dist/test/utils/format-unit-size.test.js +0 -18
  190. package/dist/test/utils/format-unit-size.test.js.map +0 -1
  191. package/dist/test/utils/local-date-from-utc.test.d.ts +0 -1
  192. package/dist/test/utils/local-date-from-utc.test.js +0 -27
  193. package/dist/test/utils/local-date-from-utc.test.js.map +0 -1
  194. package/dist/test/utils/normalize-filter-text.test.d.ts +0 -1
  195. package/dist/test/utils/normalize-filter-text.test.js +0 -69
  196. package/dist/test/utils/normalize-filter-text.test.js.map +0 -1
  197. package/docs/design/column-virtualization.md +0 -214
  198. package/eslint.config.mjs +0 -53
  199. package/index.html +0 -24
  200. package/index.ts +0 -29
  201. package/local.archive.org.cert +0 -86
  202. package/local.archive.org.key +0 -27
  203. package/pnpm-workspace.yaml +0 -30
  204. package/renovate.json +0 -6
  205. package/src/app-root.ts +0 -1282
  206. package/src/assets/img/icons/arrow-left.ts +0 -10
  207. package/src/assets/img/icons/arrow-right.ts +0 -10
  208. package/src/assets/img/icons/check.ts +0 -5
  209. package/src/assets/img/icons/chevron.ts +0 -4
  210. package/src/assets/img/icons/close-circle-dark.ts +0 -5
  211. package/src/assets/img/icons/contract.ts +0 -9
  212. package/src/assets/img/icons/empty-query.ts +0 -5
  213. package/src/assets/img/icons/expand.ts +0 -9
  214. package/src/assets/img/icons/eye-closed.ts +0 -5
  215. package/src/assets/img/icons/eye.ts +0 -5
  216. package/src/assets/img/icons/favorite-filled.ts +0 -10
  217. package/src/assets/img/icons/favorite-unfilled.ts +0 -9
  218. package/src/assets/img/icons/filter.ts +0 -10
  219. package/src/assets/img/icons/login-required.ts +0 -18
  220. package/src/assets/img/icons/mediatype/account.ts +0 -14
  221. package/src/assets/img/icons/mediatype/audio.ts +0 -14
  222. package/src/assets/img/icons/mediatype/collection.ts +0 -12
  223. package/src/assets/img/icons/mediatype/data.ts +0 -15
  224. package/src/assets/img/icons/mediatype/etree.ts +0 -14
  225. package/src/assets/img/icons/mediatype/film.ts +0 -14
  226. package/src/assets/img/icons/mediatype/images.ts +0 -13
  227. package/src/assets/img/icons/mediatype/radio.ts +0 -15
  228. package/src/assets/img/icons/mediatype/search.ts +0 -14
  229. package/src/assets/img/icons/mediatype/software.ts +0 -13
  230. package/src/assets/img/icons/mediatype/texts.ts +0 -13
  231. package/src/assets/img/icons/mediatype/tv-commercial.ts +0 -12
  232. package/src/assets/img/icons/mediatype/tv-fact-check.ts +0 -12
  233. package/src/assets/img/icons/mediatype/tv-quote.ts +0 -12
  234. package/src/assets/img/icons/mediatype/tv.ts +0 -14
  235. package/src/assets/img/icons/mediatype/video.ts +0 -14
  236. package/src/assets/img/icons/mediatype/web.ts +0 -13
  237. package/src/assets/img/icons/null-result.ts +0 -5
  238. package/src/assets/img/icons/quote.ts +0 -7
  239. package/src/assets/img/icons/restricted.ts +0 -13
  240. package/src/assets/img/icons/reviews.ts +0 -11
  241. package/src/assets/img/icons/upload.ts +0 -12
  242. package/src/assets/img/icons/views.ts +0 -11
  243. package/src/circular-activity-indicator.ts +0 -64
  244. package/src/collection-browser.ts +0 -3165
  245. package/src/collection-facets/facet-row-template.ts +0 -242
  246. package/src/collection-facets/facet-row.ts +0 -122
  247. package/src/collection-facets/facet-tombstone-row.ts +0 -40
  248. package/src/collection-facets/facets-template.ts +0 -85
  249. package/src/collection-facets/models.ts +0 -16
  250. package/src/collection-facets/more-facets-content.ts +0 -951
  251. package/src/collection-facets/more-facets-scroller.ts +0 -485
  252. package/src/collection-facets/page-window.ts +0 -247
  253. package/src/collection-facets/smart-facets/dedupe.ts +0 -44
  254. package/src/collection-facets/smart-facets/heuristics/browser-language/browser-language-heuristic.ts +0 -27
  255. package/src/collection-facets/smart-facets/heuristics/index.ts +0 -3
  256. package/src/collection-facets/smart-facets/heuristics/query-keywords/query-keywords-heuristic.ts +0 -17
  257. package/src/collection-facets/smart-facets/heuristics/query-keywords/query-keywords-map.ts +0 -70
  258. package/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-entity-map.ts +0 -79
  259. package/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-heuristic.ts +0 -93
  260. package/src/collection-facets/smart-facets/models.ts +0 -36
  261. package/src/collection-facets/smart-facets/smart-facet-bar.ts +0 -437
  262. package/src/collection-facets/smart-facets/smart-facet-button.ts +0 -145
  263. package/src/collection-facets/smart-facets/smart-facet-dropdown.ts +0 -185
  264. package/src/collection-facets/smart-facets/smart-facet-equals.ts +0 -16
  265. package/src/collection-facets/smart-facets/smart-facet-heuristics.ts +0 -26
  266. package/src/collection-facets/toggle-switch.ts +0 -175
  267. package/src/collection-facets.ts +0 -1013
  268. package/src/data-source/collection-browser-data-source-interface.ts +0 -351
  269. package/src/data-source/collection-browser-data-source.ts +0 -1474
  270. package/src/data-source/collection-browser-query-state.ts +0 -60
  271. package/src/data-source/models.ts +0 -56
  272. package/src/empty-placeholder.ts +0 -192
  273. package/src/expanded-date-picker.ts +0 -191
  274. package/src/language-code-handler/language-code-handler.ts +0 -64
  275. package/src/language-code-handler/language-code-mapping.ts +0 -564
  276. package/src/manage/manage-bar.ts +0 -276
  277. package/src/manage/remove-items-modal-content.ts +0 -102
  278. package/src/mediatype/mediatype-config.ts +0 -146
  279. package/src/models.ts +0 -912
  280. package/src/restoration-state-handler.ts +0 -550
  281. package/src/sort-filter-bar/alpha-bar-tooltip.ts +0 -53
  282. package/src/sort-filter-bar/alpha-bar.ts +0 -252
  283. package/src/sort-filter-bar/img/compact.ts +0 -5
  284. package/src/sort-filter-bar/img/list.ts +0 -5
  285. package/src/sort-filter-bar/img/sort-toggle-disabled.ts +0 -15
  286. package/src/sort-filter-bar/img/sort-toggle-down.ts +0 -17
  287. package/src/sort-filter-bar/img/sort-toggle-up.ts +0 -17
  288. package/src/sort-filter-bar/img/sort-triangle.ts +0 -5
  289. package/src/sort-filter-bar/img/tile.ts +0 -5
  290. package/src/sort-filter-bar/sort-filter-bar.ts +0 -733
  291. package/src/styles/ia-button.ts +0 -139
  292. package/src/styles/item-image-styles.ts +0 -124
  293. package/src/styles/sr-only.ts +0 -18
  294. package/src/styles/tile-action-styles.ts +0 -59
  295. package/src/tiles/base-tile-component.ts +0 -124
  296. package/src/tiles/collection-browser-loading-tile.ts +0 -26
  297. package/src/tiles/grid/account-tile.ts +0 -113
  298. package/src/tiles/grid/collection-tile.ts +0 -184
  299. package/src/tiles/grid/item-tile.ts +0 -347
  300. package/src/tiles/grid/search-tile.ts +0 -90
  301. package/src/tiles/grid/styles/tile-grid-shared-styles.ts +0 -130
  302. package/src/tiles/grid/tile-stats.ts +0 -211
  303. package/src/tiles/hover/hover-pane-controller.ts +0 -638
  304. package/src/tiles/hover/tile-hover-pane.ts +0 -184
  305. package/src/tiles/image-block.ts +0 -162
  306. package/src/tiles/item-image.ts +0 -214
  307. package/src/tiles/list/tile-list-compact-header.ts +0 -112
  308. package/src/tiles/list/tile-list-compact.ts +0 -278
  309. package/src/tiles/list/tile-list.ts +0 -718
  310. package/src/tiles/models.ts +0 -21
  311. package/src/tiles/overlay/icon-overlay.ts +0 -57
  312. package/src/tiles/overlay/text-overlay.ts +0 -79
  313. package/src/tiles/review-block.ts +0 -130
  314. package/src/tiles/text-snippet-block.ts +0 -132
  315. package/src/tiles/tile-dispatcher.ts +0 -637
  316. package/src/tiles/tile-display-value-provider.ts +0 -133
  317. package/src/tiles/tile-mediatype-icon.ts +0 -133
  318. package/src/utils/analytics-events.ts +0 -29
  319. package/src/utils/array-equals.ts +0 -8
  320. package/src/utils/collapse-repeated-quotes.ts +0 -13
  321. package/src/utils/date-filter-field.ts +0 -11
  322. package/src/utils/facet-utils.ts +0 -183
  323. package/src/utils/format-count.ts +0 -95
  324. package/src/utils/format-date.ts +0 -62
  325. package/src/utils/format-unit-size.ts +0 -43
  326. package/src/utils/local-date-from-utc.ts +0 -15
  327. package/src/utils/log.ts +0 -14
  328. package/src/utils/normalize-filter-text.ts +0 -54
  329. package/src/utils/resolve-mediatype.ts +0 -26
  330. package/src/utils/sha1.ts +0 -9
  331. package/test/collection-browser.test.ts +0 -2639
  332. package/test/collection-facets/facet-row.test.ts +0 -421
  333. package/test/collection-facets/facets-template.test.ts +0 -139
  334. package/test/collection-facets/more-facets-content.test.ts +0 -716
  335. package/test/collection-facets/more-facets-scroller.test.ts +0 -401
  336. package/test/collection-facets/page-window.test.ts +0 -208
  337. package/test/collection-facets/toggle-switch.test.ts +0 -164
  338. package/test/collection-facets.test.ts +0 -928
  339. package/test/data-source/collection-browser-data-source.test.ts +0 -193
  340. package/test/empty-placeholder.test.ts +0 -88
  341. package/test/expanded-date-picker.test.ts +0 -201
  342. package/test/icon-overlay.test.ts +0 -38
  343. package/test/image-block.test.ts +0 -247
  344. package/test/item-image.test.ts +0 -220
  345. package/test/manage/manage-bar.test.ts +0 -347
  346. package/test/manage/remove-items-modal-content.test.ts +0 -81
  347. package/test/mediatype-config.test.ts +0 -11
  348. package/test/mocks/mock-analytics-handler.ts +0 -30
  349. package/test/mocks/mock-search-responses.ts +0 -1420
  350. package/test/mocks/mock-search-service.ts +0 -136
  351. package/test/restoration-state-handler.test.ts +0 -480
  352. package/test/review-block.test.ts +0 -62
  353. package/test/sort-filter-bar/alpha-bar-tooltip.test.ts +0 -17
  354. package/test/sort-filter-bar/alpha-bar.test.ts +0 -101
  355. package/test/sort-filter-bar/sort-filter-bar.test.ts +0 -443
  356. package/test/text-overlay.test.ts +0 -55
  357. package/test/text-snippet-block.test.ts +0 -85
  358. package/test/tile-stats.test.ts +0 -191
  359. package/test/tiles/grid/account-tile.test.ts +0 -121
  360. package/test/tiles/grid/collection-tile.test.ts +0 -114
  361. package/test/tiles/grid/item-tile.test.ts +0 -520
  362. package/test/tiles/grid/search-tile.test.ts +0 -75
  363. package/test/tiles/hover/hover-pane-controller.test.ts +0 -482
  364. package/test/tiles/hover/tile-hover-pane.test.ts +0 -80
  365. package/test/tiles/list/tile-list-compact-header.test.ts +0 -43
  366. package/test/tiles/list/tile-list-compact.test.ts +0 -282
  367. package/test/tiles/list/tile-list.test.ts +0 -576
  368. package/test/tiles/tile-dispatcher.test.ts +0 -320
  369. package/test/tiles/tile-display-value-provider.test.ts +0 -172
  370. package/test/tiles/tile-mediatype-icon.test.ts +0 -160
  371. package/test/utils/array-equals.test.ts +0 -31
  372. package/test/utils/format-count.test.ts +0 -32
  373. package/test/utils/format-date.test.ts +0 -89
  374. package/test/utils/format-unit-size.test.ts +0 -21
  375. package/test/utils/local-date-from-utc.test.ts +0 -37
  376. package/test/utils/normalize-filter-text.test.ts +0 -87
  377. package/tsconfig.json +0 -25
  378. package/types/dompurify.d.ts +0 -1
  379. package/vite.config.ts +0 -29
  380. package/web-dev-server.config.mjs +0 -30
  381. package/web-test-runner.config.mjs +0 -57
package/src/models.ts DELETED
@@ -1,912 +0,0 @@
1
- import type { TemplateResult } from 'lit';
2
- import { msg } from '@lit/localize';
3
- import type { MediaType } from '@internetarchive/field-parsers';
4
- import {
5
- AggregationSortType,
6
- HitType,
7
- SearchReview,
8
- SearchResult,
9
- SortDirection,
10
- } from '@internetarchive/search-service';
11
- import { collapseRepeatedQuotes } from './utils/collapse-repeated-quotes';
12
- import { resolveMediatype } from './utils/resolve-mediatype';
13
-
14
- import { loginRequiredIcon } from './assets/img/icons/login-required';
15
- import { restrictedIcon } from './assets/img/icons/restricted';
16
-
17
- /**
18
- * Flags that can affect the visibility of content on a tile
19
- */
20
- interface TileFlags {
21
- loginRequired: boolean;
22
- contentWarning: boolean;
23
- }
24
-
25
- /**
26
- * Different types of tile overlays, corresponding to the above flags.
27
- */
28
- export type TileOverlayType = 'login-required' | 'content-warning';
29
-
30
- export const TILE_OVERLAY_TEXT: Record<TileOverlayType, string> = {
31
- 'login-required': msg('Log in to view this item'),
32
- 'content-warning': msg('Content may be inappropriate'),
33
- };
34
-
35
- export const TILE_OVERLAY_ICONS: Record<TileOverlayType, TemplateResult> = {
36
- 'login-required': loginRequiredIcon,
37
- 'content-warning': restrictedIcon,
38
- };
39
-
40
- /**
41
- * What type of request produced a given set of hits:
42
- * - `search_query`: Hits produced by an explicit user query and/or applied filters on any page
43
- * - `collection_members`: Hits produced for a collection page without any query or filters
44
- * - `profile_tab`: Hits produced for a tab of the profile page without any query or filters
45
- * - `unknown`: Hits produced via any other means
46
- */
47
- export type HitRequestSource =
48
- | 'search_query'
49
- | 'collection_members'
50
- | 'profile_tab'
51
- | 'unknown';
52
-
53
- /**
54
- * Class for converting & storing raw search results in the correct format for UI tiles.
55
- */
56
- export class TileModel {
57
- /** For TV hits. List of identifiers for any commercials contained. */
58
- adIds?: string[];
59
-
60
- averageRating?: number;
61
-
62
- /** For Web Archive hits on profile pages. List of capture dates for the current URL. */
63
- captureDates?: Date[];
64
-
65
- /** Whether this tile is currently checked for item management functions */
66
- checked: boolean;
67
-
68
- collectionIdentifier?: string;
69
-
70
- collectionName?: string;
71
-
72
- collectionFilesCount: number;
73
-
74
- collections: string[];
75
-
76
- collectionSize: number;
77
-
78
- commentCount: number;
79
-
80
- creator?: string;
81
-
82
- creators: string[];
83
-
84
- /** A string representation of the publication date, used strictly for passing preformatted dates to the parent */
85
- dateStr?: string;
86
-
87
- /** Date added to public search (software-defined) [from MD field: addeddate] */
88
- dateAdded?: Date;
89
-
90
- /** Date archived (software-defined) item created on archive.org [from MD field: publicdate] */
91
- dateArchived?: Date;
92
-
93
- /** Date work published in the world (user-defined) [from MD field: date] */
94
- datePublished?: Date;
95
-
96
- /** Date reviewed (user-created) most recent review [from MD field: reviewdate] */
97
- dateReviewed?: Date;
98
-
99
- description?: string;
100
-
101
- /** For TV hits. List of URLs for any fact-checks of the contained clips. */
102
- factChecks?: string[];
103
-
104
- favCount: number;
105
-
106
- hitRequestSource: HitRequestSource;
107
-
108
- hitType?: HitType;
109
-
110
- href?: string;
111
-
112
- identifier?: string;
113
-
114
- /** Whether this model represents a TV clip */
115
- isClip?: boolean;
116
-
117
- issue?: string;
118
-
119
- itemCount: number;
120
-
121
- mediatype: MediaType;
122
-
123
- review?: SearchReview;
124
-
125
- source?: string;
126
-
127
- snippets?: string[];
128
-
129
- subjects: string[];
130
-
131
- thumbnailUrl?: string;
132
-
133
- title: string;
134
-
135
- tvClipCount?: number;
136
-
137
- viewCount?: number;
138
-
139
- volume?: string;
140
-
141
- weeklyViewCount?: number;
142
-
143
- loginRequired: boolean;
144
-
145
- contentWarning: boolean;
146
-
147
- constructor(
148
- result: SearchResult,
149
- hitRequestSource: HitRequestSource = 'unknown',
150
- ) {
151
- const flags = this.getFlags(result);
152
-
153
- this.adIds = result.ad_id?.values;
154
- this.averageRating = result.avg_rating?.value;
155
- this.captureDates = result.capture_dates?.values;
156
- this.checked = false;
157
- this.collections = result.collection?.values ?? [];
158
- this.collectionFilesCount = result.collection_files_count?.value ?? 0;
159
- this.collectionSize = result.collection_size?.value ?? 0;
160
- this.commentCount = result.num_reviews?.value ?? 0;
161
- this.creator = result.creator?.value;
162
- this.creators = result.creator?.values ?? [];
163
- this.dateAdded = result.addeddate?.value;
164
- this.dateArchived = result.publicdate?.value;
165
- this.datePublished = result.date?.value;
166
- this.dateReviewed = result.reviewdate?.value;
167
- this.description = result.description?.values.join('\n');
168
- this.factChecks = result.factcheck?.values;
169
- this.favCount = result.num_favorites?.value ?? 0;
170
- this.hitRequestSource = hitRequestSource;
171
- this.hitType = result.rawMetadata?.hit_type;
172
- this.href = collapseRepeatedQuotes(
173
- result.review?.__href__ ?? result.__href__?.value,
174
- );
175
- this.identifier = TileModel.cleanIdentifier(result.identifier);
176
- this.isClip = result.is_clip?.value;
177
- this.issue = result.issue?.value;
178
- this.itemCount = result.item_count?.value ?? 0;
179
- this.mediatype = resolveMediatype(result);
180
- this.review = result.review;
181
- this.snippets = result.highlight?.values ?? [];
182
- this.source = result.source?.value;
183
- this.subjects = result.subject?.values ?? [];
184
- this.thumbnailUrl = result.__img__?.value;
185
- this.title = result.title?.value ?? '';
186
- this.tvClipCount = result.num_clips?.value ?? 0;
187
- this.volume = result.volume?.value;
188
- this.viewCount = result.downloads?.value;
189
- this.weeklyViewCount = result.week?.value;
190
- this.loginRequired = flags.loginRequired;
191
- this.contentWarning = flags.contentWarning;
192
- }
193
-
194
- /**
195
- * Copies the contents of this TileModel onto a new instance
196
- */
197
- clone(): TileModel {
198
- const cloned = new TileModel({});
199
- cloned.adIds = this.adIds;
200
- cloned.averageRating = this.averageRating;
201
- cloned.captureDates = this.captureDates;
202
- cloned.checked = this.checked;
203
- cloned.collections = this.collections;
204
- cloned.collectionFilesCount = this.collectionFilesCount;
205
- cloned.collectionSize = this.collectionSize;
206
- cloned.commentCount = this.commentCount;
207
- cloned.creator = this.creator;
208
- cloned.creators = this.creators;
209
- cloned.dateStr = this.dateStr;
210
- cloned.dateAdded = this.dateAdded;
211
- cloned.dateArchived = this.dateArchived;
212
- cloned.datePublished = this.datePublished;
213
- cloned.dateReviewed = this.dateReviewed;
214
- cloned.description = this.description;
215
- cloned.factChecks = this.factChecks;
216
- cloned.favCount = this.favCount;
217
- cloned.hitRequestSource = this.hitRequestSource;
218
- cloned.hitType = this.hitType;
219
- cloned.href = this.href;
220
- cloned.identifier = this.identifier;
221
- cloned.isClip = this.isClip;
222
- cloned.issue = this.issue;
223
- cloned.itemCount = this.itemCount;
224
- cloned.mediatype = this.mediatype;
225
- cloned.snippets = this.snippets;
226
- cloned.source = this.source;
227
- cloned.subjects = this.subjects;
228
- cloned.thumbnailUrl = this.thumbnailUrl;
229
- cloned.title = this.title;
230
- cloned.tvClipCount = this.tvClipCount;
231
- cloned.volume = this.volume;
232
- cloned.viewCount = this.viewCount;
233
- cloned.weeklyViewCount = this.weeklyViewCount;
234
- cloned.loginRequired = this.loginRequired;
235
- cloned.contentWarning = this.contentWarning;
236
- return cloned;
237
- }
238
-
239
- /**
240
- * Whether this model represents the result of a TV search query.
241
- */
242
- get isTvSearchResult(): boolean {
243
- return (
244
- this.hitType === 'tv_clip' && this.hitRequestSource === 'search_query'
245
- );
246
- }
247
-
248
- /**
249
- * Determines the appropriate tile flags for the given search result
250
- * (login required and/or content warning)
251
- */
252
- private getFlags(result: SearchResult): TileFlags {
253
- const flags: TileFlags = {
254
- loginRequired: false,
255
- contentWarning: false,
256
- };
257
-
258
- // Check if item and item in "modifying" collection, setting above flags
259
- if (
260
- result.collection?.values.length &&
261
- result.mediatype?.value !== 'collection'
262
- ) {
263
- for (const collection of result.collection?.values ?? []) {
264
- if (collection === 'loggedin') {
265
- flags.loginRequired = true;
266
- if (flags.contentWarning) break;
267
- }
268
- if (collection === 'no-preview') {
269
- flags.contentWarning = true;
270
- if (flags.loginRequired) break;
271
- }
272
- }
273
- }
274
-
275
- return flags;
276
- }
277
-
278
- private static cleanIdentifier(
279
- identifier: string | undefined,
280
- ): string | undefined {
281
- // Some identifiers (e.g., from Whisper) represent documents rather than items, and
282
- // are suffixed with values that need to be stripped. Those values are separated
283
- // from the item identifier itself with '|'.
284
- const barIndex = identifier?.indexOf('|') ?? -1;
285
- const cleaned = barIndex > 0 ? identifier?.slice(0, barIndex) : identifier;
286
- return cleaned;
287
- }
288
- }
289
-
290
- export type RequestKind = 'full' | 'hits' | 'aggregations';
291
-
292
- export type CollectionDisplayMode = 'grid' | 'list-compact' | 'list-detail';
293
-
294
- export type TileDisplayMode =
295
- | 'grid'
296
- | 'list-compact'
297
- | 'list-detail'
298
- | 'list-header';
299
-
300
- /**
301
- * This is mainly used to set the cookies for the collection display mode.
302
- *
303
- * It allows the user to set different modes for different contexts (collection page, search page, profile page etc).
304
- */
305
- export type CollectionBrowserContext = 'collection' | 'search' | 'profile';
306
-
307
- /**
308
- * The sort fields shown in the sort filter bar
309
- */
310
- export enum SortField {
311
- 'default' = 'default',
312
- 'unrecognized' = 'unrecognized',
313
- 'relevance' = 'relevance',
314
- 'alltimeview' = 'alltimeview',
315
- 'weeklyview' = 'weeklyview',
316
- 'title' = 'title',
317
- 'date' = 'date',
318
- 'datearchived' = 'datearchived',
319
- 'datereviewed' = 'datereviewed',
320
- 'dateadded' = 'dateadded',
321
- 'datefavorited' = 'datefavorited',
322
- 'creator' = 'creator',
323
- }
324
-
325
- /**
326
- * Views-related sort fields
327
- */
328
- export const ALL_VIEWS_SORT_FIELDS = [
329
- SortField.weeklyview,
330
- SortField.alltimeview,
331
- ] as const;
332
- export type ViewsSortField = (typeof ALL_VIEWS_SORT_FIELDS)[number];
333
-
334
- /**
335
- * Date-related sort fields
336
- */
337
- export const ALL_DATE_SORT_FIELDS = [
338
- SortField.datefavorited,
339
- SortField.date,
340
- SortField.datearchived,
341
- SortField.datereviewed,
342
- SortField.dateadded,
343
- ] as const;
344
- export type DateSortField = (typeof ALL_DATE_SORT_FIELDS)[number];
345
-
346
- export interface SortOption {
347
- /**
348
- * The SortField enum member corresponding to this option.
349
- */
350
- field: SortField;
351
-
352
- /**
353
- * The default sort direction to apply when this sort option is first selected.
354
- */
355
- defaultSortDirection: SortDirection | null;
356
-
357
- /**
358
- * Whether this sort option allows its sort direction to be changed from the default.
359
- */
360
- canSetDirection: boolean;
361
-
362
- /**
363
- * Whether this sort option may appear in the sort bar.
364
- */
365
- shownInSortBar: boolean;
366
-
367
- /**
368
- * Whether this sort option should be saved to the URL.
369
- * If false, then no `sort` param will be added to the URL when this sort option
370
- * is selected.
371
- */
372
- shownInURL: boolean;
373
-
374
- /**
375
- * Whether this sort option is passed to the search service.
376
- * If false, then no sort param will be passed to the search service at all when
377
- * this sort option is selected.
378
- */
379
- handledBySearchService: boolean;
380
-
381
- /**
382
- * The string identifying this sort field to the search service & backend API.
383
- */
384
- searchServiceKey?: string;
385
-
386
- /**
387
- * The human-readable name to use for this option in the sort bar (if applicable).
388
- */
389
- displayName: string;
390
-
391
- /**
392
- * A list of URL param keys that should be mapped to this sort option.
393
- * E.g., both `title` and `titleSorter` in the URL map to the `SortField.title` option.
394
- */
395
- urlNames: (string | null | undefined)[];
396
- }
397
-
398
- export const SORT_OPTIONS: Record<SortField, SortOption> = {
399
- // Default sort is the case where the user has not specified a sort option via the sort bar or URL.
400
- // In these cases, we defer to whatever sort the backend chooses.
401
- // For the search page, the default is always relevance sort.
402
- // For collection pages _without a query_, the default is usually weekly views, but this can be
403
- // overridden by the collection's `sort-by` metadata entry. If a query _is_ specified, then the
404
- // default is again relevance sort.
405
- // For fav-* collections only, the default is instead sorting by date favorited.
406
- [SortField.default]: {
407
- field: SortField.default,
408
- defaultSortDirection: null,
409
- canSetDirection: false,
410
- shownInSortBar: false,
411
- shownInURL: false,
412
- handledBySearchService: false, // We rely on the PPS default sort handling in these cases
413
- displayName: '',
414
- urlNames: ['', null, undefined], // Empty or nullish sort params result in default sorting
415
- },
416
- // Unrecognized sort is the case where the user has specified a sort in the URL, but it is not
417
- // one of the options listed in this map. We still want these unrecognized sorts to be applied
418
- // when searching, but they are not displayed in the sort bar and we do not actively manage
419
- // their URL param beyond flipping the direction as needed.
420
- [SortField.unrecognized]: {
421
- field: SortField.unrecognized,
422
- defaultSortDirection: null,
423
- canSetDirection: true,
424
- shownInSortBar: false,
425
- shownInURL: false,
426
- handledBySearchService: true, // The unrecognized sort param is passed along as-is
427
- displayName: '',
428
- urlNames: [],
429
- },
430
- // Relevance sort is unique in that it does not produce a URL param when it is set.
431
- // It is only available when there is a user-specified query that relevancy can be scored against.
432
- // Therefore, it does not appear as a sort bar option when browsing a collection with no query set.
433
- [SortField.relevance]: {
434
- field: SortField.relevance,
435
- defaultSortDirection: null,
436
- canSetDirection: false,
437
- shownInSortBar: true,
438
- shownInURL: false,
439
- handledBySearchService: false,
440
- displayName: 'Relevance',
441
- urlNames: ['_score'],
442
- },
443
- [SortField.alltimeview]: {
444
- field: SortField.alltimeview,
445
- defaultSortDirection: 'desc',
446
- canSetDirection: true,
447
- shownInSortBar: true,
448
- shownInURL: true,
449
- handledBySearchService: true,
450
- searchServiceKey: 'downloads',
451
- displayName: 'All-time views',
452
- urlNames: ['downloads'],
453
- },
454
- [SortField.weeklyview]: {
455
- field: SortField.weeklyview,
456
- defaultSortDirection: 'desc',
457
- canSetDirection: true,
458
- shownInSortBar: true,
459
- shownInURL: true,
460
- handledBySearchService: true,
461
- searchServiceKey: 'week',
462
- displayName: 'Weekly views',
463
- urlNames: ['week'],
464
- },
465
- [SortField.title]: {
466
- field: SortField.title,
467
- defaultSortDirection: 'asc',
468
- canSetDirection: true,
469
- shownInSortBar: true,
470
- shownInURL: true,
471
- handledBySearchService: true,
472
- searchServiceKey: 'titleSorter',
473
- displayName: 'Title',
474
- urlNames: ['title', 'titleSorter'],
475
- },
476
- [SortField.date]: {
477
- field: SortField.date,
478
- defaultSortDirection: 'desc',
479
- canSetDirection: true,
480
- shownInSortBar: true,
481
- shownInURL: true,
482
- handledBySearchService: true,
483
- searchServiceKey: 'date',
484
- displayName: 'Date published',
485
- urlNames: ['date'],
486
- },
487
- [SortField.datearchived]: {
488
- field: SortField.datearchived,
489
- defaultSortDirection: 'desc',
490
- canSetDirection: true,
491
- shownInSortBar: true,
492
- shownInURL: true,
493
- handledBySearchService: true,
494
- searchServiceKey: 'publicdate',
495
- displayName: 'Date archived',
496
- urlNames: ['publicdate'],
497
- },
498
- [SortField.datereviewed]: {
499
- field: SortField.datereviewed,
500
- defaultSortDirection: 'desc',
501
- canSetDirection: true,
502
- shownInSortBar: true,
503
- shownInURL: true,
504
- handledBySearchService: true,
505
- searchServiceKey: 'reviewdate',
506
- displayName: 'Date reviewed',
507
- urlNames: ['reviewdate'],
508
- },
509
- [SortField.dateadded]: {
510
- field: SortField.dateadded,
511
- defaultSortDirection: 'desc',
512
- canSetDirection: true,
513
- shownInSortBar: true,
514
- shownInURL: true,
515
- handledBySearchService: true,
516
- searchServiceKey: 'addeddate',
517
- displayName: 'Date added',
518
- urlNames: ['addeddate'],
519
- },
520
- [SortField.datefavorited]: {
521
- field: SortField.datefavorited,
522
- defaultSortDirection: 'desc',
523
- canSetDirection: false,
524
- shownInSortBar: true, // But only when viewing fav-* collections
525
- shownInURL: false,
526
- handledBySearchService: false,
527
- searchServiceKey: 'favoritedate',
528
- displayName: 'Date favorited',
529
- urlNames: ['favoritedate'],
530
- },
531
- [SortField.creator]: {
532
- field: SortField.creator,
533
- defaultSortDirection: 'asc',
534
- canSetDirection: true,
535
- shownInSortBar: true,
536
- shownInURL: true,
537
- handledBySearchService: true,
538
- searchServiceKey: 'creatorSorter',
539
- displayName: 'Creator',
540
- urlNames: ['creator', 'creatorSorter'],
541
- },
542
- };
543
-
544
- /**
545
- * Returns the SortOption corresponding to the given API sort name, or
546
- * the "unrecognized" SortOption if none matches.
547
- */
548
- export function sortOptionFromAPIString(sortName?: string | null): SortOption {
549
- return (
550
- Object.values(SORT_OPTIONS).find(opt =>
551
- opt.urlNames.some(name => sortName === name),
552
- ) ?? SORT_OPTIONS[SortField.unrecognized]
553
- );
554
- }
555
-
556
- export const defaultSortAvailability: Record<SortField, boolean> = {
557
- [SortField.relevance]: true,
558
- [SortField.weeklyview]: true,
559
- [SortField.alltimeview]: true,
560
- [SortField.title]: true,
561
- [SortField.datefavorited]: false,
562
- [SortField.date]: true,
563
- [SortField.datearchived]: true,
564
- [SortField.datereviewed]: true,
565
- [SortField.dateadded]: true,
566
- [SortField.creator]: true,
567
- [SortField.default]: false,
568
- [SortField.unrecognized]: false,
569
- };
570
-
571
- export const favoritesSortAvailability: Record<SortField, boolean> = {
572
- ...defaultSortAvailability,
573
- [SortField.datefavorited]: true,
574
- };
575
-
576
- export const tvSortAvailability: Record<SortField, boolean> = {
577
- ...defaultSortAvailability,
578
- [SortField.date]: false,
579
- [SortField.datereviewed]: false,
580
- [SortField.dateadded]: false,
581
- };
582
-
583
- export const defaultProfileElementSorts: Record<
584
- string,
585
- Exclude<SortField, SortField.default>
586
- > = {
587
- uploads: SortField.datearchived,
588
- reviews: SortField.datereviewed,
589
- collections: SortField.datearchived,
590
- web_archives: SortField.datearchived,
591
- favorites: SortField.datefavorited,
592
- };
593
-
594
- /** A union of the fields that permit prefix filtering (e.g., alphabetical filtering) */
595
- export type PrefixFilterType = 'title' | 'creator';
596
-
597
- /** A map from prefixes (e.g., initial letters) to the number of items matching that prefix */
598
- export type PrefixFilterCounts = Record<string, number>;
599
-
600
- /**
601
- * A map from prefix filter types to the corresponding aggregation keys
602
- * that are needed to fetch the filter counts from the backend.
603
- */
604
- export const prefixFilterAggregationKeys: Record<PrefixFilterType, string> = {
605
- title: 'firstTitle',
606
- creator: 'firstCreator',
607
- };
608
-
609
- /**
610
- * Different facet loading strategies that can be used with collection browser.
611
- * - `eager`: Facet data is always loaded as soon as a search is performed
612
- * - `lazy-mobile`: In the desktop layout, functions exactly as `eager`.
613
- * In the mobile layout, facet data will only be loaded once the "Filters" accordion is opened.
614
- * - `opt-in-or-login`: Same as `opt-in` for guest users not logged into an account, but same as `eager` for
615
- * any logged in user.
616
- * - `opt-in`: In the desktop layout, facet data will only be loaded after the user presses a "Load Facets" button.
617
- * In the mobile layout, functions exactly as `lazy-mobile`.
618
- * - `off`: Facet data will never be loaded, and a message will be displayed in place of facets
619
- * indicating that they are unavailable.
620
- */
621
- export type FacetLoadStrategy =
622
- | 'eager'
623
- | 'lazy-mobile'
624
- | 'opt-in-or-login'
625
- | 'opt-in'
626
- | 'off';
627
-
628
- /**
629
- * Union of the facet types that are available in the sidebar.
630
- */
631
- export type FacetOption =
632
- | 'subject'
633
- | 'lending'
634
- | 'mediatype'
635
- | 'language'
636
- | 'creator'
637
- | 'collection'
638
- | 'year'
639
- // TV-specific facet options:
640
- | 'clip_type'
641
- | 'program'
642
- | 'person'
643
- | 'sponsor';
644
-
645
- export type SelectedFacetState = 'selected' | 'hidden';
646
-
647
- export type FacetState = SelectedFacetState | 'none';
648
-
649
- export interface FacetBucket {
650
- key: string;
651
- count: number;
652
- state: FacetState;
653
- // for some facets, we augment the key with a display value
654
- displayText?: string;
655
- // for TV channel facets, we add a parenthesized secondary name
656
- extraNote?: string;
657
- }
658
-
659
- export interface FacetGroup {
660
- title: string;
661
- key: FacetOption;
662
- buckets: FacetBucket[];
663
- }
664
-
665
- /**
666
- * Information about a user interaction event on a facet.
667
- */
668
- export type FacetEventDetails = {
669
- /**
670
- * The type of facet that was interacted with (e.g., 'mediatype', 'language', ...).
671
- */
672
- facetType: FacetOption;
673
- /**
674
- * The bucket corresponding to the facet that was interacted with, including the
675
- * updated state of the facet after the interaction.
676
- */
677
- bucket: FacetBucket;
678
- /**
679
- * Whether the interaction occurred on a negative facet.
680
- */
681
- negative: boolean;
682
- };
683
-
684
- export type FacetValue = string;
685
-
686
- export type SelectedFacets = Partial<
687
- Record<FacetOption, Record<FacetValue, FacetBucket>>
688
- >;
689
-
690
- export const getDefaultSelectedFacets = (): Required<SelectedFacets> => ({
691
- subject: {},
692
- lending: {},
693
- mediatype: {},
694
- language: {},
695
- creator: {},
696
- collection: {},
697
- year: {},
698
- clip_type: {},
699
- program: {},
700
- person: {},
701
- sponsor: {},
702
- });
703
-
704
- /**
705
- * For TV search results, what types of TV clips to restrict the results to.
706
- */
707
- export type TvClipFilterType = 'commercial' | 'fact check' | 'quote';
708
-
709
- /**
710
- * Map from allowed TV filtering parameters in the URL to their corresponding filter type
711
- */
712
- export const tvClipURLParamsToFilters: Record<string, TvClipFilterType> = {
713
- only_commercials: 'commercial',
714
- only_factchecks: 'fact check',
715
- only_quotes: 'quote',
716
- };
717
-
718
- /**
719
- * Facet display order when presenting results for all search types *except* TV (see below).
720
- */
721
- export const defaultFacetDisplayOrder: FacetOption[] = [
722
- 'mediatype',
723
- // 'lending', Commenting this out removes the lending facet from the sidebar for now
724
- 'year',
725
- 'subject',
726
- 'collection',
727
- 'creator',
728
- 'language',
729
- ];
730
-
731
- /**
732
- * Specialized facet ordering when displaying TV search results
733
- */
734
- export const tvFacetDisplayOrder: FacetOption[] = [
735
- 'program',
736
- 'creator',
737
- 'year',
738
- 'subject',
739
- // 'person', Omitting the Person facet group for now, though it may be re-added later with new semantics
740
- 'language',
741
- 'clip_type',
742
- ];
743
-
744
- /**
745
- * Human-readable titles for each facet group.
746
- */
747
- export const facetTitles: Record<FacetOption, string> = {
748
- subject: 'Subject',
749
- lending: 'Availability',
750
- mediatype: 'Media Type',
751
- language: 'Language',
752
- creator: 'Creator',
753
- collection: 'Collection',
754
- year: 'Year',
755
- clip_type: 'Clip Type',
756
- program: 'Program',
757
- person: 'Person',
758
- sponsor: 'Sponsor',
759
- };
760
-
761
- /**
762
- * Human-readable plural titles for each facet group, for referring to its values.
763
- */
764
- export const facetPluralTitles: Record<FacetOption, string> = {
765
- subject: 'Subjects',
766
- lending: 'Availability',
767
- mediatype: 'Media Types',
768
- language: 'Languages',
769
- creator: 'Creators',
770
- collection: 'Collections',
771
- year: 'Years',
772
- clip_type: 'Clip Types',
773
- program: 'Programs',
774
- person: 'People',
775
- sponsor: 'Sponsors',
776
- };
777
-
778
- /**
779
- * The default sort type to use for each facet type
780
- */
781
- export const defaultFacetSort: Record<FacetOption, AggregationSortType> = {
782
- subject: AggregationSortType.COUNT,
783
- lending: AggregationSortType.COUNT,
784
- mediatype: AggregationSortType.COUNT,
785
- language: AggregationSortType.COUNT,
786
- creator: AggregationSortType.COUNT,
787
- collection: AggregationSortType.COUNT,
788
- year: AggregationSortType.NUMERIC, // Year facets are ordered by their numeric value by default
789
- clip_type: AggregationSortType.COUNT,
790
- program: AggregationSortType.COUNT,
791
- person: AggregationSortType.COUNT,
792
- sponsor: AggregationSortType.COUNT,
793
- };
794
-
795
- /**
796
- * The default sort type to use for each facet type in TV search More... dialogs only
797
- */
798
- export const tvMoreFacetSort: Record<FacetOption, AggregationSortType> = {
799
- ...defaultFacetSort,
800
- creator: AggregationSortType.ALPHABETICAL,
801
- program: AggregationSortType.ALPHABETICAL,
802
- };
803
-
804
- /**
805
- * The sort type corresponding to facet bucket values, for each facet type
806
- * (i.e., the opposite of "sort by count" for that type).
807
- */
808
- export const valueFacetSort: Record<FacetOption, AggregationSortType> = {
809
- subject: AggregationSortType.ALPHABETICAL,
810
- lending: AggregationSortType.ALPHABETICAL,
811
- mediatype: AggregationSortType.ALPHABETICAL,
812
- language: AggregationSortType.ALPHABETICAL,
813
- creator: AggregationSortType.ALPHABETICAL,
814
- collection: AggregationSortType.ALPHABETICAL,
815
- year: AggregationSortType.NUMERIC, // Year facets' values should be compared numerically, not lexicographically (year 2001 > year 3)
816
- clip_type: AggregationSortType.ALPHABETICAL,
817
- program: AggregationSortType.ALPHABETICAL,
818
- person: AggregationSortType.ALPHABETICAL,
819
- sponsor: AggregationSortType.ALPHABETICAL,
820
- };
821
-
822
- export type LendingFacetKey =
823
- | 'is_lendable'
824
- | 'is_borrowable'
825
- | 'available_to_borrow'
826
- | 'is_browsable'
827
- | 'available_to_browse'
828
- | 'is_readable'
829
- | 'available_to_waitlist';
830
-
831
- /**
832
- * Maps valid lending keys to whether they should be visible in the facet sidebar
833
- */
834
- export const lendingFacetKeysVisibility: Record<LendingFacetKey, boolean> = {
835
- is_lendable: true,
836
- is_borrowable: false,
837
- available_to_borrow: true,
838
- is_browsable: false,
839
- available_to_browse: false,
840
- is_readable: true,
841
- available_to_waitlist: false,
842
- };
843
-
844
- /**
845
- * Most facet options allow any string as keys, while some others can only take on a
846
- * limited set of strings. This type just defines those restrictions for the specific
847
- * facet types where they apply.
848
- */
849
- export type AllowedFacetKey<T extends FacetOption> = T extends 'lending'
850
- ? LendingFacetKey
851
- : T extends 'clip_type'
852
- ? TvClipFilterType
853
- : string;
854
-
855
- /**
856
- * A type mapping FacetOptions to objects that define custom display names for some
857
- * or all of their valid keys.
858
- */
859
- export type FacetDisplayNameMap = {
860
- [K in FacetOption]?: Partial<Record<AllowedFacetKey<K>, string>>;
861
- };
862
-
863
- export const customFacetDisplayNames: FacetDisplayNameMap = {
864
- lending: {
865
- is_lendable: 'Lending Library',
866
- available_to_borrow: 'Borrow 14 Days',
867
- is_readable: 'Always Available',
868
- },
869
- clip_type: {
870
- quote: 'Quote',
871
- commercial: 'Political Ad',
872
- 'fact check': 'Fact Check',
873
- },
874
- };
875
-
876
- /**
877
- * A record of which admin-only collections should be suppressed from being displayed
878
- * as facets or in an item's list of collections.
879
- */
880
- export const suppressedCollections: Record<string, boolean> = {
881
- deemphasize: true,
882
- community: true,
883
- stream_only: true,
884
- samples_only: true,
885
- test_collection: true,
886
- printdisabled: true,
887
- 'openlibrary-ol': true,
888
- nationalemergencylibrary: true,
889
- china: true,
890
- americana: true,
891
- toronto: true,
892
- };
893
-
894
- /**
895
- * A record of manageable item
896
- */
897
- export interface ManageableItem {
898
- identifier: string;
899
- title?: string;
900
- dateStr?: string;
901
- date?: string;
902
- }
903
-
904
- /**
905
- * Possible states for whether & how the user has overridden their user preference
906
- * for blurring behavior on tiles with sensitive content.
907
- * - `no-override`: The user has not overridden their user preference, so simply
908
- * respect the preference as given.
909
- * - `on`: The user has overridden their preference and wants tile blurring enabled.
910
- * - `off`: The user has overridden their preference and wants tile blurring disabled.
911
- */
912
- export type TileBlurOverrideState = 'no-override' | 'on' | 'off';