UNPKG

@yuebai008/cli

Version:

Command line interface for rapid qg-minigame development

3 lines 1.58 kB
import*as ComponentHelpers from"../../../ui/components/helpers/helpers.js";import*as LitHtml from"../../../ui/lit-html/lit-html.js";import adornerStyles from"./adorner.css.js";const{render:render,html:html}=LitHtml;export class Adorner extends HTMLElement{static litTagName=LitHtml.literal`devtools-adorner`;name="";#t=this.attachShadow({mode:"open"});#e=!1;#i;#s;#a;set data(t){this.name=t.name,t.content.slot="content",this.#a?.remove(),this.append(t.content),this.#a=t.content,this.#o()}connectedCallback(){this.getAttribute("aria-label")||this.setAttribute("aria-label",this.name),this.#t.adoptedStyleSheets=[adornerStyles]}isActive(){return"true"===this.getAttribute("aria-pressed")}toggle(t){if(!this.#e)return;const e=void 0===t?!this.isActive():t;this.setAttribute("aria-pressed",Boolean(e).toString()),this.setAttribute("aria-label",(e?this.#s:this.#i)||this.name)}show(){this.classList.remove("hidden")}hide(){this.classList.add("hidden")}addInteraction(t,e){const{isToggle:i=!1,shouldPropagateOnKeydown:s=!1,ariaLabelDefault:a,ariaLabelActive:o}=e;this.#e=i,this.#i=a,this.#s=o,this.setAttribute("aria-label",a),i&&(this.addEventListener("click",(()=>{this.toggle()})),this.toggle(!1)),this.addEventListener("click",t),this.classList.add("clickable"),this.setAttribute("role","button"),this.tabIndex=0,this.addEventListener("keydown",(t=>{"Enter"!==t.code&&"Space"!==t.code||(this.click(),s||t.stopPropagation())}))}#o(){render(html` <slot name="content"></slot> `,this.#t,{host:this})}}ComponentHelpers.CustomElements.defineComponent("devtools-adorner",Adorner);