@internetarchive/collection-browser 4.1.0 → 4.2.0-alpha-webdev8164.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.editorconfig +29 -29
- package/.github/workflows/ci.yml +27 -27
- package/.github/workflows/gh-pages-main.yml +39 -39
- package/.github/workflows/npm-publish.yml +39 -39
- package/.github/workflows/pr-preview.yml +38 -38
- package/.husky/pre-commit +1 -1
- package/.prettierignore +1 -1
- package/LICENSE +661 -661
- package/README.md +83 -83
- package/dist/src/collection-browser.js +761 -761
- package/dist/src/collection-browser.js.map +1 -1
- 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 +95 -8
- package/dist/src/collection-facets/more-facets-content.js +576 -102
- package/dist/src/collection-facets/more-facets-content.js.map +1 -1
- package/dist/src/collection-facets/more-facets-pagination.d.ts +12 -3
- package/dist/src/collection-facets/more-facets-pagination.js +71 -9
- package/dist/src/collection-facets/more-facets-pagination.js.map +1 -1
- package/dist/src/collection-facets/toggle-switch.js +1 -0
- package/dist/src/collection-facets/toggle-switch.js.map +1 -1
- package/dist/src/data-source/collection-browser-data-source.js.map +1 -1
- package/dist/src/data-source/collection-browser-query-state.js.map +1 -1
- package/dist/src/sort-filter-bar/sort-filter-bar.js +280 -280
- package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
- package/dist/test/collection-browser.test.js +189 -189
- package/dist/test/collection-browser.test.js.map +1 -1
- package/dist/test/collection-facets/more-facets-content.test.js +162 -3
- package/dist/test/collection-facets/more-facets-content.test.js.map +1 -1
- package/dist/test/collection-facets/more-facets-pagination.test.js +63 -3
- package/dist/test/collection-facets/more-facets-pagination.test.js.map +1 -1
- package/dist/test/mocks/mock-search-responses.d.ts +5 -0
- package/dist/test/mocks/mock-search-responses.js +44 -0
- package/dist/test/mocks/mock-search-responses.js.map +1 -1
- package/dist/test/mocks/mock-search-service.js +2 -1
- package/dist/test/mocks/mock-search-service.js.map +1 -1
- package/dist/test/sort-filter-bar/sort-filter-bar.test.js +22 -22
- package/dist/test/sort-filter-bar/sort-filter-bar.test.js.map +1 -1
- package/eslint.config.mjs +53 -53
- package/index.html +24 -24
- package/local.archive.org.cert +86 -86
- package/local.archive.org.key +27 -27
- package/package.json +121 -120
- package/renovate.json +6 -6
- package/src/collection-browser.ts +3070 -3070
- package/src/collection-facets/facets-template.ts +5 -0
- package/src/collection-facets/more-facets-content.ts +625 -113
- package/src/collection-facets/more-facets-pagination.ts +84 -10
- package/src/collection-facets/toggle-switch.ts +1 -0
- package/src/data-source/collection-browser-data-source.ts +1444 -1444
- package/src/data-source/collection-browser-query-state.ts +60 -60
- package/src/sort-filter-bar/sort-filter-bar.ts +733 -733
- package/test/collection-browser.test.ts +2402 -2402
- package/test/collection-facets/more-facets-content.test.ts +251 -4
- package/test/collection-facets/more-facets-pagination.test.ts +87 -3
- package/test/mocks/mock-search-responses.ts +48 -0
- package/test/mocks/mock-search-service.ts +2 -0
- package/test/sort-filter-bar/sort-filter-bar.test.ts +443 -443
- package/tsconfig.json +25 -25
- package/web-dev-server.config.mjs +30 -30
- package/web-test-runner.config.mjs +52 -52
- package/.claude/settings.local.json +0 -8
|
@@ -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,M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I,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 {\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,10 @@ 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
|
+
import '@internetarchive/ia-clearable-text-input';
|
|
11
12
|
export declare class MoreFacetsContent extends LitElement {
|
|
12
13
|
facetKey?: FacetOption;
|
|
13
14
|
query?: string;
|
|
@@ -51,14 +52,74 @@ export declare class MoreFacetsContent extends LitElement {
|
|
|
51
52
|
*/
|
|
52
53
|
private unappliedFacetChanges;
|
|
53
54
|
/**
|
|
54
|
-
*
|
|
55
|
+
* Text entered by the user to filter facet buckets.
|
|
56
|
+
* Applied to bucket.key for case-insensitive matching.
|
|
57
|
+
*/
|
|
58
|
+
private filterText;
|
|
59
|
+
/**
|
|
60
|
+
* Current page number for pagination (when facet count >= PAGINATION_THRESHOLD).
|
|
55
61
|
*/
|
|
56
62
|
private pageNumber;
|
|
63
|
+
/**
|
|
64
|
+
* Whether the component is narrow enough to warrant compact pagination.
|
|
65
|
+
* Updated via a ResizeObserver-based container query approach.
|
|
66
|
+
*/
|
|
67
|
+
private isCompactView;
|
|
68
|
+
/**
|
|
69
|
+
* Whether the horizontal scroll is at the leftmost position.
|
|
70
|
+
*/
|
|
71
|
+
private atScrollStart;
|
|
72
|
+
/**
|
|
73
|
+
* Whether the horizontal scroll is at the rightmost position.
|
|
74
|
+
*/
|
|
75
|
+
private atScrollEnd;
|
|
76
|
+
private filterInput;
|
|
77
|
+
private facetsContentEl;
|
|
57
78
|
willUpdate(changed: PropertyValues): void;
|
|
79
|
+
updated(changed: PropertyValues): void;
|
|
80
|
+
private resizeObserver?;
|
|
58
81
|
firstUpdated(): void;
|
|
82
|
+
disconnectedCallback(): void;
|
|
83
|
+
private scrollHandler;
|
|
84
|
+
private scrollListenerAttached;
|
|
85
|
+
private scrollListenerTarget?;
|
|
86
|
+
/**
|
|
87
|
+
* Attaches a scroll event listener to the facets content element
|
|
88
|
+
* to track horizontal scroll position for arrow button states.
|
|
89
|
+
*/
|
|
90
|
+
private attachScrollListener;
|
|
91
|
+
private removeScrollListener;
|
|
92
|
+
/**
|
|
93
|
+
* Updates the scroll arrow disabled states based on current scroll position.
|
|
94
|
+
*/
|
|
95
|
+
private updateScrollState;
|
|
96
|
+
/**
|
|
97
|
+
* Calculates the width of one column step (column width + gap) based on
|
|
98
|
+
* the CSS multi-column layout of the scroll container.
|
|
99
|
+
*/
|
|
100
|
+
private getColumnStep;
|
|
101
|
+
/**
|
|
102
|
+
* Snaps a scroll target to the nearest column boundary.
|
|
103
|
+
*/
|
|
104
|
+
private snapToColumn;
|
|
105
|
+
/**
|
|
106
|
+
* Scrolls the facet content left by approximately one page, snapping to
|
|
107
|
+
* the nearest column boundary.
|
|
108
|
+
*/
|
|
109
|
+
private onScrollLeft;
|
|
110
|
+
/**
|
|
111
|
+
* Scrolls the facet content right by approximately one page, snapping to
|
|
112
|
+
* the nearest column boundary.
|
|
113
|
+
*/
|
|
114
|
+
private onScrollRight;
|
|
115
|
+
/**
|
|
116
|
+
* Sets up a ResizeObserver to toggle compact pagination based on component width.
|
|
117
|
+
*/
|
|
118
|
+
private setupCompactViewObserver;
|
|
59
119
|
/**
|
|
60
120
|
* Close more facets modal on Escape click
|
|
61
121
|
*/
|
|
122
|
+
private escapeHandler;
|
|
62
123
|
private setupEscapeListeners;
|
|
63
124
|
/**
|
|
64
125
|
* Whether facet requests are for the search_results page type (either defaulted or explicitly).
|
|
@@ -69,10 +130,6 @@ export declare class MoreFacetsContent extends LitElement {
|
|
|
69
130
|
* - this.aggregations - hold result of search service and being used for further processing.
|
|
70
131
|
*/
|
|
71
132
|
updateSpecificFacets(): Promise<void>;
|
|
72
|
-
/**
|
|
73
|
-
* Handler for page number changes from the pagination widget.
|
|
74
|
-
*/
|
|
75
|
-
private pageNumberClicked;
|
|
76
133
|
/**
|
|
77
134
|
* Combines the selected facets with the aggregations to create a single list of facets
|
|
78
135
|
*/
|
|
@@ -88,19 +145,49 @@ export declare class MoreFacetsContent extends LitElement {
|
|
|
88
145
|
*/
|
|
89
146
|
private get aggregationFacetGroup();
|
|
90
147
|
/**
|
|
91
|
-
* Returns
|
|
148
|
+
* Returns the facet group with buckets filtered by the current filter text.
|
|
149
|
+
* Filters are applied to the full bucket list before pagination.
|
|
150
|
+
*/
|
|
151
|
+
private get filteredFacetGroup();
|
|
152
|
+
/**
|
|
153
|
+
* Determines whether to use pagination based on the number of filtered facets.
|
|
154
|
+
* Returns true if facet count >= PAGINATION_THRESHOLD, false otherwise.
|
|
155
|
+
*/
|
|
156
|
+
private get usePagination();
|
|
157
|
+
/**
|
|
158
|
+
* Returns the facet group for the current page.
|
|
159
|
+
* If using pagination (>= 1000 facets), slices to show only the current page.
|
|
160
|
+
* Otherwise, returns all facets for horizontal scrolling.
|
|
92
161
|
*/
|
|
93
162
|
private get facetGroupForCurrentPage();
|
|
94
163
|
private get moreFacetsTemplate();
|
|
95
164
|
private get loaderTemplate();
|
|
165
|
+
private get emptyFilterResultsTemplate();
|
|
96
166
|
/**
|
|
97
|
-
*
|
|
167
|
+
* Number of pages for pagination (only used when facet count >= PAGINATION_THRESHOLD).
|
|
98
168
|
*/
|
|
99
169
|
private get paginationSize();
|
|
170
|
+
/**
|
|
171
|
+
* Template for pagination component.
|
|
172
|
+
*/
|
|
100
173
|
private get facetsPaginationTemplate();
|
|
101
174
|
private get footerTemplate();
|
|
102
175
|
private sortFacetAggregation;
|
|
176
|
+
/**
|
|
177
|
+
* Handler for filter input changes. Updates the filter text and triggers re-render.
|
|
178
|
+
*/
|
|
179
|
+
private handleFilterInput;
|
|
180
|
+
/**
|
|
181
|
+
* Handler for when the filter input is cleared via the clear button.
|
|
182
|
+
*/
|
|
183
|
+
private handleFilterClear;
|
|
184
|
+
/**
|
|
185
|
+
* Handler for pagination page number clicks.
|
|
186
|
+
* Only used when facet count >= PAGINATION_THRESHOLD.
|
|
187
|
+
*/
|
|
188
|
+
private pageNumberClicked;
|
|
103
189
|
private get modalHeaderTemplate();
|
|
190
|
+
private get horizontalScrollTemplate();
|
|
104
191
|
render(): TemplateResult<1>;
|
|
105
192
|
private applySearchFacetsClicked;
|
|
106
193
|
private cancelClick;
|