import { property, state } from "lit/decorators.js"; import { msg, localized, str } from "@lit/localize"; import LiteElement, { html } from "../utils/LiteElement"; type URLs = string[]; /** * Show pending exclusions in crawl queue * * Usage example: * ```ts * * ``` */ @localized() export class CrawlPendingExclusions extends LiteElement { @property({ type: Array }) matchedURLs: URLs | null = null; @state() private page: number = 1; @state() private pageSize: number = 30; @state() private isOpen: boolean = false; private get total(): number { return this.matchedURLs?.length || 0; } private get pageResults(): URLs { if (!this.matchedURLs) return []; return this.matchedURLs.slice( (this.page - 1) * this.pageSize, this.page * this.pageSize ); } render() { return html` (this.isOpen = e.detail.open)} > ${msg("Pending Exclusions")} ${this.renderBadge()}
${this.isOpen && this.total && this.total > this.pageSize ? html` { this.page = e.detail.page; }} > ` : ""}
${this.renderContent()}
`; } private renderBadge() { if (!this.matchedURLs) return ""; return html` ${this.total ? this.total > 1 ? msg(str`+${this.total.toLocaleString()} URLs`) : msg(str`+1 URL`) : msg("No matches")} `; } private renderContent() { if (!this.total) { return html`

${this.matchedURLs ? msg("No matching URLs found in queue.") : msg( "Start typing an exclusion to view matching URLs in the queue." )}

`; } return html` ({ order: idx + 1 + (this.page - 1) * this.pageSize, content: html`${url}`, }))} aria-live="polite" style="--link-color: var(--sl-color-danger-600); --link-hover-color: var(--sl-color-danger-400);" > `; } }