@internetarchive/collection-browser 4.0.1 → 4.0.2

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