@internetarchive/collection-browser 4.3.1 → 4.3.2-alpha-webdev7939.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/src/app-root.ts CHANGED
@@ -1,1251 +1,1254 @@
1
- import {
2
- AnalyticsEvent,
3
- AnalyticsManager,
4
- } from '@internetarchive/analytics-manager';
5
- import {
6
- PageElementName,
7
- SearchService,
8
- SearchServiceInterface,
9
- SearchType,
10
- } from '@internetarchive/search-service';
11
- import { html, css, LitElement, PropertyValues, nothing } from 'lit';
12
- import { customElement, property, query, state } from 'lit/decorators.js';
13
- import { SharedResizeObserver } from '@internetarchive/shared-resize-observer';
14
-
15
- import type { ModalManagerInterface } from '@internetarchive/modal-manager';
16
- import type { AnalyticsManagerInterface } from '@internetarchive/analytics-manager';
17
- import type { CollectionBrowser } from '../src/collection-browser';
18
-
19
- import '../src/collection-browser';
20
- import { InfiniteScroller } from '@internetarchive/infinite-scroller';
21
- import { TileDispatcher } from './tiles/tile-dispatcher';
22
-
23
- @customElement('app-root')
24
- export class AppRoot extends LitElement {
25
- private searchService: SearchServiceInterface =
26
- this.initSearchServiceFromUrlParams();
27
-
28
- private resizeObserver = new SharedResizeObserver();
29
-
30
- @state() private toggleSlots: boolean = false;
31
-
32
- @state() private currentPage?: number;
33
-
34
- @state() private searchQuery?: string;
35
-
36
- @state() private withinCollection?: string;
37
-
38
- @state() private cellWidth: number = 18;
39
-
40
- @state() private cellHeight: number = 29;
41
-
42
- @state() private rowGap: number = 1.7;
43
-
44
- @state() private colGap: number = 1.7;
45
-
46
- @state() private suppressFacets: boolean = false;
47
-
48
- @state() private lazyLoadFacets: boolean = false;
49
-
50
- @state() private loggedIn: boolean = false;
51
-
52
- @state() private searchType: SearchType = SearchType.METADATA;
53
-
54
- @state() private profileElement?: PageElementName;
55
-
56
- @state() private withinProfile?: string;
57
-
58
- @property({ type: Object, reflect: false }) latestAction?: AnalyticsEvent;
59
-
60
- @query('#base-query-field') private baseQueryField!: HTMLInputElement;
61
-
62
- @query('#base-collection-field')
63
- private baseCollectionField!: HTMLInputElement;
64
-
65
- @query('#page-number-input') private pageNumberInput!: HTMLInputElement;
66
-
67
- @query('collection-browser') private collectionBrowser!: CollectionBrowser;
68
-
69
- @query('modal-manager') private modalManager!: ModalManagerInterface;
70
-
71
- private analyticsManager = new AnalyticsManager();
72
-
73
- private analyticsHandler: AnalyticsManagerInterface = {
74
- sendPing: this.sendAnalytics.bind(this),
75
- sendEvent: this.sendAnalytics.bind(this),
76
- sendEventNoSampling: this.sendAnalytics.bind(this),
77
- };
78
-
79
- private sendAnalytics(ae: AnalyticsEvent) {
80
- console.log('Analytics Received ----', ae);
81
- this.latestAction = ae;
82
- this.analyticsManager?.sendEvent(ae);
83
- }
84
-
85
- private initSearchServiceFromUrlParams() {
86
- const params = new URL(window.location.href).searchParams;
87
- return new SearchService({
88
- includeCredentials: false,
89
- baseUrl: params.get('search_base_url') ?? undefined,
90
- servicePath: params.get('search_service_path') ?? undefined,
91
- debuggingEnabled: !!params.get('debugging'),
92
- });
93
- }
94
-
95
- private searchPressed(e: Event) {
96
- e.preventDefault();
97
- this.searchQuery = this.baseQueryField.value;
98
- this.collectionBrowser.searchType = this.searchType;
99
-
100
- this.goToCurrentPage();
101
- }
102
-
103
- private collectionChanged(e: Event) {
104
- e.preventDefault();
105
- this.withinCollection = this.baseCollectionField.value;
106
- this.collectionBrowser.withinCollection = this.withinCollection;
107
-
108
- this.goToCurrentPage();
109
- }
110
-
111
- private goToCurrentPage() {
112
- const page = this.currentPage ?? 1;
113
- if (page > 1) {
114
- this.collectionBrowser.goToPage(page);
115
- }
116
- }
117
-
118
- private changePagePressed(e: Event) {
119
- e.preventDefault();
120
- this.currentPage = this.pageNumberInput.valueAsNumber;
121
- this.collectionBrowser.goToPage(this.currentPage);
122
- }
123
-
124
- protected override updated(changed: PropertyValues): void {
125
- if (changed.has('currentPage') && this.currentPage) {
126
- this.pageNumberInput.value = this.currentPage.toString();
127
- }
128
-
129
- if (changed.has('searchQuery')) {
130
- this.queryUpdated();
131
- }
132
- }
133
-
134
- private queryUpdated() {
135
- this.collectionBrowser.baseQuery = this.searchQuery;
136
- }
137
-
138
- private get getClass() {
139
- const searchParams = new URLSearchParams(window.location.search);
140
-
141
- return searchParams.get('hide-dev-tools') ? 'hidden' : '';
142
- }
143
-
144
- render() {
145
- return html`
146
- <div class="dev-tool-container">
147
- <div id="dev-tools" class=${this.getClass}>
148
- <div id="search-and-page-inputs">
149
- <form @submit=${this.searchPressed}>
150
- <label for="base-query-field"> Query: </label>
151
- <input
152
- type="text"
153
- id="base-query-field"
154
- .value=${this.searchQuery ?? ''}
155
- />
156
- <input type="submit" value="Search" />
157
- </form>
158
- <form @submit=${this.changePagePressed}>
159
- <label for="page-number-input"> Page: </label>
160
- <input type="number" value="1" id="page-number-input" />
161
- <input type="submit" value="Go" />
162
- </form>
163
- </div>
164
- <div>
165
- <form @submit=${this.collectionChanged}>
166
- <label for="base-collection-field"> Within collection: </label>
167
- <input
168
- type="text"
169
- id="base-collection-field"
170
- .value=${this.withinCollection ?? ''}
171
- />
172
- <input type="submit" value="Search" />
173
- </form>
174
- </div>
175
-
176
- <div id="search-types">
177
- Search type:
178
- <span class="search-type">
179
- <input
180
- type="radio"
181
- id="default-search"
182
- name="search-type"
183
- value="default"
184
- .checked=${this.searchType === SearchType.DEFAULT}
185
- @click=${this.searchTypeSelected}
186
- />
187
- <label for="default-search">Default</label>
188
- </span>
189
- <span class="search-type">
190
- <input
191
- type="radio"
192
- id="metadata-search"
193
- name="search-type"
194
- value="metadata"
195
- .checked=${this.searchType === SearchType.METADATA}
196
- @click=${this.searchTypeSelected}
197
- />
198
- <label for="metadata-search">Metadata</label>
199
- </span>
200
- <span class="search-type">
201
- <input
202
- type="radio"
203
- id="fulltext-search"
204
- name="search-type"
205
- value="fulltext"
206
- .checked=${this.searchType === SearchType.FULLTEXT}
207
- @click=${this.searchTypeSelected}
208
- />
209
- <label for="fulltext-search">Full text</label>
210
- </span>
211
- <span class="search-type">
212
- <input
213
- type="radio"
214
- id="tv-search"
215
- name="search-type"
216
- value="tv"
217
- .checked=${this.searchType === SearchType.TV}
218
- @click=${this.searchTypeSelected}
219
- />
220
- <label for="tv-search">TV</label>
221
- </span>
222
- <span class="search-type">
223
- <input
224
- type="radio"
225
- id="radio-search"
226
- name="search-type"
227
- value="radio"
228
- .checked=${this.searchType === SearchType.RADIO}
229
- @click=${this.searchTypeSelected}
230
- />
231
- <label for="radio-search">Radio</label>
232
- </span>
233
- </div>
234
-
235
- <div id="toggle-controls">
236
- <button
237
- @click=${() => {
238
- const details =
239
- this.shadowRoot?.getElementById('cell-size-control');
240
- details?.classList.toggle('hidden');
241
- const rowGapControls =
242
- this.shadowRoot?.getElementById('cell-gap-control');
243
- rowGapControls?.classList.toggle('hidden');
244
- }}
245
- >
246
- Toggle Cell Controls
247
- </button>
248
- <button
249
- @click=${() => {
250
- const details = this.shadowRoot?.getElementById(
251
- 'latest-event-details',
252
- );
253
- details?.classList.toggle('hidden');
254
- }}
255
- >
256
- Last Event Captured
257
- </button>
258
- </div>
259
-
260
- <div id="last-event">
261
- <pre id="latest-event-details" class="hidden">
262
- ${JSON.stringify(this.latestAction, null, 2)}
263
- </pre
264
- >
265
- </div>
266
-
267
- <fieldset class="cell-controls">
268
- <legend>Cell Controls</legend>
269
- <div>
270
- <label for="cell-width-slider">Cell width:</label>
271
- <input
272
- type="range"
273
- min="10"
274
- max="100"
275
- value="18"
276
- step="0.1"
277
- id="cell-width-slider"
278
- @input=${this.widthChanged}
279
- />
280
- <span>${this.cellWidth}rem</span>
281
- </div>
282
- <div>
283
- <label for="cell-height-slider">Cell height:</label>
284
- <input
285
- type="range"
286
- min="10"
287
- max="100"
288
- value="29"
289
- step="0.1"
290
- id="cell-height-slider"
291
- @input=${this.heightChanged}
292
- />
293
- <span>${this.cellHeight}rem</span>
294
- </div>
295
- <div>
296
- <label for="cell-row-gap-slider">Row gap:</label>
297
- <input
298
- type="range"
299
- min="0"
300
- max="5"
301
- value="1.7"
302
- step="0.1"
303
- id="cell-row-gap-slider"
304
- @input=${this.rowGapChanged}
305
- />
306
- <span>${this.rowGap}rem</span>
307
- </div>
308
- <div>
309
- <label for="cell-col-gap-slider">Col gap:</label>
310
- <input
311
- type="range"
312
- min="0"
313
- max="5"
314
- value="1.7"
315
- step="0.1"
316
- id="cell-col-gap-slider"
317
- @input=${this.colGapChanged}
318
- />
319
- <span>${this.colGap}rem</span>
320
- </div>
321
- </fieldset>
322
-
323
- <fieldset class="other-controls">
324
- <legend>Other Controls</legend>
325
- <div class="checkbox-control">
326
- <input
327
- type="checkbox"
328
- id="simulate-login"
329
- @click=${this.loginChanged}
330
- />
331
- <label for="simulate-login">Simulate login</label>
332
- </div>
333
- <div class="checkbox-control">
334
- <input
335
- type="checkbox"
336
- id="enable-date-picker"
337
- checked
338
- @click=${this.datePickerChanged}
339
- />
340
- <label for="enable-date-picker">Enable date picker</label>
341
- </div>
342
- <div class="checkbox-control">
343
- <input
344
- type="checkbox"
345
- id="enable-facets"
346
- checked
347
- @click=${this.facetsChanged}
348
- />
349
- <label for="enable-facets">Enable facets</label>
350
- </div>
351
- <div class="checkbox-control indent">
352
- <input
353
- type="checkbox"
354
- id="lazy-load-facets"
355
- ?disabled=${this.suppressFacets}
356
- @click=${this.lazyLoadFacetsChanged}
357
- />
358
- <label for="lazy-load-facets">Lazy load facets</label>
359
- </div>
360
- <div class="checkbox-control">
361
- <input
362
- type="checkbox"
363
- id="enable-management"
364
- @click=${this.manageModeCheckboxChanged}
365
- />
366
- <label for="enable-management">Enable manage mode</label>
367
- </div>
368
- <div class="checkbox-control indent">
369
- <input
370
- type="checkbox"
371
- id="enable-search-management"
372
- @click=${this.SearchManageModeCheckboxChanged}
373
- />
374
- <label for="enable-search-management">Search</label>
375
- </div>
376
- <div class="checkbox-control">
377
- <input
378
- type="checkbox"
379
- id="enable-smart-facet-bar"
380
- @click=${this.smartFacetBarCheckboxChanged}
381
- />
382
- <label for="enable-smart-facet-bar">Enable smart facet bar</label>
383
- </div>
384
- </fieldset>
385
-
386
- <fieldset class="cb-visual-appearance">
387
- <legend>CB Visual Appearance</legend>
388
- <div class="checkbox-control">
389
- <input
390
- type="checkbox"
391
- id="show-facet-group-outline-check"
392
- @click=${this.toggleFacetGroupOutline}
393
- />
394
- <label for="show-facet-group-outline-check">
395
- Show facet group outlines
396
- </label>
397
- </div>
398
- <div class="checkbox-control">
399
- <input
400
- type="checkbox"
401
- id="show-outline-check"
402
- @click=${this.outlineChanged}
403
- />
404
- <label for="show-outline-check">Show cell outlines</label>
405
- </div>
406
- <div class="checkbox-control">
407
- <input
408
- type="checkbox"
409
- id="minimal-tiles-check"
410
- @click=${this.minimalTilesChanged}
411
- />
412
- <label for="minimal-tiles-check">Minimal tile layouts</label>
413
- </div>
414
- </fieldset>
415
-
416
- <fieldset class="user-profile-controls">
417
- <legend>User Profile Controls</legend>
418
- <div class="checkbox-control">
419
- <input
420
- type="checkbox"
421
- id="enable-facet-top-slot"
422
- @click=${this.facetTopSlotCheckboxChanged}
423
- />
424
- <label for="enable-facet-top-slot">Show facet top slot</label>
425
- </div>
426
- <div class="checkbox-control">
427
- <input
428
- type="checkbox"
429
- id="enable-cb-top-slot"
430
- @click=${this.cbTopSlotCheckboxChanged}
431
- />
432
- <label for="enable-cb-top-slot">Show CB top slot</label>
433
- </div>
434
- <div class="checkbox-control">
435
- <input
436
- type="checkbox"
437
- id="enable-sortbar-left-slot"
438
- @click=${this.sortBarLeftSlotCheckboxChanged}
439
- />
440
- <label for="enable-sortbar-left-slot"
441
- >Show sortbar left slot</label
442
- >
443
- </div>
444
- <div class="checkbox-control">
445
- <input
446
- type="checkbox"
447
- id="enable-sortbar-right-slot"
448
- @click=${this.sortBarRightSlotCheckboxChanged}
449
- />
450
- <label for="enable-sortbar-right-slot"
451
- >Show sortbar right slot</label
452
- >
453
- </div>
454
- <div class="checkbox-control">
455
- <input
456
- type="checkbox"
457
- id="enable-result-last-tile-slot"
458
- @click=${this.resultLastTileSlotCheckboxChanged}
459
- />
460
- <label for="enable-result-last-tile-slot">
461
- Show result last tile slot
462
- </label>
463
- </div>
464
- <div class="checkbox-control">
465
- <input
466
- type="checkbox"
467
- id="enable-replaced-sort-options"
468
- @click=${this.replaceSortOptionsChanged}
469
- />
470
- <label for="enable-replaced-sort-options">
471
- Show replaced sort options
472
- </label>
473
- </div>
474
- <div class="text-input-control">
475
- <label for="within-profile-input">withinProfile</label>
476
- <input
477
- type="text"
478
- id="within-profile-input"
479
- placeholder="e.g. @foobar"
480
- @change=${(e: Event) => {
481
- const val = (e.target as HTMLInputElement).value.trim();
482
- this.withinProfile = val || undefined;
483
- }}
484
- />
485
- </div>
486
- <details class="profile-element-controls">
487
- <summary>
488
- Profile tab
489
- (profileElement)${this.profileElement
490
- ? html`: <strong>${this.profileElement}</strong>`
491
- : ''}
492
- </summary>
493
- <div class="profile-element-options">
494
- <div class="checkbox-control">
495
- <input
496
- type="radio"
497
- id="profile-none"
498
- name="profile-element"
499
- value=""
500
- checked
501
- @click=${this.profileElementChanged}
502
- />
503
- <label for="profile-none">None</label>
504
- </div>
505
- ${(
506
- [
507
- 'uploads',
508
- 'favorites',
509
- 'reviews',
510
- 'collections',
511
- 'lending',
512
- 'web_archives',
513
- 'forum_posts',
514
- ] as PageElementName[]
515
- ).map(
516
- tab => html`
517
- <div class="checkbox-control">
518
- <input
519
- type="radio"
520
- id="profile-${tab}"
521
- name="profile-element"
522
- value="${tab}"
523
- @click=${this.profileElementChanged}
524
- />
525
- <label for="profile-${tab}">${tab}</label>
526
- </div>
527
- `,
528
- )}
529
- </div>
530
- </details>
531
- </fieldset>
532
-
533
- <fieldset class="user-profile-controls">
534
- <legend>Set Placeholder Types</legend>
535
- <div class="checkbox-control">
536
- <input
537
- id="enable-loading-placeholder"
538
- type="radio"
539
- @click=${() => this.setPlaceholderType('loading-placeholder')}
540
- name="placeholder-radio"
541
- />
542
- <label for="enable-loading-placeholder"
543
- >Loading Placeholder</label
544
- >
545
- </div>
546
- <div class="checkbox-control">
547
- <input
548
- id="enable-empty-placeholder"
549
- type="radio"
550
- @click=${() => this.setPlaceholderType('error-placeholder')}
551
- value="empty-placeholder"
552
- name="placeholder-radio"
553
- />
554
- <label for="enable-empty-placeholder">Empty Placeholder</label>
555
- </div>
556
- </fieldset>
557
- </div>
558
- <button id="toggle-dev-tools-btn" @click=${this.toggleDevTools}>
559
- Toggle Search Controls
560
- </button>
561
- </div>
562
- <div id="collection-browser-container">
563
- <collection-browser
564
- facetPaneVisible
565
- .baseNavigationUrl=${'https://archive.org'}
566
- .baseImageUrl=${'https://archive.org'}
567
- .searchService=${this.searchService}
568
- .resizeObserver=${this.resizeObserver}
569
- .showHistogramDatePicker=${true}
570
- .suppressFacets=${this.suppressFacets}
571
- .lazyLoadFacets=${this.lazyLoadFacets}
572
- .loggedIn=${this.loggedIn}
573
- .modalManager=${this.modalManager}
574
- .analyticsHandler=${this.analyticsHandler}
575
- .withinProfile=${this.withinProfile}
576
- .profileElement=${this.profileElement}
577
- .pageContext=${'search'}
578
- @visiblePageChanged=${this.visiblePageChanged}
579
- @baseQueryChanged=${this.baseQueryChanged}
580
- @searchTypeChanged=${this.searchTypeChanged}
581
- @manageModeChanged=${this.manageModeChanged}
582
- @itemRemovalRequested=${this.handleItemRemovalRequest}
583
- @itemManagerRequested=${this.handleItemManagerRequest}
584
- >
585
- ${this.toggleSlots
586
- ? html`<div slot="sortbar-left-slot">Sort Slot</div>`
587
- : nothing}
588
- ${this.toggleSlots
589
- ? html`<div slot="facet-top-slot">Facet Slot</div>`
590
- : nothing}
591
- </collection-browser>
592
- </div>
593
- <modal-manager></modal-manager>
594
- `;
595
- }
596
-
597
- private async setPlaceholderType(type: string) {
598
- switch (type) {
599
- case 'loading-placeholder':
600
- this.collectionBrowser.baseQuery = '';
601
- this.collectionBrowser.suppressPlaceholders = true;
602
- this.collectionBrowser.clearResultsOnEmptyQuery = true;
603
- this.requestUpdate();
604
- await this.collectionBrowser.updateComplete;
605
- break;
606
- default:
607
- break;
608
- }
609
- }
610
-
611
- private baseQueryChanged(e: CustomEvent<{ baseQuery?: string }>): void {
612
- this.searchQuery = e.detail.baseQuery;
613
- }
614
-
615
- /** Handler for search type changes coming from collection browser */
616
- private searchTypeChanged(e: CustomEvent<SearchType>): void {
617
- this.searchType = e.detail;
618
- }
619
-
620
- /** Handler for user input selecting a search type */
621
- private searchTypeSelected(e: Event) {
622
- const target = e.target as HTMLInputElement;
623
- this.searchType = this.searchTypeFromSelectedOption(target.value);
624
- }
625
-
626
- private searchTypeFromSelectedOption(option: string): SearchType {
627
- switch (option) {
628
- case 'metadata':
629
- return SearchType.METADATA;
630
- case 'fulltext':
631
- return SearchType.FULLTEXT;
632
- case 'tv':
633
- return SearchType.TV;
634
- case 'radio':
635
- return SearchType.RADIO;
636
- default:
637
- return SearchType.DEFAULT;
638
- }
639
- }
640
-
641
- private loginChanged(e: Event) {
642
- const target = e.target as HTMLInputElement;
643
- if (target.checked) {
644
- this.loggedIn = true;
645
- } else {
646
- this.loggedIn = false;
647
- }
648
- }
649
-
650
- private outlineChanged(e: Event) {
651
- const target = e.target as HTMLInputElement;
652
- if (target.checked) {
653
- this.collectionBrowser.style.setProperty(
654
- '--infiniteScrollerCellOutline',
655
- '1px solid #33D1FF',
656
- );
657
- } else {
658
- this.collectionBrowser.style.removeProperty(
659
- '--infiniteScrollerCellOutline',
660
- );
661
- }
662
- }
663
-
664
- private minimalTilesChanged(e: Event) {
665
- const target = e.target as HTMLInputElement;
666
- const scroller = this.collectionBrowser?.shadowRoot!.querySelector(
667
- 'infinite-scroller',
668
- ) as InfiniteScroller;
669
- const tileDispatchers = [
670
- ...scroller.shadowRoot!.querySelectorAll('tile-dispatcher'),
671
- ] as TileDispatcher[];
672
-
673
- if (target.checked) {
674
- tileDispatchers?.forEach(tile => (tile.layoutType = 'minimal'));
675
- } else {
676
- tileDispatchers?.forEach(tile => (tile.layoutType = 'default'));
677
- }
678
- }
679
-
680
- private toggleDevTools() {
681
- const pageUrl = new URL(window.location.href);
682
- const { searchParams } = pageUrl;
683
-
684
- if (searchParams.get('hide-dev-tools')) {
685
- searchParams.delete('hide-dev-tools');
686
- } else {
687
- searchParams.set('hide-dev-tools', 'true');
688
- }
689
-
690
- this.shadowRoot?.getElementById('dev-tools')?.classList.toggle('hidden');
691
-
692
- if (window.history.replaceState) {
693
- window.history.replaceState(
694
- {
695
- path: pageUrl.toString(),
696
- },
697
- '',
698
- pageUrl.toString(),
699
- );
700
- }
701
- }
702
-
703
- private toggleFacetGroupOutline(e: Event) {
704
- const target = e.target as HTMLInputElement;
705
- if (target.checked) {
706
- this.collectionBrowser.classList.add('showFacetGroupOutlines');
707
- this.modalManager.classList.add('showFacetGroupOutlines');
708
- } else {
709
- this.collectionBrowser.classList.remove('showFacetGroupOutlines');
710
- this.modalManager.classList.remove('showFacetGroupOutlines');
711
- }
712
- }
713
-
714
- private datePickerChanged(e: Event) {
715
- const target = e.target as HTMLInputElement;
716
- this.collectionBrowser.showHistogramDatePicker = target.checked;
717
-
718
- // When disabling the date picker from the demo app, also clear any existing date range params
719
- if (!this.collectionBrowser.showHistogramDatePicker) {
720
- this.collectionBrowser.minSelectedDate = undefined;
721
- this.collectionBrowser.maxSelectedDate = undefined;
722
- }
723
- }
724
-
725
- private facetsChanged(e: Event) {
726
- const target = e.target as HTMLInputElement;
727
- this.suppressFacets = !target.checked;
728
- }
729
-
730
- private lazyLoadFacetsChanged(e: Event) {
731
- const target = e.target as HTMLInputElement;
732
- this.lazyLoadFacets = target.checked;
733
- }
734
-
735
- /**
736
- * Handler for when collection browser's manage mode changes.
737
- * This lets us disable the checkbox in the dev panel when the user cancels out
738
- * of manage mode from within collection browser.
739
- */
740
- private manageModeChanged(e: CustomEvent<boolean>): void {
741
- const manageCheckbox = this.shadowRoot?.querySelector(
742
- '#enable-management',
743
- ) as HTMLInputElement;
744
- if (manageCheckbox) manageCheckbox.checked = e.detail;
745
- }
746
-
747
- /**
748
- * Handler for item removal
749
- */
750
- private handleItemRemovalRequest(e: CustomEvent) {
751
- this.collectionBrowser.showRemoveItemsProcessingModal();
752
- console.log('itemRemovalRequested: ', e.detail.items);
753
-
754
- setTimeout(() => {
755
- // execute item-removal-service, and response is successfully deleted
756
- const status = false;
757
-
758
- if (status) {
759
- // looking for success?
760
- this.collectionBrowser.isManageView = false;
761
- this.modalManager?.closeModal();
762
- this.modalManager?.classList.remove('remove-items');
763
- } else {
764
- // looking for failure?
765
- this.collectionBrowser.showRemoveItemsErrorModal();
766
- }
767
- }, 2000); // let's wait to see processing modal
768
- }
769
-
770
- /**
771
- * Handler when item manage requested
772
- */
773
- private handleItemManagerRequest(e: CustomEvent) {
774
- console.log('itemManagerRequested: ', e.detail.items);
775
- }
776
-
777
- /**
778
- * Handler for when the dev panel's "Enable manage mode" checkbox is changed.
779
- */
780
- private manageModeCheckboxChanged(e: Event) {
781
- const target = e.target as HTMLInputElement;
782
- this.collectionBrowser.isManageView = target.checked;
783
- this.collectionBrowser.manageViewLabel =
784
- 'Select items to remove (customizable texts)';
785
- }
786
-
787
- /**
788
- * Handler when the dev panel's "Enable manage mode -> Search" checkbox is changed.
789
- */
790
- private SearchManageModeCheckboxChanged(e: Event) {
791
- const target = e.target as HTMLInputElement;
792
- this.collectionBrowser.pageContext = target.checked
793
- ? 'search'
794
- : 'collection';
795
- }
796
-
797
- /**
798
- * Handler for when the dev panel's "Enable smart facet bar" checkbox is changed.
799
- */
800
- private smartFacetBarCheckboxChanged(e: Event) {
801
- const target = e.target as HTMLInputElement;
802
- this.collectionBrowser.showSmartFacetBar = target.checked;
803
- }
804
-
805
- /**
806
- * Handler for when the dev panel's "Show facet top slot" checkbox is changed.
807
- */
808
- private facetTopSlotCheckboxChanged(e: Event) {
809
- const target = e.target as HTMLInputElement;
810
-
811
- const p = document.createElement('p');
812
- p.style.setProperty('border', '1px solid #000');
813
- p.textContent = 'New stuff as a child.';
814
- p.style.setProperty('height', '20rem');
815
- p.style.backgroundColor = '#00000';
816
- p.setAttribute('slot', 'facet-top-slot');
817
-
818
- if (target.checked) {
819
- this.collectionBrowser.appendChild(p);
820
- } else {
821
- this.collectionBrowser.removeChild(
822
- this.collectionBrowser.lastElementChild as Element,
823
- );
824
- }
825
- }
826
-
827
- private toggleSlotOptions() {
828
- this.toggleSlots = !this.toggleSlots;
829
- }
830
-
831
- private resultLastTileSlotCheckboxChanged(e: Event) {
832
- const target = e.target as HTMLInputElement;
833
-
834
- const div = document.createElement('div');
835
- const title = document.createElement('h3');
836
- title.textContent = 'Upload';
837
-
838
- div.setAttribute('slot', 'result-last-tile');
839
- div.setAttribute('class', 'result-last-tile');
840
- div.appendChild(title);
841
-
842
- if (target.checked) {
843
- this.collectionBrowser.appendChild(div);
844
- } else {
845
- this.collectionBrowser.removeChild(
846
- this.collectionBrowser.lastElementChild as Element,
847
- );
848
- }
849
- }
850
-
851
- /**
852
- * Handler for when the dev panel's "Show cb top slot" checkbox is changed.
853
- */
854
- private cbTopSlotCheckboxChanged(e: Event) {
855
- const target = e.target as HTMLInputElement;
856
-
857
- const p = document.createElement('p');
858
- p.style.setProperty('border', '1px solid #000');
859
- p.textContent = 'My Favorite list header.';
860
- p.style.setProperty('height', '10rem');
861
- p.style.backgroundColor = '#00000';
862
- p.setAttribute('slot', 'cb-top-slot');
863
-
864
- if (target.checked) {
865
- this.collectionBrowser.appendChild(p);
866
- } else {
867
- this.collectionBrowser.removeChild(
868
- this.collectionBrowser.lastElementChild as Element,
869
- );
870
- }
871
- }
872
-
873
- /**
874
- * Handler for when the dev panel's "Show sort bar top left slot" checkbox is changed.
875
- */
876
- private sortBarLeftSlotCheckboxChanged(e: Event) {
877
- const target = e.target as HTMLInputElement;
878
-
879
- if (target.checked) {
880
- const div = document.createElement('div');
881
- div.style.setProperty('border', '1px solid #000');
882
- div.textContent = 'Btn';
883
- div.style.setProperty('height', '3rem');
884
- div.style.setProperty('width', '3rem');
885
- div.setAttribute('slot', 'sort-options-left');
886
-
887
- this.collectionBrowser.appendChild(div);
888
- } else {
889
- const slottedEl = this.collectionBrowser.querySelector(
890
- '[slot="sort-options-left"]',
891
- );
892
- if (slottedEl) this.collectionBrowser.removeChild(slottedEl);
893
- }
894
- }
895
-
896
- /**
897
- * Handler for when the dev panel's "Show sort bar top right slot" checkbox is changed.
898
- */
899
- private sortBarRightSlotCheckboxChanged(e: Event) {
900
- const target = e.target as HTMLInputElement;
901
-
902
- if (target.checked) {
903
- const div = document.createElement('div');
904
- div.style.setProperty('border', '1px solid #000');
905
- div.textContent = 'Search bar';
906
- div.style.setProperty('height', '3rem');
907
- div.style.setProperty('width', '15rem');
908
- div.setAttribute('slot', 'sort-options-right');
909
-
910
- this.collectionBrowser.appendChild(div);
911
- } else {
912
- const slottedEl = this.collectionBrowser.querySelector(
913
- '[slot="sort-options-right"]',
914
- );
915
- if (slottedEl) this.collectionBrowser.removeChild(slottedEl);
916
- }
917
- }
918
-
919
- private rowGapChanged(e: Event) {
920
- const input = e.target as HTMLInputElement;
921
- this.rowGap = parseFloat(input.value);
922
- this.collectionBrowser.style.setProperty(
923
- '--collectionBrowserRowGap',
924
- `${input.value}rem`,
925
- );
926
- }
927
-
928
- private colGapChanged(e: Event) {
929
- const input = e.target as HTMLInputElement;
930
- this.colGap = parseFloat(input.value);
931
- this.collectionBrowser.style.setProperty(
932
- '--collectionBrowserColGap',
933
- `${input.value}rem`,
934
- );
935
- }
936
-
937
- private widthChanged(e: Event) {
938
- const input = e.target as HTMLInputElement;
939
- this.cellWidth = parseFloat(input.value);
940
- this.collectionBrowser.style.setProperty(
941
- '--collectionBrowserCellMinWidth',
942
- `${input.value}rem`,
943
- );
944
- }
945
-
946
- private heightChanged(e: Event) {
947
- const input = e.target as HTMLInputElement;
948
- this.cellHeight = parseFloat(input.value);
949
- this.collectionBrowser.style.setProperty(
950
- '--collectionBrowserCellMinHeight',
951
- `${input.value}rem`,
952
- );
953
- this.collectionBrowser.style.setProperty(
954
- '--collectionBrowserCellMaxHeight',
955
- `${input.value}rem`,
956
- );
957
- }
958
-
959
- private visiblePageChanged(e: CustomEvent<{ pageNumber: number }>) {
960
- const { pageNumber } = e.detail;
961
- if (pageNumber === this.currentPage) return;
962
- this.currentPage = pageNumber;
963
- }
964
-
965
- /**
966
- * Handler for when the dev panel's "Replace sort options" checkbox is changed.
967
- */
968
- private replaceSortOptionsChanged(e: Event) {
969
- const target = e.target as HTMLInputElement;
970
-
971
- if (target.checked) {
972
- const p = document.createElement('p');
973
- p.style.setProperty('border', '1px solid #000');
974
- p.textContent = 'New stuff as a child.';
975
- p.style.setProperty('height', '20px');
976
- p.setAttribute('slot', 'sort-options');
977
-
978
- this.collectionBrowser.appendChild(p);
979
- this.collectionBrowser.enableSortOptionsSlot = true;
980
- } else {
981
- const slottedEl = this.collectionBrowser.querySelector(
982
- '[slot="sort-options"]',
983
- );
984
- if (slottedEl) this.collectionBrowser.removeChild(slottedEl);
985
- this.collectionBrowser.enableSortOptionsSlot = false;
986
- }
987
- }
988
-
989
- private profileElementChanged(e: Event) {
990
- const input = e.target as HTMLInputElement;
991
- this.profileElement = (input.value as PageElementName) || undefined;
992
- }
993
-
994
- static styles = css`
995
- :host {
996
- display: block;
997
- --primaryButtonBGColor: #194880;
998
- --ia-theme-link-color: #4b64ff;
999
- }
1000
-
1001
- /* add the following styles to ensure proper modal visibility */
1002
- body.modal-manager-open {
1003
- overflow: hidden;
1004
- }
1005
- modal-manager {
1006
- display: none;
1007
- }
1008
- modal-manager[mode='open'] {
1009
- display: block;
1010
- }
1011
- modal-manager.remove-items {
1012
- --modalWidth: 58rem;
1013
- --modalBorder: 2px solid var(--primaryButtonBGColor, #194880);
1014
- --modalTitleLineHeight: 4rem;
1015
- --modalTitleFontSize: 1.8rem;
1016
- }
1017
- modal-manager.more-search-facets {
1018
- --modalWidth: 85rem;
1019
- --modalBorder: 2px solid var(--primaryButtonBGColor, #194880);
1020
- --modalTitleLineHeight: 4rem;
1021
- --modalTitleFontSize: 1.8rem;
1022
- --modalCornerRadius: 0;
1023
- --modalBottomPadding: 0;
1024
- --modalBottomMargin: 0;
1025
- --modalScrollOffset: 0;
1026
- --modalCornerRadius: 0.5rem;
1027
- }
1028
- modal-manager.expanded-date-picker {
1029
- --modalWidth: 58rem;
1030
- --modalBorder: 2px solid var(--primaryButtonBGColor, #194880);
1031
- --modalTitleLineHeight: 4rem;
1032
- --modalTitleFontSize: 1.8rem;
1033
- --modalCornerRadius: 0;
1034
- --modalBottomPadding: 0;
1035
- --modalBottomMargin: 0;
1036
- --modalScrollOffset: 0;
1037
- --modalCornerRadius: 0.5rem;
1038
- }
1039
-
1040
- input,
1041
- button {
1042
- font-size: 1.6rem;
1043
- }
1044
-
1045
- modal-manager.showFacetGroupOutlines,
1046
- collection-browser.showFacetGroupOutlines {
1047
- --facet-row-border-top: 1px solid red;
1048
- --facet-row-border-bottom: 1px solid blue;
1049
- }
1050
-
1051
- collection-browser {
1052
- /* Same as production */
1053
- max-width: 135rem;
1054
- margin: auto;
1055
- }
1056
-
1057
- #collection-browser-container {
1058
- /* Same as production */
1059
- padding-left: 0.5rem;
1060
- margin-bottom: 2rem;
1061
- }
1062
-
1063
- #base-query-field {
1064
- width: 300px;
1065
- }
1066
-
1067
- .dev-tool-container {
1068
- position: relative;
1069
- }
1070
- #dev-tools {
1071
- position: relative;
1072
- top: 0;
1073
- left: 0;
1074
- z-index: 1;
1075
- -webkit-backdrop-filter: blur(10px);
1076
- backdrop-filter: blur(10px);
1077
- padding: 0.5rem 1rem;
1078
- border: 1px solid black;
1079
- font-size: 1.4rem;
1080
- background: #ffffffb3;
1081
- }
1082
-
1083
- #dev-tools > * {
1084
- display: flex;
1085
- }
1086
-
1087
- #toggle-dev-tools-btn {
1088
- position: fixed;
1089
- left: 77.4%;
1090
- top: 0;
1091
- background: red;
1092
- padding: 5px;
1093
- color: white;
1094
- font-size: 1.4rem;
1095
- margin: 0;
1096
- z-index: 1;
1097
- cursor: pointer;
1098
- }
1099
-
1100
- #search-and-page-inputs {
1101
- flex-wrap: wrap;
1102
- row-gap: 2px;
1103
- }
1104
-
1105
- #search-and-page-inputs > form {
1106
- margin-right: 1rem;
1107
- }
1108
-
1109
- #search-and-page-inputs label {
1110
- display: inline-block;
1111
- min-width: 50px;
1112
- }
1113
-
1114
- #page-number-input {
1115
- width: 75px;
1116
- }
1117
-
1118
- .search-type {
1119
- margin-right: 1rem;
1120
- }
1121
-
1122
- .cell-controls {
1123
- display: flex;
1124
- flex-wrap: wrap;
1125
- }
1126
- .cell-controls div {
1127
- display: flex;
1128
- align-items: center;
1129
- }
1130
- .cell-controls input[type='range'] {
1131
- width: 120px;
1132
- }
1133
- #cell-controls label {
1134
- display: inline-block;
1135
- width: 10rem;
1136
- }
1137
-
1138
- #cell-size-control,
1139
- #cell-gap-control {
1140
- flex-basis: calc(50% - 1rem);
1141
- flex-grow: 1;
1142
- }
1143
-
1144
- #cell-gap-control {
1145
- margin-left: 1rem;
1146
- }
1147
-
1148
- #checkbox-controls {
1149
- padding-top: 0.5rem;
1150
- flex-wrap: wrap;
1151
- }
1152
-
1153
- .checkbox-control {
1154
- flex-basis: 50%;
1155
- }
1156
- .checkbox-control.indent {
1157
- margin-left: 10px;
1158
- }
1159
- .checkbox-control label {
1160
- user-select: none;
1161
- }
1162
-
1163
- #last-event {
1164
- background-color: aliceblue;
1165
- padding: 5px;
1166
- margin: 5px auto;
1167
- }
1168
-
1169
- .hidden {
1170
- display: none;
1171
- }
1172
-
1173
- #toggle-controls {
1174
- background-color: lightskyblue;
1175
- padding: 5px;
1176
- margin: 5px auto;
1177
- }
1178
-
1179
- #search-types {
1180
- margin: 5px auto;
1181
- background-color: aliceblue;
1182
- font-size: 1.6rem;
1183
- }
1184
-
1185
- // slots
1186
- div[slot='cb-top-slot'] {
1187
- height: 50px;
1188
- border: 1px solid red;
1189
- background: bisque;
1190
- }
1191
- div[slot='facet-top-slot'] {
1192
- border: 1px solid red;
1193
- width: 100%;
1194
- height: 150px;
1195
- background-color: darkseagreen;
1196
- }
1197
- div[slot='sort-slot-left'] {
1198
- height: 50px;
1199
- border: 1px solid red;
1200
- background: bisque;
1201
- }
1202
-
1203
- /* user profile controls */
1204
- .user-profile-controls {
1205
- width: fit-content;
1206
- }
1207
-
1208
- .profile-element-controls {
1209
- margin-top: 4px;
1210
- }
1211
-
1212
- .profile-element-controls summary {
1213
- cursor: pointer;
1214
- user-select: none;
1215
- }
1216
-
1217
- .profile-element-options {
1218
- display: grid;
1219
- grid-template-columns: 1fr 1fr;
1220
- column-gap: 8px;
1221
- margin-top: 4px;
1222
- }
1223
-
1224
- fieldset {
1225
- display: inline-block !important;
1226
- }
1227
-
1228
- .result-last-tile {
1229
- border-radius: 4px;
1230
- background-color: white;
1231
- border: 3px dashed #555;
1232
- box-shadow: none;
1233
- display: grid;
1234
- align-content: center;
1235
- }
1236
- .result-last-tile:hover {
1237
- box-shadow: rgba(8, 8, 32, 0.8) 0 0 6px 2px;
1238
- transition: box-shadow 0.1s ease 0s;
1239
- cursor: pointer;
1240
- border: 3px dashed #4b64ff;
1241
- }
1242
- .result-last-tile h3 {
1243
- margin-bottom: 4rem;
1244
- margin: 0px auto;
1245
- font-size: 2.8rem;
1246
- color: rgb(44, 44, 44);
1247
- font-weight: 200;
1248
- text-align: center;
1249
- }
1250
- `;
1251
- }
1
+ import {
2
+ AnalyticsEvent,
3
+ AnalyticsManager,
4
+ } from '@internetarchive/analytics-manager';
5
+ import {
6
+ PageElementName,
7
+ SearchService,
8
+ SearchServiceInterface,
9
+ SearchType,
10
+ } from '@internetarchive/search-service';
11
+ import { html, css, LitElement, PropertyValues, nothing } from 'lit';
12
+ import { customElement, property, query, state } from 'lit/decorators.js';
13
+ import { SharedResizeObserver } from '@internetarchive/shared-resize-observer';
14
+
15
+ import type { ModalManagerInterface } from '@internetarchive/modal-manager';
16
+ import type { AnalyticsManagerInterface } from '@internetarchive/analytics-manager';
17
+ import type { CollectionBrowser } from '../src/collection-browser';
18
+
19
+ import '../src/collection-browser';
20
+ import { InfiniteScroller } from '@internetarchive/infinite-scroller';
21
+ import { TileDispatcher } from './tiles/tile-dispatcher';
22
+
23
+ @customElement('app-root')
24
+ export class AppRoot extends LitElement {
25
+ private searchService: SearchServiceInterface =
26
+ this.initSearchServiceFromUrlParams();
27
+
28
+ private resizeObserver = new SharedResizeObserver();
29
+
30
+ @state() private toggleSlots: boolean = false;
31
+
32
+ @state() private currentPage?: number;
33
+
34
+ @state() private searchQuery?: string;
35
+
36
+ @state() private withinCollection?: string;
37
+
38
+ @state() private cellWidth: number = 18;
39
+
40
+ @state() private cellHeight: number = 29;
41
+
42
+ @state() private rowGap: number = 1.7;
43
+
44
+ @state() private colGap: number = 1.7;
45
+
46
+ @state() private suppressFacets: boolean = false;
47
+
48
+ @state() private lazyLoadFacets: boolean = false;
49
+
50
+ @state() private loggedIn: boolean = false;
51
+
52
+ @state() private searchType: SearchType = SearchType.METADATA;
53
+
54
+ @state() private profileElement?: PageElementName;
55
+
56
+ @state() private withinProfile?: string;
57
+
58
+ @property({ type: Object, reflect: false }) latestAction?: AnalyticsEvent;
59
+
60
+ @query('#base-query-field') private baseQueryField!: HTMLInputElement;
61
+
62
+ @query('#base-collection-field')
63
+ private baseCollectionField!: HTMLInputElement;
64
+
65
+ @query('#page-number-input') private pageNumberInput!: HTMLInputElement;
66
+
67
+ @query('collection-browser') private collectionBrowser!: CollectionBrowser;
68
+
69
+ @query('modal-manager') private modalManager!: ModalManagerInterface;
70
+
71
+ private analyticsManager = new AnalyticsManager();
72
+
73
+ private analyticsHandler: AnalyticsManagerInterface = {
74
+ sendPing: this.sendAnalytics.bind(this),
75
+ sendEvent: this.sendAnalytics.bind(this),
76
+ sendEventNoSampling: this.sendAnalytics.bind(this),
77
+ };
78
+
79
+ private sendAnalytics(ae: AnalyticsEvent) {
80
+ console.log('Analytics Received ----', ae);
81
+ this.latestAction = ae;
82
+ this.analyticsManager?.sendEvent(ae);
83
+ }
84
+
85
+ private initSearchServiceFromUrlParams() {
86
+ const params = new URL(window.location.href).searchParams;
87
+ return new SearchService({
88
+ includeCredentials: false,
89
+ baseUrl: params.get('search_base_url') ?? undefined,
90
+ servicePath: params.get('search_service_path') ?? undefined,
91
+ debuggingEnabled: !!params.get('debugging'),
92
+ });
93
+ }
94
+
95
+ private searchPressed(e: Event) {
96
+ e.preventDefault();
97
+ this.searchQuery = this.baseQueryField.value;
98
+ this.collectionBrowser.searchType = this.searchType;
99
+
100
+ this.goToCurrentPage();
101
+ }
102
+
103
+ private collectionChanged(e: Event) {
104
+ e.preventDefault();
105
+ this.withinCollection = this.baseCollectionField.value;
106
+ this.collectionBrowser.withinCollection = this.withinCollection;
107
+
108
+ this.goToCurrentPage();
109
+ }
110
+
111
+ private goToCurrentPage() {
112
+ const page = this.currentPage ?? 1;
113
+ if (page > 1) {
114
+ this.collectionBrowser.goToPage(page);
115
+ } else {
116
+ // Ensure we reset the initial page
117
+ this.collectionBrowser.initialPageNumber = 1;
118
+ }
119
+ }
120
+
121
+ private changePagePressed(e: Event) {
122
+ e.preventDefault();
123
+ this.currentPage = this.pageNumberInput.valueAsNumber;
124
+ this.collectionBrowser.goToPage(this.currentPage);
125
+ }
126
+
127
+ protected override updated(changed: PropertyValues): void {
128
+ if (changed.has('currentPage') && this.currentPage) {
129
+ this.pageNumberInput.value = this.currentPage.toString();
130
+ }
131
+
132
+ if (changed.has('searchQuery')) {
133
+ this.queryUpdated();
134
+ }
135
+ }
136
+
137
+ private queryUpdated() {
138
+ this.collectionBrowser.baseQuery = this.searchQuery;
139
+ }
140
+
141
+ private get getClass() {
142
+ const searchParams = new URLSearchParams(window.location.search);
143
+
144
+ return searchParams.get('hide-dev-tools') ? 'hidden' : '';
145
+ }
146
+
147
+ render() {
148
+ return html`
149
+ <div class="dev-tool-container">
150
+ <div id="dev-tools" class=${this.getClass}>
151
+ <div id="search-and-page-inputs">
152
+ <form @submit=${this.searchPressed}>
153
+ <label for="base-query-field"> Query: </label>
154
+ <input
155
+ type="text"
156
+ id="base-query-field"
157
+ .value=${this.searchQuery ?? ''}
158
+ />
159
+ <input type="submit" value="Search" />
160
+ </form>
161
+ <form @submit=${this.changePagePressed}>
162
+ <label for="page-number-input"> Page: </label>
163
+ <input type="number" value="1" id="page-number-input" />
164
+ <input type="submit" value="Go" />
165
+ </form>
166
+ </div>
167
+ <div>
168
+ <form @submit=${this.collectionChanged}>
169
+ <label for="base-collection-field"> Within collection: </label>
170
+ <input
171
+ type="text"
172
+ id="base-collection-field"
173
+ .value=${this.withinCollection ?? ''}
174
+ />
175
+ <input type="submit" value="Search" />
176
+ </form>
177
+ </div>
178
+
179
+ <div id="search-types">
180
+ Search type:
181
+ <span class="search-type">
182
+ <input
183
+ type="radio"
184
+ id="default-search"
185
+ name="search-type"
186
+ value="default"
187
+ .checked=${this.searchType === SearchType.DEFAULT}
188
+ @click=${this.searchTypeSelected}
189
+ />
190
+ <label for="default-search">Default</label>
191
+ </span>
192
+ <span class="search-type">
193
+ <input
194
+ type="radio"
195
+ id="metadata-search"
196
+ name="search-type"
197
+ value="metadata"
198
+ .checked=${this.searchType === SearchType.METADATA}
199
+ @click=${this.searchTypeSelected}
200
+ />
201
+ <label for="metadata-search">Metadata</label>
202
+ </span>
203
+ <span class="search-type">
204
+ <input
205
+ type="radio"
206
+ id="fulltext-search"
207
+ name="search-type"
208
+ value="fulltext"
209
+ .checked=${this.searchType === SearchType.FULLTEXT}
210
+ @click=${this.searchTypeSelected}
211
+ />
212
+ <label for="fulltext-search">Full text</label>
213
+ </span>
214
+ <span class="search-type">
215
+ <input
216
+ type="radio"
217
+ id="tv-search"
218
+ name="search-type"
219
+ value="tv"
220
+ .checked=${this.searchType === SearchType.TV}
221
+ @click=${this.searchTypeSelected}
222
+ />
223
+ <label for="tv-search">TV</label>
224
+ </span>
225
+ <span class="search-type">
226
+ <input
227
+ type="radio"
228
+ id="radio-search"
229
+ name="search-type"
230
+ value="radio"
231
+ .checked=${this.searchType === SearchType.RADIO}
232
+ @click=${this.searchTypeSelected}
233
+ />
234
+ <label for="radio-search">Radio</label>
235
+ </span>
236
+ </div>
237
+
238
+ <div id="toggle-controls">
239
+ <button
240
+ @click=${() => {
241
+ const details =
242
+ this.shadowRoot?.getElementById('cell-size-control');
243
+ details?.classList.toggle('hidden');
244
+ const rowGapControls =
245
+ this.shadowRoot?.getElementById('cell-gap-control');
246
+ rowGapControls?.classList.toggle('hidden');
247
+ }}
248
+ >
249
+ Toggle Cell Controls
250
+ </button>
251
+ <button
252
+ @click=${() => {
253
+ const details = this.shadowRoot?.getElementById(
254
+ 'latest-event-details',
255
+ );
256
+ details?.classList.toggle('hidden');
257
+ }}
258
+ >
259
+ Last Event Captured
260
+ </button>
261
+ </div>
262
+
263
+ <div id="last-event">
264
+ <pre id="latest-event-details" class="hidden">
265
+ ${JSON.stringify(this.latestAction, null, 2)}
266
+ </pre
267
+ >
268
+ </div>
269
+
270
+ <fieldset class="cell-controls">
271
+ <legend>Cell Controls</legend>
272
+ <div>
273
+ <label for="cell-width-slider">Cell width:</label>
274
+ <input
275
+ type="range"
276
+ min="10"
277
+ max="100"
278
+ value="18"
279
+ step="0.1"
280
+ id="cell-width-slider"
281
+ @input=${this.widthChanged}
282
+ />
283
+ <span>${this.cellWidth}rem</span>
284
+ </div>
285
+ <div>
286
+ <label for="cell-height-slider">Cell height:</label>
287
+ <input
288
+ type="range"
289
+ min="10"
290
+ max="100"
291
+ value="29"
292
+ step="0.1"
293
+ id="cell-height-slider"
294
+ @input=${this.heightChanged}
295
+ />
296
+ <span>${this.cellHeight}rem</span>
297
+ </div>
298
+ <div>
299
+ <label for="cell-row-gap-slider">Row gap:</label>
300
+ <input
301
+ type="range"
302
+ min="0"
303
+ max="5"
304
+ value="1.7"
305
+ step="0.1"
306
+ id="cell-row-gap-slider"
307
+ @input=${this.rowGapChanged}
308
+ />
309
+ <span>${this.rowGap}rem</span>
310
+ </div>
311
+ <div>
312
+ <label for="cell-col-gap-slider">Col gap:</label>
313
+ <input
314
+ type="range"
315
+ min="0"
316
+ max="5"
317
+ value="1.7"
318
+ step="0.1"
319
+ id="cell-col-gap-slider"
320
+ @input=${this.colGapChanged}
321
+ />
322
+ <span>${this.colGap}rem</span>
323
+ </div>
324
+ </fieldset>
325
+
326
+ <fieldset class="other-controls">
327
+ <legend>Other Controls</legend>
328
+ <div class="checkbox-control">
329
+ <input
330
+ type="checkbox"
331
+ id="simulate-login"
332
+ @click=${this.loginChanged}
333
+ />
334
+ <label for="simulate-login">Simulate login</label>
335
+ </div>
336
+ <div class="checkbox-control">
337
+ <input
338
+ type="checkbox"
339
+ id="enable-date-picker"
340
+ checked
341
+ @click=${this.datePickerChanged}
342
+ />
343
+ <label for="enable-date-picker">Enable date picker</label>
344
+ </div>
345
+ <div class="checkbox-control">
346
+ <input
347
+ type="checkbox"
348
+ id="enable-facets"
349
+ checked
350
+ @click=${this.facetsChanged}
351
+ />
352
+ <label for="enable-facets">Enable facets</label>
353
+ </div>
354
+ <div class="checkbox-control indent">
355
+ <input
356
+ type="checkbox"
357
+ id="lazy-load-facets"
358
+ ?disabled=${this.suppressFacets}
359
+ @click=${this.lazyLoadFacetsChanged}
360
+ />
361
+ <label for="lazy-load-facets">Lazy load facets</label>
362
+ </div>
363
+ <div class="checkbox-control">
364
+ <input
365
+ type="checkbox"
366
+ id="enable-management"
367
+ @click=${this.manageModeCheckboxChanged}
368
+ />
369
+ <label for="enable-management">Enable manage mode</label>
370
+ </div>
371
+ <div class="checkbox-control indent">
372
+ <input
373
+ type="checkbox"
374
+ id="enable-search-management"
375
+ @click=${this.SearchManageModeCheckboxChanged}
376
+ />
377
+ <label for="enable-search-management">Search</label>
378
+ </div>
379
+ <div class="checkbox-control">
380
+ <input
381
+ type="checkbox"
382
+ id="enable-smart-facet-bar"
383
+ @click=${this.smartFacetBarCheckboxChanged}
384
+ />
385
+ <label for="enable-smart-facet-bar">Enable smart facet bar</label>
386
+ </div>
387
+ </fieldset>
388
+
389
+ <fieldset class="cb-visual-appearance">
390
+ <legend>CB Visual Appearance</legend>
391
+ <div class="checkbox-control">
392
+ <input
393
+ type="checkbox"
394
+ id="show-facet-group-outline-check"
395
+ @click=${this.toggleFacetGroupOutline}
396
+ />
397
+ <label for="show-facet-group-outline-check">
398
+ Show facet group outlines
399
+ </label>
400
+ </div>
401
+ <div class="checkbox-control">
402
+ <input
403
+ type="checkbox"
404
+ id="show-outline-check"
405
+ @click=${this.outlineChanged}
406
+ />
407
+ <label for="show-outline-check">Show cell outlines</label>
408
+ </div>
409
+ <div class="checkbox-control">
410
+ <input
411
+ type="checkbox"
412
+ id="minimal-tiles-check"
413
+ @click=${this.minimalTilesChanged}
414
+ />
415
+ <label for="minimal-tiles-check">Minimal tile layouts</label>
416
+ </div>
417
+ </fieldset>
418
+
419
+ <fieldset class="user-profile-controls">
420
+ <legend>User Profile Controls</legend>
421
+ <div class="checkbox-control">
422
+ <input
423
+ type="checkbox"
424
+ id="enable-facet-top-slot"
425
+ @click=${this.facetTopSlotCheckboxChanged}
426
+ />
427
+ <label for="enable-facet-top-slot">Show facet top slot</label>
428
+ </div>
429
+ <div class="checkbox-control">
430
+ <input
431
+ type="checkbox"
432
+ id="enable-cb-top-slot"
433
+ @click=${this.cbTopSlotCheckboxChanged}
434
+ />
435
+ <label for="enable-cb-top-slot">Show CB top slot</label>
436
+ </div>
437
+ <div class="checkbox-control">
438
+ <input
439
+ type="checkbox"
440
+ id="enable-sortbar-left-slot"
441
+ @click=${this.sortBarLeftSlotCheckboxChanged}
442
+ />
443
+ <label for="enable-sortbar-left-slot"
444
+ >Show sortbar left slot</label
445
+ >
446
+ </div>
447
+ <div class="checkbox-control">
448
+ <input
449
+ type="checkbox"
450
+ id="enable-sortbar-right-slot"
451
+ @click=${this.sortBarRightSlotCheckboxChanged}
452
+ />
453
+ <label for="enable-sortbar-right-slot"
454
+ >Show sortbar right slot</label
455
+ >
456
+ </div>
457
+ <div class="checkbox-control">
458
+ <input
459
+ type="checkbox"
460
+ id="enable-result-last-tile-slot"
461
+ @click=${this.resultLastTileSlotCheckboxChanged}
462
+ />
463
+ <label for="enable-result-last-tile-slot">
464
+ Show result last tile slot
465
+ </label>
466
+ </div>
467
+ <div class="checkbox-control">
468
+ <input
469
+ type="checkbox"
470
+ id="enable-replaced-sort-options"
471
+ @click=${this.replaceSortOptionsChanged}
472
+ />
473
+ <label for="enable-replaced-sort-options">
474
+ Show replaced sort options
475
+ </label>
476
+ </div>
477
+ <div class="text-input-control">
478
+ <label for="within-profile-input">withinProfile</label>
479
+ <input
480
+ type="text"
481
+ id="within-profile-input"
482
+ placeholder="e.g. @foobar"
483
+ @change=${(e: Event) => {
484
+ const val = (e.target as HTMLInputElement).value.trim();
485
+ this.withinProfile = val || undefined;
486
+ }}
487
+ />
488
+ </div>
489
+ <details class="profile-element-controls">
490
+ <summary>
491
+ Profile tab
492
+ (profileElement)${this.profileElement
493
+ ? html`: <strong>${this.profileElement}</strong>`
494
+ : ''}
495
+ </summary>
496
+ <div class="profile-element-options">
497
+ <div class="checkbox-control">
498
+ <input
499
+ type="radio"
500
+ id="profile-none"
501
+ name="profile-element"
502
+ value=""
503
+ checked
504
+ @click=${this.profileElementChanged}
505
+ />
506
+ <label for="profile-none">None</label>
507
+ </div>
508
+ ${(
509
+ [
510
+ 'uploads',
511
+ 'favorites',
512
+ 'reviews',
513
+ 'collections',
514
+ 'lending',
515
+ 'web_archives',
516
+ 'forum_posts',
517
+ ] as PageElementName[]
518
+ ).map(
519
+ tab => html`
520
+ <div class="checkbox-control">
521
+ <input
522
+ type="radio"
523
+ id="profile-${tab}"
524
+ name="profile-element"
525
+ value="${tab}"
526
+ @click=${this.profileElementChanged}
527
+ />
528
+ <label for="profile-${tab}">${tab}</label>
529
+ </div>
530
+ `,
531
+ )}
532
+ </div>
533
+ </details>
534
+ </fieldset>
535
+
536
+ <fieldset class="user-profile-controls">
537
+ <legend>Set Placeholder Types</legend>
538
+ <div class="checkbox-control">
539
+ <input
540
+ id="enable-loading-placeholder"
541
+ type="radio"
542
+ @click=${() => this.setPlaceholderType('loading-placeholder')}
543
+ name="placeholder-radio"
544
+ />
545
+ <label for="enable-loading-placeholder"
546
+ >Loading Placeholder</label
547
+ >
548
+ </div>
549
+ <div class="checkbox-control">
550
+ <input
551
+ id="enable-empty-placeholder"
552
+ type="radio"
553
+ @click=${() => this.setPlaceholderType('error-placeholder')}
554
+ value="empty-placeholder"
555
+ name="placeholder-radio"
556
+ />
557
+ <label for="enable-empty-placeholder">Empty Placeholder</label>
558
+ </div>
559
+ </fieldset>
560
+ </div>
561
+ <button id="toggle-dev-tools-btn" @click=${this.toggleDevTools}>
562
+ Toggle Search Controls
563
+ </button>
564
+ </div>
565
+ <div id="collection-browser-container">
566
+ <collection-browser
567
+ facetPaneVisible
568
+ .baseNavigationUrl=${'https://archive.org'}
569
+ .baseImageUrl=${'https://archive.org'}
570
+ .searchService=${this.searchService}
571
+ .resizeObserver=${this.resizeObserver}
572
+ .showHistogramDatePicker=${true}
573
+ .suppressFacets=${this.suppressFacets}
574
+ .lazyLoadFacets=${this.lazyLoadFacets}
575
+ .loggedIn=${this.loggedIn}
576
+ .modalManager=${this.modalManager}
577
+ .analyticsHandler=${this.analyticsHandler}
578
+ .withinProfile=${this.withinProfile}
579
+ .profileElement=${this.profileElement}
580
+ .pageContext=${'search'}
581
+ @visiblePageChanged=${this.visiblePageChanged}
582
+ @baseQueryChanged=${this.baseQueryChanged}
583
+ @searchTypeChanged=${this.searchTypeChanged}
584
+ @manageModeChanged=${this.manageModeChanged}
585
+ @itemRemovalRequested=${this.handleItemRemovalRequest}
586
+ @itemManagerRequested=${this.handleItemManagerRequest}
587
+ >
588
+ ${this.toggleSlots
589
+ ? html`<div slot="sortbar-left-slot">Sort Slot</div>`
590
+ : nothing}
591
+ ${this.toggleSlots
592
+ ? html`<div slot="facet-top-slot">Facet Slot</div>`
593
+ : nothing}
594
+ </collection-browser>
595
+ </div>
596
+ <modal-manager></modal-manager>
597
+ `;
598
+ }
599
+
600
+ private async setPlaceholderType(type: string) {
601
+ switch (type) {
602
+ case 'loading-placeholder':
603
+ this.collectionBrowser.baseQuery = '';
604
+ this.collectionBrowser.suppressPlaceholders = true;
605
+ this.collectionBrowser.clearResultsOnEmptyQuery = true;
606
+ this.requestUpdate();
607
+ await this.collectionBrowser.updateComplete;
608
+ break;
609
+ default:
610
+ break;
611
+ }
612
+ }
613
+
614
+ private baseQueryChanged(e: CustomEvent<{ baseQuery?: string }>): void {
615
+ this.searchQuery = e.detail.baseQuery;
616
+ }
617
+
618
+ /** Handler for search type changes coming from collection browser */
619
+ private searchTypeChanged(e: CustomEvent<SearchType>): void {
620
+ this.searchType = e.detail;
621
+ }
622
+
623
+ /** Handler for user input selecting a search type */
624
+ private searchTypeSelected(e: Event) {
625
+ const target = e.target as HTMLInputElement;
626
+ this.searchType = this.searchTypeFromSelectedOption(target.value);
627
+ }
628
+
629
+ private searchTypeFromSelectedOption(option: string): SearchType {
630
+ switch (option) {
631
+ case 'metadata':
632
+ return SearchType.METADATA;
633
+ case 'fulltext':
634
+ return SearchType.FULLTEXT;
635
+ case 'tv':
636
+ return SearchType.TV;
637
+ case 'radio':
638
+ return SearchType.RADIO;
639
+ default:
640
+ return SearchType.DEFAULT;
641
+ }
642
+ }
643
+
644
+ private loginChanged(e: Event) {
645
+ const target = e.target as HTMLInputElement;
646
+ if (target.checked) {
647
+ this.loggedIn = true;
648
+ } else {
649
+ this.loggedIn = false;
650
+ }
651
+ }
652
+
653
+ private outlineChanged(e: Event) {
654
+ const target = e.target as HTMLInputElement;
655
+ if (target.checked) {
656
+ this.collectionBrowser.style.setProperty(
657
+ '--infiniteScrollerCellOutline',
658
+ '1px solid #33D1FF',
659
+ );
660
+ } else {
661
+ this.collectionBrowser.style.removeProperty(
662
+ '--infiniteScrollerCellOutline',
663
+ );
664
+ }
665
+ }
666
+
667
+ private minimalTilesChanged(e: Event) {
668
+ const target = e.target as HTMLInputElement;
669
+ const scroller = this.collectionBrowser?.shadowRoot!.querySelector(
670
+ 'infinite-scroller',
671
+ ) as InfiniteScroller;
672
+ const tileDispatchers = [
673
+ ...scroller.shadowRoot!.querySelectorAll('tile-dispatcher'),
674
+ ] as TileDispatcher[];
675
+
676
+ if (target.checked) {
677
+ tileDispatchers?.forEach(tile => (tile.layoutType = 'minimal'));
678
+ } else {
679
+ tileDispatchers?.forEach(tile => (tile.layoutType = 'default'));
680
+ }
681
+ }
682
+
683
+ private toggleDevTools() {
684
+ const pageUrl = new URL(window.location.href);
685
+ const { searchParams } = pageUrl;
686
+
687
+ if (searchParams.get('hide-dev-tools')) {
688
+ searchParams.delete('hide-dev-tools');
689
+ } else {
690
+ searchParams.set('hide-dev-tools', 'true');
691
+ }
692
+
693
+ this.shadowRoot?.getElementById('dev-tools')?.classList.toggle('hidden');
694
+
695
+ if (window.history.replaceState) {
696
+ window.history.replaceState(
697
+ {
698
+ path: pageUrl.toString(),
699
+ },
700
+ '',
701
+ pageUrl.toString(),
702
+ );
703
+ }
704
+ }
705
+
706
+ private toggleFacetGroupOutline(e: Event) {
707
+ const target = e.target as HTMLInputElement;
708
+ if (target.checked) {
709
+ this.collectionBrowser.classList.add('showFacetGroupOutlines');
710
+ this.modalManager.classList.add('showFacetGroupOutlines');
711
+ } else {
712
+ this.collectionBrowser.classList.remove('showFacetGroupOutlines');
713
+ this.modalManager.classList.remove('showFacetGroupOutlines');
714
+ }
715
+ }
716
+
717
+ private datePickerChanged(e: Event) {
718
+ const target = e.target as HTMLInputElement;
719
+ this.collectionBrowser.showHistogramDatePicker = target.checked;
720
+
721
+ // When disabling the date picker from the demo app, also clear any existing date range params
722
+ if (!this.collectionBrowser.showHistogramDatePicker) {
723
+ this.collectionBrowser.minSelectedDate = undefined;
724
+ this.collectionBrowser.maxSelectedDate = undefined;
725
+ }
726
+ }
727
+
728
+ private facetsChanged(e: Event) {
729
+ const target = e.target as HTMLInputElement;
730
+ this.suppressFacets = !target.checked;
731
+ }
732
+
733
+ private lazyLoadFacetsChanged(e: Event) {
734
+ const target = e.target as HTMLInputElement;
735
+ this.lazyLoadFacets = target.checked;
736
+ }
737
+
738
+ /**
739
+ * Handler for when collection browser's manage mode changes.
740
+ * This lets us disable the checkbox in the dev panel when the user cancels out
741
+ * of manage mode from within collection browser.
742
+ */
743
+ private manageModeChanged(e: CustomEvent<boolean>): void {
744
+ const manageCheckbox = this.shadowRoot?.querySelector(
745
+ '#enable-management',
746
+ ) as HTMLInputElement;
747
+ if (manageCheckbox) manageCheckbox.checked = e.detail;
748
+ }
749
+
750
+ /**
751
+ * Handler for item removal
752
+ */
753
+ private handleItemRemovalRequest(e: CustomEvent) {
754
+ this.collectionBrowser.showRemoveItemsProcessingModal();
755
+ console.log('itemRemovalRequested: ', e.detail.items);
756
+
757
+ setTimeout(() => {
758
+ // execute item-removal-service, and response is successfully deleted
759
+ const status = false;
760
+
761
+ if (status) {
762
+ // looking for success?
763
+ this.collectionBrowser.isManageView = false;
764
+ this.modalManager?.closeModal();
765
+ this.modalManager?.classList.remove('remove-items');
766
+ } else {
767
+ // looking for failure?
768
+ this.collectionBrowser.showRemoveItemsErrorModal();
769
+ }
770
+ }, 2000); // let's wait to see processing modal
771
+ }
772
+
773
+ /**
774
+ * Handler when item manage requested
775
+ */
776
+ private handleItemManagerRequest(e: CustomEvent) {
777
+ console.log('itemManagerRequested: ', e.detail.items);
778
+ }
779
+
780
+ /**
781
+ * Handler for when the dev panel's "Enable manage mode" checkbox is changed.
782
+ */
783
+ private manageModeCheckboxChanged(e: Event) {
784
+ const target = e.target as HTMLInputElement;
785
+ this.collectionBrowser.isManageView = target.checked;
786
+ this.collectionBrowser.manageViewLabel =
787
+ 'Select items to remove (customizable texts)';
788
+ }
789
+
790
+ /**
791
+ * Handler when the dev panel's "Enable manage mode -> Search" checkbox is changed.
792
+ */
793
+ private SearchManageModeCheckboxChanged(e: Event) {
794
+ const target = e.target as HTMLInputElement;
795
+ this.collectionBrowser.pageContext = target.checked
796
+ ? 'search'
797
+ : 'collection';
798
+ }
799
+
800
+ /**
801
+ * Handler for when the dev panel's "Enable smart facet bar" checkbox is changed.
802
+ */
803
+ private smartFacetBarCheckboxChanged(e: Event) {
804
+ const target = e.target as HTMLInputElement;
805
+ this.collectionBrowser.showSmartFacetBar = target.checked;
806
+ }
807
+
808
+ /**
809
+ * Handler for when the dev panel's "Show facet top slot" checkbox is changed.
810
+ */
811
+ private facetTopSlotCheckboxChanged(e: Event) {
812
+ const target = e.target as HTMLInputElement;
813
+
814
+ const p = document.createElement('p');
815
+ p.style.setProperty('border', '1px solid #000');
816
+ p.textContent = 'New stuff as a child.';
817
+ p.style.setProperty('height', '20rem');
818
+ p.style.backgroundColor = '#00000';
819
+ p.setAttribute('slot', 'facet-top-slot');
820
+
821
+ if (target.checked) {
822
+ this.collectionBrowser.appendChild(p);
823
+ } else {
824
+ this.collectionBrowser.removeChild(
825
+ this.collectionBrowser.lastElementChild as Element,
826
+ );
827
+ }
828
+ }
829
+
830
+ private toggleSlotOptions() {
831
+ this.toggleSlots = !this.toggleSlots;
832
+ }
833
+
834
+ private resultLastTileSlotCheckboxChanged(e: Event) {
835
+ const target = e.target as HTMLInputElement;
836
+
837
+ const div = document.createElement('div');
838
+ const title = document.createElement('h3');
839
+ title.textContent = 'Upload';
840
+
841
+ div.setAttribute('slot', 'result-last-tile');
842
+ div.setAttribute('class', 'result-last-tile');
843
+ div.appendChild(title);
844
+
845
+ if (target.checked) {
846
+ this.collectionBrowser.appendChild(div);
847
+ } else {
848
+ this.collectionBrowser.removeChild(
849
+ this.collectionBrowser.lastElementChild as Element,
850
+ );
851
+ }
852
+ }
853
+
854
+ /**
855
+ * Handler for when the dev panel's "Show cb top slot" checkbox is changed.
856
+ */
857
+ private cbTopSlotCheckboxChanged(e: Event) {
858
+ const target = e.target as HTMLInputElement;
859
+
860
+ const p = document.createElement('p');
861
+ p.style.setProperty('border', '1px solid #000');
862
+ p.textContent = 'My Favorite list header.';
863
+ p.style.setProperty('height', '10rem');
864
+ p.style.backgroundColor = '#00000';
865
+ p.setAttribute('slot', 'cb-top-slot');
866
+
867
+ if (target.checked) {
868
+ this.collectionBrowser.appendChild(p);
869
+ } else {
870
+ this.collectionBrowser.removeChild(
871
+ this.collectionBrowser.lastElementChild as Element,
872
+ );
873
+ }
874
+ }
875
+
876
+ /**
877
+ * Handler for when the dev panel's "Show sort bar top left slot" checkbox is changed.
878
+ */
879
+ private sortBarLeftSlotCheckboxChanged(e: Event) {
880
+ const target = e.target as HTMLInputElement;
881
+
882
+ if (target.checked) {
883
+ const div = document.createElement('div');
884
+ div.style.setProperty('border', '1px solid #000');
885
+ div.textContent = 'Btn';
886
+ div.style.setProperty('height', '3rem');
887
+ div.style.setProperty('width', '3rem');
888
+ div.setAttribute('slot', 'sort-options-left');
889
+
890
+ this.collectionBrowser.appendChild(div);
891
+ } else {
892
+ const slottedEl = this.collectionBrowser.querySelector(
893
+ '[slot="sort-options-left"]',
894
+ );
895
+ if (slottedEl) this.collectionBrowser.removeChild(slottedEl);
896
+ }
897
+ }
898
+
899
+ /**
900
+ * Handler for when the dev panel's "Show sort bar top right slot" checkbox is changed.
901
+ */
902
+ private sortBarRightSlotCheckboxChanged(e: Event) {
903
+ const target = e.target as HTMLInputElement;
904
+
905
+ if (target.checked) {
906
+ const div = document.createElement('div');
907
+ div.style.setProperty('border', '1px solid #000');
908
+ div.textContent = 'Search bar';
909
+ div.style.setProperty('height', '3rem');
910
+ div.style.setProperty('width', '15rem');
911
+ div.setAttribute('slot', 'sort-options-right');
912
+
913
+ this.collectionBrowser.appendChild(div);
914
+ } else {
915
+ const slottedEl = this.collectionBrowser.querySelector(
916
+ '[slot="sort-options-right"]',
917
+ );
918
+ if (slottedEl) this.collectionBrowser.removeChild(slottedEl);
919
+ }
920
+ }
921
+
922
+ private rowGapChanged(e: Event) {
923
+ const input = e.target as HTMLInputElement;
924
+ this.rowGap = parseFloat(input.value);
925
+ this.collectionBrowser.style.setProperty(
926
+ '--collectionBrowserRowGap',
927
+ `${input.value}rem`,
928
+ );
929
+ }
930
+
931
+ private colGapChanged(e: Event) {
932
+ const input = e.target as HTMLInputElement;
933
+ this.colGap = parseFloat(input.value);
934
+ this.collectionBrowser.style.setProperty(
935
+ '--collectionBrowserColGap',
936
+ `${input.value}rem`,
937
+ );
938
+ }
939
+
940
+ private widthChanged(e: Event) {
941
+ const input = e.target as HTMLInputElement;
942
+ this.cellWidth = parseFloat(input.value);
943
+ this.collectionBrowser.style.setProperty(
944
+ '--collectionBrowserCellMinWidth',
945
+ `${input.value}rem`,
946
+ );
947
+ }
948
+
949
+ private heightChanged(e: Event) {
950
+ const input = e.target as HTMLInputElement;
951
+ this.cellHeight = parseFloat(input.value);
952
+ this.collectionBrowser.style.setProperty(
953
+ '--collectionBrowserCellMinHeight',
954
+ `${input.value}rem`,
955
+ );
956
+ this.collectionBrowser.style.setProperty(
957
+ '--collectionBrowserCellMaxHeight',
958
+ `${input.value}rem`,
959
+ );
960
+ }
961
+
962
+ private visiblePageChanged(e: CustomEvent<{ pageNumber: number }>) {
963
+ const { pageNumber } = e.detail;
964
+ if (pageNumber === this.currentPage) return;
965
+ this.currentPage = pageNumber;
966
+ }
967
+
968
+ /**
969
+ * Handler for when the dev panel's "Replace sort options" checkbox is changed.
970
+ */
971
+ private replaceSortOptionsChanged(e: Event) {
972
+ const target = e.target as HTMLInputElement;
973
+
974
+ if (target.checked) {
975
+ const p = document.createElement('p');
976
+ p.style.setProperty('border', '1px solid #000');
977
+ p.textContent = 'New stuff as a child.';
978
+ p.style.setProperty('height', '20px');
979
+ p.setAttribute('slot', 'sort-options');
980
+
981
+ this.collectionBrowser.appendChild(p);
982
+ this.collectionBrowser.enableSortOptionsSlot = true;
983
+ } else {
984
+ const slottedEl = this.collectionBrowser.querySelector(
985
+ '[slot="sort-options"]',
986
+ );
987
+ if (slottedEl) this.collectionBrowser.removeChild(slottedEl);
988
+ this.collectionBrowser.enableSortOptionsSlot = false;
989
+ }
990
+ }
991
+
992
+ private profileElementChanged(e: Event) {
993
+ const input = e.target as HTMLInputElement;
994
+ this.profileElement = (input.value as PageElementName) || undefined;
995
+ }
996
+
997
+ static styles = css`
998
+ :host {
999
+ display: block;
1000
+ --primaryButtonBGColor: #194880;
1001
+ --ia-theme-link-color: #4b64ff;
1002
+ }
1003
+
1004
+ /* add the following styles to ensure proper modal visibility */
1005
+ body.modal-manager-open {
1006
+ overflow: hidden;
1007
+ }
1008
+ modal-manager {
1009
+ display: none;
1010
+ }
1011
+ modal-manager[mode='open'] {
1012
+ display: block;
1013
+ }
1014
+ modal-manager.remove-items {
1015
+ --modalWidth: 58rem;
1016
+ --modalBorder: 2px solid var(--primaryButtonBGColor, #194880);
1017
+ --modalTitleLineHeight: 4rem;
1018
+ --modalTitleFontSize: 1.8rem;
1019
+ }
1020
+ modal-manager.more-search-facets {
1021
+ --modalWidth: 85rem;
1022
+ --modalBorder: 2px solid var(--primaryButtonBGColor, #194880);
1023
+ --modalTitleLineHeight: 4rem;
1024
+ --modalTitleFontSize: 1.8rem;
1025
+ --modalCornerRadius: 0;
1026
+ --modalBottomPadding: 0;
1027
+ --modalBottomMargin: 0;
1028
+ --modalScrollOffset: 0;
1029
+ --modalCornerRadius: 0.5rem;
1030
+ }
1031
+ modal-manager.expanded-date-picker {
1032
+ --modalWidth: 58rem;
1033
+ --modalBorder: 2px solid var(--primaryButtonBGColor, #194880);
1034
+ --modalTitleLineHeight: 4rem;
1035
+ --modalTitleFontSize: 1.8rem;
1036
+ --modalCornerRadius: 0;
1037
+ --modalBottomPadding: 0;
1038
+ --modalBottomMargin: 0;
1039
+ --modalScrollOffset: 0;
1040
+ --modalCornerRadius: 0.5rem;
1041
+ }
1042
+
1043
+ input,
1044
+ button {
1045
+ font-size: 1.6rem;
1046
+ }
1047
+
1048
+ modal-manager.showFacetGroupOutlines,
1049
+ collection-browser.showFacetGroupOutlines {
1050
+ --facet-row-border-top: 1px solid red;
1051
+ --facet-row-border-bottom: 1px solid blue;
1052
+ }
1053
+
1054
+ collection-browser {
1055
+ /* Same as production */
1056
+ max-width: 135rem;
1057
+ margin: auto;
1058
+ }
1059
+
1060
+ #collection-browser-container {
1061
+ /* Same as production */
1062
+ padding-left: 0.5rem;
1063
+ margin-bottom: 2rem;
1064
+ }
1065
+
1066
+ #base-query-field {
1067
+ width: 300px;
1068
+ }
1069
+
1070
+ .dev-tool-container {
1071
+ position: relative;
1072
+ }
1073
+ #dev-tools {
1074
+ position: relative;
1075
+ top: 0;
1076
+ left: 0;
1077
+ z-index: 1;
1078
+ -webkit-backdrop-filter: blur(10px);
1079
+ backdrop-filter: blur(10px);
1080
+ padding: 0.5rem 1rem;
1081
+ border: 1px solid black;
1082
+ font-size: 1.4rem;
1083
+ background: #ffffffb3;
1084
+ }
1085
+
1086
+ #dev-tools > * {
1087
+ display: flex;
1088
+ }
1089
+
1090
+ #toggle-dev-tools-btn {
1091
+ position: fixed;
1092
+ left: 77.4%;
1093
+ top: 0;
1094
+ background: red;
1095
+ padding: 5px;
1096
+ color: white;
1097
+ font-size: 1.4rem;
1098
+ margin: 0;
1099
+ z-index: 1;
1100
+ cursor: pointer;
1101
+ }
1102
+
1103
+ #search-and-page-inputs {
1104
+ flex-wrap: wrap;
1105
+ row-gap: 2px;
1106
+ }
1107
+
1108
+ #search-and-page-inputs > form {
1109
+ margin-right: 1rem;
1110
+ }
1111
+
1112
+ #search-and-page-inputs label {
1113
+ display: inline-block;
1114
+ min-width: 50px;
1115
+ }
1116
+
1117
+ #page-number-input {
1118
+ width: 75px;
1119
+ }
1120
+
1121
+ .search-type {
1122
+ margin-right: 1rem;
1123
+ }
1124
+
1125
+ .cell-controls {
1126
+ display: flex;
1127
+ flex-wrap: wrap;
1128
+ }
1129
+ .cell-controls div {
1130
+ display: flex;
1131
+ align-items: center;
1132
+ }
1133
+ .cell-controls input[type='range'] {
1134
+ width: 120px;
1135
+ }
1136
+ #cell-controls label {
1137
+ display: inline-block;
1138
+ width: 10rem;
1139
+ }
1140
+
1141
+ #cell-size-control,
1142
+ #cell-gap-control {
1143
+ flex-basis: calc(50% - 1rem);
1144
+ flex-grow: 1;
1145
+ }
1146
+
1147
+ #cell-gap-control {
1148
+ margin-left: 1rem;
1149
+ }
1150
+
1151
+ #checkbox-controls {
1152
+ padding-top: 0.5rem;
1153
+ flex-wrap: wrap;
1154
+ }
1155
+
1156
+ .checkbox-control {
1157
+ flex-basis: 50%;
1158
+ }
1159
+ .checkbox-control.indent {
1160
+ margin-left: 10px;
1161
+ }
1162
+ .checkbox-control label {
1163
+ user-select: none;
1164
+ }
1165
+
1166
+ #last-event {
1167
+ background-color: aliceblue;
1168
+ padding: 5px;
1169
+ margin: 5px auto;
1170
+ }
1171
+
1172
+ .hidden {
1173
+ display: none;
1174
+ }
1175
+
1176
+ #toggle-controls {
1177
+ background-color: lightskyblue;
1178
+ padding: 5px;
1179
+ margin: 5px auto;
1180
+ }
1181
+
1182
+ #search-types {
1183
+ margin: 5px auto;
1184
+ background-color: aliceblue;
1185
+ font-size: 1.6rem;
1186
+ }
1187
+
1188
+ // slots
1189
+ div[slot='cb-top-slot'] {
1190
+ height: 50px;
1191
+ border: 1px solid red;
1192
+ background: bisque;
1193
+ }
1194
+ div[slot='facet-top-slot'] {
1195
+ border: 1px solid red;
1196
+ width: 100%;
1197
+ height: 150px;
1198
+ background-color: darkseagreen;
1199
+ }
1200
+ div[slot='sort-slot-left'] {
1201
+ height: 50px;
1202
+ border: 1px solid red;
1203
+ background: bisque;
1204
+ }
1205
+
1206
+ /* user profile controls */
1207
+ .user-profile-controls {
1208
+ width: fit-content;
1209
+ }
1210
+
1211
+ .profile-element-controls {
1212
+ margin-top: 4px;
1213
+ }
1214
+
1215
+ .profile-element-controls summary {
1216
+ cursor: pointer;
1217
+ user-select: none;
1218
+ }
1219
+
1220
+ .profile-element-options {
1221
+ display: grid;
1222
+ grid-template-columns: 1fr 1fr;
1223
+ column-gap: 8px;
1224
+ margin-top: 4px;
1225
+ }
1226
+
1227
+ fieldset {
1228
+ display: inline-block !important;
1229
+ }
1230
+
1231
+ .result-last-tile {
1232
+ border-radius: 4px;
1233
+ background-color: white;
1234
+ border: 3px dashed #555;
1235
+ box-shadow: none;
1236
+ display: grid;
1237
+ align-content: center;
1238
+ }
1239
+ .result-last-tile:hover {
1240
+ box-shadow: rgba(8, 8, 32, 0.8) 0 0 6px 2px;
1241
+ transition: box-shadow 0.1s ease 0s;
1242
+ cursor: pointer;
1243
+ border: 3px dashed #4b64ff;
1244
+ }
1245
+ .result-last-tile h3 {
1246
+ margin-bottom: 4rem;
1247
+ margin: 0px auto;
1248
+ font-size: 2.8rem;
1249
+ color: rgb(44, 44, 44);
1250
+ font-weight: 200;
1251
+ text-align: center;
1252
+ }
1253
+ `;
1254
+ }