@internetarchive/collection-browser 4.8.0 → 4.8.1-alpha-webdev9189.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 (336) hide show
  1. package/dist/src/collection-browser.js +27 -2
  2. package/dist/src/collection-browser.js.map +1 -1
  3. package/dist/src/sort-filter-bar/sort-filter-bar.js +38 -20
  4. package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
  5. package/dist/src/utils/log.d.ts +4 -1
  6. package/package.json +5 -1
  7. package/.editorconfig +0 -29
  8. package/.github/workflows/ci.yml +0 -29
  9. package/.github/workflows/gh-pages-main.yml +0 -41
  10. package/.github/workflows/npm-publish.yml +0 -42
  11. package/.github/workflows/pr-preview.yml +0 -40
  12. package/.husky/pre-commit +0 -1
  13. package/.prettierignore +0 -1
  14. package/dist/test/collection-browser.test.d.ts +0 -1
  15. package/dist/test/collection-browser.test.js +0 -1815
  16. package/dist/test/collection-browser.test.js.map +0 -1
  17. package/dist/test/collection-facets/facet-row.test.d.ts +0 -1
  18. package/dist/test/collection-facets/facet-row.test.js +0 -291
  19. package/dist/test/collection-facets/facet-row.test.js.map +0 -1
  20. package/dist/test/collection-facets/facets-template.test.d.ts +0 -1
  21. package/dist/test/collection-facets/facets-template.test.js +0 -95
  22. package/dist/test/collection-facets/facets-template.test.js.map +0 -1
  23. package/dist/test/collection-facets/more-facets-content.test.d.ts +0 -1
  24. package/dist/test/collection-facets/more-facets-content.test.js +0 -509
  25. package/dist/test/collection-facets/more-facets-content.test.js.map +0 -1
  26. package/dist/test/collection-facets/more-facets-scroller.test.d.ts +0 -1
  27. package/dist/test/collection-facets/more-facets-scroller.test.js +0 -288
  28. package/dist/test/collection-facets/more-facets-scroller.test.js.map +0 -1
  29. package/dist/test/collection-facets/page-window.test.d.ts +0 -1
  30. package/dist/test/collection-facets/page-window.test.js +0 -175
  31. package/dist/test/collection-facets/page-window.test.js.map +0 -1
  32. package/dist/test/collection-facets/toggle-switch.test.d.ts +0 -1
  33. package/dist/test/collection-facets/toggle-switch.test.js +0 -99
  34. package/dist/test/collection-facets/toggle-switch.test.js.map +0 -1
  35. package/dist/test/collection-facets.test.d.ts +0 -2
  36. package/dist/test/collection-facets.test.js +0 -728
  37. package/dist/test/collection-facets.test.js.map +0 -1
  38. package/dist/test/data-source/collection-browser-data-source.test.d.ts +0 -1
  39. package/dist/test/data-source/collection-browser-data-source.test.js +0 -154
  40. package/dist/test/data-source/collection-browser-data-source.test.js.map +0 -1
  41. package/dist/test/empty-placeholder.test.d.ts +0 -1
  42. package/dist/test/empty-placeholder.test.js +0 -57
  43. package/dist/test/empty-placeholder.test.js.map +0 -1
  44. package/dist/test/expanded-date-picker.test.d.ts +0 -1
  45. package/dist/test/expanded-date-picker.test.js +0 -124
  46. package/dist/test/expanded-date-picker.test.js.map +0 -1
  47. package/dist/test/icon-overlay.test.d.ts +0 -1
  48. package/dist/test/icon-overlay.test.js +0 -31
  49. package/dist/test/icon-overlay.test.js.map +0 -1
  50. package/dist/test/image-block.test.d.ts +0 -1
  51. package/dist/test/image-block.test.js +0 -208
  52. package/dist/test/image-block.test.js.map +0 -1
  53. package/dist/test/item-image.test.d.ts +0 -1
  54. package/dist/test/item-image.test.js +0 -187
  55. package/dist/test/item-image.test.js.map +0 -1
  56. package/dist/test/manage/manage-bar.test.d.ts +0 -3
  57. package/dist/test/manage/manage-bar.test.js +0 -216
  58. package/dist/test/manage/manage-bar.test.js.map +0 -1
  59. package/dist/test/manage/remove-items-modal-content.test.d.ts +0 -1
  60. package/dist/test/manage/remove-items-modal-content.test.js +0 -60
  61. package/dist/test/manage/remove-items-modal-content.test.js.map +0 -1
  62. package/dist/test/mediatype-config.test.d.ts +0 -1
  63. package/dist/test/mediatype-config.test.js +0 -11
  64. package/dist/test/mediatype-config.test.js.map +0 -1
  65. package/dist/test/mocks/mock-analytics-handler.d.ts +0 -10
  66. package/dist/test/mocks/mock-analytics-handler.js +0 -16
  67. package/dist/test/mocks/mock-analytics-handler.js.map +0 -1
  68. package/dist/test/mocks/mock-search-responses.d.ts +0 -37
  69. package/dist/test/mocks/mock-search-responses.js +0 -1293
  70. package/dist/test/mocks/mock-search-responses.js.map +0 -1
  71. package/dist/test/mocks/mock-search-service.d.ts +0 -16
  72. package/dist/test/mocks/mock-search-service.js +0 -65
  73. package/dist/test/mocks/mock-search-service.js.map +0 -1
  74. package/dist/test/restoration-state-handler.test.d.ts +0 -1
  75. package/dist/test/restoration-state-handler.test.js +0 -335
  76. package/dist/test/restoration-state-handler.test.js.map +0 -1
  77. package/dist/test/review-block.test.d.ts +0 -1
  78. package/dist/test/review-block.test.js +0 -46
  79. package/dist/test/review-block.test.js.map +0 -1
  80. package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.d.ts +0 -1
  81. package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.js +0 -12
  82. package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.js.map +0 -1
  83. package/dist/test/sort-filter-bar/alpha-bar.test.d.ts +0 -1
  84. package/dist/test/sort-filter-bar/alpha-bar.test.js +0 -68
  85. package/dist/test/sort-filter-bar/alpha-bar.test.js.map +0 -1
  86. package/dist/test/sort-filter-bar/sort-filter-bar.test.d.ts +0 -1
  87. package/dist/test/sort-filter-bar/sort-filter-bar.test.js +0 -304
  88. package/dist/test/sort-filter-bar/sort-filter-bar.test.js.map +0 -1
  89. package/dist/test/text-overlay.test.d.ts +0 -1
  90. package/dist/test/text-overlay.test.js +0 -43
  91. package/dist/test/text-overlay.test.js.map +0 -1
  92. package/dist/test/text-snippet-block.test.d.ts +0 -1
  93. package/dist/test/text-snippet-block.test.js +0 -58
  94. package/dist/test/text-snippet-block.test.js.map +0 -1
  95. package/dist/test/tile-stats.test.d.ts +0 -1
  96. package/dist/test/tile-stats.test.js +0 -167
  97. package/dist/test/tile-stats.test.js.map +0 -1
  98. package/dist/test/tiles/grid/account-tile.test.d.ts +0 -1
  99. package/dist/test/tiles/grid/account-tile.test.js +0 -96
  100. package/dist/test/tiles/grid/account-tile.test.js.map +0 -1
  101. package/dist/test/tiles/grid/collection-tile.test.d.ts +0 -1
  102. package/dist/test/tiles/grid/collection-tile.test.js +0 -90
  103. package/dist/test/tiles/grid/collection-tile.test.js.map +0 -1
  104. package/dist/test/tiles/grid/item-tile.test.d.ts +0 -1
  105. package/dist/test/tiles/grid/item-tile.test.js +0 -400
  106. package/dist/test/tiles/grid/item-tile.test.js.map +0 -1
  107. package/dist/test/tiles/grid/search-tile.test.d.ts +0 -1
  108. package/dist/test/tiles/grid/search-tile.test.js +0 -62
  109. package/dist/test/tiles/grid/search-tile.test.js.map +0 -1
  110. package/dist/test/tiles/hover/hover-pane-controller.test.d.ts +0 -1
  111. package/dist/test/tiles/hover/hover-pane-controller.test.js +0 -351
  112. package/dist/test/tiles/hover/hover-pane-controller.test.js.map +0 -1
  113. package/dist/test/tiles/hover/tile-hover-pane.test.d.ts +0 -1
  114. package/dist/test/tiles/hover/tile-hover-pane.test.js +0 -53
  115. package/dist/test/tiles/hover/tile-hover-pane.test.js.map +0 -1
  116. package/dist/test/tiles/list/tile-list-compact-header.test.d.ts +0 -1
  117. package/dist/test/tiles/list/tile-list-compact-header.test.js +0 -36
  118. package/dist/test/tiles/list/tile-list-compact-header.test.js.map +0 -1
  119. package/dist/test/tiles/list/tile-list-compact.test.d.ts +0 -1
  120. package/dist/test/tiles/list/tile-list-compact.test.js +0 -237
  121. package/dist/test/tiles/list/tile-list-compact.test.js.map +0 -1
  122. package/dist/test/tiles/list/tile-list.test.d.ts +0 -1
  123. package/dist/test/tiles/list/tile-list.test.js +0 -460
  124. package/dist/test/tiles/list/tile-list.test.js.map +0 -1
  125. package/dist/test/tiles/tile-dispatcher.test.d.ts +0 -1
  126. package/dist/test/tiles/tile-dispatcher.test.js +0 -246
  127. package/dist/test/tiles/tile-dispatcher.test.js.map +0 -1
  128. package/dist/test/tiles/tile-display-value-provider.test.d.ts +0 -1
  129. package/dist/test/tiles/tile-display-value-provider.test.js +0 -142
  130. package/dist/test/tiles/tile-display-value-provider.test.js.map +0 -1
  131. package/dist/test/tiles/tile-mediatype-icon.test.d.ts +0 -1
  132. package/dist/test/tiles/tile-mediatype-icon.test.js +0 -133
  133. package/dist/test/tiles/tile-mediatype-icon.test.js.map +0 -1
  134. package/dist/test/utils/array-equals.test.d.ts +0 -1
  135. package/dist/test/utils/array-equals.test.js +0 -27
  136. package/dist/test/utils/array-equals.test.js.map +0 -1
  137. package/dist/test/utils/format-count.test.d.ts +0 -1
  138. package/dist/test/utils/format-count.test.js +0 -24
  139. package/dist/test/utils/format-count.test.js.map +0 -1
  140. package/dist/test/utils/format-date.test.d.ts +0 -1
  141. package/dist/test/utils/format-date.test.js +0 -61
  142. package/dist/test/utils/format-date.test.js.map +0 -1
  143. package/dist/test/utils/format-unit-size.test.d.ts +0 -1
  144. package/dist/test/utils/format-unit-size.test.js +0 -18
  145. package/dist/test/utils/format-unit-size.test.js.map +0 -1
  146. package/dist/test/utils/local-date-from-utc.test.d.ts +0 -1
  147. package/dist/test/utils/local-date-from-utc.test.js +0 -27
  148. package/dist/test/utils/local-date-from-utc.test.js.map +0 -1
  149. package/dist/test/utils/normalize-filter-text.test.d.ts +0 -1
  150. package/dist/test/utils/normalize-filter-text.test.js +0 -69
  151. package/dist/test/utils/normalize-filter-text.test.js.map +0 -1
  152. package/docs/design/column-virtualization.md +0 -214
  153. package/eslint.config.mjs +0 -53
  154. package/index.html +0 -24
  155. package/index.ts +0 -29
  156. package/local.archive.org.cert +0 -86
  157. package/local.archive.org.key +0 -27
  158. package/pnpm-workspace.yaml +0 -30
  159. package/renovate.json +0 -6
  160. package/src/app-root.ts +0 -1282
  161. package/src/assets/img/icons/arrow-left.ts +0 -10
  162. package/src/assets/img/icons/arrow-right.ts +0 -10
  163. package/src/assets/img/icons/check.ts +0 -5
  164. package/src/assets/img/icons/chevron.ts +0 -4
  165. package/src/assets/img/icons/close-circle-dark.ts +0 -5
  166. package/src/assets/img/icons/contract.ts +0 -9
  167. package/src/assets/img/icons/empty-query.ts +0 -5
  168. package/src/assets/img/icons/expand.ts +0 -9
  169. package/src/assets/img/icons/eye-closed.ts +0 -5
  170. package/src/assets/img/icons/eye.ts +0 -5
  171. package/src/assets/img/icons/favorite-filled.ts +0 -10
  172. package/src/assets/img/icons/favorite-unfilled.ts +0 -9
  173. package/src/assets/img/icons/filter.ts +0 -10
  174. package/src/assets/img/icons/login-required.ts +0 -18
  175. package/src/assets/img/icons/mediatype/account.ts +0 -14
  176. package/src/assets/img/icons/mediatype/audio.ts +0 -14
  177. package/src/assets/img/icons/mediatype/collection.ts +0 -12
  178. package/src/assets/img/icons/mediatype/data.ts +0 -15
  179. package/src/assets/img/icons/mediatype/etree.ts +0 -14
  180. package/src/assets/img/icons/mediatype/film.ts +0 -14
  181. package/src/assets/img/icons/mediatype/images.ts +0 -13
  182. package/src/assets/img/icons/mediatype/radio.ts +0 -15
  183. package/src/assets/img/icons/mediatype/search.ts +0 -14
  184. package/src/assets/img/icons/mediatype/software.ts +0 -13
  185. package/src/assets/img/icons/mediatype/texts.ts +0 -13
  186. package/src/assets/img/icons/mediatype/tv-commercial.ts +0 -12
  187. package/src/assets/img/icons/mediatype/tv-fact-check.ts +0 -12
  188. package/src/assets/img/icons/mediatype/tv-quote.ts +0 -12
  189. package/src/assets/img/icons/mediatype/tv.ts +0 -14
  190. package/src/assets/img/icons/mediatype/video.ts +0 -14
  191. package/src/assets/img/icons/mediatype/web.ts +0 -13
  192. package/src/assets/img/icons/null-result.ts +0 -5
  193. package/src/assets/img/icons/quote.ts +0 -7
  194. package/src/assets/img/icons/restricted.ts +0 -13
  195. package/src/assets/img/icons/reviews.ts +0 -11
  196. package/src/assets/img/icons/upload.ts +0 -12
  197. package/src/assets/img/icons/views.ts +0 -11
  198. package/src/circular-activity-indicator.ts +0 -64
  199. package/src/collection-browser.ts +0 -3165
  200. package/src/collection-facets/facet-row-template.ts +0 -242
  201. package/src/collection-facets/facet-row.ts +0 -122
  202. package/src/collection-facets/facet-tombstone-row.ts +0 -40
  203. package/src/collection-facets/facets-template.ts +0 -85
  204. package/src/collection-facets/models.ts +0 -16
  205. package/src/collection-facets/more-facets-content.ts +0 -951
  206. package/src/collection-facets/more-facets-scroller.ts +0 -485
  207. package/src/collection-facets/page-window.ts +0 -247
  208. package/src/collection-facets/smart-facets/dedupe.ts +0 -44
  209. package/src/collection-facets/smart-facets/heuristics/browser-language/browser-language-heuristic.ts +0 -27
  210. package/src/collection-facets/smart-facets/heuristics/index.ts +0 -3
  211. package/src/collection-facets/smart-facets/heuristics/query-keywords/query-keywords-heuristic.ts +0 -17
  212. package/src/collection-facets/smart-facets/heuristics/query-keywords/query-keywords-map.ts +0 -70
  213. package/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-entity-map.ts +0 -79
  214. package/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-heuristic.ts +0 -93
  215. package/src/collection-facets/smart-facets/models.ts +0 -36
  216. package/src/collection-facets/smart-facets/smart-facet-bar.ts +0 -437
  217. package/src/collection-facets/smart-facets/smart-facet-button.ts +0 -145
  218. package/src/collection-facets/smart-facets/smart-facet-dropdown.ts +0 -185
  219. package/src/collection-facets/smart-facets/smart-facet-equals.ts +0 -16
  220. package/src/collection-facets/smart-facets/smart-facet-heuristics.ts +0 -26
  221. package/src/collection-facets/toggle-switch.ts +0 -175
  222. package/src/collection-facets.ts +0 -1013
  223. package/src/data-source/collection-browser-data-source-interface.ts +0 -351
  224. package/src/data-source/collection-browser-data-source.ts +0 -1474
  225. package/src/data-source/collection-browser-query-state.ts +0 -60
  226. package/src/data-source/models.ts +0 -56
  227. package/src/empty-placeholder.ts +0 -192
  228. package/src/expanded-date-picker.ts +0 -191
  229. package/src/language-code-handler/language-code-handler.ts +0 -64
  230. package/src/language-code-handler/language-code-mapping.ts +0 -564
  231. package/src/manage/manage-bar.ts +0 -276
  232. package/src/manage/remove-items-modal-content.ts +0 -102
  233. package/src/mediatype/mediatype-config.ts +0 -146
  234. package/src/models.ts +0 -912
  235. package/src/restoration-state-handler.ts +0 -550
  236. package/src/sort-filter-bar/alpha-bar-tooltip.ts +0 -53
  237. package/src/sort-filter-bar/alpha-bar.ts +0 -252
  238. package/src/sort-filter-bar/img/compact.ts +0 -5
  239. package/src/sort-filter-bar/img/list.ts +0 -5
  240. package/src/sort-filter-bar/img/sort-toggle-disabled.ts +0 -15
  241. package/src/sort-filter-bar/img/sort-toggle-down.ts +0 -17
  242. package/src/sort-filter-bar/img/sort-toggle-up.ts +0 -17
  243. package/src/sort-filter-bar/img/sort-triangle.ts +0 -5
  244. package/src/sort-filter-bar/img/tile.ts +0 -5
  245. package/src/sort-filter-bar/sort-filter-bar.ts +0 -733
  246. package/src/styles/ia-button.ts +0 -139
  247. package/src/styles/item-image-styles.ts +0 -124
  248. package/src/styles/sr-only.ts +0 -18
  249. package/src/styles/tile-action-styles.ts +0 -59
  250. package/src/tiles/base-tile-component.ts +0 -124
  251. package/src/tiles/collection-browser-loading-tile.ts +0 -26
  252. package/src/tiles/grid/account-tile.ts +0 -113
  253. package/src/tiles/grid/collection-tile.ts +0 -184
  254. package/src/tiles/grid/item-tile.ts +0 -347
  255. package/src/tiles/grid/search-tile.ts +0 -90
  256. package/src/tiles/grid/styles/tile-grid-shared-styles.ts +0 -130
  257. package/src/tiles/grid/tile-stats.ts +0 -211
  258. package/src/tiles/hover/hover-pane-controller.ts +0 -638
  259. package/src/tiles/hover/tile-hover-pane.ts +0 -184
  260. package/src/tiles/image-block.ts +0 -162
  261. package/src/tiles/item-image.ts +0 -214
  262. package/src/tiles/list/tile-list-compact-header.ts +0 -112
  263. package/src/tiles/list/tile-list-compact.ts +0 -278
  264. package/src/tiles/list/tile-list.ts +0 -718
  265. package/src/tiles/models.ts +0 -21
  266. package/src/tiles/overlay/icon-overlay.ts +0 -57
  267. package/src/tiles/overlay/text-overlay.ts +0 -79
  268. package/src/tiles/review-block.ts +0 -130
  269. package/src/tiles/text-snippet-block.ts +0 -132
  270. package/src/tiles/tile-dispatcher.ts +0 -637
  271. package/src/tiles/tile-display-value-provider.ts +0 -133
  272. package/src/tiles/tile-mediatype-icon.ts +0 -133
  273. package/src/utils/analytics-events.ts +0 -29
  274. package/src/utils/array-equals.ts +0 -8
  275. package/src/utils/collapse-repeated-quotes.ts +0 -13
  276. package/src/utils/date-filter-field.ts +0 -11
  277. package/src/utils/facet-utils.ts +0 -183
  278. package/src/utils/format-count.ts +0 -95
  279. package/src/utils/format-date.ts +0 -62
  280. package/src/utils/format-unit-size.ts +0 -43
  281. package/src/utils/local-date-from-utc.ts +0 -15
  282. package/src/utils/log.ts +0 -14
  283. package/src/utils/normalize-filter-text.ts +0 -54
  284. package/src/utils/resolve-mediatype.ts +0 -26
  285. package/src/utils/sha1.ts +0 -9
  286. package/test/collection-browser.test.ts +0 -2639
  287. package/test/collection-facets/facet-row.test.ts +0 -421
  288. package/test/collection-facets/facets-template.test.ts +0 -139
  289. package/test/collection-facets/more-facets-content.test.ts +0 -716
  290. package/test/collection-facets/more-facets-scroller.test.ts +0 -401
  291. package/test/collection-facets/page-window.test.ts +0 -208
  292. package/test/collection-facets/toggle-switch.test.ts +0 -164
  293. package/test/collection-facets.test.ts +0 -928
  294. package/test/data-source/collection-browser-data-source.test.ts +0 -193
  295. package/test/empty-placeholder.test.ts +0 -88
  296. package/test/expanded-date-picker.test.ts +0 -201
  297. package/test/icon-overlay.test.ts +0 -38
  298. package/test/image-block.test.ts +0 -247
  299. package/test/item-image.test.ts +0 -220
  300. package/test/manage/manage-bar.test.ts +0 -347
  301. package/test/manage/remove-items-modal-content.test.ts +0 -81
  302. package/test/mediatype-config.test.ts +0 -11
  303. package/test/mocks/mock-analytics-handler.ts +0 -30
  304. package/test/mocks/mock-search-responses.ts +0 -1420
  305. package/test/mocks/mock-search-service.ts +0 -136
  306. package/test/restoration-state-handler.test.ts +0 -480
  307. package/test/review-block.test.ts +0 -62
  308. package/test/sort-filter-bar/alpha-bar-tooltip.test.ts +0 -17
  309. package/test/sort-filter-bar/alpha-bar.test.ts +0 -101
  310. package/test/sort-filter-bar/sort-filter-bar.test.ts +0 -443
  311. package/test/text-overlay.test.ts +0 -55
  312. package/test/text-snippet-block.test.ts +0 -85
  313. package/test/tile-stats.test.ts +0 -191
  314. package/test/tiles/grid/account-tile.test.ts +0 -121
  315. package/test/tiles/grid/collection-tile.test.ts +0 -114
  316. package/test/tiles/grid/item-tile.test.ts +0 -520
  317. package/test/tiles/grid/search-tile.test.ts +0 -75
  318. package/test/tiles/hover/hover-pane-controller.test.ts +0 -482
  319. package/test/tiles/hover/tile-hover-pane.test.ts +0 -80
  320. package/test/tiles/list/tile-list-compact-header.test.ts +0 -43
  321. package/test/tiles/list/tile-list-compact.test.ts +0 -282
  322. package/test/tiles/list/tile-list.test.ts +0 -576
  323. package/test/tiles/tile-dispatcher.test.ts +0 -320
  324. package/test/tiles/tile-display-value-provider.test.ts +0 -172
  325. package/test/tiles/tile-mediatype-icon.test.ts +0 -160
  326. package/test/utils/array-equals.test.ts +0 -31
  327. package/test/utils/format-count.test.ts +0 -32
  328. package/test/utils/format-date.test.ts +0 -89
  329. package/test/utils/format-unit-size.test.ts +0 -21
  330. package/test/utils/local-date-from-utc.test.ts +0 -37
  331. package/test/utils/normalize-filter-text.test.ts +0 -87
  332. package/tsconfig.json +0 -25
  333. package/types/dompurify.d.ts +0 -1
  334. package/vite.config.ts +0 -29
  335. package/web-dev-server.config.mjs +0 -30
  336. package/web-test-runner.config.mjs +0 -57
@@ -1,733 +0,0 @@
1
- import {
2
- LitElement,
3
- html,
4
- css,
5
- nothing,
6
- PropertyValues,
7
- TemplateResult,
8
- } from 'lit';
9
- import { customElement, property, query, state } from 'lit/decorators.js';
10
- import { msg, str } from '@lit/localize';
11
- import type { IaDropdown, optionInterface } from '@internetarchive/ia-dropdown';
12
- import type { SortDirection } from '@internetarchive/search-service';
13
- import {
14
- CollectionDisplayMode,
15
- defaultSortAvailability,
16
- PrefixFilterCounts,
17
- PrefixFilterType,
18
- SORT_OPTIONS,
19
- SortField,
20
- SortOption,
21
- } from '../models';
22
-
23
- import { sortUpIcon } from './img/sort-toggle-up';
24
- import { sortDownIcon } from './img/sort-toggle-down';
25
- import { sortDisabledIcon } from './img/sort-toggle-disabled';
26
- import { tileIcon } from './img/tile';
27
- import { listIcon } from './img/list';
28
- import { compactIcon } from './img/compact';
29
- import { srOnlyStyle } from '../styles/sr-only';
30
-
31
- import '@internetarchive/ia-dropdown';
32
- import './alpha-bar';
33
-
34
- type AlphaSelector = 'creator' | 'title';
35
-
36
- @customElement('sort-filter-bar')
37
- export class SortFilterBar extends LitElement {
38
- /** Which display mode the tiles are being rendered with (grid/list-detail/list-compact) */
39
- @property({ type: String }) displayMode?: CollectionDisplayMode;
40
-
41
- /** The default sort direction to use if none is set */
42
- @property({ type: String }) defaultSortDirection: SortDirection | null = null;
43
-
44
- /** The default sort field to use if none is set */
45
- @property({ type: String }) defaultSortField: Exclude<
46
- SortField,
47
- SortField.default
48
- > = SortField.relevance;
49
-
50
- /** The current sort direction (asc/desc), or null if none is set */
51
- @property({ type: String }) sortDirection: SortDirection | null = null;
52
-
53
- /** The field currently being sorted on (e.g., 'title'). Defaults to relevance. */
54
- @property({ type: String }) selectedSort: SortField = SortField.default;
55
-
56
- /** The currently selected title letter filter, or null if none is set */
57
- @property({ type: String }) selectedTitleFilter: string | null = null;
58
-
59
- /** The currently selected creator letter filter, or null if none is set */
60
- @property({ type: String }) selectedCreatorFilter: string | null = null;
61
-
62
- /**
63
- * Map defining which sortable fields should be included on the sort bar.
64
- *
65
- * E.g.,
66
- * ```
67
- * {
68
- * [SortField.relevance]: true,
69
- * [SortField.date]: false,
70
- * [SortField.title]: true,
71
- * ...
72
- * }
73
- * ```
74
- */
75
- @property({ type: Object }) sortFieldAvailability = defaultSortAvailability;
76
-
77
- /** Whether to replace the default sort options with a slot for customization (default `false`) */
78
- @property({ type: Boolean, reflect: true }) enableSortOptionsSlot: boolean =
79
- false;
80
-
81
- /** Whether to suppress showing the three display mode options on the right of the bar (default `false`) */
82
- @property({ type: Boolean, reflect: true })
83
- suppressDisplayModes: boolean = false;
84
-
85
- /** Maps of result counts for letters on the alphabet bar, for each letter filter type */
86
- @property({ type: Object }) prefixFilterCountMap?: Record<
87
- PrefixFilterType,
88
- PrefixFilterCounts
89
- >;
90
-
91
- /**
92
- * Which of the alphabet bars (title/creator) should be shown, or null if one
93
- * should not currently be rendered.
94
- */
95
- @state() alphaSelectorVisible: AlphaSelector | null = null;
96
-
97
- /**
98
- * Whether the transparent backdrop to catch clicks outside the dropdown menu
99
- * should be rendered.
100
- */
101
- @state() dropdownBackdropVisible = false;
102
-
103
- /** The single, consolidated dropdown component containing all available options */
104
- @query('#sort-dropdown')
105
- private sortOptionsDropdown!: IaDropdown;
106
-
107
- render() {
108
- return html`
109
- <div id="container">
110
- <section id="sort-bar" aria-label="Sorting options">
111
- <slot name="sort-options-left"></slot>
112
- <div id="sort-options">
113
- ${!this.enableSortOptionsSlot
114
- ? html`
115
- <div class="sort-direction-container">
116
- ${this.sortDirectionSelectorTemplate}
117
- </div>
118
- <span class="sort-by-text">${msg('Sort by:')}</span>
119
- <div id="sort-selector-container">
120
- ${this.sortSelectorTemplate}
121
- </div>
122
- `
123
- : html`<slot name="sort-options"></slot>`}
124
- </div>
125
- <slot name="sort-options-right"></slot>
126
-
127
- ${this.suppressDisplayModes
128
- ? nothing
129
- : html`<div id="display-style-selector">
130
- ${this.displayOptionTemplate}
131
- </div>`}
132
- </section>
133
-
134
- ${this.dropdownBackdropVisible ? this.dropdownBackdrop : nothing}
135
- ${this.alphaBarTemplate}
136
- </div>
137
- `;
138
- }
139
-
140
- willUpdate(changed: PropertyValues) {
141
- if (changed.has('selectedSort') || changed.has('defaultSortField')) {
142
- // If the sort is changed from its default without a direction set,
143
- // we adopt the default sort direction for that sort type.
144
- if (
145
- this.selectedSort &&
146
- this.selectedSort !== SortField.default &&
147
- this.sortDirection === null
148
- ) {
149
- const sortOption = SORT_OPTIONS[this.finalizedSortField];
150
- this.sortDirection = sortOption.defaultSortDirection;
151
- }
152
- }
153
- }
154
-
155
- updated(changed: PropertyValues) {
156
- if (changed.has('displayMode')) {
157
- this.displayModeChanged();
158
- }
159
-
160
- if (changed.has('selectedTitleFilter') && this.selectedTitleFilter) {
161
- this.alphaSelectorVisible = 'title';
162
- }
163
-
164
- if (changed.has('selectedCreatorFilter') && this.selectedCreatorFilter) {
165
- this.alphaSelectorVisible = 'creator';
166
- }
167
-
168
- if (changed.has('dropdownBackdropVisible')) {
169
- this.setupEscapeListeners();
170
- }
171
- }
172
-
173
- private setupEscapeListeners() {
174
- if (this.dropdownBackdropVisible) {
175
- document.addEventListener(
176
- 'keydown',
177
- this.boundSortBarSelectorEscapeListener,
178
- );
179
- } else {
180
- document.removeEventListener(
181
- 'keydown',
182
- this.boundSortBarSelectorEscapeListener,
183
- );
184
- }
185
- }
186
-
187
- private boundSortBarSelectorEscapeListener = (e: KeyboardEvent) => {
188
- if (e.key === 'Escape') {
189
- this.closeDropdown();
190
- }
191
- };
192
-
193
- /**
194
- * Template to render the alphabet bar, or `nothing` if it should not be rendered
195
- * for the current sort
196
- */
197
- private get alphaBarTemplate(): TemplateResult | typeof nothing {
198
- if (!['title', 'creator'].includes(this.selectedSort)) return nothing;
199
-
200
- if (this.alphaSelectorVisible === null) {
201
- if (this.selectedSort === 'creator') return this.creatorSelectorBar;
202
- if (this.selectedSort === 'title') return this.titleSelectorBar;
203
- } else {
204
- return this.alphaSelectorVisible === 'creator'
205
- ? this.creatorSelectorBar
206
- : this.titleSelectorBar;
207
- }
208
-
209
- return nothing;
210
- }
211
-
212
- /** Template to render the sort direction toggle button */
213
- private get sortDirectionSelectorTemplate(): TemplateResult {
214
- const oppositeSortDirectionReadable =
215
- this.sortDirection === 'asc' ? msg('descending') : msg('ascending');
216
- const buttonLabel = this.canChangeSortDirection
217
- ? msg(str`Change to ${oppositeSortDirectionReadable} sort`)
218
- : msg('Directions are not available for the current sort option');
219
-
220
- return html`
221
- <button
222
- class="sort-direction-selector"
223
- title=${buttonLabel}
224
- ?disabled=${!this.canChangeSortDirection}
225
- @click=${this.handleSortDirectionClicked}
226
- >
227
- <span class="sr-only">${buttonLabel}</span>
228
- ${this.sortDirectionIcon}
229
- </button>
230
- `;
231
- }
232
-
233
- /** Template to render the sort direction button's icon in the correct current state */
234
- private get sortDirectionIcon(): TemplateResult {
235
- // Show a fully disabled icon for sort options without direction support
236
- if (!this.canChangeSortDirection) {
237
- return html`<div class="sort-direction-icon">${sortDisabledIcon}</div>`;
238
- }
239
-
240
- // For all other sorts, show the ascending/descending direction
241
- return html`
242
- <div class="sort-direction-icon">
243
- ${this.finalizedSortDirection === 'asc' ? sortUpIcon : sortDownIcon}
244
- </div>
245
- `;
246
- }
247
-
248
- /** The template to render all the sort options in a single dropdown */
249
- private get sortSelectorTemplate() {
250
- const displayedOptions = Object.values(SORT_OPTIONS).filter(
251
- opt => opt.shownInSortBar && this.sortFieldAvailability[opt.field],
252
- );
253
-
254
- return html`
255
- <div id="sort-dropdown-container">
256
- ${this.getSortDropdown({
257
- displayName: SORT_OPTIONS[this.finalizedSortField].displayName,
258
- id: 'sort-dropdown',
259
- selected: true,
260
- dropdownOptions: displayedOptions.map(opt =>
261
- this.getDropdownOption(opt.field),
262
- ),
263
- selectedOption: this.finalizedSortField,
264
- onOptionSelected: this.sortOptionSelected,
265
- onDropdownClick: () => {
266
- this.dropdownBackdropVisible = this.sortOptionsDropdown.open;
267
- this.sortOptionsDropdown.classList.toggle(
268
- 'open',
269
- this.sortOptionsDropdown.open,
270
- );
271
- },
272
- })}
273
- </div>
274
- `;
275
- }
276
-
277
- /**
278
- * Generates a dropdown component containing multiple grouped sort options.
279
- *
280
- * @param options.displayName The name to use for the dropdown's visible label
281
- * @param options.id The id to apply to the dropdown element
282
- * @param options.dropdownOptions An array of option objects used to populate the dropdown
283
- * @param options.selectedOption The id of the option that should be initially selected
284
- * @param options.selected A boolean indicating whether this dropdown should use its
285
- * selected appearance
286
- * @param options.onOptionSelected A handler for optionSelected events coming from the dropdown
287
- * @param options.onDropdownClick A handler for click events on the dropdown
288
- */
289
- private getSortDropdown(options: {
290
- displayName: string;
291
- id: string;
292
- dropdownOptions: optionInterface[];
293
- selectedOption?: string;
294
- selected: boolean;
295
- onOptionSelected?: (e: CustomEvent<{ option: optionInterface }>) => void;
296
- onDropdownClick?: (e: PointerEvent) => void;
297
- }): TemplateResult {
298
- return html`
299
- <ia-dropdown
300
- id=${options.id}
301
- class=${options.selected ? 'selected' : ''}
302
- displayCaret
303
- closeOnSelect
304
- includeSelectedOption
305
- .openViaButton=${options.selected}
306
- .options=${options.dropdownOptions}
307
- .selectedOption=${options.selectedOption ?? ''}
308
- @optionSelected=${options.onOptionSelected ?? nothing}
309
- @click=${options.onDropdownClick ?? nothing}
310
- >
311
- <span
312
- class="dropdown-label"
313
- slot="dropdown-label"
314
- data-title=${options.displayName}
315
- >
316
- ${options.displayName}
317
- </span>
318
- </ia-dropdown>
319
- `;
320
- }
321
-
322
- /** Generates a single dropdown option object for the given sort field */
323
- private getDropdownOption(sortField: SortField): optionInterface {
324
- return {
325
- id: sortField,
326
- label: html`
327
- <span class="dropdown-option-label">
328
- ${SORT_OPTIONS[sortField].displayName}
329
- </span>
330
- `,
331
- };
332
- }
333
-
334
- /** Handler for when a new sort dropdown option is selected */
335
- private sortOptionSelected(e: CustomEvent<{ option: optionInterface }>) {
336
- this.dropdownBackdropVisible = false;
337
-
338
- const sortField = e.detail.option.id as SortField;
339
- this.setSelectedSort(sortField);
340
-
341
- this.alphaSelectorVisible = null;
342
- if (sortField !== 'title' && this.selectedTitleFilter) {
343
- this.selectedTitleFilter = null;
344
- this.emitTitleLetterChangedEvent();
345
- }
346
- if (sortField !== 'creator' && this.selectedCreatorFilter) {
347
- this.selectedCreatorFilter = null;
348
- this.emitCreatorLetterChangedEvent();
349
- }
350
- }
351
-
352
- /** Template for rendering the three display mode options */
353
- /** Added data-testid for Playwright testing * */
354
- private get displayOptionTemplate() {
355
- return html`
356
- <ul>
357
- <li>
358
- <button
359
- id="grid-button"
360
- @click=${() => {
361
- this.displayMode = 'grid';
362
- }}
363
- class=${this.displayMode === 'grid' ? 'active' : ''}
364
- title="Tile view"
365
- data-testid="grid-button"
366
- >
367
- ${tileIcon}
368
- </button>
369
- </li>
370
- <li>
371
- <button
372
- id="list-detail-button"
373
- @click=${() => {
374
- this.displayMode = 'list-detail';
375
- }}
376
- class=${this.displayMode === 'list-detail' ? 'active' : ''}
377
- title="List view"
378
- data-testid="list-detail-button"
379
- >
380
- ${listIcon}
381
- </button>
382
- </li>
383
- <li>
384
- <button
385
- id="list-compact-button"
386
- @click=${() => {
387
- this.displayMode = 'list-compact';
388
- }}
389
- class=${this.displayMode === 'list-compact' ? 'active' : ''}
390
- title="Compact list view"
391
- data-testid="list-compact-button"
392
- >
393
- ${compactIcon}
394
- </button>
395
- </li>
396
- </ul>
397
- `;
398
- }
399
-
400
- /**
401
- * Template for rendering the transparent backdrop to capture clicks outside the
402
- * dropdown menu while it is open.
403
- */
404
- private get dropdownBackdrop() {
405
- return html`
406
- <div
407
- id="sort-selector-backdrop"
408
- @keyup=${this.closeDropdown}
409
- @click=${this.closeDropdown}
410
- ></div>
411
- `;
412
- }
413
-
414
- /** Closes the sorting dropdown component's menus */
415
- private closeDropdown() {
416
- this.dropdownBackdropVisible = false;
417
-
418
- if (!this.sortOptionsDropdown) return;
419
- this.sortOptionsDropdown.open = false;
420
- this.sortOptionsDropdown.classList.remove('open');
421
- }
422
-
423
- setSortDirection(sortDirection: SortDirection) {
424
- this.sortDirection = sortDirection;
425
- this.emitSortChangedEvent();
426
- }
427
-
428
- /** Toggles the current sort direction between 'asc' and 'desc' */
429
- private toggleSortDirection() {
430
- this.setSortDirection(
431
- this.finalizedSortDirection === 'desc' ? 'asc' : 'desc',
432
- );
433
- }
434
-
435
- private handleSortDirectionClicked(): void {
436
- if (
437
- !this.sortDirection &&
438
- this.defaultSortField &&
439
- this.defaultSortDirection
440
- ) {
441
- // When the sort direction is merely defaulted (not set by the user), clicking
442
- // the toggled button should "promote" the default sort to an explicitly-set one
443
- // and then toggle it as usual.
444
- this.selectedSort = this.defaultSortField;
445
- this.sortDirection = this.defaultSortDirection;
446
- }
447
-
448
- this.toggleSortDirection();
449
- }
450
-
451
- setSelectedSort(sort: SortField) {
452
- this.selectedSort = sort;
453
- // Apply this field's default sort direction
454
- const sortOption = SORT_OPTIONS[sort];
455
- this.sortDirection = sortOption.defaultSortDirection;
456
- this.emitSortChangedEvent();
457
- }
458
-
459
- /** The current sort field, or the default one if no explicit sort is set */
460
- private get finalizedSortField(): SortField {
461
- const resolvedField =
462
- this.selectedSort === SortField.default
463
- ? this.defaultSortField
464
- : this.selectedSort;
465
- if (this.sortFieldAvailability[resolvedField]) return resolvedField;
466
-
467
- // Fall back to the first available sort option shown in the sort bar, if
468
- // the requested one isn't available
469
- return this.firstAvailableOption?.field ?? resolvedField;
470
- }
471
-
472
- /** The current sort direction, or the default one if no explicit direction is set */
473
- private get finalizedSortDirection(): SortDirection | null {
474
- return this.sortDirection === null
475
- ? this.defaultSortDirection
476
- : this.sortDirection;
477
- }
478
-
479
- /** The first option shown in the sort dropdown, or undefined if none are available */
480
- private get firstAvailableOption(): SortOption | undefined {
481
- return Object.values(SORT_OPTIONS).find(
482
- opt => opt.shownInSortBar && this.sortFieldAvailability[opt.field],
483
- );
484
- }
485
-
486
- /** Whether the sort direction button should be enabled for the current sort */
487
- private get canChangeSortDirection(): boolean {
488
- return SORT_OPTIONS[this.finalizedSortField].canSetDirection;
489
- }
490
-
491
- private get titleSelectorBar() {
492
- return html` <alpha-bar
493
- .selectedLetter=${this.selectedTitleFilter}
494
- .letterCounts=${this.prefixFilterCountMap?.title}
495
- ariaLandmarkLabel="Filter by title letter"
496
- @letterChanged=${this.titleLetterChanged}
497
- ></alpha-bar>`;
498
- }
499
-
500
- private get creatorSelectorBar() {
501
- return html` <alpha-bar
502
- .selectedLetter=${this.selectedCreatorFilter}
503
- .letterCounts=${this.prefixFilterCountMap?.creator}
504
- ariaLandmarkLabel="Filter by creator letter"
505
- @letterChanged=${this.creatorLetterChanged}
506
- ></alpha-bar>`;
507
- }
508
-
509
- private titleLetterChanged(
510
- e: CustomEvent<{ selectedLetter: string | undefined }>,
511
- ) {
512
- this.selectedTitleFilter = e.detail.selectedLetter ?? null;
513
- this.emitTitleLetterChangedEvent();
514
- }
515
-
516
- private creatorLetterChanged(
517
- e: CustomEvent<{ selectedLetter: string | undefined }>,
518
- ) {
519
- this.selectedCreatorFilter = e.detail.selectedLetter ?? null;
520
- this.emitCreatorLetterChangedEvent();
521
- }
522
-
523
- private emitTitleLetterChangedEvent() {
524
- const event = new CustomEvent<{ selectedLetter: string | null }>(
525
- 'titleLetterChanged',
526
- {
527
- detail: { selectedLetter: this.selectedTitleFilter },
528
- },
529
- );
530
- this.dispatchEvent(event);
531
- }
532
-
533
- private emitCreatorLetterChangedEvent() {
534
- const event = new CustomEvent<{ selectedLetter: string | null }>(
535
- 'creatorLetterChanged',
536
- {
537
- detail: { selectedLetter: this.selectedCreatorFilter },
538
- },
539
- );
540
- this.dispatchEvent(event);
541
- }
542
-
543
- private displayModeChanged() {
544
- const event = new CustomEvent<{
545
- displayMode?: CollectionDisplayMode;
546
- }>('displayModeChanged', {
547
- detail: { displayMode: this.displayMode },
548
- });
549
- this.dispatchEvent(event);
550
- }
551
-
552
- private emitSortChangedEvent() {
553
- const event = new CustomEvent<{
554
- selectedSort: SortField;
555
- sortDirection: SortDirection | null;
556
- }>('sortChanged', {
557
- detail: {
558
- selectedSort: this.selectedSort,
559
- sortDirection: this.sortDirection,
560
- },
561
- });
562
- this.dispatchEvent(event);
563
- }
564
-
565
- static get styles() {
566
- const disabledIconColor = css`#bbbbbb`;
567
-
568
- return [
569
- srOnlyStyle,
570
- css`
571
- #container {
572
- position: relative;
573
- }
574
-
575
- #sort-bar {
576
- display: flex;
577
- justify-content: flex-start;
578
- align-items: center;
579
- padding-bottom: 1px;
580
- border-bottom: 1px solid #2c2c2c;
581
- font-size: 1.4rem;
582
- }
583
-
584
- #sort-options {
585
- display: flex;
586
- align-items: center;
587
- flex-grow: 1;
588
- }
589
-
590
- ul {
591
- list-style: none;
592
- display: flex;
593
- align-items: center;
594
- margin: 0;
595
- padding: 0;
596
- }
597
-
598
- li {
599
- padding: 0;
600
- }
601
-
602
- .sort-by-text {
603
- margin-right: 5px;
604
- font-weight: bold;
605
- white-space: nowrap;
606
- }
607
-
608
- .sort-direction-container {
609
- display: flex;
610
- align-self: stretch;
611
- flex: 0;
612
- margin: 0 3px;
613
- }
614
-
615
- .sort-direction-selector {
616
- display: flex;
617
- justify-content: center;
618
- width: 30px;
619
- margin: 0 5px 0 0;
620
- padding: 7px 8px;
621
- max-height: fit-content;
622
- border-radius: 5px;
623
- background: white;
624
- border: 1px solid rgb(25, 72, 128);
625
- appearance: none;
626
- cursor: pointer;
627
- }
628
-
629
- .sort-direction-selector:disabled {
630
- cursor: not-allowed;
631
- border-color: ${disabledIconColor};
632
- }
633
-
634
- .sort-direction-icon {
635
- display: flex;
636
- align-items: center;
637
- background: none;
638
- color: inherit;
639
- border: none;
640
- padding: 0;
641
- outline: inherit;
642
- width: 12px;
643
- height: 12px;
644
- }
645
-
646
- .sort-direction-icon > svg {
647
- flex: 1;
648
- }
649
-
650
- #sort-selector-container {
651
- flex: 1;
652
- display: flex;
653
- justify-content: flex-start;
654
- align-items: center;
655
- }
656
-
657
- #sort-dropdown-container {
658
- display: flex;
659
- justify-content: flex-start;
660
- align-items: center;
661
- }
662
-
663
- #sort-selector-backdrop {
664
- position: fixed;
665
- top: 0;
666
- left: 0;
667
- width: 100vw;
668
- height: 100vh;
669
- z-index: 1;
670
- background-color: transparent;
671
- }
672
-
673
- #display-style-selector {
674
- flex: 0;
675
- }
676
-
677
- #display-style-selector button {
678
- background: none;
679
- color: inherit;
680
- border: none;
681
- appearance: none;
682
- cursor: pointer;
683
- -webkit-appearance: none;
684
- fill: ${disabledIconColor};
685
- }
686
-
687
- #display-style-selector button.active {
688
- fill: var(--ia-theme-primary-text-color, #2c2c2c);
689
- }
690
-
691
- #display-style-selector button svg {
692
- width: 24px;
693
- height: 24px;
694
- }
695
-
696
- ia-dropdown {
697
- --dropdownTextColor: white;
698
- --dropdownOffsetTop: 0;
699
- --dropdownBorderTopWidth: 0;
700
- --dropdownBorderTopLeftRadius: 0;
701
- --dropdownBorderTopRightRadius: 0;
702
- --dropdownWhiteSpace: nowrap;
703
- --dropdownListZIndex: 2;
704
- --dropdownCaretColor: var(--ia-theme-primary-text-color, #2c2c2c);
705
- --dropdownSelectedTextColor: white;
706
- --dropdownSelectedBgColor: rgba(255, 255, 255, 0.3);
707
- --dropdownHoverBgColor: rgba(255, 255, 255, 0.3);
708
- --caretHeight: 9px;
709
- --caretWidth: 12px;
710
- --caretPadding: 0 5px 0 0;
711
- }
712
- ia-dropdown.selected .dropdown-label {
713
- font-weight: bold;
714
- }
715
- ia-dropdown.open {
716
- z-index: 2;
717
- }
718
-
719
- .dropdown-label {
720
- display: inline-block;
721
- height: 100%;
722
- padding-left: 5px;
723
- font-size: 1.4rem;
724
- font-family: var(--ia-theme-base-font-family);
725
- line-height: 2;
726
- color: var(--ia-theme-primary-text-color, #2c2c2c);
727
- white-space: nowrap;
728
- user-select: none;
729
- }
730
- `,
731
- ];
732
- }
733
- }