builder-settings-types 0.0.112 → 0.0.113
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.
|
@@ -77,9 +77,9 @@
|
|
|
77
77
|
`))}draw(){const t=document.createElement("div");t.className="upload-setting-wrapper",t.setAttribute("data-setting-id",this.id),t.addEventListener("focusout",c=>{var r;c.relatedTarget&&t.contains(c.relatedTarget)||(r=this.onBlur)==null||r.call(this)},!0);const e=!!(this.props.title||this.props.icon);if(e||t.classList.add("no-label"),e){const c=document.createElement("div");if(c.className="icon-title-container",this.props.icon){const r=this.createIcon(this.props.icon);c.appendChild(r)}if(this.props.title){const r=this.createLabel(this.props.title);c.appendChild(r)}t.appendChild(c)}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");n.className="preview-placeholder",n.innerHTML=D,this.previewWrapper=document.createElement("div"),this.previewWrapper.className="preview-wrapper",this.previewEl=document.createElement("img"),this.previewEl.className="upload-preview";const a=document.createElement("button");a.className="delete-button",a.type="button",a.title="Delete image",a.innerHTML=z,this.previewWrapper.appendChild(this.previewEl),this.previewWrapper.appendChild(a);const o=document.createElement("button");o.className="upload-button",o.innerHTML=`
|
|
78
78
|
<span class="upload-icon">${N}</span>
|
|
79
79
|
<span class="upload-label">Upload</span>
|
|
80
|
-
`;const l=document.createElement("input");return l.type="file",l.accept="image/*",l.style.display="none",i.appendChild(n),i.appendChild(this.previewWrapper),i.appendChild(o),t.appendChild(i),t.appendChild(l),s?this.updatePreviewState(this.value):this.updatePreviewState(null),a.onclick=c=>{var r;c.stopPropagation(),this.value="",this.updatePreviewState(null),(r=this.onChange)==null||r.call(this,"")},o.onclick=()=>{l.click()},l.onchange=async()=>{var r,u,p,g;const c=(r=l.files)==null?void 0:r[0];if(c)try{o.classList.add("loading"),o.disabled=!0;const d=new FormData,f=this.props.formFieldName||"file";d.append(f,c,c.name);const v=this.props.uploadUrl;if(!v)throw new Error("No uploadUrl provided to UploadSetting.");const k=this.props.requestMethod||"POST",O={...this.props.requestHeaders||{}},E=await(await fetch(v,{method:k,body:d,headers:O})).json();console.log("Upload response:",E);let x;if(this.props.parseResponse)x=this.props.parseResponse(E);else if(x=(u=E==null?void 0:E.data)==null?void 0:u.url,!x)throw new Error("No URL found in response. Provide a parseResponse if needed.");console.log("Final URL:",x),this.value=x,this.updatePreviewState(x),(p=this.onChange)==null||p.call(this,x),(g=this.onBlur)==null||g.call(this)}catch(d){console.error("Error uploading file:",d),this.updatePreviewState(null)}finally{o.classList.remove("loading"),o.disabled=!1}},t}}class Z extends m{constructor(t={}){super(t),this.inputType="number",this.value=this.value??0,this.numberSetting=new w({title:"Height",default:this.value,suffix:"px",minValue:t.minHeight??0,maxValue:t.maxHeight,icon:P}),this.numberSetting.setOnChange(e=>{var i;isNaN(e)||(this.value=e,(i=this.onChange)==null||i.call(this,this.value))})}draw(){return this.numberSetting.draw()}}const P=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
80
|
+
`;const l=document.createElement("input");return l.type="file",l.accept="image/*",l.style.display="none",i.appendChild(n),i.appendChild(this.previewWrapper),i.appendChild(o),t.appendChild(i),t.appendChild(l),s?this.updatePreviewState(this.value):this.updatePreviewState(null),a.onclick=c=>{var r;c.stopPropagation(),this.value="",this.updatePreviewState(null),(r=this.onChange)==null||r.call(this,"")},o.onclick=()=>{l.click()},l.onchange=async()=>{var r,u,p,g;const c=(r=l.files)==null?void 0:r[0];if(c)try{o.classList.add("loading"),o.disabled=!0;const d=new FormData,f=this.props.formFieldName||"file";d.append(f,c,c.name);const v=this.props.uploadUrl;if(!v)throw new Error("No uploadUrl provided to UploadSetting.");const k=this.props.requestMethod||"POST",O={...this.props.requestHeaders||{}},E=await(await fetch(v,{method:k,body:d,headers:O})).json();console.log("Upload response:",E);let x;if(this.props.parseResponse)x=this.props.parseResponse(E);else if(x=(u=E==null?void 0:E.data)==null?void 0:u.url,!x)throw new Error("No URL found in response. Provide a parseResponse if needed.");console.log("Final URL:",x),this.value=x,this.updatePreviewState(x),(p=this.onChange)==null||p.call(this,x),(g=this.onBlur)==null||g.call(this)}catch(d){console.error("Error uploading file:",d),this.updatePreviewState(null)}finally{o.classList.remove("loading"),o.disabled=!1}},t}}class Z extends m{constructor(t={}){super(t),this.inputType="number",this.value=this.value??0,this.numberSetting=new w({title:"Height",default:this.value,suffix:"px",minValue:t.minHeight??0,maxValue:t.maxHeight,icon:P}),this.numberSetting.setOnChange(e=>{var i;isNaN(e)||(this.value=e,(i=this.onChange)==null||i.call(this,this.value))})}draw(){return this.numberSetting.draw()}setValue(t){const e=t==null||isNaN(t)?this.props.default??0:t;super.setValue(e),this.numberSetting.setValue(e)}}const P=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
81
81
|
<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"/>
|
|
82
|
-
</svg>`;class J extends
|
|
82
|
+
</svg>`;class J extends w{constructor(t={}){super({...t,title:t.title||"Width",suffix:"px",minValue:t.minValue??0,maxValue:t.maxValue,icon:t.icon||X}),this.inputType="number"}}const X=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
83
83
|
<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"/>
|
|
84
84
|
</svg>`,Q=`
|
|
85
85
|
<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">
|
|
@@ -875,30 +875,24 @@ class rt extends m {
|
|
|
875
875
|
draw() {
|
|
876
876
|
return this.numberSetting.draw();
|
|
877
877
|
}
|
|
878
|
+
setValue(t) {
|
|
879
|
+
const e = t == null || isNaN(t) ? this.props.default ?? 0 : t;
|
|
880
|
+
super.setValue(e), this.numberSetting.setValue(e);
|
|
881
|
+
}
|
|
878
882
|
}
|
|
879
883
|
const D = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
880
884
|
<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"/>
|
|
881
885
|
</svg>`;
|
|
882
|
-
class ht extends
|
|
886
|
+
class ht extends b {
|
|
883
887
|
constructor(t = {}) {
|
|
884
|
-
super(
|
|
885
|
-
|
|
886
|
-
|
|
888
|
+
super({
|
|
889
|
+
...t,
|
|
890
|
+
title: t.title || "Width",
|
|
887
891
|
suffix: "px",
|
|
888
|
-
minValue: t.
|
|
889
|
-
maxValue: t.
|
|
890
|
-
icon: z
|
|
891
|
-
}), this.
|
|
892
|
-
var i;
|
|
893
|
-
isNaN(e) || (this.value = e, (i = this.onChange) == null || i.call(this, this.value));
|
|
894
|
-
});
|
|
895
|
-
}
|
|
896
|
-
draw() {
|
|
897
|
-
return this.numberSetting.draw();
|
|
898
|
-
}
|
|
899
|
-
setValue(t) {
|
|
900
|
-
const e = t == null || isNaN(t) ? this.props.default ?? 0 : t;
|
|
901
|
-
super.setValue(e), this.numberSetting.setValue(e);
|
|
892
|
+
minValue: t.minValue ?? 0,
|
|
893
|
+
maxValue: t.maxValue,
|
|
894
|
+
icon: t.icon || z
|
|
895
|
+
}), this.inputType = "number";
|
|
902
896
|
}
|
|
903
897
|
}
|
|
904
898
|
const z = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
package/dist/index.d.ts
CHANGED
|
@@ -209,6 +209,7 @@ export declare class HeightSetting extends Setting<number, HeightSettingProps> {
|
|
|
209
209
|
private numberSetting;
|
|
210
210
|
constructor(props?: HeightSettingProps);
|
|
211
211
|
draw(): HTMLElement;
|
|
212
|
+
setValue(value: number | undefined): void;
|
|
212
213
|
}
|
|
213
214
|
|
|
214
215
|
export declare interface HeightSettingProps extends SettingProps<number> {
|
|
@@ -605,17 +606,12 @@ export declare interface UploadSettingProps extends SettingProps<string> {
|
|
|
605
606
|
parseResponse?: (responseData: any) => string;
|
|
606
607
|
}
|
|
607
608
|
|
|
608
|
-
export declare class WidthSetting extends
|
|
609
|
-
inputType:
|
|
610
|
-
private numberSetting;
|
|
609
|
+
export declare class WidthSetting extends NumberSetting {
|
|
610
|
+
inputType: InputTypes;
|
|
611
611
|
constructor(props?: WidthSettingProps);
|
|
612
|
-
draw(): HTMLElement;
|
|
613
|
-
setValue(value: number | undefined): void;
|
|
614
612
|
}
|
|
615
613
|
|
|
616
|
-
export declare interface WidthSettingProps extends
|
|
617
|
-
minWidth?: number;
|
|
618
|
-
maxWidth?: number;
|
|
614
|
+
export declare interface WidthSettingProps extends NumberSettingsProps {
|
|
619
615
|
}
|
|
620
616
|
|
|
621
617
|
export { }
|
package/package.json
CHANGED