import { html, render } from "/js/lib/lit-html.js"; import { Component, getChildrenFragment } from "/js/components/component.js"; import "/js/components/app-icon.js"; class ModerationWarning extends Component { connectedCallback() { if (this._initialized) { return; } this.label = this.getAttribute("label"); this.labelerLink = this.getAttribute("labelerLink"); this.labelerName = this.getAttribute("labelerName"); this.iconStyle = this.getAttribute("icon-style") ?? "info"; this.expanded = false; this._children = getChildrenFragment(this); this.innerHTML = ""; this.render(); this._initialized = true; } render() { const iconHtml = this.iconStyle === "closed-eye" ? html`` : html``; render( html`
this.toggle()} @keydown=${(e) => { if (e.key === "Enter" || e.key === " ") { e.preventDefault(); e.stopPropagation(); this.toggle(); } }} > ${iconHtml} ${this.label}
${this.labelerName ? html`
Labeled by ${this.labelerLink ? html`${this.labelerName}` : this.labelerName}
` : ""} `, this, ); const toggleContent = this.querySelector(".toggle-content"); if (toggleContent) { toggleContent.appendChild(this._children); } } toggle() { this.expanded = !this.expanded; this.render(); } } ModerationWarning.register();