@internetarchive/collection-browser 4.8.1-webdev-9227.4 → 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 -20
- package/dist/src/utils/get-locale.js.map +0 -1
- package/locales/es.d.ts +0 -1
- package/locales/es.js +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { LitElement, html, css, nothing, } from 'lit';
|
|
3
3
|
import { customElement, property, query, state } from 'lit/decorators.js';
|
|
4
|
-
import {
|
|
4
|
+
import { msg, str } from '@lit/localize';
|
|
5
5
|
import { defaultSortAvailability, SORT_OPTIONS, SortField, } from '../models';
|
|
6
6
|
import { sortUpIcon } from './img/sort-toggle-up';
|
|
7
7
|
import { sortDownIcon } from './img/sort-toggle-down';
|
|
@@ -64,29 +64,32 @@ let SortFilterBar = class SortFilterBar extends LitElement {
|
|
|
64
64
|
render() {
|
|
65
65
|
return html `
|
|
66
66
|
<div id="container">
|
|
67
|
-
<
|
|
68
|
-
<
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
<div id="sort-bar-row">
|
|
68
|
+
<section id="sort-bar" aria-label="Sorting options">
|
|
69
|
+
<slot name="sort-options-left"></slot>
|
|
70
|
+
<div id="sort-options">
|
|
71
|
+
${!this.enableSortOptionsSlot
|
|
71
72
|
? html `
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
73
|
+
<div class="sort-direction-container">
|
|
74
|
+
${this.sortDirectionSelectorTemplate}
|
|
75
|
+
</div>
|
|
76
|
+
<span class="sort-by-text">${msg('Sort by:')}</span>
|
|
77
|
+
<div id="sort-selector-container">
|
|
78
|
+
${this.sortSelectorTemplate}
|
|
79
|
+
</div>
|
|
80
|
+
`
|
|
80
81
|
: html `<slot name="sort-options"></slot>`}
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
</div>
|
|
83
|
+
<slot name="sort-options-right"></slot>
|
|
83
84
|
|
|
84
|
-
|
|
85
|
+
${this.suppressDisplayModes
|
|
85
86
|
? nothing
|
|
86
87
|
: html `<div id="display-style-selector">
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
88
|
+
${this.displayOptionTemplate}
|
|
89
|
+
</div>`}
|
|
90
|
+
</section>
|
|
91
|
+
<slot name="sort-bar-end"></slot>
|
|
92
|
+
</div>
|
|
90
93
|
|
|
91
94
|
${this.dropdownBackdropVisible ? this.dropdownBackdrop : nothing}
|
|
92
95
|
${this.alphaBarTemplate}
|
|
@@ -272,7 +275,7 @@ let SortFilterBar = class SortFilterBar extends LitElement {
|
|
|
272
275
|
this.displayMode = 'grid';
|
|
273
276
|
}}
|
|
274
277
|
class=${this.displayMode === 'grid' ? 'active' : ''}
|
|
275
|
-
title
|
|
278
|
+
title="Tile view"
|
|
276
279
|
data-testid="grid-button"
|
|
277
280
|
>
|
|
278
281
|
${tileIcon}
|
|
@@ -285,7 +288,7 @@ let SortFilterBar = class SortFilterBar extends LitElement {
|
|
|
285
288
|
this.displayMode = 'list-detail';
|
|
286
289
|
}}
|
|
287
290
|
class=${this.displayMode === 'list-detail' ? 'active' : ''}
|
|
288
|
-
title
|
|
291
|
+
title="List view"
|
|
289
292
|
data-testid="list-detail-button"
|
|
290
293
|
>
|
|
291
294
|
${listIcon}
|
|
@@ -298,7 +301,7 @@ let SortFilterBar = class SortFilterBar extends LitElement {
|
|
|
298
301
|
this.displayMode = 'list-compact';
|
|
299
302
|
}}
|
|
300
303
|
class=${this.displayMode === 'list-compact' ? 'active' : ''}
|
|
301
|
-
title
|
|
304
|
+
title="Compact list view"
|
|
302
305
|
data-testid="list-compact-button"
|
|
303
306
|
>
|
|
304
307
|
${compactIcon}
|
|
@@ -384,7 +387,7 @@ let SortFilterBar = class SortFilterBar extends LitElement {
|
|
|
384
387
|
return html ` <alpha-bar
|
|
385
388
|
.selectedLetter=${this.selectedTitleFilter}
|
|
386
389
|
.letterCounts=${this.prefixFilterCountMap?.title}
|
|
387
|
-
ariaLandmarkLabel
|
|
390
|
+
ariaLandmarkLabel="Filter by title letter"
|
|
388
391
|
@letterChanged=${this.titleLetterChanged}
|
|
389
392
|
></alpha-bar>`;
|
|
390
393
|
}
|
|
@@ -392,7 +395,7 @@ let SortFilterBar = class SortFilterBar extends LitElement {
|
|
|
392
395
|
return html ` <alpha-bar
|
|
393
396
|
.selectedLetter=${this.selectedCreatorFilter}
|
|
394
397
|
.letterCounts=${this.prefixFilterCountMap?.creator}
|
|
395
|
-
ariaLandmarkLabel
|
|
398
|
+
ariaLandmarkLabel="Filter by creator letter"
|
|
396
399
|
@letterChanged=${this.creatorLetterChanged}
|
|
397
400
|
></alpha-bar>`;
|
|
398
401
|
}
|
|
@@ -440,15 +443,30 @@ let SortFilterBar = class SortFilterBar extends LitElement {
|
|
|
440
443
|
position: relative;
|
|
441
444
|
}
|
|
442
445
|
|
|
443
|
-
|
|
446
|
+
/*
|
|
447
|
+
* The sort-bar-end slot shares this row with the sort bar but sits
|
|
448
|
+
* outside its "Sorting options" landmark. When the slotted content
|
|
449
|
+
* doesn't fit beside the sort controls, it wraps onto its own line at
|
|
450
|
+
* the right rather than overflowing the row.
|
|
451
|
+
*/
|
|
452
|
+
#sort-bar-row {
|
|
444
453
|
display: flex;
|
|
445
|
-
|
|
454
|
+
flex-wrap: wrap;
|
|
455
|
+
justify-content: flex-end;
|
|
446
456
|
align-items: center;
|
|
447
457
|
padding-bottom: 1px;
|
|
448
458
|
border-bottom: 1px solid #2c2c2c;
|
|
449
459
|
font-size: 1.4rem;
|
|
450
460
|
}
|
|
451
461
|
|
|
462
|
+
#sort-bar {
|
|
463
|
+
flex: auto;
|
|
464
|
+
min-width: 0;
|
|
465
|
+
display: flex;
|
|
466
|
+
justify-content: flex-start;
|
|
467
|
+
align-items: center;
|
|
468
|
+
}
|
|
469
|
+
|
|
452
470
|
#sort-options {
|
|
453
471
|
display: flex;
|
|
454
472
|
align-items: center;
|
|
@@ -642,8 +660,7 @@ __decorate([
|
|
|
642
660
|
query('#sort-dropdown')
|
|
643
661
|
], SortFilterBar.prototype, "sortOptionsDropdown", void 0);
|
|
644
662
|
SortFilterBar = __decorate([
|
|
645
|
-
customElement('sort-filter-bar')
|
|
646
|
-
localized()
|
|
663
|
+
customElement('sort-filter-bar')
|
|
647
664
|
], SortFilterBar);
|
|
648
665
|
export { SortFilterBar };
|
|
649
666
|
//# sourceMappingURL=sort-filter-bar.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sort-filter-bar.js","sourceRoot":"","sources":["../../../src/sort-filter-bar/sort-filter-bar.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EACV,IAAI,EACJ,GAAG,EACH,OAAO,GAGR,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAGpD,OAAO,EAEL,uBAAuB,EAGvB,YAAY,EACZ,SAAS,GAEV,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,8BAA8B,CAAC;AACtC,OAAO,aAAa,CAAC;AAMd,IAAM,aAAa,GAAnB,MAAM,a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AA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;uDAGH;AAGI;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;oDAA4C;AAG3C;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mDAA6C;AAG5C;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0DAA2C;AAG1C;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4DAA6C;AAe5C;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4DAAiD;AAGhC;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;4DACnC;AAIR;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2DACL;AAGV;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2DAGzB;AAMO;IAAR,KAAK,EAAE;2DAAmD;AAMlD;IAAR,KAAK,EAAE;8DAAiC;AAIjC;IADP,KAAK,CAAC,gBAAgB,CAAC;0DACiB;AApE9B,aAAa;IAFzB,aAAa,CAAC,iBAAiB,CAAC;IAChC,SAAS,EAAE;GACC,aAAa,CAwrBzB","sourcesContent":["import {\n LitElement,\n html,\n css,\n nothing,\n PropertyValues,\n TemplateResult,\n} from 'lit';\nimport { customElement, property, query, state } from 'lit/decorators.js';\nimport { localized, msg, str } from '@lit/localize';\nimport type { IaDropdown, optionInterface } from '@internetarchive/ia-dropdown';\nimport type { SortDirection } from '@internetarchive/search-service';\nimport {\n CollectionDisplayMode,\n defaultSortAvailability,\n PrefixFilterCounts,\n PrefixFilterType,\n SORT_OPTIONS,\n SortField,\n SortOption,\n} from '../models';\n\nimport { sortUpIcon } from './img/sort-toggle-up';\nimport { sortDownIcon } from './img/sort-toggle-down';\nimport { sortDisabledIcon } from './img/sort-toggle-disabled';\nimport { tileIcon } from './img/tile';\nimport { listIcon } from './img/list';\nimport { compactIcon } from './img/compact';\nimport { srOnlyStyle } from '../styles/sr-only';\n\nimport '@internetarchive/ia-dropdown';\nimport './alpha-bar';\n\ntype AlphaSelector = 'creator' | 'title';\n\n@customElement('sort-filter-bar')\n@localized()\nexport class SortFilterBar extends LitElement {\n /** Which display mode the tiles are being rendered with (grid/list-detail/list-compact) */\n @property({ type: String }) displayMode?: CollectionDisplayMode;\n\n /** The default sort direction to use if none is set */\n @property({ type: String }) defaultSortDirection: SortDirection | null = null;\n\n /** The default sort field to use if none is set */\n @property({ type: String }) defaultSortField: Exclude<\n SortField,\n SortField.default\n > = SortField.relevance;\n\n /** The current sort direction (asc/desc), or null if none is set */\n @property({ type: String }) sortDirection: SortDirection | null = null;\n\n /** The field currently being sorted on (e.g., 'title'). Defaults to relevance. */\n @property({ type: String }) selectedSort: SortField = SortField.default;\n\n /** The currently selected title letter filter, or null if none is set */\n @property({ type: String }) selectedTitleFilter: string | null = null;\n\n /** The currently selected creator letter filter, or null if none is set */\n @property({ type: String }) selectedCreatorFilter: string | null = null;\n\n /**\n * Map defining which sortable fields should be included on the sort bar.\n *\n * E.g.,\n * ```\n * {\n * [SortField.relevance]: true,\n * [SortField.date]: false,\n * [SortField.title]: true,\n * ...\n * }\n * ```\n */\n @property({ type: Object }) sortFieldAvailability = defaultSortAvailability;\n\n /** Whether to replace the default sort options with a slot for customization (default `false`) */\n @property({ type: Boolean, reflect: true }) enableSortOptionsSlot: boolean =\n false;\n\n /** Whether to suppress showing the three display mode options on the right of the bar (default `false`) */\n @property({ type: Boolean, reflect: true })\n suppressDisplayModes: boolean = false;\n\n /** Maps of result counts for letters on the alphabet bar, for each letter filter type */\n @property({ type: Object }) prefixFilterCountMap?: Record<\n PrefixFilterType,\n PrefixFilterCounts\n >;\n\n /**\n * Which of the alphabet bars (title/creator) should be shown, or null if one\n * should not currently be rendered.\n */\n @state() alphaSelectorVisible: AlphaSelector | null = null;\n\n /**\n * Whether the transparent backdrop to catch clicks outside the dropdown menu\n * should be rendered.\n */\n @state() dropdownBackdropVisible = false;\n\n /** The single, consolidated dropdown component containing all available options */\n @query('#sort-dropdown')\n private sortOptionsDropdown!: IaDropdown;\n\n render() {\n return html`\n <div id=\"container\">\n <section id=\"sort-bar\" aria-label=${msg('Sorting options')}>\n <slot name=\"sort-options-left\"></slot>\n <div id=\"sort-options\">\n ${!this.enableSortOptionsSlot\n ? html`\n <div class=\"sort-direction-container\">\n ${this.sortDirectionSelectorTemplate}\n </div>\n <span class=\"sort-by-text\">${msg('Sort by:')}</span>\n <div id=\"sort-selector-container\">\n ${this.sortSelectorTemplate}\n </div>\n `\n : html`<slot name=\"sort-options\"></slot>`}\n </div>\n <slot name=\"sort-options-right\"></slot>\n\n ${this.suppressDisplayModes\n ? nothing\n : html`<div id=\"display-style-selector\">\n ${this.displayOptionTemplate}\n </div>`}\n </section>\n\n ${this.dropdownBackdropVisible ? this.dropdownBackdrop : nothing}\n ${this.alphaBarTemplate}\n </div>\n `;\n }\n\n willUpdate(changed: PropertyValues) {\n if (changed.has('selectedSort') || changed.has('defaultSortField')) {\n // If the sort is changed from its default without a direction set,\n // we adopt the default sort direction for that sort type.\n if (\n this.selectedSort &&\n this.selectedSort !== SortField.default &&\n this.sortDirection === null\n ) {\n const sortOption = SORT_OPTIONS[this.finalizedSortField];\n this.sortDirection = sortOption.defaultSortDirection;\n }\n }\n }\n\n updated(changed: PropertyValues) {\n if (changed.has('displayMode')) {\n this.displayModeChanged();\n }\n\n if (changed.has('selectedTitleFilter') && this.selectedTitleFilter) {\n this.alphaSelectorVisible = 'title';\n }\n\n if (changed.has('selectedCreatorFilter') && this.selectedCreatorFilter) {\n this.alphaSelectorVisible = 'creator';\n }\n\n if (changed.has('dropdownBackdropVisible')) {\n this.setupEscapeListeners();\n }\n }\n\n private setupEscapeListeners() {\n if (this.dropdownBackdropVisible) {\n document.addEventListener(\n 'keydown',\n this.boundSortBarSelectorEscapeListener,\n );\n } else {\n document.removeEventListener(\n 'keydown',\n this.boundSortBarSelectorEscapeListener,\n );\n }\n }\n\n private boundSortBarSelectorEscapeListener = (e: KeyboardEvent) => {\n if (e.key === 'Escape') {\n this.closeDropdown();\n }\n };\n\n /**\n * Template to render the alphabet bar, or `nothing` if it should not be rendered\n * for the current sort\n */\n private get alphaBarTemplate(): TemplateResult | typeof nothing {\n if (!['title', 'creator'].includes(this.selectedSort)) return nothing;\n\n if (this.alphaSelectorVisible === null) {\n if (this.selectedSort === 'creator') return this.creatorSelectorBar;\n if (this.selectedSort === 'title') return this.titleSelectorBar;\n } else {\n return this.alphaSelectorVisible === 'creator'\n ? this.creatorSelectorBar\n : this.titleSelectorBar;\n }\n\n return nothing;\n }\n\n /** Template to render the sort direction toggle button */\n private get sortDirectionSelectorTemplate(): TemplateResult {\n const oppositeSortDirectionReadable =\n this.sortDirection === 'asc' ? msg('descending') : msg('ascending');\n const buttonLabel = this.canChangeSortDirection\n ? msg(str`Change to ${oppositeSortDirectionReadable} sort`)\n : msg('Directions are not available for the current sort option');\n\n return html`\n <button\n class=\"sort-direction-selector\"\n title=${buttonLabel}\n ?disabled=${!this.canChangeSortDirection}\n @click=${this.handleSortDirectionClicked}\n >\n <span class=\"sr-only\">${buttonLabel}</span>\n ${this.sortDirectionIcon}\n </button>\n `;\n }\n\n /** Template to render the sort direction button's icon in the correct current state */\n private get sortDirectionIcon(): TemplateResult {\n // Show a fully disabled icon for sort options without direction support\n if (!this.canChangeSortDirection) {\n return html`<div class=\"sort-direction-icon\">${sortDisabledIcon}</div>`;\n }\n\n // For all other sorts, show the ascending/descending direction\n return html`\n <div class=\"sort-direction-icon\">\n ${this.finalizedSortDirection === 'asc' ? sortUpIcon : sortDownIcon}\n </div>\n `;\n }\n\n /** The template to render all the sort options in a single dropdown */\n private get sortSelectorTemplate() {\n const displayedOptions = Object.values(SORT_OPTIONS).filter(\n opt => opt.shownInSortBar && this.sortFieldAvailability[opt.field],\n );\n\n return html`\n <div id=\"sort-dropdown-container\">\n ${this.getSortDropdown({\n displayName: SORT_OPTIONS[this.finalizedSortField].displayName,\n id: 'sort-dropdown',\n selected: true,\n dropdownOptions: displayedOptions.map(opt =>\n this.getDropdownOption(opt.field),\n ),\n selectedOption: this.finalizedSortField,\n onOptionSelected: this.sortOptionSelected,\n onDropdownClick: () => {\n this.dropdownBackdropVisible = this.sortOptionsDropdown.open;\n this.sortOptionsDropdown.classList.toggle(\n 'open',\n this.sortOptionsDropdown.open,\n );\n },\n })}\n </div>\n `;\n }\n\n /**\n * Generates a dropdown component containing multiple grouped sort options.\n *\n * @param options.displayName The name to use for the dropdown's visible label\n * @param options.id The id to apply to the dropdown element\n * @param options.dropdownOptions An array of option objects used to populate the dropdown\n * @param options.selectedOption The id of the option that should be initially selected\n * @param options.selected A boolean indicating whether this dropdown should use its\n * selected appearance\n * @param options.onOptionSelected A handler for optionSelected events coming from the dropdown\n * @param options.onDropdownClick A handler for click events on the dropdown\n */\n private getSortDropdown(options: {\n displayName: string;\n id: string;\n dropdownOptions: optionInterface[];\n selectedOption?: string;\n selected: boolean;\n onOptionSelected?: (e: CustomEvent<{ option: optionInterface }>) => void;\n onDropdownClick?: (e: PointerEvent) => void;\n }): TemplateResult {\n return html`\n <ia-dropdown\n id=${options.id}\n class=${options.selected ? 'selected' : ''}\n displayCaret\n closeOnSelect\n includeSelectedOption\n .openViaButton=${options.selected}\n .options=${options.dropdownOptions}\n .selectedOption=${options.selectedOption ?? ''}\n @optionSelected=${options.onOptionSelected ?? nothing}\n @click=${options.onDropdownClick ?? nothing}\n >\n <span\n class=\"dropdown-label\"\n slot=\"dropdown-label\"\n data-title=${options.displayName}\n >\n ${options.displayName}\n </span>\n </ia-dropdown>\n `;\n }\n\n /** Generates a single dropdown option object for the given sort field */\n private getDropdownOption(sortField: SortField): optionInterface {\n return {\n id: sortField,\n label: html`\n <span class=\"dropdown-option-label\">\n ${SORT_OPTIONS[sortField].displayName}\n </span>\n `,\n };\n }\n\n /** Handler for when a new sort dropdown option is selected */\n private sortOptionSelected(e: CustomEvent<{ option: optionInterface }>) {\n this.dropdownBackdropVisible = false;\n\n const sortField = e.detail.option.id as SortField;\n this.setSelectedSort(sortField);\n\n this.alphaSelectorVisible = null;\n if (sortField !== 'title' && this.selectedTitleFilter) {\n this.selectedTitleFilter = null;\n this.emitTitleLetterChangedEvent();\n }\n if (sortField !== 'creator' && this.selectedCreatorFilter) {\n this.selectedCreatorFilter = null;\n this.emitCreatorLetterChangedEvent();\n }\n }\n\n /** Template for rendering the three display mode options */\n /** Added data-testid for Playwright testing * */\n private get displayOptionTemplate() {\n return html`\n <ul>\n <li>\n <button\n id=\"grid-button\"\n @click=${() => {\n this.displayMode = 'grid';\n }}\n class=${this.displayMode === 'grid' ? 'active' : ''}\n title=${msg('Tile view')}\n data-testid=\"grid-button\"\n >\n ${tileIcon}\n </button>\n </li>\n <li>\n <button\n id=\"list-detail-button\"\n @click=${() => {\n this.displayMode = 'list-detail';\n }}\n class=${this.displayMode === 'list-detail' ? 'active' : ''}\n title=${msg('List view')}\n data-testid=\"list-detail-button\"\n >\n ${listIcon}\n </button>\n </li>\n <li>\n <button\n id=\"list-compact-button\"\n @click=${() => {\n this.displayMode = 'list-compact';\n }}\n class=${this.displayMode === 'list-compact' ? 'active' : ''}\n title=${msg('Compact list view')}\n data-testid=\"list-compact-button\"\n >\n ${compactIcon}\n </button>\n </li>\n </ul>\n `;\n }\n\n /**\n * Template for rendering the transparent backdrop to capture clicks outside the\n * dropdown menu while it is open.\n */\n private get dropdownBackdrop() {\n return html`\n <div\n id=\"sort-selector-backdrop\"\n @keyup=${this.closeDropdown}\n @click=${this.closeDropdown}\n ></div>\n `;\n }\n\n /** Closes the sorting dropdown component's menus */\n private closeDropdown() {\n this.dropdownBackdropVisible = false;\n\n if (!this.sortOptionsDropdown) return;\n this.sortOptionsDropdown.open = false;\n this.sortOptionsDropdown.classList.remove('open');\n }\n\n setSortDirection(sortDirection: SortDirection) {\n this.sortDirection = sortDirection;\n this.emitSortChangedEvent();\n }\n\n /** Toggles the current sort direction between 'asc' and 'desc' */\n private toggleSortDirection() {\n this.setSortDirection(\n this.finalizedSortDirection === 'desc' ? 'asc' : 'desc',\n );\n }\n\n private handleSortDirectionClicked(): void {\n if (\n !this.sortDirection &&\n this.defaultSortField &&\n this.defaultSortDirection\n ) {\n // When the sort direction is merely defaulted (not set by the user), clicking\n // the toggled button should \"promote\" the default sort to an explicitly-set one\n // and then toggle it as usual.\n this.selectedSort = this.defaultSortField;\n this.sortDirection = this.defaultSortDirection;\n }\n\n this.toggleSortDirection();\n }\n\n setSelectedSort(sort: SortField) {\n this.selectedSort = sort;\n // Apply this field's default sort direction\n const sortOption = SORT_OPTIONS[sort];\n this.sortDirection = sortOption.defaultSortDirection;\n this.emitSortChangedEvent();\n }\n\n /** The current sort field, or the default one if no explicit sort is set */\n private get finalizedSortField(): SortField {\n const resolvedField =\n this.selectedSort === SortField.default\n ? this.defaultSortField\n : this.selectedSort;\n if (this.sortFieldAvailability[resolvedField]) return resolvedField;\n\n // Fall back to the first available sort option shown in the sort bar, if\n // the requested one isn't available\n return this.firstAvailableOption?.field ?? resolvedField;\n }\n\n /** The current sort direction, or the default one if no explicit direction is set */\n private get finalizedSortDirection(): SortDirection | null {\n return this.sortDirection === null\n ? this.defaultSortDirection\n : this.sortDirection;\n }\n\n /** The first option shown in the sort dropdown, or undefined if none are available */\n private get firstAvailableOption(): SortOption | undefined {\n return Object.values(SORT_OPTIONS).find(\n opt => opt.shownInSortBar && this.sortFieldAvailability[opt.field],\n );\n }\n\n /** Whether the sort direction button should be enabled for the current sort */\n private get canChangeSortDirection(): boolean {\n return SORT_OPTIONS[this.finalizedSortField].canSetDirection;\n }\n\n private get titleSelectorBar() {\n return html` <alpha-bar\n .selectedLetter=${this.selectedTitleFilter}\n .letterCounts=${this.prefixFilterCountMap?.title}\n ariaLandmarkLabel=${msg('Filter by title letter')}\n @letterChanged=${this.titleLetterChanged}\n ></alpha-bar>`;\n }\n\n private get creatorSelectorBar() {\n return html` <alpha-bar\n .selectedLetter=${this.selectedCreatorFilter}\n .letterCounts=${this.prefixFilterCountMap?.creator}\n ariaLandmarkLabel=${msg('Filter by creator letter')}\n @letterChanged=${this.creatorLetterChanged}\n ></alpha-bar>`;\n }\n\n private titleLetterChanged(\n e: CustomEvent<{ selectedLetter: string | undefined }>,\n ) {\n this.selectedTitleFilter = e.detail.selectedLetter ?? null;\n this.emitTitleLetterChangedEvent();\n }\n\n private creatorLetterChanged(\n e: CustomEvent<{ selectedLetter: string | undefined }>,\n ) {\n this.selectedCreatorFilter = e.detail.selectedLetter ?? null;\n this.emitCreatorLetterChangedEvent();\n }\n\n private emitTitleLetterChangedEvent() {\n const event = new CustomEvent<{ selectedLetter: string | null }>(\n 'titleLetterChanged',\n {\n detail: { selectedLetter: this.selectedTitleFilter },\n },\n );\n this.dispatchEvent(event);\n }\n\n private emitCreatorLetterChangedEvent() {\n const event = new CustomEvent<{ selectedLetter: string | null }>(\n 'creatorLetterChanged',\n {\n detail: { selectedLetter: this.selectedCreatorFilter },\n },\n );\n this.dispatchEvent(event);\n }\n\n private displayModeChanged() {\n const event = new CustomEvent<{\n displayMode?: CollectionDisplayMode;\n }>('displayModeChanged', {\n detail: { displayMode: this.displayMode },\n });\n this.dispatchEvent(event);\n }\n\n private emitSortChangedEvent() {\n const event = new CustomEvent<{\n selectedSort: SortField;\n sortDirection: SortDirection | null;\n }>('sortChanged', {\n detail: {\n selectedSort: this.selectedSort,\n sortDirection: this.sortDirection,\n },\n });\n this.dispatchEvent(event);\n }\n\n static get styles() {\n const disabledIconColor = css`#bbbbbb`;\n\n return [\n srOnlyStyle,\n css`\n #container {\n position: relative;\n }\n\n #sort-bar {\n display: flex;\n justify-content: flex-start;\n align-items: center;\n padding-bottom: 1px;\n border-bottom: 1px solid #2c2c2c;\n font-size: 1.4rem;\n }\n\n #sort-options {\n display: flex;\n align-items: center;\n flex-grow: 1;\n }\n\n ul {\n list-style: none;\n display: flex;\n align-items: center;\n margin: 0;\n padding: 0;\n }\n\n li {\n padding: 0;\n }\n\n .sort-by-text {\n margin-right: 5px;\n font-weight: bold;\n white-space: nowrap;\n }\n\n .sort-direction-container {\n display: flex;\n align-self: stretch;\n flex: 0;\n margin: 0 3px;\n }\n\n .sort-direction-selector {\n display: flex;\n justify-content: center;\n width: 30px;\n margin: 0 5px 0 0;\n padding: 7px 8px;\n max-height: fit-content;\n border-radius: 5px;\n background: white;\n border: 1px solid rgb(25, 72, 128);\n appearance: none;\n cursor: pointer;\n }\n\n .sort-direction-selector:disabled {\n cursor: not-allowed;\n border-color: ${disabledIconColor};\n }\n\n .sort-direction-icon {\n display: flex;\n align-items: center;\n background: none;\n color: inherit;\n border: none;\n padding: 0;\n outline: inherit;\n width: 12px;\n height: 12px;\n }\n\n .sort-direction-icon > svg {\n flex: 1;\n }\n\n #sort-selector-container {\n flex: 1;\n display: flex;\n justify-content: flex-start;\n align-items: center;\n }\n\n #sort-dropdown-container {\n display: flex;\n justify-content: flex-start;\n align-items: center;\n }\n\n #sort-selector-backdrop {\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n z-index: 1;\n background-color: transparent;\n }\n\n #display-style-selector {\n flex: 0;\n }\n\n #display-style-selector button {\n background: none;\n color: inherit;\n border: none;\n appearance: none;\n cursor: pointer;\n -webkit-appearance: none;\n fill: ${disabledIconColor};\n }\n\n #display-style-selector button.active {\n fill: var(--ia-theme-primary-text-color, #2c2c2c);\n }\n\n #display-style-selector button svg {\n width: 24px;\n height: 24px;\n }\n\n ia-dropdown {\n --dropdownTextColor: white;\n --dropdownOffsetTop: 0;\n --dropdownBorderTopWidth: 0;\n --dropdownBorderTopLeftRadius: 0;\n --dropdownBorderTopRightRadius: 0;\n --dropdownWhiteSpace: nowrap;\n --dropdownListZIndex: 2;\n --dropdownCaretColor: var(--ia-theme-primary-text-color, #2c2c2c);\n --dropdownSelectedTextColor: white;\n --dropdownSelectedBgColor: rgba(255, 255, 255, 0.3);\n --dropdownHoverBgColor: rgba(255, 255, 255, 0.3);\n --caretHeight: 9px;\n --caretWidth: 12px;\n --caretPadding: 0 5px 0 0;\n }\n ia-dropdown.selected .dropdown-label {\n font-weight: bold;\n }\n ia-dropdown.open {\n z-index: 2;\n }\n\n .dropdown-label {\n display: inline-block;\n height: 100%;\n padding-left: 5px;\n font-size: 1.4rem;\n font-family: var(--ia-theme-base-font-family);\n line-height: 2;\n color: var(--ia-theme-primary-text-color, #2c2c2c);\n white-space: nowrap;\n user-select: none;\n }\n `,\n ];\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"sort-filter-bar.js","sourceRoot":"","sources":["../../../src/sort-filter-bar/sort-filter-bar.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,UAAU,EACV,IAAI,EACJ,GAAG,EACH,OAAO,GAGR,MAAM,KAAK,CAAC;AACb,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAGzC,OAAO,EAEL,uBAAuB,EAGvB,YAAY,EACZ,SAAS,GAEV,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,OAAO,8BAA8B,CAAC;AACtC,OAAO,aAAa,CAAC;AAKd,IAAM,aAAa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AAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;mDAA6C;AAG5C;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;0DAA2C;AAG1C;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4DAA6C;AAe5C;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4DAAiD;AAGhC;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;4DACnC;AAIR;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;2DACL;AAGV;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;2DAGzB;AAMO;IAAR,KAAK,EAAE;2DAAmD;AAMlD;IAAR,KAAK,EAAE;8DAAiC;AAIjC;IADP,KAAK,CAAC,gBAAgB,CAAC;0DACiB;AApE9B,aAAa;IADzB,aAAa,CAAC,iBAAiB,CAAC;GACpB,aAAa,CA0sBzB","sourcesContent":["import {\n LitElement,\n html,\n css,\n nothing,\n PropertyValues,\n TemplateResult,\n} from 'lit';\nimport { customElement, property, query, state } from 'lit/decorators.js';\nimport { msg, str } from '@lit/localize';\nimport type { IaDropdown, optionInterface } from '@internetarchive/ia-dropdown';\nimport type { SortDirection } from '@internetarchive/search-service';\nimport {\n CollectionDisplayMode,\n defaultSortAvailability,\n PrefixFilterCounts,\n PrefixFilterType,\n SORT_OPTIONS,\n SortField,\n SortOption,\n} from '../models';\n\nimport { sortUpIcon } from './img/sort-toggle-up';\nimport { sortDownIcon } from './img/sort-toggle-down';\nimport { sortDisabledIcon } from './img/sort-toggle-disabled';\nimport { tileIcon } from './img/tile';\nimport { listIcon } from './img/list';\nimport { compactIcon } from './img/compact';\nimport { srOnlyStyle } from '../styles/sr-only';\n\nimport '@internetarchive/ia-dropdown';\nimport './alpha-bar';\n\ntype AlphaSelector = 'creator' | 'title';\n\n@customElement('sort-filter-bar')\nexport class SortFilterBar extends LitElement {\n /** Which display mode the tiles are being rendered with (grid/list-detail/list-compact) */\n @property({ type: String }) displayMode?: CollectionDisplayMode;\n\n /** The default sort direction to use if none is set */\n @property({ type: String }) defaultSortDirection: SortDirection | null = null;\n\n /** The default sort field to use if none is set */\n @property({ type: String }) defaultSortField: Exclude<\n SortField,\n SortField.default\n > = SortField.relevance;\n\n /** The current sort direction (asc/desc), or null if none is set */\n @property({ type: String }) sortDirection: SortDirection | null = null;\n\n /** The field currently being sorted on (e.g., 'title'). Defaults to relevance. */\n @property({ type: String }) selectedSort: SortField = SortField.default;\n\n /** The currently selected title letter filter, or null if none is set */\n @property({ type: String }) selectedTitleFilter: string | null = null;\n\n /** The currently selected creator letter filter, or null if none is set */\n @property({ type: String }) selectedCreatorFilter: string | null = null;\n\n /**\n * Map defining which sortable fields should be included on the sort bar.\n *\n * E.g.,\n * ```\n * {\n * [SortField.relevance]: true,\n * [SortField.date]: false,\n * [SortField.title]: true,\n * ...\n * }\n * ```\n */\n @property({ type: Object }) sortFieldAvailability = defaultSortAvailability;\n\n /** Whether to replace the default sort options with a slot for customization (default `false`) */\n @property({ type: Boolean, reflect: true }) enableSortOptionsSlot: boolean =\n false;\n\n /** Whether to suppress showing the three display mode options on the right of the bar (default `false`) */\n @property({ type: Boolean, reflect: true })\n suppressDisplayModes: boolean = false;\n\n /** Maps of result counts for letters on the alphabet bar, for each letter filter type */\n @property({ type: Object }) prefixFilterCountMap?: Record<\n PrefixFilterType,\n PrefixFilterCounts\n >;\n\n /**\n * Which of the alphabet bars (title/creator) should be shown, or null if one\n * should not currently be rendered.\n */\n @state() alphaSelectorVisible: AlphaSelector | null = null;\n\n /**\n * Whether the transparent backdrop to catch clicks outside the dropdown menu\n * should be rendered.\n */\n @state() dropdownBackdropVisible = false;\n\n /** The single, consolidated dropdown component containing all available options */\n @query('#sort-dropdown')\n private sortOptionsDropdown!: IaDropdown;\n\n render() {\n return html`\n <div id=\"container\">\n <div id=\"sort-bar-row\">\n <section id=\"sort-bar\" aria-label=\"Sorting options\">\n <slot name=\"sort-options-left\"></slot>\n <div id=\"sort-options\">\n ${!this.enableSortOptionsSlot\n ? html`\n <div class=\"sort-direction-container\">\n ${this.sortDirectionSelectorTemplate}\n </div>\n <span class=\"sort-by-text\">${msg('Sort by:')}</span>\n <div id=\"sort-selector-container\">\n ${this.sortSelectorTemplate}\n </div>\n `\n : html`<slot name=\"sort-options\"></slot>`}\n </div>\n <slot name=\"sort-options-right\"></slot>\n\n ${this.suppressDisplayModes\n ? nothing\n : html`<div id=\"display-style-selector\">\n ${this.displayOptionTemplate}\n </div>`}\n </section>\n <slot name=\"sort-bar-end\"></slot>\n </div>\n\n ${this.dropdownBackdropVisible ? this.dropdownBackdrop : nothing}\n ${this.alphaBarTemplate}\n </div>\n `;\n }\n\n willUpdate(changed: PropertyValues) {\n if (changed.has('selectedSort') || changed.has('defaultSortField')) {\n // If the sort is changed from its default without a direction set,\n // we adopt the default sort direction for that sort type.\n if (\n this.selectedSort &&\n this.selectedSort !== SortField.default &&\n this.sortDirection === null\n ) {\n const sortOption = SORT_OPTIONS[this.finalizedSortField];\n this.sortDirection = sortOption.defaultSortDirection;\n }\n }\n }\n\n updated(changed: PropertyValues) {\n if (changed.has('displayMode')) {\n this.displayModeChanged();\n }\n\n if (changed.has('selectedTitleFilter') && this.selectedTitleFilter) {\n this.alphaSelectorVisible = 'title';\n }\n\n if (changed.has('selectedCreatorFilter') && this.selectedCreatorFilter) {\n this.alphaSelectorVisible = 'creator';\n }\n\n if (changed.has('dropdownBackdropVisible')) {\n this.setupEscapeListeners();\n }\n }\n\n private setupEscapeListeners() {\n if (this.dropdownBackdropVisible) {\n document.addEventListener(\n 'keydown',\n this.boundSortBarSelectorEscapeListener,\n );\n } else {\n document.removeEventListener(\n 'keydown',\n this.boundSortBarSelectorEscapeListener,\n );\n }\n }\n\n private boundSortBarSelectorEscapeListener = (e: KeyboardEvent) => {\n if (e.key === 'Escape') {\n this.closeDropdown();\n }\n };\n\n /**\n * Template to render the alphabet bar, or `nothing` if it should not be rendered\n * for the current sort\n */\n private get alphaBarTemplate(): TemplateResult | typeof nothing {\n if (!['title', 'creator'].includes(this.selectedSort)) return nothing;\n\n if (this.alphaSelectorVisible === null) {\n if (this.selectedSort === 'creator') return this.creatorSelectorBar;\n if (this.selectedSort === 'title') return this.titleSelectorBar;\n } else {\n return this.alphaSelectorVisible === 'creator'\n ? this.creatorSelectorBar\n : this.titleSelectorBar;\n }\n\n return nothing;\n }\n\n /** Template to render the sort direction toggle button */\n private get sortDirectionSelectorTemplate(): TemplateResult {\n const oppositeSortDirectionReadable =\n this.sortDirection === 'asc' ? msg('descending') : msg('ascending');\n const buttonLabel = this.canChangeSortDirection\n ? msg(str`Change to ${oppositeSortDirectionReadable} sort`)\n : msg('Directions are not available for the current sort option');\n\n return html`\n <button\n class=\"sort-direction-selector\"\n title=${buttonLabel}\n ?disabled=${!this.canChangeSortDirection}\n @click=${this.handleSortDirectionClicked}\n >\n <span class=\"sr-only\">${buttonLabel}</span>\n ${this.sortDirectionIcon}\n </button>\n `;\n }\n\n /** Template to render the sort direction button's icon in the correct current state */\n private get sortDirectionIcon(): TemplateResult {\n // Show a fully disabled icon for sort options without direction support\n if (!this.canChangeSortDirection) {\n return html`<div class=\"sort-direction-icon\">${sortDisabledIcon}</div>`;\n }\n\n // For all other sorts, show the ascending/descending direction\n return html`\n <div class=\"sort-direction-icon\">\n ${this.finalizedSortDirection === 'asc' ? sortUpIcon : sortDownIcon}\n </div>\n `;\n }\n\n /** The template to render all the sort options in a single dropdown */\n private get sortSelectorTemplate() {\n const displayedOptions = Object.values(SORT_OPTIONS).filter(\n opt => opt.shownInSortBar && this.sortFieldAvailability[opt.field],\n );\n\n return html`\n <div id=\"sort-dropdown-container\">\n ${this.getSortDropdown({\n displayName: SORT_OPTIONS[this.finalizedSortField].displayName,\n id: 'sort-dropdown',\n selected: true,\n dropdownOptions: displayedOptions.map(opt =>\n this.getDropdownOption(opt.field),\n ),\n selectedOption: this.finalizedSortField,\n onOptionSelected: this.sortOptionSelected,\n onDropdownClick: () => {\n this.dropdownBackdropVisible = this.sortOptionsDropdown.open;\n this.sortOptionsDropdown.classList.toggle(\n 'open',\n this.sortOptionsDropdown.open,\n );\n },\n })}\n </div>\n `;\n }\n\n /**\n * Generates a dropdown component containing multiple grouped sort options.\n *\n * @param options.displayName The name to use for the dropdown's visible label\n * @param options.id The id to apply to the dropdown element\n * @param options.dropdownOptions An array of option objects used to populate the dropdown\n * @param options.selectedOption The id of the option that should be initially selected\n * @param options.selected A boolean indicating whether this dropdown should use its\n * selected appearance\n * @param options.onOptionSelected A handler for optionSelected events coming from the dropdown\n * @param options.onDropdownClick A handler for click events on the dropdown\n */\n private getSortDropdown(options: {\n displayName: string;\n id: string;\n dropdownOptions: optionInterface[];\n selectedOption?: string;\n selected: boolean;\n onOptionSelected?: (e: CustomEvent<{ option: optionInterface }>) => void;\n onDropdownClick?: (e: PointerEvent) => void;\n }): TemplateResult {\n return html`\n <ia-dropdown\n id=${options.id}\n class=${options.selected ? 'selected' : ''}\n displayCaret\n closeOnSelect\n includeSelectedOption\n .openViaButton=${options.selected}\n .options=${options.dropdownOptions}\n .selectedOption=${options.selectedOption ?? ''}\n @optionSelected=${options.onOptionSelected ?? nothing}\n @click=${options.onDropdownClick ?? nothing}\n >\n <span\n class=\"dropdown-label\"\n slot=\"dropdown-label\"\n data-title=${options.displayName}\n >\n ${options.displayName}\n </span>\n </ia-dropdown>\n `;\n }\n\n /** Generates a single dropdown option object for the given sort field */\n private getDropdownOption(sortField: SortField): optionInterface {\n return {\n id: sortField,\n label: html`\n <span class=\"dropdown-option-label\">\n ${SORT_OPTIONS[sortField].displayName}\n </span>\n `,\n };\n }\n\n /** Handler for when a new sort dropdown option is selected */\n private sortOptionSelected(e: CustomEvent<{ option: optionInterface }>) {\n this.dropdownBackdropVisible = false;\n\n const sortField = e.detail.option.id as SortField;\n this.setSelectedSort(sortField);\n\n this.alphaSelectorVisible = null;\n if (sortField !== 'title' && this.selectedTitleFilter) {\n this.selectedTitleFilter = null;\n this.emitTitleLetterChangedEvent();\n }\n if (sortField !== 'creator' && this.selectedCreatorFilter) {\n this.selectedCreatorFilter = null;\n this.emitCreatorLetterChangedEvent();\n }\n }\n\n /** Template for rendering the three display mode options */\n /** Added data-testid for Playwright testing * */\n private get displayOptionTemplate() {\n return html`\n <ul>\n <li>\n <button\n id=\"grid-button\"\n @click=${() => {\n this.displayMode = 'grid';\n }}\n class=${this.displayMode === 'grid' ? 'active' : ''}\n title=\"Tile view\"\n data-testid=\"grid-button\"\n >\n ${tileIcon}\n </button>\n </li>\n <li>\n <button\n id=\"list-detail-button\"\n @click=${() => {\n this.displayMode = 'list-detail';\n }}\n class=${this.displayMode === 'list-detail' ? 'active' : ''}\n title=\"List view\"\n data-testid=\"list-detail-button\"\n >\n ${listIcon}\n </button>\n </li>\n <li>\n <button\n id=\"list-compact-button\"\n @click=${() => {\n this.displayMode = 'list-compact';\n }}\n class=${this.displayMode === 'list-compact' ? 'active' : ''}\n title=\"Compact list view\"\n data-testid=\"list-compact-button\"\n >\n ${compactIcon}\n </button>\n </li>\n </ul>\n `;\n }\n\n /**\n * Template for rendering the transparent backdrop to capture clicks outside the\n * dropdown menu while it is open.\n */\n private get dropdownBackdrop() {\n return html`\n <div\n id=\"sort-selector-backdrop\"\n @keyup=${this.closeDropdown}\n @click=${this.closeDropdown}\n ></div>\n `;\n }\n\n /** Closes the sorting dropdown component's menus */\n private closeDropdown() {\n this.dropdownBackdropVisible = false;\n\n if (!this.sortOptionsDropdown) return;\n this.sortOptionsDropdown.open = false;\n this.sortOptionsDropdown.classList.remove('open');\n }\n\n setSortDirection(sortDirection: SortDirection) {\n this.sortDirection = sortDirection;\n this.emitSortChangedEvent();\n }\n\n /** Toggles the current sort direction between 'asc' and 'desc' */\n private toggleSortDirection() {\n this.setSortDirection(\n this.finalizedSortDirection === 'desc' ? 'asc' : 'desc',\n );\n }\n\n private handleSortDirectionClicked(): void {\n if (\n !this.sortDirection &&\n this.defaultSortField &&\n this.defaultSortDirection\n ) {\n // When the sort direction is merely defaulted (not set by the user), clicking\n // the toggled button should \"promote\" the default sort to an explicitly-set one\n // and then toggle it as usual.\n this.selectedSort = this.defaultSortField;\n this.sortDirection = this.defaultSortDirection;\n }\n\n this.toggleSortDirection();\n }\n\n setSelectedSort(sort: SortField) {\n this.selectedSort = sort;\n // Apply this field's default sort direction\n const sortOption = SORT_OPTIONS[sort];\n this.sortDirection = sortOption.defaultSortDirection;\n this.emitSortChangedEvent();\n }\n\n /** The current sort field, or the default one if no explicit sort is set */\n private get finalizedSortField(): SortField {\n const resolvedField =\n this.selectedSort === SortField.default\n ? this.defaultSortField\n : this.selectedSort;\n if (this.sortFieldAvailability[resolvedField]) return resolvedField;\n\n // Fall back to the first available sort option shown in the sort bar, if\n // the requested one isn't available\n return this.firstAvailableOption?.field ?? resolvedField;\n }\n\n /** The current sort direction, or the default one if no explicit direction is set */\n private get finalizedSortDirection(): SortDirection | null {\n return this.sortDirection === null\n ? this.defaultSortDirection\n : this.sortDirection;\n }\n\n /** The first option shown in the sort dropdown, or undefined if none are available */\n private get firstAvailableOption(): SortOption | undefined {\n return Object.values(SORT_OPTIONS).find(\n opt => opt.shownInSortBar && this.sortFieldAvailability[opt.field],\n );\n }\n\n /** Whether the sort direction button should be enabled for the current sort */\n private get canChangeSortDirection(): boolean {\n return SORT_OPTIONS[this.finalizedSortField].canSetDirection;\n }\n\n private get titleSelectorBar() {\n return html` <alpha-bar\n .selectedLetter=${this.selectedTitleFilter}\n .letterCounts=${this.prefixFilterCountMap?.title}\n ariaLandmarkLabel=\"Filter by title letter\"\n @letterChanged=${this.titleLetterChanged}\n ></alpha-bar>`;\n }\n\n private get creatorSelectorBar() {\n return html` <alpha-bar\n .selectedLetter=${this.selectedCreatorFilter}\n .letterCounts=${this.prefixFilterCountMap?.creator}\n ariaLandmarkLabel=\"Filter by creator letter\"\n @letterChanged=${this.creatorLetterChanged}\n ></alpha-bar>`;\n }\n\n private titleLetterChanged(\n e: CustomEvent<{ selectedLetter: string | undefined }>,\n ) {\n this.selectedTitleFilter = e.detail.selectedLetter ?? null;\n this.emitTitleLetterChangedEvent();\n }\n\n private creatorLetterChanged(\n e: CustomEvent<{ selectedLetter: string | undefined }>,\n ) {\n this.selectedCreatorFilter = e.detail.selectedLetter ?? null;\n this.emitCreatorLetterChangedEvent();\n }\n\n private emitTitleLetterChangedEvent() {\n const event = new CustomEvent<{ selectedLetter: string | null }>(\n 'titleLetterChanged',\n {\n detail: { selectedLetter: this.selectedTitleFilter },\n },\n );\n this.dispatchEvent(event);\n }\n\n private emitCreatorLetterChangedEvent() {\n const event = new CustomEvent<{ selectedLetter: string | null }>(\n 'creatorLetterChanged',\n {\n detail: { selectedLetter: this.selectedCreatorFilter },\n },\n );\n this.dispatchEvent(event);\n }\n\n private displayModeChanged() {\n const event = new CustomEvent<{\n displayMode?: CollectionDisplayMode;\n }>('displayModeChanged', {\n detail: { displayMode: this.displayMode },\n });\n this.dispatchEvent(event);\n }\n\n private emitSortChangedEvent() {\n const event = new CustomEvent<{\n selectedSort: SortField;\n sortDirection: SortDirection | null;\n }>('sortChanged', {\n detail: {\n selectedSort: this.selectedSort,\n sortDirection: this.sortDirection,\n },\n });\n this.dispatchEvent(event);\n }\n\n static get styles() {\n const disabledIconColor = css`#bbbbbb`;\n\n return [\n srOnlyStyle,\n css`\n #container {\n position: relative;\n }\n\n /*\n * The sort-bar-end slot shares this row with the sort bar but sits\n * outside its \"Sorting options\" landmark. When the slotted content\n * doesn't fit beside the sort controls, it wraps onto its own line at\n * the right rather than overflowing the row.\n */\n #sort-bar-row {\n display: flex;\n flex-wrap: wrap;\n justify-content: flex-end;\n align-items: center;\n padding-bottom: 1px;\n border-bottom: 1px solid #2c2c2c;\n font-size: 1.4rem;\n }\n\n #sort-bar {\n flex: auto;\n min-width: 0;\n display: flex;\n justify-content: flex-start;\n align-items: center;\n }\n\n #sort-options {\n display: flex;\n align-items: center;\n flex-grow: 1;\n }\n\n ul {\n list-style: none;\n display: flex;\n align-items: center;\n margin: 0;\n padding: 0;\n }\n\n li {\n padding: 0;\n }\n\n .sort-by-text {\n margin-right: 5px;\n font-weight: bold;\n white-space: nowrap;\n }\n\n .sort-direction-container {\n display: flex;\n align-self: stretch;\n flex: 0;\n margin: 0 3px;\n }\n\n .sort-direction-selector {\n display: flex;\n justify-content: center;\n width: 30px;\n margin: 0 5px 0 0;\n padding: 7px 8px;\n max-height: fit-content;\n border-radius: 5px;\n background: white;\n border: 1px solid rgb(25, 72, 128);\n appearance: none;\n cursor: pointer;\n }\n\n .sort-direction-selector:disabled {\n cursor: not-allowed;\n border-color: ${disabledIconColor};\n }\n\n .sort-direction-icon {\n display: flex;\n align-items: center;\n background: none;\n color: inherit;\n border: none;\n padding: 0;\n outline: inherit;\n width: 12px;\n height: 12px;\n }\n\n .sort-direction-icon > svg {\n flex: 1;\n }\n\n #sort-selector-container {\n flex: 1;\n display: flex;\n justify-content: flex-start;\n align-items: center;\n }\n\n #sort-dropdown-container {\n display: flex;\n justify-content: flex-start;\n align-items: center;\n }\n\n #sort-selector-backdrop {\n position: fixed;\n top: 0;\n left: 0;\n width: 100vw;\n height: 100vh;\n z-index: 1;\n background-color: transparent;\n }\n\n #display-style-selector {\n flex: 0;\n }\n\n #display-style-selector button {\n background: none;\n color: inherit;\n border: none;\n appearance: none;\n cursor: pointer;\n -webkit-appearance: none;\n fill: ${disabledIconColor};\n }\n\n #display-style-selector button.active {\n fill: var(--ia-theme-primary-text-color, #2c2c2c);\n }\n\n #display-style-selector button svg {\n width: 24px;\n height: 24px;\n }\n\n ia-dropdown {\n --dropdownTextColor: white;\n --dropdownOffsetTop: 0;\n --dropdownBorderTopWidth: 0;\n --dropdownBorderTopLeftRadius: 0;\n --dropdownBorderTopRightRadius: 0;\n --dropdownWhiteSpace: nowrap;\n --dropdownListZIndex: 2;\n --dropdownCaretColor: var(--ia-theme-primary-text-color, #2c2c2c);\n --dropdownSelectedTextColor: white;\n --dropdownSelectedBgColor: rgba(255, 255, 255, 0.3);\n --dropdownHoverBgColor: rgba(255, 255, 255, 0.3);\n --caretHeight: 9px;\n --caretWidth: 12px;\n --caretPadding: 0 5px 0 0;\n }\n ia-dropdown.selected .dropdown-label {\n font-weight: bold;\n }\n ia-dropdown.open {\n z-index: 2;\n }\n\n .dropdown-label {\n display: inline-block;\n height: 100%;\n padding-left: 5px;\n font-size: 1.4rem;\n font-family: var(--ia-theme-base-font-family);\n line-height: 2;\n color: var(--ia-theme-primary-text-color, #2c2c2c);\n white-space: nowrap;\n user-select: none;\n }\n `,\n ];\n }\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { css, html, nothing } from 'lit';
|
|
3
3
|
import { customElement, property } from 'lit/decorators.js';
|
|
4
|
-
import {
|
|
4
|
+
import { msg } from '@lit/localize';
|
|
5
5
|
import { BaseTileComponent } from '../base-tile-component';
|
|
6
6
|
import { baseTileStyles } from './styles/tile-grid-shared-styles';
|
|
7
7
|
import '../image-block';
|
|
@@ -103,8 +103,7 @@ __decorate([
|
|
|
103
103
|
property({ type: Boolean })
|
|
104
104
|
], AccountTile.prototype, "showInfoButton", void 0);
|
|
105
105
|
AccountTile = __decorate([
|
|
106
|
-
customElement('account-tile')
|
|
107
|
-
localized()
|
|
106
|
+
customElement('account-tile')
|
|
108
107
|
], AccountTile);
|
|
109
108
|
export { AccountTile };
|
|
110
109
|
//# sourceMappingURL=account-tile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account-tile.js","sourceRoot":"","sources":["../../../../src/tiles/grid/account-tile.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAkB,MAAM,KAAK,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,QAAQ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;mBACI,IAAI,CAAC,KAAK,EAAE,SAAS;mBACrB,IAAI,CAAC,KAAK,EAAE,SAAS;kBACtB,IAAI,CAAC,KAAK,EAAE,QAAQ;sBAChB,IAAI,CAAC,KAAK,EAAE,YAAY;;kBAE5B,CAAC;IACjB,CAAC;IAED,IAAY,kBAAkB;QAC5B,iCAAiC;QACjC,OAAO,IAAI,CAAC,cAAc;YACxB,CAAC,CAAC,IAAI,CAAA,sCAAsC,IAAI,CAAC,iBAAiB;;kCAEtC,GAAG,CAAC,WAAW,CAAC;kBAChC;YACZ,CAAC,CAAC,OAAO,CAAC;IACd,CAAC;IAEO,iBAAiB,CAAC,CAAe;QACvC,CAAC,CAAC,cAAc,EAAE,CAAC;QACnB,MAAM,KAAK,GAAG,IAAI,WAAW,CAC3B,mBAAmB,EACnB,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,CAC3C,CAAC;QACF,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,MAAM,KAAK,MAAM;QACf,MAAM,eAAe,GAAG,GAAG,CAAA,iCAAiC,CAAC;QAE7D,OAAO;YACL,cAAc;YACd,GAAG,CAAA;;8BAEqB,eAAe;;OAEtC;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AArF8B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;mDAAwB;AAjBzC,WAAW;IADvB,aAAa,CAAC,cAAc,CAAC;GACjB,WAAW,CAsGvB","sourcesContent":["import { css, html, nothing, TemplateResult } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { msg } from '@lit/localize';\nimport { BaseTileComponent } from '../base-tile-component';\n\nimport { baseTileStyles } from './styles/tile-grid-shared-styles';\nimport '../image-block';\nimport './tile-stats';\n\n@customElement('account-tile')\nexport class AccountTile extends BaseTileComponent {\n /*\n * Reactive properties inherited from BaseTileComponent:\n * - model?: TileModel;\n * - currentWidth?: number;\n * - currentHeight?: number;\n * - baseNavigationUrl?: string;\n * - baseImageUrl?: string;\n * - collectionPagePath?: string;\n * - sortParam: SortParam | null = null;\n * - creatorFilter?: string;\n * - mobileBreakpoint?: number;\n * - loggedIn = false;\n * - suppressBlurring = false;\n * - useLocalTime = false;\n */\n\n @property({ type: Boolean }) showInfoButton = false;\n\n render() {\n return html`\n <div class=\"container\">\n ${this.infoButtonTemplate}\n <div class=\"tile-details\">\n <div class=\"item-info\">\n ${this.getAvatarTemplate} ${this.getTitleTemplate}\n ${this.getArchivistTemplate}\n </div>\n ${this.getTileStatsTemplate}\n </div>\n </div>\n `;\n }\n\n private get getAvatarTemplate(): TemplateResult {\n return html`\n <image-block\n .model=${this.model}\n .baseImageUrl=${this.baseImageUrl}\n .viewSize=${'grid'}\n .suppressBlurring=${this.suppressBlurring}\n >\n </image-block>\n `;\n }\n\n private get getTitleTemplate() {\n return html`<div id=\"title\">\n <h4 class=\"truncated\">${this.model?.identifier}</h4>\n </div>`;\n }\n\n private get getArchivistTemplate() {\n return html`<div class=\"archivist-since\">\n <span>${this.displayValueProvider.accountLabel}</span>\n </div>`;\n }\n\n private get getTileStatsTemplate() {\n return html`<tile-stats\n .mediatype=${this.model?.mediatype}\n .itemCount=${this.model?.itemCount}\n .favCount=${this.model?.favCount}\n .commentCount=${this.model?.commentCount}\n >\n </tile-stats>`;\n }\n\n private get infoButtonTemplate(): TemplateResult | typeof nothing {\n // ⓘ is an information icon\n return this.showInfoButton\n ? html`<button class=\"info-button\" @click=${this.infoButtonPressed}>\n ⓘ\n <span class=\"sr-only\">${msg('More info')}</span>\n </button>`\n : nothing;\n }\n\n private infoButtonPressed(e: PointerEvent) {\n e.preventDefault();\n const event = new CustomEvent<{ x: number; y: number }>(\n 'infoButtonPressed',\n { detail: { x: e.clientX, y: e.clientY } },\n );\n this.dispatchEvent(event);\n }\n\n /**\n * CSS\n */\n static get styles() {\n const tileBorderColor = css`var(--tileBorderColor, #dddddd)`;\n\n return [\n baseTileStyles,\n css`\n .container {\n border: 1px solid ${tileBorderColor};\n }\n `,\n ];\n }\n}\n"]}
|
|
@@ -2,10 +2,9 @@ import { __decorate } from "tslib";
|
|
|
2
2
|
import { css, html, nothing } from 'lit';
|
|
3
3
|
import { customElement, property } from 'lit/decorators.js';
|
|
4
4
|
import { classMap } from 'lit/directives/class-map.js';
|
|
5
|
-
import {
|
|
5
|
+
import { msg } from '@lit/localize';
|
|
6
6
|
import { collectionIcon } from '../../assets/img/icons/mediatype/collection';
|
|
7
7
|
import { formatUnitSize } from '../../utils/format-unit-size';
|
|
8
|
-
import { getLocale } from '../../utils/get-locale';
|
|
9
8
|
import { baseTileStyles } from './styles/tile-grid-shared-styles';
|
|
10
9
|
import { BaseTileComponent } from '../base-tile-component';
|
|
11
10
|
import '../image-block';
|
|
@@ -76,14 +75,10 @@ let CollectionTile = class CollectionTile extends BaseTileComponent {
|
|
|
76
75
|
`;
|
|
77
76
|
}
|
|
78
77
|
get getItemsTemplate() {
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const itemsLabel = itemCount === 1
|
|
84
|
-
? msg(str `${formattedCount} item`)
|
|
85
|
-
: msg(str `${formattedCount} items`);
|
|
86
|
-
return html `<span id="item-count">${itemsLabel}</span>`;
|
|
78
|
+
const collectionItems = this.model?.itemCount?.toLocaleString();
|
|
79
|
+
return html `<span id="item-count"
|
|
80
|
+
>${collectionItems} item${Number(collectionItems) !== 1 ? 's' : ''}</span
|
|
81
|
+
>`;
|
|
87
82
|
}
|
|
88
83
|
get getSizeTemplate() {
|
|
89
84
|
const collectionSize = this.model?.collectionSize ?? 0;
|
|
@@ -177,8 +172,7 @@ __decorate([
|
|
|
177
172
|
property({ type: String })
|
|
178
173
|
], CollectionTile.prototype, "layoutType", void 0);
|
|
179
174
|
CollectionTile = __decorate([
|
|
180
|
-
customElement('collection-tile')
|
|
181
|
-
localized()
|
|
175
|
+
customElement('collection-tile')
|
|
182
176
|
], CollectionTile);
|
|
183
177
|
export { CollectionTile };
|
|
184
178
|
//# sourceMappingURL=collection-tile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collection-tile.js","sourceRoot":"","sources":["../../../../src/tiles/grid/collection-tile.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAkB,IAAI,EAAE,OAAO,EAAkB,MAAM,KAAK,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"collection-tile.js","sourceRoot":"","sources":["../../../../src/tiles/grid/collection-tile.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAkB,IAAI,EAAE,OAAO,EAAkB,MAAM,KAAK,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,6CAA6C,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,gBAAgB,CAAC;AAGjB,IAAM,cAAc,GAApB,MAAM,cAAe,SAAQ,iBAAiB;IAA9C;QACL;;;;;;;;;;;;;;WAcG;;QAE0B,mBAAc,GAAG,KAAK,CAAC;QAExB,eAAU,GAAe,SAAS,CAAC;IAwJjE,CAAC;IAtJC,MAAM;QACJ,MAAM,gBAAgB,GAAG,QAAQ,CAAC;YAChC,SAAS,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CAAA,sCAAsC,IAAI,CAAC,iBAAiB;;kCAEtC,GAAG,CAAC,WAAW,CAAC;kBAChC;YACZ,CAAC,CAAC,OAAO,CAAC;IACd,CAAC;IAEO,iBAAiB,CAAC,CAAe;QACvC,CAAC,CAAC,cAAc,EAAE,CAAC;QACnB,MAAM,KAAK,GAAG,IAAI,WAAW,CAC3B,mBAAmB,EACnB,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,CAC3C,CAAC;QACF,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED,MAAM,KAAK,MAAM;QACf,MAAM,eAAe,GAAG,GAAG,CAAA,iCAAiC,CAAC;QAC7D,MAAM,mBAAmB,GAAG,GAAG,CAAA,qCAAqC,CAAC;QACrE,MAAM,UAAU,GAAG,GAAG,CAAA,MAAM,CAAC;QAE7B,OAAO;YACL,cAAc;YACd,GAAG,CAAA;;8BAEqB,mBAAmB;8BACnB,eAAe;;;;;;;;;mBAS1B,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;mBA2BV,UAAU;;;;;;;;;;;;;;;;OAgBtB;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AA1J8B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;sDAAwB;AAExB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;kDAAoC;AAnBpD,cAAc;IAD1B,aAAa,CAAC,iBAAiB,CAAC;GACpB,cAAc,CA2K1B","sourcesContent":["import { css, CSSResultGroup, html, nothing, TemplateResult } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { msg } from '@lit/localize';\nimport { collectionIcon } from '../../assets/img/icons/mediatype/collection';\nimport { formatUnitSize } from '../../utils/format-unit-size';\nimport { baseTileStyles } from './styles/tile-grid-shared-styles';\nimport { BaseTileComponent } from '../base-tile-component';\nimport { LayoutType } from '../models';\nimport '../image-block';\n\n@customElement('collection-tile')\nexport class CollectionTile extends BaseTileComponent {\n /*\n * Reactive properties inherited from BaseTileComponent:\n * - model?: TileModel;\n * - currentWidth?: number;\n * - currentHeight?: number;\n * - baseNavigationUrl?: string;\n * - baseImageUrl?: string;\n * - collectionPagePath?: string;\n * - sortParam: SortParam | null = null;\n * - creatorFilter?: string;\n * - mobileBreakpoint?: number;\n * - loggedIn = false;\n * - suppressBlurring = false;\n * - useLocalTime = false;\n */\n\n @property({ type: Boolean }) showInfoButton = false;\n\n @property({ type: String }) layoutType: LayoutType = 'default';\n\n render() {\n const containerClasses = classMap({\n container: true,\n minimal: this.layoutType === 'minimal',\n });\n\n return html`\n <div class=${containerClasses}>\n ${this.infoButtonTemplate}\n <div class=\"tile-details\">\n <div class=\"item-info\">\n ${this.getImageBlockTemplate} ${this.getTitleTemplate}\n </div>\n </div>\n\n ${this.getTileStatsTemplate}\n </div>\n `;\n }\n\n private get getImageBlockTemplate(): TemplateResult {\n return html`\n <image-block\n .model=${this.model}\n .baseImageUrl=${this.baseImageUrl}\n .viewSize=${'grid'}\n .suppressBlurring=${this.suppressBlurring}\n >\n </image-block>\n `;\n }\n\n private get getTitleTemplate() {\n return html`<div id=\"title\">\n <h3 class=\"truncated\">${this.model?.title}</h3>\n </div>`;\n }\n\n private get getTileStatsTemplate() {\n return html`\n <div id=\"item-stats\">\n <div id=\"item-mediatype\">${collectionIcon}</div>\n\n <div id=\"stats-row\">\n ${this.getItemsTemplate} ${this.getSizeTemplate}\n </div>\n </div>\n `;\n }\n\n private get getItemsTemplate() {\n const collectionItems = this.model?.itemCount?.toLocaleString();\n\n return html`<span id=\"item-count\"\n >${collectionItems} item${Number(collectionItems) !== 1 ? 's' : ''}</span\n >`;\n }\n\n private get getSizeTemplate() {\n const collectionSize = this.model?.collectionSize ?? 0;\n\n return collectionSize\n ? html`<span id=\"item-size\">${formatUnitSize(collectionSize, 1)}</span>`\n : ``;\n }\n\n private get infoButtonTemplate(): TemplateResult | typeof nothing {\n // ⓘ is an information icon\n return this.showInfoButton\n ? html`<button class=\"info-button\" @click=${this.infoButtonPressed}>\n ⓘ\n <span class=\"sr-only\">${msg('More info')}</span>\n </button>`\n : nothing;\n }\n\n private infoButtonPressed(e: PointerEvent) {\n e.preventDefault();\n const event = new CustomEvent<{ x: number; y: number }>(\n 'infoButtonPressed',\n { detail: { x: e.clientX, y: e.clientY } },\n );\n this.dispatchEvent(event);\n }\n\n static get styles(): CSSResultGroup {\n const tileBorderColor = css`var(--tileBorderColor, #555555)`;\n const tileBackgroundColor = css`var(--tileBackgroundColor, #666666)`;\n const whiteColor = css`#fff`;\n\n return [\n baseTileStyles,\n css`\n .container {\n background-color: ${tileBackgroundColor};\n border: 1px solid ${tileBorderColor};\n }\n\n .item-info {\n flex-grow: initial;\n }\n\n h4.truncated,\n h3.truncated {\n color: ${whiteColor};\n }\n\n #item-mediatype svg {\n filter: invert(100%);\n height: 2.5rem;\n align-items: baseline;\n }\n\n .container:hover > #title {\n text-decoration: underline;\n }\n\n /* this is a workaround for Safari 15 where the hover effects are not working */\n image-block:hover > #title {\n text-decoration: underline;\n }\n\n #item-stats {\n display: flex;\n padding: 0 5px 5px;\n align-items: center;\n }\n\n #stats-row {\n display: flex;\n align-items: baseline;\n color: ${whiteColor};\n flex-direction: column;\n margin-left: 10px;\n }\n\n .minimal #item-stats {\n display: none;\n }\n\n .minimal .truncated {\n -webkit-line-clamp: initial;\n }\n\n .minimal .item-info {\n padding-bottom: 5px;\n }\n `,\n ];\n }\n}\n"]}
|
|
@@ -4,7 +4,7 @@ import { customElement, property } from 'lit/decorators.js';
|
|
|
4
4
|
import { ifDefined } from 'lit/directives/if-defined.js';
|
|
5
5
|
import { map } from 'lit/directives/map.js';
|
|
6
6
|
import { classMap } from 'lit/directives/class-map.js';
|
|
7
|
-
import {
|
|
7
|
+
import { msg } from '@lit/localize';
|
|
8
8
|
import { isFirstMillisecondOfUTCYear } from '../../utils/local-date-from-utc';
|
|
9
9
|
import { BaseTileComponent } from '../base-tile-component';
|
|
10
10
|
import { baseTileStyles } from './styles/tile-grid-shared-styles';
|
|
@@ -83,7 +83,7 @@ let ItemTile = class ItemTile extends BaseTileComponent {
|
|
|
83
83
|
return html `
|
|
84
84
|
<div class="created-by">
|
|
85
85
|
<span class="truncated" title=${displayedCreator}>
|
|
86
|
-
|
|
86
|
+
by ${displayedCreator}
|
|
87
87
|
</span>
|
|
88
88
|
</div>
|
|
89
89
|
`;
|
|
@@ -175,8 +175,8 @@ let ItemTile = class ItemTile extends BaseTileComponent {
|
|
|
175
175
|
return nothing;
|
|
176
176
|
return html `
|
|
177
177
|
<div class="volume-issue">
|
|
178
|
-
<span class="truncated" title
|
|
179
|
-
|
|
178
|
+
<span class="truncated" title="volume|issue">
|
|
179
|
+
Volume ${this.model?.volume}, Issue ${this.model?.issue}
|
|
180
180
|
</span>
|
|
181
181
|
</div>
|
|
182
182
|
`;
|
|
@@ -201,8 +201,8 @@ let ItemTile = class ItemTile extends BaseTileComponent {
|
|
|
201
201
|
}
|
|
202
202
|
const effectiveSort = this.sortParam ?? this.defaultSortParam;
|
|
203
203
|
const [viewCount, viewLabel] = effectiveSort?.field === 'week'
|
|
204
|
-
? [this.model?.weeklyViewCount,
|
|
205
|
-
: [this.model?.viewCount,
|
|
204
|
+
? [this.model?.weeklyViewCount, 'weekly views']
|
|
205
|
+
: [this.model?.viewCount, 'all-time views'];
|
|
206
206
|
return html `
|
|
207
207
|
<tile-stats
|
|
208
208
|
.model=${this.model}
|
|
@@ -312,8 +312,7 @@ __decorate([
|
|
|
312
312
|
property({ type: String })
|
|
313
313
|
], ItemTile.prototype, "layoutType", void 0);
|
|
314
314
|
ItemTile = __decorate([
|
|
315
|
-
customElement('item-tile')
|
|
316
|
-
localized()
|
|
315
|
+
customElement('item-tile')
|
|
317
316
|
], ItemTile);
|
|
318
317
|
export { ItemTile };
|
|
319
318
|
//#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B,MAAM,KAAK,GAAG,IAAI,WAAW,CAC3B,mBAAmB,EACnB,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,CAC3C,CAAC;QACF,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,MAAM,KAAK,MAAM;QACf,MAAM,eAAe,GAAG,GAAG,CAAA,iCAAiC,CAAC;QAE7D,OAAO;YACL,cAAc;YACd,GAAG,CAAA;;;;;;;;;;8BAUqB,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA+CtC;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AAnT8B;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;gDAAwB;AAEvB;IAA5B,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;6CAAqB;AAErB;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;4CAAoC;AAvBpD,QAAQ;IAFpB,aAAa,CAAC,WAAW,CAAC;IAC1B,SAAS,EAAE;GACC,QAAQ,CAsUpB","sourcesContent":["import { css, CSSResultGroup, html, nothing, TemplateResult } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { map } from 'lit/directives/map.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { localized, msg, str } from '@lit/localize';\n\nimport type { SortParam } from '@internetarchive/search-service';\nimport type { DateFormat } from '../../utils/format-date';\nimport { isFirstMillisecondOfUTCYear } from '../../utils/local-date-from-utc';\nimport { BaseTileComponent } from '../base-tile-component';\nimport { baseTileStyles } from './styles/tile-grid-shared-styles';\nimport { LayoutType } from '../models';\n\nimport '../image-block';\nimport '../review-block';\nimport '../text-snippet-block';\nimport '../item-image';\nimport '../tile-mediatype-icon';\nimport './tile-stats';\n\n@customElement('item-tile')\n@localized()\nexport class ItemTile extends BaseTileComponent {\n /*\n * Reactive properties inherited from BaseTileComponent:\n * - model?: TileModel;\n * - tileActions: TileAction[] = [];\n * - currentWidth?: number;\n * - currentHeight?: number;\n * - baseNavigationUrl?: string;\n * - baseImageUrl?: string;\n * - collectionPagePath?: string;\n * - sortParam: SortParam | null = null;\n * - defaultSortParam: SortParam | null = null;\n * - creatorFilter?: string;\n * - mobileBreakpoint?: number;\n * - loggedIn = false;\n * - suppressBlurring = false;\n * - useLocalTime = false;\n */\n\n @property({ type: Boolean }) showInfoButton = false;\n\n @property({ type: Boolean }) showTvClips = false;\n\n @property({ type: String }) layoutType: LayoutType = 'default';\n\n render() {\n const itemTitle = this.model?.title;\n const containerClasses = classMap({\n container: true,\n simple: this.layoutType !== 'default',\n 'stats-only': this.layoutType === 'stats-only',\n 'snippets-only': this.layoutType === 'snippets-only',\n minimal: this.layoutType === 'minimal',\n });\n\n return html`\n <div class=${containerClasses}>\n ${this.infoButtonTemplate}\n <div class=\"tile-details\">\n <div class=\"item-info\">\n ${this.imageBlockTemplate}\n\n <div id=\"title\">\n <h3 class=\"truncated\" title=${ifDefined(itemTitle)}>\n ${itemTitle}\n </h3>\n </div>\n\n ${this.volumeIssueTemplate}\n ${this.isSortedByDate\n ? this.sortedDateInfoTemplate\n : this.creatorTemplate}\n ${this.webArchivesCaptureDatesTemplate} ${this.textSnippetsTemplate}\n ${this.reviewBlockTemplate}\n </div>\n\n ${this.tileStatsTemplate}\n </div>\n </div>\n `;\n }\n\n /**\n * Templates\n */\n private get creatorTemplate(): TemplateResult | typeof nothing {\n const displayedCreator =\n this.displayValueProvider.firstCreatorMatchingFilter;\n if (!displayedCreator) return nothing;\n\n return html`\n <div class=\"created-by\">\n <span class=\"truncated\" title=${displayedCreator}>\n ${msg(str`by\\u00a0${displayedCreator}`)}\n </span>\n </div>\n `;\n }\n\n private get imageBlockTemplate(): TemplateResult {\n return html`\n <image-block\n .model=${this.model}\n .baseImageUrl=${this.baseImageUrl}\n .loggedIn=${this.loggedIn}\n .suppressBlurring=${this.suppressBlurring}\n .isCompactTile=${false}\n .isListTile=${false}\n .viewSize=${'grid'}\n >\n </image-block>\n `;\n }\n\n private get sortedDateInfoTemplate() {\n let sortedValue;\n let format: DateFormat = 'long';\n switch (this.effectiveSort?.field) {\n case 'date': {\n const datePublished = this.model?.datePublished;\n sortedValue = { field: 'published', value: datePublished };\n if (isFirstMillisecondOfUTCYear(datePublished)) {\n format = 'year-only';\n }\n break;\n }\n case 'reviewdate':\n sortedValue = { field: 'reviewed', value: this.model?.dateReviewed };\n break;\n case 'addeddate':\n sortedValue = { field: 'added', value: this.model?.dateAdded };\n break;\n case 'publicdate':\n sortedValue = { field: 'archived', value: this.model?.dateArchived };\n break;\n default:\n break;\n }\n\n if (!sortedValue?.value) {\n return nothing;\n }\n\n const formattedDate = this.getFormattedDate(sortedValue.value, format);\n return html`\n <div class=\"date-sorted-by truncated\">\n <span>${sortedValue.field} ${formattedDate}</span>\n </div>\n `;\n }\n\n private get infoButtonTemplate(): TemplateResult | typeof nothing {\n // ⓘ is an information icon\n return this.showInfoButton\n ? html`<button class=\"info-button\" @click=${this.infoButtonPressed}>\n ⓘ\n <span class=\"sr-only\">${msg('More info')}</span>\n </button>`\n : nothing;\n }\n\n private get reviewBlockTemplate(): TemplateResult | typeof nothing {\n if (!this.model?.review) return nothing;\n\n const { reviewtitle, reviewbody, stars } = this.model.review;\n return html`\n <review-block\n viewsize=\"grid\"\n title=${ifDefined(reviewtitle)}\n body=${ifDefined(reviewbody)}\n starRating=${ifDefined(stars)}\n >\n </review-block>\n `;\n }\n\n private get textSnippetsTemplate(): TemplateResult | typeof nothing {\n if (!this.hasSnippets) return nothing;\n if (['stats-only', 'minimal'].includes(this.layoutType)) {\n return nothing;\n }\n\n return html`\n <text-snippet-block viewsize=\"grid\" .snippets=${this.model?.snippets}>\n </text-snippet-block>\n `;\n }\n\n private get volumeIssueTemplate(): TemplateResult | typeof nothing {\n if (!this.model?.volume || !this.model?.issue) return nothing;\n\n return html`\n <div class=\"volume-issue\">\n <span class=\"truncated\" title=${msg('volume|issue')}>\n ${msg(\n str`Volume\\u00a0${this.model.volume}, Issue\\u00a0${this.model.issue}`,\n )}\n </span>\n </div>\n `;\n }\n\n private get webArchivesCaptureDatesTemplate():\n | TemplateResult\n | typeof nothing {\n if (!this.model?.captureDates || !this.model.title) return nothing;\n\n return html`\n <ul class=\"capture-dates\">\n ${map(\n this.model.captureDates,\n date =>\n html`<li>\n ${this.displayValueProvider.webArchivesCaptureLink(\n this.model!.title,\n date,\n )}\n </li>`,\n )}\n </ul>\n `;\n }\n\n /**\n * Template for the stats row along the bottom of the tile.\n */\n private get tileStatsTemplate(): TemplateResult | typeof nothing {\n if (['snippets-only', 'minimal'].includes(this.layoutType)) {\n return nothing;\n }\n\n const effectiveSort = this.sortParam ?? this.defaultSortParam;\n const [viewCount, viewLabel] =\n effectiveSort?.field === 'week'\n ? [this.model?.weeklyViewCount, msg('weekly views')]\n : [this.model?.viewCount, msg('all-time views')];\n\n return html`\n <tile-stats\n .model=${this.model}\n .mediatype=${this.model?.mediatype}\n .viewCount=${viewCount}\n .viewLabel=${viewLabel}\n .favCount=${this.model?.favCount}\n .commentCount=${this.model?.commentCount}\n .tvClipCount=${this.model?.tvClipCount}\n .showTvClips=${this.showTvClips}\n >\n </tile-stats>\n `;\n }\n\n private get isSortedByDate(): boolean {\n return ['date', 'reviewdate', 'addeddate', 'publicdate'].includes(\n this.effectiveSort?.field as string,\n );\n }\n\n /**\n * Returns the active sort param if one is set, or the default sort param otherwise.\n */\n private get effectiveSort(): SortParam | null {\n return this.sortParam ?? this.defaultSortParam;\n }\n\n private get hasSnippets(): boolean {\n return !!this.model?.snippets?.length;\n }\n\n private infoButtonPressed(e: PointerEvent): void {\n e.preventDefault();\n const event = new CustomEvent<{ x: number; y: number }>(\n 'infoButtonPressed',\n { detail: { x: e.clientX, y: e.clientY } },\n );\n this.dispatchEvent(event);\n }\n\n /**\n * CSS\n */\n static get styles(): CSSResultGroup {\n const tileBorderColor = css`var(--tileBorderColor, #dddddd)`;\n\n return [\n baseTileStyles,\n css`\n a:link {\n text-decoration: none;\n color: var(--ia-theme-link-color, #4b64ff);\n }\n a:hover {\n text-decoration: underline;\n }\n\n .container {\n border: 1px solid ${tileBorderColor};\n }\n\n .simple #title > .truncated {\n -webkit-line-clamp: 2;\n }\n\n .simple .created-by > .truncated,\n .simple .date-sorted-by > .truncated,\n .simple .volume-issue > .truncated {\n -webkit-line-clamp: 1;\n }\n\n .simple.snippets-only .item-info,\n .simple.minimal .item-info {\n padding-bottom: 5px;\n }\n\n .simple.snippets-only text-snippet-block {\n margin-top: auto; /* Force the snippets to the bottom of the tile */\n }\n\n .capture-dates {\n margin: 0;\n padding: 0 5px;\n list-style-type: none;\n }\n\n review-block,\n text-snippet-block {\n --containerLeftMargin: 5px;\n --containerTopMargin: 5px;\n }\n\n /**\n * iOS Safari long-press on tiles (to bring up hover pane)\n * gets messy without this\n */\n @media screen and (pointer: coarse) and (hover: none) {\n .container {\n -webkit-touch-callout: none;\n }\n\n .truncated {\n -webkit-touch-callout: default;\n }\n }\n `,\n ];\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"item-tile.js","sourceRoot":"","sources":["../../../../src/tiles/grid/item-tile.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAkB,IAAI,EAAE,OAAO,EAAkB,MAAM,KAAK,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AACzD,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAC5C,OAAO,EAAE,QAAQ,EAAE,MAAM,6BAA6B,CAAC;AACvD,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAIpC,OAAO,EAAE,2BAA2B,EAAE,MAAM,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C;4CAAoC;AAvBpD,QAAQ;IADpB,aAAa,CAAC,WAAW,CAAC;GACd,QAAQ,CAoUpB","sourcesContent":["import { css, CSSResultGroup, html, nothing, TemplateResult } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { ifDefined } from 'lit/directives/if-defined.js';\nimport { map } from 'lit/directives/map.js';\nimport { classMap } from 'lit/directives/class-map.js';\nimport { msg } from '@lit/localize';\n\nimport type { SortParam } from '@internetarchive/search-service';\nimport type { DateFormat } from '../../utils/format-date';\nimport { isFirstMillisecondOfUTCYear } from '../../utils/local-date-from-utc';\nimport { BaseTileComponent } from '../base-tile-component';\nimport { baseTileStyles } from './styles/tile-grid-shared-styles';\nimport { LayoutType } from '../models';\n\nimport '../image-block';\nimport '../review-block';\nimport '../text-snippet-block';\nimport '../item-image';\nimport '../tile-mediatype-icon';\nimport './tile-stats';\n\n@customElement('item-tile')\nexport class ItemTile extends BaseTileComponent {\n /*\n * Reactive properties inherited from BaseTileComponent:\n * - model?: TileModel;\n * - tileActions: TileAction[] = [];\n * - currentWidth?: number;\n * - currentHeight?: number;\n * - baseNavigationUrl?: string;\n * - baseImageUrl?: string;\n * - collectionPagePath?: string;\n * - sortParam: SortParam | null = null;\n * - defaultSortParam: SortParam | null = null;\n * - creatorFilter?: string;\n * - mobileBreakpoint?: number;\n * - loggedIn = false;\n * - suppressBlurring = false;\n * - useLocalTime = false;\n */\n\n @property({ type: Boolean }) showInfoButton = false;\n\n @property({ type: Boolean }) showTvClips = false;\n\n @property({ type: String }) layoutType: LayoutType = 'default';\n\n render() {\n const itemTitle = this.model?.title;\n const containerClasses = classMap({\n container: true,\n simple: this.layoutType !== 'default',\n 'stats-only': this.layoutType === 'stats-only',\n 'snippets-only': this.layoutType === 'snippets-only',\n minimal: this.layoutType === 'minimal',\n });\n\n return html`\n <div class=${containerClasses}>\n ${this.infoButtonTemplate}\n <div class=\"tile-details\">\n <div class=\"item-info\">\n ${this.imageBlockTemplate}\n\n <div id=\"title\">\n <h3 class=\"truncated\" title=${ifDefined(itemTitle)}>\n ${itemTitle}\n </h3>\n </div>\n\n ${this.volumeIssueTemplate}\n ${this.isSortedByDate\n ? this.sortedDateInfoTemplate\n : this.creatorTemplate}\n ${this.webArchivesCaptureDatesTemplate} ${this.textSnippetsTemplate}\n ${this.reviewBlockTemplate}\n </div>\n\n ${this.tileStatsTemplate}\n </div>\n </div>\n `;\n }\n\n /**\n * Templates\n */\n private get creatorTemplate(): TemplateResult | typeof nothing {\n const displayedCreator =\n this.displayValueProvider.firstCreatorMatchingFilter;\n if (!displayedCreator) return nothing;\n\n return html`\n <div class=\"created-by\">\n <span class=\"truncated\" title=${displayedCreator}>\n by ${displayedCreator}\n </span>\n </div>\n `;\n }\n\n private get imageBlockTemplate(): TemplateResult {\n return html`\n <image-block\n .model=${this.model}\n .baseImageUrl=${this.baseImageUrl}\n .loggedIn=${this.loggedIn}\n .suppressBlurring=${this.suppressBlurring}\n .isCompactTile=${false}\n .isListTile=${false}\n .viewSize=${'grid'}\n >\n </image-block>\n `;\n }\n\n private get sortedDateInfoTemplate() {\n let sortedValue;\n let format: DateFormat = 'long';\n switch (this.effectiveSort?.field) {\n case 'date': {\n const datePublished = this.model?.datePublished;\n sortedValue = { field: 'published', value: datePublished };\n if (isFirstMillisecondOfUTCYear(datePublished)) {\n format = 'year-only';\n }\n break;\n }\n case 'reviewdate':\n sortedValue = { field: 'reviewed', value: this.model?.dateReviewed };\n break;\n case 'addeddate':\n sortedValue = { field: 'added', value: this.model?.dateAdded };\n break;\n case 'publicdate':\n sortedValue = { field: 'archived', value: this.model?.dateArchived };\n break;\n default:\n break;\n }\n\n if (!sortedValue?.value) {\n return nothing;\n }\n\n const formattedDate = this.getFormattedDate(sortedValue.value, format);\n return html`\n <div class=\"date-sorted-by truncated\">\n <span>${sortedValue.field} ${formattedDate}</span>\n </div>\n `;\n }\n\n private get infoButtonTemplate(): TemplateResult | typeof nothing {\n // ⓘ is an information icon\n return this.showInfoButton\n ? html`<button class=\"info-button\" @click=${this.infoButtonPressed}>\n ⓘ\n <span class=\"sr-only\">${msg('More info')}</span>\n </button>`\n : nothing;\n }\n\n private get reviewBlockTemplate(): TemplateResult | typeof nothing {\n if (!this.model?.review) return nothing;\n\n const { reviewtitle, reviewbody, stars } = this.model.review;\n return html`\n <review-block\n viewsize=\"grid\"\n title=${ifDefined(reviewtitle)}\n body=${ifDefined(reviewbody)}\n starRating=${ifDefined(stars)}\n >\n </review-block>\n `;\n }\n\n private get textSnippetsTemplate(): TemplateResult | typeof nothing {\n if (!this.hasSnippets) return nothing;\n if (['stats-only', 'minimal'].includes(this.layoutType)) {\n return nothing;\n }\n\n return html`\n <text-snippet-block viewsize=\"grid\" .snippets=${this.model?.snippets}>\n </text-snippet-block>\n `;\n }\n\n private get volumeIssueTemplate(): TemplateResult | typeof nothing {\n if (!this.model?.volume || !this.model?.issue) return nothing;\n\n return html`\n <div class=\"volume-issue\">\n <span class=\"truncated\" title=\"volume|issue\">\n Volume ${this.model?.volume}, Issue ${this.model?.issue}\n </span>\n </div>\n `;\n }\n\n private get webArchivesCaptureDatesTemplate():\n | TemplateResult\n | typeof nothing {\n if (!this.model?.captureDates || !this.model.title) return nothing;\n\n return html`\n <ul class=\"capture-dates\">\n ${map(\n this.model.captureDates,\n date =>\n html`<li>\n ${this.displayValueProvider.webArchivesCaptureLink(\n this.model!.title,\n date,\n )}\n </li>`,\n )}\n </ul>\n `;\n }\n\n /**\n * Template for the stats row along the bottom of the tile.\n */\n private get tileStatsTemplate(): TemplateResult | typeof nothing {\n if (['snippets-only', 'minimal'].includes(this.layoutType)) {\n return nothing;\n }\n\n const effectiveSort = this.sortParam ?? this.defaultSortParam;\n const [viewCount, viewLabel] =\n effectiveSort?.field === 'week'\n ? [this.model?.weeklyViewCount, 'weekly views']\n : [this.model?.viewCount, 'all-time views'];\n\n return html`\n <tile-stats\n .model=${this.model}\n .mediatype=${this.model?.mediatype}\n .viewCount=${viewCount}\n .viewLabel=${viewLabel}\n .favCount=${this.model?.favCount}\n .commentCount=${this.model?.commentCount}\n .tvClipCount=${this.model?.tvClipCount}\n .showTvClips=${this.showTvClips}\n >\n </tile-stats>\n `;\n }\n\n private get isSortedByDate(): boolean {\n return ['date', 'reviewdate', 'addeddate', 'publicdate'].includes(\n this.effectiveSort?.field as string,\n );\n }\n\n /**\n * Returns the active sort param if one is set, or the default sort param otherwise.\n */\n private get effectiveSort(): SortParam | null {\n return this.sortParam ?? this.defaultSortParam;\n }\n\n private get hasSnippets(): boolean {\n return !!this.model?.snippets?.length;\n }\n\n private infoButtonPressed(e: PointerEvent): void {\n e.preventDefault();\n const event = new CustomEvent<{ x: number; y: number }>(\n 'infoButtonPressed',\n { detail: { x: e.clientX, y: e.clientY } },\n );\n this.dispatchEvent(event);\n }\n\n /**\n * CSS\n */\n static get styles(): CSSResultGroup {\n const tileBorderColor = css`var(--tileBorderColor, #dddddd)`;\n\n return [\n baseTileStyles,\n css`\n a:link {\n text-decoration: none;\n color: var(--ia-theme-link-color, #4b64ff);\n }\n a:hover {\n text-decoration: underline;\n }\n\n .container {\n border: 1px solid ${tileBorderColor};\n }\n\n .simple #title > .truncated {\n -webkit-line-clamp: 2;\n }\n\n .simple .created-by > .truncated,\n .simple .date-sorted-by > .truncated,\n .simple .volume-issue > .truncated {\n -webkit-line-clamp: 1;\n }\n\n .simple.snippets-only .item-info,\n .simple.minimal .item-info {\n padding-bottom: 5px;\n }\n\n .simple.snippets-only text-snippet-block {\n margin-top: auto; /* Force the snippets to the bottom of the tile */\n }\n\n .capture-dates {\n margin: 0;\n padding: 0 5px;\n list-style-type: none;\n }\n\n review-block,\n text-snippet-block {\n --containerLeftMargin: 5px;\n --containerTopMargin: 5px;\n }\n\n /**\n * iOS Safari long-press on tiles (to bring up hover pane)\n * gets messy without this\n */\n @media screen and (pointer: coarse) and (hover: none) {\n .container {\n -webkit-touch-callout: none;\n }\n\n .truncated {\n -webkit-touch-callout: default;\n }\n }\n `,\n ];\n }\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __decorate } from "tslib";
|
|
2
2
|
import { css, html, LitElement } from 'lit';
|
|
3
3
|
import { customElement, property } from 'lit/decorators.js';
|
|
4
|
-
import {
|
|
4
|
+
import { msg, str } from '@lit/localize';
|
|
5
5
|
import { favoriteFilledIcon as favIcon } from '../../assets/img/icons/favorite-filled';
|
|
6
6
|
import { reviewsIcon } from '../../assets/img/icons/reviews';
|
|
7
7
|
import { uploadIcon } from '../../assets/img/icons/upload';
|
|
@@ -19,9 +19,7 @@ let TileStats = class TileStats extends LitElement {
|
|
|
19
19
|
return html `
|
|
20
20
|
<div class="item-stats">
|
|
21
21
|
<p class="sr-only">
|
|
22
|
-
${this.mediatype === 'account'
|
|
23
|
-
? msg('Account Stats')
|
|
24
|
-
: msg('Item Stats')}
|
|
22
|
+
${this.mediatype === 'account' ? 'Account Stats' : 'Item Stats'}
|
|
25
23
|
</p>
|
|
26
24
|
<ul id="stats-row">
|
|
27
25
|
${this.mediatypeIconColumnTemplate}
|
|
@@ -199,8 +197,7 @@ __decorate([
|
|
|
199
197
|
property({ type: Number })
|
|
200
198
|
], TileStats.prototype, "tvClipCount", void 0);
|
|
201
199
|
TileStats = __decorate([
|
|
202
|
-
customElement('tile-stats')
|
|
203
|
-
localized()
|
|
200
|
+
customElement('tile-stats')
|
|
204
201
|
], TileStats);
|
|
205
202
|
export { TileStats };
|
|
206
203
|
//# sourceMappingURL=tile-stats.js.map
|