@everymatrix/general-styling-wrapper 1.66.2 → 1.67.0

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.
@@ -10,10 +10,15 @@ const mergeTranslations = (url, target) => {
10
10
  .then((res) => res.json())
11
11
  .then((data) => {
12
12
  Object.keys(data).forEach((item) => {
13
- target[item] = target[item] ? target[item] : target['en'];
13
+ target[item] = target[item] || target['en'];
14
14
  for (let key in data[item]) {
15
+ //if there is a key that no exists in target[en]
16
+ if (!target['en'][key]) {
17
+ return;
18
+ }
19
+ // if the key is not in target, then take from en
20
+ target[item][key] = target[item][key] || target['en'][key];
15
21
  if (typeof data[item][key] === 'object') {
16
- target[item][key] = target[item][key] || target['en'][key];
17
22
  Object.keys(data[item][key]).forEach((subKey) => {
18
23
  target[item][key][subKey] = data[item][key][subKey];
19
24
  });
@@ -4,10 +4,15 @@ export const mergeTranslations = (url, target) => {
4
4
  .then((res) => res.json())
5
5
  .then((data) => {
6
6
  Object.keys(data).forEach((item) => {
7
- target[item] = target[item] ? target[item] : target['en'];
7
+ target[item] = target[item] || target['en'];
8
8
  for (let key in data[item]) {
9
+ //if there is a key that no exists in target[en]
10
+ if (!target['en'][key]) {
11
+ return;
12
+ }
13
+ // if the key is not in target, then take from en
14
+ target[item][key] = target[item][key] || target['en'][key];
9
15
  if (typeof data[item][key] === 'object') {
10
- target[item][key] = target[item][key] || target['en'][key];
11
16
  Object.keys(data[item][key]).forEach((subKey) => {
12
17
  target[item][key][subKey] = data[item][key][subKey];
13
18
  });
@@ -6,10 +6,15 @@ const mergeTranslations = (url, target) => {
6
6
  .then((res) => res.json())
7
7
  .then((data) => {
8
8
  Object.keys(data).forEach((item) => {
9
- target[item] = target[item] ? target[item] : target['en'];
9
+ target[item] = target[item] || target['en'];
10
10
  for (let key in data[item]) {
11
+ //if there is a key that no exists in target[en]
12
+ if (!target['en'][key]) {
13
+ return;
14
+ }
15
+ // if the key is not in target, then take from en
16
+ target[item][key] = target[item][key] || target['en'][key];
11
17
  if (typeof data[item][key] === 'object') {
12
- target[item][key] = target[item][key] || target['en'][key];
13
18
  Object.keys(data[item][key]).forEach((subKey) => {
14
19
  target[item][key][subKey] = data[item][key][subKey];
15
20
  });
@@ -1 +1 @@
1
- import{r as t,h as s,g as e}from"./index-5d1b44a7.js";const i=class{constructor(s){t(this,s),this.stylingAppends=!1,this.setClientStyling=()=>{let t=document.createElement("style");t.innerHTML=this.clientStyling,this.el.prepend(t)},this.setClientStylingURL=()=>{let t=new URL(this.clientStylingUrl),s=document.createElement("style");fetch(t.href).then((t=>t.text())).then((t=>{s.innerHTML=t,setTimeout((()=>{this.el.prepend(s)}),1)})).catch((t=>{console.log("error ",t)}))},this.clientStyling="",this.clientStylingUrl="",this.translationUrl="",this.targetTranslations=void 0}componentDidRender(){this.stylingAppends||(this.clientStyling&&this.setClientStyling(),this.clientStylingUrl&&this.setClientStylingURL(),this.stylingAppends=!0)}async componentWillLoad(){const t=[];if(this.translationUrl){const i=(s=this.translationUrl,e=this.targetTranslations,new Promise((t=>{fetch(s).then((t=>t.json())).then((s=>{Object.keys(s).forEach((t=>{e[t]=e[t]?e[t]:e.en;for(let i in s[t])"object"==typeof s[t][i]?(e[t][i]=e[t][i]||e.en[i],Object.keys(s[t][i]).forEach((o=>{e[t][i][o]=s[t][i][o]}))):e[t][i]=s[t][i]})),t(!0)}))})));t.push(i)}var s,e;return await Promise.all(t)}render(){return s("div",{key:"4d3414408c7662f88331dbe655966237f74d6958",class:"StyleShell"},s("slot",{key:"1d004644d84602c4314bdf5dfc26b55b160f57df",name:"mainContent"}))}get el(){return e(this)}};i.style=":host{display:block}";export{i as general_styling_wrapper}
1
+ import{r as t,h as e,g as s}from"./index-5d1b44a7.js";const i=class{constructor(e){t(this,e),this.stylingAppends=!1,this.setClientStyling=()=>{let t=document.createElement("style");t.innerHTML=this.clientStyling,this.el.prepend(t)},this.setClientStylingURL=()=>{let t=new URL(this.clientStylingUrl),e=document.createElement("style");fetch(t.href).then((t=>t.text())).then((t=>{e.innerHTML=t,setTimeout((()=>{this.el.prepend(e)}),1)})).catch((t=>{console.log("error ",t)}))},this.clientStyling="",this.clientStylingUrl="",this.translationUrl="",this.targetTranslations=void 0}componentDidRender(){this.stylingAppends||(this.clientStyling&&this.setClientStyling(),this.clientStylingUrl&&this.setClientStylingURL(),this.stylingAppends=!0)}async componentWillLoad(){const t=[];if(this.translationUrl){const i=(e=this.translationUrl,s=this.targetTranslations,new Promise((t=>{fetch(e).then((t=>t.json())).then((e=>{Object.keys(e).forEach((t=>{s[t]=s[t]||s.en;for(let i in e[t]){if(!s.en[i])return;s[t][i]=s[t][i]||s.en[i],"object"==typeof e[t][i]?Object.keys(e[t][i]).forEach((o=>{s[t][i][o]=e[t][i][o]})):s[t][i]=e[t][i]}})),t(!0)}))})));t.push(i)}var e,s;return await Promise.all(t)}render(){return e("div",{key:"4d3414408c7662f88331dbe655966237f74d6958",class:"StyleShell"},e("slot",{key:"1d004644d84602c4314bdf5dfc26b55b160f57df",name:"mainContent"}))}get el(){return s(this)}};i.style=":host{display:block}";export{i as general_styling_wrapper}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@everymatrix/general-styling-wrapper",
3
- "version": "1.66.2",
3
+ "version": "1.67.0",
4
4
  "main": "./dist/index.cjs.js",
5
5
  "module": "./dist/index.js",
6
6
  "es2015": "./dist/esm/index.mjs",