UNPKG

radh-ui

Version:

Stencil Component Starter

1 lines 899 B
import{r as t,c as s,h as e,g as n}from"./p-1a9f3501.js";function i(t,s){return new Promise((e,n)=>{fetch(`/assets/i18n/${t}.${s}.json`).then(t=>{t.ok?e(t.json()):n()},()=>n())})}class a{constructor(e){t(this,e),this.selected=s(this,"selected",7)}async loadStrings(){this.strings=await async function(t){let s,e=t.tagName.toLowerCase(),n=function(t){let s=t.closest("[lang]");return s?s.lang:"en"}(t);try{s=await i(e,n)}catch(a){console.warn(`no locale for ${e} (${n}) loading default locale en.`),s=await i(e,"en")}return s}(this.myComponent)}componentWillLoad(){return this.loadStrings()}async loadLocale(){this.loadStrings()}onListenClick(){this.selected.emit(this.name),this.addClass()}addClass(){this.myComponent.classList.add("active")}render(){return e("div",{id:"hello"},this.strings.hello," ",this.name)}get myComponent(){return n(this)}}a.style=".active{color:red}";export{a as radh_hello}