@internetarchive/collection-browser 3.5.2-webdev-8178.0 → 3.5.3-alpha-webdev8156.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/.editorconfig +29 -29
- package/.github/workflows/ci.yml +27 -27
- package/.github/workflows/gh-pages-main.yml +39 -39
- package/.github/workflows/npm-publish.yml +39 -39
- package/.github/workflows/pr-preview.yml +38 -38
- package/.husky/pre-commit +4 -0
- package/.prettierignore +1 -1
- package/LICENSE +661 -661
- package/README.md +83 -83
- package/dist/src/app-root.js +606 -606
- package/dist/src/app-root.js.map +1 -1
- package/dist/src/collection-browser.js +8 -8
- package/dist/src/collection-browser.js.map +1 -1
- package/dist/src/data-source/collection-browser-query-state.d.ts +2 -1
- package/dist/src/data-source/collection-browser-query-state.js.map +1 -1
- package/dist/src/tiles/grid/collection-tile.js +77 -77
- package/dist/src/tiles/grid/collection-tile.js.map +1 -1
- package/dist/src/tiles/grid/item-tile.js +137 -137
- package/dist/src/tiles/grid/item-tile.js.map +1 -1
- package/dist/src/tiles/hover/hover-pane-controller.d.ts +8 -0
- package/dist/src/tiles/hover/hover-pane-controller.js +41 -29
- package/dist/src/tiles/hover/hover-pane-controller.js.map +1 -1
- package/dist/src/tiles/models.js.map +1 -1
- package/dist/src/tiles/tile-dispatcher.js +215 -215
- package/dist/src/tiles/tile-dispatcher.js.map +1 -1
- package/dist/test/collection-browser.test.js +1 -1
- package/dist/test/collection-browser.test.js.map +1 -1
- package/eslint.config.mjs +53 -53
- package/index.html +24 -24
- package/local.archive.org.cert +86 -86
- package/local.archive.org.key +27 -27
- package/package.json +119 -121
- package/renovate.json +6 -6
- package/src/app-root.ts +1140 -1140
- package/src/collection-browser.ts +9 -7
- package/src/data-source/collection-browser-query-state.ts +2 -1
- package/src/tiles/grid/collection-tile.ts +163 -163
- package/src/tiles/grid/item-tile.ts +340 -340
- package/src/tiles/hover/hover-pane-controller.ts +627 -613
- package/src/tiles/models.ts +1 -1
- package/src/tiles/tile-dispatcher.ts +517 -517
- package/test/collection-browser.test.ts +1 -1
- package/tsconfig.json +25 -25
- package/web-dev-server.config.mjs +30 -30
- package/web-test-runner.config.mjs +41 -52
|
@@ -1 +1 @@
|
|
|
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,iCAAiC,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAGlE,OAAO,gBAAgB,CAAC;AACxB,OAAO,iBAAiB,CAAC;AACzB,OAAO,uBAAuB,CAAC;AAC/B,OAAO,eAAe,CAAC;AACvB,OAAO,wBAAwB,CAAC;AAChC,OAAO,cAAc,CAAC;AAGf,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,iBAAiB;IAAxC;QACL;;;;;;;;;;;;;;;WAeG;;QAE0B,mBAAc,GAAG,KAAK,CAAC;QAEvB,gBAAW,GAAG,KAAK,CAAC;QAErB,qBAAgB,GAAqB,MAAM,CAAC;IAuS1E,CAAC;IArSC,MAAM;QACJ,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,EAAE,KAAK,CAAC;QACpC,MAAM,gBAAgB,GAAG,QAAQ,CAAC;YAChC,SAAS,EAAE,IA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MAAM;QACf,MAAM,eAAe,GAAG,GAAG,CAAA,iCAAiC,CAAC;QAE7D,OAAO;YACL,cAAc;YACd,GAAG,CAAA;;;;;;;;;;8BAUqB,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8CtC;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AA3S8B;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;kDAA6C;AAtB7D,QAAQ;IADpB,aAAa,CAAC,WAAW,CAAC;GACd,QAAQ,CA6TpB","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 { SimpleLayoutType } 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 * - 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 }) simpleLayoutType: SimpleLayoutType = 'none';\n\n render() {\n const itemTitle = this.model?.title;\n const containerClasses = classMap({\n container: true,\n simple: this.simpleLayoutType !== 'none',\n 'stats-only': this.simpleLayoutType === 'stats-only',\n 'snippets-only': this.simpleLayoutType === 'snippets-only',\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 || this.simpleLayoutType === 'stats-only')\n return nothing;\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 (this.simpleLayoutType === 'snippets-only') return nothing;\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 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,iCAAiC,CAAC;AAC9E,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAGlE,OAAO,gBAAgB,CAAC;AACxB,OAAO,iBAAiB,CAAC;AACzB,OAAO,uBAAuB,CAAC;AAC/B,OAAO,eAAe,CAAC;AACvB,OAAO,wBAAwB,CAAC;AAChC,OAAO,cAAc,CAAC;AAGf,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,iBAAiB;IAAxC;QACL;;;;;;;;;;;;;;;WAeG;;QAE0B,mBAAc,GAAG,KAAK,CAAC;QAEvB,gBAAW,GAA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M,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA8CtC;SACF,CAAC;IACJ,CAAC;CACF,CAAA;AA3S8B;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;kDAA6C;AAtB7D,QAAQ;IADpB,aAAa,CAAC,WAAW,CAAC;GACd,QAAQ,CA6TpB","sourcesContent":["import { css, CSSResultGroup, html, nothing, TemplateResult } from 'lit';\r\nimport { customElement, property } from 'lit/decorators.js';\r\nimport { ifDefined } from 'lit/directives/if-defined.js';\r\nimport { map } from 'lit/directives/map.js';\r\nimport { classMap } from 'lit/directives/class-map.js';\r\nimport { msg } from '@lit/localize';\r\n\r\nimport type { SortParam } from '@internetarchive/search-service';\r\nimport type { DateFormat } from '../../utils/format-date';\r\nimport { isFirstMillisecondOfUTCYear } from '../../utils/local-date-from-utc';\r\nimport { BaseTileComponent } from '../base-tile-component';\r\nimport { baseTileStyles } from './styles/tile-grid-shared-styles';\r\nimport { SimpleLayoutType } from '../models';\r\n\r\nimport '../image-block';\r\nimport '../review-block';\r\nimport '../text-snippet-block';\r\nimport '../item-image';\r\nimport '../tile-mediatype-icon';\r\nimport './tile-stats';\r\n\r\n@customElement('item-tile')\r\nexport class ItemTile extends BaseTileComponent {\r\n /*\r\n * Reactive properties inherited from BaseTileComponent:\r\n * - model?: TileModel;\r\n * - currentWidth?: number;\r\n * - currentHeight?: number;\r\n * - baseNavigationUrl?: string;\r\n * - baseImageUrl?: string;\r\n * - collectionPagePath?: string;\r\n * - sortParam: SortParam | null = null;\r\n * - defaultSortParam: SortParam | null = null;\r\n * - creatorFilter?: string;\r\n * - mobileBreakpoint?: number;\r\n * - loggedIn = false;\r\n * - suppressBlurring = false;\r\n * - useLocalTime = false;\r\n */\r\n\r\n @property({ type: Boolean }) showInfoButton = false;\r\n\r\n @property({ type: Boolean }) showTvClips = false;\r\n\r\n @property({ type: String }) simpleLayoutType: SimpleLayoutType = 'none';\r\n\r\n render() {\r\n const itemTitle = this.model?.title;\r\n const containerClasses = classMap({\r\n container: true,\r\n simple: this.simpleLayoutType !== 'none',\r\n 'stats-only': this.simpleLayoutType === 'stats-only',\r\n 'snippets-only': this.simpleLayoutType === 'snippets-only',\r\n });\r\n\r\n return html`\r\n <div class=${containerClasses}>\r\n ${this.infoButtonTemplate}\r\n <div class=\"tile-details\">\r\n <div class=\"item-info\">\r\n ${this.imageBlockTemplate}\r\n\r\n <div id=\"title\">\r\n <h3 class=\"truncated\" title=${ifDefined(itemTitle)}>\r\n ${itemTitle}\r\n </h3>\r\n </div>\r\n\r\n ${this.volumeIssueTemplate}\r\n ${this.isSortedByDate\r\n ? this.sortedDateInfoTemplate\r\n : this.creatorTemplate}\r\n ${this.webArchivesCaptureDatesTemplate} ${this.textSnippetsTemplate}\r\n ${this.reviewBlockTemplate}\r\n </div>\r\n\r\n ${this.tileStatsTemplate}\r\n </div>\r\n </div>\r\n `;\r\n }\r\n\r\n /**\r\n * Templates\r\n */\r\n private get creatorTemplate(): TemplateResult | typeof nothing {\r\n const displayedCreator =\r\n this.displayValueProvider.firstCreatorMatchingFilter;\r\n if (!displayedCreator) return nothing;\r\n\r\n return html`\r\n <div class=\"created-by\">\r\n <span class=\"truncated\" title=${displayedCreator}>\r\n by ${displayedCreator}\r\n </span>\r\n </div>\r\n `;\r\n }\r\n\r\n private get imageBlockTemplate(): TemplateResult {\r\n return html`\r\n <image-block\r\n .model=${this.model}\r\n .baseImageUrl=${this.baseImageUrl}\r\n .loggedIn=${this.loggedIn}\r\n .suppressBlurring=${this.suppressBlurring}\r\n .isCompactTile=${false}\r\n .isListTile=${false}\r\n .viewSize=${'grid'}\r\n >\r\n </image-block>\r\n `;\r\n }\r\n\r\n private get sortedDateInfoTemplate() {\r\n let sortedValue;\r\n let format: DateFormat = 'long';\r\n switch (this.effectiveSort?.field) {\r\n case 'date': {\r\n const datePublished = this.model?.datePublished;\r\n sortedValue = { field: 'published', value: datePublished };\r\n if (isFirstMillisecondOfUTCYear(datePublished)) {\r\n format = 'year-only';\r\n }\r\n break;\r\n }\r\n case 'reviewdate':\r\n sortedValue = { field: 'reviewed', value: this.model?.dateReviewed };\r\n break;\r\n case 'addeddate':\r\n sortedValue = { field: 'added', value: this.model?.dateAdded };\r\n break;\r\n case 'publicdate':\r\n sortedValue = { field: 'archived', value: this.model?.dateArchived };\r\n break;\r\n default:\r\n break;\r\n }\r\n\r\n if (!sortedValue?.value) {\r\n return nothing;\r\n }\r\n\r\n const formattedDate = this.getFormattedDate(sortedValue.value, format);\r\n return html`\r\n <div class=\"date-sorted-by truncated\">\r\n <span>${sortedValue.field} ${formattedDate}</span>\r\n </div>\r\n `;\r\n }\r\n\r\n private get infoButtonTemplate(): TemplateResult | typeof nothing {\r\n // ⓘ is an information icon\r\n return this.showInfoButton\r\n ? html`<button class=\"info-button\" @click=${this.infoButtonPressed}>\r\n ⓘ\r\n <span class=\"sr-only\">${msg('More info')}</span>\r\n </button>`\r\n : nothing;\r\n }\r\n\r\n private get reviewBlockTemplate(): TemplateResult | typeof nothing {\r\n if (!this.model?.review) return nothing;\r\n\r\n const { reviewtitle, reviewbody, stars } = this.model.review;\r\n return html`\r\n <review-block\r\n viewsize=\"grid\"\r\n title=${ifDefined(reviewtitle)}\r\n body=${ifDefined(reviewbody)}\r\n starRating=${ifDefined(stars)}\r\n >\r\n </review-block>\r\n `;\r\n }\r\n\r\n private get textSnippetsTemplate(): TemplateResult | typeof nothing {\r\n if (!this.hasSnippets || this.simpleLayoutType === 'stats-only')\r\n return nothing;\r\n\r\n return html`\r\n <text-snippet-block viewsize=\"grid\" .snippets=${this.model?.snippets}>\r\n </text-snippet-block>\r\n `;\r\n }\r\n\r\n private get volumeIssueTemplate(): TemplateResult | typeof nothing {\r\n if (!this.model?.volume || !this.model?.issue) return nothing;\r\n\r\n return html`\r\n <div class=\"volume-issue\">\r\n <span class=\"truncated\" title=\"volume|issue\">\r\n Volume ${this.model?.volume}, Issue ${this.model?.issue}\r\n </span>\r\n </div>\r\n `;\r\n }\r\n\r\n private get webArchivesCaptureDatesTemplate():\r\n | TemplateResult\r\n | typeof nothing {\r\n if (!this.model?.captureDates || !this.model.title) return nothing;\r\n\r\n return html`\r\n <ul class=\"capture-dates\">\r\n ${map(\r\n this.model.captureDates,\r\n date =>\r\n html`<li>\r\n ${this.displayValueProvider.webArchivesCaptureLink(\r\n this.model!.title,\r\n date,\r\n )}\r\n </li>`,\r\n )}\r\n </ul>\r\n `;\r\n }\r\n\r\n /**\r\n * Template for the stats row along the bottom of the tile.\r\n */\r\n private get tileStatsTemplate(): TemplateResult | typeof nothing {\r\n if (this.simpleLayoutType === 'snippets-only') return nothing;\r\n\r\n const effectiveSort = this.sortParam ?? this.defaultSortParam;\r\n const [viewCount, viewLabel] =\r\n effectiveSort?.field === 'week'\r\n ? [this.model?.weeklyViewCount, 'weekly views']\r\n : [this.model?.viewCount, 'all-time views'];\r\n\r\n return html`\r\n <tile-stats\r\n .model=${this.model}\r\n .mediatype=${this.model?.mediatype}\r\n .viewCount=${viewCount}\r\n .viewLabel=${viewLabel}\r\n .favCount=${this.model?.favCount}\r\n .commentCount=${this.model?.commentCount}\r\n .tvClipCount=${this.model?.tvClipCount}\r\n .showTvClips=${this.showTvClips}\r\n >\r\n </tile-stats>\r\n `;\r\n }\r\n\r\n private get isSortedByDate(): boolean {\r\n return ['date', 'reviewdate', 'addeddate', 'publicdate'].includes(\r\n this.effectiveSort?.field as string,\r\n );\r\n }\r\n\r\n /**\r\n * Returns the active sort param if one is set, or the default sort param otherwise.\r\n */\r\n private get effectiveSort(): SortParam | null {\r\n return this.sortParam ?? this.defaultSortParam;\r\n }\r\n\r\n private get hasSnippets(): boolean {\r\n return !!this.model?.snippets?.length;\r\n }\r\n\r\n private infoButtonPressed(e: PointerEvent): void {\r\n e.preventDefault();\r\n const event = new CustomEvent<{ x: number; y: number }>(\r\n 'infoButtonPressed',\r\n { detail: { x: e.clientX, y: e.clientY } },\r\n );\r\n this.dispatchEvent(event);\r\n }\r\n\r\n /**\r\n * CSS\r\n */\r\n static get styles(): CSSResultGroup {\r\n const tileBorderColor = css`var(--tileBorderColor, #dddddd)`;\r\n\r\n return [\r\n baseTileStyles,\r\n css`\r\n a:link {\r\n text-decoration: none;\r\n color: var(--ia-theme-link-color, #4b64ff);\r\n }\r\n a:hover {\r\n text-decoration: underline;\r\n }\r\n\r\n .container {\r\n border: 1px solid ${tileBorderColor};\r\n }\r\n\r\n .simple #title > .truncated {\r\n -webkit-line-clamp: 2;\r\n }\r\n\r\n .simple .created-by > .truncated,\r\n .simple .date-sorted-by > .truncated,\r\n .simple .volume-issue > .truncated {\r\n -webkit-line-clamp: 1;\r\n }\r\n\r\n .simple.snippets-only .item-info {\r\n padding-bottom: 5px;\r\n }\r\n\r\n .simple.snippets-only text-snippet-block {\r\n margin-top: auto; /* Force the snippets to the bottom of the tile */\r\n }\r\n\r\n .capture-dates {\r\n margin: 0;\r\n padding: 0 5px;\r\n list-style-type: none;\r\n }\r\n\r\n review-block,\r\n text-snippet-block {\r\n --containerLeftMargin: 5px;\r\n --containerTopMargin: 5px;\r\n }\r\n\r\n /**\r\n * iOS Safari long-press on tiles (to bring up hover pane)\r\n * gets messy without this\r\n */\r\n @media screen and (pointer: coarse) and (hover: none) {\r\n .container {\r\n -webkit-touch-callout: none;\r\n }\r\n\r\n .truncated {\r\n -webkit-touch-callout: default;\r\n }\r\n }\r\n `,\r\n ];\r\n }\r\n}\r\n"]}
|
|
@@ -122,6 +122,13 @@ export declare class HoverPaneController implements HoverPaneControllerInterface
|
|
|
122
122
|
private forceTouchBackdrop;
|
|
123
123
|
/** A record of the last mouse position on the host element, for positioning the hover pane */
|
|
124
124
|
private lastPointerClientPos;
|
|
125
|
+
/**
|
|
126
|
+
* A flag to track whether the host element is being clicked by a pointer device, so that we
|
|
127
|
+
* don't trigger unnecessary keyboard focus behaviors on click. This is needed, e.g., to prevent
|
|
128
|
+
* the hover pane from appearing immediately at its `host` positioning on click, which can
|
|
129
|
+
* obstruct the host element itself (due to the ordering of events fired).
|
|
130
|
+
*/
|
|
131
|
+
private clicking;
|
|
125
132
|
constructor(
|
|
126
133
|
/** The host element to which this controller should attach listeners */
|
|
127
134
|
host: ReactiveControllerHost & HoverPaneProviderInterface & HTMLElement,
|
|
@@ -171,6 +178,7 @@ export declare class HoverPaneController implements HoverPaneControllerInterface
|
|
|
171
178
|
private detachListeners;
|
|
172
179
|
private handleFocus;
|
|
173
180
|
private handleBlur;
|
|
181
|
+
private handlePointerDown;
|
|
174
182
|
private handleKeyDown;
|
|
175
183
|
private handleKeyUp;
|
|
176
184
|
/**
|
|
@@ -56,18 +56,29 @@ export class HoverPaneController {
|
|
|
56
56
|
this.forceTouchBackdrop = false;
|
|
57
57
|
/** A record of the last mouse position on the host element, for positioning the hover pane */
|
|
58
58
|
this.lastPointerClientPos = { x: 0, y: 0 };
|
|
59
|
+
/**
|
|
60
|
+
* A flag to track whether the host element is being clicked by a pointer device, so that we
|
|
61
|
+
* don't trigger unnecessary keyboard focus behaviors on click. This is needed, e.g., to prevent
|
|
62
|
+
* the hover pane from appearing immediately at its `host` positioning on click, which can
|
|
63
|
+
* obstruct the host element itself (due to the ordering of events fired).
|
|
64
|
+
*/
|
|
65
|
+
this.clicking = false;
|
|
59
66
|
this.handleFocus = () => {
|
|
60
|
-
if (this.hoverPaneState === 'hidden') {
|
|
67
|
+
if (!this.clicking && this.hoverPaneState === 'hidden') {
|
|
61
68
|
this.showHoverPane({
|
|
62
69
|
anchor: 'host',
|
|
63
70
|
});
|
|
64
71
|
}
|
|
72
|
+
this.clicking = false;
|
|
65
73
|
};
|
|
66
74
|
this.handleBlur = () => {
|
|
67
75
|
if (this.hoverPaneState !== 'hidden') {
|
|
68
76
|
this.fadeOutHoverPane();
|
|
69
77
|
}
|
|
70
78
|
};
|
|
79
|
+
this.handlePointerDown = () => {
|
|
80
|
+
this.clicking = true;
|
|
81
|
+
};
|
|
71
82
|
this.handleKeyDown = (e) => {
|
|
72
83
|
if ((e.key === 'ArrowDown' || e.key === 'ArrowUp') &&
|
|
73
84
|
this.hoverPaneState !== 'hidden') {
|
|
@@ -204,25 +215,25 @@ export class HoverPaneController {
|
|
|
204
215
|
getTemplate() {
|
|
205
216
|
this.hoverPaneProps = this.host.getHoverPaneProps();
|
|
206
217
|
return this.shouldRenderHoverPane
|
|
207
|
-
? html `
|
|
208
|
-
${this.touchBackdropTemplate}
|
|
209
|
-
<tile-hover-pane
|
|
210
|
-
popover
|
|
211
|
-
tabindex="-1"
|
|
212
|
-
aria-describedby="tile-hover-pane-aria-description"
|
|
213
|
-
.model=${this.hoverPaneProps?.model}
|
|
214
|
-
.baseNavigationUrl=${this.hoverPaneProps?.baseNavigationUrl}
|
|
215
|
-
.baseImageUrl=${this.hoverPaneProps?.baseImageUrl}
|
|
216
|
-
.loggedIn=${this.hoverPaneProps?.loggedIn}
|
|
217
|
-
.suppressBlurring=${this.hoverPaneProps?.suppressBlurring}
|
|
218
|
-
.sortParam=${this.hoverPaneProps?.sortParam}
|
|
219
|
-
.collectionTitles=${this.hoverPaneProps?.collectionTitles}
|
|
220
|
-
.mobileBreakpoint=${this.mobileBreakpoint}
|
|
221
|
-
.currentWidth=${window.innerWidth}
|
|
222
|
-
></tile-hover-pane>
|
|
223
|
-
<div id="tile-hover-pane-aria-description" class="sr-only">
|
|
224
|
-
${msg('Press Up Arrow to exit item detail preview')}
|
|
225
|
-
</div>
|
|
218
|
+
? html `
|
|
219
|
+
${this.touchBackdropTemplate}
|
|
220
|
+
<tile-hover-pane
|
|
221
|
+
popover
|
|
222
|
+
tabindex="-1"
|
|
223
|
+
aria-describedby="tile-hover-pane-aria-description"
|
|
224
|
+
.model=${this.hoverPaneProps?.model}
|
|
225
|
+
.baseNavigationUrl=${this.hoverPaneProps?.baseNavigationUrl}
|
|
226
|
+
.baseImageUrl=${this.hoverPaneProps?.baseImageUrl}
|
|
227
|
+
.loggedIn=${this.hoverPaneProps?.loggedIn}
|
|
228
|
+
.suppressBlurring=${this.hoverPaneProps?.suppressBlurring}
|
|
229
|
+
.sortParam=${this.hoverPaneProps?.sortParam}
|
|
230
|
+
.collectionTitles=${this.hoverPaneProps?.collectionTitles}
|
|
231
|
+
.mobileBreakpoint=${this.mobileBreakpoint}
|
|
232
|
+
.currentWidth=${window.innerWidth}
|
|
233
|
+
></tile-hover-pane>
|
|
234
|
+
<div id="tile-hover-pane-aria-description" class="sr-only">
|
|
235
|
+
${msg('Press Up Arrow to exit item detail preview')}
|
|
236
|
+
</div>
|
|
226
237
|
`
|
|
227
238
|
: nothing;
|
|
228
239
|
}
|
|
@@ -247,15 +258,15 @@ export class HoverPaneController {
|
|
|
247
258
|
*/
|
|
248
259
|
get touchBackdropTemplate() {
|
|
249
260
|
return this.showTouchBackdrop
|
|
250
|
-
? html `<div
|
|
251
|
-
id="touch-backdrop"
|
|
252
|
-
@touchstart=${this.handleBackdropInteraction}
|
|
253
|
-
@touchmove=${this.handleBackdropInteraction}
|
|
254
|
-
@touchend=${this.handleBackdropInteraction}
|
|
255
|
-
@touchcancel=${this.handleBackdropInteraction}
|
|
256
|
-
@mouseenter=${(e) => e.stopPropagation()}
|
|
257
|
-
@mousemove=${(e) => e.stopPropagation()}
|
|
258
|
-
@mouseleave=${(e) => e.stopPropagation()}
|
|
261
|
+
? html `<div
|
|
262
|
+
id="touch-backdrop"
|
|
263
|
+
@touchstart=${this.handleBackdropInteraction}
|
|
264
|
+
@touchmove=${this.handleBackdropInteraction}
|
|
265
|
+
@touchend=${this.handleBackdropInteraction}
|
|
266
|
+
@touchcancel=${this.handleBackdropInteraction}
|
|
267
|
+
@mouseenter=${(e) => e.stopPropagation()}
|
|
268
|
+
@mousemove=${(e) => e.stopPropagation()}
|
|
269
|
+
@mouseleave=${(e) => e.stopPropagation()}
|
|
259
270
|
></div>`
|
|
260
271
|
: nothing;
|
|
261
272
|
}
|
|
@@ -340,6 +351,7 @@ export class HoverPaneController {
|
|
|
340
351
|
// keyboard navigation listeners
|
|
341
352
|
this.host.addEventListener('focus', this.handleFocus);
|
|
342
353
|
this.host.addEventListener('blur', this.handleBlur);
|
|
354
|
+
this.host.addEventListener('pointerdown', this.handlePointerDown);
|
|
343
355
|
this.host.addEventListener('keyup', this.handleKeyUp);
|
|
344
356
|
this.host.addEventListener('keydown', this.handleKeyDown);
|
|
345
357
|
if (this.isHoverEnabled) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hover-pane-controller.js","sourceRoot":"","sources":["../../../../src/tiles/hover/hover-pane-controller.ts"],"names":[],"mappings":"AACA,OAAO,EACL,IAAI,EAEJ,OAAO,GAGR,MAAM,KAAK,CAAC;AAGb,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAoEpC,MAAM,KAAK,GAAG,CAAC,GAAW,EAAE,GAAG,GAAG,CAAC,QAAQ,EAAE,GAAG,GAAG,QAAQ,EAAE,EAAE,CAC7D,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;AAEpC,MAAM,OAAO,mBAAmB;IA8E9B;IACE,wEAAwE;IACvD,IAEJ;IACb,4EAA4E;IAC5E,UAAsC,EAAE;QAJvB,SAAI,GAAJ,IAAI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,IAAI,CAAC,cAAc,GAAG,YAAY,CAAC;QACnC,IAAI,CAAC,SAAS,EAAE,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAE5C,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,EAAE;YACtC,IAAI,CAAC,cAAc,GAAG,QAAQ,CAAC;YAC/B,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;gBACnB,IAAI,CAAC,SAAS,CAAC,QAAQ,GAAG,CAAC,CAAC,CAAC;YAC/B,CAAC;YACD,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;QAC5B,CAAC,EAAE,GAAG,CAAC,CAAC;IACV,CAAC;IAED;;OAEG;IACK,mBAAmB,CAAC,MAA+B;QACzD,IAAI,CAAC,IAAI,CAAC,SAAS;YAAE,OAAO;QAE5B,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC;QAE1D,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG,GAAG,IAAI,CAAC;QACtC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,IAAI,IAAI,CAAC;IAC1C,CAAC;CACF","sourcesContent":["import type { SortParam } from '@internetarchive/search-service';\nimport {\n html,\n HTMLTemplateResult,\n nothing,\n ReactiveController,\n ReactiveControllerHost,\n} from 'lit';\nimport type { TileModel } from '../../models';\nimport type { CollectionTitles } from '../../data-source/models';\nimport { msg } from '@lit/localize';\n\ntype HoverPaneState = 'hidden' | 'shown' | 'fading-out';\n\n// the anchor point of the hover pane\n// can be either the mouse cursor or near the host element\n// in the case of mouse navigation, we want it to follow the cursor\n// in the case of keyboard navigation, we want it to appear near the host element\ntype HoverPanePositionAnchor = 'host' | 'cursor';\n\nexport interface HoverPaneProperties {\n model?: TileModel;\n baseNavigationUrl?: string;\n baseImageUrl?: string;\n loggedIn: boolean;\n suppressBlurring: boolean;\n sortParam: SortParam | null;\n collectionTitles?: CollectionTitles;\n}\n\nexport interface HoverPaneControllerOptions {\n offsetX?: number;\n offsetY?: number;\n enableLongPress?: boolean;\n showDelay?: number;\n hideDelay?: number;\n longPressDelay?: number;\n mobileBreakpoint?: number;\n}\n\n/** A common interface for providing a hover pane element. */\nexport interface HoverPaneProviderInterface {\n /** Returns the provider's currently rendered hover pane element. */\n getHoverPane(): HTMLElement | undefined;\n /** Returns properties that should be passed to the hover pane. */\n getHoverPaneProps(): HoverPaneProperties;\n /** When user has keyboard navigated out of more info, we want the host to get focus */\n acquireFocus(): void;\n /** When user has keyboard navigated out of more info, we want the host to lose focus */\n releaseFocus(): void;\n}\n\nexport interface ToggleHoverPaneOptions {\n coords: { x: number; y: number };\n enableTouchBackdrop?: boolean;\n}\n\n/**\n * An interface for interacting with hover pane controllers (e.g.,\n * to retrieve their current hover pane template).\n */\nexport interface HoverPaneControllerInterface extends ReactiveController {\n /**\n * Returns the hover pane template to render based on this controller's\n * current state. The returned template may be `nothing` if the hover\n * pane should not currently be rendered.\n */\n getTemplate(): HTMLTemplateResult | typeof nothing;\n\n /**\n * Requests to manually toggle the state of the hover pane.\n * If the hover pane is already shown, it will begin fading out and then\n * subsequently be hidden and removed. If the hover pane is already fading\n * out or hidden, it will fade back in and be shown.\n */\n toggleHoverPane(options: ToggleHoverPaneOptions): void;\n}\n\nconst clamp = (val: number, min = -Infinity, max = Infinity) =>\n Math.max(min, Math.min(val, max));\n\nexport class HoverPaneController implements HoverPaneControllerInterface {\n /**\n * The hover pane element attached to this controller's host.\n */\n private hoverPane?: HTMLElement;\n\n /**\n * The properties to be passed to the hover pane element\n */\n private hoverPaneProps?: HoverPaneProperties;\n\n /**\n * The breakpoint (in pixels) below which the mobile interface should be used.\n */\n private mobileBreakpoint?: number = 600;\n\n /**\n * The number of horizontal pixels the hover pane should be offset from the\n * pointer position.\n */\n private offsetX: number = -10;\n\n /**\n * The number of vertical pixels the hover pane should be offset from the\n * pointer position.\n */\n private offsetY: number = 15;\n\n /**\n * The delay between the mouse idling within the host element and when the hover\n * pane should begin fading in (in milliseconds).\n */\n private showDelay: number = 300;\n\n /**\n * The delay between when the mouse leaves the host element and when the hover\n * pane should begin fading out (in milliseconds).\n */\n private hideDelay: number = 100;\n\n /**\n * The delay between when a touch event begins on the host element and when the\n * hover pane should begin fading in (in milliseconds).\n */\n private longPressDelay: number = 600;\n\n /**\n * Whether long press interactions should cause the hover pane to appear (when\n * below the mobile breakpoint).\n */\n private enableLongPress: boolean = false;\n\n /**\n * Used to control the current state of this provider's hover pane.\n * - `'hidden'` => The hover pane is not present at all.\n * - `'shown'` => The hover pane is either fading in or fully visible.\n * - `'fading-out'` => The hover pane is fading out and about to be removed.\n */\n private hoverPaneState: HoverPaneState = 'hidden';\n\n /** The timer ID for showing the hover pane */\n private showTimer?: number;\n\n /** The timer ID for hiding the hover pane */\n private hideTimer?: number;\n\n /** The timer ID for recognizing a long press event */\n private longPressTimer?: number;\n\n /**\n * Whether the touch backdrop should currently be rendered irrespective of other touch\n * interactions being enabled.\n */\n private forceTouchBackdrop: boolean = false;\n\n /** A record of the last mouse position on the host element, for positioning the hover pane */\n private lastPointerClientPos = { x: 0, y: 0 };\n\n constructor(\n /** The host element to which this controller should attach listeners */\n private readonly host: ReactiveControllerHost &\n HoverPaneProviderInterface &\n HTMLElement,\n /** Options for adjusting the hover pane behavior (offsets, delays, etc.) */\n options: HoverPaneControllerOptions = {},\n ) {\n this.mobileBreakpoint = options.mobileBreakpoint ?? this.mobileBreakpoint;\n this.offsetX = options.offsetX ?? this.offsetX;\n this.offsetY = options.offsetY ?? this.offsetY;\n this.showDelay = options.showDelay ?? this.showDelay;\n this.hideDelay = options.hideDelay ?? this.hideDelay;\n this.longPressDelay = options.longPressDelay ?? this.longPressDelay;\n this.enableLongPress = options.enableLongPress ?? this.enableLongPress;\n\n this.host.addController(this);\n }\n\n hostConnected(): void {\n this.attachListeners();\n }\n\n hostDisconnected(): void {\n this.detachListeners();\n }\n\n hostUpdated(): void {\n this.hoverPane = this.host.getHoverPane();\n this.hoverPaneProps = this.host.getHoverPaneProps();\n }\n\n /** @inheritdoc */\n getTemplate(): HTMLTemplateResult | typeof nothing {\n this.hoverPaneProps = this.host.getHoverPaneProps();\n\n return this.shouldRenderHoverPane\n ? html`\n ${this.touchBackdropTemplate}\n <tile-hover-pane\n popover\n tabindex=\"-1\"\n aria-describedby=\"tile-hover-pane-aria-description\"\n .model=${this.hoverPaneProps?.model}\n .baseNavigationUrl=${this.hoverPaneProps?.baseNavigationUrl}\n .baseImageUrl=${this.hoverPaneProps?.baseImageUrl}\n .loggedIn=${this.hoverPaneProps?.loggedIn}\n .suppressBlurring=${this.hoverPaneProps?.suppressBlurring}\n .sortParam=${this.hoverPaneProps?.sortParam}\n .collectionTitles=${this.hoverPaneProps?.collectionTitles}\n .mobileBreakpoint=${this.mobileBreakpoint}\n .currentWidth=${window.innerWidth}\n ></tile-hover-pane>\n <div id=\"tile-hover-pane-aria-description\" class=\"sr-only\">\n ${msg('Press Up Arrow to exit item detail preview')}\n </div>\n `\n : nothing;\n }\n\n /** @inheritdoc */\n toggleHoverPane(options: ToggleHoverPaneOptions): void {\n if (this.hoverPaneState === 'shown') {\n this.fadeOutHoverPane();\n this.forceTouchBackdrop = false;\n } else {\n this.lastPointerClientPos = options.coords;\n this.forceTouchBackdrop = options.enableTouchBackdrop ?? false;\n this.showHoverPane();\n }\n }\n\n /**\n * Produces a template for the invisible touch capture backdrop that\n * is used to cancel the hover pane on touch devices. We want any\n * touch interaction on the backdrop to remove the hover pane, and\n * we don't want to bubble up mouse events that would otherwise\n * affect the state of the hover pane (e.g., fading it back in).\n */\n private get touchBackdropTemplate(): HTMLTemplateResult | typeof nothing {\n return this.showTouchBackdrop\n ? html`<div\n id=\"touch-backdrop\"\n @touchstart=${this.handleBackdropInteraction}\n @touchmove=${this.handleBackdropInteraction}\n @touchend=${this.handleBackdropInteraction}\n @touchcancel=${this.handleBackdropInteraction}\n @mouseenter=${(e: MouseEvent) => e.stopPropagation()}\n @mousemove=${(e: MouseEvent) => e.stopPropagation()}\n @mouseleave=${(e: MouseEvent) => e.stopPropagation()}\n ></div>`\n : nothing;\n }\n\n private get showTouchBackdrop(): boolean {\n return (\n (this.isTouchEnabled && this.enableLongPress) || this.forceTouchBackdrop\n );\n }\n\n /** Whether to use the mobile layout */\n private get isMobileView(): boolean {\n return !!this.mobileBreakpoint && window.innerWidth < this.mobileBreakpoint;\n }\n\n private get isHoverEnabled(): boolean {\n return window.matchMedia('(hover: hover)').matches;\n }\n\n private get isTouchEnabled(): boolean {\n return (\n 'ontouchstart' in window &&\n window.matchMedia('(any-pointer: coarse)').matches\n );\n }\n\n /** Whether this controller should currently render its hover pane. */\n private get shouldRenderHoverPane(): boolean {\n return this.hoverPaneState !== 'hidden';\n }\n\n /**\n * Returns the desired top/left offsets (in pixels) for this tile's hover pane.\n * The desired offsets balance positioning the hover pane under the primary pointer\n * while preventing it from flowing outside the viewport. The returned offsets are\n * relative to the viewport, intended to position the pane as a popover element.\n *\n * These offsets are only valid if the hover pane is already rendered with its\n * correct width and height. If the hover pane is not present, the returned offsets\n * will simply represent the current pointer position.\n */\n private makePaneDesiredOffsets(anchor: HoverPanePositionAnchor): {\n top: number;\n left: number;\n } {\n // Try to find offsets for the hover pane that:\n // (a) cause it to lie entirely within the viewport, and\n // (b) to the extent possible, minimize the distance between the\n // nearest corner of the hover pane and the mouse/host element position\n // (with some additional offsets applied after the fact).\n\n let [left, top] = [0, 0];\n switch (anchor) {\n case 'host':\n const hostRect = this.host.getBoundingClientRect();\n // slight inset from host top left corner\n left = hostRect.left + 20;\n top = hostRect.top + 30;\n break;\n case 'cursor':\n left = this.lastPointerClientPos.x;\n top = this.lastPointerClientPos.y;\n break;\n }\n\n // Flip the hover pane according to which quadrant of the viewport the coordinates are in.\n // (Similar to how Wikipedia's link hover panes work)\n const flipHorizontal = left > window.innerWidth / 2;\n const flipVertical = top > window.innerHeight / 2;\n\n const hoverPaneRect = this.hoverPane?.getBoundingClientRect();\n if (hoverPaneRect) {\n // If we need to flip the hover pane, do so by subtracting its width/height from left/top\n if (flipHorizontal) {\n left -= hoverPaneRect.width;\n }\n if (flipVertical) {\n top -= hoverPaneRect.height;\n }\n\n // Apply desired offsets from the target position\n left += (flipHorizontal ? -1 : 1) * this.offsetX;\n top += (flipVertical ? -1 : 1) * this.offsetY;\n\n // On mobile view, shunt the hover pane to avoid overflowing the viewport\n if (this.isMobileView) {\n left = clamp(left, 20, window.innerWidth - hoverPaneRect.width - 20);\n top = clamp(top, 20, window.innerHeight - hoverPaneRect.height - 20);\n }\n }\n\n left += window.scrollX;\n top += window.scrollY;\n\n return { left, top };\n }\n\n /**\n * Adds to the host element all the listeners necessary to make the\n * hover pane functional.\n */\n private attachListeners(): void {\n // keyboard navigation listeners\n this.host.addEventListener('focus', this.handleFocus);\n this.host.addEventListener('blur', this.handleBlur);\n this.host.addEventListener('keyup', this.handleKeyUp);\n this.host.addEventListener('keydown', this.handleKeyDown);\n\n if (this.isHoverEnabled) {\n this.host.addEventListener('mouseenter', this.handleMouseEnter);\n this.host.addEventListener('mousemove', this.handleMouseMove);\n this.host.addEventListener('mouseleave', this.handleMouseLeave);\n }\n\n if (this.isTouchEnabled && this.enableLongPress) {\n this.host.addEventListener('touchstart', this.handleTouchStart);\n this.host.addEventListener('touchmove', this.handleLongPressCancel);\n this.host.addEventListener('touchend', this.handleLongPressCancel);\n this.host.addEventListener('touchcancel', this.handleLongPressCancel);\n this.host.addEventListener('contextmenu', this.handleContextMenu);\n }\n }\n\n /**\n * Removes all the hover pane listeners from the host element.\n */\n private detachListeners(): void {\n this.host.removeEventListener('mouseenter', this.handleMouseEnter);\n this.host.removeEventListener('mousemove', this.handleMouseMove);\n this.host.removeEventListener('mouseleave', this.handleMouseLeave);\n this.host.removeEventListener('touchstart', this.handleTouchStart);\n this.host.removeEventListener('touchmove', this.handleLongPressCancel);\n this.host.removeEventListener('touchend', this.handleLongPressCancel);\n this.host.removeEventListener('touchcancel', this.handleLongPressCancel);\n this.host.removeEventListener('contextmenu', this.handleContextMenu);\n\n // keyboard navigation listeners\n this.host.removeEventListener('focus', this.handleFocus);\n this.host.removeEventListener('blur', this.handleBlur);\n this.host.removeEventListener('keyup', this.handleKeyUp);\n this.host.removeEventListener('keydown', this.handleKeyDown);\n }\n\n private handleFocus = (): void => {\n if (this.hoverPaneState === 'hidden') {\n this.showHoverPane({\n anchor: 'host',\n });\n }\n };\n\n private handleBlur = (): void => {\n if (this.hoverPaneState !== 'hidden') {\n this.fadeOutHoverPane();\n }\n };\n\n private handleKeyDown = (e: KeyboardEvent): void => {\n if (\n (e.key === 'ArrowDown' || e.key === 'ArrowUp') &&\n this.hoverPaneState !== 'hidden'\n ) {\n e.preventDefault();\n }\n };\n\n private handleKeyUp = (e: KeyboardEvent): void => {\n if (this.hoverPaneState === 'hidden' || !this.hoverPane) return;\n if (e.key === 'ArrowDown') {\n this.hoverPane.tabIndex = 1;\n this.hoverPane.focus();\n }\n\n const isArrowUp = e.key === 'ArrowUp';\n const isEscape = e.key === 'Escape' || e.key === 'Esc';\n\n if (isEscape) {\n this.fadeOutHoverPane();\n }\n if (isArrowUp || isEscape) {\n this.hoverPane.tabIndex = -1;\n this.host.acquireFocus();\n }\n };\n\n /**\n * Handler for the mouseenter event on the host element.\n */\n // NB: Arrow function so 'this' remains bound to the controller\n private handleMouseEnter = (e: MouseEvent): void => {\n // Delegate to the mousemove handler, as they are currently processed identically\n this.handleMouseMove(e);\n };\n\n /**\n * Handler for the mousemove event on the host element.\n * Aborts any pending hide/fade-out for the hover pane, and restarts the\n * timer to show it.\n */\n // NB: Arrow function so 'this' remains bound to the controller\n private handleMouseMove = (e: MouseEvent): void => {\n // The mouse is within the tile, so abort any pending removal of the hover pane\n clearTimeout(this.hideTimer);\n\n // If the hover pane is currently fading out, just make it fade back in where it is\n if (this.hoverPaneState === 'fading-out') {\n this.hoverPaneState = 'shown';\n this.hoverPane?.classList.add('fade-in');\n }\n\n // Restart the timer to show the hover pane anytime the mouse moves within the tile\n if (this.hoverPaneState === 'hidden') {\n this.restartShowHoverPaneTimer();\n this.lastPointerClientPos = { x: e.clientX, y: e.clientY };\n }\n };\n\n /**\n * Handler for the mouseleave event on the host element.\n * Hides the hover pane if present, and aborts the timer for showing it.\n */\n // NB: Arrow function so 'this' remains bound to the controller\n private handleMouseLeave = (): void => {\n this.host.releaseFocus();\n\n // Abort any timer to show the hover pane, as the mouse has left the tile\n clearTimeout(this.showTimer);\n\n // Hide the hover pane if it's already been shown\n if (this.hoverPaneState !== 'hidden') {\n this.hideTimer = window.setTimeout(() => {\n this.fadeOutHoverPane();\n }, this.hideDelay);\n }\n };\n\n /**\n * Handler for the touchstart event on the host element.\n * Begins the timer for recognizing a long press event.\n */\n // NB: Arrow function so 'this' remains bound to the controller\n private handleTouchStart = (e: TouchEvent): void => {\n clearTimeout(this.longPressTimer);\n\n if (e.touches.length === 1) {\n this.longPressTimer = window.setTimeout(() => {\n if (this.hoverPaneState === 'hidden') {\n this.showHoverPane();\n }\n }, this.longPressDelay);\n\n this.lastPointerClientPos = {\n x: e.touches[0].clientX,\n y: e.touches[0].clientY,\n };\n }\n };\n\n /**\n * Handler for events that should cancel a pending long press event\n * (touchmove, touchend, touchcancel). Aborts the timer for recognizing\n * a long press.\n */\n // NB: Arrow function so 'this' remains bound to the controller\n private handleLongPressCancel = (): void => {\n clearTimeout(this.longPressTimer);\n };\n\n /**\n * Handler for the contextmenu event, which should be suppressed during\n * mobile long-press events on the host element.\n */\n // NB: Arrow function so 'this' remains bound to the controller\n private handleContextMenu = (e: Event): void => {\n e.preventDefault();\n };\n\n /**\n * Immediately causes the hover pane to begin fading out, if it is present.\n */\n // NB: Arrow function so 'this' remains bound to the controller\n private handleBackdropInteraction = (e: Event): void => {\n if (this.hoverPaneState !== 'hidden') {\n this.fadeOutHoverPane();\n }\n e.stopPropagation();\n };\n\n /**\n * Aborts and restarts the timer for showing the hover pane.\n */\n private restartShowHoverPaneTimer(): void {\n clearTimeout(this.showTimer);\n this.showTimer = window.setTimeout(() => {\n this.host.acquireFocus();\n this.showHoverPane();\n }, this.showDelay);\n }\n\n /**\n * Causes this tile's hover pane to be rendered, positioned, and made visible.\n */\n private async showHoverPane(\n options: {\n anchor: HoverPanePositionAnchor;\n } = {\n anchor: 'cursor',\n },\n ): Promise<void> {\n this.hoverPaneState = 'shown';\n this.host.requestUpdate();\n\n // Wait for the state update to render the hover pane\n await this.host.updateComplete;\n\n // Ensure the hover pane element is still in the document before showing,\n // as it might have been removed by the previous update.\n if (!this.hoverPane?.isConnected) return;\n\n this.hoverPane?.showPopover?.();\n await new Promise(resolve => {\n // Pane sizes aren't accurate until next frame\n requestAnimationFrame(resolve);\n });\n\n // Apply the correct positioning to the hover pane\n this.repositionHoverPane(options.anchor);\n\n // The hover pane is initially not visible (to avoid it shifting around\n // while being positioned). Since it now has the correct positioning, we\n // can make it visible and begin its fade-in animation.\n this.hoverPane?.classList.add('visible', 'fade-in');\n }\n\n /**\n * Causes this tile's hover pane to begin fading out and starts\n * the timer for it to be removed.\n */\n private fadeOutHoverPane(): void {\n this.hoverPaneState = 'fading-out';\n this.hoverPane?.classList.remove('fade-in');\n\n clearTimeout(this.hideTimer);\n this.hideTimer = window.setTimeout(() => {\n this.hoverPaneState = 'hidden';\n if (this.hoverPane) {\n this.hoverPane.tabIndex = -1;\n }\n this.host.requestUpdate();\n }, 100);\n }\n\n /**\n * Positions the hover pane with the correct offsets.\n */\n private repositionHoverPane(anchor: HoverPanePositionAnchor): void {\n if (!this.hoverPane) return;\n\n const { top, left } = this.makePaneDesiredOffsets(anchor);\n\n this.hoverPane.style.top = `${top}px`;\n this.hoverPane.style.left = `${left}px`;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"hover-pane-controller.js","sourceRoot":"","sources":["../../../../src/tiles/hover/hover-pane-controller.ts"],"names":[],"mappings":"AAC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;OAEG;IACK,mBAAmB,CAAC,MAA+B;QACzD,IAAI,CAAC,IAAI,CAAC,SAAS;YAAE,OAAO;QAE5B,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC;QAE1D,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAG,GAAG,GAAG,GAAG,IAAI,CAAC;QACtC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,GAAG,GAAG,IAAI,IAAI,CAAC;IAC1C,CAAC;CACF","sourcesContent":["import type { SortParam } from '@internetarchive/search-service';\r\nimport {\r\n html,\r\n HTMLTemplateResult,\r\n nothing,\r\n ReactiveController,\r\n ReactiveControllerHost,\r\n} from 'lit';\r\nimport type { TileModel } from '../../models';\r\nimport type { CollectionTitles } from '../../data-source/models';\r\nimport { msg } from '@lit/localize';\r\n\r\ntype HoverPaneState = 'hidden' | 'shown' | 'fading-out';\r\n\r\n// the anchor point of the hover pane\r\n// can be either the mouse cursor or near the host element\r\n// in the case of mouse navigation, we want it to follow the cursor\r\n// in the case of keyboard navigation, we want it to appear near the host element\r\ntype HoverPanePositionAnchor = 'host' | 'cursor';\r\n\r\nexport interface HoverPaneProperties {\r\n model?: TileModel;\r\n baseNavigationUrl?: string;\r\n baseImageUrl?: string;\r\n loggedIn: boolean;\r\n suppressBlurring: boolean;\r\n sortParam: SortParam | null;\r\n collectionTitles?: CollectionTitles;\r\n}\r\n\r\nexport interface HoverPaneControllerOptions {\r\n offsetX?: number;\r\n offsetY?: number;\r\n enableLongPress?: boolean;\r\n showDelay?: number;\r\n hideDelay?: number;\r\n longPressDelay?: number;\r\n mobileBreakpoint?: number;\r\n}\r\n\r\n/** A common interface for providing a hover pane element. */\r\nexport interface HoverPaneProviderInterface {\r\n /** Returns the provider's currently rendered hover pane element. */\r\n getHoverPane(): HTMLElement | undefined;\r\n /** Returns properties that should be passed to the hover pane. */\r\n getHoverPaneProps(): HoverPaneProperties;\r\n /** When user has keyboard navigated out of more info, we want the host to get focus */\r\n acquireFocus(): void;\r\n /** When user has keyboard navigated out of more info, we want the host to lose focus */\r\n releaseFocus(): void;\r\n}\r\n\r\nexport interface ToggleHoverPaneOptions {\r\n coords: { x: number; y: number };\r\n enableTouchBackdrop?: boolean;\r\n}\r\n\r\n/**\r\n * An interface for interacting with hover pane controllers (e.g.,\r\n * to retrieve their current hover pane template).\r\n */\r\nexport interface HoverPaneControllerInterface extends ReactiveController {\r\n /**\r\n * Returns the hover pane template to render based on this controller's\r\n * current state. The returned template may be `nothing` if the hover\r\n * pane should not currently be rendered.\r\n */\r\n getTemplate(): HTMLTemplateResult | typeof nothing;\r\n\r\n /**\r\n * Requests to manually toggle the state of the hover pane.\r\n * If the hover pane is already shown, it will begin fading out and then\r\n * subsequently be hidden and removed. If the hover pane is already fading\r\n * out or hidden, it will fade back in and be shown.\r\n */\r\n toggleHoverPane(options: ToggleHoverPaneOptions): void;\r\n}\r\n\r\nconst clamp = (val: number, min = -Infinity, max = Infinity) =>\r\n Math.max(min, Math.min(val, max));\r\n\r\nexport class HoverPaneController implements HoverPaneControllerInterface {\r\n /**\r\n * The hover pane element attached to this controller's host.\r\n */\r\n private hoverPane?: HTMLElement;\r\n\r\n /**\r\n * The properties to be passed to the hover pane element\r\n */\r\n private hoverPaneProps?: HoverPaneProperties;\r\n\r\n /**\r\n * The breakpoint (in pixels) below which the mobile interface should be used.\r\n */\r\n private mobileBreakpoint?: number = 600;\r\n\r\n /**\r\n * The number of horizontal pixels the hover pane should be offset from the\r\n * pointer position.\r\n */\r\n private offsetX: number = -10;\r\n\r\n /**\r\n * The number of vertical pixels the hover pane should be offset from the\r\n * pointer position.\r\n */\r\n private offsetY: number = 15;\r\n\r\n /**\r\n * The delay between the mouse idling within the host element and when the hover\r\n * pane should begin fading in (in milliseconds).\r\n */\r\n private showDelay: number = 300;\r\n\r\n /**\r\n * The delay between when the mouse leaves the host element and when the hover\r\n * pane should begin fading out (in milliseconds).\r\n */\r\n private hideDelay: number = 100;\r\n\r\n /**\r\n * The delay between when a touch event begins on the host element and when the\r\n * hover pane should begin fading in (in milliseconds).\r\n */\r\n private longPressDelay: number = 600;\r\n\r\n /**\r\n * Whether long press interactions should cause the hover pane to appear (when\r\n * below the mobile breakpoint).\r\n */\r\n private enableLongPress: boolean = false;\r\n\r\n /**\r\n * Used to control the current state of this provider's hover pane.\r\n * - `'hidden'` => The hover pane is not present at all.\r\n * - `'shown'` => The hover pane is either fading in or fully visible.\r\n * - `'fading-out'` => The hover pane is fading out and about to be removed.\r\n */\r\n private hoverPaneState: HoverPaneState = 'hidden';\r\n\r\n /** The timer ID for showing the hover pane */\r\n private showTimer?: number;\r\n\r\n /** The timer ID for hiding the hover pane */\r\n private hideTimer?: number;\r\n\r\n /** The timer ID for recognizing a long press event */\r\n private longPressTimer?: number;\r\n\r\n /**\r\n * Whether the touch backdrop should currently be rendered irrespective of other touch\r\n * interactions being enabled.\r\n */\r\n private forceTouchBackdrop: boolean = false;\r\n\r\n /** A record of the last mouse position on the host element, for positioning the hover pane */\r\n private lastPointerClientPos = { x: 0, y: 0 };\r\n\r\n /**\r\n * A flag to track whether the host element is being clicked by a pointer device, so that we\r\n * don't trigger unnecessary keyboard focus behaviors on click. This is needed, e.g., to prevent\r\n * the hover pane from appearing immediately at its `host` positioning on click, which can\r\n * obstruct the host element itself (due to the ordering of events fired).\r\n */\r\n private clicking = false;\r\n\r\n constructor(\r\n /** The host element to which this controller should attach listeners */\r\n private readonly host: ReactiveControllerHost &\r\n HoverPaneProviderInterface &\r\n HTMLElement,\r\n /** Options for adjusting the hover pane behavior (offsets, delays, etc.) */\r\n options: HoverPaneControllerOptions = {},\r\n ) {\r\n this.mobileBreakpoint = options.mobileBreakpoint ?? this.mobileBreakpoint;\r\n this.offsetX = options.offsetX ?? this.offsetX;\r\n this.offsetY = options.offsetY ?? this.offsetY;\r\n this.showDelay = options.showDelay ?? this.showDelay;\r\n this.hideDelay = options.hideDelay ?? this.hideDelay;\r\n this.longPressDelay = options.longPressDelay ?? this.longPressDelay;\r\n this.enableLongPress = options.enableLongPress ?? this.enableLongPress;\r\n\r\n this.host.addController(this);\r\n }\r\n\r\n hostConnected(): void {\r\n this.attachListeners();\r\n }\r\n\r\n hostDisconnected(): void {\r\n this.detachListeners();\r\n }\r\n\r\n hostUpdated(): void {\r\n this.hoverPane = this.host.getHoverPane();\r\n this.hoverPaneProps = this.host.getHoverPaneProps();\r\n }\r\n\r\n /** @inheritdoc */\r\n getTemplate(): HTMLTemplateResult | typeof nothing {\r\n this.hoverPaneProps = this.host.getHoverPaneProps();\r\n\r\n return this.shouldRenderHoverPane\r\n ? html`\r\n ${this.touchBackdropTemplate}\r\n <tile-hover-pane\r\n popover\r\n tabindex=\"-1\"\r\n aria-describedby=\"tile-hover-pane-aria-description\"\r\n .model=${this.hoverPaneProps?.model}\r\n .baseNavigationUrl=${this.hoverPaneProps?.baseNavigationUrl}\r\n .baseImageUrl=${this.hoverPaneProps?.baseImageUrl}\r\n .loggedIn=${this.hoverPaneProps?.loggedIn}\r\n .suppressBlurring=${this.hoverPaneProps?.suppressBlurring}\r\n .sortParam=${this.hoverPaneProps?.sortParam}\r\n .collectionTitles=${this.hoverPaneProps?.collectionTitles}\r\n .mobileBreakpoint=${this.mobileBreakpoint}\r\n .currentWidth=${window.innerWidth}\r\n ></tile-hover-pane>\r\n <div id=\"tile-hover-pane-aria-description\" class=\"sr-only\">\r\n ${msg('Press Up Arrow to exit item detail preview')}\r\n </div>\r\n `\r\n : nothing;\r\n }\r\n\r\n /** @inheritdoc */\r\n toggleHoverPane(options: ToggleHoverPaneOptions): void {\r\n if (this.hoverPaneState === 'shown') {\r\n this.fadeOutHoverPane();\r\n this.forceTouchBackdrop = false;\r\n } else {\r\n this.lastPointerClientPos = options.coords;\r\n this.forceTouchBackdrop = options.enableTouchBackdrop ?? false;\r\n this.showHoverPane();\r\n }\r\n }\r\n\r\n /**\r\n * Produces a template for the invisible touch capture backdrop that\r\n * is used to cancel the hover pane on touch devices. We want any\r\n * touch interaction on the backdrop to remove the hover pane, and\r\n * we don't want to bubble up mouse events that would otherwise\r\n * affect the state of the hover pane (e.g., fading it back in).\r\n */\r\n private get touchBackdropTemplate(): HTMLTemplateResult | typeof nothing {\r\n return this.showTouchBackdrop\r\n ? html`<div\r\n id=\"touch-backdrop\"\r\n @touchstart=${this.handleBackdropInteraction}\r\n @touchmove=${this.handleBackdropInteraction}\r\n @touchend=${this.handleBackdropInteraction}\r\n @touchcancel=${this.handleBackdropInteraction}\r\n @mouseenter=${(e: MouseEvent) => e.stopPropagation()}\r\n @mousemove=${(e: MouseEvent) => e.stopPropagation()}\r\n @mouseleave=${(e: MouseEvent) => e.stopPropagation()}\r\n ></div>`\r\n : nothing;\r\n }\r\n\r\n private get showTouchBackdrop(): boolean {\r\n return (\r\n (this.isTouchEnabled && this.enableLongPress) || this.forceTouchBackdrop\r\n );\r\n }\r\n\r\n /** Whether to use the mobile layout */\r\n private get isMobileView(): boolean {\r\n return !!this.mobileBreakpoint && window.innerWidth < this.mobileBreakpoint;\r\n }\r\n\r\n private get isHoverEnabled(): boolean {\r\n return window.matchMedia('(hover: hover)').matches;\r\n }\r\n\r\n private get isTouchEnabled(): boolean {\r\n return (\r\n 'ontouchstart' in window &&\r\n window.matchMedia('(any-pointer: coarse)').matches\r\n );\r\n }\r\n\r\n /** Whether this controller should currently render its hover pane. */\r\n private get shouldRenderHoverPane(): boolean {\r\n return this.hoverPaneState !== 'hidden';\r\n }\r\n\r\n /**\r\n * Returns the desired top/left offsets (in pixels) for this tile's hover pane.\r\n * The desired offsets balance positioning the hover pane under the primary pointer\r\n * while preventing it from flowing outside the viewport. The returned offsets are\r\n * relative to the viewport, intended to position the pane as a popover element.\r\n *\r\n * These offsets are only valid if the hover pane is already rendered with its\r\n * correct width and height. If the hover pane is not present, the returned offsets\r\n * will simply represent the current pointer position.\r\n */\r\n private makePaneDesiredOffsets(anchor: HoverPanePositionAnchor): {\r\n top: number;\r\n left: number;\r\n } {\r\n // Try to find offsets for the hover pane that:\r\n // (a) cause it to lie entirely within the viewport, and\r\n // (b) to the extent possible, minimize the distance between the\r\n // nearest corner of the hover pane and the mouse/host element position\r\n // (with some additional offsets applied after the fact).\r\n\r\n let [left, top] = [0, 0];\r\n switch (anchor) {\r\n case 'host':\r\n const hostRect = this.host.getBoundingClientRect();\r\n // slight inset from host top left corner\r\n left = hostRect.left + 20;\r\n top = hostRect.top + 30;\r\n break;\r\n case 'cursor':\r\n left = this.lastPointerClientPos.x;\r\n top = this.lastPointerClientPos.y;\r\n break;\r\n }\r\n\r\n // Flip the hover pane according to which quadrant of the viewport the coordinates are in.\r\n // (Similar to how Wikipedia's link hover panes work)\r\n const flipHorizontal = left > window.innerWidth / 2;\r\n const flipVertical = top > window.innerHeight / 2;\r\n\r\n const hoverPaneRect = this.hoverPane?.getBoundingClientRect();\r\n if (hoverPaneRect) {\r\n // If we need to flip the hover pane, do so by subtracting its width/height from left/top\r\n if (flipHorizontal) {\r\n left -= hoverPaneRect.width;\r\n }\r\n if (flipVertical) {\r\n top -= hoverPaneRect.height;\r\n }\r\n\r\n // Apply desired offsets from the target position\r\n left += (flipHorizontal ? -1 : 1) * this.offsetX;\r\n top += (flipVertical ? -1 : 1) * this.offsetY;\r\n\r\n // On mobile view, shunt the hover pane to avoid overflowing the viewport\r\n if (this.isMobileView) {\r\n left = clamp(left, 20, window.innerWidth - hoverPaneRect.width - 20);\r\n top = clamp(top, 20, window.innerHeight - hoverPaneRect.height - 20);\r\n }\r\n }\r\n\r\n left += window.scrollX;\r\n top += window.scrollY;\r\n\r\n return { left, top };\r\n }\r\n\r\n /**\r\n * Adds to the host element all the listeners necessary to make the\r\n * hover pane functional.\r\n */\r\n private attachListeners(): void {\r\n // keyboard navigation listeners\r\n this.host.addEventListener('focus', this.handleFocus);\r\n this.host.addEventListener('blur', this.handleBlur);\r\n this.host.addEventListener('pointerdown', this.handlePointerDown);\r\n this.host.addEventListener('keyup', this.handleKeyUp);\r\n this.host.addEventListener('keydown', this.handleKeyDown);\r\n\r\n if (this.isHoverEnabled) {\r\n this.host.addEventListener('mouseenter', this.handleMouseEnter);\r\n this.host.addEventListener('mousemove', this.handleMouseMove);\r\n this.host.addEventListener('mouseleave', this.handleMouseLeave);\r\n }\r\n\r\n if (this.isTouchEnabled && this.enableLongPress) {\r\n this.host.addEventListener('touchstart', this.handleTouchStart);\r\n this.host.addEventListener('touchmove', this.handleLongPressCancel);\r\n this.host.addEventListener('touchend', this.handleLongPressCancel);\r\n this.host.addEventListener('touchcancel', this.handleLongPressCancel);\r\n this.host.addEventListener('contextmenu', this.handleContextMenu);\r\n }\r\n }\r\n\r\n /**\r\n * Removes all the hover pane listeners from the host element.\r\n */\r\n private detachListeners(): void {\r\n this.host.removeEventListener('mouseenter', this.handleMouseEnter);\r\n this.host.removeEventListener('mousemove', this.handleMouseMove);\r\n this.host.removeEventListener('mouseleave', this.handleMouseLeave);\r\n this.host.removeEventListener('touchstart', this.handleTouchStart);\r\n this.host.removeEventListener('touchmove', this.handleLongPressCancel);\r\n this.host.removeEventListener('touchend', this.handleLongPressCancel);\r\n this.host.removeEventListener('touchcancel', this.handleLongPressCancel);\r\n this.host.removeEventListener('contextmenu', this.handleContextMenu);\r\n\r\n // keyboard navigation listeners\r\n this.host.removeEventListener('focus', this.handleFocus);\r\n this.host.removeEventListener('blur', this.handleBlur);\r\n this.host.removeEventListener('keyup', this.handleKeyUp);\r\n this.host.removeEventListener('keydown', this.handleKeyDown);\r\n }\r\n\r\n private handleFocus = (): void => {\r\n if (!this.clicking && this.hoverPaneState === 'hidden') {\r\n this.showHoverPane({\r\n anchor: 'host',\r\n });\r\n }\r\n this.clicking = false;\r\n };\r\n\r\n private handleBlur = (): void => {\r\n if (this.hoverPaneState !== 'hidden') {\r\n this.fadeOutHoverPane();\r\n }\r\n };\r\n\r\n private handlePointerDown = (): void => {\r\n this.clicking = true;\r\n };\r\n\r\n private handleKeyDown = (e: KeyboardEvent): void => {\r\n if (\r\n (e.key === 'ArrowDown' || e.key === 'ArrowUp') &&\r\n this.hoverPaneState !== 'hidden'\r\n ) {\r\n e.preventDefault();\r\n }\r\n };\r\n\r\n private handleKeyUp = (e: KeyboardEvent): void => {\r\n if (this.hoverPaneState === 'hidden' || !this.hoverPane) return;\r\n if (e.key === 'ArrowDown') {\r\n this.hoverPane.tabIndex = 1;\r\n this.hoverPane.focus();\r\n }\r\n\r\n const isArrowUp = e.key === 'ArrowUp';\r\n const isEscape = e.key === 'Escape' || e.key === 'Esc';\r\n\r\n if (isEscape) {\r\n this.fadeOutHoverPane();\r\n }\r\n if (isArrowUp || isEscape) {\r\n this.hoverPane.tabIndex = -1;\r\n this.host.acquireFocus();\r\n }\r\n };\r\n\r\n /**\r\n * Handler for the mouseenter event on the host element.\r\n */\r\n // NB: Arrow function so 'this' remains bound to the controller\r\n private handleMouseEnter = (e: MouseEvent): void => {\r\n // Delegate to the mousemove handler, as they are currently processed identically\r\n this.handleMouseMove(e);\r\n };\r\n\r\n /**\r\n * Handler for the mousemove event on the host element.\r\n * Aborts any pending hide/fade-out for the hover pane, and restarts the\r\n * timer to show it.\r\n */\r\n // NB: Arrow function so 'this' remains bound to the controller\r\n private handleMouseMove = (e: MouseEvent): void => {\r\n // The mouse is within the tile, so abort any pending removal of the hover pane\r\n clearTimeout(this.hideTimer);\r\n\r\n // If the hover pane is currently fading out, just make it fade back in where it is\r\n if (this.hoverPaneState === 'fading-out') {\r\n this.hoverPaneState = 'shown';\r\n this.hoverPane?.classList.add('fade-in');\r\n }\r\n\r\n // Restart the timer to show the hover pane anytime the mouse moves within the tile\r\n if (this.hoverPaneState === 'hidden') {\r\n this.restartShowHoverPaneTimer();\r\n this.lastPointerClientPos = { x: e.clientX, y: e.clientY };\r\n }\r\n };\r\n\r\n /**\r\n * Handler for the mouseleave event on the host element.\r\n * Hides the hover pane if present, and aborts the timer for showing it.\r\n */\r\n // NB: Arrow function so 'this' remains bound to the controller\r\n private handleMouseLeave = (): void => {\r\n this.host.releaseFocus();\r\n\r\n // Abort any timer to show the hover pane, as the mouse has left the tile\r\n clearTimeout(this.showTimer);\r\n\r\n // Hide the hover pane if it's already been shown\r\n if (this.hoverPaneState !== 'hidden') {\r\n this.hideTimer = window.setTimeout(() => {\r\n this.fadeOutHoverPane();\r\n }, this.hideDelay);\r\n }\r\n };\r\n\r\n /**\r\n * Handler for the touchstart event on the host element.\r\n * Begins the timer for recognizing a long press event.\r\n */\r\n // NB: Arrow function so 'this' remains bound to the controller\r\n private handleTouchStart = (e: TouchEvent): void => {\r\n clearTimeout(this.longPressTimer);\r\n\r\n if (e.touches.length === 1) {\r\n this.longPressTimer = window.setTimeout(() => {\r\n if (this.hoverPaneState === 'hidden') {\r\n this.showHoverPane();\r\n }\r\n }, this.longPressDelay);\r\n\r\n this.lastPointerClientPos = {\r\n x: e.touches[0].clientX,\r\n y: e.touches[0].clientY,\r\n };\r\n }\r\n };\r\n\r\n /**\r\n * Handler for events that should cancel a pending long press event\r\n * (touchmove, touchend, touchcancel). Aborts the timer for recognizing\r\n * a long press.\r\n */\r\n // NB: Arrow function so 'this' remains bound to the controller\r\n private handleLongPressCancel = (): void => {\r\n clearTimeout(this.longPressTimer);\r\n };\r\n\r\n /**\r\n * Handler for the contextmenu event, which should be suppressed during\r\n * mobile long-press events on the host element.\r\n */\r\n // NB: Arrow function so 'this' remains bound to the controller\r\n private handleContextMenu = (e: Event): void => {\r\n e.preventDefault();\r\n };\r\n\r\n /**\r\n * Immediately causes the hover pane to begin fading out, if it is present.\r\n */\r\n // NB: Arrow function so 'this' remains bound to the controller\r\n private handleBackdropInteraction = (e: Event): void => {\r\n if (this.hoverPaneState !== 'hidden') {\r\n this.fadeOutHoverPane();\r\n }\r\n e.stopPropagation();\r\n };\r\n\r\n /**\r\n * Aborts and restarts the timer for showing the hover pane.\r\n */\r\n private restartShowHoverPaneTimer(): void {\r\n clearTimeout(this.showTimer);\r\n this.showTimer = window.setTimeout(() => {\r\n this.host.acquireFocus();\r\n this.showHoverPane();\r\n }, this.showDelay);\r\n }\r\n\r\n /**\r\n * Causes this tile's hover pane to be rendered, positioned, and made visible.\r\n */\r\n private async showHoverPane(\r\n options: {\r\n anchor: HoverPanePositionAnchor;\r\n } = {\r\n anchor: 'cursor',\r\n },\r\n ): Promise<void> {\r\n this.hoverPaneState = 'shown';\r\n this.host.requestUpdate();\r\n\r\n // Wait for the state update to render the hover pane\r\n await this.host.updateComplete;\r\n\r\n // Ensure the hover pane element is still in the document before showing,\r\n // as it might have been removed by the previous update.\r\n if (!this.hoverPane?.isConnected) return;\r\n\r\n this.hoverPane?.showPopover?.();\r\n await new Promise(resolve => {\r\n // Pane sizes aren't accurate until next frame\r\n requestAnimationFrame(resolve);\r\n });\r\n\r\n // Apply the correct positioning to the hover pane\r\n this.repositionHoverPane(options.anchor);\r\n\r\n // The hover pane is initially not visible (to avoid it shifting around\r\n // while being positioned). Since it now has the correct positioning, we\r\n // can make it visible and begin its fade-in animation.\r\n this.hoverPane?.classList.add('visible', 'fade-in');\r\n }\r\n\r\n /**\r\n * Causes this tile's hover pane to begin fading out and starts\r\n * the timer for it to be removed.\r\n */\r\n private fadeOutHoverPane(): void {\r\n this.hoverPaneState = 'fading-out';\r\n this.hoverPane?.classList.remove('fade-in');\r\n\r\n clearTimeout(this.hideTimer);\r\n this.hideTimer = window.setTimeout(() => {\r\n this.hoverPaneState = 'hidden';\r\n if (this.hoverPane) {\r\n this.hoverPane.tabIndex = -1;\r\n }\r\n this.host.requestUpdate();\r\n }, 100);\r\n }\r\n\r\n /**\r\n * Positions the hover pane with the correct offsets.\r\n */\r\n private repositionHoverPane(anchor: HoverPanePositionAnchor): void {\r\n if (!this.hoverPane) return;\r\n\r\n const { top, left } = this.makePaneDesiredOffsets(anchor);\r\n\r\n this.hoverPane.style.top = `${top}px`;\r\n this.hoverPane.style.left = `${left}px`;\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../../src/tiles/models.ts"],"names":[],"mappings":"","sourcesContent":["export type SimpleLayoutType = 'none' | 'stats-only' | 'snippets-only';\n"]}
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../../src/tiles/models.ts"],"names":[],"mappings":"","sourcesContent":["export type SimpleLayoutType = 'none' | 'stats-only' | 'snippets-only';\r\n"]}
|