builder-settings-types 0.0.179 → 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={
|
|
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={}){
|
|
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,16 +1301,13 @@ 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
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
minValue: t.minValue ?? 0,
|
|
1313
|
-
icon: t.icon || Y
|
|
1306
|
+
title: "Height",
|
|
1307
|
+
suffix: "px",
|
|
1308
|
+
minValue: 0,
|
|
1309
|
+
icon: Y,
|
|
1310
|
+
...t
|
|
1314
1311
|
};
|
|
1315
1312
|
super(e), this.inputType = "number", this.mobileValue = t.mobile;
|
|
1316
1313
|
}
|
|
@@ -1326,15 +1323,15 @@ const Y = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBo
|
|
|
1326
1323
|
</svg>`;
|
|
1327
1324
|
class wt extends C {
|
|
1328
1325
|
constructor(t = {}) {
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1326
|
+
const e = {
|
|
1327
|
+
title: "Width",
|
|
1328
|
+
suffix: "px",
|
|
1329
|
+
minValue: 0,
|
|
1330
|
+
icon: tt,
|
|
1331
|
+
...t
|
|
1332
|
+
// Override with passed props
|
|
1333
|
+
};
|
|
1334
|
+
super(e), this.inputType = "number", this.mobileValue = t.mobile;
|
|
1338
1335
|
}
|
|
1339
1336
|
getMobileValue() {
|
|
1340
1337
|
return this.mobileValue;
|
package/package.json
CHANGED