UNPKG

@liascript/exporter

Version:
1 lines 4.96 kB
!function(t,e,i,a,s){var n="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},r="function"==typeof n[a]&&n[a],o=r.cache||{},l="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function u(e,i){if(!o[e]){if(!t[e]){var s="function"==typeof n[a]&&n[a];if(!i&&s)return s(e,!0);if(r)return r(e,!0);if(l&&"string"==typeof e)return l(e);var c=new Error("Cannot find module '"+e+"'");throw c.code="MODULE_NOT_FOUND",c}h.resolve=function(i){var a=t[e][1][i];return null!=a?a:i},h.cache={};var m=o[e]=new u.Module(e);t[e][0].call(m.exports,h,m,m.exports,this)}return o[e].exports;function h(t){var e=h.resolve(t);return!1===e?{}:u(e)}}u.isParcelRequire=!0,u.Module=function(t){this.id=t,this.bundle=u,this.exports={}},u.modules=t,u.cache=o,u.parent=r,u.register=function(e,i){t[e]=[function(t,e){e.exports=i},{}]},Object.defineProperty(u,"root",{get:function(){return n[a]}}),n[a]=u;for(var c=0;c<e.length;c++)u(e[c]);if(i){var m=u(i);"object"==typeof exports&&"undefined"!=typeof module?module.exports=m:"function"==typeof define&&define.amd&&define((function(){return m}))}}({"4B9Rr":[function(t,e,i){let a;!function(t){t.DateTime="datetime",t.List="list",t.Number="number",t.PluralRules="pluralrules",t.RelativeTime="relativetime"}(a||(a={})),customElements.define("lia-format",class extends HTMLElement{constructor(){super(),this.span=document.createElement("span"),this.option={},this.value_="",this.format,this.locale}connectedCallback(){switch(this.attachShadow({mode:"open"}).appendChild(this.span),this.locale=this.get("locale")||void 0,this.format=this.get("format")||void 0,this.format){case"number":this.option={compactDisplay:this.get("compactDisplay"),currency:this.get("currency"),currencyDisplay:this.get("currencyDisplay"),currencySign:this.get("currencySign"),localeMatcher:this.get("localeMatcher"),maximumFractionDigits:this.get("maximumFractionDigits"),maximumSignificantDigits:this.get("maximumSignificantDigits"),minimumFractionDigits:this.get("minimumFractionDigits"),minimumIntegerDigits:this.get("minimumIntegerDigits"),minimumSignificantDigits:this.get("minimumSignificantDigits"),notation:this.get("notation"),numberingSystem:this.get("numberingSystem"),signDisplay:this.get("signDisplay"),style:this.get("localeStyle"),unit:this.get("unit"),unitDisplay:this.get("unitDisplay"),useGrouping:this.get("useGrouping")};break;case"datetime":this.option={calendar:this.get("calendar"),dateStyle:this.get("dateStyle"),day:this.get("day"),dayPeriod:this.get("dayPeriod"),era:this.get("era"),formatMatcher:this.get("formatMatcher"),fractionalSecondDigits:this.get("fractionalSecondDigits"),hour:this.get("hour"),hour12:this.get("hour12"),hourCycle:this.get("hourCycle"),localeMatcher:this.get("localeMatcher"),minute:this.get("minute"),month:this.get("month"),numberingSystem:this.get("numberingSystem"),second:this.get("second"),timeStyle:this.get("timeStyle"),timeZone:this.get("timeZone"),timeZoneName:this.get("timeZoneName"),weekday:this.get("weekday"),year:this.get("year")};break;case"relativetime":this.unit=this.get("unit")||void 0,this.option={localeMatcher:this.get("localeMatcher"),numeric:this.get("numeric"),style:this.get("localeStyle")};break;case"list":this.option={localeMatcher:this.get("localeMatcher"),style:this.get("localeStyle"),type:this.get("type")};break;case"pluralrules":this.option={localeMatcher:this.get("localeMatcher"),maximumFractionDigits:this.get("maximumFractionDigits"),maximumSignificantDigits:this.get("maximumSignificantDigits"),minimumFractionDigits:this.get("minimumFractionDigits"),minimumIntegerDigits:this.get("minimumIntegerDigits"),minimumSignificantDigits:this.get("minimumSignificantDigits"),type:this.get("type")};break;default:this.option={}}this.value_=this.textContent||"",this.view()}view(){let t="";try{switch(this.format){case a.Number:t=new Intl.NumberFormat(this.locale,this.option).format(parseFloat(this.value_));break;case a.DateTime:t=new Intl.DateTimeFormat(this.locale,this.option).format(Date.parse(this.value_));break;case a.RelativeTime:t=new Intl.RelativeTimeFormat(this.locale,this.option).format(this.value_,this.unit);break;case a.List:t=new Intl.ListFormat(this.locale,this.option).format(JSON.parse(this.value_));break;case a.PluralRules:t=new Intl.PluralRules(this.locale,this.option).select(parseFloat(this.value_))}}catch(t){console.warn("intl-format: ",t.message)}this.span.innerText=t||this.value_}get(t){const e=this.getAttribute(t);return null===e?void 0:e}get value(){return this.value_}getFormat(){switch(this.get("format")){case a.DateTime:return a.DateTime;case a.List:return a.List;case a.Number:return a.Number;case a.PluralRules:return a.PluralRules;case a.RelativeTime:return a.RelativeTime}return null}set value(t){this.value_!==t&&(this.value_=t,this.view())}disconnectedCallback(){}})},{}]},["4B9Rr"],"4B9Rr","parcelRequire55a5");