@internetarchive/collection-browser 4.0.1 → 4.1.0-alpha-webdev8164.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.
- package/dist/src/collection-facets/facets-template.js +5 -0
- package/dist/src/collection-facets/facets-template.js.map +1 -1
- package/dist/src/collection-facets/more-facets-content.d.ts +47 -8
- package/dist/src/collection-facets/more-facets-content.js +382 -83
- package/dist/src/collection-facets/more-facets-content.js.map +1 -1
- package/dist/src/collection-facets/more-facets-pagination.d.ts +10 -0
- package/dist/src/collection-facets/more-facets-pagination.js +64 -1
- package/dist/src/collection-facets/more-facets-pagination.js.map +1 -1
- package/dist/test/collection-facets/more-facets-content.test.js +154 -3
- package/dist/test/collection-facets/more-facets-content.test.js.map +1 -1
- package/dist/test/collection-facets/more-facets-pagination.test.js +60 -0
- package/dist/test/collection-facets/more-facets-pagination.test.js.map +1 -1
- package/package.json +1 -1
- package/src/collection-facets/facets-template.ts +5 -0
- package/src/collection-facets/more-facets-content.ts +411 -94
- package/src/collection-facets/more-facets-pagination.ts +73 -1
- package/test/collection-facets/more-facets-content.test.ts +218 -3
- package/test/collection-facets/more-facets-pagination.test.ts +84 -0
|
@@ -38,10 +38,15 @@ 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)`;
|
|
41
43
|
return css `
|
|
42
44
|
.facet-rows {
|
|
43
45
|
column-count: ${columnCount};
|
|
44
46
|
column-gap: ${columnGap};
|
|
47
|
+
column-width: ${columnWidth};
|
|
48
|
+
max-height: ${maxHeight};
|
|
49
|
+
column-fill: auto;
|
|
45
50
|
}
|
|
46
51
|
|
|
47
52
|
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,IAA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,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 {\n css,\n html,\n LitElement,\n TemplateResult,\n CSSResultGroup,\n nothing,\n} from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { repeat } from 'lit/directives/repeat.js';\nimport type { FacetGroup, FacetBucket, FacetEventDetails } from '../models';\nimport type { CollectionTitles } from '../data-source/models';\nimport './facet-row';\n\n@customElement('facets-template')\nexport class FacetsTemplate extends LitElement {\n @property({ type: Object }) facetGroup?: FacetGroup;\n\n @property({ type: Object })\n collectionTitles?: CollectionTitles;\n\n private facetClicked(e: CustomEvent<FacetEventDetails>) {\n this.dispatchFacetClickEvent(e.detail);\n }\n\n private dispatchFacetClickEvent(detail: FacetEventDetails) {\n const event = new CustomEvent<FacetEventDetails>('facetClick', {\n detail,\n composed: true,\n });\n this.dispatchEvent(event);\n }\n\n private get facetsTemplate(): TemplateResult | typeof nothing {\n const { facetGroup } = this;\n if (!facetGroup) return nothing;\n\n const facetBuckets = facetGroup.buckets as FacetBucket[];\n\n // Added data-testid for Playwright testing\n // Using className and aria-labels is not ideal for Playwright locator\n return html`\n <div class=\"facet-rows\" data-testid=\"facets-on-${facetGroup.key}\">\n ${repeat(\n facetBuckets,\n bucket => `${facetGroup.key}:${bucket.key}`,\n bucket =>\n html`<facet-row\n .facetType=${facetGroup.key}\n .bucket=${bucket}\n .collectionTitles=${this.collectionTitles}\n @facetClick=${this.facetClicked}\n ></facet-row>`,\n )}\n </div>\n `;\n }\n\n render() {\n return html`${this.facetsTemplate}`;\n }\n\n static get styles(): CSSResultGroup {\n const columnCount = css`var(--facetsColumnCount, 1)`;\n const columnGap = css`var(--facetsColumnGap, 15px)`;\n const columnWidth = css`var(--facetsColumnWidth, auto)`;\n const maxHeight = css`var(--facetsMaxHeight, none)`;\n\n return css`\n .facet-rows {\n column-count: ${columnCount};\n column-gap: ${columnGap};\n column-width: ${columnWidth};\n max-height: ${maxHeight};\n column-fill: auto;\n }\n\n a:link,\n a:visited {\n text-decoration: none;\n color: var(--ia-theme-link-color, #4b64ff);\n }\n a:hover {\n text-decoration: underline;\n }\n `;\n }\n}\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';
|
|
9
8
|
import './facets-template';
|
|
10
9
|
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,11 +51,25 @@ export declare class MoreFacetsContent extends LitElement {
|
|
|
51
51
|
*/
|
|
52
52
|
private unappliedFacetChanges;
|
|
53
53
|
/**
|
|
54
|
-
*
|
|
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).
|
|
55
60
|
*/
|
|
56
61
|
private pageNumber;
|
|
62
|
+
/**
|
|
63
|
+
* Whether the viewport is narrow enough to warrant compact pagination.
|
|
64
|
+
*/
|
|
65
|
+
private isCompactView;
|
|
57
66
|
willUpdate(changed: PropertyValues): void;
|
|
67
|
+
updated(changed: PropertyValues): void;
|
|
58
68
|
firstUpdated(): void;
|
|
69
|
+
/**
|
|
70
|
+
* Sets up a matchMedia listener to toggle compact pagination on narrow viewports.
|
|
71
|
+
*/
|
|
72
|
+
private setupCompactViewListener;
|
|
59
73
|
/**
|
|
60
74
|
* Close more facets modal on Escape click
|
|
61
75
|
*/
|
|
@@ -69,10 +83,6 @@ export declare class MoreFacetsContent extends LitElement {
|
|
|
69
83
|
* - this.aggregations - hold result of search service and being used for further processing.
|
|
70
84
|
*/
|
|
71
85
|
updateSpecificFacets(): Promise<void>;
|
|
72
|
-
/**
|
|
73
|
-
* Handler for page number changes from the pagination widget.
|
|
74
|
-
*/
|
|
75
|
-
private pageNumberClicked;
|
|
76
86
|
/**
|
|
77
87
|
* Combines the selected facets with the aggregations to create a single list of facets
|
|
78
88
|
*/
|
|
@@ -88,18 +98,47 @@ export declare class MoreFacetsContent extends LitElement {
|
|
|
88
98
|
*/
|
|
89
99
|
private get aggregationFacetGroup();
|
|
90
100
|
/**
|
|
91
|
-
* Returns
|
|
101
|
+
* Returns the facet group with buckets filtered by the current filter text.
|
|
102
|
+
* Filters are applied to the full bucket list before pagination.
|
|
103
|
+
*/
|
|
104
|
+
private get filteredFacetGroup();
|
|
105
|
+
/**
|
|
106
|
+
* Determines whether to use pagination based on the number of filtered facets.
|
|
107
|
+
* Returns true if facet count >= PAGINATION_THRESHOLD, false otherwise.
|
|
108
|
+
*/
|
|
109
|
+
private get usePagination();
|
|
110
|
+
/**
|
|
111
|
+
* Returns the facet group for the current page.
|
|
112
|
+
* If using pagination (>= 1000 facets), slices to show only the current page.
|
|
113
|
+
* Otherwise, returns all facets for horizontal scrolling.
|
|
92
114
|
*/
|
|
93
115
|
private get facetGroupForCurrentPage();
|
|
94
116
|
private get moreFacetsTemplate();
|
|
95
117
|
private get loaderTemplate();
|
|
118
|
+
private get emptyFilterResultsTemplate();
|
|
96
119
|
/**
|
|
97
|
-
*
|
|
120
|
+
* Number of pages for pagination (only used when facet count >= PAGINATION_THRESHOLD).
|
|
98
121
|
*/
|
|
99
122
|
private get paginationSize();
|
|
123
|
+
/**
|
|
124
|
+
* Template for pagination component (only shown when facet count >= PAGINATION_THRESHOLD).
|
|
125
|
+
*/
|
|
100
126
|
private get facetsPaginationTemplate();
|
|
101
127
|
private get footerTemplate();
|
|
102
128
|
private sortFacetAggregation;
|
|
129
|
+
/**
|
|
130
|
+
* Handler for filter input changes. Updates the filter text and triggers re-render.
|
|
131
|
+
*/
|
|
132
|
+
private handleFilterInput;
|
|
133
|
+
/**
|
|
134
|
+
* Clears the filter text and refocuses the input.
|
|
135
|
+
*/
|
|
136
|
+
private handleFilterClear;
|
|
137
|
+
/**
|
|
138
|
+
* Handler for pagination page number clicks.
|
|
139
|
+
* Only used when facet count >= PAGINATION_THRESHOLD.
|
|
140
|
+
*/
|
|
141
|
+
private pageNumberClicked;
|
|
103
142
|
private get modalHeaderTemplate();
|
|
104
143
|
render(): TemplateResult<1>;
|
|
105
144
|
private applySearchFacetsClicked;
|