builder-settings-types 0.0.178 → 0.0.180

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.
@@ -78,9 +78,9 @@
78
78
  `))}draw(){const t=document.createElement("div");t.className="upload-setting-wrapper",t.setAttribute("data-setting-id",this.id),t.addEventListener("focusout",l=>{var h;l.relatedTarget&&t.contains(l.relatedTarget)||(h=this.onBlur)==null||h.call(this,this.value??"")},!0);const e=!!(this.props.title||this.props.icon);if(e||t.classList.add("no-label"),e){const l=document.createElement("div");if(l.className="icon-title-container",this.props.icon){const h=this.createIcon(this.props.icon);l.appendChild(h)}if(this.props.title){const h=this.createLabel(this.props.title);l.appendChild(h)}t.appendChild(l)}const i=document.createElement("div");i.className="preview-button-container";const s=this.value&&this.value!=="";s||i.classList.add("no-image");const n=document.createElement("div");if(n.className="preview-placeholder",n.innerHTML=tt,this.previewWrapper=document.createElement("div"),this.previewWrapper.className="preview-wrapper",this.previewEl=document.createElement("img"),this.previewEl.className="upload-preview",this.props.delete){const l=document.createElement("button");l.className="delete-button",l.type="button",l.title="Delete image",l.innerHTML=et,this.previewWrapper.appendChild(l),l.onclick=h=>{var r;h.stopPropagation(),this.value="",o.value="",this.updatePreviewState(null),(r=this.onChange)==null||r.call(this,"")}}this.previewWrapper.appendChild(this.previewEl);const a=document.createElement("button");a.className="upload-button",a.innerHTML=`
79
79
  <span class="upload-icon">${k}</span>
80
80
  <span class="upload-label">Upload</span>
81
- `;const o=document.createElement("input");return o.type="file",o.accept="image/*",o.style.display="none",i.appendChild(n),i.appendChild(this.previewWrapper),i.appendChild(a),t.appendChild(i),t.appendChild(o),s?this.updatePreviewState(this.value):this.updatePreviewState(null),a.onclick=()=>{o.click()},o.onchange=async()=>{var h,r,u;const l=(h=o.files)==null?void 0:h[0];if(l)try{a.classList.add("loading"),a.disabled=!0;const d=new FormData,$=this.props.formFieldName||"file";d.append($,l,l.name);const T=this.props.uploadUrl;if(!T)throw new Error("No uploadUrl provided to UploadSetting.");const j=this.props.requestMethod||"POST",F={...this.props.requestHeaders||{}},E=await(await fetch(T,{method:j,body:d,headers:F})).json();console.log("Upload response:",E);let b;if(this.props.parseResponse)b=this.props.parseResponse(E);else if(b=(r=E==null?void 0:E.data)==null?void 0:r.url,!b)throw new Error("No URL found in response. Provide a parseResponse if needed.");console.log("Final URL:",b),this.value=b,this.updatePreviewState(b),(u=this.onChange)==null||u.call(this,b)}catch(d){console.error("Error uploading file:",d)}finally{a.classList.remove("loading"),a.disabled=!1,o.value=""}else o.value=""},t}}class it extends C{constructor(t={}){const e={title:t.title||"Height",suffix:"px",minValue:t.minValue??0,maxValue:t.maxValue,icon:t.icon||st,...t};super(e),this.inputType="number",this.mobileValue=t.mobile}getMobileValue(){return this.mobileValue}setMobileValue(t){this.mobileValue=t,t!==void 0&&this.setValue(t)}}const st=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
81
+ `;const o=document.createElement("input");return o.type="file",o.accept="image/*",o.style.display="none",i.appendChild(n),i.appendChild(this.previewWrapper),i.appendChild(a),t.appendChild(i),t.appendChild(o),s?this.updatePreviewState(this.value):this.updatePreviewState(null),a.onclick=()=>{o.click()},o.onchange=async()=>{var h,r,u;const l=(h=o.files)==null?void 0:h[0];if(l)try{a.classList.add("loading"),a.disabled=!0;const d=new FormData,$=this.props.formFieldName||"file";d.append($,l,l.name);const T=this.props.uploadUrl;if(!T)throw new Error("No uploadUrl provided to UploadSetting.");const j=this.props.requestMethod||"POST",F={...this.props.requestHeaders||{}},E=await(await fetch(T,{method:j,body:d,headers:F})).json();console.log("Upload response:",E);let b;if(this.props.parseResponse)b=this.props.parseResponse(E);else if(b=(r=E==null?void 0:E.data)==null?void 0:r.url,!b)throw new Error("No URL found in response. Provide a parseResponse if needed.");console.log("Final URL:",b),this.value=b,this.updatePreviewState(b),(u=this.onChange)==null||u.call(this,b)}catch(d){console.error("Error uploading file:",d)}finally{a.classList.remove("loading"),a.disabled=!1,o.value=""}else o.value=""},t}}class it extends C{constructor(t={}){const e={title:"Height",suffix:"px",minValue:0,icon:st,...t};super(e),this.inputType="number",this.mobileValue=t.mobile}getMobileValue(){return this.mobileValue}setMobileValue(t){this.mobileValue=t,t!==void 0&&this.setValue(t)}}const st=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
82
82
  <path d="M9 14L9 5M9 14L6.75 12.5M9 14L11.25 12.5M9 5L6.75 6.5M9 5L11.25 6.5M15.75 2.75H2.25M15.75 16.25H2.25" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
83
- </svg>`;class nt extends C{constructor(t={}){super({title:t.title||"Width",suffix:"px",minValue:t.minValue??0,maxValue:t.maxValue,icon:t.icon||at,...t}),this.inputType="number",this.mobileValue=t.mobile}getMobileValue(){return this.mobileValue}}const at=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
83
+ </svg>`;class nt extends C{constructor(t={}){const e={title:"Width",suffix:"px",minValue:0,icon:at,...t};super(e),this.inputType="number",this.mobileValue=t.mobile}getMobileValue(){return this.mobileValue}setMobileValue(t){this.mobileValue=t,t!==void 0&&this.setValue(t)}}const at=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
84
84
  <path d="M4.5 9.5H13.5M4.5 9.5L6 7.25M4.5 9.5L6 11.75M13.5 9.5L12 7.25M13.5 9.5L12 11.75M15.75 16.25V2.75M2.25 16.25V2.75" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
85
85
  </svg>`,ot=`
86
86
  <svg xmlns="http://www.w3.org/2000/svg" class="svg-select-api" width="12" height="12" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-chevron-down">
@@ -1301,14 +1301,12 @@ class Q extends p {
1301
1301
  }
1302
1302
  }
1303
1303
  class bt extends C {
1304
- // Store mobile value
1305
1304
  constructor(t = {}) {
1306
1305
  const e = {
1307
- title: t.title || "Height",
1306
+ title: "Height",
1308
1307
  suffix: "px",
1309
- minValue: t.minValue ?? 0,
1310
- maxValue: t.maxValue,
1311
- icon: t.icon || Y,
1308
+ minValue: 0,
1309
+ icon: Y,
1312
1310
  ...t
1313
1311
  };
1314
1312
  super(e), this.inputType = "number", this.mobileValue = t.mobile;
@@ -1325,18 +1323,22 @@ const Y = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBo
1325
1323
  </svg>`;
1326
1324
  class wt extends C {
1327
1325
  constructor(t = {}) {
1328
- super({
1329
- title: t.title || "Width",
1326
+ const e = {
1327
+ title: "Width",
1330
1328
  suffix: "px",
1331
- minValue: t.minValue ?? 0,
1332
- maxValue: t.maxValue,
1333
- icon: t.icon || tt,
1329
+ minValue: 0,
1330
+ icon: tt,
1334
1331
  ...t
1335
- }), this.inputType = "number", this.mobileValue = t.mobile;
1332
+ // Override with passed props
1333
+ };
1334
+ super(e), this.inputType = "number", this.mobileValue = t.mobile;
1336
1335
  }
1337
1336
  getMobileValue() {
1338
1337
  return this.mobileValue;
1339
1338
  }
1339
+ setMobileValue(t) {
1340
+ this.mobileValue = t, t !== void 0 && this.setValue(t);
1341
+ }
1340
1342
  }
1341
1343
  const tt = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
1342
1344
  <path d="M4.5 9.5H13.5M4.5 9.5L6 7.25M4.5 9.5L6 11.75M13.5 9.5L12 7.25M13.5 9.5L12 11.75M15.75 16.25V2.75M2.25 16.25V2.75" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
package/dist/index.d.ts CHANGED
@@ -753,6 +753,7 @@ export declare class WidthSetting extends NumberSetting {
753
753
  mobileValue?: number;
754
754
  constructor(props?: WidthSettingProps);
755
755
  getMobileValue(): number | undefined;
756
+ setMobileValue(value: number | undefined): void;
756
757
  }
757
758
 
758
759
  export declare type WidthSettingProps = NumberSettingsProps & {
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.178",
4
+ "version": "0.0.180",
5
5
  "type": "module",
6
6
  "main": "dist/builder-settings-types.cjs.js",
7
7
  "module": "dist/builder-settings-types.es.js",