@internetarchive/collection-browser 1.12.0 → 1.13.0-alpha1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (267) hide show
  1. package/.editorconfig +29 -29
  2. package/.github/workflows/ci.yml +26 -26
  3. package/.github/workflows/gh-pages-main.yml +39 -39
  4. package/.github/workflows/npm-publish.yml +39 -39
  5. package/.github/workflows/pr-preview.yml +38 -38
  6. package/.husky/pre-commit +4 -4
  7. package/LICENSE +661 -661
  8. package/README.md +83 -83
  9. package/dist/index.d.ts +9 -9
  10. package/dist/index.js +9 -9
  11. package/dist/src/app-root.d.ts +54 -54
  12. package/dist/src/app-root.js +293 -293
  13. package/dist/src/assets/img/icons/arrow-left.d.ts +2 -2
  14. package/dist/src/assets/img/icons/arrow-left.js +2 -2
  15. package/dist/src/assets/img/icons/arrow-right.d.ts +2 -2
  16. package/dist/src/assets/img/icons/arrow-right.js +2 -2
  17. package/dist/src/assets/img/icons/chevron.d.ts +2 -2
  18. package/dist/src/assets/img/icons/chevron.js +2 -2
  19. package/dist/src/assets/img/icons/contract.d.ts +2 -2
  20. package/dist/src/assets/img/icons/contract.js +2 -2
  21. package/dist/src/assets/img/icons/empty-query.d.ts +2 -2
  22. package/dist/src/assets/img/icons/empty-query.js +2 -2
  23. package/dist/src/assets/img/icons/expand.d.ts +2 -2
  24. package/dist/src/assets/img/icons/expand.js +2 -2
  25. package/dist/src/assets/img/icons/eye-closed.d.ts +2 -2
  26. package/dist/src/assets/img/icons/eye-closed.js +2 -2
  27. package/dist/src/assets/img/icons/eye.d.ts +2 -2
  28. package/dist/src/assets/img/icons/eye.js +2 -2
  29. package/dist/src/assets/img/icons/favorite-filled.d.ts +1 -1
  30. package/dist/src/assets/img/icons/favorite-filled.js +2 -2
  31. package/dist/src/assets/img/icons/login-required.d.ts +1 -1
  32. package/dist/src/assets/img/icons/login-required.js +2 -2
  33. package/dist/src/assets/img/icons/mediatype/account.d.ts +1 -1
  34. package/dist/src/assets/img/icons/mediatype/account.js +2 -2
  35. package/dist/src/assets/img/icons/mediatype/audio.d.ts +1 -1
  36. package/dist/src/assets/img/icons/mediatype/audio.js +2 -2
  37. package/dist/src/assets/img/icons/mediatype/collection.d.ts +1 -1
  38. package/dist/src/assets/img/icons/mediatype/collection.js +2 -2
  39. package/dist/src/assets/img/icons/mediatype/data.d.ts +1 -1
  40. package/dist/src/assets/img/icons/mediatype/data.js +2 -2
  41. package/dist/src/assets/img/icons/mediatype/etree.d.ts +1 -1
  42. package/dist/src/assets/img/icons/mediatype/etree.js +2 -2
  43. package/dist/src/assets/img/icons/mediatype/film.d.ts +1 -1
  44. package/dist/src/assets/img/icons/mediatype/film.js +2 -2
  45. package/dist/src/assets/img/icons/mediatype/images.d.ts +1 -1
  46. package/dist/src/assets/img/icons/mediatype/images.js +2 -2
  47. package/dist/src/assets/img/icons/mediatype/radio.d.ts +1 -1
  48. package/dist/src/assets/img/icons/mediatype/radio.js +2 -2
  49. package/dist/src/assets/img/icons/mediatype/software.d.ts +1 -1
  50. package/dist/src/assets/img/icons/mediatype/software.js +2 -2
  51. package/dist/src/assets/img/icons/mediatype/texts.d.ts +1 -1
  52. package/dist/src/assets/img/icons/mediatype/texts.js +2 -2
  53. package/dist/src/assets/img/icons/mediatype/tv.d.ts +1 -1
  54. package/dist/src/assets/img/icons/mediatype/tv.js +2 -2
  55. package/dist/src/assets/img/icons/mediatype/video.d.ts +1 -1
  56. package/dist/src/assets/img/icons/mediatype/video.js +2 -2
  57. package/dist/src/assets/img/icons/mediatype/web.d.ts +1 -1
  58. package/dist/src/assets/img/icons/mediatype/web.js +2 -2
  59. package/dist/src/assets/img/icons/null-result.d.ts +2 -2
  60. package/dist/src/assets/img/icons/null-result.js +2 -2
  61. package/dist/src/assets/img/icons/restricted.d.ts +1 -1
  62. package/dist/src/assets/img/icons/restricted.js +2 -2
  63. package/dist/src/assets/img/icons/reviews.d.ts +1 -1
  64. package/dist/src/assets/img/icons/reviews.js +2 -2
  65. package/dist/src/assets/img/icons/upload.d.ts +1 -1
  66. package/dist/src/assets/img/icons/upload.js +2 -2
  67. package/dist/src/assets/img/icons/views.d.ts +1 -1
  68. package/dist/src/assets/img/icons/views.js +2 -2
  69. package/dist/src/circular-activity-indicator.d.ts +5 -5
  70. package/dist/src/circular-activity-indicator.js +17 -17
  71. package/dist/src/collection-browser.d.ts +472 -472
  72. package/dist/src/collection-browser.js +1693 -1686
  73. package/dist/src/collection-browser.js.map +1 -1
  74. package/dist/src/collection-facets/facet-tombstone-row.d.ts +5 -5
  75. package/dist/src/collection-facets/facet-tombstone-row.js +15 -15
  76. package/dist/src/collection-facets/facets-template.d.ts +20 -20
  77. package/dist/src/collection-facets/facets-template.js +152 -152
  78. package/dist/src/collection-facets/more-facets-content.d.ts +77 -77
  79. package/dist/src/collection-facets/more-facets-content.js +359 -359
  80. package/dist/src/collection-facets/more-facets-pagination.d.ts +36 -36
  81. package/dist/src/collection-facets/more-facets-pagination.js +196 -196
  82. package/dist/src/collection-facets/toggle-switch.d.ts +41 -41
  83. package/dist/src/collection-facets/toggle-switch.js +94 -94
  84. package/dist/src/collection-facets.d.ts +103 -103
  85. package/dist/src/collection-facets.js +497 -497
  86. package/dist/src/empty-placeholder.d.ts +23 -21
  87. package/dist/src/empty-placeholder.js +83 -69
  88. package/dist/src/empty-placeholder.js.map +1 -1
  89. package/dist/src/expanded-date-picker.d.ts +43 -43
  90. package/dist/src/expanded-date-picker.js +109 -109
  91. package/dist/src/language-code-handler/language-code-handler.d.ts +37 -37
  92. package/dist/src/language-code-handler/language-code-handler.js +26 -26
  93. package/dist/src/language-code-handler/language-code-mapping.d.ts +1 -1
  94. package/dist/src/language-code-handler/language-code-mapping.js +562 -562
  95. package/dist/src/mediatype/mediatype-config.d.ts +3 -3
  96. package/dist/src/mediatype/mediatype-config.js +85 -85
  97. package/dist/src/models.d.ts +163 -163
  98. package/dist/src/models.js +269 -269
  99. package/dist/src/restoration-state-handler.d.ts +70 -70
  100. package/dist/src/restoration-state-handler.js +355 -355
  101. package/dist/src/sort-filter-bar/alpha-bar-tooltip.d.ts +6 -6
  102. package/dist/src/sort-filter-bar/alpha-bar-tooltip.js +24 -24
  103. package/dist/src/sort-filter-bar/alpha-bar.d.ts +21 -21
  104. package/dist/src/sort-filter-bar/alpha-bar.js +128 -128
  105. package/dist/src/sort-filter-bar/img/compact.d.ts +1 -1
  106. package/dist/src/sort-filter-bar/img/compact.js +2 -2
  107. package/dist/src/sort-filter-bar/img/list.d.ts +1 -1
  108. package/dist/src/sort-filter-bar/img/list.js +2 -2
  109. package/dist/src/sort-filter-bar/img/sort-toggle-disabled.d.ts +1 -1
  110. package/dist/src/sort-filter-bar/img/sort-toggle-disabled.js +2 -2
  111. package/dist/src/sort-filter-bar/img/sort-toggle-down.d.ts +1 -1
  112. package/dist/src/sort-filter-bar/img/sort-toggle-down.js +2 -2
  113. package/dist/src/sort-filter-bar/img/sort-toggle-up.d.ts +1 -1
  114. package/dist/src/sort-filter-bar/img/sort-toggle-up.js +2 -2
  115. package/dist/src/sort-filter-bar/img/sort-triangle.d.ts +1 -1
  116. package/dist/src/sort-filter-bar/img/sort-triangle.js +2 -2
  117. package/dist/src/sort-filter-bar/img/tile.d.ts +1 -1
  118. package/dist/src/sort-filter-bar/img/tile.js +2 -2
  119. package/dist/src/sort-filter-bar/sort-filter-bar.d.ts +208 -208
  120. package/dist/src/sort-filter-bar/sort-filter-bar.js +637 -637
  121. package/dist/src/styles/item-image-styles.d.ts +8 -8
  122. package/dist/src/styles/item-image-styles.js +9 -9
  123. package/dist/src/styles/sr-only.d.ts +1 -1
  124. package/dist/src/styles/sr-only.js +2 -2
  125. package/dist/src/tiles/base-tile-component.d.ts +18 -18
  126. package/dist/src/tiles/base-tile-component.js +59 -59
  127. package/dist/src/tiles/collection-browser-loading-tile.d.ts +5 -5
  128. package/dist/src/tiles/collection-browser-loading-tile.js +15 -15
  129. package/dist/src/tiles/grid/account-tile.d.ts +18 -18
  130. package/dist/src/tiles/grid/account-tile.js +72 -72
  131. package/dist/src/tiles/grid/collection-tile.d.ts +15 -15
  132. package/dist/src/tiles/grid/collection-tile.js +80 -80
  133. package/dist/src/tiles/grid/item-tile.d.ts +27 -27
  134. package/dist/src/tiles/grid/item-tile.js +134 -134
  135. package/dist/src/tiles/grid/styles/tile-grid-shared-styles.d.ts +1 -1
  136. package/dist/src/tiles/grid/styles/tile-grid-shared-styles.js +8 -8
  137. package/dist/src/tiles/grid/tile-stats.d.ts +11 -11
  138. package/dist/src/tiles/grid/tile-stats.js +48 -48
  139. package/dist/src/tiles/hover/hover-pane-controller.d.ts +219 -219
  140. package/dist/src/tiles/hover/hover-pane-controller.js +352 -352
  141. package/dist/src/tiles/hover/tile-hover-pane.d.ts +15 -15
  142. package/dist/src/tiles/hover/tile-hover-pane.js +38 -38
  143. package/dist/src/tiles/image-block.d.ts +17 -17
  144. package/dist/src/tiles/image-block.js +72 -72
  145. package/dist/src/tiles/item-image.d.ts +35 -35
  146. package/dist/src/tiles/item-image.js +117 -117
  147. package/dist/src/tiles/list/tile-list-compact-header.d.ts +6 -6
  148. package/dist/src/tiles/list/tile-list-compact-header.js +38 -38
  149. package/dist/src/tiles/list/tile-list-compact.d.ts +15 -15
  150. package/dist/src/tiles/list/tile-list-compact.js +114 -114
  151. package/dist/src/tiles/list/tile-list.d.ts +46 -46
  152. package/dist/src/tiles/list/tile-list.js +298 -298
  153. package/dist/src/tiles/mediatype-icon.d.ts +9 -9
  154. package/dist/src/tiles/mediatype-icon.js +47 -47
  155. package/dist/src/tiles/overlay/icon-overlay.d.ts +10 -10
  156. package/dist/src/tiles/overlay/icon-overlay.js +40 -40
  157. package/dist/src/tiles/overlay/icon-text-overlay.d.ts +9 -9
  158. package/dist/src/tiles/overlay/icon-text-overlay.js +38 -38
  159. package/dist/src/tiles/overlay/text-overlay.d.ts +10 -10
  160. package/dist/src/tiles/overlay/text-overlay.js +42 -42
  161. package/dist/src/tiles/text-snippet-block.d.ts +27 -27
  162. package/dist/src/tiles/text-snippet-block.js +73 -73
  163. package/dist/src/tiles/tile-dispatcher.d.ts +50 -50
  164. package/dist/src/tiles/tile-dispatcher.js +185 -185
  165. package/dist/src/tiles/tile-display-value-provider.d.ts +43 -43
  166. package/dist/src/tiles/tile-display-value-provider.js +80 -80
  167. package/dist/src/utils/analytics-events.d.ts +25 -25
  168. package/dist/src/utils/analytics-events.js +27 -27
  169. package/dist/src/utils/array-equals.d.ts +4 -4
  170. package/dist/src/utils/array-equals.js +10 -10
  171. package/dist/src/utils/format-count.d.ts +7 -7
  172. package/dist/src/utils/format-count.js +76 -76
  173. package/dist/src/utils/format-date.d.ts +2 -2
  174. package/dist/src/utils/format-date.js +25 -25
  175. package/dist/src/utils/format-unit-size.d.ts +2 -2
  176. package/dist/src/utils/format-unit-size.js +33 -33
  177. package/dist/src/utils/local-date-from-utc.d.ts +9 -9
  178. package/dist/src/utils/local-date-from-utc.js +15 -15
  179. package/dist/src/utils/sha1.d.ts +2 -2
  180. package/dist/src/utils/sha1.js +8 -8
  181. package/dist/test/collection-browser.test.d.ts +1 -1
  182. package/dist/test/collection-browser.test.js +981 -967
  183. package/dist/test/collection-browser.test.js.map +1 -1
  184. package/dist/test/collection-facets/facets-template.test.d.ts +1 -1
  185. package/dist/test/collection-facets/facets-template.test.js +134 -134
  186. package/dist/test/collection-facets/more-facets-content.test.d.ts +1 -1
  187. package/dist/test/collection-facets/more-facets-content.test.js +133 -133
  188. package/dist/test/collection-facets/more-facets-pagination.test.d.ts +1 -1
  189. package/dist/test/collection-facets/more-facets-pagination.test.js +117 -117
  190. package/dist/test/collection-facets/toggle-switch.test.d.ts +1 -1
  191. package/dist/test/collection-facets/toggle-switch.test.js +73 -73
  192. package/dist/test/collection-facets.test.d.ts +2 -2
  193. package/dist/test/collection-facets.test.js +682 -682
  194. package/dist/test/empty-placeholder.test.d.ts +1 -1
  195. package/dist/test/empty-placeholder.test.js +63 -56
  196. package/dist/test/empty-placeholder.test.js.map +1 -1
  197. package/dist/test/expanded-date-picker.test.d.ts +1 -1
  198. package/dist/test/expanded-date-picker.test.js +95 -95
  199. package/dist/test/icon-overlay.test.d.ts +1 -1
  200. package/dist/test/icon-overlay.test.js +24 -24
  201. package/dist/test/image-block.test.d.ts +1 -1
  202. package/dist/test/image-block.test.js +48 -48
  203. package/dist/test/item-image.test.d.ts +1 -1
  204. package/dist/test/item-image.test.js +84 -84
  205. package/dist/test/mediatype-config.test.d.ts +1 -1
  206. package/dist/test/mediatype-config.test.js +16 -16
  207. package/dist/test/mocks/mock-analytics-handler.d.ts +10 -10
  208. package/dist/test/mocks/mock-analytics-handler.js +15 -15
  209. package/dist/test/mocks/mock-collection-name-cache.d.ts +9 -9
  210. package/dist/test/mocks/mock-collection-name-cache.js +17 -17
  211. package/dist/test/mocks/mock-search-responses.d.ts +21 -21
  212. package/dist/test/mocks/mock-search-responses.js +707 -707
  213. package/dist/test/mocks/mock-search-service.d.ts +15 -15
  214. package/dist/test/mocks/mock-search-service.js +50 -50
  215. package/dist/test/restoration-state-handler.test.d.ts +1 -1
  216. package/dist/test/restoration-state-handler.test.js +270 -270
  217. package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.d.ts +1 -1
  218. package/dist/test/sort-filter-bar/alpha-bar-tooltip.test.js +12 -12
  219. package/dist/test/sort-filter-bar/alpha-bar.test.d.ts +1 -1
  220. package/dist/test/sort-filter-bar/alpha-bar.test.js +73 -73
  221. package/dist/test/sort-filter-bar/sort-filter-bar.test.d.ts +1 -1
  222. package/dist/test/sort-filter-bar/sort-filter-bar.test.js +378 -378
  223. package/dist/test/text-overlay.test.d.ts +1 -1
  224. package/dist/test/text-overlay.test.js +48 -48
  225. package/dist/test/text-snippet-block.test.d.ts +1 -1
  226. package/dist/test/text-snippet-block.test.js +57 -57
  227. package/dist/test/tile-stats.test.d.ts +1 -1
  228. package/dist/test/tile-stats.test.js +33 -33
  229. package/dist/test/tiles/grid/account-tile.test.d.ts +1 -1
  230. package/dist/test/tiles/grid/account-tile.test.js +76 -76
  231. package/dist/test/tiles/grid/collection-tile.test.d.ts +1 -1
  232. package/dist/test/tiles/grid/collection-tile.test.js +73 -73
  233. package/dist/test/tiles/grid/item-tile.test.d.ts +1 -1
  234. package/dist/test/tiles/grid/item-tile.test.js +254 -254
  235. package/dist/test/tiles/hover/hover-pane-controller.test.d.ts +1 -1
  236. package/dist/test/tiles/hover/hover-pane-controller.test.js +257 -257
  237. package/dist/test/tiles/hover/tile-hover-pane.test.d.ts +1 -1
  238. package/dist/test/tiles/hover/tile-hover-pane.test.js +13 -13
  239. package/dist/test/tiles/list/tile-list-compact.test.d.ts +1 -1
  240. package/dist/test/tiles/list/tile-list-compact.test.js +143 -143
  241. package/dist/test/tiles/list/tile-list.test.d.ts +1 -1
  242. package/dist/test/tiles/list/tile-list.test.js +242 -242
  243. package/dist/test/tiles/tile-dispatcher.test.d.ts +1 -1
  244. package/dist/test/tiles/tile-dispatcher.test.js +67 -67
  245. package/dist/test/tiles/tile-display-value-provider.test.d.ts +1 -1
  246. package/dist/test/tiles/tile-display-value-provider.test.js +141 -141
  247. package/dist/test/utils/array-equals.test.d.ts +1 -1
  248. package/dist/test/utils/array-equals.test.js +26 -26
  249. package/dist/test/utils/format-count.test.d.ts +1 -1
  250. package/dist/test/utils/format-count.test.js +23 -23
  251. package/dist/test/utils/format-date.test.d.ts +1 -1
  252. package/dist/test/utils/format-date.test.js +17 -17
  253. package/dist/test/utils/format-unit-size.test.d.ts +1 -1
  254. package/dist/test/utils/format-unit-size.test.js +17 -17
  255. package/dist/test/utils/local-date-from-utc.test.d.ts +1 -1
  256. package/dist/test/utils/local-date-from-utc.test.js +26 -26
  257. package/local.archive.org.cert +86 -86
  258. package/local.archive.org.key +27 -27
  259. package/package.json +1 -1
  260. package/renovate.json +6 -6
  261. package/src/collection-browser.ts +7 -1
  262. package/src/empty-placeholder.ts +17 -0
  263. package/test/collection-browser.test.ts +23 -0
  264. package/test/empty-placeholder.test.ts +26 -19
  265. package/tsconfig.json +21 -21
  266. package/web-dev-server.config.mjs +30 -30
  267. package/web-test-runner.config.mjs +41 -41
@@ -1,72 +1,72 @@
1
- import { __decorate } from "tslib";
2
- /* eslint-disable import/no-duplicates */
3
- import { css, html, LitElement, nothing, } from 'lit';
4
- import { customElement, property, state } from 'lit/decorators.js';
5
- import { map } from 'lit/directives/map.js';
6
- import { ref } from 'lit/directives/ref.js';
7
- import { msg } from '@lit/localize';
8
- import '@internetarchive/histogram-date-range';
9
- import '@internetarchive/feature-feedback';
10
- import '@internetarchive/collection-name-cache';
11
- import { ModalConfig, } from '@internetarchive/modal-manager';
12
- import chevronIcon from './assets/img/icons/chevron';
13
- import expandIcon from './assets/img/icons/expand';
14
- import { facetDisplayOrder, facetTitles, lendingFacetDisplayNames, lendingFacetKeysVisibility, suppressedCollections, defaultFacetSort, } from './models';
15
- import './collection-facets/more-facets-content';
16
- import './collection-facets/facets-template';
17
- import './collection-facets/facet-tombstone-row';
18
- import './expanded-date-picker';
19
- import { analyticsActions, analyticsCategories, } from './utils/analytics-events';
20
- import { srOnlyStyle } from './styles/sr-only';
21
- import { ExpandedDatePicker } from './expanded-date-picker';
22
- let CollectionFacets = class CollectionFacets extends LitElement {
23
- constructor() {
24
- super(...arguments);
25
- this.moreLinksVisible = true;
26
- this.facetsLoading = false;
27
- this.fullYearAggregationLoading = false;
28
- this.collapsableFacets = false;
29
- this.showHistogramDatePicker = false;
30
- this.allowExpandingDatePicker = false;
31
- this.parentCollections = [];
32
- this.collectionPagePath = '/details/';
33
- this.openFacets = {
34
- subject: false,
35
- lending: false,
36
- mediatype: false,
37
- language: false,
38
- creator: false,
39
- collection: false,
40
- year: false,
41
- };
42
- /**
43
- * Maximum # of facet buckets to render per facet group
44
- */
45
- this.allowedFacetCount = 6;
46
- this.handleExpandedDatePickerClosed = () => {
47
- var _a;
48
- (_a = this.modalManager) === null || _a === void 0 ? void 0 : _a.classList.remove('expanded-date-picker');
49
- };
50
- /**
51
- * Dispatches a `histogramDateRangeUpdated` event with the date range copied from the
52
- * input event.
53
- *
54
- * Arrow function to ensure `this` is always bound to the current component.
55
- */
56
- this.histogramDateRangeUpdated = (e) => {
57
- const { minDate, maxDate } = e.detail;
58
- const event = new CustomEvent('histogramDateRangeUpdated', {
59
- detail: { minDate, maxDate },
60
- });
61
- this.dispatchEvent(event);
62
- };
63
- }
64
- render() {
65
- const datePickerLabelId = 'date-picker-label';
1
+ import { __decorate } from "tslib";
2
+ /* eslint-disable import/no-duplicates */
3
+ import { css, html, LitElement, nothing, } from 'lit';
4
+ import { customElement, property, state } from 'lit/decorators.js';
5
+ import { map } from 'lit/directives/map.js';
6
+ import { ref } from 'lit/directives/ref.js';
7
+ import { msg } from '@lit/localize';
8
+ import '@internetarchive/histogram-date-range';
9
+ import '@internetarchive/feature-feedback';
10
+ import '@internetarchive/collection-name-cache';
11
+ import { ModalConfig, } from '@internetarchive/modal-manager';
12
+ import chevronIcon from './assets/img/icons/chevron';
13
+ import expandIcon from './assets/img/icons/expand';
14
+ import { facetDisplayOrder, facetTitles, lendingFacetDisplayNames, lendingFacetKeysVisibility, suppressedCollections, defaultFacetSort, } from './models';
15
+ import './collection-facets/more-facets-content';
16
+ import './collection-facets/facets-template';
17
+ import './collection-facets/facet-tombstone-row';
18
+ import './expanded-date-picker';
19
+ import { analyticsActions, analyticsCategories, } from './utils/analytics-events';
20
+ import { srOnlyStyle } from './styles/sr-only';
21
+ import { ExpandedDatePicker } from './expanded-date-picker';
22
+ let CollectionFacets = class CollectionFacets extends LitElement {
23
+ constructor() {
24
+ super(...arguments);
25
+ this.moreLinksVisible = true;
26
+ this.facetsLoading = false;
27
+ this.fullYearAggregationLoading = false;
28
+ this.collapsableFacets = false;
29
+ this.showHistogramDatePicker = false;
30
+ this.allowExpandingDatePicker = false;
31
+ this.parentCollections = [];
32
+ this.collectionPagePath = '/details/';
33
+ this.openFacets = {
34
+ subject: false,
35
+ lending: false,
36
+ mediatype: false,
37
+ language: false,
38
+ creator: false,
39
+ collection: false,
40
+ year: false,
41
+ };
42
+ /**
43
+ * Maximum # of facet buckets to render per facet group
44
+ */
45
+ this.allowedFacetCount = 6;
46
+ this.handleExpandedDatePickerClosed = () => {
47
+ var _a;
48
+ (_a = this.modalManager) === null || _a === void 0 ? void 0 : _a.classList.remove('expanded-date-picker');
49
+ };
50
+ /**
51
+ * Dispatches a `histogramDateRangeUpdated` event with the date range copied from the
52
+ * input event.
53
+ *
54
+ * Arrow function to ensure `this` is always bound to the current component.
55
+ */
56
+ this.histogramDateRangeUpdated = (e) => {
57
+ const { minDate, maxDate } = e.detail;
58
+ const event = new CustomEvent('histogramDateRangeUpdated', {
59
+ detail: { minDate, maxDate },
60
+ });
61
+ this.dispatchEvent(event);
62
+ };
63
+ }
64
+ render() {
65
+ const datePickerLabelId = 'date-picker-label';
66
66
  return html `
67
67
  <div id="container" class="${this.facetsLoading ? 'loading' : ''}">
68
- ${this.showHistogramDatePicker &&
69
- (this.fullYearsHistogramAggregation || this.fullYearAggregationLoading)
68
+ ${this.showHistogramDatePicker &&
69
+ (this.fullYearsHistogramAggregation || this.fullYearAggregationLoading)
70
70
  ? html `
71
71
  <section class="facet-group" aria-labelledby=${datePickerLabelId}>
72
72
  <h3 id=${datePickerLabelId}>
@@ -75,18 +75,18 @@ let CollectionFacets = class CollectionFacets extends LitElement {
75
75
  </h3>
76
76
  ${this.histogramTemplate}
77
77
  </section>
78
- `
78
+ `
79
79
  : nothing}
80
80
  ${this.collectionPartOfTemplate}
81
81
  ${this.mergedFacets.map(facetGroup => this.getFacetGroupTemplate(facetGroup))}
82
82
  </div>
83
- `;
84
- }
85
- get collectionPartOfTemplate() {
86
- // We only display the "Part Of" section on collection pages
87
- if (!this.withinCollection || this.parentCollections.length === 0)
88
- return nothing;
89
- const headingId = 'partof-heading';
83
+ `;
84
+ }
85
+ get collectionPartOfTemplate() {
86
+ // We only display the "Part Of" section on collection pages
87
+ if (!this.withinCollection || this.parentCollections.length === 0)
88
+ return nothing;
89
+ const headingId = 'partof-heading';
90
90
  return html `
91
91
  <section
92
92
  class="facet-group partof-collections"
@@ -96,8 +96,8 @@ let CollectionFacets = class CollectionFacets extends LitElement {
96
96
  <h3 id=${headingId}>${msg('Part Of')}</h3>
97
97
  </div>
98
98
  <ul>
99
- ${map(this.parentCollections, collxn => {
100
- const collectionURL = `${this.baseNavigationUrl}${this.collectionPagePath}${collxn}`;
99
+ ${map(this.parentCollections, collxn => {
100
+ const collectionURL = `${this.baseNavigationUrl}${this.collectionPagePath}${collxn}`;
101
101
  return html ` <li>
102
102
  <a
103
103
  href=${collectionURL}
@@ -110,44 +110,44 @@ let CollectionFacets = class CollectionFacets extends LitElement {
110
110
  placeholder=${collxn}
111
111
  ></async-collection-name>
112
112
  </a>
113
- </li>`;
113
+ </li>`;
114
114
  })}
115
115
  </ul>
116
116
  </section>
117
- `;
118
- }
119
- partOfCollectionClicked(e) {
120
- var _a;
121
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
122
- category: analyticsCategories.default,
123
- action: analyticsActions.partOfCollectionClicked,
124
- label: e.target.dataset.id,
125
- });
126
- }
127
- /**
128
- * Opens a modal dialog containing an enlarged version of the date picker.
129
- */
130
- showDatePickerModal() {
131
- var _a, _b, _c;
132
- const { fullYearsHistogramAggregation } = this;
133
- const minDate = fullYearsHistogramAggregation === null || fullYearsHistogramAggregation === void 0 ? void 0 : fullYearsHistogramAggregation.first_bucket_key;
134
- const maxDate = fullYearsHistogramAggregation === null || fullYearsHistogramAggregation === void 0 ? void 0 : fullYearsHistogramAggregation.last_bucket_key;
135
- const buckets = fullYearsHistogramAggregation === null || fullYearsHistogramAggregation === void 0 ? void 0 : fullYearsHistogramAggregation.buckets;
136
- // Because the modal manager does not clear its DOM content after being closed,
137
- // it may try to render the exact same date picker template when it is reopened.
138
- // And because it isn't actually a descendent of this collection-facets component,
139
- // changes to the template defined here may not trigger a reactive update to the date
140
- // picker, resulting in it displaying a stale date range.
141
- // This ref callback ensures that every time the date picker modal is opened, it will
142
- // always propagate the most recent date range into the date picker regardless of
143
- // whether Lit thinks the update is necessary.
144
- const expandedDatePickerChanged = (elmt) => {
145
- if (elmt && elmt instanceof ExpandedDatePicker) {
146
- const expandedDatePicker = elmt;
147
- expandedDatePicker.minSelectedDate = this.minSelectedDate;
148
- expandedDatePicker.maxSelectedDate = this.maxSelectedDate;
149
- }
150
- };
117
+ `;
118
+ }
119
+ partOfCollectionClicked(e) {
120
+ var _a;
121
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
122
+ category: analyticsCategories.default,
123
+ action: analyticsActions.partOfCollectionClicked,
124
+ label: e.target.dataset.id,
125
+ });
126
+ }
127
+ /**
128
+ * Opens a modal dialog containing an enlarged version of the date picker.
129
+ */
130
+ showDatePickerModal() {
131
+ var _a, _b, _c;
132
+ const { fullYearsHistogramAggregation } = this;
133
+ const minDate = fullYearsHistogramAggregation === null || fullYearsHistogramAggregation === void 0 ? void 0 : fullYearsHistogramAggregation.first_bucket_key;
134
+ const maxDate = fullYearsHistogramAggregation === null || fullYearsHistogramAggregation === void 0 ? void 0 : fullYearsHistogramAggregation.last_bucket_key;
135
+ const buckets = fullYearsHistogramAggregation === null || fullYearsHistogramAggregation === void 0 ? void 0 : fullYearsHistogramAggregation.buckets;
136
+ // Because the modal manager does not clear its DOM content after being closed,
137
+ // it may try to render the exact same date picker template when it is reopened.
138
+ // And because it isn't actually a descendent of this collection-facets component,
139
+ // changes to the template defined here may not trigger a reactive update to the date
140
+ // picker, resulting in it displaying a stale date range.
141
+ // This ref callback ensures that every time the date picker modal is opened, it will
142
+ // always propagate the most recent date range into the date picker regardless of
143
+ // whether Lit thinks the update is necessary.
144
+ const expandedDatePickerChanged = (elmt) => {
145
+ if (elmt && elmt instanceof ExpandedDatePicker) {
146
+ const expandedDatePicker = elmt;
147
+ expandedDatePicker.minSelectedDate = this.minSelectedDate;
148
+ expandedDatePicker.maxSelectedDate = this.maxSelectedDate;
149
+ }
150
+ };
151
151
  const customModalContent = html `
152
152
  <expanded-date-picker
153
153
  ${ref(expandedDatePickerChanged)}
@@ -161,57 +161,57 @@ let CollectionFacets = class CollectionFacets extends LitElement {
161
161
  @histogramDateRangeApplied=${this.histogramDateRangeUpdated}
162
162
  @modalClosed=${this.handleExpandedDatePickerClosed}
163
163
  ></expanded-date-picker>
164
- `;
165
- const config = new ModalConfig({
166
- bodyColor: '#fff',
167
- headerColor: '#194880',
168
- showHeaderLogo: false,
169
- closeOnBackdropClick: true,
170
- title: html `Select a date range`,
171
- });
172
- (_a = this.modalManager) === null || _a === void 0 ? void 0 : _a.classList.add('expanded-date-picker');
173
- (_b = this.modalManager) === null || _b === void 0 ? void 0 : _b.showModal({
174
- config,
175
- customModalContent,
176
- userClosedModalCallback: this.handleExpandedDatePickerClosed,
177
- });
178
- (_c = this.analyticsHandler) === null || _c === void 0 ? void 0 : _c.sendEvent({
179
- category: analyticsCategories.default,
180
- action: analyticsActions.histogramExpanded,
181
- label: window.location.href,
182
- });
183
- }
184
- updated(changed) {
185
- if (changed.has('selectedFacets')) {
186
- this.dispatchFacetsChangedEvent();
187
- }
188
- }
189
- // TODO: want to fire analytics?
190
- dispatchFacetsChangedEvent() {
191
- const event = new CustomEvent('facetsChanged', {
192
- detail: this.selectedFacets,
193
- });
194
- this.dispatchEvent(event);
195
- }
196
- /**
197
- * Template for the "Expand" button to show the date picker modal, or
198
- * `nothing` if that button should currently not be shown.
199
- */
200
- get expandDatePickerBtnTemplate() {
201
- return this.allowExpandingDatePicker && !this.facetsLoading
164
+ `;
165
+ const config = new ModalConfig({
166
+ bodyColor: '#fff',
167
+ headerColor: '#194880',
168
+ showHeaderLogo: false,
169
+ closeOnBackdropClick: true,
170
+ title: html `Select a date range`,
171
+ });
172
+ (_a = this.modalManager) === null || _a === void 0 ? void 0 : _a.classList.add('expanded-date-picker');
173
+ (_b = this.modalManager) === null || _b === void 0 ? void 0 : _b.showModal({
174
+ config,
175
+ customModalContent,
176
+ userClosedModalCallback: this.handleExpandedDatePickerClosed,
177
+ });
178
+ (_c = this.analyticsHandler) === null || _c === void 0 ? void 0 : _c.sendEvent({
179
+ category: analyticsCategories.default,
180
+ action: analyticsActions.histogramExpanded,
181
+ label: window.location.href,
182
+ });
183
+ }
184
+ updated(changed) {
185
+ if (changed.has('selectedFacets')) {
186
+ this.dispatchFacetsChangedEvent();
187
+ }
188
+ }
189
+ // TODO: want to fire analytics?
190
+ dispatchFacetsChangedEvent() {
191
+ const event = new CustomEvent('facetsChanged', {
192
+ detail: this.selectedFacets,
193
+ });
194
+ this.dispatchEvent(event);
195
+ }
196
+ /**
197
+ * Template for the "Expand" button to show the date picker modal, or
198
+ * `nothing` if that button should currently not be shown.
199
+ */
200
+ get expandDatePickerBtnTemplate() {
201
+ return this.allowExpandingDatePicker && !this.facetsLoading
202
202
  ? html `<button
203
203
  class="expand-date-picker-btn"
204
204
  aria-hidden="true"
205
205
  @click=${this.showDatePickerModal}
206
206
  >
207
207
  ${expandIcon}
208
- </button>`
209
- : nothing;
210
- }
211
- get histogramTemplate() {
212
- const { fullYearsHistogramAggregation } = this;
213
- return this.fullYearAggregationLoading
214
- ? html `<div class="histogram-loading-indicator">&hellip;</div>` // Ellipsis block
208
+ </button>`
209
+ : nothing;
210
+ }
211
+ get histogramTemplate() {
212
+ const { fullYearsHistogramAggregation } = this;
213
+ return this.fullYearAggregationLoading
214
+ ? html `<div class="histogram-loading-indicator">&hellip;</div>` // Ellipsis block
215
215
  : html `
216
216
  <histogram-date-range
217
217
  .minDate=${fullYearsHistogramAggregation === null || fullYearsHistogramAggregation === void 0 ? void 0 : fullYearsHistogramAggregation.first_bucket_key}
@@ -220,180 +220,180 @@ let CollectionFacets = class CollectionFacets extends LitElement {
220
220
  .maxSelectedDate=${this.maxSelectedDate}
221
221
  .updateDelay=${100}
222
222
  missingDataMessage="..."
223
- .width=${this.collapsableFacets && this.contentWidth
224
- ? this.contentWidth
223
+ .width=${this.collapsableFacets && this.contentWidth
224
+ ? this.contentWidth
225
225
  : 180}
226
226
  .bins=${fullYearsHistogramAggregation === null || fullYearsHistogramAggregation === void 0 ? void 0 : fullYearsHistogramAggregation.buckets}
227
227
  @histogramDateRangeUpdated=${this.histogramDateRangeUpdated}
228
228
  ></histogram-date-range>
229
- `;
230
- }
231
- /**
232
- * Combines the selected facets with the aggregations to create a single list of facets
233
- */
234
- get mergedFacets() {
235
- const facetGroups = [];
236
- facetDisplayOrder.forEach(facetKey => {
237
- var _a, _b;
238
- const selectedFacetGroup = this.selectedFacetGroups.find(group => group.key === facetKey);
239
- const aggregateFacetGroup = this.aggregationFacetGroups.find(group => group.key === facetKey);
240
- // if the user selected a facet, but it's not in the aggregation, we add it as-is
241
- if (selectedFacetGroup && !aggregateFacetGroup) {
242
- facetGroups.push(selectedFacetGroup);
243
- return;
244
- }
245
- // if we don't have an aggregate facet group, don't add this to the list
246
- if (!aggregateFacetGroup)
247
- return;
248
- // start with either the selected group if we have one, or the aggregate group
249
- const facetGroup = selectedFacetGroup !== null && selectedFacetGroup !== void 0 ? selectedFacetGroup : aggregateFacetGroup;
250
- // attach the counts to the selected buckets
251
- let bucketsWithCount = (_a = selectedFacetGroup === null || selectedFacetGroup === void 0 ? void 0 : selectedFacetGroup.buckets.map(bucket => {
252
- const selectedBucket = aggregateFacetGroup.buckets.find(b => b.key === bucket.key);
253
- return selectedBucket
254
- ? {
255
- ...bucket,
256
- count: selectedBucket.count,
257
- }
258
- : bucket;
259
- })) !== null && _a !== void 0 ? _a : [];
260
- // append any additional buckets that were not selected
261
- aggregateFacetGroup.buckets.forEach(bucket => {
262
- const existingBucket = bucketsWithCount.find(b => b.key === bucket.key);
263
- if (existingBucket)
264
- return;
265
- bucketsWithCount.push(bucket);
266
- });
267
- /**
268
- * render limited facet items on page facet area
269
- *
270
- * - by-default we are showing 6 items
271
- * - additionally want to show all items (selected/suppressed) in page facet area
272
- */
273
- let allowedFacetCount = (_b = Object.keys((selectedFacetGroup === null || selectedFacetGroup === void 0 ? void 0 : selectedFacetGroup.buckets) || [])) === null || _b === void 0 ? void 0 : _b.length;
274
- if (allowedFacetCount < this.allowedFacetCount) {
275
- allowedFacetCount = this.allowedFacetCount; // splice start index from 0th
276
- }
277
- // For lending facets, only include a specific subset of buckets
278
- if (facetKey === 'lending') {
279
- bucketsWithCount = bucketsWithCount.filter(bucket => lendingFacetKeysVisibility[bucket.key]);
280
- }
281
- // For mediatype facets, ensure the collection bucket is always shown if present
282
- if (facetKey === 'mediatype') {
283
- const collectionIndex = bucketsWithCount.findIndex(bucket => bucket.key === 'collection');
284
- if (collectionIndex >= allowedFacetCount) {
285
- const [collectionBucket] = bucketsWithCount.splice(collectionIndex, 1);
286
- bucketsWithCount.splice(allowedFacetCount - 1, 0, collectionBucket);
287
- // If we're showing lots of selected facets, ensure we're not cutting off the last one
288
- if (allowedFacetCount > this.allowedFacetCount)
289
- allowedFacetCount += 1;
290
- }
291
- }
292
- // splice how many items we want to show in page facet area
293
- facetGroup.buckets = bucketsWithCount.splice(0, allowedFacetCount);
294
- facetGroups.push(facetGroup);
295
- });
296
- return facetGroups;
297
- }
298
- /**
299
- * Converts the selected facets to a `FacetGroup` array,
300
- * which is easier to work with
301
- */
302
- get selectedFacetGroups() {
303
- if (!this.selectedFacets)
304
- return [];
305
- const facetGroups = Object.entries(this.selectedFacets).map(([key, selectedFacets]) => {
306
- const option = key;
307
- const title = facetTitles[option];
308
- const buckets = Object.entries(selectedFacets).map(([value, facetData]) => {
309
- var _a;
310
- let displayText = value;
311
- // for lending facets, convert the key to a readable format
312
- if (option === 'lending') {
313
- displayText =
314
- (_a = lendingFacetDisplayNames[value]) !== null && _a !== void 0 ? _a : value;
315
- }
316
- return {
317
- displayText,
318
- key: value,
319
- count: facetData.count,
320
- state: facetData.state,
321
- };
322
- });
323
- return {
324
- title,
325
- key: option,
326
- buckets,
327
- };
328
- });
329
- return facetGroups;
330
- }
331
- /**
332
- * Converts the raw `aggregations` to `FacetGroups`, which are easier to use
333
- */
334
- get aggregationFacetGroups() {
335
- var _a;
336
- const facetGroups = [];
337
- Object.entries((_a = this.aggregations) !== null && _a !== void 0 ? _a : []).forEach(([key, aggregation]) => {
338
- // the year_histogram data is in a different format so can't be handled here
339
- if (key === 'year_histogram')
340
- return;
341
- const option = key;
342
- const title = facetTitles[option];
343
- if (!title)
344
- return;
345
- let castedBuckets = aggregation.getSortedBuckets(defaultFacetSort[option]);
346
- if (option === 'collection') {
347
- // we are not showing fav- collections or certain deemphasized collections in facets
348
- castedBuckets = castedBuckets === null || castedBuckets === void 0 ? void 0 : castedBuckets.filter(bucket => {
349
- var _a;
350
- const bucketKey = (_a = bucket === null || bucket === void 0 ? void 0 : bucket.key) === null || _a === void 0 ? void 0 : _a.toString();
351
- return (!suppressedCollections[bucketKey] && !(bucketKey === null || bucketKey === void 0 ? void 0 : bucketKey.startsWith('fav-')));
352
- });
353
- }
354
- const facetBuckets = castedBuckets.map(bucket => {
355
- var _a;
356
- const bucketKey = bucket.key;
357
- let displayText = `${bucket.key}`;
358
- // for lending facets, convert the bucket key to a readable format
359
- if (option === 'lending') {
360
- displayText =
361
- (_a = lendingFacetDisplayNames[bucket.key]) !== null && _a !== void 0 ? _a : `${bucket.key}`;
362
- }
363
- return {
364
- displayText,
365
- key: `${bucketKey}`,
366
- count: bucket.doc_count,
367
- state: 'none',
368
- };
369
- });
370
- const group = {
371
- title,
372
- key: option,
373
- buckets: facetBuckets,
374
- };
375
- facetGroups.push(group);
376
- });
377
- return facetGroups;
378
- }
379
- /**
380
- * Generate the template for a facet group with a header and the collapsible
381
- * chevron for the mobile view
382
- */
383
- getFacetGroupTemplate(facetGroup) {
384
- if (!this.facetsLoading && facetGroup.buckets.length === 0)
385
- return nothing;
386
- const { key } = facetGroup;
387
- const isOpen = this.openFacets[key];
229
+ `;
230
+ }
231
+ /**
232
+ * Combines the selected facets with the aggregations to create a single list of facets
233
+ */
234
+ get mergedFacets() {
235
+ const facetGroups = [];
236
+ facetDisplayOrder.forEach(facetKey => {
237
+ var _a, _b;
238
+ const selectedFacetGroup = this.selectedFacetGroups.find(group => group.key === facetKey);
239
+ const aggregateFacetGroup = this.aggregationFacetGroups.find(group => group.key === facetKey);
240
+ // if the user selected a facet, but it's not in the aggregation, we add it as-is
241
+ if (selectedFacetGroup && !aggregateFacetGroup) {
242
+ facetGroups.push(selectedFacetGroup);
243
+ return;
244
+ }
245
+ // if we don't have an aggregate facet group, don't add this to the list
246
+ if (!aggregateFacetGroup)
247
+ return;
248
+ // start with either the selected group if we have one, or the aggregate group
249
+ const facetGroup = selectedFacetGroup !== null && selectedFacetGroup !== void 0 ? selectedFacetGroup : aggregateFacetGroup;
250
+ // attach the counts to the selected buckets
251
+ let bucketsWithCount = (_a = selectedFacetGroup === null || selectedFacetGroup === void 0 ? void 0 : selectedFacetGroup.buckets.map(bucket => {
252
+ const selectedBucket = aggregateFacetGroup.buckets.find(b => b.key === bucket.key);
253
+ return selectedBucket
254
+ ? {
255
+ ...bucket,
256
+ count: selectedBucket.count,
257
+ }
258
+ : bucket;
259
+ })) !== null && _a !== void 0 ? _a : [];
260
+ // append any additional buckets that were not selected
261
+ aggregateFacetGroup.buckets.forEach(bucket => {
262
+ const existingBucket = bucketsWithCount.find(b => b.key === bucket.key);
263
+ if (existingBucket)
264
+ return;
265
+ bucketsWithCount.push(bucket);
266
+ });
267
+ /**
268
+ * render limited facet items on page facet area
269
+ *
270
+ * - by-default we are showing 6 items
271
+ * - additionally want to show all items (selected/suppressed) in page facet area
272
+ */
273
+ let allowedFacetCount = (_b = Object.keys((selectedFacetGroup === null || selectedFacetGroup === void 0 ? void 0 : selectedFacetGroup.buckets) || [])) === null || _b === void 0 ? void 0 : _b.length;
274
+ if (allowedFacetCount < this.allowedFacetCount) {
275
+ allowedFacetCount = this.allowedFacetCount; // splice start index from 0th
276
+ }
277
+ // For lending facets, only include a specific subset of buckets
278
+ if (facetKey === 'lending') {
279
+ bucketsWithCount = bucketsWithCount.filter(bucket => lendingFacetKeysVisibility[bucket.key]);
280
+ }
281
+ // For mediatype facets, ensure the collection bucket is always shown if present
282
+ if (facetKey === 'mediatype') {
283
+ const collectionIndex = bucketsWithCount.findIndex(bucket => bucket.key === 'collection');
284
+ if (collectionIndex >= allowedFacetCount) {
285
+ const [collectionBucket] = bucketsWithCount.splice(collectionIndex, 1);
286
+ bucketsWithCount.splice(allowedFacetCount - 1, 0, collectionBucket);
287
+ // If we're showing lots of selected facets, ensure we're not cutting off the last one
288
+ if (allowedFacetCount > this.allowedFacetCount)
289
+ allowedFacetCount += 1;
290
+ }
291
+ }
292
+ // splice how many items we want to show in page facet area
293
+ facetGroup.buckets = bucketsWithCount.splice(0, allowedFacetCount);
294
+ facetGroups.push(facetGroup);
295
+ });
296
+ return facetGroups;
297
+ }
298
+ /**
299
+ * Converts the selected facets to a `FacetGroup` array,
300
+ * which is easier to work with
301
+ */
302
+ get selectedFacetGroups() {
303
+ if (!this.selectedFacets)
304
+ return [];
305
+ const facetGroups = Object.entries(this.selectedFacets).map(([key, selectedFacets]) => {
306
+ const option = key;
307
+ const title = facetTitles[option];
308
+ const buckets = Object.entries(selectedFacets).map(([value, facetData]) => {
309
+ var _a;
310
+ let displayText = value;
311
+ // for lending facets, convert the key to a readable format
312
+ if (option === 'lending') {
313
+ displayText =
314
+ (_a = lendingFacetDisplayNames[value]) !== null && _a !== void 0 ? _a : value;
315
+ }
316
+ return {
317
+ displayText,
318
+ key: value,
319
+ count: facetData.count,
320
+ state: facetData.state,
321
+ };
322
+ });
323
+ return {
324
+ title,
325
+ key: option,
326
+ buckets,
327
+ };
328
+ });
329
+ return facetGroups;
330
+ }
331
+ /**
332
+ * Converts the raw `aggregations` to `FacetGroups`, which are easier to use
333
+ */
334
+ get aggregationFacetGroups() {
335
+ var _a;
336
+ const facetGroups = [];
337
+ Object.entries((_a = this.aggregations) !== null && _a !== void 0 ? _a : []).forEach(([key, aggregation]) => {
338
+ // the year_histogram data is in a different format so can't be handled here
339
+ if (key === 'year_histogram')
340
+ return;
341
+ const option = key;
342
+ const title = facetTitles[option];
343
+ if (!title)
344
+ return;
345
+ let castedBuckets = aggregation.getSortedBuckets(defaultFacetSort[option]);
346
+ if (option === 'collection') {
347
+ // we are not showing fav- collections or certain deemphasized collections in facets
348
+ castedBuckets = castedBuckets === null || castedBuckets === void 0 ? void 0 : castedBuckets.filter(bucket => {
349
+ var _a;
350
+ const bucketKey = (_a = bucket === null || bucket === void 0 ? void 0 : bucket.key) === null || _a === void 0 ? void 0 : _a.toString();
351
+ return (!suppressedCollections[bucketKey] && !(bucketKey === null || bucketKey === void 0 ? void 0 : bucketKey.startsWith('fav-')));
352
+ });
353
+ }
354
+ const facetBuckets = castedBuckets.map(bucket => {
355
+ var _a;
356
+ const bucketKey = bucket.key;
357
+ let displayText = `${bucket.key}`;
358
+ // for lending facets, convert the bucket key to a readable format
359
+ if (option === 'lending') {
360
+ displayText =
361
+ (_a = lendingFacetDisplayNames[bucket.key]) !== null && _a !== void 0 ? _a : `${bucket.key}`;
362
+ }
363
+ return {
364
+ displayText,
365
+ key: `${bucketKey}`,
366
+ count: bucket.doc_count,
367
+ state: 'none',
368
+ };
369
+ });
370
+ const group = {
371
+ title,
372
+ key: option,
373
+ buckets: facetBuckets,
374
+ };
375
+ facetGroups.push(group);
376
+ });
377
+ return facetGroups;
378
+ }
379
+ /**
380
+ * Generate the template for a facet group with a header and the collapsible
381
+ * chevron for the mobile view
382
+ */
383
+ getFacetGroupTemplate(facetGroup) {
384
+ if (!this.facetsLoading && facetGroup.buckets.length === 0)
385
+ return nothing;
386
+ const { key } = facetGroup;
387
+ const isOpen = this.openFacets[key];
388
388
  const collapser = html `
389
389
  <span class="collapser ${isOpen ? 'open' : ''}"> ${chevronIcon} </span>
390
- `;
391
- const toggleCollapsed = () => {
392
- const newOpenFacets = { ...this.openFacets };
393
- newOpenFacets[key] = !isOpen;
394
- this.openFacets = newOpenFacets;
395
- };
396
- const headerId = `facet-group-header-label-${facetGroup.key}`;
390
+ `;
391
+ const toggleCollapsed = () => {
392
+ const newOpenFacets = { ...this.openFacets };
393
+ newOpenFacets[key] = !isOpen;
394
+ this.openFacets = newOpenFacets;
395
+ };
396
+ const headerId = `facet-group-header-label-${facetGroup.key}`;
397
397
  return html `
398
398
  <section
399
399
  class="facet-group ${this.collapsableFacets ? 'mobile' : ''}"
@@ -410,61 +410,61 @@ let CollectionFacets = class CollectionFacets extends LitElement {
410
410
  </h3>
411
411
  </div>
412
412
  <div class="facet-group-content ${isOpen ? 'open' : ''}">
413
- ${this.facetsLoading
414
- ? this.getTombstoneFacetGroupTemplate()
413
+ ${this.facetsLoading
414
+ ? this.getTombstoneFacetGroupTemplate()
415
415
  : html `
416
416
  ${this.getFacetTemplate(facetGroup)}
417
417
  ${this.searchMoreFacetsLink(facetGroup)}
418
418
  `}
419
419
  </div>
420
420
  </section>
421
- `;
422
- }
423
- getTombstoneFacetGroupTemplate() {
424
- // Render five tombstone rows
421
+ `;
422
+ }
423
+ getTombstoneFacetGroupTemplate() {
424
+ // Render five tombstone rows
425
425
  return html `
426
426
  ${map(Array(5).fill(null), () => html `<facet-tombstone-row></facet-tombstone-row>`)}
427
- `;
428
- }
429
- /**
430
- * Generate the More... link button just below the facets group
431
- *
432
- * TODO: want to fire analytics?
433
- */
434
- searchMoreFacetsLink(facetGroup) {
435
- // Don't render More... links for FTS searches
436
- if (!this.moreLinksVisible) {
437
- return nothing;
438
- }
439
- // Don't render More... links for lending facets
440
- if (facetGroup.key === 'lending') {
441
- return nothing;
442
- }
443
- // Don't render More... link if the number of facets < this.allowedFacetCount
444
- if (Object.keys(facetGroup.buckets).length < this.allowedFacetCount) {
445
- return nothing;
446
- }
447
- // We sort years in numeric order by default, rather than bucket count
448
- const facetSort = defaultFacetSort[facetGroup.key];
427
+ `;
428
+ }
429
+ /**
430
+ * Generate the More... link button just below the facets group
431
+ *
432
+ * TODO: want to fire analytics?
433
+ */
434
+ searchMoreFacetsLink(facetGroup) {
435
+ // Don't render More... links for FTS searches
436
+ if (!this.moreLinksVisible) {
437
+ return nothing;
438
+ }
439
+ // Don't render More... links for lending facets
440
+ if (facetGroup.key === 'lending') {
441
+ return nothing;
442
+ }
443
+ // Don't render More... link if the number of facets < this.allowedFacetCount
444
+ if (Object.keys(facetGroup.buckets).length < this.allowedFacetCount) {
445
+ return nothing;
446
+ }
447
+ // We sort years in numeric order by default, rather than bucket count
448
+ const facetSort = defaultFacetSort[facetGroup.key];
449
449
  return html `<button
450
450
  class="more-link"
451
- @click=${() => {
452
- var _a;
453
- this.showMoreFacetsModal(facetGroup, facetSort);
454
- (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
455
- category: analyticsCategories.default,
456
- action: analyticsActions.showMoreFacetsModal,
457
- label: facetGroup.key,
458
- });
459
- this.dispatchEvent(new CustomEvent('showMoreFacets', { detail: facetGroup.key }));
451
+ @click=${() => {
452
+ var _a;
453
+ this.showMoreFacetsModal(facetGroup, facetSort);
454
+ (_a = this.analyticsHandler) === null || _a === void 0 ? void 0 : _a.sendEvent({
455
+ category: analyticsCategories.default,
456
+ action: analyticsActions.showMoreFacetsModal,
457
+ label: facetGroup.key,
458
+ });
459
+ this.dispatchEvent(new CustomEvent('showMoreFacets', { detail: facetGroup.key }));
460
460
  }}
461
461
  >
462
462
  More...
463
- </button>`;
464
- }
465
- async showMoreFacetsModal(facetGroup, sortedBy) {
466
- var _a, _b;
467
- const facetAggrKey = facetGroup.key;
463
+ </button>`;
464
+ }
465
+ async showMoreFacetsModal(facetGroup, sortedBy) {
466
+ var _a, _b;
467
+ const facetAggrKey = facetGroup.key;
468
468
  const customModalContent = html `
469
469
  <more-facets-content
470
470
  .analyticsHandler=${this.analyticsHandler}
@@ -479,38 +479,38 @@ let CollectionFacets = class CollectionFacets extends LitElement {
479
479
  .collectionNameCache=${this.collectionNameCache}
480
480
  .selectedFacets=${this.selectedFacets}
481
481
  .sortedBy=${sortedBy}
482
- @facetsChanged=${(e) => {
483
- const event = new CustomEvent('facetsChanged', {
484
- detail: e.detail,
485
- bubbles: true,
486
- composed: true,
487
- });
488
- this.dispatchEvent(event);
482
+ @facetsChanged=${(e) => {
483
+ const event = new CustomEvent('facetsChanged', {
484
+ detail: e.detail,
485
+ bubbles: true,
486
+ composed: true,
487
+ });
488
+ this.dispatchEvent(event);
489
489
  }}
490
490
  >
491
491
  </more-facets-content>
492
- `;
493
- const config = new ModalConfig({
494
- bodyColor: '#fff',
495
- headerColor: '#194880',
496
- showHeaderLogo: false,
497
- closeOnBackdropClick: true,
498
- title: html `Select filters`,
499
- });
500
- (_a = this.modalManager) === null || _a === void 0 ? void 0 : _a.classList.add('more-search-facets');
501
- (_b = this.modalManager) === null || _b === void 0 ? void 0 : _b.showModal({
502
- config,
503
- customModalContent,
504
- userClosedModalCallback: () => {
505
- var _a;
506
- (_a = this.modalManager) === null || _a === void 0 ? void 0 : _a.classList.remove('more-search-facets');
507
- },
508
- });
509
- }
510
- /**
511
- * Generate the list template for each bucket in a facet group
512
- */
513
- getFacetTemplate(facetGroup) {
492
+ `;
493
+ const config = new ModalConfig({
494
+ bodyColor: '#fff',
495
+ headerColor: '#194880',
496
+ showHeaderLogo: false,
497
+ closeOnBackdropClick: true,
498
+ title: html `Select filters`,
499
+ });
500
+ (_a = this.modalManager) === null || _a === void 0 ? void 0 : _a.classList.add('more-search-facets');
501
+ (_b = this.modalManager) === null || _b === void 0 ? void 0 : _b.showModal({
502
+ config,
503
+ customModalContent,
504
+ userClosedModalCallback: () => {
505
+ var _a;
506
+ (_a = this.modalManager) === null || _a === void 0 ? void 0 : _a.classList.remove('more-search-facets');
507
+ },
508
+ });
509
+ }
510
+ /**
511
+ * Generate the list template for each bucket in a facet group
512
+ */
513
+ getFacetTemplate(facetGroup) {
514
514
  return html `
515
515
  <facets-template
516
516
  .collectionPagePath=${this.collectionPagePath}
@@ -518,20 +518,20 @@ let CollectionFacets = class CollectionFacets extends LitElement {
518
518
  .selectedFacets=${this.selectedFacets}
519
519
  .renderOn=${'page'}
520
520
  .collectionNameCache=${this.collectionNameCache}
521
- @selectedFacetsChanged=${(e) => {
522
- const event = new CustomEvent('facetsChanged', {
523
- detail: e.detail,
524
- bubbles: true,
525
- composed: true,
526
- });
527
- this.dispatchEvent(event);
521
+ @selectedFacetsChanged=${(e) => {
522
+ const event = new CustomEvent('facetsChanged', {
523
+ detail: e.detail,
524
+ bubbles: true,
525
+ composed: true,
526
+ });
527
+ this.dispatchEvent(event);
528
528
  }}
529
529
  ></facets-template>
530
- `;
531
- }
532
- static get styles() {
533
- return [
534
- srOnlyStyle,
530
+ `;
531
+ }
532
+ static get styles() {
533
+ return [
534
+ srOnlyStyle,
535
535
  css `
536
536
  a:link {
537
537
  text-decoration: none;
@@ -646,93 +646,93 @@ let CollectionFacets = class CollectionFacets extends LitElement {
646
646
  height: 15px;
647
647
  cursor: pointer;
648
648
  }
649
- `,
650
- ];
651
- }
652
- };
653
- __decorate([
654
- property({ type: Object })
655
- ], CollectionFacets.prototype, "searchService", void 0);
656
- __decorate([
657
- property({ type: String })
658
- ], CollectionFacets.prototype, "searchType", void 0);
659
- __decorate([
660
- property({ type: Object })
661
- ], CollectionFacets.prototype, "aggregations", void 0);
662
- __decorate([
663
- property({ type: Object })
664
- ], CollectionFacets.prototype, "fullYearsHistogramAggregation", void 0);
665
- __decorate([
666
- property({ type: String })
667
- ], CollectionFacets.prototype, "minSelectedDate", void 0);
668
- __decorate([
669
- property({ type: String })
670
- ], CollectionFacets.prototype, "maxSelectedDate", void 0);
671
- __decorate([
672
- property({ type: Boolean })
673
- ], CollectionFacets.prototype, "moreLinksVisible", void 0);
674
- __decorate([
675
- property({ type: Boolean })
676
- ], CollectionFacets.prototype, "facetsLoading", void 0);
677
- __decorate([
678
- property({ type: Boolean })
679
- ], CollectionFacets.prototype, "fullYearAggregationLoading", void 0);
680
- __decorate([
681
- property({ type: Object })
682
- ], CollectionFacets.prototype, "selectedFacets", void 0);
683
- __decorate([
684
- property({ type: Boolean })
685
- ], CollectionFacets.prototype, "collapsableFacets", void 0);
686
- __decorate([
687
- property({ type: Number })
688
- ], CollectionFacets.prototype, "contentWidth", void 0);
689
- __decorate([
690
- property({ type: Boolean })
691
- ], CollectionFacets.prototype, "showHistogramDatePicker", void 0);
692
- __decorate([
693
- property({ type: Boolean })
694
- ], CollectionFacets.prototype, "allowExpandingDatePicker", void 0);
695
- __decorate([
696
- property({ type: String })
697
- ], CollectionFacets.prototype, "query", void 0);
698
- __decorate([
699
- property({ type: String })
700
- ], CollectionFacets.prototype, "withinCollection", void 0);
701
- __decorate([
702
- property({ type: Array })
703
- ], CollectionFacets.prototype, "parentCollections", void 0);
704
- __decorate([
705
- property({ type: Object })
706
- ], CollectionFacets.prototype, "filterMap", void 0);
707
- __decorate([
708
- property({ type: String })
709
- ], CollectionFacets.prototype, "baseNavigationUrl", void 0);
710
- __decorate([
711
- property({ type: String })
712
- ], CollectionFacets.prototype, "collectionPagePath", void 0);
713
- __decorate([
714
- property({ type: Object, attribute: false })
715
- ], CollectionFacets.prototype, "modalManager", void 0);
716
- __decorate([
717
- property({ type: Object, attribute: false })
718
- ], CollectionFacets.prototype, "resizeObserver", void 0);
719
- __decorate([
720
- property({ type: Object, attribute: false })
721
- ], CollectionFacets.prototype, "featureFeedbackService", void 0);
722
- __decorate([
723
- property({ type: Object, attribute: false })
724
- ], CollectionFacets.prototype, "recaptchaManager", void 0);
725
- __decorate([
726
- property({ type: Object, attribute: false })
727
- ], CollectionFacets.prototype, "analyticsHandler", void 0);
728
- __decorate([
729
- property({ type: Object, attribute: false })
730
- ], CollectionFacets.prototype, "collectionNameCache", void 0);
731
- __decorate([
732
- state()
733
- ], CollectionFacets.prototype, "openFacets", void 0);
734
- CollectionFacets = __decorate([
735
- customElement('collection-facets')
736
- ], CollectionFacets);
737
- export { CollectionFacets };
649
+ `,
650
+ ];
651
+ }
652
+ };
653
+ __decorate([
654
+ property({ type: Object })
655
+ ], CollectionFacets.prototype, "searchService", void 0);
656
+ __decorate([
657
+ property({ type: String })
658
+ ], CollectionFacets.prototype, "searchType", void 0);
659
+ __decorate([
660
+ property({ type: Object })
661
+ ], CollectionFacets.prototype, "aggregations", void 0);
662
+ __decorate([
663
+ property({ type: Object })
664
+ ], CollectionFacets.prototype, "fullYearsHistogramAggregation", void 0);
665
+ __decorate([
666
+ property({ type: String })
667
+ ], CollectionFacets.prototype, "minSelectedDate", void 0);
668
+ __decorate([
669
+ property({ type: String })
670
+ ], CollectionFacets.prototype, "maxSelectedDate", void 0);
671
+ __decorate([
672
+ property({ type: Boolean })
673
+ ], CollectionFacets.prototype, "moreLinksVisible", void 0);
674
+ __decorate([
675
+ property({ type: Boolean })
676
+ ], CollectionFacets.prototype, "facetsLoading", void 0);
677
+ __decorate([
678
+ property({ type: Boolean })
679
+ ], CollectionFacets.prototype, "fullYearAggregationLoading", void 0);
680
+ __decorate([
681
+ property({ type: Object })
682
+ ], CollectionFacets.prototype, "selectedFacets", void 0);
683
+ __decorate([
684
+ property({ type: Boolean })
685
+ ], CollectionFacets.prototype, "collapsableFacets", void 0);
686
+ __decorate([
687
+ property({ type: Number })
688
+ ], CollectionFacets.prototype, "contentWidth", void 0);
689
+ __decorate([
690
+ property({ type: Boolean })
691
+ ], CollectionFacets.prototype, "showHistogramDatePicker", void 0);
692
+ __decorate([
693
+ property({ type: Boolean })
694
+ ], CollectionFacets.prototype, "allowExpandingDatePicker", void 0);
695
+ __decorate([
696
+ property({ type: String })
697
+ ], CollectionFacets.prototype, "query", void 0);
698
+ __decorate([
699
+ property({ type: String })
700
+ ], CollectionFacets.prototype, "withinCollection", void 0);
701
+ __decorate([
702
+ property({ type: Array })
703
+ ], CollectionFacets.prototype, "parentCollections", void 0);
704
+ __decorate([
705
+ property({ type: Object })
706
+ ], CollectionFacets.prototype, "filterMap", void 0);
707
+ __decorate([
708
+ property({ type: String })
709
+ ], CollectionFacets.prototype, "baseNavigationUrl", void 0);
710
+ __decorate([
711
+ property({ type: String })
712
+ ], CollectionFacets.prototype, "collectionPagePath", void 0);
713
+ __decorate([
714
+ property({ type: Object, attribute: false })
715
+ ], CollectionFacets.prototype, "modalManager", void 0);
716
+ __decorate([
717
+ property({ type: Object, attribute: false })
718
+ ], CollectionFacets.prototype, "resizeObserver", void 0);
719
+ __decorate([
720
+ property({ type: Object, attribute: false })
721
+ ], CollectionFacets.prototype, "featureFeedbackService", void 0);
722
+ __decorate([
723
+ property({ type: Object, attribute: false })
724
+ ], CollectionFacets.prototype, "recaptchaManager", void 0);
725
+ __decorate([
726
+ property({ type: Object, attribute: false })
727
+ ], CollectionFacets.prototype, "analyticsHandler", void 0);
728
+ __decorate([
729
+ property({ type: Object, attribute: false })
730
+ ], CollectionFacets.prototype, "collectionNameCache", void 0);
731
+ __decorate([
732
+ state()
733
+ ], CollectionFacets.prototype, "openFacets", void 0);
734
+ CollectionFacets = __decorate([
735
+ customElement('collection-facets')
736
+ ], CollectionFacets);
737
+ export { CollectionFacets };
738
738
  //# sourceMappingURL=collection-facets.js.map