@internetarchive/collection-browser 4.3.1-alpha-webdev8257.0 → 4.3.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.
Files changed (41) hide show
  1. package/dist/index.d.ts +0 -1
  2. package/dist/index.js.map +1 -1
  3. package/dist/src/app-root.d.ts +0 -8
  4. package/dist/src/app-root.js +672 -698
  5. package/dist/src/app-root.js.map +1 -1
  6. package/dist/src/collection-browser.d.ts +0 -8
  7. package/dist/src/collection-browser.js +762 -779
  8. package/dist/src/collection-browser.js.map +1 -1
  9. package/dist/src/tiles/base-tile-component.d.ts +1 -17
  10. package/dist/src/tiles/base-tile-component.js +1 -48
  11. package/dist/src/tiles/base-tile-component.js.map +1 -1
  12. package/dist/src/tiles/grid/item-tile.js +138 -139
  13. package/dist/src/tiles/grid/item-tile.js.map +1 -1
  14. package/dist/src/tiles/list/tile-list-compact-header.js +46 -66
  15. package/dist/src/tiles/list/tile-list-compact-header.js.map +1 -1
  16. package/dist/src/tiles/list/tile-list-compact.d.ts +1 -1
  17. package/dist/src/tiles/list/tile-list-compact.js +100 -132
  18. package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
  19. package/dist/src/tiles/list/tile-list.d.ts +1 -1
  20. package/dist/src/tiles/list/tile-list.js +298 -316
  21. package/dist/src/tiles/list/tile-list.js.map +1 -1
  22. package/dist/src/tiles/models.d.ts +0 -14
  23. package/dist/src/tiles/models.js.map +1 -1
  24. package/dist/src/tiles/tile-dispatcher.d.ts +0 -14
  25. package/dist/src/tiles/tile-dispatcher.js +216 -319
  26. package/dist/src/tiles/tile-dispatcher.js.map +1 -1
  27. package/index.ts +28 -29
  28. package/package.json +2 -2
  29. package/src/app-root.ts +1251 -1281
  30. package/src/collection-browser.ts +3049 -3063
  31. package/src/tiles/base-tile-component.ts +65 -121
  32. package/src/tiles/grid/item-tile.ts +346 -347
  33. package/src/tiles/list/tile-list-compact-header.ts +86 -106
  34. package/src/tiles/list/tile-list-compact.ts +239 -273
  35. package/src/tiles/list/tile-list.ts +700 -718
  36. package/src/tiles/models.ts +8 -24
  37. package/src/tiles/tile-dispatcher.ts +527 -637
  38. package/dist/src/styles/tile-action-styles.d.ts +0 -14
  39. package/dist/src/styles/tile-action-styles.js +0 -52
  40. package/dist/src/styles/tile-action-styles.js.map +0 -1
  41. package/src/styles/tile-action-styles.ts +0 -52
package/src/app-root.ts CHANGED
@@ -1,1281 +1,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
- }
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
- <div class="checkbox-control">
385
- <input
386
- type="checkbox"
387
- id="enable-tile-actions"
388
- @click=${this.tileActionsCheckboxChanged}
389
- />
390
- <label for="enable-tile-actions"
391
- >Enable tile action buttons</label
392
- >
393
- </div>
394
- </fieldset>
395
-
396
- <fieldset class="cb-visual-appearance">
397
- <legend>CB Visual Appearance</legend>
398
- <div class="checkbox-control">
399
- <input
400
- type="checkbox"
401
- id="show-facet-group-outline-check"
402
- @click=${this.toggleFacetGroupOutline}
403
- />
404
- <label for="show-facet-group-outline-check">
405
- Show facet group outlines
406
- </label>
407
- </div>
408
- <div class="checkbox-control">
409
- <input
410
- type="checkbox"
411
- id="show-outline-check"
412
- @click=${this.outlineChanged}
413
- />
414
- <label for="show-outline-check">Show cell outlines</label>
415
- </div>
416
- <div class="checkbox-control">
417
- <input
418
- type="checkbox"
419
- id="minimal-tiles-check"
420
- @click=${this.minimalTilesChanged}
421
- />
422
- <label for="minimal-tiles-check">Minimal tile layouts</label>
423
- </div>
424
- </fieldset>
425
-
426
- <fieldset class="user-profile-controls">
427
- <legend>User Profile Controls</legend>
428
- <div class="checkbox-control">
429
- <input
430
- type="checkbox"
431
- id="enable-facet-top-slot"
432
- @click=${this.facetTopSlotCheckboxChanged}
433
- />
434
- <label for="enable-facet-top-slot">Show facet top slot</label>
435
- </div>
436
- <div class="checkbox-control">
437
- <input
438
- type="checkbox"
439
- id="enable-cb-top-slot"
440
- @click=${this.cbTopSlotCheckboxChanged}
441
- />
442
- <label for="enable-cb-top-slot">Show CB top slot</label>
443
- </div>
444
- <div class="checkbox-control">
445
- <input
446
- type="checkbox"
447
- id="enable-sortbar-left-slot"
448
- @click=${this.sortBarLeftSlotCheckboxChanged}
449
- />
450
- <label for="enable-sortbar-left-slot"
451
- >Show sortbar left slot</label
452
- >
453
- </div>
454
- <div class="checkbox-control">
455
- <input
456
- type="checkbox"
457
- id="enable-sortbar-right-slot"
458
- @click=${this.sortBarRightSlotCheckboxChanged}
459
- />
460
- <label for="enable-sortbar-right-slot"
461
- >Show sortbar right slot</label
462
- >
463
- </div>
464
- <div class="checkbox-control">
465
- <input
466
- type="checkbox"
467
- id="enable-result-last-tile-slot"
468
- @click=${this.resultLastTileSlotCheckboxChanged}
469
- />
470
- <label for="enable-result-last-tile-slot">
471
- Show result last tile slot
472
- </label>
473
- </div>
474
- <div class="checkbox-control">
475
- <input
476
- type="checkbox"
477
- id="enable-replaced-sort-options"
478
- @click=${this.replaceSortOptionsChanged}
479
- />
480
- <label for="enable-replaced-sort-options">
481
- Show replaced sort options
482
- </label>
483
- </div>
484
- <div class="text-input-control">
485
- <label for="within-profile-input">withinProfile</label>
486
- <input
487
- type="text"
488
- id="within-profile-input"
489
- placeholder="e.g. @foobar"
490
- @change=${(e: Event) => {
491
- const val = (e.target as HTMLInputElement).value.trim();
492
- this.withinProfile = val || undefined;
493
- }}
494
- />
495
- </div>
496
- <details class="profile-element-controls">
497
- <summary>
498
- Profile tab
499
- (profileElement)${this.profileElement
500
- ? html`: <strong>${this.profileElement}</strong>`
501
- : ''}
502
- </summary>
503
- <div class="profile-element-options">
504
- <div class="checkbox-control">
505
- <input
506
- type="radio"
507
- id="profile-none"
508
- name="profile-element"
509
- value=""
510
- checked
511
- @click=${this.profileElementChanged}
512
- />
513
- <label for="profile-none">None</label>
514
- </div>
515
- ${(
516
- [
517
- 'uploads',
518
- 'favorites',
519
- 'reviews',
520
- 'collections',
521
- 'lending',
522
- 'web_archives',
523
- 'forum_posts',
524
- ] as PageElementName[]
525
- ).map(
526
- tab => html`
527
- <div class="checkbox-control">
528
- <input
529
- type="radio"
530
- id="profile-${tab}"
531
- name="profile-element"
532
- value="${tab}"
533
- @click=${this.profileElementChanged}
534
- />
535
- <label for="profile-${tab}">${tab}</label>
536
- </div>
537
- `,
538
- )}
539
- </div>
540
- </details>
541
- </fieldset>
542
-
543
- <fieldset class="user-profile-controls">
544
- <legend>Set Placeholder Types</legend>
545
- <div class="checkbox-control">
546
- <input
547
- id="enable-loading-placeholder"
548
- type="radio"
549
- @click=${() => this.setPlaceholderType('loading-placeholder')}
550
- name="placeholder-radio"
551
- />
552
- <label for="enable-loading-placeholder"
553
- >Loading Placeholder</label
554
- >
555
- </div>
556
- <div class="checkbox-control">
557
- <input
558
- id="enable-empty-placeholder"
559
- type="radio"
560
- @click=${() => this.setPlaceholderType('error-placeholder')}
561
- value="empty-placeholder"
562
- name="placeholder-radio"
563
- />
564
- <label for="enable-empty-placeholder">Empty Placeholder</label>
565
- </div>
566
- </fieldset>
567
- </div>
568
- <button id="toggle-dev-tools-btn" @click=${this.toggleDevTools}>
569
- Toggle Search Controls
570
- </button>
571
- </div>
572
- <div id="collection-browser-container">
573
- <collection-browser
574
- facetPaneVisible
575
- .baseNavigationUrl=${'https://archive.org'}
576
- .baseImageUrl=${'https://archive.org'}
577
- .searchService=${this.searchService}
578
- .resizeObserver=${this.resizeObserver}
579
- .showHistogramDatePicker=${true}
580
- .suppressFacets=${this.suppressFacets}
581
- .lazyLoadFacets=${this.lazyLoadFacets}
582
- .loggedIn=${this.loggedIn}
583
- .modalManager=${this.modalManager}
584
- .analyticsHandler=${this.analyticsHandler}
585
- .withinProfile=${this.withinProfile}
586
- .profileElement=${this.profileElement}
587
- .pageContext=${'search'}
588
- @visiblePageChanged=${this.visiblePageChanged}
589
- @baseQueryChanged=${this.baseQueryChanged}
590
- @searchTypeChanged=${this.searchTypeChanged}
591
- @manageModeChanged=${this.manageModeChanged}
592
- @itemRemovalRequested=${this.handleItemRemovalRequest}
593
- @itemManagerRequested=${this.handleItemManagerRequest}
594
- @tileActionClicked=${this.handleTileActionClicked}
595
- >
596
- ${this.toggleSlots
597
- ? html`<div slot="sortbar-left-slot">Sort Slot</div>`
598
- : nothing}
599
- ${this.toggleSlots
600
- ? html`<div slot="facet-top-slot">Facet Slot</div>`
601
- : nothing}
602
- </collection-browser>
603
- </div>
604
- <modal-manager></modal-manager>
605
- `;
606
- }
607
-
608
- private async setPlaceholderType(type: string) {
609
- switch (type) {
610
- case 'loading-placeholder':
611
- this.collectionBrowser.baseQuery = '';
612
- this.collectionBrowser.suppressPlaceholders = true;
613
- this.collectionBrowser.clearResultsOnEmptyQuery = true;
614
- this.requestUpdate();
615
- await this.collectionBrowser.updateComplete;
616
- break;
617
- default:
618
- break;
619
- }
620
- }
621
-
622
- private baseQueryChanged(e: CustomEvent<{ baseQuery?: string }>): void {
623
- this.searchQuery = e.detail.baseQuery;
624
- }
625
-
626
- /** Handler for search type changes coming from collection browser */
627
- private searchTypeChanged(e: CustomEvent<SearchType>): void {
628
- this.searchType = e.detail;
629
- }
630
-
631
- /** Handler for user input selecting a search type */
632
- private searchTypeSelected(e: Event) {
633
- const target = e.target as HTMLInputElement;
634
- this.searchType = this.searchTypeFromSelectedOption(target.value);
635
- }
636
-
637
- private searchTypeFromSelectedOption(option: string): SearchType {
638
- switch (option) {
639
- case 'metadata':
640
- return SearchType.METADATA;
641
- case 'fulltext':
642
- return SearchType.FULLTEXT;
643
- case 'tv':
644
- return SearchType.TV;
645
- case 'radio':
646
- return SearchType.RADIO;
647
- default:
648
- return SearchType.DEFAULT;
649
- }
650
- }
651
-
652
- private loginChanged(e: Event) {
653
- const target = e.target as HTMLInputElement;
654
- if (target.checked) {
655
- this.loggedIn = true;
656
- } else {
657
- this.loggedIn = false;
658
- }
659
- }
660
-
661
- private outlineChanged(e: Event) {
662
- const target = e.target as HTMLInputElement;
663
- if (target.checked) {
664
- this.collectionBrowser.style.setProperty(
665
- '--infiniteScrollerCellOutline',
666
- '1px solid #33D1FF',
667
- );
668
- } else {
669
- this.collectionBrowser.style.removeProperty(
670
- '--infiniteScrollerCellOutline',
671
- );
672
- }
673
- }
674
-
675
- private minimalTilesChanged(e: Event) {
676
- const target = e.target as HTMLInputElement;
677
- const scroller = this.collectionBrowser?.shadowRoot!.querySelector(
678
- 'infinite-scroller',
679
- ) as InfiniteScroller;
680
- const tileDispatchers = [
681
- ...scroller.shadowRoot!.querySelectorAll('tile-dispatcher'),
682
- ] as TileDispatcher[];
683
-
684
- if (target.checked) {
685
- tileDispatchers?.forEach(tile => (tile.layoutType = 'minimal'));
686
- } else {
687
- tileDispatchers?.forEach(tile => (tile.layoutType = 'default'));
688
- }
689
- }
690
-
691
- private toggleDevTools() {
692
- const pageUrl = new URL(window.location.href);
693
- const { searchParams } = pageUrl;
694
-
695
- if (searchParams.get('hide-dev-tools')) {
696
- searchParams.delete('hide-dev-tools');
697
- } else {
698
- searchParams.set('hide-dev-tools', 'true');
699
- }
700
-
701
- this.shadowRoot?.getElementById('dev-tools')?.classList.toggle('hidden');
702
-
703
- if (window.history.replaceState) {
704
- window.history.replaceState(
705
- {
706
- path: pageUrl.toString(),
707
- },
708
- '',
709
- pageUrl.toString(),
710
- );
711
- }
712
- }
713
-
714
- private toggleFacetGroupOutline(e: Event) {
715
- const target = e.target as HTMLInputElement;
716
- if (target.checked) {
717
- this.collectionBrowser.classList.add('showFacetGroupOutlines');
718
- this.modalManager.classList.add('showFacetGroupOutlines');
719
- } else {
720
- this.collectionBrowser.classList.remove('showFacetGroupOutlines');
721
- this.modalManager.classList.remove('showFacetGroupOutlines');
722
- }
723
- }
724
-
725
- private datePickerChanged(e: Event) {
726
- const target = e.target as HTMLInputElement;
727
- this.collectionBrowser.showHistogramDatePicker = target.checked;
728
-
729
- // When disabling the date picker from the demo app, also clear any existing date range params
730
- if (!this.collectionBrowser.showHistogramDatePicker) {
731
- this.collectionBrowser.minSelectedDate = undefined;
732
- this.collectionBrowser.maxSelectedDate = undefined;
733
- }
734
- }
735
-
736
- private facetsChanged(e: Event) {
737
- const target = e.target as HTMLInputElement;
738
- this.suppressFacets = !target.checked;
739
- }
740
-
741
- private lazyLoadFacetsChanged(e: Event) {
742
- const target = e.target as HTMLInputElement;
743
- this.lazyLoadFacets = target.checked;
744
- }
745
-
746
- /**
747
- * Handler for when collection browser's manage mode changes.
748
- * This lets us disable the checkbox in the dev panel when the user cancels out
749
- * of manage mode from within collection browser.
750
- */
751
- private manageModeChanged(e: CustomEvent<boolean>): void {
752
- const manageCheckbox = this.shadowRoot?.querySelector(
753
- '#enable-management',
754
- ) as HTMLInputElement;
755
- if (manageCheckbox) manageCheckbox.checked = e.detail;
756
- }
757
-
758
- /**
759
- * Handler for item removal
760
- */
761
- private handleItemRemovalRequest(e: CustomEvent) {
762
- this.collectionBrowser.showRemoveItemsProcessingModal();
763
- console.log('itemRemovalRequested: ', e.detail.items);
764
-
765
- setTimeout(() => {
766
- // execute item-removal-service, and response is successfully deleted
767
- const status = false;
768
-
769
- if (status) {
770
- // looking for success?
771
- this.collectionBrowser.isManageView = false;
772
- this.modalManager?.closeModal();
773
- this.modalManager?.classList.remove('remove-items');
774
- } else {
775
- // looking for failure?
776
- this.collectionBrowser.showRemoveItemsErrorModal();
777
- }
778
- }, 2000); // let's wait to see processing modal
779
- }
780
-
781
- /**
782
- * Handler when item manage requested
783
- */
784
- private handleItemManagerRequest(e: CustomEvent) {
785
- console.log('itemManagerRequested: ', e.detail.items);
786
- }
787
-
788
- /**
789
- * Handler for when the dev panel's "Enable manage mode" checkbox is changed.
790
- */
791
- private manageModeCheckboxChanged(e: Event) {
792
- const target = e.target as HTMLInputElement;
793
- this.collectionBrowser.isManageView = target.checked;
794
- this.collectionBrowser.manageViewLabel =
795
- 'Select items to remove (customizable texts)';
796
- }
797
-
798
- /**
799
- * Handler when the dev panel's "Enable manage mode -> Search" checkbox is changed.
800
- */
801
- private SearchManageModeCheckboxChanged(e: Event) {
802
- const target = e.target as HTMLInputElement;
803
- this.collectionBrowser.pageContext = target.checked
804
- ? 'search'
805
- : 'collection';
806
- }
807
-
808
- /**
809
- * Handler for when the dev panel's "Enable smart facet bar" checkbox is changed.
810
- */
811
- private smartFacetBarCheckboxChanged(e: Event) {
812
- const target = e.target as HTMLInputElement;
813
- this.collectionBrowser.showSmartFacetBar = target.checked;
814
- }
815
-
816
- /**
817
- * Handler for when the dev panel's "Enable tile action buttons" checkbox is changed.
818
- */
819
- private tileActionsCheckboxChanged(e: Event) {
820
- const target = e.target as HTMLInputElement;
821
- this.collectionBrowser.tileActions = target.checked
822
- ? [{ id: 'demo-action', label: 'Return' }]
823
- : [];
824
- }
825
-
826
- /**
827
- * Handler for tile action button clicks (logs to console for QA).
828
- */
829
- private handleTileActionClicked(
830
- e: CustomEvent<{ actionId: string; model: unknown }>,
831
- ) {
832
- console.log('Tile action clicked:', e.detail.actionId, e.detail.model);
833
- }
834
-
835
- /**
836
- * Handler for when the dev panel's "Show facet top slot" checkbox is changed.
837
- */
838
- private facetTopSlotCheckboxChanged(e: Event) {
839
- const target = e.target as HTMLInputElement;
840
-
841
- const p = document.createElement('p');
842
- p.style.setProperty('border', '1px solid #000');
843
- p.textContent = 'New stuff as a child.';
844
- p.style.setProperty('height', '20rem');
845
- p.style.backgroundColor = '#00000';
846
- p.setAttribute('slot', 'facet-top-slot');
847
-
848
- if (target.checked) {
849
- this.collectionBrowser.appendChild(p);
850
- } else {
851
- this.collectionBrowser.removeChild(
852
- this.collectionBrowser.lastElementChild as Element,
853
- );
854
- }
855
- }
856
-
857
- private toggleSlotOptions() {
858
- this.toggleSlots = !this.toggleSlots;
859
- }
860
-
861
- private resultLastTileSlotCheckboxChanged(e: Event) {
862
- const target = e.target as HTMLInputElement;
863
-
864
- const div = document.createElement('div');
865
- const title = document.createElement('h3');
866
- title.textContent = 'Upload';
867
-
868
- div.setAttribute('slot', 'result-last-tile');
869
- div.setAttribute('class', 'result-last-tile');
870
- div.appendChild(title);
871
-
872
- if (target.checked) {
873
- this.collectionBrowser.appendChild(div);
874
- } else {
875
- this.collectionBrowser.removeChild(
876
- this.collectionBrowser.lastElementChild as Element,
877
- );
878
- }
879
- }
880
-
881
- /**
882
- * Handler for when the dev panel's "Show cb top slot" checkbox is changed.
883
- */
884
- private cbTopSlotCheckboxChanged(e: Event) {
885
- const target = e.target as HTMLInputElement;
886
-
887
- const p = document.createElement('p');
888
- p.style.setProperty('border', '1px solid #000');
889
- p.textContent = 'My Favorite list header.';
890
- p.style.setProperty('height', '10rem');
891
- p.style.backgroundColor = '#00000';
892
- p.setAttribute('slot', 'cb-top-slot');
893
-
894
- if (target.checked) {
895
- this.collectionBrowser.appendChild(p);
896
- } else {
897
- this.collectionBrowser.removeChild(
898
- this.collectionBrowser.lastElementChild as Element,
899
- );
900
- }
901
- }
902
-
903
- /**
904
- * Handler for when the dev panel's "Show sort bar top left slot" checkbox is changed.
905
- */
906
- private sortBarLeftSlotCheckboxChanged(e: Event) {
907
- const target = e.target as HTMLInputElement;
908
-
909
- if (target.checked) {
910
- const div = document.createElement('div');
911
- div.style.setProperty('border', '1px solid #000');
912
- div.textContent = 'Btn';
913
- div.style.setProperty('height', '3rem');
914
- div.style.setProperty('width', '3rem');
915
- div.setAttribute('slot', 'sort-options-left');
916
-
917
- this.collectionBrowser.appendChild(div);
918
- } else {
919
- const slottedEl = this.collectionBrowser.querySelector(
920
- '[slot="sort-options-left"]',
921
- );
922
- if (slottedEl) this.collectionBrowser.removeChild(slottedEl);
923
- }
924
- }
925
-
926
- /**
927
- * Handler for when the dev panel's "Show sort bar top right slot" checkbox is changed.
928
- */
929
- private sortBarRightSlotCheckboxChanged(e: Event) {
930
- const target = e.target as HTMLInputElement;
931
-
932
- if (target.checked) {
933
- const div = document.createElement('div');
934
- div.style.setProperty('border', '1px solid #000');
935
- div.textContent = 'Search bar';
936
- div.style.setProperty('height', '3rem');
937
- div.style.setProperty('width', '15rem');
938
- div.setAttribute('slot', 'sort-options-right');
939
-
940
- this.collectionBrowser.appendChild(div);
941
- } else {
942
- const slottedEl = this.collectionBrowser.querySelector(
943
- '[slot="sort-options-right"]',
944
- );
945
- if (slottedEl) this.collectionBrowser.removeChild(slottedEl);
946
- }
947
- }
948
-
949
- private rowGapChanged(e: Event) {
950
- const input = e.target as HTMLInputElement;
951
- this.rowGap = parseFloat(input.value);
952
- this.collectionBrowser.style.setProperty(
953
- '--collectionBrowserRowGap',
954
- `${input.value}rem`,
955
- );
956
- }
957
-
958
- private colGapChanged(e: Event) {
959
- const input = e.target as HTMLInputElement;
960
- this.colGap = parseFloat(input.value);
961
- this.collectionBrowser.style.setProperty(
962
- '--collectionBrowserColGap',
963
- `${input.value}rem`,
964
- );
965
- }
966
-
967
- private widthChanged(e: Event) {
968
- const input = e.target as HTMLInputElement;
969
- this.cellWidth = parseFloat(input.value);
970
- this.collectionBrowser.style.setProperty(
971
- '--collectionBrowserCellMinWidth',
972
- `${input.value}rem`,
973
- );
974
- }
975
-
976
- private heightChanged(e: Event) {
977
- const input = e.target as HTMLInputElement;
978
- this.cellHeight = parseFloat(input.value);
979
- this.collectionBrowser.style.setProperty(
980
- '--collectionBrowserCellMinHeight',
981
- `${input.value}rem`,
982
- );
983
- this.collectionBrowser.style.setProperty(
984
- '--collectionBrowserCellMaxHeight',
985
- `${input.value}rem`,
986
- );
987
- }
988
-
989
- private visiblePageChanged(e: CustomEvent<{ pageNumber: number }>) {
990
- const { pageNumber } = e.detail;
991
- if (pageNumber === this.currentPage) return;
992
- this.currentPage = pageNumber;
993
- }
994
-
995
- /**
996
- * Handler for when the dev panel's "Replace sort options" checkbox is changed.
997
- */
998
- private replaceSortOptionsChanged(e: Event) {
999
- const target = e.target as HTMLInputElement;
1000
-
1001
- if (target.checked) {
1002
- const p = document.createElement('p');
1003
- p.style.setProperty('border', '1px solid #000');
1004
- p.textContent = 'New stuff as a child.';
1005
- p.style.setProperty('height', '20px');
1006
- p.setAttribute('slot', 'sort-options');
1007
-
1008
- this.collectionBrowser.appendChild(p);
1009
- this.collectionBrowser.enableSortOptionsSlot = true;
1010
- } else {
1011
- const slottedEl = this.collectionBrowser.querySelector(
1012
- '[slot="sort-options"]',
1013
- );
1014
- if (slottedEl) this.collectionBrowser.removeChild(slottedEl);
1015
- this.collectionBrowser.enableSortOptionsSlot = false;
1016
- }
1017
- }
1018
-
1019
- private profileElementChanged(e: Event) {
1020
- const input = e.target as HTMLInputElement;
1021
- this.profileElement = (input.value as PageElementName) || undefined;
1022
- }
1023
-
1024
- static styles = css`
1025
- :host {
1026
- display: block;
1027
- --primaryButtonBGColor: #194880;
1028
- --ia-theme-link-color: #4b64ff;
1029
- }
1030
-
1031
- /* add the following styles to ensure proper modal visibility */
1032
- body.modal-manager-open {
1033
- overflow: hidden;
1034
- }
1035
- modal-manager {
1036
- display: none;
1037
- }
1038
- modal-manager[mode='open'] {
1039
- display: block;
1040
- }
1041
- modal-manager.remove-items {
1042
- --modalWidth: 58rem;
1043
- --modalBorder: 2px solid var(--primaryButtonBGColor, #194880);
1044
- --modalTitleLineHeight: 4rem;
1045
- --modalTitleFontSize: 1.8rem;
1046
- }
1047
- modal-manager.more-search-facets {
1048
- --modalWidth: 85rem;
1049
- --modalBorder: 2px solid var(--primaryButtonBGColor, #194880);
1050
- --modalTitleLineHeight: 4rem;
1051
- --modalTitleFontSize: 1.8rem;
1052
- --modalCornerRadius: 0;
1053
- --modalBottomPadding: 0;
1054
- --modalBottomMargin: 0;
1055
- --modalScrollOffset: 0;
1056
- --modalCornerRadius: 0.5rem;
1057
- }
1058
- modal-manager.expanded-date-picker {
1059
- --modalWidth: 58rem;
1060
- --modalBorder: 2px solid var(--primaryButtonBGColor, #194880);
1061
- --modalTitleLineHeight: 4rem;
1062
- --modalTitleFontSize: 1.8rem;
1063
- --modalCornerRadius: 0;
1064
- --modalBottomPadding: 0;
1065
- --modalBottomMargin: 0;
1066
- --modalScrollOffset: 0;
1067
- --modalCornerRadius: 0.5rem;
1068
- }
1069
-
1070
- input,
1071
- button {
1072
- font-size: 1.6rem;
1073
- }
1074
-
1075
- modal-manager.showFacetGroupOutlines,
1076
- collection-browser.showFacetGroupOutlines {
1077
- --facet-row-border-top: 1px solid red;
1078
- --facet-row-border-bottom: 1px solid blue;
1079
- }
1080
-
1081
- collection-browser {
1082
- /* Same as production */
1083
- max-width: 135rem;
1084
- margin: auto;
1085
- }
1086
-
1087
- #collection-browser-container {
1088
- /* Same as production */
1089
- padding-left: 0.5rem;
1090
- margin-bottom: 2rem;
1091
- }
1092
-
1093
- #base-query-field {
1094
- width: 300px;
1095
- }
1096
-
1097
- .dev-tool-container {
1098
- position: relative;
1099
- }
1100
- #dev-tools {
1101
- position: relative;
1102
- top: 0;
1103
- left: 0;
1104
- z-index: 1;
1105
- -webkit-backdrop-filter: blur(10px);
1106
- backdrop-filter: blur(10px);
1107
- padding: 0.5rem 1rem;
1108
- border: 1px solid black;
1109
- font-size: 1.4rem;
1110
- background: #ffffffb3;
1111
- }
1112
-
1113
- #dev-tools > * {
1114
- display: flex;
1115
- }
1116
-
1117
- #toggle-dev-tools-btn {
1118
- position: fixed;
1119
- left: 77.4%;
1120
- top: 0;
1121
- background: red;
1122
- padding: 5px;
1123
- color: white;
1124
- font-size: 1.4rem;
1125
- margin: 0;
1126
- z-index: 1;
1127
- cursor: pointer;
1128
- }
1129
-
1130
- #search-and-page-inputs {
1131
- flex-wrap: wrap;
1132
- row-gap: 2px;
1133
- }
1134
-
1135
- #search-and-page-inputs > form {
1136
- margin-right: 1rem;
1137
- }
1138
-
1139
- #search-and-page-inputs label {
1140
- display: inline-block;
1141
- min-width: 50px;
1142
- }
1143
-
1144
- #page-number-input {
1145
- width: 75px;
1146
- }
1147
-
1148
- .search-type {
1149
- margin-right: 1rem;
1150
- }
1151
-
1152
- .cell-controls {
1153
- display: flex;
1154
- flex-wrap: wrap;
1155
- }
1156
- .cell-controls div {
1157
- display: flex;
1158
- align-items: center;
1159
- }
1160
- .cell-controls input[type='range'] {
1161
- width: 120px;
1162
- }
1163
- #cell-controls label {
1164
- display: inline-block;
1165
- width: 10rem;
1166
- }
1167
-
1168
- #cell-size-control,
1169
- #cell-gap-control {
1170
- flex-basis: calc(50% - 1rem);
1171
- flex-grow: 1;
1172
- }
1173
-
1174
- #cell-gap-control {
1175
- margin-left: 1rem;
1176
- }
1177
-
1178
- #checkbox-controls {
1179
- padding-top: 0.5rem;
1180
- flex-wrap: wrap;
1181
- }
1182
-
1183
- .checkbox-control {
1184
- flex-basis: 50%;
1185
- }
1186
- .checkbox-control.indent {
1187
- margin-left: 10px;
1188
- }
1189
- .checkbox-control label {
1190
- user-select: none;
1191
- }
1192
-
1193
- #last-event {
1194
- background-color: aliceblue;
1195
- padding: 5px;
1196
- margin: 5px auto;
1197
- }
1198
-
1199
- .hidden {
1200
- display: none;
1201
- }
1202
-
1203
- #toggle-controls {
1204
- background-color: lightskyblue;
1205
- padding: 5px;
1206
- margin: 5px auto;
1207
- }
1208
-
1209
- #search-types {
1210
- margin: 5px auto;
1211
- background-color: aliceblue;
1212
- font-size: 1.6rem;
1213
- }
1214
-
1215
- // slots
1216
- div[slot='cb-top-slot'] {
1217
- height: 50px;
1218
- border: 1px solid red;
1219
- background: bisque;
1220
- }
1221
- div[slot='facet-top-slot'] {
1222
- border: 1px solid red;
1223
- width: 100%;
1224
- height: 150px;
1225
- background-color: darkseagreen;
1226
- }
1227
- div[slot='sort-slot-left'] {
1228
- height: 50px;
1229
- border: 1px solid red;
1230
- background: bisque;
1231
- }
1232
-
1233
- /* user profile controls */
1234
- .user-profile-controls {
1235
- width: fit-content;
1236
- }
1237
-
1238
- .profile-element-controls {
1239
- margin-top: 4px;
1240
- }
1241
-
1242
- .profile-element-controls summary {
1243
- cursor: pointer;
1244
- user-select: none;
1245
- }
1246
-
1247
- .profile-element-options {
1248
- display: grid;
1249
- grid-template-columns: 1fr 1fr;
1250
- column-gap: 8px;
1251
- margin-top: 4px;
1252
- }
1253
-
1254
- fieldset {
1255
- display: inline-block !important;
1256
- }
1257
-
1258
- .result-last-tile {
1259
- border-radius: 4px;
1260
- background-color: white;
1261
- border: 3px dashed #555;
1262
- box-shadow: none;
1263
- display: grid;
1264
- align-content: center;
1265
- }
1266
- .result-last-tile:hover {
1267
- box-shadow: rgba(8, 8, 32, 0.8) 0 0 6px 2px;
1268
- transition: box-shadow 0.1s ease 0s;
1269
- cursor: pointer;
1270
- border: 3px dashed #4b64ff;
1271
- }
1272
- .result-last-tile h3 {
1273
- margin-bottom: 4rem;
1274
- margin: 0px auto;
1275
- font-size: 2.8rem;
1276
- color: rgb(44, 44, 44);
1277
- font-weight: 200;
1278
- text-align: center;
1279
- }
1280
- `;
1281
- }
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
+ }