wc-country-name
Version:
A web component for displaying country name in desired locale
2 lines (1 loc) • 1.08 kB
JavaScript
import{S as u,i as p,a as y,b as i,f as r,s as $,e as h,t as m,n as l,c as f,d as g,g as b}from"./svelte.js";function x(a){let t,o;return{c(){t=h("div"),o=m(a[0]),this.c=l},m(e,s){i(e,t,s),f(t,o)},p(e,[s]){s&1&&g(o,e[0])},i:l,o:l,d(e){e&&b(t)}}}function v(a,t,o){let{displaylocale:e}=t,{countrycode:s}=t,n;return a.$$set=c=>{"displaylocale"in c&&o(1,e=c.displaylocale),"countrycode"in c&&o(2,s=c.countrycode)},a.$$.update=()=>{if(a.$$.dirty&6&&e&&s){const c=new Intl.DisplayNames([e],{type:"region"});o(0,n=c.of(s))}},[n,e,s]}class d extends u{constructor(t){super(),p(this,{target:this.shadowRoot,props:y(this.attributes),customElement:!0},v,x,$,{displaylocale:1,countrycode:2},null),t&&(t.target&&i(t.target,this,t.anchor),t.props&&(this.$set(t.props),r()))}static get observedAttributes(){return["displaylocale","countrycode"]}get displaylocale(){return this.$$.ctx[1]}set displaylocale(t){this.$$set({displaylocale:t}),r()}get countrycode(){return this.$$.ctx[2]}set countrycode(t){this.$$set({countrycode:t}),r()}}customElements.define("country-name",d);export{d as default};