@internetarchive/collection-browser 4.8.1-webdev-9227.3 → 4.9.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.
- package/README.md +0 -33
- package/dist/src/collection-browser.d.ts +1 -2
- package/dist/src/collection-browser.js +35 -13
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/collection-facets/facet-row-template.d.ts +1 -1
- package/dist/src/collection-facets/facet-row-template.js +7 -14
- package/dist/src/collection-facets/facet-row-template.js.map +1 -1
- package/dist/src/collection-facets/facet-row.js +1 -3
- package/dist/src/collection-facets/facet-row.js.map +1 -1
- package/dist/src/collection-facets/more-facets-content.js +5 -6
- package/dist/src/collection-facets/more-facets-content.js.map +1 -1
- package/dist/src/collection-facets/more-facets-scroller.js +2 -3
- package/dist/src/collection-facets/more-facets-scroller.js.map +1 -1
- package/dist/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-entity-map.js +4 -13
- package/dist/src/collection-facets/smart-facets/heuristics/wikidata/wikidata-entity-map.js.map +1 -1
- package/dist/src/collection-facets/smart-facets/smart-facet-bar.js +2 -6
- package/dist/src/collection-facets/smart-facets/smart-facet-bar.js.map +1 -1
- package/dist/src/collection-facets.js +5 -6
- package/dist/src/collection-facets.js.map +1 -1
- package/dist/src/empty-placeholder.d.ts +7 -7
- package/dist/src/empty-placeholder.js +15 -29
- package/dist/src/empty-placeholder.js.map +1 -1
- package/dist/src/expanded-date-picker.js +2 -3
- package/dist/src/expanded-date-picker.js.map +1 -1
- package/dist/src/manage/manage-bar.d.ts +2 -3
- package/dist/src/manage/manage-bar.js +16 -15
- package/dist/src/manage/manage-bar.js.map +1 -1
- package/dist/src/manage/remove-items-modal-content.js +2 -3
- package/dist/src/manage/remove-items-modal-content.js.map +1 -1
- package/dist/src/mediatype/mediatype-config.js +18 -55
- package/dist/src/mediatype/mediatype-config.js.map +1 -1
- package/dist/src/models.js +40 -120
- package/dist/src/models.js.map +1 -1
- package/dist/src/sort-filter-bar/alpha-bar-tooltip.js +2 -8
- package/dist/src/sort-filter-bar/alpha-bar-tooltip.js.map +1 -1
- package/dist/src/sort-filter-bar/alpha-bar.js +2 -7
- package/dist/src/sort-filter-bar/alpha-bar.js.map +1 -1
- package/dist/src/sort-filter-bar/sort-filter-bar.js +45 -28
- package/dist/src/sort-filter-bar/sort-filter-bar.js.map +1 -1
- package/dist/src/tiles/grid/account-tile.js +2 -3
- package/dist/src/tiles/grid/account-tile.js.map +1 -1
- package/dist/src/tiles/grid/collection-tile.js +6 -12
- package/dist/src/tiles/grid/collection-tile.js.map +1 -1
- package/dist/src/tiles/grid/item-tile.js +7 -8
- package/dist/src/tiles/grid/item-tile.js.map +1 -1
- package/dist/src/tiles/grid/tile-stats.js +3 -6
- package/dist/src/tiles/grid/tile-stats.js.map +1 -1
- package/dist/src/tiles/list/tile-list-compact-header.js +2 -3
- package/dist/src/tiles/list/tile-list-compact-header.js.map +1 -1
- package/dist/src/tiles/list/tile-list-compact.js +1 -3
- package/dist/src/tiles/list/tile-list-compact.js.map +1 -1
- package/dist/src/tiles/list/tile-list.js +5 -15
- package/dist/src/tiles/list/tile-list.js.map +1 -1
- package/dist/src/tiles/overlay/text-overlay.js +1 -3
- package/dist/src/tiles/overlay/text-overlay.js.map +1 -1
- package/dist/src/tiles/review-block.js +2 -3
- package/dist/src/tiles/review-block.js.map +1 -1
- package/dist/src/tiles/tile-dispatcher.d.ts +1 -2
- package/dist/src/tiles/tile-dispatcher.js +5 -6
- package/dist/src/tiles/tile-dispatcher.js.map +1 -1
- package/dist/src/tiles/tile-mediatype-icon.js +1 -3
- package/dist/src/tiles/tile-mediatype-icon.js.map +1 -1
- package/dist/src/utils/format-count.d.ts +1 -3
- package/dist/src/utils/format-count.js +59 -19
- package/dist/src/utils/format-count.js.map +1 -1
- package/dist/src/utils/format-unit-size.d.ts +1 -1
- package/dist/src/utils/format-unit-size.js +18 -21
- package/dist/src/utils/format-unit-size.js.map +1 -1
- package/dist/src/utils/log.d.ts +4 -1
- package/package.json +2 -10
- package/dist/src/locales/es.d.ts +0 -200
- package/dist/src/locales/es.js +0 -215
- package/dist/src/locales/es.js.map +0 -1
- package/dist/src/utils/get-locale.d.ts +0 -14
- package/dist/src/utils/get-locale.js +0 -18
- package/dist/src/utils/get-locale.js.map +0 -1
- package/locales/es.d.ts +0 -1
- package/locales/es.js +0 -1
package/dist/src/models.js
CHANGED
|
@@ -5,12 +5,8 @@ import { resolveMediatype } from './utils/resolve-mediatype';
|
|
|
5
5
|
import { loginRequiredIcon } from './assets/img/icons/login-required';
|
|
6
6
|
import { restrictedIcon } from './assets/img/icons/restricted';
|
|
7
7
|
export const TILE_OVERLAY_TEXT = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
},
|
|
11
|
-
get 'content-warning'() {
|
|
12
|
-
return msg('Content may be inappropriate');
|
|
13
|
-
},
|
|
8
|
+
'login-required': msg('Log in to view this item'),
|
|
9
|
+
'content-warning': msg('Content may be inappropriate'),
|
|
14
10
|
};
|
|
15
11
|
export const TILE_OVERLAY_ICONS = {
|
|
16
12
|
'login-required': loginRequiredIcon,
|
|
@@ -223,9 +219,7 @@ export const SORT_OPTIONS = {
|
|
|
223
219
|
shownInSortBar: true,
|
|
224
220
|
shownInURL: false,
|
|
225
221
|
handledBySearchService: false,
|
|
226
|
-
|
|
227
|
-
return msg('Relevance');
|
|
228
|
-
},
|
|
222
|
+
displayName: 'Relevance',
|
|
229
223
|
urlNames: ['_score'],
|
|
230
224
|
},
|
|
231
225
|
[SortField.alltimeview]: {
|
|
@@ -236,9 +230,7 @@ export const SORT_OPTIONS = {
|
|
|
236
230
|
shownInURL: true,
|
|
237
231
|
handledBySearchService: true,
|
|
238
232
|
searchServiceKey: 'downloads',
|
|
239
|
-
|
|
240
|
-
return msg('All-time views');
|
|
241
|
-
},
|
|
233
|
+
displayName: 'All-time views',
|
|
242
234
|
urlNames: ['downloads'],
|
|
243
235
|
},
|
|
244
236
|
[SortField.weeklyview]: {
|
|
@@ -249,9 +241,7 @@ export const SORT_OPTIONS = {
|
|
|
249
241
|
shownInURL: true,
|
|
250
242
|
handledBySearchService: true,
|
|
251
243
|
searchServiceKey: 'week',
|
|
252
|
-
|
|
253
|
-
return msg('Weekly views');
|
|
254
|
-
},
|
|
244
|
+
displayName: 'Weekly views',
|
|
255
245
|
urlNames: ['week'],
|
|
256
246
|
},
|
|
257
247
|
[SortField.title]: {
|
|
@@ -262,9 +252,7 @@ export const SORT_OPTIONS = {
|
|
|
262
252
|
shownInURL: true,
|
|
263
253
|
handledBySearchService: true,
|
|
264
254
|
searchServiceKey: 'titleSorter',
|
|
265
|
-
|
|
266
|
-
return msg('Title');
|
|
267
|
-
},
|
|
255
|
+
displayName: 'Title',
|
|
268
256
|
urlNames: ['title', 'titleSorter'],
|
|
269
257
|
},
|
|
270
258
|
[SortField.date]: {
|
|
@@ -275,9 +263,7 @@ export const SORT_OPTIONS = {
|
|
|
275
263
|
shownInURL: true,
|
|
276
264
|
handledBySearchService: true,
|
|
277
265
|
searchServiceKey: 'date',
|
|
278
|
-
|
|
279
|
-
return msg('Date published');
|
|
280
|
-
},
|
|
266
|
+
displayName: 'Date published',
|
|
281
267
|
urlNames: ['date'],
|
|
282
268
|
},
|
|
283
269
|
[SortField.datearchived]: {
|
|
@@ -288,9 +274,7 @@ export const SORT_OPTIONS = {
|
|
|
288
274
|
shownInURL: true,
|
|
289
275
|
handledBySearchService: true,
|
|
290
276
|
searchServiceKey: 'publicdate',
|
|
291
|
-
|
|
292
|
-
return msg('Date archived');
|
|
293
|
-
},
|
|
277
|
+
displayName: 'Date archived',
|
|
294
278
|
urlNames: ['publicdate'],
|
|
295
279
|
},
|
|
296
280
|
[SortField.datereviewed]: {
|
|
@@ -301,9 +285,7 @@ export const SORT_OPTIONS = {
|
|
|
301
285
|
shownInURL: true,
|
|
302
286
|
handledBySearchService: true,
|
|
303
287
|
searchServiceKey: 'reviewdate',
|
|
304
|
-
|
|
305
|
-
return msg('Date reviewed');
|
|
306
|
-
},
|
|
288
|
+
displayName: 'Date reviewed',
|
|
307
289
|
urlNames: ['reviewdate'],
|
|
308
290
|
},
|
|
309
291
|
[SortField.dateadded]: {
|
|
@@ -314,9 +296,7 @@ export const SORT_OPTIONS = {
|
|
|
314
296
|
shownInURL: true,
|
|
315
297
|
handledBySearchService: true,
|
|
316
298
|
searchServiceKey: 'addeddate',
|
|
317
|
-
|
|
318
|
-
return msg('Date added');
|
|
319
|
-
},
|
|
299
|
+
displayName: 'Date added',
|
|
320
300
|
urlNames: ['addeddate'],
|
|
321
301
|
},
|
|
322
302
|
[SortField.datefavorited]: {
|
|
@@ -327,9 +307,7 @@ export const SORT_OPTIONS = {
|
|
|
327
307
|
shownInURL: false,
|
|
328
308
|
handledBySearchService: false,
|
|
329
309
|
searchServiceKey: 'favoritedate',
|
|
330
|
-
|
|
331
|
-
return msg('Date favorited');
|
|
332
|
-
},
|
|
310
|
+
displayName: 'Date favorited',
|
|
333
311
|
urlNames: ['favoritedate'],
|
|
334
312
|
},
|
|
335
313
|
[SortField.creator]: {
|
|
@@ -340,9 +318,7 @@ export const SORT_OPTIONS = {
|
|
|
340
318
|
shownInURL: true,
|
|
341
319
|
handledBySearchService: true,
|
|
342
320
|
searchServiceKey: 'creatorSorter',
|
|
343
|
-
|
|
344
|
-
return msg('Creator');
|
|
345
|
-
},
|
|
321
|
+
displayName: 'Creator',
|
|
346
322
|
urlNames: ['creator', 'creatorSorter'],
|
|
347
323
|
},
|
|
348
324
|
};
|
|
@@ -441,77 +417,33 @@ export const tvFacetDisplayOrder = [
|
|
|
441
417
|
* Human-readable titles for each facet group.
|
|
442
418
|
*/
|
|
443
419
|
export const facetTitles = {
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
},
|
|
456
|
-
get creator() {
|
|
457
|
-
return msg('Creator');
|
|
458
|
-
},
|
|
459
|
-
get collection() {
|
|
460
|
-
return msg('Collection');
|
|
461
|
-
},
|
|
462
|
-
get year() {
|
|
463
|
-
return msg('Year');
|
|
464
|
-
},
|
|
465
|
-
get clip_type() {
|
|
466
|
-
return msg('Clip Type');
|
|
467
|
-
},
|
|
468
|
-
get program() {
|
|
469
|
-
return msg('Program');
|
|
470
|
-
},
|
|
471
|
-
get person() {
|
|
472
|
-
return msg('Person');
|
|
473
|
-
},
|
|
474
|
-
get sponsor() {
|
|
475
|
-
return msg('Sponsor');
|
|
476
|
-
},
|
|
420
|
+
subject: 'Subject',
|
|
421
|
+
lending: 'Availability',
|
|
422
|
+
mediatype: 'Media Type',
|
|
423
|
+
language: 'Language',
|
|
424
|
+
creator: 'Creator',
|
|
425
|
+
collection: 'Collection',
|
|
426
|
+
year: 'Year',
|
|
427
|
+
clip_type: 'Clip Type',
|
|
428
|
+
program: 'Program',
|
|
429
|
+
person: 'Person',
|
|
430
|
+
sponsor: 'Sponsor',
|
|
477
431
|
};
|
|
478
432
|
/**
|
|
479
433
|
* Human-readable plural titles for each facet group, for referring to its values.
|
|
480
434
|
*/
|
|
481
435
|
export const facetPluralTitles = {
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
},
|
|
494
|
-
get creator() {
|
|
495
|
-
return msg('Creators');
|
|
496
|
-
},
|
|
497
|
-
get collection() {
|
|
498
|
-
return msg('Collections');
|
|
499
|
-
},
|
|
500
|
-
get year() {
|
|
501
|
-
return msg('Years');
|
|
502
|
-
},
|
|
503
|
-
get clip_type() {
|
|
504
|
-
return msg('Clip Types');
|
|
505
|
-
},
|
|
506
|
-
get program() {
|
|
507
|
-
return msg('Programs');
|
|
508
|
-
},
|
|
509
|
-
get person() {
|
|
510
|
-
return msg('People');
|
|
511
|
-
},
|
|
512
|
-
get sponsor() {
|
|
513
|
-
return msg('Sponsors');
|
|
514
|
-
},
|
|
436
|
+
subject: 'Subjects',
|
|
437
|
+
lending: 'Availability',
|
|
438
|
+
mediatype: 'Media Types',
|
|
439
|
+
language: 'Languages',
|
|
440
|
+
creator: 'Creators',
|
|
441
|
+
collection: 'Collections',
|
|
442
|
+
year: 'Years',
|
|
443
|
+
clip_type: 'Clip Types',
|
|
444
|
+
program: 'Programs',
|
|
445
|
+
person: 'People',
|
|
446
|
+
sponsor: 'Sponsors',
|
|
515
447
|
};
|
|
516
448
|
/**
|
|
517
449
|
* The default sort type to use for each facet type
|
|
@@ -568,26 +500,14 @@ export const lendingFacetKeysVisibility = {
|
|
|
568
500
|
};
|
|
569
501
|
export const customFacetDisplayNames = {
|
|
570
502
|
lending: {
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
get available_to_borrow() {
|
|
575
|
-
return msg('Borrow 14 Days');
|
|
576
|
-
},
|
|
577
|
-
get is_readable() {
|
|
578
|
-
return msg('Always Available');
|
|
579
|
-
},
|
|
503
|
+
is_lendable: 'Lending Library',
|
|
504
|
+
available_to_borrow: 'Borrow 14 Days',
|
|
505
|
+
is_readable: 'Always Available',
|
|
580
506
|
},
|
|
581
507
|
clip_type: {
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
get commercial() {
|
|
586
|
-
return msg('Political Ad');
|
|
587
|
-
},
|
|
588
|
-
get 'fact check'() {
|
|
589
|
-
return msg('Fact Check');
|
|
590
|
-
},
|
|
508
|
+
quote: 'Quote',
|
|
509
|
+
commercial: 'Political Ad',
|
|
510
|
+
'fact check': 'Fact Check',
|
|
591
511
|
},
|
|
592
512
|
};
|
|
593
513
|
/**
|
package/dist/src/models.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;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ACP,IAAI,WAAW;YACb,OAAO,GAAG,CAAC,iBAAiB,CAAC,CAAC;QAChC,CAAC;QACD,IAAI,mBAAmB;YACrB,OAAO,GAAG,CAAC,gBAAgB,CAAC,CAAC;QAC/B,CAAC;QACD,IAAI,WAAW;YACb,OAAO,GAAG,CAAC,kBAAkB,CAAC,CAAC;QACjC,CAAC;KACF;IACD,SAAS,EAAE;QACT,IAAI,KAAK;YACP,OAAO,GAAG,CAAC,OAAO,CAAC,CAAC;QACtB,CAAC;QACD,IAAI,UAAU;YACZ,OAAO,GAAG,CAAC,cAAc,CAAC,CAAC;QAC7B,CAAC;QACD,IAAI,YAAY;YACd,OAAO,GAAG,CAAC,YAAY,CAAC,CAAC;QAC3B,CAAC;KACF;CACF,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAA4B;IAC5D,WAAW,EAAE,IAAI;IACjB,SAAS,EAAE,IAAI;IACf,WAAW,EAAE,IAAI;IACjB,YAAY,EAAE,IAAI;IAClB,eAAe,EAAE,IAAI;IACrB,aAAa,EAAE,IAAI;IACnB,gBAAgB,EAAE,IAAI;IACtB,wBAAwB,EAAE,IAAI;IAC9B,KAAK,EAAE,IAAI;IACX,SAAS,EAAE,IAAI;IACf,OAAO,EAAE,IAAI;CACd,CAAC","sourcesContent":["import type { TemplateResult } from 'lit';\nimport { msg } from '@lit/localize';\nimport type { MediaType } from '@internetarchive/field-parsers';\nimport {\n AggregationSortType,\n HitType,\n SearchReview,\n SearchResult,\n SortDirection,\n} from '@internetarchive/search-service';\nimport { collapseRepeatedQuotes } from './utils/collapse-repeated-quotes';\nimport { resolveMediatype } from './utils/resolve-mediatype';\n\nimport { loginRequiredIcon } from './assets/img/icons/login-required';\nimport { restrictedIcon } from './assets/img/icons/restricted';\n\n/**\n * Flags that can affect the visibility of content on a tile\n */\ninterface TileFlags {\n loginRequired: boolean;\n contentWarning: boolean;\n}\n\n/**\n * Different types of tile overlays, corresponding to the above flags.\n */\nexport type TileOverlayType = 'login-required' | 'content-warning';\n\nexport const TILE_OVERLAY_TEXT: Record<TileOverlayType, string> = {\n get 'login-required'() {\n return msg('Log in to view this item');\n },\n get 'content-warning'() {\n return msg('Content may be inappropriate');\n },\n};\n\nexport const TILE_OVERLAY_ICONS: Record<TileOverlayType, TemplateResult> = {\n 'login-required': loginRequiredIcon,\n 'content-warning': restrictedIcon,\n};\n\n/**\n * What type of request produced a given set of hits:\n * - `search_query`: Hits produced by an explicit user query and/or applied filters on any page\n * - `collection_members`: Hits produced for a collection page without any query or filters\n * - `profile_tab`: Hits produced for a tab of the profile page without any query or filters\n * - `unknown`: Hits produced via any other means\n */\nexport type HitRequestSource =\n | 'search_query'\n | 'collection_members'\n | 'profile_tab'\n | 'unknown';\n\n/**\n * Class for converting & storing raw search results in the correct format for UI tiles.\n */\nexport class TileModel {\n /** For TV hits. List of identifiers for any commercials contained. */\n adIds?: string[];\n\n averageRating?: number;\n\n /** For Web Archive hits on profile pages. List of capture dates for the current URL. */\n captureDates?: Date[];\n\n /** Whether this tile is currently checked for item management functions */\n checked: boolean;\n\n collectionIdentifier?: string;\n\n collectionName?: string;\n\n collectionFilesCount: number;\n\n collections: string[];\n\n collectionSize: number;\n\n commentCount: number;\n\n creator?: string;\n\n creators: string[];\n\n /** A string representation of the publication date, used strictly for passing preformatted dates to the parent */\n dateStr?: string;\n\n /** Date added to public search (software-defined) [from MD field: addeddate] */\n dateAdded?: Date;\n\n /** Date archived (software-defined) item created on archive.org [from MD field: publicdate] */\n dateArchived?: Date;\n\n /** Date work published in the world (user-defined) [from MD field: date] */\n datePublished?: Date;\n\n /** Date reviewed (user-created) most recent review [from MD field: reviewdate] */\n dateReviewed?: Date;\n\n description?: string;\n\n /** For TV hits. List of URLs for any fact-checks of the contained clips. */\n factChecks?: string[];\n\n favCount: number;\n\n hitRequestSource: HitRequestSource;\n\n hitType?: HitType;\n\n href?: string;\n\n identifier?: string;\n\n /** Whether this model represents a TV clip */\n isClip?: boolean;\n\n issue?: string;\n\n itemCount: number;\n\n mediatype: MediaType;\n\n review?: SearchReview;\n\n source?: string;\n\n snippets?: string[];\n\n subjects: string[];\n\n thumbnailUrl?: string;\n\n title: string;\n\n tvClipCount?: number;\n\n viewCount?: number;\n\n volume?: string;\n\n weeklyViewCount?: number;\n\n loginRequired: boolean;\n\n contentWarning: boolean;\n\n constructor(\n result: SearchResult,\n hitRequestSource: HitRequestSource = 'unknown',\n ) {\n const flags = this.getFlags(result);\n\n this.adIds = result.ad_id?.values;\n this.averageRating = result.avg_rating?.value;\n this.captureDates = result.capture_dates?.values;\n this.checked = false;\n this.collections = result.collection?.values ?? [];\n this.collectionFilesCount = result.collection_files_count?.value ?? 0;\n this.collectionSize = result.collection_size?.value ?? 0;\n this.commentCount = result.num_reviews?.value ?? 0;\n this.creator = result.creator?.value;\n this.creators = result.creator?.values ?? [];\n this.dateAdded = result.addeddate?.value;\n this.dateArchived = result.publicdate?.value;\n this.datePublished = result.date?.value;\n this.dateReviewed = result.reviewdate?.value;\n this.description = result.description?.values.join('\\n');\n this.factChecks = result.factcheck?.values;\n this.favCount = result.num_favorites?.value ?? 0;\n this.hitRequestSource = hitRequestSource;\n this.hitType = result.rawMetadata?.hit_type;\n this.href = collapseRepeatedQuotes(\n result.review?.__href__ ?? result.__href__?.value,\n );\n this.identifier = TileModel.cleanIdentifier(result.identifier);\n this.isClip = result.is_clip?.value;\n this.issue = result.issue?.value;\n this.itemCount = result.item_count?.value ?? 0;\n this.mediatype = resolveMediatype(result);\n this.review = result.review;\n this.snippets = result.highlight?.values ?? [];\n this.source = result.source?.value;\n this.subjects = result.subject?.values ?? [];\n this.thumbnailUrl = result.__img__?.value;\n this.title = result.title?.value ?? '';\n this.tvClipCount = result.num_clips?.value ?? 0;\n this.volume = result.volume?.value;\n this.viewCount = result.downloads?.value;\n this.weeklyViewCount = result.week?.value;\n this.loginRequired = flags.loginRequired;\n this.contentWarning = flags.contentWarning;\n }\n\n /**\n * Copies the contents of this TileModel onto a new instance\n */\n clone(): TileModel {\n const cloned = new TileModel({});\n cloned.adIds = this.adIds;\n cloned.averageRating = this.averageRating;\n cloned.captureDates = this.captureDates;\n cloned.checked = this.checked;\n cloned.collections = this.collections;\n cloned.collectionFilesCount = this.collectionFilesCount;\n cloned.collectionSize = this.collectionSize;\n cloned.commentCount = this.commentCount;\n cloned.creator = this.creator;\n cloned.creators = this.creators;\n cloned.dateStr = this.dateStr;\n cloned.dateAdded = this.dateAdded;\n cloned.dateArchived = this.dateArchived;\n cloned.datePublished = this.datePublished;\n cloned.dateReviewed = this.dateReviewed;\n cloned.description = this.description;\n cloned.factChecks = this.factChecks;\n cloned.favCount = this.favCount;\n cloned.hitRequestSource = this.hitRequestSource;\n cloned.hitType = this.hitType;\n cloned.href = this.href;\n cloned.identifier = this.identifier;\n cloned.isClip = this.isClip;\n cloned.issue = this.issue;\n cloned.itemCount = this.itemCount;\n cloned.mediatype = this.mediatype;\n cloned.snippets = this.snippets;\n cloned.source = this.source;\n cloned.subjects = this.subjects;\n cloned.thumbnailUrl = this.thumbnailUrl;\n cloned.title = this.title;\n cloned.tvClipCount = this.tvClipCount;\n cloned.volume = this.volume;\n cloned.viewCount = this.viewCount;\n cloned.weeklyViewCount = this.weeklyViewCount;\n cloned.loginRequired = this.loginRequired;\n cloned.contentWarning = this.contentWarning;\n return cloned;\n }\n\n /**\n * Whether this model represents the result of a TV search query.\n */\n get isTvSearchResult(): boolean {\n return (\n this.hitType === 'tv_clip' && this.hitRequestSource === 'search_query'\n );\n }\n\n /**\n * Determines the appropriate tile flags for the given search result\n * (login required and/or content warning)\n */\n private getFlags(result: SearchResult): TileFlags {\n const flags: TileFlags = {\n loginRequired: false,\n contentWarning: false,\n };\n\n // Check if item and item in \"modifying\" collection, setting above flags\n if (\n result.collection?.values.length &&\n result.mediatype?.value !== 'collection'\n ) {\n for (const collection of result.collection?.values ?? []) {\n if (collection === 'loggedin') {\n flags.loginRequired = true;\n if (flags.contentWarning) break;\n }\n if (collection === 'no-preview') {\n flags.contentWarning = true;\n if (flags.loginRequired) break;\n }\n }\n }\n\n return flags;\n }\n\n private static cleanIdentifier(\n identifier: string | undefined,\n ): string | undefined {\n // Some identifiers (e.g., from Whisper) represent documents rather than items, and\n // are suffixed with values that need to be stripped. Those values are separated\n // from the item identifier itself with '|'.\n const barIndex = identifier?.indexOf('|') ?? -1;\n const cleaned = barIndex > 0 ? identifier?.slice(0, barIndex) : identifier;\n return cleaned;\n }\n}\n\nexport type RequestKind = 'full' | 'hits' | 'aggregations';\n\nexport type CollectionDisplayMode = 'grid' | 'list-compact' | 'list-detail';\n\nexport type TileDisplayMode =\n | 'grid'\n | 'list-compact'\n | 'list-detail'\n | 'list-header';\n\n/**\n * This is mainly used to set the cookies for the collection display mode.\n *\n * It allows the user to set different modes for different contexts (collection page, search page, profile page etc).\n */\nexport type CollectionBrowserContext = 'collection' | 'search' | 'profile';\n\n/**\n * The sort fields shown in the sort filter bar\n */\nexport enum SortField {\n 'default' = 'default',\n 'unrecognized' = 'unrecognized',\n 'relevance' = 'relevance',\n 'alltimeview' = 'alltimeview',\n 'weeklyview' = 'weeklyview',\n 'title' = 'title',\n 'date' = 'date',\n 'datearchived' = 'datearchived',\n 'datereviewed' = 'datereviewed',\n 'dateadded' = 'dateadded',\n 'datefavorited' = 'datefavorited',\n 'creator' = 'creator',\n}\n\n/**\n * Views-related sort fields\n */\nexport const ALL_VIEWS_SORT_FIELDS = [\n SortField.weeklyview,\n SortField.alltimeview,\n] as const;\nexport type ViewsSortField = (typeof ALL_VIEWS_SORT_FIELDS)[number];\n\n/**\n * Date-related sort fields\n */\nexport const ALL_DATE_SORT_FIELDS = [\n SortField.datefavorited,\n SortField.date,\n SortField.datearchived,\n SortField.datereviewed,\n SortField.dateadded,\n] as const;\nexport type DateSortField = (typeof ALL_DATE_SORT_FIELDS)[number];\n\nexport interface SortOption {\n /**\n * The SortField enum member corresponding to this option.\n */\n field: SortField;\n\n /**\n * The default sort direction to apply when this sort option is first selected.\n */\n defaultSortDirection: SortDirection | null;\n\n /**\n * Whether this sort option allows its sort direction to be changed from the default.\n */\n canSetDirection: boolean;\n\n /**\n * Whether this sort option may appear in the sort bar.\n */\n shownInSortBar: boolean;\n\n /**\n * Whether this sort option should be saved to the URL.\n * If false, then no `sort` param will be added to the URL when this sort option\n * is selected.\n */\n shownInURL: boolean;\n\n /**\n * Whether this sort option is passed to the search service.\n * If false, then no sort param will be passed to the search service at all when\n * this sort option is selected.\n */\n handledBySearchService: boolean;\n\n /**\n * The string identifying this sort field to the search service & backend API.\n */\n searchServiceKey?: string;\n\n /**\n * The human-readable name to use for this option in the sort bar (if applicable).\n */\n displayName: string;\n\n /**\n * A list of URL param keys that should be mapped to this sort option.\n * E.g., both `title` and `titleSorter` in the URL map to the `SortField.title` option.\n */\n urlNames: (string | null | undefined)[];\n}\n\nexport const SORT_OPTIONS: Record<SortField, SortOption> = {\n // Default sort is the case where the user has not specified a sort option via the sort bar or URL.\n // In these cases, we defer to whatever sort the backend chooses.\n // For the search page, the default is always relevance sort.\n // For collection pages _without a query_, the default is usually weekly views, but this can be\n // overridden by the collection's `sort-by` metadata entry. If a query _is_ specified, then the\n // default is again relevance sort.\n // For fav-* collections only, the default is instead sorting by date favorited.\n [SortField.default]: {\n field: SortField.default,\n defaultSortDirection: null,\n canSetDirection: false,\n shownInSortBar: false,\n shownInURL: false,\n handledBySearchService: false, // We rely on the PPS default sort handling in these cases\n displayName: '',\n urlNames: ['', null, undefined], // Empty or nullish sort params result in default sorting\n },\n // Unrecognized sort is the case where the user has specified a sort in the URL, but it is not\n // one of the options listed in this map. We still want these unrecognized sorts to be applied\n // when searching, but they are not displayed in the sort bar and we do not actively manage\n // their URL param beyond flipping the direction as needed.\n [SortField.unrecognized]: {\n field: SortField.unrecognized,\n defaultSortDirection: null,\n canSetDirection: true,\n shownInSortBar: false,\n shownInURL: false,\n handledBySearchService: true, // The unrecognized sort param is passed along as-is\n displayName: '',\n urlNames: [],\n },\n // Relevance sort is unique in that it does not produce a URL param when it is set.\n // It is only available when there is a user-specified query that relevancy can be scored against.\n // Therefore, it does not appear as a sort bar option when browsing a collection with no query set.\n [SortField.relevance]: {\n field: SortField.relevance,\n defaultSortDirection: null,\n canSetDirection: false,\n shownInSortBar: true,\n shownInURL: false,\n handledBySearchService: false,\n get displayName() {\n return msg('Relevance');\n },\n urlNames: ['_score'],\n },\n [SortField.alltimeview]: {\n field: SortField.alltimeview,\n defaultSortDirection: 'desc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'downloads',\n get displayName() {\n return msg('All-time views');\n },\n urlNames: ['downloads'],\n },\n [SortField.weeklyview]: {\n field: SortField.weeklyview,\n defaultSortDirection: 'desc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'week',\n get displayName() {\n return msg('Weekly views');\n },\n urlNames: ['week'],\n },\n [SortField.title]: {\n field: SortField.title,\n defaultSortDirection: 'asc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'titleSorter',\n get displayName() {\n return msg('Title');\n },\n urlNames: ['title', 'titleSorter'],\n },\n [SortField.date]: {\n field: SortField.date,\n defaultSortDirection: 'desc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'date',\n get displayName() {\n return msg('Date published');\n },\n urlNames: ['date'],\n },\n [SortField.datearchived]: {\n field: SortField.datearchived,\n defaultSortDirection: 'desc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'publicdate',\n get displayName() {\n return msg('Date archived');\n },\n urlNames: ['publicdate'],\n },\n [SortField.datereviewed]: {\n field: SortField.datereviewed,\n defaultSortDirection: 'desc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'reviewdate',\n get displayName() {\n return msg('Date reviewed');\n },\n urlNames: ['reviewdate'],\n },\n [SortField.dateadded]: {\n field: SortField.dateadded,\n defaultSortDirection: 'desc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'addeddate',\n get displayName() {\n return msg('Date added');\n },\n urlNames: ['addeddate'],\n },\n [SortField.datefavorited]: {\n field: SortField.datefavorited,\n defaultSortDirection: 'desc',\n canSetDirection: false,\n shownInSortBar: true, // But only when viewing fav-* collections\n shownInURL: false,\n handledBySearchService: false,\n searchServiceKey: 'favoritedate',\n get displayName() {\n return msg('Date favorited');\n },\n urlNames: ['favoritedate'],\n },\n [SortField.creator]: {\n field: SortField.creator,\n defaultSortDirection: 'asc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'creatorSorter',\n get displayName() {\n return msg('Creator');\n },\n urlNames: ['creator', 'creatorSorter'],\n },\n};\n\n/**\n * Returns the SortOption corresponding to the given API sort name, or\n * the \"unrecognized\" SortOption if none matches.\n */\nexport function sortOptionFromAPIString(sortName?: string | null): SortOption {\n return (\n Object.values(SORT_OPTIONS).find(opt =>\n opt.urlNames.some(name => sortName === name),\n ) ?? SORT_OPTIONS[SortField.unrecognized]\n );\n}\n\nexport const defaultSortAvailability: Record<SortField, boolean> = {\n [SortField.relevance]: true,\n [SortField.weeklyview]: true,\n [SortField.alltimeview]: true,\n [SortField.title]: true,\n [SortField.datefavorited]: false,\n [SortField.date]: true,\n [SortField.datearchived]: true,\n [SortField.datereviewed]: true,\n [SortField.dateadded]: true,\n [SortField.creator]: true,\n [SortField.default]: false,\n [SortField.unrecognized]: false,\n};\n\nexport const favoritesSortAvailability: Record<SortField, boolean> = {\n ...defaultSortAvailability,\n [SortField.datefavorited]: true,\n};\n\nexport const tvSortAvailability: Record<SortField, boolean> = {\n ...defaultSortAvailability,\n [SortField.date]: false,\n [SortField.datereviewed]: false,\n [SortField.dateadded]: false,\n};\n\nexport const defaultProfileElementSorts: Record<\n string,\n Exclude<SortField, SortField.default>\n> = {\n uploads: SortField.datearchived,\n reviews: SortField.datereviewed,\n collections: SortField.datearchived,\n web_archives: SortField.datearchived,\n favorites: SortField.datefavorited,\n};\n\n/** A union of the fields that permit prefix filtering (e.g., alphabetical filtering) */\nexport type PrefixFilterType = 'title' | 'creator';\n\n/** A map from prefixes (e.g., initial letters) to the number of items matching that prefix */\nexport type PrefixFilterCounts = Record<string, number>;\n\n/**\n * A map from prefix filter types to the corresponding aggregation keys\n * that are needed to fetch the filter counts from the backend.\n */\nexport const prefixFilterAggregationKeys: Record<PrefixFilterType, string> = {\n title: 'firstTitle',\n creator: 'firstCreator',\n};\n\n/**\n * Different facet loading strategies that can be used with collection browser.\n * - `eager`: Facet data is always loaded as soon as a search is performed\n * - `lazy-mobile`: In the desktop layout, functions exactly as `eager`.\n * In the mobile layout, facet data will only be loaded once the \"Filters\" accordion is opened.\n * - `opt-in-or-login`: Same as `opt-in` for guest users not logged into an account, but same as `eager` for\n * any logged in user.\n * - `opt-in`: In the desktop layout, facet data will only be loaded after the user presses a \"Load Facets\" button.\n * In the mobile layout, functions exactly as `lazy-mobile`.\n * - `off`: Facet data will never be loaded, and a message will be displayed in place of facets\n * indicating that they are unavailable.\n */\nexport type FacetLoadStrategy =\n | 'eager'\n | 'lazy-mobile'\n | 'opt-in-or-login'\n | 'opt-in'\n | 'off';\n\n/**\n * Union of the facet types that are available in the sidebar.\n */\nexport type FacetOption =\n | 'subject'\n | 'lending'\n | 'mediatype'\n | 'language'\n | 'creator'\n | 'collection'\n | 'year'\n // TV-specific facet options:\n | 'clip_type'\n | 'program'\n | 'person'\n | 'sponsor';\n\nexport type SelectedFacetState = 'selected' | 'hidden';\n\nexport type FacetState = SelectedFacetState | 'none';\n\nexport interface FacetBucket {\n key: string;\n count: number;\n state: FacetState;\n // for some facets, we augment the key with a display value\n displayText?: string;\n // for TV channel facets, we add a parenthesized secondary name\n extraNote?: string;\n}\n\nexport interface FacetGroup {\n title: string;\n key: FacetOption;\n buckets: FacetBucket[];\n}\n\n/**\n * Information about a user interaction event on a facet.\n */\nexport type FacetEventDetails = {\n /**\n * The type of facet that was interacted with (e.g., 'mediatype', 'language', ...).\n */\n facetType: FacetOption;\n /**\n * The bucket corresponding to the facet that was interacted with, including the\n * updated state of the facet after the interaction.\n */\n bucket: FacetBucket;\n /**\n * Whether the interaction occurred on a negative facet.\n */\n negative: boolean;\n};\n\nexport type FacetValue = string;\n\nexport type SelectedFacets = Partial<\n Record<FacetOption, Record<FacetValue, FacetBucket>>\n>;\n\nexport const getDefaultSelectedFacets = (): Required<SelectedFacets> => ({\n subject: {},\n lending: {},\n mediatype: {},\n language: {},\n creator: {},\n collection: {},\n year: {},\n clip_type: {},\n program: {},\n person: {},\n sponsor: {},\n});\n\n/**\n * For TV search results, what types of TV clips to restrict the results to.\n */\nexport type TvClipFilterType = 'commercial' | 'fact check' | 'quote';\n\n/**\n * Map from allowed TV filtering parameters in the URL to their corresponding filter type\n */\nexport const tvClipURLParamsToFilters: Record<string, TvClipFilterType> = {\n only_commercials: 'commercial',\n only_factchecks: 'fact check',\n only_quotes: 'quote',\n};\n\n/**\n * Facet display order when presenting results for all search types *except* TV (see below).\n */\nexport const defaultFacetDisplayOrder: FacetOption[] = [\n 'mediatype',\n // 'lending', Commenting this out removes the lending facet from the sidebar for now\n 'year',\n 'subject',\n 'collection',\n 'creator',\n 'language',\n];\n\n/**\n * Specialized facet ordering when displaying TV search results\n */\nexport const tvFacetDisplayOrder: FacetOption[] = [\n 'program',\n 'creator',\n 'year',\n 'subject',\n // 'person', Omitting the Person facet group for now, though it may be re-added later with new semantics\n 'language',\n 'clip_type',\n];\n\n/**\n * Human-readable titles for each facet group.\n */\nexport const facetTitles: Record<FacetOption, string> = {\n get subject() {\n return msg('Subject');\n },\n get lending() {\n return msg('Availability');\n },\n get mediatype() {\n return msg('Media Type');\n },\n get language() {\n return msg('Language');\n },\n get creator() {\n return msg('Creator');\n },\n get collection() {\n return msg('Collection');\n },\n get year() {\n return msg('Year');\n },\n get clip_type() {\n return msg('Clip Type');\n },\n get program() {\n return msg('Program');\n },\n get person() {\n return msg('Person');\n },\n get sponsor() {\n return msg('Sponsor');\n },\n};\n\n/**\n * Human-readable plural titles for each facet group, for referring to its values.\n */\nexport const facetPluralTitles: Record<FacetOption, string> = {\n get subject() {\n return msg('Subjects');\n },\n get lending() {\n return msg('Availability');\n },\n get mediatype() {\n return msg('Media Types');\n },\n get language() {\n return msg('Languages');\n },\n get creator() {\n return msg('Creators');\n },\n get collection() {\n return msg('Collections');\n },\n get year() {\n return msg('Years');\n },\n get clip_type() {\n return msg('Clip Types');\n },\n get program() {\n return msg('Programs');\n },\n get person() {\n return msg('People');\n },\n get sponsor() {\n return msg('Sponsors');\n },\n};\n\n/**\n * The default sort type to use for each facet type\n */\nexport const defaultFacetSort: Record<FacetOption, AggregationSortType> = {\n subject: AggregationSortType.COUNT,\n lending: AggregationSortType.COUNT,\n mediatype: AggregationSortType.COUNT,\n language: AggregationSortType.COUNT,\n creator: AggregationSortType.COUNT,\n collection: AggregationSortType.COUNT,\n year: AggregationSortType.NUMERIC, // Year facets are ordered by their numeric value by default\n clip_type: AggregationSortType.COUNT,\n program: AggregationSortType.COUNT,\n person: AggregationSortType.COUNT,\n sponsor: AggregationSortType.COUNT,\n};\n\n/**\n * The default sort type to use for each facet type in TV search More... dialogs only\n */\nexport const tvMoreFacetSort: Record<FacetOption, AggregationSortType> = {\n ...defaultFacetSort,\n creator: AggregationSortType.ALPHABETICAL,\n program: AggregationSortType.ALPHABETICAL,\n};\n\n/**\n * The sort type corresponding to facet bucket values, for each facet type\n * (i.e., the opposite of \"sort by count\" for that type).\n */\nexport const valueFacetSort: Record<FacetOption, AggregationSortType> = {\n subject: AggregationSortType.ALPHABETICAL,\n lending: AggregationSortType.ALPHABETICAL,\n mediatype: AggregationSortType.ALPHABETICAL,\n language: AggregationSortType.ALPHABETICAL,\n creator: AggregationSortType.ALPHABETICAL,\n collection: AggregationSortType.ALPHABETICAL,\n year: AggregationSortType.NUMERIC, // Year facets' values should be compared numerically, not lexicographically (year 2001 > year 3)\n clip_type: AggregationSortType.ALPHABETICAL,\n program: AggregationSortType.ALPHABETICAL,\n person: AggregationSortType.ALPHABETICAL,\n sponsor: AggregationSortType.ALPHABETICAL,\n};\n\nexport type LendingFacetKey =\n | 'is_lendable'\n | 'is_borrowable'\n | 'available_to_borrow'\n | 'is_browsable'\n | 'available_to_browse'\n | 'is_readable'\n | 'available_to_waitlist';\n\n/**\n * Maps valid lending keys to whether they should be visible in the facet sidebar\n */\nexport const lendingFacetKeysVisibility: Record<LendingFacetKey, boolean> = {\n is_lendable: true,\n is_borrowable: false,\n available_to_borrow: true,\n is_browsable: false,\n available_to_browse: false,\n is_readable: true,\n available_to_waitlist: false,\n};\n\n/**\n * Most facet options allow any string as keys, while some others can only take on a\n * limited set of strings. This type just defines those restrictions for the specific\n * facet types where they apply.\n */\nexport type AllowedFacetKey<T extends FacetOption> = T extends 'lending'\n ? LendingFacetKey\n : T extends 'clip_type'\n ? TvClipFilterType\n : string;\n\n/**\n * A type mapping FacetOptions to objects that define custom display names for some\n * or all of their valid keys.\n */\nexport type FacetDisplayNameMap = {\n [K in FacetOption]?: Partial<Record<AllowedFacetKey<K>, string>>;\n};\n\nexport const customFacetDisplayNames: FacetDisplayNameMap = {\n lending: {\n get is_lendable() {\n return msg('Lending Library');\n },\n get available_to_borrow() {\n return msg('Borrow 14 Days');\n },\n get is_readable() {\n return msg('Always Available');\n },\n },\n clip_type: {\n get quote() {\n return msg('Quote');\n },\n get commercial() {\n return msg('Political Ad');\n },\n get 'fact check'() {\n return msg('Fact Check');\n },\n },\n};\n\n/**\n * A record of which admin-only collections should be suppressed from being displayed\n * as facets or in an item's list of collections.\n */\nexport const suppressedCollections: Record<string, boolean> = {\n deemphasize: true,\n community: true,\n stream_only: true,\n samples_only: true,\n test_collection: true,\n printdisabled: true,\n 'openlibrary-ol': true,\n nationalemergencylibrary: true,\n china: true,\n americana: true,\n toronto: true,\n};\n\n/**\n * A record of manageable item\n */\nexport interface ManageableItem {\n identifier: string;\n title?: string;\n dateStr?: string;\n date?: string;\n}\n\n/**\n * Possible states for whether & how the user has overridden their user preference\n * for blurring behavior on tiles with sensitive content.\n * - `no-override`: The user has not overridden their user preference, so simply\n * respect the preference as given.\n * - `on`: The user has overridden their preference and wants tile blurring enabled.\n * - `off`: The user has overridden their preference and wants tile blurring disabled.\n */\nexport type TileBlurOverrideState = 'no-override' | 'on' | 'off';\n"]}
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC,OAAO,EACL,mBAAmB,GAKpB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AACtE,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAe/D,MAAM,CAAC,MAAM,iBAAiB,GAAoC;IAChE,gBAAgB,EAAE,GAAG,CAAC,0BAA0B,CAAC;IACjD,iBAAiB,EAAE,GAAG,CAAC,8BAA8B,CAAC;CACvD,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAA4C;IACzE,gBAAgB,EAAE,iBAAiB;IACnC,iBAAiB,EAAE,cAAc;CAClC,CAAC;AAeF;;GAEG;AACH,MAAM,OAAO,SAAS;IA2FpB,YACE,MAAoB,EACpB,mBAAqC,SAAS;QAE9C,MAAM,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAEpC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC;QAClC,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC,UAAU,EAAE,KAA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E,KAAK;IAC1B,WAAW,EAAE,IAAI;IACjB,qBAAqB,EAAE,KAAK;CAC7B,CAAC;AAqBF,MAAM,CAAC,MAAM,uBAAuB,GAAwB;IAC1D,OAAO,EAAE;QACP,WAAW,EAAE,iBAAiB;QAC9B,mBAAmB,EAAE,gBAAgB;QACrC,WAAW,EAAE,kBAAkB;KAChC;IACD,SAAS,EAAE;QACT,KAAK,EAAE,OAAO;QACd,UAAU,EAAE,cAAc;QAC1B,YAAY,EAAE,YAAY;KAC3B;CACF,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAA4B;IAC5D,WAAW,EAAE,IAAI;IACjB,SAAS,EAAE,IAAI;IACf,WAAW,EAAE,IAAI;IACjB,YAAY,EAAE,IAAI;IAClB,eAAe,EAAE,IAAI;IACrB,aAAa,EAAE,IAAI;IACnB,gBAAgB,EAAE,IAAI;IACtB,wBAAwB,EAAE,IAAI;IAC9B,KAAK,EAAE,IAAI;IACX,SAAS,EAAE,IAAI;IACf,OAAO,EAAE,IAAI;CACd,CAAC","sourcesContent":["import type { TemplateResult } from 'lit';\nimport { msg } from '@lit/localize';\nimport type { MediaType } from '@internetarchive/field-parsers';\nimport {\n AggregationSortType,\n HitType,\n SearchReview,\n SearchResult,\n SortDirection,\n} from '@internetarchive/search-service';\nimport { collapseRepeatedQuotes } from './utils/collapse-repeated-quotes';\nimport { resolveMediatype } from './utils/resolve-mediatype';\n\nimport { loginRequiredIcon } from './assets/img/icons/login-required';\nimport { restrictedIcon } from './assets/img/icons/restricted';\n\n/**\n * Flags that can affect the visibility of content on a tile\n */\ninterface TileFlags {\n loginRequired: boolean;\n contentWarning: boolean;\n}\n\n/**\n * Different types of tile overlays, corresponding to the above flags.\n */\nexport type TileOverlayType = 'login-required' | 'content-warning';\n\nexport const TILE_OVERLAY_TEXT: Record<TileOverlayType, string> = {\n 'login-required': msg('Log in to view this item'),\n 'content-warning': msg('Content may be inappropriate'),\n};\n\nexport const TILE_OVERLAY_ICONS: Record<TileOverlayType, TemplateResult> = {\n 'login-required': loginRequiredIcon,\n 'content-warning': restrictedIcon,\n};\n\n/**\n * What type of request produced a given set of hits:\n * - `search_query`: Hits produced by an explicit user query and/or applied filters on any page\n * - `collection_members`: Hits produced for a collection page without any query or filters\n * - `profile_tab`: Hits produced for a tab of the profile page without any query or filters\n * - `unknown`: Hits produced via any other means\n */\nexport type HitRequestSource =\n | 'search_query'\n | 'collection_members'\n | 'profile_tab'\n | 'unknown';\n\n/**\n * Class for converting & storing raw search results in the correct format for UI tiles.\n */\nexport class TileModel {\n /** For TV hits. List of identifiers for any commercials contained. */\n adIds?: string[];\n\n averageRating?: number;\n\n /** For Web Archive hits on profile pages. List of capture dates for the current URL. */\n captureDates?: Date[];\n\n /** Whether this tile is currently checked for item management functions */\n checked: boolean;\n\n collectionIdentifier?: string;\n\n collectionName?: string;\n\n collectionFilesCount: number;\n\n collections: string[];\n\n collectionSize: number;\n\n commentCount: number;\n\n creator?: string;\n\n creators: string[];\n\n /** A string representation of the publication date, used strictly for passing preformatted dates to the parent */\n dateStr?: string;\n\n /** Date added to public search (software-defined) [from MD field: addeddate] */\n dateAdded?: Date;\n\n /** Date archived (software-defined) item created on archive.org [from MD field: publicdate] */\n dateArchived?: Date;\n\n /** Date work published in the world (user-defined) [from MD field: date] */\n datePublished?: Date;\n\n /** Date reviewed (user-created) most recent review [from MD field: reviewdate] */\n dateReviewed?: Date;\n\n description?: string;\n\n /** For TV hits. List of URLs for any fact-checks of the contained clips. */\n factChecks?: string[];\n\n favCount: number;\n\n hitRequestSource: HitRequestSource;\n\n hitType?: HitType;\n\n href?: string;\n\n identifier?: string;\n\n /** Whether this model represents a TV clip */\n isClip?: boolean;\n\n issue?: string;\n\n itemCount: number;\n\n mediatype: MediaType;\n\n review?: SearchReview;\n\n source?: string;\n\n snippets?: string[];\n\n subjects: string[];\n\n thumbnailUrl?: string;\n\n title: string;\n\n tvClipCount?: number;\n\n viewCount?: number;\n\n volume?: string;\n\n weeklyViewCount?: number;\n\n loginRequired: boolean;\n\n contentWarning: boolean;\n\n constructor(\n result: SearchResult,\n hitRequestSource: HitRequestSource = 'unknown',\n ) {\n const flags = this.getFlags(result);\n\n this.adIds = result.ad_id?.values;\n this.averageRating = result.avg_rating?.value;\n this.captureDates = result.capture_dates?.values;\n this.checked = false;\n this.collections = result.collection?.values ?? [];\n this.collectionFilesCount = result.collection_files_count?.value ?? 0;\n this.collectionSize = result.collection_size?.value ?? 0;\n this.commentCount = result.num_reviews?.value ?? 0;\n this.creator = result.creator?.value;\n this.creators = result.creator?.values ?? [];\n this.dateAdded = result.addeddate?.value;\n this.dateArchived = result.publicdate?.value;\n this.datePublished = result.date?.value;\n this.dateReviewed = result.reviewdate?.value;\n this.description = result.description?.values.join('\\n');\n this.factChecks = result.factcheck?.values;\n this.favCount = result.num_favorites?.value ?? 0;\n this.hitRequestSource = hitRequestSource;\n this.hitType = result.rawMetadata?.hit_type;\n this.href = collapseRepeatedQuotes(\n result.review?.__href__ ?? result.__href__?.value,\n );\n this.identifier = TileModel.cleanIdentifier(result.identifier);\n this.isClip = result.is_clip?.value;\n this.issue = result.issue?.value;\n this.itemCount = result.item_count?.value ?? 0;\n this.mediatype = resolveMediatype(result);\n this.review = result.review;\n this.snippets = result.highlight?.values ?? [];\n this.source = result.source?.value;\n this.subjects = result.subject?.values ?? [];\n this.thumbnailUrl = result.__img__?.value;\n this.title = result.title?.value ?? '';\n this.tvClipCount = result.num_clips?.value ?? 0;\n this.volume = result.volume?.value;\n this.viewCount = result.downloads?.value;\n this.weeklyViewCount = result.week?.value;\n this.loginRequired = flags.loginRequired;\n this.contentWarning = flags.contentWarning;\n }\n\n /**\n * Copies the contents of this TileModel onto a new instance\n */\n clone(): TileModel {\n const cloned = new TileModel({});\n cloned.adIds = this.adIds;\n cloned.averageRating = this.averageRating;\n cloned.captureDates = this.captureDates;\n cloned.checked = this.checked;\n cloned.collections = this.collections;\n cloned.collectionFilesCount = this.collectionFilesCount;\n cloned.collectionSize = this.collectionSize;\n cloned.commentCount = this.commentCount;\n cloned.creator = this.creator;\n cloned.creators = this.creators;\n cloned.dateStr = this.dateStr;\n cloned.dateAdded = this.dateAdded;\n cloned.dateArchived = this.dateArchived;\n cloned.datePublished = this.datePublished;\n cloned.dateReviewed = this.dateReviewed;\n cloned.description = this.description;\n cloned.factChecks = this.factChecks;\n cloned.favCount = this.favCount;\n cloned.hitRequestSource = this.hitRequestSource;\n cloned.hitType = this.hitType;\n cloned.href = this.href;\n cloned.identifier = this.identifier;\n cloned.isClip = this.isClip;\n cloned.issue = this.issue;\n cloned.itemCount = this.itemCount;\n cloned.mediatype = this.mediatype;\n cloned.snippets = this.snippets;\n cloned.source = this.source;\n cloned.subjects = this.subjects;\n cloned.thumbnailUrl = this.thumbnailUrl;\n cloned.title = this.title;\n cloned.tvClipCount = this.tvClipCount;\n cloned.volume = this.volume;\n cloned.viewCount = this.viewCount;\n cloned.weeklyViewCount = this.weeklyViewCount;\n cloned.loginRequired = this.loginRequired;\n cloned.contentWarning = this.contentWarning;\n return cloned;\n }\n\n /**\n * Whether this model represents the result of a TV search query.\n */\n get isTvSearchResult(): boolean {\n return (\n this.hitType === 'tv_clip' && this.hitRequestSource === 'search_query'\n );\n }\n\n /**\n * Determines the appropriate tile flags for the given search result\n * (login required and/or content warning)\n */\n private getFlags(result: SearchResult): TileFlags {\n const flags: TileFlags = {\n loginRequired: false,\n contentWarning: false,\n };\n\n // Check if item and item in \"modifying\" collection, setting above flags\n if (\n result.collection?.values.length &&\n result.mediatype?.value !== 'collection'\n ) {\n for (const collection of result.collection?.values ?? []) {\n if (collection === 'loggedin') {\n flags.loginRequired = true;\n if (flags.contentWarning) break;\n }\n if (collection === 'no-preview') {\n flags.contentWarning = true;\n if (flags.loginRequired) break;\n }\n }\n }\n\n return flags;\n }\n\n private static cleanIdentifier(\n identifier: string | undefined,\n ): string | undefined {\n // Some identifiers (e.g., from Whisper) represent documents rather than items, and\n // are suffixed with values that need to be stripped. Those values are separated\n // from the item identifier itself with '|'.\n const barIndex = identifier?.indexOf('|') ?? -1;\n const cleaned = barIndex > 0 ? identifier?.slice(0, barIndex) : identifier;\n return cleaned;\n }\n}\n\nexport type RequestKind = 'full' | 'hits' | 'aggregations';\n\nexport type CollectionDisplayMode = 'grid' | 'list-compact' | 'list-detail';\n\nexport type TileDisplayMode =\n | 'grid'\n | 'list-compact'\n | 'list-detail'\n | 'list-header';\n\n/**\n * This is mainly used to set the cookies for the collection display mode.\n *\n * It allows the user to set different modes for different contexts (collection page, search page, profile page etc).\n */\nexport type CollectionBrowserContext = 'collection' | 'search' | 'profile';\n\n/**\n * The sort fields shown in the sort filter bar\n */\nexport enum SortField {\n 'default' = 'default',\n 'unrecognized' = 'unrecognized',\n 'relevance' = 'relevance',\n 'alltimeview' = 'alltimeview',\n 'weeklyview' = 'weeklyview',\n 'title' = 'title',\n 'date' = 'date',\n 'datearchived' = 'datearchived',\n 'datereviewed' = 'datereviewed',\n 'dateadded' = 'dateadded',\n 'datefavorited' = 'datefavorited',\n 'creator' = 'creator',\n}\n\n/**\n * Views-related sort fields\n */\nexport const ALL_VIEWS_SORT_FIELDS = [\n SortField.weeklyview,\n SortField.alltimeview,\n] as const;\nexport type ViewsSortField = (typeof ALL_VIEWS_SORT_FIELDS)[number];\n\n/**\n * Date-related sort fields\n */\nexport const ALL_DATE_SORT_FIELDS = [\n SortField.datefavorited,\n SortField.date,\n SortField.datearchived,\n SortField.datereviewed,\n SortField.dateadded,\n] as const;\nexport type DateSortField = (typeof ALL_DATE_SORT_FIELDS)[number];\n\nexport interface SortOption {\n /**\n * The SortField enum member corresponding to this option.\n */\n field: SortField;\n\n /**\n * The default sort direction to apply when this sort option is first selected.\n */\n defaultSortDirection: SortDirection | null;\n\n /**\n * Whether this sort option allows its sort direction to be changed from the default.\n */\n canSetDirection: boolean;\n\n /**\n * Whether this sort option may appear in the sort bar.\n */\n shownInSortBar: boolean;\n\n /**\n * Whether this sort option should be saved to the URL.\n * If false, then no `sort` param will be added to the URL when this sort option\n * is selected.\n */\n shownInURL: boolean;\n\n /**\n * Whether this sort option is passed to the search service.\n * If false, then no sort param will be passed to the search service at all when\n * this sort option is selected.\n */\n handledBySearchService: boolean;\n\n /**\n * The string identifying this sort field to the search service & backend API.\n */\n searchServiceKey?: string;\n\n /**\n * The human-readable name to use for this option in the sort bar (if applicable).\n */\n displayName: string;\n\n /**\n * A list of URL param keys that should be mapped to this sort option.\n * E.g., both `title` and `titleSorter` in the URL map to the `SortField.title` option.\n */\n urlNames: (string | null | undefined)[];\n}\n\nexport const SORT_OPTIONS: Record<SortField, SortOption> = {\n // Default sort is the case where the user has not specified a sort option via the sort bar or URL.\n // In these cases, we defer to whatever sort the backend chooses.\n // For the search page, the default is always relevance sort.\n // For collection pages _without a query_, the default is usually weekly views, but this can be\n // overridden by the collection's `sort-by` metadata entry. If a query _is_ specified, then the\n // default is again relevance sort.\n // For fav-* collections only, the default is instead sorting by date favorited.\n [SortField.default]: {\n field: SortField.default,\n defaultSortDirection: null,\n canSetDirection: false,\n shownInSortBar: false,\n shownInURL: false,\n handledBySearchService: false, // We rely on the PPS default sort handling in these cases\n displayName: '',\n urlNames: ['', null, undefined], // Empty or nullish sort params result in default sorting\n },\n // Unrecognized sort is the case where the user has specified a sort in the URL, but it is not\n // one of the options listed in this map. We still want these unrecognized sorts to be applied\n // when searching, but they are not displayed in the sort bar and we do not actively manage\n // their URL param beyond flipping the direction as needed.\n [SortField.unrecognized]: {\n field: SortField.unrecognized,\n defaultSortDirection: null,\n canSetDirection: true,\n shownInSortBar: false,\n shownInURL: false,\n handledBySearchService: true, // The unrecognized sort param is passed along as-is\n displayName: '',\n urlNames: [],\n },\n // Relevance sort is unique in that it does not produce a URL param when it is set.\n // It is only available when there is a user-specified query that relevancy can be scored against.\n // Therefore, it does not appear as a sort bar option when browsing a collection with no query set.\n [SortField.relevance]: {\n field: SortField.relevance,\n defaultSortDirection: null,\n canSetDirection: false,\n shownInSortBar: true,\n shownInURL: false,\n handledBySearchService: false,\n displayName: 'Relevance',\n urlNames: ['_score'],\n },\n [SortField.alltimeview]: {\n field: SortField.alltimeview,\n defaultSortDirection: 'desc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'downloads',\n displayName: 'All-time views',\n urlNames: ['downloads'],\n },\n [SortField.weeklyview]: {\n field: SortField.weeklyview,\n defaultSortDirection: 'desc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'week',\n displayName: 'Weekly views',\n urlNames: ['week'],\n },\n [SortField.title]: {\n field: SortField.title,\n defaultSortDirection: 'asc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'titleSorter',\n displayName: 'Title',\n urlNames: ['title', 'titleSorter'],\n },\n [SortField.date]: {\n field: SortField.date,\n defaultSortDirection: 'desc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'date',\n displayName: 'Date published',\n urlNames: ['date'],\n },\n [SortField.datearchived]: {\n field: SortField.datearchived,\n defaultSortDirection: 'desc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'publicdate',\n displayName: 'Date archived',\n urlNames: ['publicdate'],\n },\n [SortField.datereviewed]: {\n field: SortField.datereviewed,\n defaultSortDirection: 'desc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'reviewdate',\n displayName: 'Date reviewed',\n urlNames: ['reviewdate'],\n },\n [SortField.dateadded]: {\n field: SortField.dateadded,\n defaultSortDirection: 'desc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'addeddate',\n displayName: 'Date added',\n urlNames: ['addeddate'],\n },\n [SortField.datefavorited]: {\n field: SortField.datefavorited,\n defaultSortDirection: 'desc',\n canSetDirection: false,\n shownInSortBar: true, // But only when viewing fav-* collections\n shownInURL: false,\n handledBySearchService: false,\n searchServiceKey: 'favoritedate',\n displayName: 'Date favorited',\n urlNames: ['favoritedate'],\n },\n [SortField.creator]: {\n field: SortField.creator,\n defaultSortDirection: 'asc',\n canSetDirection: true,\n shownInSortBar: true,\n shownInURL: true,\n handledBySearchService: true,\n searchServiceKey: 'creatorSorter',\n displayName: 'Creator',\n urlNames: ['creator', 'creatorSorter'],\n },\n};\n\n/**\n * Returns the SortOption corresponding to the given API sort name, or\n * the \"unrecognized\" SortOption if none matches.\n */\nexport function sortOptionFromAPIString(sortName?: string | null): SortOption {\n return (\n Object.values(SORT_OPTIONS).find(opt =>\n opt.urlNames.some(name => sortName === name),\n ) ?? SORT_OPTIONS[SortField.unrecognized]\n );\n}\n\nexport const defaultSortAvailability: Record<SortField, boolean> = {\n [SortField.relevance]: true,\n [SortField.weeklyview]: true,\n [SortField.alltimeview]: true,\n [SortField.title]: true,\n [SortField.datefavorited]: false,\n [SortField.date]: true,\n [SortField.datearchived]: true,\n [SortField.datereviewed]: true,\n [SortField.dateadded]: true,\n [SortField.creator]: true,\n [SortField.default]: false,\n [SortField.unrecognized]: false,\n};\n\nexport const favoritesSortAvailability: Record<SortField, boolean> = {\n ...defaultSortAvailability,\n [SortField.datefavorited]: true,\n};\n\nexport const tvSortAvailability: Record<SortField, boolean> = {\n ...defaultSortAvailability,\n [SortField.date]: false,\n [SortField.datereviewed]: false,\n [SortField.dateadded]: false,\n};\n\nexport const defaultProfileElementSorts: Record<\n string,\n Exclude<SortField, SortField.default>\n> = {\n uploads: SortField.datearchived,\n reviews: SortField.datereviewed,\n collections: SortField.datearchived,\n web_archives: SortField.datearchived,\n favorites: SortField.datefavorited,\n};\n\n/** A union of the fields that permit prefix filtering (e.g., alphabetical filtering) */\nexport type PrefixFilterType = 'title' | 'creator';\n\n/** A map from prefixes (e.g., initial letters) to the number of items matching that prefix */\nexport type PrefixFilterCounts = Record<string, number>;\n\n/**\n * A map from prefix filter types to the corresponding aggregation keys\n * that are needed to fetch the filter counts from the backend.\n */\nexport const prefixFilterAggregationKeys: Record<PrefixFilterType, string> = {\n title: 'firstTitle',\n creator: 'firstCreator',\n};\n\n/**\n * Different facet loading strategies that can be used with collection browser.\n * - `eager`: Facet data is always loaded as soon as a search is performed\n * - `lazy-mobile`: In the desktop layout, functions exactly as `eager`.\n * In the mobile layout, facet data will only be loaded once the \"Filters\" accordion is opened.\n * - `opt-in-or-login`: Same as `opt-in` for guest users not logged into an account, but same as `eager` for\n * any logged in user.\n * - `opt-in`: In the desktop layout, facet data will only be loaded after the user presses a \"Load Facets\" button.\n * In the mobile layout, functions exactly as `lazy-mobile`.\n * - `off`: Facet data will never be loaded, and a message will be displayed in place of facets\n * indicating that they are unavailable.\n */\nexport type FacetLoadStrategy =\n | 'eager'\n | 'lazy-mobile'\n | 'opt-in-or-login'\n | 'opt-in'\n | 'off';\n\n/**\n * Union of the facet types that are available in the sidebar.\n */\nexport type FacetOption =\n | 'subject'\n | 'lending'\n | 'mediatype'\n | 'language'\n | 'creator'\n | 'collection'\n | 'year'\n // TV-specific facet options:\n | 'clip_type'\n | 'program'\n | 'person'\n | 'sponsor';\n\nexport type SelectedFacetState = 'selected' | 'hidden';\n\nexport type FacetState = SelectedFacetState | 'none';\n\nexport interface FacetBucket {\n key: string;\n count: number;\n state: FacetState;\n // for some facets, we augment the key with a display value\n displayText?: string;\n // for TV channel facets, we add a parenthesized secondary name\n extraNote?: string;\n}\n\nexport interface FacetGroup {\n title: string;\n key: FacetOption;\n buckets: FacetBucket[];\n}\n\n/**\n * Information about a user interaction event on a facet.\n */\nexport type FacetEventDetails = {\n /**\n * The type of facet that was interacted with (e.g., 'mediatype', 'language', ...).\n */\n facetType: FacetOption;\n /**\n * The bucket corresponding to the facet that was interacted with, including the\n * updated state of the facet after the interaction.\n */\n bucket: FacetBucket;\n /**\n * Whether the interaction occurred on a negative facet.\n */\n negative: boolean;\n};\n\nexport type FacetValue = string;\n\nexport type SelectedFacets = Partial<\n Record<FacetOption, Record<FacetValue, FacetBucket>>\n>;\n\nexport const getDefaultSelectedFacets = (): Required<SelectedFacets> => ({\n subject: {},\n lending: {},\n mediatype: {},\n language: {},\n creator: {},\n collection: {},\n year: {},\n clip_type: {},\n program: {},\n person: {},\n sponsor: {},\n});\n\n/**\n * For TV search results, what types of TV clips to restrict the results to.\n */\nexport type TvClipFilterType = 'commercial' | 'fact check' | 'quote';\n\n/**\n * Map from allowed TV filtering parameters in the URL to their corresponding filter type\n */\nexport const tvClipURLParamsToFilters: Record<string, TvClipFilterType> = {\n only_commercials: 'commercial',\n only_factchecks: 'fact check',\n only_quotes: 'quote',\n};\n\n/**\n * Facet display order when presenting results for all search types *except* TV (see below).\n */\nexport const defaultFacetDisplayOrder: FacetOption[] = [\n 'mediatype',\n // 'lending', Commenting this out removes the lending facet from the sidebar for now\n 'year',\n 'subject',\n 'collection',\n 'creator',\n 'language',\n];\n\n/**\n * Specialized facet ordering when displaying TV search results\n */\nexport const tvFacetDisplayOrder: FacetOption[] = [\n 'program',\n 'creator',\n 'year',\n 'subject',\n // 'person', Omitting the Person facet group for now, though it may be re-added later with new semantics\n 'language',\n 'clip_type',\n];\n\n/**\n * Human-readable titles for each facet group.\n */\nexport const facetTitles: Record<FacetOption, string> = {\n subject: 'Subject',\n lending: 'Availability',\n mediatype: 'Media Type',\n language: 'Language',\n creator: 'Creator',\n collection: 'Collection',\n year: 'Year',\n clip_type: 'Clip Type',\n program: 'Program',\n person: 'Person',\n sponsor: 'Sponsor',\n};\n\n/**\n * Human-readable plural titles for each facet group, for referring to its values.\n */\nexport const facetPluralTitles: Record<FacetOption, string> = {\n subject: 'Subjects',\n lending: 'Availability',\n mediatype: 'Media Types',\n language: 'Languages',\n creator: 'Creators',\n collection: 'Collections',\n year: 'Years',\n clip_type: 'Clip Types',\n program: 'Programs',\n person: 'People',\n sponsor: 'Sponsors',\n};\n\n/**\n * The default sort type to use for each facet type\n */\nexport const defaultFacetSort: Record<FacetOption, AggregationSortType> = {\n subject: AggregationSortType.COUNT,\n lending: AggregationSortType.COUNT,\n mediatype: AggregationSortType.COUNT,\n language: AggregationSortType.COUNT,\n creator: AggregationSortType.COUNT,\n collection: AggregationSortType.COUNT,\n year: AggregationSortType.NUMERIC, // Year facets are ordered by their numeric value by default\n clip_type: AggregationSortType.COUNT,\n program: AggregationSortType.COUNT,\n person: AggregationSortType.COUNT,\n sponsor: AggregationSortType.COUNT,\n};\n\n/**\n * The default sort type to use for each facet type in TV search More... dialogs only\n */\nexport const tvMoreFacetSort: Record<FacetOption, AggregationSortType> = {\n ...defaultFacetSort,\n creator: AggregationSortType.ALPHABETICAL,\n program: AggregationSortType.ALPHABETICAL,\n};\n\n/**\n * The sort type corresponding to facet bucket values, for each facet type\n * (i.e., the opposite of \"sort by count\" for that type).\n */\nexport const valueFacetSort: Record<FacetOption, AggregationSortType> = {\n subject: AggregationSortType.ALPHABETICAL,\n lending: AggregationSortType.ALPHABETICAL,\n mediatype: AggregationSortType.ALPHABETICAL,\n language: AggregationSortType.ALPHABETICAL,\n creator: AggregationSortType.ALPHABETICAL,\n collection: AggregationSortType.ALPHABETICAL,\n year: AggregationSortType.NUMERIC, // Year facets' values should be compared numerically, not lexicographically (year 2001 > year 3)\n clip_type: AggregationSortType.ALPHABETICAL,\n program: AggregationSortType.ALPHABETICAL,\n person: AggregationSortType.ALPHABETICAL,\n sponsor: AggregationSortType.ALPHABETICAL,\n};\n\nexport type LendingFacetKey =\n | 'is_lendable'\n | 'is_borrowable'\n | 'available_to_borrow'\n | 'is_browsable'\n | 'available_to_browse'\n | 'is_readable'\n | 'available_to_waitlist';\n\n/**\n * Maps valid lending keys to whether they should be visible in the facet sidebar\n */\nexport const lendingFacetKeysVisibility: Record<LendingFacetKey, boolean> = {\n is_lendable: true,\n is_borrowable: false,\n available_to_borrow: true,\n is_browsable: false,\n available_to_browse: false,\n is_readable: true,\n available_to_waitlist: false,\n};\n\n/**\n * Most facet options allow any string as keys, while some others can only take on a\n * limited set of strings. This type just defines those restrictions for the specific\n * facet types where they apply.\n */\nexport type AllowedFacetKey<T extends FacetOption> = T extends 'lending'\n ? LendingFacetKey\n : T extends 'clip_type'\n ? TvClipFilterType\n : string;\n\n/**\n * A type mapping FacetOptions to objects that define custom display names for some\n * or all of their valid keys.\n */\nexport type FacetDisplayNameMap = {\n [K in FacetOption]?: Partial<Record<AllowedFacetKey<K>, string>>;\n};\n\nexport const customFacetDisplayNames: FacetDisplayNameMap = {\n lending: {\n is_lendable: 'Lending Library',\n available_to_borrow: 'Borrow 14 Days',\n is_readable: 'Always Available',\n },\n clip_type: {\n quote: 'Quote',\n commercial: 'Political Ad',\n 'fact check': 'Fact Check',\n },\n};\n\n/**\n * A record of which admin-only collections should be suppressed from being displayed\n * as facets or in an item's list of collections.\n */\nexport const suppressedCollections: Record<string, boolean> = {\n deemphasize: true,\n community: true,\n stream_only: true,\n samples_only: true,\n test_collection: true,\n printdisabled: true,\n 'openlibrary-ol': true,\n nationalemergencylibrary: true,\n china: true,\n americana: true,\n toronto: true,\n};\n\n/**\n * A record of manageable item\n */\nexport interface ManageableItem {\n identifier: string;\n title?: string;\n dateStr?: string;\n date?: string;\n}\n\n/**\n * Possible states for whether & how the user has overridden their user preference\n * for blurring behavior on tiles with sensitive content.\n * - `no-override`: The user has not overridden their user preference, so simply\n * respect the preference as given.\n * - `on`: The user has overridden their preference and wants tile blurring enabled.\n * - `off`: The user has overridden their preference and wants tile blurring disabled.\n */\nexport type TileBlurOverrideState = 'no-override' | 'on' | 'off';\n"]}
|
|
@@ -1,22 +1,17 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { LitElement, html, css } from 'lit';
|
|
3
3
|
import { customElement, property } from 'lit/decorators.js';
|
|
4
|
-
import { localized, msg, str } from '@lit/localize';
|
|
5
|
-
import { getLocale } from '../utils/get-locale';
|
|
6
4
|
let AlphaBarTooltip = class AlphaBarTooltip extends LitElement {
|
|
7
5
|
constructor() {
|
|
8
6
|
super(...arguments);
|
|
9
7
|
this.numResults = 0;
|
|
10
8
|
}
|
|
11
9
|
render() {
|
|
12
|
-
const formattedCount = new Intl.NumberFormat(getLocale()).format(this.numResults);
|
|
13
10
|
return html `
|
|
14
11
|
<div id="tooltip-container" role="tooltip">
|
|
15
12
|
<div id="arrow"></div>
|
|
16
13
|
<div id="tooltip-text">
|
|
17
|
-
${this.numResults === 1
|
|
18
|
-
? msg(str `${formattedCount} result`)
|
|
19
|
-
: msg(str `${formattedCount} results`)}
|
|
14
|
+
${this.numResults} ${this.numResults === 1 ? 'result' : 'results'}
|
|
20
15
|
</div>
|
|
21
16
|
</div>
|
|
22
17
|
`;
|
|
@@ -59,8 +54,7 @@ __decorate([
|
|
|
59
54
|
property({ type: Number })
|
|
60
55
|
], AlphaBarTooltip.prototype, "numResults", void 0);
|
|
61
56
|
AlphaBarTooltip = __decorate([
|
|
62
|
-
customElement('alpha-bar-tooltip')
|
|
63
|
-
localized()
|
|
57
|
+
customElement('alpha-bar-tooltip')
|
|
64
58
|
], AlphaBarTooltip);
|
|
65
59
|
export { AlphaBarTooltip };
|
|
66
60
|
//# sourceMappingURL=alpha-bar-tooltip.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alpha-bar-tooltip.js","sourceRoot":"","sources":["../../../src/sort-filter-bar/alpha-bar-tooltip.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAkB,MAAM,KAAK,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"alpha-bar-tooltip.js","sourceRoot":"","sources":["../../../src/sort-filter-bar/alpha-bar-tooltip.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAkB,MAAM,KAAK,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAGrD,IAAM,eAAe,GAArB,MAAM,eAAgB,SAAQ,UAAU;IAAxC;;QACuB,eAAU,GAAW,CAAC,CAAC;IA+CrD,CAAC;IA7CC,MAAM;QACJ,OAAO,IAAI,CAAA;;;;YAIH,IAAI,CAAC,UAAU,IAAI,IAAI,CAAC,UAAU,KAAK,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;;;KAGtE,CAAC;IACJ,CAAC;IAED,MAAM,KAAK,MAAM;QACf,MAAM,SAAS,GAAG,GAAG,CAAA,8BAA8B,CAAC;QACpD,MAAM,WAAW,GAAG,GAAG,CAAA,gCAAgC,CAAC;QAExD,OAAO,GAAG,CAAA;;;;;;;;;2BASa,WAAW;;;;gCAIN,SAAS;iCACR,SAAS;kBACxB,SAAS;;;;;;;;;;;;;KAatB,CAAC;IACJ,CAAC;CACF,CAAA;AA/C6B;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mDAAwB;AADxC,eAAe;IAD3B,aAAa,CAAC,mBAAmB,CAAC;GACtB,eAAe,CAgD3B","sourcesContent":["import { LitElement, html, css, CSSResultGroup } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\n\n@customElement('alpha-bar-tooltip')\nexport class AlphaBarTooltip extends LitElement {\n @property({ type: Number }) numResults: number = 0;\n\n render() {\n return html`\n <div id=\"tooltip-container\" role=\"tooltip\">\n <div id=\"arrow\"></div>\n <div id=\"tooltip-text\">\n ${this.numResults} ${this.numResults === 1 ? 'result' : 'results'}\n </div>\n </div>\n `;\n }\n\n static get styles(): CSSResultGroup {\n const arrowSize = css`var(--tooltipArrowSize, 5px)`;\n const arrowOffset = css`var(--tooltipArrowOffset, 0px)`;\n\n return css`\n #tooltip-container {\n width: max-content;\n max-width: 200px;\n pointer-events: none;\n }\n\n #arrow {\n position: relative;\n left: calc(50% + ${arrowOffset});\n top: 0;\n width: 0;\n height: 0;\n margin-top: calc(-1 * ${arrowSize});\n margin-left: calc(-1 * ${arrowSize});\n border: ${arrowSize} solid transparent;\n border-bottom-color: black;\n }\n\n #tooltip-text {\n padding: 3px 8px;\n border-radius: 4px;\n background-color: #000;\n color: white;\n font-size: 1.2rem;\n text-align: center;\n text-decoration: none;\n }\n `;\n }\n}\n"]}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { LitElement, html, css, nothing } from 'lit';
|
|
3
3
|
import { customElement, property, state, query } from 'lit/decorators.js';
|
|
4
|
-
import { localized, msg, str } from '@lit/localize';
|
|
5
|
-
import { getLocale } from '../utils/get-locale';
|
|
6
4
|
import './alpha-bar-tooltip';
|
|
7
5
|
let AlphaBar = class AlphaBar extends LitElement {
|
|
8
6
|
constructor() {
|
|
@@ -35,9 +33,7 @@ let AlphaBar = class AlphaBar extends LitElement {
|
|
|
35
33
|
`;
|
|
36
34
|
}
|
|
37
35
|
letterButtonTemplate(letter) {
|
|
38
|
-
const
|
|
39
|
-
const formattedCount = new Intl.NumberFormat(getLocale()).format(count);
|
|
40
|
-
const ariaLabel = msg(str `${letter}: ${formattedCount} results`);
|
|
36
|
+
const ariaLabel = `${letter}: ${this.letterCounts?.[letter] ?? 0} results`;
|
|
41
37
|
return html `
|
|
42
38
|
<button
|
|
43
39
|
aria-label=${ariaLabel}
|
|
@@ -234,8 +230,7 @@ __decorate([
|
|
|
234
230
|
query('alpha-bar-tooltip')
|
|
235
231
|
], AlphaBar.prototype, "tooltip", void 0);
|
|
236
232
|
AlphaBar = __decorate([
|
|
237
|
-
customElement('alpha-bar')
|
|
238
|
-
localized()
|
|
233
|
+
customElement('alpha-bar')
|
|
239
234
|
], AlphaBar);
|
|
240
235
|
export { AlphaBar };
|
|
241
236
|
//# sourceMappingURL=alpha-bar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"alpha-bar.js","sourceRoot":"","sources":["../../../src/sort-filter-bar/alpha-b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CAC8B;AAG9B;IADP,KAAK,EAAE;+CACuB;AAGvB;IADP,KAAK,CAAC,mBAAmB,CAAC;yCACO;AAdvB,QAAQ;IAFpB,aAAa,CAAC,WAAW,CAAC;IAC1B,SAAS,EAAE;GACC,QAAQ,CAqPpB","sourcesContent":["import { LitElement, html, css, nothing, TemplateResult } from 'lit';\nimport { customElement, property, state, query } from 'lit/decorators.js';\nimport { localized, msg, str } from '@lit/localize';\nimport type { PrefixFilterCounts } from '../models';\nimport { getLocale } from '../utils/get-locale';\n\nimport './alpha-bar-tooltip';\nimport type { AlphaBarTooltip } from './alpha-bar-tooltip';\n\n@customElement('alpha-bar')\n@localized()\nexport class AlphaBar extends LitElement {\n @property({ type: String }) selectedLetter: string | null = null;\n\n @property({ type: Object }) letterCounts?: PrefixFilterCounts;\n\n @property({ type: String }) ariaLandmarkLabel?: string;\n\n @state()\n private tooltipShown: boolean = false;\n\n @state()\n private hoveredLetter?: string;\n\n @query('alpha-bar-tooltip')\n private tooltip?: AlphaBarTooltip;\n\n private readonly alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');\n\n private get selectedUppercaseLetter(): string | undefined {\n return this.selectedLetter?.toUpperCase();\n }\n\n render() {\n return html`\n <section id=\"container\" aria-label=${this.ariaLandmarkLabel ?? nothing}>\n <ul>\n ${this.alphabet.map(\n letter => html`\n <li\n class=${letter === this.selectedUppercaseLetter\n ? 'selected'\n : nothing}\n @mousemove=${this.handleMouseMove}\n @mouseleave=${this.handleMouseLeave}\n >\n ${this.letterButtonTemplate(letter)}\n ${this.tooltipTemplate(letter)}\n </li>\n `,\n )}\n </ul>\n </section>\n `;\n }\n\n private letterButtonTemplate(letter: string) {\n const count = this.letterCounts?.[letter] ?? 0;\n const formattedCount = new Intl.NumberFormat(getLocale()).format(count);\n const ariaLabel = msg(str`${letter}: ${formattedCount} results`);\n return html`\n <button\n aria-label=${ariaLabel}\n ?disabled=${!this.letterCounts?.[letter]}\n @click=${() => {\n this.letterClicked(letter);\n }}\n >\n ${letter}\n </button>\n `;\n }\n\n private tooltipTemplate(letter: string): TemplateResult | typeof nothing {\n if (this.hoveredLetter !== letter) return nothing;\n\n return this.tooltipShown\n ? html`<alpha-bar-tooltip\n data-letter=${letter}\n .numResults=${this.letterCounts?.[this.hoveredLetter] ?? 0}\n ></alpha-bar-tooltip>`\n : nothing;\n }\n\n private letterClicked(letter: string) {\n if (letter === this.selectedUppercaseLetter) {\n this.selectedLetter = null;\n } else {\n this.selectedLetter = letter;\n }\n this.dispatchEvent(\n new CustomEvent('letterChanged', {\n detail: { selectedLetter: this.selectedUppercaseLetter },\n }),\n );\n }\n\n private async handleMouseMove(e: MouseEvent) {\n const target = e.target as HTMLLIElement;\n if (target && !this.tooltipShown) {\n const targetLetter = target.textContent?.trim() ?? undefined;\n this.tooltipShown = true;\n this.hoveredLetter = targetLetter;\n\n await this.updateComplete;\n await new Promise(resolve => {\n setTimeout(resolve, 0);\n });\n\n if (this.tooltip && this.tooltip.dataset.letter === targetLetter) {\n this.positionTooltip(target);\n }\n }\n }\n\n private handleMouseLeave() {\n this.tooltipShown = false;\n this.hoveredLetter = undefined;\n }\n\n private positionTooltip(targetElmt: HTMLElement) {\n if (!this.tooltip) return;\n\n // Basic positioning is just to center the whole tooltip on the letter box.\n const tooltipWidth = this.tooltip.clientWidth;\n const letterWidth = targetElmt.clientWidth;\n let left = letterWidth / 2 - tooltipWidth / 2;\n\n // But we also need to ensure the tooltip doesn't flow outside the viewport.\n // First, calculate the full width of the document body, including margins\n // (but not including any scrollbar).\n const bodyStyle = getComputedStyle(document.body);\n const bodyMarginLeft = parseFloat(\n bodyStyle.getPropertyValue('margin-left'),\n );\n const bodyMarginRight = parseFloat(\n bodyStyle.getPropertyValue('margin-right'),\n );\n const bodyWidthWithMargin =\n document.body.clientWidth + bodyMarginLeft + bodyMarginRight;\n\n // Calculate the positions of the tooltip's left/right edges, and determine\n // how much they overflow the viewport by (if at all).\n const targetRect = targetElmt.getBoundingClientRect();\n const tooltipLeft = targetRect.left + left;\n const tooltipRight = tooltipLeft + tooltipWidth;\n const offset = 1; // How many pixels the tooltip must be offset from the left/right edges\n let overflowAmt;\n if (tooltipLeft < offset) {\n // Tooltip overflows left edge of viewport\n overflowAmt = tooltipLeft - offset;\n } else if (tooltipRight > bodyWidthWithMargin - offset) {\n // Tooltip overflows right edge of viewport\n overflowAmt = tooltipRight - bodyWidthWithMargin + offset;\n }\n\n // Apply any needed adjustment to the tooltip and its arrow to keep it in the viewport\n if (overflowAmt) {\n left -= overflowAmt;\n this.tooltip.style.setProperty(\n '--tooltipArrowOffset',\n `${overflowAmt}px`,\n );\n }\n\n this.tooltip.style.left = `${left}px`;\n this.tooltip.classList.add('fade-in');\n }\n\n static styles = css`\n h1 {\n font-size: 1.2rem;\n }\n\n #container {\n background-color: #ddd;\n color: #333;\n box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);\n }\n\n ul {\n list-style: none;\n display: flex;\n margin: 0;\n padding: 0.5rem 1rem;\n justify-content: space-between;\n }\n\n ul li {\n position: relative;\n flex: 1;\n text-align: center;\n max-width: 2.5rem;\n border-radius: 4px;\n }\n\n li:hover:not(.selected) button:not(:disabled) {\n background-color: #c0c0c0;\n }\n\n button {\n display: flex;\n justify-content: center;\n align-items: center;\n aspect-ratio: 1 / 1;\n }\n\n button {\n width: 100%;\n height: 100%;\n color: #333;\n appearance: none;\n background: none;\n border: none;\n border-radius: 4px;\n font-family: inherit;\n font-size: 1.2rem;\n cursor: pointer;\n }\n\n button:disabled {\n color: #aaa;\n cursor: default;\n }\n\n .selected {\n background-color: #2c2c2c;\n }\n\n .selected button {\n color: white;\n }\n\n alpha-bar-tooltip {\n position: absolute;\n top: 100%;\n left: -9999px;\n margin-top: 3px;\n z-index: 1;\n\n opacity: 0;\n transition: opacity 0.2s ease;\n }\n\n alpha-bar-tooltip.fade-in {\n opacity: 1;\n }\n\n /* Make alphabet bar a 2-row container in small screen widths */\n @media screen and (max-width: 768px) {\n ul {\n display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, TemplateResult } from 'lit';\nimport { customElement, property, state, query } from 'lit/decorators.js';\nimport type { PrefixFilterCounts } from '../models';\n\nimport './alpha-bar-tooltip';\nimport type { AlphaBarTooltip } from './alpha-bar-tooltip';\n\n@customElement('alpha-bar')\nexport class AlphaBar extends LitElement {\n @property({ type: String }) selectedLetter: string | null = null;\n\n @property({ type: Object }) letterCounts?: PrefixFilterCounts;\n\n @property({ type: String }) ariaLandmarkLabel?: string;\n\n @state()\n private tooltipShown: boolean = false;\n\n @state()\n private hoveredLetter?: string;\n\n @query('alpha-bar-tooltip')\n private tooltip?: AlphaBarTooltip;\n\n private readonly alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('');\n\n private get selectedUppercaseLetter(): string | undefined {\n return this.selectedLetter?.toUpperCase();\n }\n\n render() {\n return html`\n <section id=\"container\" aria-label=${this.ariaLandmarkLabel ?? nothing}>\n <ul>\n ${this.alphabet.map(\n letter => html`\n <li\n class=${letter === this.selectedUppercaseLetter\n ? 'selected'\n : nothing}\n @mousemove=${this.handleMouseMove}\n @mouseleave=${this.handleMouseLeave}\n >\n ${this.letterButtonTemplate(letter)}\n ${this.tooltipTemplate(letter)}\n </li>\n `,\n )}\n </ul>\n </section>\n `;\n }\n\n private letterButtonTemplate(letter: string) {\n const ariaLabel = `${letter}: ${this.letterCounts?.[letter] ?? 0} results`;\n return html`\n <button\n aria-label=${ariaLabel}\n ?disabled=${!this.letterCounts?.[letter]}\n @click=${() => {\n this.letterClicked(letter);\n }}\n >\n ${letter}\n </button>\n `;\n }\n\n private tooltipTemplate(letter: string): TemplateResult | typeof nothing {\n if (this.hoveredLetter !== letter) return nothing;\n\n return this.tooltipShown\n ? html`<alpha-bar-tooltip\n data-letter=${letter}\n .numResults=${this.letterCounts?.[this.hoveredLetter] ?? 0}\n ></alpha-bar-tooltip>`\n : nothing;\n }\n\n private letterClicked(letter: string) {\n if (letter === this.selectedUppercaseLetter) {\n this.selectedLetter = null;\n } else {\n this.selectedLetter = letter;\n }\n this.dispatchEvent(\n new CustomEvent('letterChanged', {\n detail: { selectedLetter: this.selectedUppercaseLetter },\n }),\n );\n }\n\n private async handleMouseMove(e: MouseEvent) {\n const target = e.target as HTMLLIElement;\n if (target && !this.tooltipShown) {\n const targetLetter = target.textContent?.trim() ?? undefined;\n this.tooltipShown = true;\n this.hoveredLetter = targetLetter;\n\n await this.updateComplete;\n await new Promise(resolve => {\n setTimeout(resolve, 0);\n });\n\n if (this.tooltip && this.tooltip.dataset.letter === targetLetter) {\n this.positionTooltip(target);\n }\n }\n }\n\n private handleMouseLeave() {\n this.tooltipShown = false;\n this.hoveredLetter = undefined;\n }\n\n private positionTooltip(targetElmt: HTMLElement) {\n if (!this.tooltip) return;\n\n // Basic positioning is just to center the whole tooltip on the letter box.\n const tooltipWidth = this.tooltip.clientWidth;\n const letterWidth = targetElmt.clientWidth;\n let left = letterWidth / 2 - tooltipWidth / 2;\n\n // But we also need to ensure the tooltip doesn't flow outside the viewport.\n // First, calculate the full width of the document body, including margins\n // (but not including any scrollbar).\n const bodyStyle = getComputedStyle(document.body);\n const bodyMarginLeft = parseFloat(\n bodyStyle.getPropertyValue('margin-left'),\n );\n const bodyMarginRight = parseFloat(\n bodyStyle.getPropertyValue('margin-right'),\n );\n const bodyWidthWithMargin =\n document.body.clientWidth + bodyMarginLeft + bodyMarginRight;\n\n // Calculate the positions of the tooltip's left/right edges, and determine\n // how much they overflow the viewport by (if at all).\n const targetRect = targetElmt.getBoundingClientRect();\n const tooltipLeft = targetRect.left + left;\n const tooltipRight = tooltipLeft + tooltipWidth;\n const offset = 1; // How many pixels the tooltip must be offset from the left/right edges\n let overflowAmt;\n if (tooltipLeft < offset) {\n // Tooltip overflows left edge of viewport\n overflowAmt = tooltipLeft - offset;\n } else if (tooltipRight > bodyWidthWithMargin - offset) {\n // Tooltip overflows right edge of viewport\n overflowAmt = tooltipRight - bodyWidthWithMargin + offset;\n }\n\n // Apply any needed adjustment to the tooltip and its arrow to keep it in the viewport\n if (overflowAmt) {\n left -= overflowAmt;\n this.tooltip.style.setProperty(\n '--tooltipArrowOffset',\n `${overflowAmt}px`,\n );\n }\n\n this.tooltip.style.left = `${left}px`;\n this.tooltip.classList.add('fade-in');\n }\n\n static styles = css`\n h1 {\n font-size: 1.2rem;\n }\n\n #container {\n background-color: #ddd;\n color: #333;\n box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.5);\n }\n\n ul {\n list-style: none;\n display: flex;\n margin: 0;\n padding: 0.5rem 1rem;\n justify-content: space-between;\n }\n\n ul li {\n position: relative;\n flex: 1;\n text-align: center;\n max-width: 2.5rem;\n border-radius: 4px;\n }\n\n li:hover:not(.selected) button:not(:disabled) {\n background-color: #c0c0c0;\n }\n\n button {\n display: flex;\n justify-content: center;\n align-items: center;\n aspect-ratio: 1 / 1;\n }\n\n button {\n width: 100%;\n height: 100%;\n color: #333;\n appearance: none;\n background: none;\n border: none;\n border-radius: 4px;\n font-family: inherit;\n font-size: 1.2rem;\n cursor: pointer;\n }\n\n button:disabled {\n color: #aaa;\n cursor: default;\n }\n\n .selected {\n background-color: #2c2c2c;\n }\n\n .selected button {\n color: white;\n }\n\n alpha-bar-tooltip {\n position: absolute;\n top: 100%;\n left: -9999px;\n margin-top: 3px;\n z-index: 1;\n\n opacity: 0;\n transition: opacity 0.2s ease;\n }\n\n alpha-bar-tooltip.fade-in {\n opacity: 1;\n }\n\n /* Make alphabet bar a 2-row container in small screen widths */\n @media screen and (max-width: 768px) {\n ul {\n display: grid;\n grid-template-columns: repeat(13, 1fr);\n }\n }\n `;\n}\n"]}
|