builder-settings-types 0.0.384 → 0.0.386

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.
@@ -312,7 +312,7 @@
312
312
  </svg>`;class li extends ${constructor(t={}){super({...t,minValue:t.minValue??0,maxValue:t.maxValue??1e3,icon:t.icon||ai,title:t.title||"Margin Bottom",default:t.default??20,wrapperClassName:"margin-bottom-wrapper "+(t.wrapperClassName||"")}),this.inputType="number"}}const ri=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
313
313
  <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"
314
314
  stroke="#667085" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
315
- </svg>`;class ci extends ${constructor(t={}){super({...t,minValue:t.minValue??0,maxValue:t.maxValue??1e3,icon:t.icon||ri,title:t.title||"Margin Top",default:t.default??20,wrapperClassName:"margin-top-wrapper "+(t.wrapperClassName||"")}),this.inputType="number"}}class hi extends w{constructor(t){super(t),this.inputType={},this.container=null,this.defaultLanguage="",this.uploadSettings=new Map,this.popup=null;const e=window;e.textElementListeners||(e.textElementListeners=new Map),t.default?this.value=t.default:this.value||(this.value={}),this.value.$id=gt();const i=w.HasExplicitCurrentLanguage(),s=i?w.CurrentLanguage():"",n=w.DefaultLanguage;this.defaultLanguage=i&&s&&t.languages.includes(s)?s:n&&t.languages.includes(n)?n:t.languages[0];const o=t.defaultValue||`Enter text in ${this.capitalizeFirstLetter(this.defaultLanguage)}`;t.languages.forEach(a=>{var l,r;a in(this.value||{})||(this.value||(this.value={}),a===this.defaultLanguage&&o?this.value[a]=((l=t.default)==null?void 0:l[a])||o:this.value[a]=((r=t.default)==null?void 0:r[a])||"")})}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 h="...";let d=0,p=e.length,u=0;for(;d<=p;){const m=Math.floor((d+p)/2),g=e.slice(0,m).trimEnd()+h;this.measureTextWidth(g,i)<=l?(u=m,d=m+1):p=m-1}const C=e.slice(0,u).trimEnd()+h;t.placeholder=C}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 lt({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 h=n.getAttribute("data-full-placeholder")||"";h&&this.adaptPlaceholderToSingleLine(n,h)}),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 n;const e=t.querySelector(".simple-multi-language-content");if(!e)return;e.innerHTML="";const i=w.HasExplicitCurrentLanguage(),s=w.CurrentLanguage();if(!i||!s||!this.props.languages.includes(s))this.props.languages.forEach(o=>{var r;const a=((r=this.value)==null?void 0:r[o])||"",l=this.createTextareaRow(o,a);e.appendChild(l)});else{const o=((n=this.value)==null?void 0:n[s])||"",a=this.createTextareaRow(s,o);e.appendChild(a);const l=e.querySelector(".simple-language-textarea");if(l){const r=l.getAttribute("data-full-placeholder")||"";r&&this.adaptPlaceholderToSingleLine(l,r)}}}createPopup(){const t=document.createElement("div");t.classList.add("multi-language-popup-overlay"),t.style.cssText=`
315
+ </svg>`;class ci extends ${constructor(t={}){super({...t,minValue:t.minValue??0,maxValue:t.maxValue??1e3,icon:t.icon||ri,title:t.title||"Margin Top",default:t.default??20,wrapperClassName:"margin-top-wrapper "+(t.wrapperClassName||"")}),this.inputType="number"}}class hi extends w{constructor(t){super(t),this.inputType={},this.container=null,this.defaultLanguage="",this.uploadSettings=new Map,this.popup=null;const e=window;e.textElementListeners||(e.textElementListeners=new Map),t.default?this.value=t.default:this.value||(this.value={});const i=w.HasExplicitCurrentLanguage(),s=i?w.CurrentLanguage():"",n=w.DefaultLanguage;this.defaultLanguage=i&&s&&t.languages.includes(s)?s:n&&t.languages.includes(n)?n:t.languages[0];const o=t.defaultValue||`Enter text in ${this.capitalizeFirstLetter(this.defaultLanguage)}`;t.languages.forEach(a=>{var l,r;a in(this.value||{})||(this.value||(this.value={}),a===this.defaultLanguage&&o?this.value[a]=((l=t.default)==null?void 0:l[a])||o:this.value[a]=((r=t.default)==null?void 0:r[a])||"")})}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 h="...";let d=0,p=e.length,u=0;for(;d<=p;){const m=Math.floor((d+p)/2),g=e.slice(0,m).trimEnd()+h;this.measureTextWidth(g,i)<=l?(u=m,d=m+1):p=m-1}const C=e.slice(0,u).trimEnd()+h;t.placeholder=C}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 lt({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 h=n.getAttribute("data-full-placeholder")||"";h&&this.adaptPlaceholderToSingleLine(n,h)}),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 n;const e=t.querySelector(".simple-multi-language-content");if(!e)return;e.innerHTML="";const i=w.HasExplicitCurrentLanguage(),s=w.CurrentLanguage();if(!i||!s||!this.props.languages.includes(s))this.props.languages.forEach(o=>{var r;const a=((r=this.value)==null?void 0:r[o])||"",l=this.createTextareaRow(o,a);e.appendChild(l)});else{const o=((n=this.value)==null?void 0:n[s])||"",a=this.createTextareaRow(s,o);e.appendChild(a);const l=e.querySelector(".simple-language-textarea");if(l){const r=l.getAttribute("data-full-placeholder")||"";r&&this.adaptPlaceholderToSingleLine(l,r)}}}createPopup(){const t=document.createElement("div");t.classList.add("multi-language-popup-overlay"),t.style.cssText=`
316
316
  position: fixed;
317
317
  top: 0;
318
318
  left: 0;
@@ -373,7 +373,7 @@
373
373
  justify-content: center;
374
374
  color: #666;
375
375
  transition: color 0.2s;
376
- `,s.addEventListener("mouseenter",()=>{s.style.color="#000"}),s.addEventListener("mouseleave",()=>{s.style.color="#666"}),s.addEventListener("click",l=>{l.preventDefault(),this.showPopup()});const n=window.textElementListeners;if(this.id&&!n.has(this.id)){const l=r=>{var p;const{type:h,data:d}=r.data||{};h==="TEXT_ELEMENT_CLICKED"&&d.$id&&(d==null?void 0:d.$id)===((p=this.value)==null?void 0:p.$id)&&this.showPopup()};window.addEventListener("message",l),n.set(this.id,l)}e.appendChild(i),e.appendChild(s),t.appendChild(e);const o=document.createElement("div");o.classList.add("simple-multi-language-content"),t.appendChild(o),this.container=t,this.renderContent(t),this.languageChangeUnsubscribe=w.onLanguageChange(l=>{l&&this.props.languages.includes(l)&&(this.defaultLanguage=l),this.container&&this.renderContent(this.container)});const a=()=>{if(!this.container)return;this.container.querySelectorAll(".simple-language-textarea").forEach(r=>{const h=r.getAttribute("data-full-placeholder")||"";h&&this.adaptPlaceholderToSingleLine(r,h)})};return window.addEventListener("resize",a),t}setValue(t){super.setValue(t),this.value.$id=this.value.$id||t.$id,this.container&&this.props.languages.forEach(e=>{var i;if(this.props.multiImg){const s=this.uploadSettings.get(e);s&&s.setValue((t==null?void 0:t[e])||"")}else{const s=(i=this.container)==null?void 0:i.querySelector(`#textarea-${e}`);if(s){s.value=(t==null?void 0:t[e])||"",this.autosizeTextarea(s,3);const n=s.getAttribute("data-full-placeholder")||"";n&&this.adaptPlaceholderToSingleLine(s,n)}}})}}class di extends w{constructor(t={}){super(t),this.inputType="select";const e=[{name:"None",value:"none"},{name:"Fade",value:"fade 1.5s ease-in-out infinite"},{name:"Slide",value:"slide 1.5s ease-in-out infinite"},{name:"Zoom",value:"zoom 1.5s ease-in-out infinite"},{name:"Bounce",value:"bounce 1.5s ease-in-out infinite"},{name:"Pulse",value:"pulse 1.5s ease-in-out infinite"}];this.selectSetting=new st({title:this.title||"Animation",options:e,default:this.props.default||"none"}),this.selectSetting.onChange=i=>{var s;this.value=i,(s=this.onChange)==null||s.call(this,i)}}draw(){return this.selectSetting.draw()}destroy(){this.selectSetting.destroy(),super.destroy()}}const pi=`
376
+ `,s.addEventListener("mouseenter",()=>{s.style.color="#000"}),s.addEventListener("mouseleave",()=>{s.style.color="#666"}),s.addEventListener("click",l=>{l.preventDefault(),this.showPopup()});const n=window.textElementListeners;if(this.id&&!n.has(this.id)){const l=r=>{var p,u;const{type:h,data:d}=r.data||{};h==="TEXT_ELEMENT_CLICKED"&&d.$id&&(console.log((p=this.value)==null?void 0:p.$id),(d==null?void 0:d.$id)===((u=this.value)==null?void 0:u.$id)&&this.showPopup())};window.addEventListener("message",l),n.set(this.id,l)}e.appendChild(i),e.appendChild(s),t.appendChild(e);const o=document.createElement("div");o.classList.add("simple-multi-language-content"),t.appendChild(o),this.container=t,this.renderContent(t),this.languageChangeUnsubscribe=w.onLanguageChange(l=>{l&&this.props.languages.includes(l)&&(this.defaultLanguage=l),this.container&&this.renderContent(this.container)});const a=()=>{if(!this.container)return;this.container.querySelectorAll(".simple-language-textarea").forEach(r=>{const h=r.getAttribute("data-full-placeholder")||"";h&&this.adaptPlaceholderToSingleLine(r,h)})};return window.addEventListener("resize",a),t}setValue(t){super.setValue(t),this.value.$id||(this.value.$id=t.$id||gt()),this.container&&this.props.languages.forEach(e=>{var i;if(this.props.multiImg){const s=this.uploadSettings.get(e);s&&s.setValue((t==null?void 0:t[e])||"")}else{const s=(i=this.container)==null?void 0:i.querySelector(`#textarea-${e}`);if(s){s.value=(t==null?void 0:t[e])||"",this.autosizeTextarea(s,3);const n=s.getAttribute("data-full-placeholder")||"";n&&this.adaptPlaceholderToSingleLine(s,n)}}})}}class di extends w{constructor(t={}){super(t),this.inputType="select";const e=[{name:"None",value:"none"},{name:"Fade",value:"fade 1.5s ease-in-out infinite"},{name:"Slide",value:"slide 1.5s ease-in-out infinite"},{name:"Zoom",value:"zoom 1.5s ease-in-out infinite"},{name:"Bounce",value:"bounce 1.5s ease-in-out infinite"},{name:"Pulse",value:"pulse 1.5s ease-in-out infinite"}];this.selectSetting=new st({title:this.title||"Animation",options:e,default:this.props.default||"none"}),this.selectSetting.onChange=i=>{var s;this.value=i,(s=this.onChange)==null||s.call(this,i)}}draw(){return this.selectSetting.draw()}destroy(){this.selectSetting.destroy(),super.destroy()}}const pi=`
377
377
  <svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
378
378
  <path d="M5.625 9.5H5.6325M12.375 9.5H12.3825M9 9.5H9.0075M9 12.875H9.0075M9 6.125H9.0075M2.25 6.35L2.25 12.65C2.25 13.9101 2.25 14.5402 2.49524 15.0215C2.71095 15.4448 3.05516 15.789 3.47852 16.0048C3.95982 16.25 4.58988 16.25 5.85 16.25H12.15C13.4101 16.25 14.0402 16.25 14.5215 16.0048C14.9448 15.789 15.289 15.4448 15.5048 15.0215C15.75 14.5402 15.75 13.9101 15.75 12.65V6.35C15.75 5.08988 15.75 4.45982 15.5048 3.97852C15.289 3.55516 14.9448 3.21095 14.5215 2.99524C14.0402 2.75 13.4101 2.75 12.15 2.75L5.85 2.75C4.58988 2.75 3.95982 2.75 3.47852 2.99524C3.05516 3.21095 2.71095 3.55516 2.49524 3.97852C2.25 4.45982 2.25 5.08988 2.25 6.35Z" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
379
379
  </svg>
@@ -4745,7 +4745,7 @@ class yi extends w {
4745
4745
  constructor(t) {
4746
4746
  super(t), this.inputType = {}, this.container = null, this.defaultLanguage = "", this.uploadSettings = /* @__PURE__ */ new Map(), this.popup = null;
4747
4747
  const e = window;
4748
- e.textElementListeners || (e.textElementListeners = /* @__PURE__ */ new Map()), t.default ? this.value = t.default : this.value || (this.value = {}), this.value.$id = dt();
4748
+ e.textElementListeners || (e.textElementListeners = /* @__PURE__ */ new Map()), t.default ? this.value = t.default : this.value || (this.value = {});
4749
4749
  const i = w.HasExplicitCurrentLanguage(), s = i ? w.CurrentLanguage() : "", n = w.DefaultLanguage;
4750
4750
  this.defaultLanguage = i && s && t.languages.includes(s) ? s : n && t.languages.includes(n) ? n : t.languages[0];
4751
4751
  const o = t.defaultValue || `Enter text in ${this.capitalizeFirstLetter(this.defaultLanguage)}`;
@@ -4981,9 +4981,9 @@ class yi extends w {
4981
4981
  const n = window.textElementListeners;
4982
4982
  if (this.id && !n.has(this.id)) {
4983
4983
  const l = (r) => {
4984
- var p;
4984
+ var p, u;
4985
4985
  const { type: h, data: d } = r.data || {};
4986
- h === "TEXT_ELEMENT_CLICKED" && d.$id && (d == null ? void 0 : d.$id) === ((p = this.value) == null ? void 0 : p.$id) && this.showPopup();
4986
+ h === "TEXT_ELEMENT_CLICKED" && d.$id && (console.log((p = this.value) == null ? void 0 : p.$id), (d == null ? void 0 : d.$id) === ((u = this.value) == null ? void 0 : u.$id) && this.showPopup());
4987
4987
  };
4988
4988
  window.addEventListener("message", l), n.set(this.id, l);
4989
4989
  }
@@ -5004,7 +5004,7 @@ class yi extends w {
5004
5004
  return window.addEventListener("resize", a), t;
5005
5005
  }
5006
5006
  setValue(t) {
5007
- super.setValue(t), this.value.$id = this.value.$id || t.$id, this.container && this.props.languages.forEach((e) => {
5007
+ super.setValue(t), this.value.$id || (this.value.$id = t.$id || dt()), this.container && this.props.languages.forEach((e) => {
5008
5008
  var i;
5009
5009
  if (this.props.multiImg) {
5010
5010
  const s = this.uploadSettings.get(e);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "builder-settings-types",
3
3
  "description": "builder settings",
4
- "version": "0.0.384",
4
+ "version": "0.0.386",
5
5
  "type": "module",
6
6
  "main": "dist/builder-settings-types.cjs.js",
7
7
  "module": "dist/builder-settings-types.es.js",