@fluid-topics/ft-i18n 1.1.40 → 1.1.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/build/ft-i18n.js +1 -1
- package/build/ft-i18n.light.js +3 -3
- package/build/ft-i18n.min.js +98 -21
- package/build/index.d.ts +1 -1
- package/build/index.js +1 -1
- package/package.json +4 -4
- /package/build/{ft-i18n.css.d.ts → ft-i18n.styles.d.ts} +0 -0
- /package/build/{ft-i18n.css.js → ft-i18n.styles.js} +0 -0
package/README.md
CHANGED
package/build/ft-i18n.js
CHANGED
|
@@ -7,7 +7,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
7
7
|
import { html, nothing } from "lit";
|
|
8
8
|
import { property } from "lit/decorators.js";
|
|
9
9
|
import { jsonProperty, redux } from "@fluid-topics/ft-wc-utils";
|
|
10
|
-
import { styles } from "./ft-i18n.
|
|
10
|
+
import { styles } from "./ft-i18n.styles";
|
|
11
11
|
import { FtLitElementReduxWithI18n } from "./lit/i18n";
|
|
12
12
|
import { ftAppInfoStore } from "@fluid-topics/ft-app-context";
|
|
13
13
|
class FtI18n extends FtLitElementReduxWithI18n {
|
package/build/ft-i18n.light.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
!function(t,s,i,e){const n=i.css`
|
|
2
2
|
`,o=i.css`
|
|
3
|
-
`,a=s.FtReduxStore.get({name:"ft-app-info",reducers:{},initialState:{baseUrl:void 0,apiIntegrationIdentifier:void 0,uiLocale:document.documentElement.lang||"en-US",availableUiLocales:[],metadataConfiguration:void 0,editorMode:!1,noCustom:!1,noCustomComponent:!1,session:void 0}});class r{static build(t){const{baseUrl:s,apiIntegrationIdentifier:i}=a.getState(),e=null!=t?t:i;if(s&&e&&window.fluidtopics)return new window.fluidtopics.FluidTopicsApi(s,e,!0)}static get(t){var s;return null!=t?r.build(t):null!==(s=r.API)&&void 0!==s?s:r.API=r.build()}static await(t){return new Promise((s=>{let i=r.get(t);if(i)s(i);else{const e=a.subscribe((()=>{i=r.get(t),i&&(e(),s(i))}))}}))}}class l{constructor(t=!0,i){var e;this.overrideApi=i;let n=this.constructor;n.commonCache=null!==(e=n.commonCache)&&void 0!==e?e:new s.CacheRegistry,this.cache=t?n.commonCache:new s.CacheRegistry}get api(){var t;return null!==(t=this.overrideApi)&&void 0!==t?t:r.get()}get awaitApi(){var t;return null!==(t=this.overrideApi)&&void 0!==t?t:r.await()}clearCache(){this.cache.clearAll()}}var h;const u=Symbol("clearAfterUnitTest");class d extends l{constructor(t){super(),this.messageContextProvider=t,this.defaultMessages={},this.listeners={},this.currentUiLocale="",this[h]=()=>{this.defaultMessages={},this.cache=new s.CacheRegistry,this.listeners={}},this.currentUiLocale=a.getState().uiLocale,a.subscribe((()=>this.clearWhenUiLocaleChanges()))}clearWhenUiLocaleChanges(){const{uiLocale:t}=a.getState();this.currentUiLocale!==t&&(this.currentUiLocale=t,this.cache.clearAll(),this.notifyAll())}addContext(t){const s=t.name.toLowerCase();this.cache.setFinal(s,t),this.notify(s)}getAllContexts(){return this.cache.resolvedValues()}async prepareContext(t,i){var e;if(t=t.toLowerCase(),Object.keys(i).length>0){const n={...null!==(e=this.defaultMessages[t])&&void 0!==e?e:{},...i};s.deepEqual(this.defaultMessages[t],n)||(this.defaultMessages[t]=n,await this.notify(t))}await this.fetchContext(t)}resolveMessage(t,i,...e){var n,o,a;t=t.toLowerCase(),this.fetchContext(t);const r=null!==(o=null===(n=this.cache.getNow(t))||void 0===n?void 0:n.messages)&&void 0!==o?o:{};return new s.ParametrizedLabelResolver(null!==(a=this.defaultMessages[t])&&void 0!==a?a:{},r).resolve(i,...e)}async fetchContext(t){if(!this.cache.has(t))try{await this.cache.get(t,(()=>this.messageContextProvider(this.currentUiLocale,t))),await this.notify(t)}catch(t){console.error(t)}}subscribe(t,s){var i;return t=t.toLowerCase(),this.listeners[t]=null!==(i=this.listeners[t])&&void 0!==i?i:new Set,this.listeners[t].add(s),()=>{var i;return null===(i=this.listeners[t])||void 0===i?void 0:i.delete(s)}}async notifyAll(){await Promise.all(Object.keys(this.listeners).map((t=>this.notify(t))))}async notify(t){null!=this.listeners[t]&&await Promise.all([...this.listeners[t].values()].map((t=>s.delay(0).then((()=>t())).catch((()=>null)))))}}h=u,null==window.FluidTopicsI18nService&&(window.FluidTopicsI18nService=new class extends d{constructor(){super((async(t,s)=>(await this.awaitApi).getFluidTopicsMessageContext(t,s)))}}),null==window.FluidTopicsCustomI18nService&&(window.FluidTopicsCustomI18nService=new class extends d{constructor(){super((async(t,s)=>(await this.awaitApi).getCustomMessageContext(t,s)))}});const c=window.FluidTopicsI18nService,v=window.FluidTopicsCustomI18nService;var w=function(t,s,i,e){for(var n,o=arguments.length,a=o<3?s:null===e?e=Object.getOwnPropertyDescriptor(s,i):e,r=t.length-1;r>=0;r--)(n=t[r])&&(a=(o<3?n(a):o>3?n(s,i,a):n(s,i))||a);return o>3&&a&&Object.defineProperty(s,i,a),a};class p extends s.FtLitElement{constructor(){super(...arguments),this.apiIntegrationIdentifier="ft-integration",this.uiLocale="en-US",this.editorMode=!1,this.noCustom=!1,this.noCustomComponent=!1,this.withManualResources=!1,this.messageContexts=[],this.apiProvider=()=>r.get(),this.cache=new s.CacheRegistry,this.cleanSessionDebouncer=new s.Debouncer}render(){return i.html`
|
|
3
|
+
`,a=s.FtReduxStore.get({name:"ft-app-info",reducers:{},initialState:{baseUrl:void 0,apiIntegrationIdentifier:void 0,uiLocale:document.documentElement.lang||"en-US",availableUiLocales:[],metadataConfiguration:void 0,editorMode:!1,noCustom:!1,noCustomComponent:!1,session:void 0,openExternalDocumentInNewTab:!1}});class r{static build(t){const{baseUrl:s,apiIntegrationIdentifier:i}=a.getState(),e=null!=t?t:i;if(s&&e&&window.fluidtopics)return new window.fluidtopics.FluidTopicsApi(s,e,!0)}static get(t){var s;return null!=t?r.build(t):null!==(s=r.API)&&void 0!==s?s:r.API=r.build()}static await(t){return new Promise((s=>{let i=r.get(t);if(i)s(i);else{const e=a.subscribe((()=>{i=r.get(t),i&&(e(),s(i))}))}}))}}class l{constructor(t=!0,i){var e;this.overrideApi=i;let n=this.constructor;n.commonCache=null!==(e=n.commonCache)&&void 0!==e?e:new s.CacheRegistry,this.cache=t?n.commonCache:new s.CacheRegistry}get api(){var t;return null!==(t=this.overrideApi)&&void 0!==t?t:r.get()}get awaitApi(){var t;return null!==(t=this.overrideApi)&&void 0!==t?t:r.await()}clearCache(){this.cache.clearAll()}}var h;const u=Symbol("clearAfterUnitTest");class d extends l{constructor(t){super(),this.messageContextProvider=t,this.defaultMessages={},this.listeners={},this.currentUiLocale="",this[h]=()=>{this.defaultMessages={},this.cache=new s.CacheRegistry,this.listeners={}},this.currentUiLocale=a.getState().uiLocale,a.subscribe((()=>this.clearWhenUiLocaleChanges()))}clearWhenUiLocaleChanges(){const{uiLocale:t}=a.getState();this.currentUiLocale!==t&&(this.currentUiLocale=t,this.cache.clearAll(),this.notifyAll())}addContext(t){const s=t.name.toLowerCase();this.cache.setFinal(s,t),this.notify(s)}getAllContexts(){return this.cache.resolvedValues()}async prepareContext(t,i){var e;if(t=t.toLowerCase(),Object.keys(i).length>0){const n={...null!==(e=this.defaultMessages[t])&&void 0!==e?e:{},...i};s.deepEqual(this.defaultMessages[t],n)||(this.defaultMessages[t]=n,await this.notify(t))}await this.fetchContext(t)}resolveMessage(t,i,...e){var n,o,a;t=t.toLowerCase(),this.fetchContext(t);const r=null!==(o=null===(n=this.cache.getNow(t))||void 0===n?void 0:n.messages)&&void 0!==o?o:{};return new s.ParametrizedLabelResolver(null!==(a=this.defaultMessages[t])&&void 0!==a?a:{},r).resolve(i,...e)}async fetchContext(t){if(!this.cache.has(t))try{await this.cache.get(t,(()=>this.messageContextProvider(this.currentUiLocale,t))),await this.notify(t)}catch(t){console.error(t)}}subscribe(t,s){var i;return t=t.toLowerCase(),this.listeners[t]=null!==(i=this.listeners[t])&&void 0!==i?i:new Set,this.listeners[t].add(s),()=>{var i;return null===(i=this.listeners[t])||void 0===i?void 0:i.delete(s)}}async notifyAll(){await Promise.all(Object.keys(this.listeners).map((t=>this.notify(t))))}async notify(t){null!=this.listeners[t]&&await Promise.all([...this.listeners[t].values()].map((t=>s.delay(0).then((()=>t())).catch((()=>null)))))}}h=u,null==window.FluidTopicsI18nService&&(window.FluidTopicsI18nService=new class extends d{constructor(){super((async(t,s)=>(await this.awaitApi).getFluidTopicsMessageContext(t,s)))}}),null==window.FluidTopicsCustomI18nService&&(window.FluidTopicsCustomI18nService=new class extends d{constructor(){super((async(t,s)=>(await this.awaitApi).getCustomMessageContext(t,s)))}});const c=window.FluidTopicsI18nService,v=window.FluidTopicsCustomI18nService;var w=function(t,s,i,e){for(var n,o=arguments.length,a=o<3?s:null===e?e=Object.getOwnPropertyDescriptor(s,i):e,r=t.length-1;r>=0;r--)(n=t[r])&&(a=(o<3?n(a):o>3?n(s,i,a):n(s,i))||a);return o>3&&a&&Object.defineProperty(s,i,a),a};class p extends s.FtLitElement{constructor(){super(...arguments),this.apiIntegrationIdentifier="ft-integration",this.uiLocale="en-US",this.editorMode=!1,this.noCustom=!1,this.openExternalDocumentInNewTab=!1,this.noCustomComponent=!1,this.withManualResources=!1,this.messageContexts=[],this.apiProvider=()=>r.get(),this.cache=new s.CacheRegistry,this.cleanSessionDebouncer=new s.Debouncer}render(){return i.html`
|
|
4
4
|
<slot></slot>
|
|
5
|
-
`}update(t){super.update(t),t.has("baseUrl")&&(a.actions.baseUrl(this.baseUrl),window.fluidTopicsBaseUrl=this.baseUrl),t.has("apiIntegrationIdentifier")&&a.actions.apiIntegrationIdentifier(this.apiIntegrationIdentifier),t.has("uiLocale")&&a.actions.uiLocale(this.uiLocale),t.has("metadataConfiguration")&&a.actions.metadataConfiguration(this.metadataConfiguration),t.has("noCustom")&&a.actions.noCustom(this.noCustom),t.has("editorMode")&&a.actions.editorMode(this.editorMode),t.has("noCustomComponent")&&a.actions.noCustomComponent(this.noCustomComponent),t.has("session")&&a.actions.session(this.session),t.has("availableUiLocales")&&a.actions.availableUiLocales(Array.isArray(this.availableUiLocales)?this.availableUiLocales:[]),t.has("messageContexts")&&null!=this.messageContexts&&this.messageContexts.forEach((t=>c.addContext(t))),setTimeout((()=>this.updateIfNeeded()))}async updateIfNeeded(){!this.withManualResources&&this.apiProvider()&&(null==this.session&&this.updateSession(),null==this.availableUiLocales&&this.updateUiLocales(),null==this.metadataConfiguration&&this.updateMetadataConfiguration())}async updateSession(){this.session=await this.cache.get("session",(async()=>{const t=await this.apiProvider().getCurrentSession();return t.idleTimeoutInMillis>0&&this.cleanSessionDebouncer.run((()=>{this.cache.clear("session"),this.session=void 0}),t.idleTimeoutInMillis),t}))}async updateUiLocales(){this.availableUiLocales=await this.cache.get("availableUiLocales",(()=>this.apiProvider().getAvailableUiLocales()))}async updateMetadataConfiguration(){this.metadataConfiguration=await this.cache.get("metadataConfiguration",(()=>this.apiProvider().getMetadataConfiguration()))}}p.elementDefinitions={},p.styles=o,w([e.property()],p.prototype,"baseUrl",void 0),w([e.property()],p.prototype,"apiIntegrationIdentifier",void 0),w([e.property()],p.prototype,"uiLocale",void 0),w([s.jsonProperty(null)],p.prototype,"availableUiLocales",void 0),w([s.jsonProperty(null)],p.prototype,"metadataConfiguration",void 0),w([e.property({type:Boolean})],p.prototype,"editorMode",void 0),w([e.property({type:Boolean})],p.prototype,"noCustom",void 0),w([e.property({converter:{fromAttribute:t=>"false"!==t&&("true"===t||null!=t&&t)}})],p.prototype,"noCustomComponent",void 0),w([e.property({type:Boolean})],p.prototype,"withManualResources",void 0),w([s.jsonProperty([])],p.prototype,"messageContexts",void 0),w([s.jsonProperty(void 0)],p.prototype,"session",void 0),w([e.property({type:Object})],p.prototype,"apiProvider",void 0);class y extends l{async listMySearches(){let t=a.getState().session;return(null==t?void 0:t.sessionAuthenticated)?this.cache.get("my-searches",(async()=>(await this.awaitApi).listMySearches(t.profile.userId)),3e5):[]}}class f extends l{async listMyBookmarks(){let t=a.getState().session;return(null==t?void 0:t.sessionAuthenticated)?this.cache.get("my-bookmarks",(async()=>(await this.awaitApi).listMyBookmarks(t.profile.userId)),3e5):[]}}const m=s.FtReduxStore.get({name:"ft-user-assets",initialState:{savedSearches:void 0,bookmarks:void 0}});new class{constructor(){this.currentSession=a.getState().session,this.bookmarksAreUsed=!1,this.bookmarksService=new f,this.savedSearchesService=new y,a.subscribe((()=>this.reloadWhenUserSessionChanges()))}reloadWhenUserSessionChanges(){var t;const{session:i}=a.getState();s.deepEqual(null===(t=this.currentSession)||void 0===t?void 0:t.profile,null==i?void 0:i.profile)||(this.currentSession=i,this.clearMySearches(),this.reloadBookmarks())}clear(){this.clearMySearches(),this.clearMyBookmarks()}clearMySearches(){this.savedSearchesService.clearCache(),m.actions.savedSearches(void 0)}clearMyBookmarks(){this.bookmarksService.clearCache(),m.actions.bookmarks(void 0)}async reloadMySearches(){this.savedSearchesService.clearCache();const t=await this.savedSearchesService.listMySearches();m.actions.savedSearches(t)}async reloadBookmarks(){this.bookmarksService.clearCache(),await this.updateBookmarksIfUsed()}async registerBookmarkComponent(){this.bookmarksAreUsed=!0,await this.updateBookmarksIfUsed()}async updateBookmarksIfUsed(){var t;if(this.bookmarksAreUsed){const s=(null===(t=this.currentSession)||void 0===t?void 0:t.sessionAuthenticated)?await this.bookmarksService.listMyBookmarks():void 0;m.actions.bookmarks(s)}}},s.customElement("ft-app-context")(p);var b=function(t,s,i,e){for(var n,o=arguments.length,a=o<3?s:null===e?e=Object.getOwnPropertyDescriptor(s,i):e,r=t.length-1;r>=0;r--)(n=t[r])&&(a=(o<3?n(a):o>3?n(s,i,a):n(s,i))||a);return o>3&&a&&Object.defineProperty(s,i,a),a};const g=Symbol("i18nAttributes"),
|
|
5
|
+
`}update(t){super.update(t),t.has("baseUrl")&&(a.actions.baseUrl(this.baseUrl),window.fluidTopicsBaseUrl=this.baseUrl),t.has("apiIntegrationIdentifier")&&a.actions.apiIntegrationIdentifier(this.apiIntegrationIdentifier),t.has("uiLocale")&&a.actions.uiLocale(this.uiLocale),t.has("metadataConfiguration")&&a.actions.metadataConfiguration(this.metadataConfiguration),t.has("noCustom")&&a.actions.noCustom(this.noCustom),t.has("editorMode")&&a.actions.editorMode(this.editorMode),t.has("noCustomComponent")&&a.actions.noCustomComponent(this.noCustomComponent),t.has("session")&&a.actions.session(this.session),t.has("availableUiLocales")&&a.actions.availableUiLocales(Array.isArray(this.availableUiLocales)?this.availableUiLocales:[]),t.has("messageContexts")&&null!=this.messageContexts&&this.messageContexts.forEach((t=>c.addContext(t))),t.has("openExternalDocumentInNewTab")&&a.actions.openExternalDocumentInNewTab(this.openExternalDocumentInNewTab),setTimeout((()=>this.updateIfNeeded()))}async updateIfNeeded(){!this.withManualResources&&this.apiProvider()&&(null==this.session&&this.updateSession(),null==this.availableUiLocales&&this.updateUiLocales(),null==this.metadataConfiguration&&this.updateMetadataConfiguration())}async updateSession(){this.session=await this.cache.get("session",(async()=>{const t=await this.apiProvider().getCurrentSession();return t.idleTimeoutInMillis>0&&this.cleanSessionDebouncer.run((()=>{this.cache.clear("session"),this.session=void 0}),t.idleTimeoutInMillis),t}))}async updateUiLocales(){this.availableUiLocales=await this.cache.get("availableUiLocales",(()=>this.apiProvider().getAvailableUiLocales()))}async updateMetadataConfiguration(){this.metadataConfiguration=await this.cache.get("metadataConfiguration",(()=>this.apiProvider().getMetadataConfiguration()))}}p.elementDefinitions={},p.styles=o,w([e.property()],p.prototype,"baseUrl",void 0),w([e.property()],p.prototype,"apiIntegrationIdentifier",void 0),w([e.property()],p.prototype,"uiLocale",void 0),w([s.jsonProperty(null)],p.prototype,"availableUiLocales",void 0),w([s.jsonProperty(null)],p.prototype,"metadataConfiguration",void 0),w([e.property({type:Boolean})],p.prototype,"editorMode",void 0),w([e.property({type:Boolean})],p.prototype,"noCustom",void 0),w([e.property({type:Boolean})],p.prototype,"openExternalDocumentInNewTab",void 0),w([e.property({converter:{fromAttribute:t=>"false"!==t&&("true"===t||null!=t&&t)}})],p.prototype,"noCustomComponent",void 0),w([e.property({type:Boolean})],p.prototype,"withManualResources",void 0),w([s.jsonProperty([])],p.prototype,"messageContexts",void 0),w([s.jsonProperty(void 0)],p.prototype,"session",void 0),w([e.property({type:Object})],p.prototype,"apiProvider",void 0);class y extends l{async listMySearches(){let t=a.getState().session;return(null==t?void 0:t.sessionAuthenticated)?this.cache.get("my-searches",(async()=>(await this.awaitApi).listMySearches(t.profile.userId)),3e5):[]}}class f extends l{async listMyBookmarks(){let t=a.getState().session;return(null==t?void 0:t.sessionAuthenticated)?this.cache.get("my-bookmarks",(async()=>(await this.awaitApi).listMyBookmarks(t.profile.userId)),3e5):[]}}const m=s.FtReduxStore.get({name:"ft-user-assets",initialState:{savedSearches:void 0,bookmarks:void 0}});new class{constructor(){this.currentSession=a.getState().session,this.bookmarksAreUsed=!1,this.bookmarksService=new f,this.savedSearchesService=new y,a.subscribe((()=>this.reloadWhenUserSessionChanges()))}reloadWhenUserSessionChanges(){var t;const{session:i}=a.getState();s.deepEqual(null===(t=this.currentSession)||void 0===t?void 0:t.profile,null==i?void 0:i.profile)||(this.currentSession=i,this.clearMySearches(),this.reloadBookmarks())}clear(){this.clearMySearches(),this.clearMyBookmarks()}clearMySearches(){this.savedSearchesService.clearCache(),m.actions.savedSearches(void 0)}clearMyBookmarks(){this.bookmarksService.clearCache(),m.actions.bookmarks(void 0)}async reloadMySearches(){this.savedSearchesService.clearCache();const t=await this.savedSearchesService.listMySearches();m.actions.savedSearches(t)}async reloadBookmarks(){this.bookmarksService.clearCache(),await this.updateBookmarksIfUsed()}async registerBookmarkComponent(){this.bookmarksAreUsed=!0,await this.updateBookmarksIfUsed()}async updateBookmarksIfUsed(){var t;if(this.bookmarksAreUsed){const s=(null===(t=this.currentSession)||void 0===t?void 0:t.sessionAuthenticated)?await this.bookmarksService.listMyBookmarks():void 0;m.actions.bookmarks(s)}}},s.customElement("ft-app-context")(p);var b=function(t,s,i,e){for(var n,o=arguments.length,a=o<3?s:null===e?e=Object.getOwnPropertyDescriptor(s,i):e,r=t.length-1;r>=0;r--)(n=t[r])&&(a=(o<3?n(a):o>3?n(s,i,a):n(s,i))||a);return o>3&&a&&Object.defineProperty(s,i,a),a};const g=Symbol("i18nAttributes"),x=Symbol("i18nProperties"),C=Symbol("i18nUnsubs");function k(t){var s;class i extends t{constructor(){super(...arguments),this.useCustomMessageContexts=!1,this[s]=new Map}get i18nService(){return this.useCustomMessageContexts?v:c}i18n(t,s,...i){var e;if("string"==typeof t)return this.i18nService.resolveMessage(t,s,...i);const n=null!==(e=t.args)&&void 0!==e?e:t.argsProvider?t.argsProvider(this):[];return this.i18nService.resolveMessage(t.context,t.key,...n)}onI18nUpdate(t){var s,i;null===(s=this[g])||void 0===s||s.forEach(((s,i)=>{var e;const n=this.getI18nAttributeValue(i);(null===(e=null==n?void 0:n.context)||void 0===e?void 0:e.toLowerCase())===t.toLowerCase()&&this.updateI18nAttributeMessage(i,n,s)})),null===(i=this[x])||void 0===i||i.forEach(((s,i)=>{s.context.toLowerCase()===t.toLowerCase()&&(this[i]=this.i18n(s))})),setTimeout((()=>this.requestUpdate()),0)}updateI18nAttributeMessage(t,s,i){this[t]={...s,message:this.i18n({context:s.context,key:s.key,...i})}}update(t){var s,i;super.update(t),null===(s=this[g])||void 0===s||s.forEach(((s,i)=>{const e=this.getI18nAttributeValue(i);(null==e?void 0:e.context)&&e.key&&(t.has(i)||null!=s.argsProvider)&&(t.has(i)&&this.addI18nContext(e.context),this.updateI18nAttributeMessage(i,e,s))})),null===(i=this[x])||void 0===i||i.forEach(((t,s)=>{null!=t.argsProvider&&(this[s]=this.i18n(t))}))}getI18nAttributeValue(t){return this[t]}connectedCallback(){var t,s,i,e;super.connectedCallback(),new Set([...null!==(s=null===(t=this[x])||void 0===t?void 0:t.values())&&void 0!==s?s:[],...[...null!==(e=null===(i=this[g])||void 0===i?void 0:i.keys())&&void 0!==e?e:[]].map((t=>this.getI18nAttributeValue(t)))].map((t=>null==t?void 0:t.context))).forEach((t=>t&&this.addI18nMessages(t)))}addI18nMessages(t,s){t=t.toLowerCase(),this[C].has(t)||this[C].set(t,this.i18nService.subscribe(t,(()=>this.onI18nUpdate(t)))),this.i18nService.prepareContext(t,null!=s?s:{})}addI18nContext(t,s){this.addI18nMessages("string"==typeof t?t:t.name,s)}disconnectedCallback(){super.disconnectedCallback(),this[C].forEach((t=>t())),this[C].clear()}}return s=C,b([e.property({type:Boolean})],i.prototype,"useCustomMessageContexts",void 0),i}class M extends(k(s.FtLitElement)){}class S extends(k(s.FtLitElementRedux)){}var I=function(t,s,i,e){for(var n,o=arguments.length,a=o<3?s:null===e?e=Object.getOwnPropertyDescriptor(s,i):e,r=t.length-1;r>=0;r--)(n=t[r])&&(a=(o<3?n(a):o>3?n(s,i,a):n(s,i))||a);return o>3&&a&&Object.defineProperty(s,i,a),a};class U extends S{constructor(){super(),this.editorMode=!1,this.addStore(a)}render(){return this.key&&this.context?i.html`
|
|
6
6
|
<span class="ft-i18n">
|
|
7
7
|
${this.i18n(this.context,this.key,...Array.isArray(this.args)?this.args:[])}
|
|
8
8
|
</span>
|
|
9
|
-
`:this.editorMode?"Select a context and a label key.":i.nothing}update(t){var s;super.update(t),["context","key","defaultMessage"].some((s=>t.has(s)))&&this.context&&this.key&&this.addI18nMessages(this.context,{[this.key]:null!==(s=this.defaultMessage)&&void 0!==s?s:""})}}
|
|
9
|
+
`:this.editorMode?"Select a context and a label key.":i.nothing}update(t){var s;super.update(t),["context","key","defaultMessage"].some((s=>t.has(s)))&&this.context&&this.key&&this.addI18nMessages(this.context,{[this.key]:null!==(s=this.defaultMessage)&&void 0!==s?s:""})}}U.elementDefinitions={},U.styles=n,I([s.redux()],U.prototype,"editorMode",void 0),I([e.property()],U.prototype,"context",void 0),I([e.property()],U.prototype,"key",void 0),I([s.jsonProperty([])],U.prototype,"args",void 0),I([e.property()],U.prototype,"defaultMessage",void 0);class A{static build(t){return new A(t)}static fromGwt(t){return new A(t)}constructor(t){this.name=t,this.properties=new Proxy({},{get:(t,s)=>{const i=s;return t=>({context:this.name,key:i,args:"function"==typeof t?void 0:t,argsProvider:"function"==typeof t?t:void 0})}}),this.messages=new Proxy({},{get:(t,s)=>(...t)=>c.resolveMessage(this.name,s,...t)})}}s.customElement("ft-i18n")(U),t.FtI18n=U,t.FtI18nCssVariables={},t.FtLitElementReduxWithI18n=S,t.FtLitElementWithI18n=M,t.I18nMessageContext=A,t.i18n=(t,s)=>(i,e)=>{var n,o;i.constructor.createProperty(e,null!=s?s:{attribute:!1,type:String});const a={...t,key:null!==(n=t.key)&&void 0!==n?n:e};i[x]=null!==(o=i[x])&&void 0!==o?o:new Map,i[x].set(e,a)},t.i18nAttributes=g,t.i18nProperties=x,t.i18nUnsubs=C,t.styles=n,t.withI18n=k}({},ftGlobals.wcUtils,ftGlobals.lit,ftGlobals.litDecorators);
|