@internetarchive/collection-browser 3.5.2-alpha-webdev8164.0 → 3.5.2-alpha-webdev8093.0

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.
@@ -38,15 +38,10 @@ let FacetsTemplate = class FacetsTemplate extends LitElement {
38
38
  static get styles() {
39
39
  const columnCount = css `var(--facetsColumnCount, 1)`;
40
40
  const columnGap = css `var(--facetsColumnGap, 15px)`;
41
- const columnWidth = css `var(--facetsColumnWidth, auto)`;
42
- const maxHeight = css `var(--facetsMaxHeight, none)`;
43
41
  return css `
44
42
  .facet-rows {
45
43
  column-count: ${columnCount};
46
44
  column-gap: ${columnGap};
47
- column-width: ${columnWidth};
48
- max-height: ${maxHeight};
49
- column-fill: auto;
50
45
  }
51
46
 
52
47
  a:link,
@@ -1 +1 @@
1
- {"version":3,"file":"facets-template.js","sourceRoot":"","sources":["../../../src/collection-facets/facets-template.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,GAAG,EACH,IAAI,EACJ,UAAU,EAGV,OAAO,GACR,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAGlD,OAAO,aAAa,CAAC;AAGd,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,UAAU;IAMpC,YAAY,CAAC,CAAiC;QACpD,IAAI,CAAC,uBAAuB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC;IAEO,uBAAuB,CAAC,MAAyB;QACvD,MAAM,KAAK,GAAG,IAAI,WAAW,CAAoB,YAAY,EAAE;YAC7D,MAAM;YACN,QAAQ,EAAE,IAAI;SACf,CAAC,CAAC;QACH,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED,IAAY,cAAc;QACxB,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;QAC5B,IAAI,CAAC,UAAU;YAAE,OAAO,OAAO,CAAC;QAEhC,MAAM,YAAY,GAAG,UAAU,CAAC,OAAwB,CAAC;QAEzD,2CAA2C;QAC3C,sEAAsE;QACtE,OAAO,IAAI,CAAA;uDACwC,UAAU,CAAC,GAAG;UAC3D,MAAM,CACN,YAAY,EACZ,MAAM,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,GAAG,IAAI,MAAM,CAAC,GAAG,EAAE,EAC3C,MAAM,CAAC,EAAE,CACP,IAAI,CAAA;2BACW,UAAU,CAAC,GAAG;wBACjB,MAAM;kCACI,IAAI,CAAC,gBAAgB;4BAC3B,IAAI,CAAC,YAAY;0BACnB,CACjB;;KAEJ,CAAC;IACJ,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAA,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;IACtC,CAAC;IAED,MAAM,KAAK,MAAM;QACf,MAAM,WAAW,GAAG,GAAG,CAAA,6BAA6B,CAAC;QACrD,MAAM,SAAS,GAAG,GAAG,CAAA,8BAA8B,CAAC;QACpD,MAAM,WAAW,GAAG,GAAG,CAAA,gCAAgC,CAAC;QACxD,MAAM,SAAS,GAAG,GAAG,CAAA,8BAA8B,CAAC;QAEpD,OAAO,GAAG,CAAA;;wBAEU,WAAW;sBACb,SAAS;wBACP,WAAW;sBACb,SAAS;;;;;;;;;;;;KAY1B,CAAC;IACJ,CAAC;CACF,CAAA;AAvE6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDAAyB;AAGpD;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;wDACS;AAJzB,cAAc;IAD1B,aAAa,CAAC,iBAAiB,CAAC;GACpB,cAAc,CAwE1B","sourcesContent":["import {\r\n css,\r\n html,\r\n LitElement,\r\n TemplateResult,\r\n CSSResultGroup,\r\n nothing,\r\n} from 'lit';\r\nimport { customElement, property } from 'lit/decorators.js';\r\nimport { repeat } from 'lit/directives/repeat.js';\r\nimport type { FacetGroup, FacetBucket, FacetEventDetails } from '../models';\r\nimport type { CollectionTitles } from '../data-source/models';\r\nimport './facet-row';\r\n\r\n@customElement('facets-template')\r\nexport class FacetsTemplate extends LitElement {\r\n @property({ type: Object }) facetGroup?: FacetGroup;\r\n\r\n @property({ type: Object })\r\n collectionTitles?: CollectionTitles;\r\n\r\n private facetClicked(e: CustomEvent<FacetEventDetails>) {\r\n this.dispatchFacetClickEvent(e.detail);\r\n }\r\n\r\n private dispatchFacetClickEvent(detail: FacetEventDetails) {\r\n const event = new CustomEvent<FacetEventDetails>('facetClick', {\r\n detail,\r\n composed: true,\r\n });\r\n this.dispatchEvent(event);\r\n }\r\n\r\n private get facetsTemplate(): TemplateResult | typeof nothing {\r\n const { facetGroup } = this;\r\n if (!facetGroup) return nothing;\r\n\r\n const facetBuckets = facetGroup.buckets as FacetBucket[];\r\n\r\n // Added data-testid for Playwright testing\r\n // Using className and aria-labels is not ideal for Playwright locator\r\n return html`\r\n <div class=\"facet-rows\" data-testid=\"facets-on-${facetGroup.key}\">\r\n ${repeat(\r\n facetBuckets,\r\n bucket => `${facetGroup.key}:${bucket.key}`,\r\n bucket =>\r\n html`<facet-row\r\n .facetType=${facetGroup.key}\r\n .bucket=${bucket}\r\n .collectionTitles=${this.collectionTitles}\r\n @facetClick=${this.facetClicked}\r\n ></facet-row>`,\r\n )}\r\n </div>\r\n `;\r\n }\r\n\r\n render() {\r\n return html`${this.facetsTemplate}`;\r\n }\r\n\r\n static get styles(): CSSResultGroup {\r\n const columnCount = css`var(--facetsColumnCount, 1)`;\r\n const columnGap = css`var(--facetsColumnGap, 15px)`;\r\n const columnWidth = css`var(--facetsColumnWidth, auto)`;\r\n const maxHeight = css`var(--facetsMaxHeight, none)`;\r\n\r\n return css`\r\n .facet-rows {\r\n column-count: ${columnCount};\r\n column-gap: ${columnGap};\r\n column-width: ${columnWidth};\r\n max-height: ${maxHeight};\r\n column-fill: auto;\r\n }\r\n\r\n a:link,\r\n a:visited {\r\n text-decoration: none;\r\n color: var(--ia-theme-link-color, #4b64ff);\r\n }\r\n a:hover {\r\n text-decoration: underline;\r\n }\r\n `;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"facets-template.js","sourceRoot":"","sources":["../../../src/collection-facets/facets-template.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,GAAG,EACH,IAAI,EACJ,UAAU,EAGV,OAAO,GACR,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAGlD,OAAO,aAAa,CAAC;AAGd,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,UAAU;IAMpC,YAAY,CAAC,CAAiC;QACpD,IAAI,CAAC,uBAAuB,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC;IAEO,uBAAuB,CAAC,MAAyB;QACvD,MAAM,KAAK,GAAG,IAAI,WAAW,CAAoB,YAAY,EAAE;YAC7D,MAAM;YACN,QAAQ,EAAE,IAAI;SACf,CAAC,CAAC;QACH,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED,IAAY,cAAc;QACxB,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,CAAC;QAC5B,IAAI,CAAC,UAAU;YAAE,OAAO,OAAO,CAAC;QAEhC,MAAM,YAAY,GAAG,UAAU,CAAC,OAAwB,CAAC;QAEzD,2CAA2C;QAC3C,sEAAsE;QACtE,OAAO,IAAI,CAAA;uDACwC,UAAU,CAAC,GAAG;UAC3D,MAAM,CACN,YAAY,EACZ,MAAM,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,GAAG,IAAI,MAAM,CAAC,GAAG,EAAE,EAC3C,MAAM,CAAC,EAAE,CACP,IAAI,CAAA;2BACW,UAAU,CAAC,GAAG;wBACjB,MAAM;kCACI,IAAI,CAAC,gBAAgB;4BAC3B,IAAI,CAAC,YAAY;0BACnB,CACjB;;KAEJ,CAAC;IACJ,CAAC;IAED,MAAM;QACJ,OAAO,IAAI,CAAA,GAAG,IAAI,CAAC,cAAc,EAAE,CAAC;IACtC,CAAC;IAED,MAAM,KAAK,MAAM;QACf,MAAM,WAAW,GAAG,GAAG,CAAA,6BAA6B,CAAC;QACrD,MAAM,SAAS,GAAG,GAAG,CAAA,8BAA8B,CAAC;QAEpD,OAAO,GAAG,CAAA;;wBAEU,WAAW;sBACb,SAAS;;;;;;;;;;;KAW1B,CAAC;IACJ,CAAC;CACF,CAAA;AAlE6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDAAyB;AAGpD;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;wDACS;AAJzB,cAAc;IAD1B,aAAa,CAAC,iBAAiB,CAAC;GACpB,cAAc,CAmE1B","sourcesContent":["import {\r\n css,\r\n html,\r\n LitElement,\r\n TemplateResult,\r\n CSSResultGroup,\r\n nothing,\r\n} from 'lit';\r\nimport { customElement, property } from 'lit/decorators.js';\r\nimport { repeat } from 'lit/directives/repeat.js';\r\nimport type { FacetGroup, FacetBucket, FacetEventDetails } from '../models';\r\nimport type { CollectionTitles } from '../data-source/models';\r\nimport './facet-row';\r\n\r\n@customElement('facets-template')\r\nexport class FacetsTemplate extends LitElement {\r\n @property({ type: Object }) facetGroup?: FacetGroup;\r\n\r\n @property({ type: Object })\r\n collectionTitles?: CollectionTitles;\r\n\r\n private facetClicked(e: CustomEvent<FacetEventDetails>) {\r\n this.dispatchFacetClickEvent(e.detail);\r\n }\r\n\r\n private dispatchFacetClickEvent(detail: FacetEventDetails) {\r\n const event = new CustomEvent<FacetEventDetails>('facetClick', {\r\n detail,\r\n composed: true,\r\n });\r\n this.dispatchEvent(event);\r\n }\r\n\r\n private get facetsTemplate(): TemplateResult | typeof nothing {\r\n const { facetGroup } = this;\r\n if (!facetGroup) return nothing;\r\n\r\n const facetBuckets = facetGroup.buckets as FacetBucket[];\r\n\r\n // Added data-testid for Playwright testing\r\n // Using className and aria-labels is not ideal for Playwright locator\r\n return html`\r\n <div class=\"facet-rows\" data-testid=\"facets-on-${facetGroup.key}\">\r\n ${repeat(\r\n facetBuckets,\r\n bucket => `${facetGroup.key}:${bucket.key}`,\r\n bucket =>\r\n html`<facet-row\r\n .facetType=${facetGroup.key}\r\n .bucket=${bucket}\r\n .collectionTitles=${this.collectionTitles}\r\n @facetClick=${this.facetClicked}\r\n ></facet-row>`,\r\n )}\r\n </div>\r\n `;\r\n }\r\n\r\n render() {\r\n return html`${this.facetsTemplate}`;\r\n }\r\n\r\n static get styles(): CSSResultGroup {\r\n const columnCount = css`var(--facetsColumnCount, 1)`;\r\n const columnGap = css`var(--facetsColumnGap, 15px)`;\r\n\r\n return css`\r\n .facet-rows {\r\n column-count: ${columnCount};\r\n column-gap: ${columnGap};\r\n }\r\n\r\n a:link,\r\n a:visited {\r\n text-decoration: none;\r\n color: var(--ia-theme-link-color, #4b64ff);\r\n }\r\n a:hover {\r\n text-decoration: underline;\r\n }\r\n `;\r\n }\r\n}\r\n"]}
@@ -5,9 +5,9 @@ import type { AnalyticsManagerInterface } from '@internetarchive/analytics-manag
5
5
  import { SelectedFacets, FacetOption } from '../models';
6
6
  import type { CollectionTitles, PageSpecifierParams, TVChannelAliases } from '../data-source/models';
7
7
  import '@internetarchive/elements/ia-status-indicator/ia-status-indicator';
8
+ import './more-facets-pagination';
8
9
  import './facets-template';
9
10
  import './toggle-switch';
10
- import './more-facets-pagination';
11
11
  export declare class MoreFacetsContent extends LitElement {
12
12
  facetKey?: FacetOption;
13
13
  query?: string;
@@ -51,12 +51,7 @@ export declare class MoreFacetsContent extends LitElement {
51
51
  */
52
52
  private unappliedFacetChanges;
53
53
  /**
54
- * Text entered by the user to filter facet buckets.
55
- * Applied to bucket.key for case-insensitive matching.
56
- */
57
- private filterText;
58
- /**
59
- * Current page number for pagination (when facet count >= PAGINATION_THRESHOLD).
54
+ * Which page of facets we are showing.
60
55
  */
61
56
  private pageNumber;
62
57
  willUpdate(changed: PropertyValues): void;
@@ -75,6 +70,10 @@ export declare class MoreFacetsContent extends LitElement {
75
70
  * - this.aggregations - hold result of search service and being used for further processing.
76
71
  */
77
72
  updateSpecificFacets(): Promise<void>;
73
+ /**
74
+ * Handler for page number changes from the pagination widget.
75
+ */
76
+ private pageNumberClicked;
78
77
  /**
79
78
  * Combines the selected facets with the aggregations to create a single list of facets
80
79
  */
@@ -90,43 +89,18 @@ export declare class MoreFacetsContent extends LitElement {
90
89
  */
91
90
  private get aggregationFacetGroup();
92
91
  /**
93
- * Returns the facet group with buckets filtered by the current filter text.
94
- * Filters are applied to the full bucket list before pagination.
95
- */
96
- private get filteredFacetGroup();
97
- /**
98
- * Determines whether to use pagination based on the number of filtered facets.
99
- * Returns true if facet count >= PAGINATION_THRESHOLD, false otherwise.
100
- */
101
- private get usePagination();
102
- /**
103
- * Returns the facet group for the current page.
104
- * If using pagination (>= 1000 facets), slices to show only the current page.
105
- * Otherwise, returns all facets for horizontal scrolling.
92
+ * Returns a FacetGroup representing only the current page of facet buckets to show.
106
93
  */
107
94
  private get facetGroupForCurrentPage();
108
95
  private get moreFacetsTemplate();
109
96
  private get loaderTemplate();
110
- private get emptyFilterResultsTemplate();
111
97
  /**
112
- * Number of pages for pagination (only used when facet count >= PAGINATION_THRESHOLD).
98
+ * How many pages of facets to show in the modal pagination widget
113
99
  */
114
100
  private get paginationSize();
115
- /**
116
- * Template for pagination component (only shown when facet count >= PAGINATION_THRESHOLD).
117
- */
118
101
  private get facetsPaginationTemplate();
119
102
  private get footerTemplate();
120
103
  private sortFacetAggregation;
121
- /**
122
- * Handler for filter input changes. Updates the filter text and triggers re-render.
123
- */
124
- private handleFilterInput;
125
- /**
126
- * Handler for pagination page number clicks.
127
- * Only used when facet count >= PAGINATION_THRESHOLD.
128
- */
129
- private pageNumberClicked;
130
104
  private get modalHeaderTemplate();
131
105
  render(): TemplateResult<1>;
132
106
  private applySearchFacetsClicked;
@@ -5,18 +5,13 @@ import { AggregationSortType, } from '@internetarchive/search-service';
5
5
  import { msg } from '@lit/localize';
6
6
  import { facetTitles, suppressedCollections, valueFacetSort, defaultFacetSort, getDefaultSelectedFacets, } from '../models';
7
7
  import '@internetarchive/elements/ia-status-indicator/ia-status-indicator';
8
+ import './more-facets-pagination';
8
9
  import './facets-template';
9
10
  import { analyticsActions, analyticsCategories, } from '../utils/analytics-events';
10
11
  import './toggle-switch';
11
- import './more-facets-pagination';
12
12
  import { srOnlyStyle } from '../styles/sr-only';
13
13
  import { mergeSelectedFacets, sortBucketsBySelectionState, updateSelectedFacetBucket, } from '../utils/facet-utils';
14
14
  import { MORE_FACETS__DEFAULT_PAGE_SIZE, MORE_FACETS__MAX_AGGREGATIONS, } from './models';
15
- /**
16
- * Threshold for switching from horizontal scroll to pagination.
17
- * If facet count >= this value, use pagination. Otherwise use horizontal scroll.
18
- */
19
- const PAGINATION_THRESHOLD = 1000;
20
15
  let MoreFacetsContent = class MoreFacetsContent extends LitElement {
21
16
  constructor() {
22
17
  super(...arguments);
@@ -39,12 +34,7 @@ let MoreFacetsContent = class MoreFacetsContent extends LitElement {
39
34
  */
40
35
  this.unappliedFacetChanges = getDefaultSelectedFacets();
41
36
  /**
42
- * Text entered by the user to filter facet buckets.
43
- * Applied to bucket.key for case-insensitive matching.
44
- */
45
- this.filterText = '';
46
- /**
47
- * Current page number for pagination (when facet count >= PAGINATION_THRESHOLD).
37
+ * Which page of facets we are showing.
48
38
  */
49
39
  this.pageNumber = 1;
50
40
  }
@@ -58,10 +48,6 @@ let MoreFacetsContent = class MoreFacetsContent extends LitElement {
58
48
  // store it for reuse across pages.
59
49
  this.facetGroup = this.mergedFacets;
60
50
  }
61
- // Reset to page 1 when filter text changes (only matters for pagination mode)
62
- if (changed.has('filterText')) {
63
- this.pageNumber = 1;
64
- }
65
51
  }
66
52
  updated(changed) {
67
53
  // If any of the search properties change, it triggers a facet fetch
@@ -70,7 +56,7 @@ let MoreFacetsContent = class MoreFacetsContent extends LitElement {
70
56
  changed.has('searchType') ||
71
57
  changed.has('filterMap')) {
72
58
  this.facetsLoading = true;
73
- this.pageNumber = 1; // Reset to page 1 on new search
59
+ this.pageNumber = 1;
74
60
  this.sortedBy = defaultFacetSort[this.facetKey];
75
61
  this.updateSpecificFacets();
76
62
  }
@@ -135,6 +121,20 @@ let MoreFacetsContent = class MoreFacetsContent extends LitElement {
135
121
  }
136
122
  }
137
123
  }
124
+ /**
125
+ * Handler for page number changes from the pagination widget.
126
+ */
127
+ pageNumberClicked(e) {
128
+ const page = e?.detail?.page;
129
+ if (page) {
130
+ this.pageNumber = Number(page);
131
+ }
132
+ this.analyticsHandler?.sendEvent({
133
+ category: analyticsCategories.default,
134
+ action: analyticsActions.moreFacetsPageChange,
135
+ label: `${this.pageNumber}`,
136
+ });
137
+ }
138
138
  /**
139
139
  * Combines the selected facets with the aggregations to create a single list of facets
140
140
  */
@@ -252,65 +252,24 @@ let MoreFacetsContent = class MoreFacetsContent extends LitElement {
252
252
  };
253
253
  }
254
254
  /**
255
- * Returns the facet group with buckets filtered by the current filter text.
256
- * Filters are applied to the full bucket list before pagination.
255
+ * Returns a FacetGroup representing only the current page of facet buckets to show.
257
256
  */
258
- get filteredFacetGroup() {
259
- const { facetGroup, filterText } = this;
257
+ get facetGroupForCurrentPage() {
258
+ const { facetGroup } = this;
260
259
  if (!facetGroup)
261
260
  return undefined;
262
- // If no filter text, return the full group
263
- if (!filterText.trim()) {
264
- return facetGroup;
265
- }
266
- // Filter buckets case-insensitively by bucket key
267
- const lowerFilter = filterText.toLowerCase().trim();
268
- const filteredBuckets = facetGroup.buckets.filter(bucket => bucket.key.toLowerCase().includes(lowerFilter));
261
+ // Slice out only the current page of facet buckets
262
+ const firstBucketIndexOnPage = (this.pageNumber - 1) * this.facetsPerPage;
263
+ const truncatedBuckets = facetGroup.buckets.slice(firstBucketIndexOnPage, firstBucketIndexOnPage + this.facetsPerPage);
269
264
  return {
270
265
  ...facetGroup,
271
- buckets: filteredBuckets,
272
- };
273
- }
274
- /**
275
- * Determines whether to use pagination based on the number of filtered facets.
276
- * Returns true if facet count >= PAGINATION_THRESHOLD, false otherwise.
277
- */
278
- get usePagination() {
279
- const facetCount = this.filteredFacetGroup?.buckets.length ?? 0;
280
- return facetCount >= PAGINATION_THRESHOLD;
281
- }
282
- /**
283
- * Returns the facet group for the current page.
284
- * If using pagination (>= 1000 facets), slices to show only the current page.
285
- * Otherwise, returns all facets for horizontal scrolling.
286
- */
287
- get facetGroupForCurrentPage() {
288
- const filteredGroup = this.filteredFacetGroup;
289
- if (!filteredGroup)
290
- return undefined;
291
- // If facet count is below threshold, show all facets with horizontal scroll
292
- if (!this.usePagination) {
293
- return filteredGroup;
294
- }
295
- // Otherwise, use pagination - slice to current page
296
- const startIndex = (this.pageNumber - 1) * this.facetsPerPage;
297
- const endIndex = startIndex + this.facetsPerPage;
298
- const slicedBuckets = filteredGroup.buckets.slice(startIndex, endIndex);
299
- return {
300
- ...filteredGroup,
301
- buckets: slicedBuckets,
266
+ buckets: truncatedBuckets,
302
267
  };
303
268
  }
304
269
  get moreFacetsTemplate() {
305
- const facetGroup = this.facetGroupForCurrentPage;
306
- // Show empty state if filtering returned no results
307
- if (this.filterText.trim() &&
308
- (!facetGroup || facetGroup.buckets.length === 0)) {
309
- return this.emptyFilterResultsTemplate;
310
- }
311
270
  return html `
312
271
  <facets-template
313
- .facetGroup=${facetGroup}
272
+ .facetGroup=${this.facetGroupForCurrentPage}
314
273
  .selectedFacets=${this.selectedFacets}
315
274
  .collectionTitles=${this.collectionTitles}
316
275
  @facetClick=${(e) => {
@@ -329,75 +288,52 @@ let MoreFacetsContent = class MoreFacetsContent extends LitElement {
329
288
  ></ia-status-indicator>
330
289
  `;
331
290
  }
332
- get emptyFilterResultsTemplate() {
333
- return html `
334
- <div class="empty-results">
335
- <p>${msg('No matching values found.')}</p>
336
- <p class="hint">${msg('Try a different search term.')}</p>
337
- </div>
338
- `;
339
- }
340
291
  /**
341
- * Number of pages for pagination (only used when facet count >= PAGINATION_THRESHOLD).
292
+ * How many pages of facets to show in the modal pagination widget
342
293
  */
343
294
  get paginationSize() {
344
- const filteredBuckets = this.filteredFacetGroup?.buckets ?? [];
345
- return Math.ceil(filteredBuckets.length / this.facetsPerPage);
295
+ if (!this.aggregations || !this.facetKey)
296
+ return 0;
297
+ // Calculate the appropriate number of pages to show in the modal pagination widget
298
+ const length = this.aggregations[this.facetKey]?.buckets.length;
299
+ return Math.ceil(length / this.facetsPerPage);
346
300
  }
347
- /**
348
- * Template for pagination component (only shown when facet count >= PAGINATION_THRESHOLD).
349
- */
301
+ // render pagination if more then 1 page
350
302
  get facetsPaginationTemplate() {
351
- if (!this.usePagination)
352
- return nothing;
353
- return html `<more-facets-pagination
354
- .size=${this.paginationSize}
355
- .currentPage=${this.pageNumber}
356
- @pageNumberClicked=${this.pageNumberClicked}
357
- ></more-facets-pagination>`;
303
+ return this.paginationSize > 1
304
+ ? html `<more-facets-pagination
305
+ .size=${this.paginationSize}
306
+ .currentPage=${1}
307
+ @pageNumberClicked=${this.pageNumberClicked}
308
+ ></more-facets-pagination>`
309
+ : nothing;
358
310
  }
359
311
  get footerTemplate() {
360
- return html `
361
- ${this.facetsPaginationTemplate}
362
- <div class="footer">
363
- <button class="btn btn-cancel" type="button" @click=${this.cancelClick}>
364
- Cancel
365
- </button>
366
- <button
367
- class="btn btn-submit"
368
- type="button"
369
- @click=${this.applySearchFacetsClicked}
370
- >
371
- Apply filters
372
- </button>
373
- </div>
374
- `;
312
+ if (this.paginationSize > 0) {
313
+ return html `${this.facetsPaginationTemplate}
314
+ <div class="footer">
315
+ <button
316
+ class="btn btn-cancel"
317
+ type="button"
318
+ @click=${this.cancelClick}
319
+ >
320
+ Cancel
321
+ </button>
322
+ <button
323
+ class="btn btn-submit"
324
+ type="button"
325
+ @click=${this.applySearchFacetsClicked}
326
+ >
327
+ Apply filters
328
+ </button>
329
+ </div> `;
330
+ }
331
+ return nothing;
375
332
  }
376
333
  sortFacetAggregation(facetSortType) {
377
334
  this.sortedBy = facetSortType;
378
335
  this.dispatchEvent(new CustomEvent('sortedFacets', { detail: this.sortedBy }));
379
336
  }
380
- /**
381
- * Handler for filter input changes. Updates the filter text and triggers re-render.
382
- */
383
- handleFilterInput(e) {
384
- const input = e.target;
385
- this.filterText = input.value;
386
- }
387
- /**
388
- * Handler for pagination page number clicks.
389
- * Only used when facet count >= PAGINATION_THRESHOLD.
390
- */
391
- pageNumberClicked(e) {
392
- this.pageNumber = e.detail.page;
393
- // Track page navigation in analytics
394
- this.analyticsHandler?.sendEvent({
395
- category: analyticsCategories.default,
396
- action: analyticsActions.moreFacetsPageChange,
397
- label: `${this.pageNumber}`,
398
- });
399
- this.dispatchEvent(new CustomEvent('pageChanged', { detail: this.pageNumber }));
400
- }
401
337
  get modalHeaderTemplate() {
402
338
  const facetSort = this.sortedBy ?? defaultFacetSort[this.facetKey];
403
339
  const defaultSwitchSide = facetSort === AggregationSortType.COUNT ? 'left' : 'right';
@@ -419,41 +355,16 @@ let MoreFacetsContent = class MoreFacetsContent extends LitElement {
419
355
  }}
420
356
  ></toggle-switch>`
421
357
  : nothing}
422
-
423
- <label class="filter-label" for="facet-filter"
424
- >${msg('Filter by:')}</label
425
- >
426
- <input
427
- id="facet-filter"
428
- type="text"
429
- class="filter-input"
430
- .value=${this.filterText}
431
- @input=${this.handleFilterInput}
432
- placeholder=${msg('Search...')}
433
- aria-label=${msg('Filter facets')}
434
- />
435
358
  </span>`;
436
359
  }
437
360
  render() {
438
- const contentClass = this.usePagination
439
- ? 'facets-content pagination-mode'
440
- : 'facets-content horizontal-scroll-mode';
441
- const sectionClass = this.usePagination
442
- ? 'pagination-mode'
443
- : 'horizontal-scroll-mode';
444
361
  return html `
445
362
  ${this.facetsLoading
446
363
  ? this.loaderTemplate
447
364
  : html `
448
- <section id="more-facets" class="${sectionClass}">
365
+ <section id="more-facets">
449
366
  <div class="header-content">${this.modalHeaderTemplate}</div>
450
- <div class="${contentClass}">
451
- ${this.usePagination
452
- ? this.moreFacetsTemplate
453
- : html `<div class="facets-horizontal-container">
454
- ${this.moreFacetsTemplate}
455
- </div>`}
456
- </div>
367
+ <div class="facets-content">${this.moreFacetsTemplate}</div>
457
368
  ${this.footerTemplate}
458
369
  </section>
459
370
  `}
@@ -469,8 +380,6 @@ let MoreFacetsContent = class MoreFacetsContent extends LitElement {
469
380
  this.dispatchEvent(event);
470
381
  // Reset the unapplied changes back to default, now that they have been applied
471
382
  this.unappliedFacetChanges = getDefaultSelectedFacets();
472
- // Reset filter text
473
- this.filterText = '';
474
383
  this.modalManager?.closeModal();
475
384
  this.analyticsHandler?.sendEvent({
476
385
  category: analyticsCategories.default,
@@ -481,8 +390,6 @@ let MoreFacetsContent = class MoreFacetsContent extends LitElement {
481
390
  cancelClick() {
482
391
  // Reset the unapplied changes back to default
483
392
  this.unappliedFacetChanges = getDefaultSelectedFacets();
484
- // Reset filter text
485
- this.filterText = '';
486
393
  this.modalManager?.closeModal();
487
394
  this.analyticsHandler?.sendEvent({
488
395
  category: analyticsCategories.default,
@@ -500,18 +407,6 @@ let MoreFacetsContent = class MoreFacetsContent extends LitElement {
500
407
  padding: 10px; /* leaves room for scroll bar to appear without overlaying on content */
501
408
  --facetsColumnCount: 3;
502
409
  }
503
-
504
- /* Horizontal scroll mode: fixed column height for horizontal overflow */
505
- section#more-facets.horizontal-scroll-mode {
506
- --facetsColumnCount: 3;
507
- --facetsMaxHeight: 280px;
508
- }
509
-
510
- /* Pagination mode: set height for proper column layout with vertical scroll */
511
- section#more-facets.pagination-mode {
512
- --facetsColumnCount: 3;
513
- --facetsMaxHeight: 280px; /* Columns need height constraint to flow properly */
514
- }
515
410
  .header-content .title {
516
411
  display: block;
517
412
  text-align: left;
@@ -529,92 +424,11 @@ let MoreFacetsContent = class MoreFacetsContent extends LitElement {
529
424
  font-weight: normal;
530
425
  }
531
426
 
532
- .filter-label {
533
- margin-left: 20px;
534
- font-size: 1.3rem;
535
- }
536
-
537
- .filter-input {
538
- font-size: 1.3rem;
539
- padding: 4px 8px;
540
- border: 1px solid #ccc;
541
- border-radius: 4px;
542
- margin-left: 5px;
543
- width: 150px;
544
- font-family: inherit;
545
- }
546
-
547
- .filter-input:focus {
548
- outline: 2px solid #194880;
549
- outline-offset: 1px;
550
- border-color: #194880;
551
- }
552
-
553
- .empty-results {
554
- text-align: center;
555
- padding: 40px 20px;
556
- color: #666;
557
- }
558
-
559
- .empty-results .hint {
560
- font-size: 1.1rem;
561
- margin-top: 10px;
562
- }
563
-
564
427
  .facets-content {
565
428
  font-size: 1.2rem;
566
429
  max-height: 300px;
430
+ overflow: auto;
567
431
  padding: 10px;
568
- /* Force scrollbar to always be visible */
569
- scrollbar-width: thin; /* Firefox */
570
- scrollbar-color: #888 #f1f1f1; /* Firefox - thumb and track colors */
571
- }
572
-
573
- /* Pagination mode: vertical scrolling, allow taller height for multiple columns */
574
- .facets-content.pagination-mode {
575
- overflow-y: auto;
576
- overflow-x: hidden;
577
- max-height: none; /* Remove height constraint to allow columns to flow properly */
578
- height: 300px; /* Fixed height to enable vertical scroll */
579
- }
580
-
581
- /* Horizontal scroll mode: horizontal scrolling only */
582
- .facets-content.horizontal-scroll-mode {
583
- overflow-x: auto;
584
- overflow-y: hidden;
585
- }
586
-
587
- /* Webkit browsers scrollbar styling - always visible */
588
- .facets-content::-webkit-scrollbar {
589
- width: 12px; /* Vertical scrollbar width */
590
- height: 12px; /* Horizontal scrollbar height */
591
- }
592
-
593
- .facets-content::-webkit-scrollbar-track {
594
- background: #f1f1f1;
595
- border-radius: 6px;
596
- }
597
-
598
- .facets-content::-webkit-scrollbar-thumb {
599
- background: #888;
600
- border-radius: 6px;
601
- min-height: 30px; /* Ensure thumb is always visible when scrolling is possible */
602
- }
603
-
604
- .facets-content::-webkit-scrollbar-thumb:hover {
605
- background: #555;
606
- }
607
-
608
- /* Force corner to match track color */
609
- .facets-content::-webkit-scrollbar-corner {
610
- background: #f1f1f1;
611
- }
612
-
613
- .facets-horizontal-container {
614
- display: inline-block;
615
- min-width: 100%;
616
- /* Allow natural width expansion based on content */
617
- width: fit-content;
618
432
  }
619
433
  .facets-loader {
620
434
  --icon-width: 70px;
@@ -645,24 +459,14 @@ let MoreFacetsContent = class MoreFacetsContent extends LitElement {
645
459
  }
646
460
 
647
461
  @media (max-width: 560px) {
648
- section#more-facets.horizontal-scroll-mode,
649
- section#more-facets.pagination-mode {
462
+ section#more-facets {
650
463
  max-height: 450px;
651
- --facetsColumnCount: 1; /* Single column on mobile */
652
- --facetsMaxHeight: none; /* Remove fixed height for vertical scrolling */
464
+ --facetsColumnCount: 1;
653
465
  }
654
- /* On mobile, always use vertical scrolling regardless of mode */
655
- .facets-content,
656
- .facets-content.pagination-mode,
657
- .facets-content.horizontal-scroll-mode {
466
+ .facets-content {
658
467
  overflow-y: auto;
659
- overflow-x: hidden;
660
468
  height: 300px;
661
469
  }
662
- .filter-input {
663
- width: 120px;
664
- font-size: 1.2rem;
665
- }
666
470
  }
667
471
  `,
668
472
  ];
@@ -725,9 +529,6 @@ __decorate([
725
529
  __decorate([
726
530
  state()
727
531
  ], MoreFacetsContent.prototype, "unappliedFacetChanges", void 0);
728
- __decorate([
729
- state()
730
- ], MoreFacetsContent.prototype, "filterText", void 0);
731
532
  __decorate([
732
533
  state()
733
534
  ], MoreFacetsContent.prototype, "pageNumber", void 0);