builder-settings-types 0.0.317 → 0.0.318
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.
|
@@ -282,7 +282,7 @@
|
|
|
282
282
|
</svg>`;class ye extends H{constructor(t={}){super({...t,minValue:t.minValue??0,maxValue:t.maxValue??1e3,icon:t.icon||Ce,title:t.title||"Margin Bottom",default:t.default??20,wrapperClassName:"margin-bottom-wrapper "+(t.wrapperClassName||"")}),this.inputType="number"}}const be=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
283
283
|
<path d="M15.75 7.25H2.25m9.9 9h-6.3c-1.26 0-1.89 0-2.371-.245a2.25 2.25 0 0 1-.984-.983c-.245-.482-.245-1.112-.245-2.372v-6.3c0-1.26 0-1.89.245-2.371a2.25 2.25 0 0 1 .984-.984c.48-.245 1.11-.245 2.371-.245h6.3c1.26 0 1.89 0 2.371.245.424.216.768.56.984.984.245.48.245 1.11.245 2.371v6.3c0 1.26 0 1.89-.245 2.371-.216.424-.56.768-.984.984-.48.245-1.11.245-2.371.245"
|
|
284
284
|
stroke="#667085" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
285
|
-
</svg>`;class Ee extends H{constructor(t={}){super({...t,minValue:t.minValue??0,maxValue:t.maxValue??1e3,icon:t.icon||be,title:t.title||"Margin Top",default:t.default??20,wrapperClassName:"margin-top-wrapper "+(t.wrapperClassName||"")}),this.inputType="number"}}class we extends x{constructor(t){super(t),this.inputType={},this.container=null,this.defaultLanguage="",this.uploadSettings=new Map,this.popup=null,t.default?this.value={...t.default}:this.value||(this.value={}),this.defaultLanguage=t.languages.includes(x.DefaultLanguage)?x.DefaultLanguage:t.languages[0];const e=t.defaultValue||`Enter text in ${this.capitalizeFirstLetter(this.defaultLanguage)}`;t.languages.forEach(i=>{var s,n;i in(this.value||{})||(this.value||(this.value={}),i===this.defaultLanguage&&e?this.value[i]=((s=t.default)==null?void 0:s[i])||e:this.value[i]=((n=t.default)==null?void 0:n[i])||"")})}capitalizeFirstLetter(t){return String(t).charAt(0).toUpperCase()+String(t).slice(1)}measureTextWidth(t,e){this.textMeasureCanvas||(this.textMeasureCanvas=document.createElement("canvas"));const i=this.textMeasureCanvas.getContext("2d");if(!i)return t.length*10;const s=`${e.fontStyle} ${e.fontWeight} ${e.fontSize} ${e.fontFamily}`.trim();return i.font=s,i.measureText(t).width}adaptPlaceholderToSingleLine(t,e){const i=window.getComputedStyle(t),s=parseFloat(i.paddingLeft)||0,n=parseFloat(i.paddingRight)||0,o=parseFloat(i.borderLeftWidth)||0,a=parseFloat(i.borderRightWidth)||0,l=Math.max(0,t.clientWidth-s-n-o-a);if(l<=0){t.placeholder=e;return}if(this.measureTextWidth(e,i)<=l){t.placeholder=e;return}const c="...";let h=0,d=e.length,u=0;for(;h<=d;){const m=Math.floor((h+d)/2),g=e.slice(0,m).trimEnd()+c;this.measureTextWidth(g,i)<=l?(u=m,h=m+1):d=m-1}const f=e.slice(0,u).trimEnd()+c;t.placeholder=f}autosizeTextarea(t,e=3){t.style.height="auto";const i=window.getComputedStyle(t),s=parseFloat(i.lineHeight)||20,n=parseFloat(i.paddingTop)+parseFloat(i.paddingBottom),o=parseFloat(i.borderTopWidth)+parseFloat(i.borderBottomWidth),a=s*e+n+o,l=Math.min(t.scrollHeight||44,a);t.style.height=`${l}px`,t.scrollHeight>a?t.style.overflowY="auto":t.style.overflowY="hidden"}createTextareaRow(t,e){const i=document.createElement("div");i.classList.add("simple-multi-language-row");const s=document.createElement("label");if(s.classList.add("simple-language-label"),s.textContent=t.toUpperCase(),s.setAttribute("for",`textarea-${t}`),i.appendChild(s),this.props.multiImg){const n=new et({defaultUrl:e||"",title:"",id:`${this.id}_upload_${t}`});n.setOnChange(a=>{this.updateLanguageValue(t,a),t===this.defaultLanguage&&this.updateOtherLanguagePlaceholders(a)}),this.uploadSettings.set(t,n);const o=n.draw();o.classList.add("simple-language-upload"),i.appendChild(o)}else{const n=document.createElement("textarea");n.id=`textarea-${t}`,n.classList.add("simple-language-textarea"),n.value=e||"",n.rows=1,n.style.overflowY="hidden";let o=this.props.placeholder||"Enter text in {language}...";o.includes("{language}")&&(o=o.replace("{language}",t.toUpperCase())),n.setAttribute("data-full-placeholder",o),this.adaptPlaceholderToSingleLine(n,o),this.getDataPropsPath()&&n.setAttribute("data-test-id",`${this.getDataPropsPath()}_${t}`),n.addEventListener("input",l=>{const r=l.target;this.updateLanguageValue(t,r.value),t===this.defaultLanguage&&this.updateOtherLanguagePlaceholders(r.value),this.autosizeTextarea(r,3);const c=n.getAttribute("data-full-placeholder")||"";c&&this.adaptPlaceholderToSingleLine(n,c)}),i.appendChild(n),(l=>(typeof queueMicrotask=="function"?queueMicrotask:r=>setTimeout(r,0))(l))(()=>{this.autosizeTextarea(n,3);const l=n.getAttribute("data-full-placeholder")||"";l&&this.adaptPlaceholderToSingleLine(n,l)})}return i}updateLanguageValue(t,e){this.value||(this.value={});const i={...this.value,[t]:e};this.setValue(i)}updateOtherLanguagePlaceholders(t){this.container&&this.props.languages.forEach(e=>{var s,n;if(e===this.defaultLanguage)return;const i=(s=this.container)==null?void 0:s.querySelector(`#textarea-${e}`);if(i&&(!i.value||i.value.trim()==="")){const o=t||((n=this.props.placeholder)==null?void 0:n.replace("{language}",e.toUpperCase()))||`Enter text in ${e.toUpperCase()}...`;i.setAttribute("data-full-placeholder",o),this.adaptPlaceholderToSingleLine(i,o)}})}renderContent(t){var
|
|
285
|
+
</svg>`;class Ee extends H{constructor(t={}){super({...t,minValue:t.minValue??0,maxValue:t.maxValue??1e3,icon:t.icon||be,title:t.title||"Margin Top",default:t.default??20,wrapperClassName:"margin-top-wrapper "+(t.wrapperClassName||"")}),this.inputType="number"}}class we extends x{constructor(t){super(t),this.inputType={},this.container=null,this.defaultLanguage="",this.uploadSettings=new Map,this.popup=null,t.default?this.value={...t.default}:this.value||(this.value={}),this.defaultLanguage=t.languages.includes(x.DefaultLanguage)?x.DefaultLanguage:t.languages[0];const e=t.defaultValue||`Enter text in ${this.capitalizeFirstLetter(this.defaultLanguage)}`;t.languages.forEach(i=>{var s,n;i in(this.value||{})||(this.value||(this.value={}),i===this.defaultLanguage&&e?this.value[i]=((s=t.default)==null?void 0:s[i])||e:this.value[i]=((n=t.default)==null?void 0:n[i])||"")})}capitalizeFirstLetter(t){return String(t).charAt(0).toUpperCase()+String(t).slice(1)}measureTextWidth(t,e){this.textMeasureCanvas||(this.textMeasureCanvas=document.createElement("canvas"));const i=this.textMeasureCanvas.getContext("2d");if(!i)return t.length*10;const s=`${e.fontStyle} ${e.fontWeight} ${e.fontSize} ${e.fontFamily}`.trim();return i.font=s,i.measureText(t).width}adaptPlaceholderToSingleLine(t,e){const i=window.getComputedStyle(t),s=parseFloat(i.paddingLeft)||0,n=parseFloat(i.paddingRight)||0,o=parseFloat(i.borderLeftWidth)||0,a=parseFloat(i.borderRightWidth)||0,l=Math.max(0,t.clientWidth-s-n-o-a);if(l<=0){t.placeholder=e;return}if(this.measureTextWidth(e,i)<=l){t.placeholder=e;return}const c="...";let h=0,d=e.length,u=0;for(;h<=d;){const m=Math.floor((h+d)/2),g=e.slice(0,m).trimEnd()+c;this.measureTextWidth(g,i)<=l?(u=m,h=m+1):d=m-1}const f=e.slice(0,u).trimEnd()+c;t.placeholder=f}autosizeTextarea(t,e=3){t.style.height="auto";const i=window.getComputedStyle(t),s=parseFloat(i.lineHeight)||20,n=parseFloat(i.paddingTop)+parseFloat(i.paddingBottom),o=parseFloat(i.borderTopWidth)+parseFloat(i.borderBottomWidth),a=s*e+n+o,l=Math.min(t.scrollHeight||44,a);t.style.height=`${l}px`,t.scrollHeight>a?t.style.overflowY="auto":t.style.overflowY="hidden"}createTextareaRow(t,e){const i=document.createElement("div");i.classList.add("simple-multi-language-row");const s=document.createElement("label");if(s.classList.add("simple-language-label"),s.textContent=t.toUpperCase(),s.setAttribute("for",`textarea-${t}`),i.appendChild(s),this.props.multiImg){const n=new et({defaultUrl:e||"",title:"",id:`${this.id}_upload_${t}`});n.setOnChange(a=>{this.updateLanguageValue(t,a),t===this.defaultLanguage&&this.updateOtherLanguagePlaceholders(a)}),this.uploadSettings.set(t,n);const o=n.draw();o.classList.add("simple-language-upload"),i.appendChild(o)}else{const n=document.createElement("textarea");n.id=`textarea-${t}`,n.classList.add("simple-language-textarea"),n.value=e||"",n.rows=1,n.style.overflowY="hidden";let o=this.props.placeholder||"Enter text in {language}...";o.includes("{language}")&&(o=o.replace("{language}",t.toUpperCase())),n.setAttribute("data-full-placeholder",o),this.adaptPlaceholderToSingleLine(n,o),this.getDataPropsPath()&&n.setAttribute("data-test-id",`${this.getDataPropsPath()}_${t}`),n.addEventListener("input",l=>{const r=l.target;this.updateLanguageValue(t,r.value),t===this.defaultLanguage&&this.updateOtherLanguagePlaceholders(r.value),this.autosizeTextarea(r,3);const c=n.getAttribute("data-full-placeholder")||"";c&&this.adaptPlaceholderToSingleLine(n,c)}),i.appendChild(n),(l=>(typeof queueMicrotask=="function"?queueMicrotask:r=>setTimeout(r,0))(l))(()=>{this.autosizeTextarea(n,3);const l=n.getAttribute("data-full-placeholder")||"";l&&this.adaptPlaceholderToSingleLine(n,l)})}return i}updateLanguageValue(t,e){this.value||(this.value={});const i={...this.value,[t]:e};this.setValue(i)}updateOtherLanguagePlaceholders(t){this.container&&this.props.languages.forEach(e=>{var s,n;if(e===this.defaultLanguage)return;const i=(s=this.container)==null?void 0:s.querySelector(`#textarea-${e}`);if(i&&(!i.value||i.value.trim()==="")){const o=t||((n=this.props.placeholder)==null?void 0:n.replace("{language}",e.toUpperCase()))||`Enter text in ${e.toUpperCase()}...`;i.setAttribute("data-full-placeholder",o),this.adaptPlaceholderToSingleLine(i,o)}})}renderContent(t){var s;const e=t.querySelector(".simple-multi-language-content");if(!e)return;e.innerHTML="";const i=x.CurrentLanguage();if(!i||!this.props.languages.includes(i))this.props.languages.forEach(n=>{var l;const o=((l=this.value)==null?void 0:l[n])||"",a=this.createTextareaRow(n,o);e.appendChild(a)});else{const n=((s=this.value)==null?void 0:s[i])||"",o=this.createTextareaRow(i,n);e.appendChild(o);const a=e.querySelector(".simple-language-textarea");if(a){const l=a.getAttribute("data-full-placeholder")||"";l&&this.adaptPlaceholderToSingleLine(a,l)}}}createPopup(){const t=document.createElement("div");t.classList.add("multi-language-popup-overlay"),t.style.cssText=`
|
|
286
286
|
position: fixed;
|
|
287
287
|
top: 0;
|
|
288
288
|
left: 0;
|
|
@@ -4283,20 +4283,29 @@ class Te extends x {
|
|
|
4283
4283
|
});
|
|
4284
4284
|
}
|
|
4285
4285
|
renderContent(t) {
|
|
4286
|
-
var
|
|
4286
|
+
var s;
|
|
4287
4287
|
const e = t.querySelector(
|
|
4288
4288
|
".simple-multi-language-content"
|
|
4289
4289
|
);
|
|
4290
4290
|
if (!e) return;
|
|
4291
4291
|
e.innerHTML = "";
|
|
4292
|
-
const i = x.CurrentLanguage()
|
|
4293
|
-
|
|
4294
|
-
|
|
4295
|
-
|
|
4296
|
-
|
|
4297
|
-
|
|
4298
|
-
|
|
4299
|
-
|
|
4292
|
+
const i = x.CurrentLanguage();
|
|
4293
|
+
if (!i || !this.props.languages.includes(i))
|
|
4294
|
+
this.props.languages.forEach((n) => {
|
|
4295
|
+
var l;
|
|
4296
|
+
const o = ((l = this.value) == null ? void 0 : l[n]) || "", a = this.createTextareaRow(n, o);
|
|
4297
|
+
e.appendChild(a);
|
|
4298
|
+
});
|
|
4299
|
+
else {
|
|
4300
|
+
const n = ((s = this.value) == null ? void 0 : s[i]) || "", o = this.createTextareaRow(i, n);
|
|
4301
|
+
e.appendChild(o);
|
|
4302
|
+
const a = e.querySelector(
|
|
4303
|
+
".simple-language-textarea"
|
|
4304
|
+
);
|
|
4305
|
+
if (a) {
|
|
4306
|
+
const l = a.getAttribute("data-full-placeholder") || "";
|
|
4307
|
+
l && this.adaptPlaceholderToSingleLine(a, l);
|
|
4308
|
+
}
|
|
4300
4309
|
}
|
|
4301
4310
|
}
|
|
4302
4311
|
createPopup() {
|
package/package.json
CHANGED