@fluid-topics/ft-i18n 1.1.31 → 1.1.33
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/build/ft-i18n.js +1 -1
- package/build/ft-i18n.light.js +2 -2
- package/build/ft-i18n.min.js +1 -1
- package/package.json +4 -4
package/build/ft-i18n.js
CHANGED
|
@@ -29,7 +29,7 @@ class FtI18n extends FtLitElementReduxWithI18n {
|
|
|
29
29
|
update(props) {
|
|
30
30
|
var _a;
|
|
31
31
|
super.update(props);
|
|
32
|
-
if (this.context && this.key) {
|
|
32
|
+
if (["context", "key", "defaultMessage"].some(a => props.has(a)) && this.context && this.key) {
|
|
33
33
|
this.addI18nMessages(this.context, { [this.key]: (_a = this.defaultMessage) !== null && _a !== void 0 ? _a : "" });
|
|
34
34
|
}
|
|
35
35
|
}
|
package/build/ft-i18n.light.js
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
`,o=i.css`
|
|
3
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))}))}}))}}var h;const l=Symbol("clearAfterUnitTest");class c{constructor(t){this.messageContextProvider=t,this.defaultMessages={},this.cache=new s.CacheRegistry,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=l,null==window.FluidTopicsI18nService&&(window.FluidTopicsI18nService=new c((async(t,s)=>(await r.await()).getFluidTopicsMessageContext(t,s)))),null==window.FluidTopicsCustomI18nService&&(window.FluidTopicsCustomI18nService=new c((async(t,s)=>(await r.await()).getCustomMessageContext(t,s))));const u=window.FluidTopicsI18nService,d=window.FluidTopicsCustomI18nService;var v=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 w 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`
|
|
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=>u.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()))}}w.elementDefinitions={},w.styles=o,v([e.property()],w.prototype,"baseUrl",void 0),v([e.property()],w.prototype,"apiIntegrationIdentifier",void 0),v([e.property()],w.prototype,"uiLocale",void 0),v([s.jsonProperty(null)],w.prototype,"availableUiLocales",void 0),v([s.jsonProperty(null)],w.prototype,"metadataConfiguration",void 0),v([e.property({type:Boolean})],w.prototype,"editorMode",void 0),v([e.property({type:Boolean})],w.prototype,"noCustom",void 0),v([e.property({converter:{fromAttribute:t=>"false"!==t&&("true"===t||null!=t&&t)}})],w.prototype,"noCustomComponent",void 0),v([e.property({type:Boolean})],w.prototype,"withManualResources",void 0),v([s.jsonProperty([])],w.prototype,"messageContexts",void 0),v([s.jsonProperty(void 0)],w.prototype,"session",void 0),v([e.property({type:Object})],w.prototype,"apiProvider",void 0);class f{async listMySearches(){var t;return(null===(t=a.getState().session)||void 0===t?void 0:t.sessionAuthenticated)?(await r.await()).listMySearches(a.getState().session.profile.userId):[]}}const
|
|
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=>u.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()))}}w.elementDefinitions={},w.styles=o,v([e.property()],w.prototype,"baseUrl",void 0),v([e.property()],w.prototype,"apiIntegrationIdentifier",void 0),v([e.property()],w.prototype,"uiLocale",void 0),v([s.jsonProperty(null)],w.prototype,"availableUiLocales",void 0),v([s.jsonProperty(null)],w.prototype,"metadataConfiguration",void 0),v([e.property({type:Boolean})],w.prototype,"editorMode",void 0),v([e.property({type:Boolean})],w.prototype,"noCustom",void 0),v([e.property({converter:{fromAttribute:t=>"false"!==t&&("true"===t||null!=t&&t)}})],w.prototype,"noCustomComponent",void 0),v([e.property({type:Boolean})],w.prototype,"withManualResources",void 0),v([s.jsonProperty([])],w.prototype,"messageContexts",void 0),v([s.jsonProperty(void 0)],w.prototype,"session",void 0),v([e.property({type:Object})],w.prototype,"apiProvider",void 0);class f{async listMySearches(){var t;return(null===(t=a.getState().session)||void 0===t?void 0:t.sessionAuthenticated)?(await r.await()).listMySearches(a.getState().session.profile.userId):[]}}const y=new s.CacheRegistry;class p{async listMyBookmarks(){return y.get("bookmarks",(async()=>(await r.await()).listMyBookmarks(a.getState().session.profile.userId)))}clearCache(){y.clear("bookmarks")}}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 p,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(){m.actions.savedSearches(void 0)}clearMyBookmarks(){m.actions.bookmarks(void 0)}async reloadMySearches(){const t=new f,s=await t.listMySearches();m.actions.savedSearches(s)}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")(w);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("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?d:u}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;null===(s=this[g])||void 0===s||s.forEach(((s,i)=>{s.context.toLowerCase()===t.toLowerCase()&&(this[i]=this.i18n(s))})),setTimeout((()=>this.requestUpdate()),0)}update(t){var s;super.update(t),null===(s=this[g])||void 0===s||s.forEach(((t,s)=>{null!=t.argsProvider&&(this[s]=this.i18n(t))}))}connectedCallback(){super.connectedCallback(),null!=this[g]&&new Set([...this[g].values()].map((t=>t.context))).forEach((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(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 x extends(k(s.FtLitElement)){}class M extends(k(s.FtLitElementRedux)){}var S=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 M{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),this.context&&this.key&&this.addI18nMessages(this.context,{[this.key]:null!==(s=this.defaultMessage)&&void 0!==s?s:""})}}U.elementDefinitions={},U.styles=n,
|
|
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,S([s.redux()],U.prototype,"editorMode",void 0),S([e.property()],U.prototype,"context",void 0),S([e.property()],U.prototype,"key",void 0),S([s.jsonProperty([])],U.prototype,"args",void 0),S([e.property()],U.prototype,"defaultMessage",void 0);class I{static build(t){return new I(t)}static fromGwt(t){return new I(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)=>u.resolveMessage(this.name,s,...t)})}}s.customElement("ft-i18n")(U),t.FtI18n=U,t.FtI18nCssVariables={},t.FtLitElementReduxWithI18n=M,t.FtLitElementWithI18n=x,t.I18nMessageContext=I,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[g]=null!==(o=i[g])&&void 0!==o?o:new Map,i[g].set(e,a)},t.i18nProperties=g,t.i18nUnsubs=C,t.styles=n,t.withI18n=k}({},ftGlobals.wcUtils,ftGlobals.lit,ftGlobals.litDecorators);
|
package/build/ft-i18n.min.js
CHANGED
|
@@ -106,4 +106,4 @@ const No=window,wo=No.ShadowRoot&&(void 0===No.ShadyCSS||No.ShadyCSS.nativeShado
|
|
|
106
106
|
<span class="ft-i18n">
|
|
107
107
|
${this.i18n(this.context,this.key,...Array.isArray(this.args)?this.args:[])}
|
|
108
108
|
</span>
|
|
109
|
-
`:this.editorMode?"Select a context and a label key.":oo}update(t){var o;super.update(t),this.context&&this.key&&this.addI18nMessages(this.context,{[this.key]:null!==(o=this.defaultMessage)&&void 0!==o?o:""})}}Qr.elementDefinitions={},Qr.styles=Lr,Xr([(t=>{const o=null!=t?t:{};return(t,e)=>{var r;const n={hasChanged:(t,o)=>!I(t,o),attribute:!1,...o};R(n)(t,e);const i=t.constructor;i.reduxProperties=new Map(i.reduxProperties),i.reduxProperties.set(e,{selector:null!==(r=o.selector)&&void 0!==r?r:t=>t[e],store:o.store})}})()],Qr.prototype,"editorMode",void 0),Xr([R()],Qr.prototype,"context",void 0),Xr([R()],Qr.prototype,"key",void 0),Xr([L([])],Qr.prototype,"args",void 0),Xr([R()],Qr.prototype,"defaultMessage",void 0);class tn{static build(t){return new tn(t)}static fromGwt(t){return new tn(t)}constructor(t){this.name=t,this.properties=new Proxy({},{get:(t,o)=>{const e=o;return t=>({context:this.name,key:e,args:"function"==typeof t?void 0:t,argsProvider:"function"==typeof t?t:void 0})}}),this.messages=new Proxy({},{get:(t,o)=>(...t)=>Fr.resolveMessage(this.name,o,...t)})}}W("ft-i18n")(Qr),t.FtI18n=Qr,t.FtI18nCssVariables={},t.FtLitElementReduxWithI18n=Jr,t.FtLitElementWithI18n=Vr,t.I18nMessageContext=tn,t.i18n=(t,o)=>(e,r)=>{var n,i;e.constructor.createProperty(r,null!=o?o:{attribute:!1,type:String});const a={...t,key:null!==(n=t.key)&&void 0!==n?n:r};e[Gr]=null!==(i=e[Gr])&&void 0!==i?i:new Map,e[Gr].set(r,a)},t.i18nProperties=Gr,t.i18nUnsubs=qr,t.styles=Lr,t.withI18n=Yr}({});
|
|
109
|
+
`:this.editorMode?"Select a context and a label key.":oo}update(t){var o;super.update(t),["context","key","defaultMessage"].some((o=>t.has(o)))&&this.context&&this.key&&this.addI18nMessages(this.context,{[this.key]:null!==(o=this.defaultMessage)&&void 0!==o?o:""})}}Qr.elementDefinitions={},Qr.styles=Lr,Xr([(t=>{const o=null!=t?t:{};return(t,e)=>{var r;const n={hasChanged:(t,o)=>!I(t,o),attribute:!1,...o};R(n)(t,e);const i=t.constructor;i.reduxProperties=new Map(i.reduxProperties),i.reduxProperties.set(e,{selector:null!==(r=o.selector)&&void 0!==r?r:t=>t[e],store:o.store})}})()],Qr.prototype,"editorMode",void 0),Xr([R()],Qr.prototype,"context",void 0),Xr([R()],Qr.prototype,"key",void 0),Xr([L([])],Qr.prototype,"args",void 0),Xr([R()],Qr.prototype,"defaultMessage",void 0);class tn{static build(t){return new tn(t)}static fromGwt(t){return new tn(t)}constructor(t){this.name=t,this.properties=new Proxy({},{get:(t,o)=>{const e=o;return t=>({context:this.name,key:e,args:"function"==typeof t?void 0:t,argsProvider:"function"==typeof t?t:void 0})}}),this.messages=new Proxy({},{get:(t,o)=>(...t)=>Fr.resolveMessage(this.name,o,...t)})}}W("ft-i18n")(Qr),t.FtI18n=Qr,t.FtI18nCssVariables={},t.FtLitElementReduxWithI18n=Jr,t.FtLitElementWithI18n=Vr,t.I18nMessageContext=tn,t.i18n=(t,o)=>(e,r)=>{var n,i;e.constructor.createProperty(r,null!=o?o:{attribute:!1,type:String});const a={...t,key:null!==(n=t.key)&&void 0!==n?n:r};e[Gr]=null!==(i=e[Gr])&&void 0!==i?i:new Map,e[Gr].set(r,a)},t.i18nProperties=Gr,t.i18nUnsubs=qr,t.styles=Lr,t.withI18n=Yr}({});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fluid-topics/ft-i18n",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.33",
|
|
4
4
|
"description": "Integrated component that displays internationalized label from a Fluid Topics portal.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Lit"
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"url": "ssh://git@scm.mrs.antidot.net:2222/fluidtopics/ft-web-components.git"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@fluid-topics/ft-app-context": "1.1.
|
|
23
|
-
"@fluid-topics/ft-wc-utils": "1.1.
|
|
22
|
+
"@fluid-topics/ft-app-context": "1.1.33",
|
|
23
|
+
"@fluid-topics/ft-wc-utils": "1.1.33",
|
|
24
24
|
"lit": "3.1.0"
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "25cbbfada37d7c107ea0a7742ff3230c0dc74b3b"
|
|
27
27
|
}
|