@internetarchive/collection-browser 4.1.0-alpha-webdev8164.0 → 4.1.0-alpha-webdev8186.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 +4 -4
- package/.prettierignore +1 -1
- package/LICENSE +661 -661
- package/README.md +83 -83
- package/dist/index.d.ts +1 -0
- package/dist/index.js.map +1 -1
- package/dist/src/collection-browser.js +3 -13
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/collection-facets/facets-template.js +0 -5
- package/dist/src/collection-facets/facets-template.js.map +1 -1
- package/dist/src/collection-facets/more-facets-content.d.ts +8 -47
- package/dist/src/collection-facets/more-facets-content.js +83 -382
- package/dist/src/collection-facets/more-facets-content.js.map +1 -1
- package/dist/src/collection-facets/more-facets-pagination.d.ts +0 -10
- package/dist/src/collection-facets/more-facets-pagination.js +1 -64
- package/dist/src/collection-facets/more-facets-pagination.js.map +1 -1
- package/dist/src/sort-filter-bar/sort-filter-bar.d.ts +13 -172
- package/dist/src/sort-filter-bar/sort-filter-bar.js +42 -549
- package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
- package/dist/test/collection-browser.test.js +8 -13
- package/dist/test/collection-browser.test.js.map +1 -1
- package/dist/test/collection-facets/more-facets-content.test.js +3 -154
- package/dist/test/collection-facets/more-facets-content.test.js.map +1 -1
- package/dist/test/collection-facets/more-facets-pagination.test.js +0 -60
- package/dist/test/collection-facets/more-facets-pagination.test.js.map +1 -1
- package/dist/test/sort-filter-bar/sort-filter-bar.test.js +86 -401
- 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/index.ts +1 -0
- package/local.archive.org.cert +86 -86
- package/local.archive.org.key +27 -27
- package/package.json +121 -121
- package/renovate.json +6 -6
- package/src/collection-browser.ts +3 -13
- package/src/collection-facets/facets-template.ts +0 -5
- package/src/collection-facets/more-facets-content.ts +94 -411
- package/src/collection-facets/more-facets-pagination.ts +1 -73
- package/src/sort-filter-bar/sort-filter-bar.ts +48 -606
- package/test/collection-browser.test.ts +9 -20
- package/test/collection-facets/more-facets-content.test.ts +3 -218
- package/test/collection-facets/more-facets-pagination.test.ts +0 -84
- package/test/sort-filter-bar/sort-filter-bar.test.ts +110 -566
- package/tsconfig.json +25 -25
- package/web-dev-server.config.mjs +30 -30
- package/web-test-runner.config.mjs +52 -52
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
import { LitElement, PropertyValues, TemplateResult } from 'lit';
|
|
2
|
-
import type { SharedResizeObserverInterface, SharedResizeObserverResizeHandlerInterface } from '@internetarchive/shared-resize-observer';
|
|
3
|
-
import '@internetarchive/ia-dropdown';
|
|
4
2
|
import type { SortDirection } from '@internetarchive/search-service';
|
|
5
|
-
import { CollectionDisplayMode,
|
|
3
|
+
import { CollectionDisplayMode, PrefixFilterCounts, PrefixFilterType, SortField } from '../models';
|
|
4
|
+
import '@internetarchive/ia-dropdown';
|
|
6
5
|
import './alpha-bar';
|
|
7
6
|
type AlphaSelector = 'creator' | 'title';
|
|
8
|
-
export declare class SortFilterBar extends LitElement
|
|
7
|
+
export declare class SortFilterBar extends LitElement {
|
|
9
8
|
/** Which display mode the tiles are being rendered with (grid/list-detail/list-compact) */
|
|
10
9
|
displayMode?: CollectionDisplayMode;
|
|
11
10
|
/** The default sort direction to use if none is set */
|
|
12
11
|
defaultSortDirection: SortDirection | null;
|
|
13
12
|
/** The default sort field to use if none is set */
|
|
14
13
|
defaultSortField: Exclude<SortField, SortField.default>;
|
|
15
|
-
/** Which view sort option to expose by default. */
|
|
16
|
-
defaultViewSort: ViewsSortField;
|
|
17
|
-
/** Which date sort option to expose by default */
|
|
18
|
-
defaultDateSort: DateSortField;
|
|
19
14
|
/** The current sort direction (asc/desc), or null if none is set */
|
|
20
15
|
sortDirection: SortDirection | null;
|
|
21
16
|
/** The field currently being sorted on (e.g., 'title'). Defaults to relevance. */
|
|
@@ -44,15 +39,6 @@ export declare class SortFilterBar extends LitElement implements SharedResizeObs
|
|
|
44
39
|
suppressDisplayModes: boolean;
|
|
45
40
|
/** Maps of result counts for letters on the alphabet bar, for each letter filter type */
|
|
46
41
|
prefixFilterCountMap?: Record<PrefixFilterType, PrefixFilterCounts>;
|
|
47
|
-
resizeObserver?: SharedResizeObserverInterface;
|
|
48
|
-
/**
|
|
49
|
-
* The Views sort option that was most recently selected (or the default, if none has been selected yet)
|
|
50
|
-
*/
|
|
51
|
-
private lastSelectedViewSort;
|
|
52
|
-
/**
|
|
53
|
-
* The Date sort option that was most recently selected (or the default, if none has been selected yet)
|
|
54
|
-
*/
|
|
55
|
-
private lastSelectedDateSort;
|
|
56
42
|
/**
|
|
57
43
|
* Which of the alphabet bars (title/creator) should be shown, or null if one
|
|
58
44
|
* should not currently be rendered.
|
|
@@ -63,47 +49,13 @@ export declare class SortFilterBar extends LitElement implements SharedResizeObs
|
|
|
63
49
|
* should be rendered.
|
|
64
50
|
*/
|
|
65
51
|
dropdownBackdropVisible: boolean;
|
|
66
|
-
/**
|
|
67
|
-
|
|
68
|
-
* Used for dynamically determining whether to use desktop or mobile view.
|
|
69
|
-
*/
|
|
70
|
-
desktopSortContainerWidth: number;
|
|
71
|
-
/**
|
|
72
|
-
* The width of the full sort bar, updated upon each resize.
|
|
73
|
-
* Used for dynamically determining whether to use desktop or mobile view.
|
|
74
|
-
*/
|
|
75
|
-
selectorBarContainerWidth: number;
|
|
76
|
-
/**
|
|
77
|
-
* The container for all the desktop view's sort options.
|
|
78
|
-
* Used for dynamically determining whether to use desktop or mobile view.
|
|
79
|
-
*/
|
|
80
|
-
private desktopSortContainer;
|
|
81
|
-
/**
|
|
82
|
-
* The container for the full sort bar.
|
|
83
|
-
* Used for dynamically determining whether to use desktop or mobile view.
|
|
84
|
-
*/
|
|
85
|
-
private sortSelectorContainer;
|
|
86
|
-
/** The dropdown component containing options for weekly and all-time views */
|
|
87
|
-
private viewsDropdown?;
|
|
88
|
-
/** The dropdown component containing all the available date options */
|
|
89
|
-
private dateDropdown?;
|
|
90
|
-
/** The single, consolidated dropdown component shown in mobile view */
|
|
91
|
-
private mobileDropdown;
|
|
52
|
+
/** The single, consolidated dropdown component containing all available options */
|
|
53
|
+
private sortOptionsDropdown;
|
|
92
54
|
render(): TemplateResult<1>;
|
|
93
55
|
willUpdate(changed: PropertyValues): void;
|
|
94
56
|
updated(changed: PropertyValues): void;
|
|
95
57
|
private setupEscapeListeners;
|
|
96
58
|
private boundSortBarSelectorEscapeListener;
|
|
97
|
-
connectedCallback(): void;
|
|
98
|
-
disconnectedCallback(): void;
|
|
99
|
-
private disconnectResizeObserver;
|
|
100
|
-
private setupResizeObserver;
|
|
101
|
-
handleResize(entry: ResizeObserverEntry): void;
|
|
102
|
-
/**
|
|
103
|
-
* Whether to show the mobile sort bar because there is not enough space
|
|
104
|
-
* for the desktop sort bar.
|
|
105
|
-
*/
|
|
106
|
-
private get mobileSelectorVisible();
|
|
107
59
|
/**
|
|
108
60
|
* Template to render the alphabet bar, or `nothing` if it should not be rendered
|
|
109
61
|
* for the current sort
|
|
@@ -113,21 +65,8 @@ export declare class SortFilterBar extends LitElement implements SharedResizeObs
|
|
|
113
65
|
private get sortDirectionSelectorTemplate();
|
|
114
66
|
/** Template to render the sort direction button's icon in the correct current state */
|
|
115
67
|
private get sortDirectionIcon();
|
|
116
|
-
/** The template to render all the sort options in
|
|
117
|
-
private get
|
|
118
|
-
/** The template to render all the sort options in mobile view */
|
|
119
|
-
private get mobileSortSelectorTemplate();
|
|
120
|
-
/**
|
|
121
|
-
* This generates each of the non-dropdown sort option buttons.
|
|
122
|
-
*
|
|
123
|
-
* It manages the display value and the selected state of the option.
|
|
124
|
-
*
|
|
125
|
-
* @param sortField Which sort field the button represents
|
|
126
|
-
* @param options Additional options:
|
|
127
|
-
* - `onSelected?: (e: Event) => void;` If this is provided, it will also be called when the option is selected.
|
|
128
|
-
* Default is to clear any selected alphabetical filters.
|
|
129
|
-
*/
|
|
130
|
-
private getSortSelectorButton;
|
|
68
|
+
/** The template to render all the sort options in a single dropdown */
|
|
69
|
+
private get sortSelectorTemplate();
|
|
131
70
|
/**
|
|
132
71
|
* Generates a dropdown component containing multiple grouped sort options.
|
|
133
72
|
*
|
|
@@ -139,61 +78,12 @@ export declare class SortFilterBar extends LitElement implements SharedResizeObs
|
|
|
139
78
|
* selected appearance
|
|
140
79
|
* @param options.onOptionSelected A handler for optionSelected events coming from the dropdown
|
|
141
80
|
* @param options.onDropdownClick A handler for click events on the dropdown
|
|
142
|
-
* @param options.onLabelInteraction A handler for click events and Enter/Space keydown events
|
|
143
|
-
* on the dropdown's label
|
|
144
81
|
*/
|
|
145
82
|
private getSortDropdown;
|
|
146
83
|
/** Generates a single dropdown option object for the given sort field */
|
|
147
84
|
private getDropdownOption;
|
|
148
|
-
/** Handler for when
|
|
149
|
-
private
|
|
150
|
-
/**
|
|
151
|
-
* Template for the Relevance sort selector button, or `nothing` if the relevance
|
|
152
|
-
* field is not available for display.
|
|
153
|
-
*/
|
|
154
|
-
private get relevanceSortSelectorTemplate();
|
|
155
|
-
/**
|
|
156
|
-
* Template for the Views sort selector button.
|
|
157
|
-
* This is shown instead of the views dropdown when only a single views sort field
|
|
158
|
-
* is available.
|
|
159
|
-
*/
|
|
160
|
-
private get viewsSortSelectorTemplate();
|
|
161
|
-
/**
|
|
162
|
-
* Template for the Title sort selector button, or `nothing` if the title field is
|
|
163
|
-
* not available for display.
|
|
164
|
-
*/
|
|
165
|
-
private get titleSortSelectorTemplate();
|
|
166
|
-
/**
|
|
167
|
-
* Template for the Date sort selector button.
|
|
168
|
-
* This is shown instead of the dates dropdown when only a single date sort field
|
|
169
|
-
* is available.
|
|
170
|
-
*/
|
|
171
|
-
private get dateSortSelectorTemplate();
|
|
172
|
-
/**
|
|
173
|
-
* Template for the Creator sort selector button, or `nothing` if the creator field
|
|
174
|
-
* is not available for display.
|
|
175
|
-
*/
|
|
176
|
-
private get creatorSortSelectorTemplate();
|
|
177
|
-
/**
|
|
178
|
-
* Template for the Views dropdown, shown when 2+ views sort fields are available.
|
|
179
|
-
*/
|
|
180
|
-
private get viewsDropdownTemplate();
|
|
181
|
-
/**
|
|
182
|
-
* Template for the Date dropdown, shown when 2+ date sort fields are available.
|
|
183
|
-
*/
|
|
184
|
-
private get dateDropdownTemplate();
|
|
185
|
-
/**
|
|
186
|
-
* Provides the appropriate template to use for Views sorting, depending on how many
|
|
187
|
-
* views sort fields are available.
|
|
188
|
-
*/
|
|
189
|
-
private get allViewsSortOptionsTemplate();
|
|
190
|
-
/**
|
|
191
|
-
* Provides the appropriate template to use for Date sorting, depending on how many
|
|
192
|
-
* date sort fields are available.
|
|
193
|
-
*/
|
|
194
|
-
private get allDateSortOptionsTemplate();
|
|
195
|
-
/** Handler for when a new mobile sort dropdown option is selected */
|
|
196
|
-
private mobileSortChanged;
|
|
85
|
+
/** Handler for when a new sort dropdown option is selected */
|
|
86
|
+
private sortOptionSelected;
|
|
197
87
|
/** Template for rendering the three display mode options */
|
|
198
88
|
/** Added data-testid for Playwright testing * */
|
|
199
89
|
private get displayOptionTemplate();
|
|
@@ -202,69 +92,20 @@ export declare class SortFilterBar extends LitElement implements SharedResizeObs
|
|
|
202
92
|
* dropdown menu while it is open.
|
|
203
93
|
*/
|
|
204
94
|
private get dropdownBackdrop();
|
|
205
|
-
/** Closes
|
|
206
|
-
private
|
|
95
|
+
/** Closes the sorting dropdown component's menus */
|
|
96
|
+
private closeDropdown;
|
|
207
97
|
private selectDropdownSortField;
|
|
208
|
-
|
|
209
|
-
private setSortDirection;
|
|
98
|
+
setSortDirection(sortDirection: SortDirection): void;
|
|
210
99
|
/** Toggles the current sort direction between 'asc' and 'desc' */
|
|
211
100
|
private toggleSortDirection;
|
|
212
101
|
private handleSortDirectionClicked;
|
|
213
|
-
|
|
102
|
+
setSelectedSort(sort: SortField): void;
|
|
214
103
|
/** The current sort field, or the default one if no explicit sort is set */
|
|
215
104
|
private get finalizedSortField();
|
|
216
105
|
/** The current sort direction, or the default one if no explicit direction is set */
|
|
217
106
|
private get finalizedSortDirection();
|
|
218
107
|
/** Whether the sort direction button should be enabled for the current sort */
|
|
219
108
|
private get canChangeSortDirection();
|
|
220
|
-
/**
|
|
221
|
-
* There are four date sort options.
|
|
222
|
-
*
|
|
223
|
-
* This checks to see if the current sort is one of them.
|
|
224
|
-
*
|
|
225
|
-
* @readonly
|
|
226
|
-
* @private
|
|
227
|
-
* @type {boolean}
|
|
228
|
-
* @memberof SortFilterBar
|
|
229
|
-
*/
|
|
230
|
-
private get dateOptionSelected();
|
|
231
|
-
/**
|
|
232
|
-
* There are two view sort options.
|
|
233
|
-
*
|
|
234
|
-
* This checks to see if the current sort is one of them.
|
|
235
|
-
*
|
|
236
|
-
* @readonly
|
|
237
|
-
* @private
|
|
238
|
-
* @type {boolean}
|
|
239
|
-
* @memberof SortFilterBar
|
|
240
|
-
*/
|
|
241
|
-
private get viewOptionSelected();
|
|
242
|
-
/**
|
|
243
|
-
* The display name of the last selected date field
|
|
244
|
-
*
|
|
245
|
-
* @readonly
|
|
246
|
-
* @private
|
|
247
|
-
* @type {string}
|
|
248
|
-
* @memberof SortFilterBar
|
|
249
|
-
*/
|
|
250
|
-
private get dateSortDisplayName();
|
|
251
|
-
/**
|
|
252
|
-
* The display name of the last selected view field
|
|
253
|
-
*
|
|
254
|
-
* @readonly
|
|
255
|
-
* @private
|
|
256
|
-
* @type {string}
|
|
257
|
-
* @memberof SortFilterBar
|
|
258
|
-
*/
|
|
259
|
-
private get viewSortDisplayName();
|
|
260
|
-
/**
|
|
261
|
-
* Array of all the views sorts that should be shown
|
|
262
|
-
*/
|
|
263
|
-
private get availableViewsFields();
|
|
264
|
-
/**
|
|
265
|
-
* Array of all the date sorts that should be shown
|
|
266
|
-
*/
|
|
267
|
-
private get availableDateFields();
|
|
268
109
|
private get titleSelectorBar();
|
|
269
110
|
private get creatorSelectorBar();
|
|
270
111
|
private titleLetterChanged;
|