+var __decorate=this&&this.__decorate||function(t,e,i,n){var o,a=arguments.length,s=a<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,e,i,n);else for(var c=t.length-1;c>=0;c--)(o=t[c])&&(s=(a<3?o(s):a>3?o(e,i,s):o(e,i))||s);return a>3&&s&&Object.defineProperty(e,i,s),s};import{LitElement,html,css}from"./lit/index.min.js";import{customElement,property}from"./lit/decorators.min.js";import{classMap}from"./lit/directives/class-map.min.js";import{unsafeHTML}from"./lit/directives/unsafe-html.min.js";import{join}from"./lit/directives/join.min.js";let NinjaAction=class extends LitElement{constructor(){super(),this.selected=!1,this.hotKeysJoinedView=!0,this.addEventListener("click",this.click)}ensureInView(){this.scrollIntoView({block:"nearest"})}click(){this.dispatchEvent(new CustomEvent("actionsSelected",{detail:this.action,bubbles:!0,composed:!0}))}updated(t){t.has("selected")&&this.selected&&this.ensureInView()}highlightMatch(t,e){const tt=new DOMParser().parseFromString(t,'text/html').body.textContent||"";let i="",n=0,o=0;for(o=0;o<tt.length;o++)e[n]===o?(i+=`<span class="highlight">${t[o]}</span>`,n++):i+=t[o];if(o<t.length){i+=t.slice(o);}return unsafeHTML(i)}render(){let t,e;this.action.mdIcon?t=html`<div>${this.action.mdIcon}</div>`:this.action.icon&&(t=this.action.icon?unsafeHTML(`<div class="ninja-icon">${this.action.icon}</div>`):""),this.action.hotkey&&(e=this.hotKeysJoinedView?this.action.hotkey.split(",").map((t=>{const e=t.split("+"),i=html`${join(e.map((t=>html`<kbd>${t}</kbd>`)),"+")}`;return html`<div class="ninja-hotkey ninja-hotkeys">${i}</div>`})):this.action.hotkey.split(",").map((t=>{const e=t.split("+").map((t=>html`<kbd class="ninja-hotkey">${t}</kbd>`));return html`<kbd class="ninja-hotkeys">${e}</kbd>`})));const i={selected:this.selected,"ninja-action":!0};return html`
0 commit comments