@internetarchive/collection-browser 4.4.1 → 4.5.0

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