@innovastudio/contentbuilder-blocks-runtime 1.0.24 → 1.0.25
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.
|
@@ -8935,7 +8935,7 @@ class yn {
|
|
|
8935
8935
|
if (r.querySelector(`[name="${w}"]`) && (o++, w = w + "_" + o), b === "short-text") {
|
|
8936
8936
|
let g = this.getId();
|
|
8937
8937
|
const v = document.createElement("label");
|
|
8938
|
-
if (v.setAttribute("for", `short_text_label_${g}`), v.className = "field-label", v.innerHTML = l.title + (l.isRequired ? ' <span class="text-red-500">*</span>' : ""), p.appendChild(v), l.fieldNote) {
|
|
8938
|
+
if (v.setAttribute("for", `short_text_label_${g}`), v.className = "field-label", v.innerHTML = l.title + (l.isRequired ? ' <span class="text-red-500" aria-hidden="true">*</span>' : ""), p.appendChild(v), l.fieldNote) {
|
|
8939
8939
|
const m = document.createElement("div");
|
|
8940
8940
|
m.className = "field-note", m.innerHTML = l.fieldNote, p.appendChild(m);
|
|
8941
8941
|
}
|
|
@@ -8945,7 +8945,7 @@ class yn {
|
|
|
8945
8945
|
if (b === "long-text") {
|
|
8946
8946
|
let g = this.getId();
|
|
8947
8947
|
const v = document.createElement("label");
|
|
8948
|
-
if (v.setAttribute("for", `long_text_label_${g}`), v.className = "field-label", v.innerHTML = l.title + (l.isRequired ? ' <span class="text-red-500">*</span>' : ""), p.appendChild(v), l.fieldNote) {
|
|
8948
|
+
if (v.setAttribute("for", `long_text_label_${g}`), v.className = "field-label", v.innerHTML = l.title + (l.isRequired ? ' <span class="text-red-500" aria-hidden="true">*</span>' : ""), p.appendChild(v), l.fieldNote) {
|
|
8949
8949
|
const m = document.createElement("div");
|
|
8950
8950
|
m.className = "field-note", m.innerHTML = l.fieldNote, p.appendChild(m);
|
|
8951
8951
|
}
|
|
@@ -8955,7 +8955,7 @@ class yn {
|
|
|
8955
8955
|
if (b === "number") {
|
|
8956
8956
|
let g = this.getId();
|
|
8957
8957
|
const v = document.createElement("label");
|
|
8958
|
-
if (v.setAttribute("for", `number_label_${g}`), v.className = "field-label", v.innerHTML = l.title + (l.isRequired ? ' <span class="text-red-500">*</span>' : ""), p.appendChild(v), l.fieldNote) {
|
|
8958
|
+
if (v.setAttribute("for", `number_label_${g}`), v.className = "field-label", v.innerHTML = l.title + (l.isRequired ? ' <span class="text-red-500" aria-hidden="true">*</span>' : ""), p.appendChild(v), l.fieldNote) {
|
|
8959
8959
|
const m = document.createElement("div");
|
|
8960
8960
|
m.className = "field-note", m.innerHTML = l.fieldNote, p.appendChild(m);
|
|
8961
8961
|
}
|
|
@@ -8966,7 +8966,7 @@ class yn {
|
|
|
8966
8966
|
p.classList.add("input-slider");
|
|
8967
8967
|
let g = this.getId();
|
|
8968
8968
|
const v = document.createElement("label");
|
|
8969
|
-
if (v.setAttribute("for", `number_label_${g}`), v.className = "field-label", v.innerHTML = l.title + (l.isRequired ? ' <span class="text-red-500">*</span>' : ""), p.appendChild(v), l.fieldNote) {
|
|
8969
|
+
if (v.setAttribute("for", `number_label_${g}`), v.className = "field-label", v.innerHTML = l.title + (l.isRequired ? ' <span class="text-red-500" aria-hidden="true">*</span>' : ""), p.appendChild(v), l.fieldNote) {
|
|
8970
8970
|
const E = document.createElement("div");
|
|
8971
8971
|
E.className = "field-note", E.innerHTML = l.fieldNote, p.appendChild(E);
|
|
8972
8972
|
}
|
|
@@ -8988,7 +8988,7 @@ class yn {
|
|
|
8988
8988
|
if (b === "select") {
|
|
8989
8989
|
let g = this.getId();
|
|
8990
8990
|
const v = document.createElement("div");
|
|
8991
|
-
if (v.id = `radio_group_label_${g}`, v.className = "field-label-normal", v.innerHTML = l.title + (l.isRequired ? ' <span class="text-red-500">*</span>' : ""), p.appendChild(v), l.fieldNote) {
|
|
8991
|
+
if (v.id = `radio_group_label_${g}`, v.className = "field-label-normal", v.innerHTML = l.title + (l.isRequired ? ' <span class="text-red-500" aria-hidden="true">*</span>' : ""), p.appendChild(v), l.fieldNote) {
|
|
8992
8992
|
const m = document.createElement("div");
|
|
8993
8993
|
m.className = "field-note", m.innerHTML = l.fieldNote, p.appendChild(m);
|
|
8994
8994
|
}
|
|
@@ -9026,7 +9026,7 @@ class yn {
|
|
|
9026
9026
|
if (b === "multi-select") {
|
|
9027
9027
|
let g = this.getId();
|
|
9028
9028
|
const v = document.createElement("div");
|
|
9029
|
-
if (v.id = `checkbox_group_label_${g}`, v.className = "field-label-normal", v.innerHTML = l.title + (l.isRequired ?
|
|
9029
|
+
if (v.id = `checkbox_group_label_${g}`, v.className = "field-label-normal", v.innerHTML = l.title + (l.isRequired ? ` <span class="text-red-500" aria-hidden="true">*</span><span style="position:absolute;width:1px;height:1px;clip-path:inset(50%);overflow:hidden;white-space:nowrap;">(${this.out("required")})</span>` : ""), p.appendChild(v), l.fieldNote) {
|
|
9030
9030
|
const m = document.createElement("div");
|
|
9031
9031
|
m.className = "field-note", m.innerHTML = l.fieldNote, p.appendChild(m);
|
|
9032
9032
|
}
|
|
@@ -9068,7 +9068,7 @@ class yn {
|
|
|
9068
9068
|
if (b === "switch") {
|
|
9069
9069
|
let g = this.getId();
|
|
9070
9070
|
const v = document.createElement("label");
|
|
9071
|
-
if (v.className = "field-label", v.innerHTML = l.title + (l.isRequired ? ' <span class="text-red-500">*</span>' : ""), v.id = `switch_${g}`, p.appendChild(v), l.fieldNote) {
|
|
9071
|
+
if (v.className = "field-label", v.innerHTML = l.title + (l.isRequired ? ' <span class="text-red-500" aria-hidden="true">*</span>' : ""), v.id = `switch_${g}`, p.appendChild(v), l.fieldNote) {
|
|
9072
9072
|
const x = document.createElement("div");
|
|
9073
9073
|
x.className = "field-note", x.innerHTML = l.fieldNote, p.appendChild(x);
|
|
9074
9074
|
}
|
|
@@ -9077,7 +9077,7 @@ class yn {
|
|
|
9077
9077
|
const m = document.createElement("div");
|
|
9078
9078
|
m.className = "switch-thumb", f.appendChild(m);
|
|
9079
9079
|
const y = document.createElement("input");
|
|
9080
|
-
y.id = `
|
|
9080
|
+
y.id = `switch_input_${g}`, y.setAttribute("aria-hidden", "true"), y.type = "text", y.name = w, y.style.cssText = "position:absolute;bottom:0px;left:25px;width:1px;height:1px;clip-path:inset(50%);overflow:hidden;", y.setAttribute("tabindex", "-1"), l.isRequired && (y.setAttribute("required", "required"), y.setCustomValidity(this.out("Please toggle this switch to proceed.")), f.setAttribute("aria-required", "true")), p.appendChild(y), l.value === "true" ? (f.setAttribute("aria-checked", "true"), f.setAttribute("data-checked", "true"), y.value = "true", l.isRequired && y.setCustomValidity("")) : (f.setAttribute("aria-checked", "false"), f.setAttribute("data-checked", "false"), y.value = "false", l.isRequired && y.setCustomValidity(this.out("Please toggle this switch to proceed."))), v.addEventListener("click", () => {
|
|
9081
9081
|
f.focus();
|
|
9082
9082
|
});
|
|
9083
9083
|
const k = () => {
|
|
@@ -9095,7 +9095,7 @@ class yn {
|
|
|
9095
9095
|
if (b === "dropdown") {
|
|
9096
9096
|
let g = this.getId();
|
|
9097
9097
|
const v = document.createElement("label");
|
|
9098
|
-
if (v.setAttribute("for", `dropdown_${g}`), v.className = "field-label", v.innerHTML = l.title + (l.isRequired ? ' <span class="text-red-500">*</span>' : ""), p.appendChild(v), l.fieldNote) {
|
|
9098
|
+
if (v.setAttribute("for", `dropdown_${g}`), v.className = "field-label", v.innerHTML = l.title + (l.isRequired ? ' <span class="text-red-500" aria-hidden="true">*</span>' : ""), p.appendChild(v), l.fieldNote) {
|
|
9099
9099
|
const M = document.createElement("div");
|
|
9100
9100
|
M.className = "field-note", M.innerHTML = l.fieldNote, p.appendChild(M);
|
|
9101
9101
|
}
|
|
@@ -9133,7 +9133,7 @@ class yn {
|
|
|
9133
9133
|
if (b === "date") {
|
|
9134
9134
|
let g = this.getId();
|
|
9135
9135
|
const v = document.createElement("label");
|
|
9136
|
-
if (v.setAttribute("for", `date_${g}`), v.className = "field-label", v.innerHTML = l.title + (l.isRequired ? ' <span class="text-red-500">*</span>' : ""), p.appendChild(v), l.fieldNote) {
|
|
9136
|
+
if (v.setAttribute("for", `date_${g}`), v.className = "field-label", v.innerHTML = l.title + (l.isRequired ? ' <span class="text-red-500" aria-hidden="true">*</span>' : ""), p.appendChild(v), l.fieldNote) {
|
|
9137
9137
|
const m = document.createElement("div");
|
|
9138
9138
|
m.className = "field-note", m.innerHTML = l.fieldNote, p.appendChild(m);
|
|
9139
9139
|
}
|
|
@@ -9143,7 +9143,7 @@ class yn {
|
|
|
9143
9143
|
if (b === "time") {
|
|
9144
9144
|
let g = this.getId();
|
|
9145
9145
|
const v = document.createElement("label");
|
|
9146
|
-
if (v.setAttribute("for", `time_${g}`), v.className = "field-label", v.innerHTML = l.title + (l.isRequired ? ' <span class="text-red-500">*</span>' : ""), p.appendChild(v), l.fieldNote) {
|
|
9146
|
+
if (v.setAttribute("for", `time_${g}`), v.className = "field-label", v.innerHTML = l.title + (l.isRequired ? ' <span class="text-red-500" aria-hidden="true">*</span>' : ""), p.appendChild(v), l.fieldNote) {
|
|
9147
9147
|
const m = document.createElement("div");
|
|
9148
9148
|
m.className = "field-note", m.innerHTML = l.fieldNote, p.appendChild(m);
|
|
9149
9149
|
}
|
|
@@ -9153,7 +9153,7 @@ class yn {
|
|
|
9153
9153
|
if (b === "datetime") {
|
|
9154
9154
|
let g = this.getId();
|
|
9155
9155
|
const v = document.createElement("label");
|
|
9156
|
-
if (v.setAttribute("for", `datetime_${g}`), v.className = "field-label", v.innerHTML = l.title + (l.isRequired ? ' <span class="text-red-500">*</span>' : ""), p.appendChild(v), l.fieldNote) {
|
|
9156
|
+
if (v.setAttribute("for", `datetime_${g}`), v.className = "field-label", v.innerHTML = l.title + (l.isRequired ? ' <span class="text-red-500" aria-hidden="true">*</span>' : ""), p.appendChild(v), l.fieldNote) {
|
|
9157
9157
|
const m = document.createElement("div");
|
|
9158
9158
|
m.className = "field-note", m.innerHTML = l.fieldNote, p.appendChild(m);
|
|
9159
9159
|
}
|
|
@@ -9163,7 +9163,7 @@ class yn {
|
|
|
9163
9163
|
if (b === "color") {
|
|
9164
9164
|
let g = this.getId();
|
|
9165
9165
|
const v = document.createElement("label");
|
|
9166
|
-
if (v.setAttribute("for", `color_${g}`), v.className = "field-label", v.innerHTML = l.title + (l.isRequired ? ' <span class="text-red-500">*</span>' : ""), p.appendChild(v), l.fieldNote) {
|
|
9166
|
+
if (v.setAttribute("for", `color_${g}`), v.className = "field-label", v.innerHTML = l.title + (l.isRequired ? ' <span class="text-red-500" aria-hidden="true">*</span>' : ""), p.appendChild(v), l.fieldNote) {
|
|
9167
9167
|
const m = document.createElement("div");
|
|
9168
9168
|
m.className = "field-note", m.innerHTML = l.fieldNote, p.appendChild(m);
|
|
9169
9169
|
}
|
|
@@ -9173,7 +9173,7 @@ class yn {
|
|
|
9173
9173
|
if (b === "file" || b === "multifile") {
|
|
9174
9174
|
let g = this.getId();
|
|
9175
9175
|
const v = document.createElement("label");
|
|
9176
|
-
if (v.setAttribute("for", `file_${g}`), v.className = "field-label", v.innerHTML = l.title + (l.isRequired ? ' <span class="text-red-500">*</span>' : ""), p.appendChild(v), l.fieldNote) {
|
|
9176
|
+
if (v.setAttribute("for", `file_${g}`), v.className = "field-label", v.innerHTML = l.title + (l.isRequired ? ' <span class="text-red-500" aria-hidden="true">*</span>' : ""), p.appendChild(v), l.fieldNote) {
|
|
9177
9177
|
const I = document.createElement("div");
|
|
9178
9178
|
I.className = "field-note", I.innerHTML = l.fieldNote, p.appendChild(I);
|
|
9179
9179
|
}
|
|
@@ -9548,7 +9548,7 @@ class yn {
|
|
|
9548
9548
|
if (b === "email") {
|
|
9549
9549
|
let g = this.getId();
|
|
9550
9550
|
const v = document.createElement("label");
|
|
9551
|
-
if (v.setAttribute("for", `email_label_${g}`), v.className = "field-label", v.innerHTML = l.title + (l.isRequired ? ' <span class="text-red-500">*</span>' : ""), p.appendChild(v), l.fieldNote) {
|
|
9551
|
+
if (v.setAttribute("for", `email_label_${g}`), v.className = "field-label", v.innerHTML = l.title + (l.isRequired ? ' <span class="text-red-500" aria-hidden="true">*</span>' : ""), p.appendChild(v), l.fieldNote) {
|
|
9552
9552
|
const m = document.createElement("div");
|
|
9553
9553
|
m.className = "field-note", m.innerHTML = l.fieldNote, p.appendChild(m);
|
|
9554
9554
|
}
|
|
@@ -9558,7 +9558,7 @@ class yn {
|
|
|
9558
9558
|
if (b === "phone") {
|
|
9559
9559
|
let g = this.getId();
|
|
9560
9560
|
const v = document.createElement("label");
|
|
9561
|
-
if (v.setAttribute("for", `phone_label_${g}`), v.className = "field-label", v.innerHTML = l.title + (l.isRequired ? ' <span class="text-red-500">*</span>' : ""), p.appendChild(v), l.fieldNote) {
|
|
9561
|
+
if (v.setAttribute("for", `phone_label_${g}`), v.className = "field-label", v.innerHTML = l.title + (l.isRequired ? ' <span class="text-red-500" aria-hidden="true">*</span>' : ""), p.appendChild(v), l.fieldNote) {
|
|
9562
9562
|
const m = document.createElement("div");
|
|
9563
9563
|
m.className = "field-note", m.innerHTML = l.fieldNote, p.appendChild(m);
|
|
9564
9564
|
}
|
|
@@ -9568,7 +9568,7 @@ class yn {
|
|
|
9568
9568
|
if (b === "url") {
|
|
9569
9569
|
let g = this.getId();
|
|
9570
9570
|
const v = document.createElement("label");
|
|
9571
|
-
if (v.setAttribute("for", `url_label_${g}`), v.className = "field-label", v.innerHTML = l.title + (l.isRequired ? ' <span class="text-red-500">*</span>' : ""), p.appendChild(v), l.fieldNote) {
|
|
9571
|
+
if (v.setAttribute("for", `url_label_${g}`), v.className = "field-label", v.innerHTML = l.title + (l.isRequired ? ' <span class="text-red-500" aria-hidden="true">*</span>' : ""), p.appendChild(v), l.fieldNote) {
|
|
9572
9572
|
const m = document.createElement("div");
|
|
9573
9573
|
m.className = "field-note", m.innerHTML = l.fieldNote, p.appendChild(m);
|
|
9574
9574
|
}
|
|
@@ -329,15 +329,15 @@ Check the information and return the details.
|
|
|
329
329
|
<path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M7 7m0 2.667a2.667 2.667 0 0 1 2.667 -2.667h8.666a2.667 2.667 0 0 1 2.667 2.667v8.666a2.667 2.667 0 0 1 -2.667 2.667h-8.666a2.667 2.667 0 0 1 -2.667 -2.667z" /><path d="M4.012 16.737a2.005 2.005 0 0 1 -1.012 -1.737v-10c0 -1.1 .9 -2 2 -2h10c.75 0 1.158 .385 1.5 1" />
|
|
330
330
|
</svg>
|
|
331
331
|
<span>${this.out("Copy")}</span>
|
|
332
|
-
`},600)}),l.addEventListener("click",h=>{h.preventDefault(),localStorage.removeItem("_results"),localStorage.removeItem("_results_html"),e.innerHTML=""})}getScrollableParent(e){for(;e.parentElement;){const t=window.getComputedStyle(e.parentElement).overflowY;if((t==="auto"||t==="scroll")&&e.parentElement.scrollHeight>e.parentElement.clientHeight)return e.parentElement;e=e.parentElement}return null}stickyElement(e){if(!this.settings.alwaysVisibleSubmit)return;const i=this.getScrollableParent(e);this._scrollListener&&(i?i.removeEventListener("scroll",this._scrollListener):window.removeEventListener("scroll",this._scrollListener),window.removeEventListener("resize",this._resizeListener));let t;const n=()=>{e.style.position="",i?t=e.offsetTop+e.offsetHeight-i.offsetTop:t=e.offsetTop+e.offsetHeight},s=()=>{if(i)if(i.offsetHeight+i.scrollTop>t)e.style.position="",e.style.top="";else{const a=window.innerHeight-e.offsetHeight;e.style.position="fixed",e.style.top=`${a}px`}else if(window.innerHeight+window.scrollY>t)e.style.position="",e.style.top="";else{const a=window.innerHeight-e.offsetHeight;e.style.position="fixed",e.style.top=`${a}px`}e.parentNode.offsetWidth!==0&&(e.style.width=`${e.parentNode.offsetWidth}px`)};this._scrollListener=s;let r;this._resizeListener=()=>{r&&clearTimeout(r),r=setTimeout(()=>{let o=null;const a=()=>{const d=e.offsetTop;d===o?(n(),s()):(o=d,requestAnimationFrame(a))};a()},200)},n(),s(),i?i.addEventListener("scroll",s):window.addEventListener("scroll",s),window.addEventListener("resize",this._resizeListener)}view(e){if(!e)return;let i;try{i=JSON.parse(e)}catch{console.log("Invalid JSON Form.");return}this.json=i,this.inputListener=()=>{clearTimeout(this.debounceTimeout),this.debounceTimeout=setTimeout(()=>{const s=this.getFormValues();this.settings.onInputChange&&this.settings.onInputChange(s)},300)},this.changeListener=()=>{const s=this.getFormValues();this.settings.onInputChange&&this.settings.onInputChange(s)};let t;if(this.settings.isBuilder){if(!this.settings.previewSelector){this.settings.consoleLog&&console.log("previewSelector not set.");return}t=document.querySelector(this.settings.previewSelector)}else t=this.element;if(t){if(t.classList.remove("hidden"),t.classList.add("formview-container"),t.classList.add("fb-ui"),t.innerHTML="",!(i.hideHeader||!1)){const l=document.createElement("div");l.className="form-header",t.appendChild(l);const h=document.createElement("h1");h.className="form-title",h.innerText=i.title||this.out("Your Form Title Here"),l.appendChild(h);const p=document.createElement("p");p.className="form-desc",p.innerText=i.description||this.out("Your Description Here"),l.appendChild(p)}let r;this.settings.isBuilder?r=document.createElement("form"):r=document.createElement("div"),r.className="form-wrapper",r.style.flexFlow="wrap",t.appendChild(r);let o=1;i.elements&&i.elements.forEach(l=>{if(l.type==="spacer"){const g=document.createElement("div");g.className="form-spacer",l.spacerHeight&&!isNaN(parseFloat(l.spacerHeight))&&(g.style.height=l.spacerHeight+"px"),l.displayInOutput||r.appendChild(g);return}if(l.type==="separator"){const g=document.createElement("hr");g.style.borderTopColor=l.color,l.displayInOutput||r.appendChild(g);return}if(l.type==="html"){if(l.html){const g=document.createElement("div");g.innerHTML=l.html,l.displayInOutput||r.appendChild(g)}return}if(l.type==="heading"){const g=document.createElement(l.heading||"h2");g.innerHTML=l.headingText||this.out("Your Heading Here!"),l.displayInOutput||r.appendChild(g);return}if(l.type==="paragraph"){const g=document.createElement("p");g.innerHTML=l.paragraphText||this.out("Your paragraph content here!"),l.displayInOutput||r.appendChild(g);return}if(l.type==="media"){if(l.tag==="video"){const g=document.createElement("video");g.style.width="100%",g.style.height="auto",g.controls=!0;var h=document.createElement("source");h.src=l.url,h.type="video/mp4",g.appendChild(h),l.displayInOutput||r.appendChild(g)}else if(l.tag==="audio"){const g=document.createElement("audio");g.controls=!0;let v=document.createElement("source");v.src=l.url,v.type="audio/mp3",g.appendChild(v),l.displayInOutput||r.appendChild(g)}else if(l.tag==="img"){const g=document.createElement("img");g.src=l.url,g.setAttribute("alt",this.out("Output Image")),l.displayInOutput||r.appendChild(g)}return}if(l.type==="image"){const g=document.createElement("img");g.src=l.url,g.setAttribute("alt",this.out("Output Image")),l.displayInOutput||r.appendChild(g);return}if(l.type==="video"){const g=document.createElement("video");g.style.width="100%",g.style.height="auto",g.controls=!0;let v=document.createElement("source");v.src=l.url,v.type="video/mp4",g.appendChild(v),l.displayInOutput||r.appendChild(g);return}if(l.type==="audio"){const g=document.createElement("audio");g.controls=!0;let v=document.createElement("source");v.src=l.url,v.type="audio/mp3",g.appendChild(v),l.displayInOutput||r.appendChild(g);return}const p=document.createElement("div");p.className="form-field",l.type==="hidden"&&(p.className="hidden"),l.displayInOutput||r.appendChild(p),l.type==="color"&&p.classList.add("field-color");const b=l.type;let w=l.name;if(r.querySelector(`[name="${w}"]`)&&(o++,w=w+"_"+o),b==="short-text"){let g=this.getId();const v=document.createElement("label");if(v.setAttribute("for",`short_text_label_${g}`),v.className="field-label",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500">*</span>':""),p.appendChild(v),l.fieldNote){const m=document.createElement("div");m.className="field-note",m.innerHTML=l.fieldNote,p.appendChild(m)}const f=document.createElement("input");f.id=`short_text_label_${g}`,f.type="text",f.name=w,f.value=l.value||"",f.className="inp-base",f.placeholder=l.placeholder,l.isRequired&&f.setAttribute("required","required"),p.appendChild(f),f.addEventListener("input",this.inputListener)}if(b==="long-text"){let g=this.getId();const v=document.createElement("label");if(v.setAttribute("for",`long_text_label_${g}`),v.className="field-label",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500">*</span>':""),p.appendChild(v),l.fieldNote){const m=document.createElement("div");m.className="field-note",m.innerHTML=l.fieldNote,p.appendChild(m)}const f=document.createElement("textarea");f.id=`long_text_label_${g}`,f.name=w,f.value=l.value||"",f.className="inp-base",f.style.height=l.height+"px",f.placeholder=l.placeholder,l.isRequired&&f.setAttribute("required","required"),p.appendChild(f),f.addEventListener("input",this.inputListener)}if(b==="number"){let g=this.getId();const v=document.createElement("label");if(v.setAttribute("for",`number_label_${g}`),v.className="field-label",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500">*</span>':""),p.appendChild(v),l.fieldNote){const m=document.createElement("div");m.className="field-note",m.innerHTML=l.fieldNote,p.appendChild(m)}const f=document.createElement("input");f.id=`number_label_${g}`,f.type="number",f.name=w,f.value=l.value||"",f.className="inp-base",f.placeholder=l.placeholder,l.isRequired&&f.setAttribute("required","required"),p.appendChild(f),f.addEventListener("input",this.inputListener)}if(b==="slider"){p.classList.add("input-slider");let g=this.getId();const v=document.createElement("label");if(v.setAttribute("for",`number_label_${g}`),v.className="field-label",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500">*</span>':""),p.appendChild(v),l.fieldNote){const E=document.createElement("div");E.className="field-note",E.innerHTML=l.fieldNote,p.appendChild(E)}const f=document.createElement("div");f.className="slider-container",p.appendChild(f);const m=document.createElement("div");m.className="slider-values",f.appendChild(m);const y=document.createElement("span");m.appendChild(y),y.innerText=l.minValue;const k=document.createElement("span");m.appendChild(k),k.innerText=l.maxValue;const x=document.createElement("input");x.id=`number_label_${g}`,x.type="range",x.name=w,x.setAttribute("min",l.minValue),x.setAttribute("max",l.maxValue),x.setAttribute("step",l.step),x.setAttribute("value",l.value||0),f.appendChild(x);const S=document.createElement("div");S.className="current-value",f.appendChild(S),f.querySelector(".current-value").textContent=l.value||0,x.addEventListener("input",()=>{f.querySelector(".current-value").textContent=x.value})}if(b==="select"){let g=this.getId();const v=document.createElement("div");if(v.id=`radio_group_label_${g}`,v.className="field-label-normal",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500">*</span>':""),p.appendChild(v),l.fieldNote){const m=document.createElement("div");m.className="field-note",m.innerHTML=l.fieldNote,p.appendChild(m)}const f=document.createElement("div");if(f.setAttribute("aria-labelledby",`radio_group_label_${g}`),f.setAttribute("role","group"),f.className="div-options",p.appendChild(f),l.choices&&l.choices.forEach((m,y)=>{let k=m;l.choicesText&&(k=l.choicesText[y]||m);const x=document.createElement("label");x.setAttribute("for",`${g}_${y}`),x.className="option-label",f.appendChild(x);const S=document.createElement("input");S.type="radio",S.className="peer",S.id=`${g}_${y}`,S.name=w,S.value=m,x.appendChild(S),y===l.selected&&(S.checked=!0);const E=document.createElement("span");E.className="peer-span-rounded",x.appendChild(E);const L='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M12 7a5 5 0 1 1 -4.995 5.217l-.005 -.217l.005 -.217a5 5 0 0 1 4.995 -4.783z"></path></svg>';E.innerHTML=L,y===0&&l.isRequired&&S.setAttribute("required","required");const M=document.createElement("span");M.innerText=k,x.appendChild(M),S.addEventListener("change",this.changeListener)}),l.showOtherItem){const m=document.createElement("label");m.setAttribute("for",g+"_other"),m.className="option-label",f.appendChild(m);const y=document.createElement("input");y.type="radio",y.className="peer",y.id=g+"_other",y.name=w,y.value="other",m.appendChild(y);const k=document.createElement("span");k.className="peer-span-rounded",m.appendChild(k);const x='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M12 7a5 5 0 1 1 -4.995 5.217l-.005 -.217l.005 -.217a5 5 0 0 1 4.995 -4.783z"></path></svg>';k.innerHTML=x;const S=document.createElement("span");S.innerText=l.otherText,m.appendChild(S);const E=document.createElement("div");p.appendChild(E);const L=document.createElement("input");L.type="text",L.name=w+"_other",L.className="inp-base",E.appendChild(L),y.addEventListener("change",this.changeListener),L.addEventListener("input",this.inputListener)}}if(b==="multi-select"){let g=this.getId();const v=document.createElement("div");if(v.id=`checkbox_group_label_${g}`,v.className="field-label-normal",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500">*</span>':""),p.appendChild(v),l.fieldNote){const m=document.createElement("div");m.className="field-note",m.innerHTML=l.fieldNote,p.appendChild(m)}const f=document.createElement("div");if(f.setAttribute("aria-labelledby",`checkbox_group_label_${g}`),f.setAttribute("role","group"),f.className="div-options",p.appendChild(f),l.choices&&l.choices.forEach((m,y)=>{let k=m;l.choicesText&&(k=l.choicesText[y]||m);const x=document.createElement("label");x.setAttribute("for",`${g}_${y}`),x.className="option-label",f.appendChild(x);const S=document.createElement("input");S.type="checkbox",S.className="peer",S.id=`${g}_${y}`,S.name=w+"[]",S.value=m,x.appendChild(S);const E=document.createElement("span");E.className="peer-span-square",x.appendChild(E);const L=`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="4" stroke-linecap="round" stroke-linejoin="round">
|
|
332
|
+
`},600)}),l.addEventListener("click",h=>{h.preventDefault(),localStorage.removeItem("_results"),localStorage.removeItem("_results_html"),e.innerHTML=""})}getScrollableParent(e){for(;e.parentElement;){const t=window.getComputedStyle(e.parentElement).overflowY;if((t==="auto"||t==="scroll")&&e.parentElement.scrollHeight>e.parentElement.clientHeight)return e.parentElement;e=e.parentElement}return null}stickyElement(e){if(!this.settings.alwaysVisibleSubmit)return;const i=this.getScrollableParent(e);this._scrollListener&&(i?i.removeEventListener("scroll",this._scrollListener):window.removeEventListener("scroll",this._scrollListener),window.removeEventListener("resize",this._resizeListener));let t;const n=()=>{e.style.position="",i?t=e.offsetTop+e.offsetHeight-i.offsetTop:t=e.offsetTop+e.offsetHeight},s=()=>{if(i)if(i.offsetHeight+i.scrollTop>t)e.style.position="",e.style.top="";else{const a=window.innerHeight-e.offsetHeight;e.style.position="fixed",e.style.top=`${a}px`}else if(window.innerHeight+window.scrollY>t)e.style.position="",e.style.top="";else{const a=window.innerHeight-e.offsetHeight;e.style.position="fixed",e.style.top=`${a}px`}e.parentNode.offsetWidth!==0&&(e.style.width=`${e.parentNode.offsetWidth}px`)};this._scrollListener=s;let r;this._resizeListener=()=>{r&&clearTimeout(r),r=setTimeout(()=>{let o=null;const a=()=>{const d=e.offsetTop;d===o?(n(),s()):(o=d,requestAnimationFrame(a))};a()},200)},n(),s(),i?i.addEventListener("scroll",s):window.addEventListener("scroll",s),window.addEventListener("resize",this._resizeListener)}view(e){if(!e)return;let i;try{i=JSON.parse(e)}catch{console.log("Invalid JSON Form.");return}this.json=i,this.inputListener=()=>{clearTimeout(this.debounceTimeout),this.debounceTimeout=setTimeout(()=>{const s=this.getFormValues();this.settings.onInputChange&&this.settings.onInputChange(s)},300)},this.changeListener=()=>{const s=this.getFormValues();this.settings.onInputChange&&this.settings.onInputChange(s)};let t;if(this.settings.isBuilder){if(!this.settings.previewSelector){this.settings.consoleLog&&console.log("previewSelector not set.");return}t=document.querySelector(this.settings.previewSelector)}else t=this.element;if(t){if(t.classList.remove("hidden"),t.classList.add("formview-container"),t.classList.add("fb-ui"),t.innerHTML="",!(i.hideHeader||!1)){const l=document.createElement("div");l.className="form-header",t.appendChild(l);const h=document.createElement("h1");h.className="form-title",h.innerText=i.title||this.out("Your Form Title Here"),l.appendChild(h);const p=document.createElement("p");p.className="form-desc",p.innerText=i.description||this.out("Your Description Here"),l.appendChild(p)}let r;this.settings.isBuilder?r=document.createElement("form"):r=document.createElement("div"),r.className="form-wrapper",r.style.flexFlow="wrap",t.appendChild(r);let o=1;i.elements&&i.elements.forEach(l=>{if(l.type==="spacer"){const g=document.createElement("div");g.className="form-spacer",l.spacerHeight&&!isNaN(parseFloat(l.spacerHeight))&&(g.style.height=l.spacerHeight+"px"),l.displayInOutput||r.appendChild(g);return}if(l.type==="separator"){const g=document.createElement("hr");g.style.borderTopColor=l.color,l.displayInOutput||r.appendChild(g);return}if(l.type==="html"){if(l.html){const g=document.createElement("div");g.innerHTML=l.html,l.displayInOutput||r.appendChild(g)}return}if(l.type==="heading"){const g=document.createElement(l.heading||"h2");g.innerHTML=l.headingText||this.out("Your Heading Here!"),l.displayInOutput||r.appendChild(g);return}if(l.type==="paragraph"){const g=document.createElement("p");g.innerHTML=l.paragraphText||this.out("Your paragraph content here!"),l.displayInOutput||r.appendChild(g);return}if(l.type==="media"){if(l.tag==="video"){const g=document.createElement("video");g.style.width="100%",g.style.height="auto",g.controls=!0;var h=document.createElement("source");h.src=l.url,h.type="video/mp4",g.appendChild(h),l.displayInOutput||r.appendChild(g)}else if(l.tag==="audio"){const g=document.createElement("audio");g.controls=!0;let v=document.createElement("source");v.src=l.url,v.type="audio/mp3",g.appendChild(v),l.displayInOutput||r.appendChild(g)}else if(l.tag==="img"){const g=document.createElement("img");g.src=l.url,g.setAttribute("alt",this.out("Output Image")),l.displayInOutput||r.appendChild(g)}return}if(l.type==="image"){const g=document.createElement("img");g.src=l.url,g.setAttribute("alt",this.out("Output Image")),l.displayInOutput||r.appendChild(g);return}if(l.type==="video"){const g=document.createElement("video");g.style.width="100%",g.style.height="auto",g.controls=!0;let v=document.createElement("source");v.src=l.url,v.type="video/mp4",g.appendChild(v),l.displayInOutput||r.appendChild(g);return}if(l.type==="audio"){const g=document.createElement("audio");g.controls=!0;let v=document.createElement("source");v.src=l.url,v.type="audio/mp3",g.appendChild(v),l.displayInOutput||r.appendChild(g);return}const p=document.createElement("div");p.className="form-field",l.type==="hidden"&&(p.className="hidden"),l.displayInOutput||r.appendChild(p),l.type==="color"&&p.classList.add("field-color");const b=l.type;let w=l.name;if(r.querySelector(`[name="${w}"]`)&&(o++,w=w+"_"+o),b==="short-text"){let g=this.getId();const v=document.createElement("label");if(v.setAttribute("for",`short_text_label_${g}`),v.className="field-label",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500" aria-hidden="true">*</span>':""),p.appendChild(v),l.fieldNote){const m=document.createElement("div");m.className="field-note",m.innerHTML=l.fieldNote,p.appendChild(m)}const f=document.createElement("input");f.id=`short_text_label_${g}`,f.type="text",f.name=w,f.value=l.value||"",f.className="inp-base",f.placeholder=l.placeholder,l.isRequired&&f.setAttribute("required","required"),p.appendChild(f),f.addEventListener("input",this.inputListener)}if(b==="long-text"){let g=this.getId();const v=document.createElement("label");if(v.setAttribute("for",`long_text_label_${g}`),v.className="field-label",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500" aria-hidden="true">*</span>':""),p.appendChild(v),l.fieldNote){const m=document.createElement("div");m.className="field-note",m.innerHTML=l.fieldNote,p.appendChild(m)}const f=document.createElement("textarea");f.id=`long_text_label_${g}`,f.name=w,f.value=l.value||"",f.className="inp-base",f.style.height=l.height+"px",f.placeholder=l.placeholder,l.isRequired&&f.setAttribute("required","required"),p.appendChild(f),f.addEventListener("input",this.inputListener)}if(b==="number"){let g=this.getId();const v=document.createElement("label");if(v.setAttribute("for",`number_label_${g}`),v.className="field-label",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500" aria-hidden="true">*</span>':""),p.appendChild(v),l.fieldNote){const m=document.createElement("div");m.className="field-note",m.innerHTML=l.fieldNote,p.appendChild(m)}const f=document.createElement("input");f.id=`number_label_${g}`,f.type="number",f.name=w,f.value=l.value||"",f.className="inp-base",f.placeholder=l.placeholder,l.isRequired&&f.setAttribute("required","required"),p.appendChild(f),f.addEventListener("input",this.inputListener)}if(b==="slider"){p.classList.add("input-slider");let g=this.getId();const v=document.createElement("label");if(v.setAttribute("for",`number_label_${g}`),v.className="field-label",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500" aria-hidden="true">*</span>':""),p.appendChild(v),l.fieldNote){const E=document.createElement("div");E.className="field-note",E.innerHTML=l.fieldNote,p.appendChild(E)}const f=document.createElement("div");f.className="slider-container",p.appendChild(f);const m=document.createElement("div");m.className="slider-values",f.appendChild(m);const y=document.createElement("span");m.appendChild(y),y.innerText=l.minValue;const k=document.createElement("span");m.appendChild(k),k.innerText=l.maxValue;const x=document.createElement("input");x.id=`number_label_${g}`,x.type="range",x.name=w,x.setAttribute("min",l.minValue),x.setAttribute("max",l.maxValue),x.setAttribute("step",l.step),x.setAttribute("value",l.value||0),f.appendChild(x);const S=document.createElement("div");S.className="current-value",f.appendChild(S),f.querySelector(".current-value").textContent=l.value||0,x.addEventListener("input",()=>{f.querySelector(".current-value").textContent=x.value})}if(b==="select"){let g=this.getId();const v=document.createElement("div");if(v.id=`radio_group_label_${g}`,v.className="field-label-normal",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500" aria-hidden="true">*</span>':""),p.appendChild(v),l.fieldNote){const m=document.createElement("div");m.className="field-note",m.innerHTML=l.fieldNote,p.appendChild(m)}const f=document.createElement("div");if(f.setAttribute("aria-labelledby",`radio_group_label_${g}`),f.setAttribute("role","group"),f.className="div-options",p.appendChild(f),l.choices&&l.choices.forEach((m,y)=>{let k=m;l.choicesText&&(k=l.choicesText[y]||m);const x=document.createElement("label");x.setAttribute("for",`${g}_${y}`),x.className="option-label",f.appendChild(x);const S=document.createElement("input");S.type="radio",S.className="peer",S.id=`${g}_${y}`,S.name=w,S.value=m,x.appendChild(S),y===l.selected&&(S.checked=!0);const E=document.createElement("span");E.className="peer-span-rounded",x.appendChild(E);const L='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M12 7a5 5 0 1 1 -4.995 5.217l-.005 -.217l.005 -.217a5 5 0 0 1 4.995 -4.783z"></path></svg>';E.innerHTML=L,y===0&&l.isRequired&&S.setAttribute("required","required");const M=document.createElement("span");M.innerText=k,x.appendChild(M),S.addEventListener("change",this.changeListener)}),l.showOtherItem){const m=document.createElement("label");m.setAttribute("for",g+"_other"),m.className="option-label",f.appendChild(m);const y=document.createElement("input");y.type="radio",y.className="peer",y.id=g+"_other",y.name=w,y.value="other",m.appendChild(y);const k=document.createElement("span");k.className="peer-span-rounded",m.appendChild(k);const x='<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="currentColor"><path stroke="none" d="M0 0h24v24H0z" fill="none"></path><path d="M12 7a5 5 0 1 1 -4.995 5.217l-.005 -.217l.005 -.217a5 5 0 0 1 4.995 -4.783z"></path></svg>';k.innerHTML=x;const S=document.createElement("span");S.innerText=l.otherText,m.appendChild(S);const E=document.createElement("div");p.appendChild(E);const L=document.createElement("input");L.type="text",L.name=w+"_other",L.className="inp-base",E.appendChild(L),y.addEventListener("change",this.changeListener),L.addEventListener("input",this.inputListener)}}if(b==="multi-select"){let g=this.getId();const v=document.createElement("div");if(v.id=`checkbox_group_label_${g}`,v.className="field-label-normal",v.innerHTML=l.title+(l.isRequired?` <span class="text-red-500" aria-hidden="true">*</span><span style="position:absolute;width:1px;height:1px;clip-path:inset(50%);overflow:hidden;white-space:nowrap;">(${this.out("required")})</span>`:""),p.appendChild(v),l.fieldNote){const m=document.createElement("div");m.className="field-note",m.innerHTML=l.fieldNote,p.appendChild(m)}const f=document.createElement("div");if(f.setAttribute("aria-labelledby",`checkbox_group_label_${g}`),f.setAttribute("role","group"),f.className="div-options",p.appendChild(f),l.choices&&l.choices.forEach((m,y)=>{let k=m;l.choicesText&&(k=l.choicesText[y]||m);const x=document.createElement("label");x.setAttribute("for",`${g}_${y}`),x.className="option-label",f.appendChild(x);const S=document.createElement("input");S.type="checkbox",S.className="peer",S.id=`${g}_${y}`,S.name=w+"[]",S.value=m,x.appendChild(S);const E=document.createElement("span");E.className="peer-span-square",x.appendChild(E);const L=`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="4" stroke-linecap="round" stroke-linejoin="round">
|
|
333
333
|
<path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M5 12l5 5l10 -10" />
|
|
334
334
|
</svg>`;E.innerHTML=L;const M=document.createElement("span");M.innerText=k,x.appendChild(M),S.addEventListener("change",this.changeListener)}),l.showOtherItem){const m=document.createElement("label");m.setAttribute("for",g+"_other"),m.className="option-label",f.appendChild(m);const y=document.createElement("input");y.type="checkbox",y.className="peer",y.id=g+"_other",y.name=w,y.value="other",m.appendChild(y);const k=document.createElement("span");k.className="peer-span-square",m.appendChild(k);const x=`<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="4" stroke-linecap="round" stroke-linejoin="round">
|
|
335
335
|
<path stroke="none" d="M0 0h24v24H0z" fill="none"/><path d="M5 12l5 5l10 -10" />
|
|
336
|
-
</svg>`;k.innerHTML=x;const S=document.createElement("span");S.innerText=l.otherText,m.appendChild(S);const E=document.createElement("div");p.appendChild(E);const L=document.createElement("input");L.type="text",L.name=w+"_other",L.className="inp-base",E.appendChild(L),y.addEventListener("change",this.changeListener),L.addEventListener("input",this.inputListener)}}if(b==="switch"){let g=this.getId();const v=document.createElement("label");if(v.className="field-label",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500">*</span>':""),v.id=`switch_${g}`,p.appendChild(v),l.fieldNote){const x=document.createElement("div");x.className="field-note",x.innerHTML=l.fieldNote,p.appendChild(x)}const f=document.createElement("div");f.className="switch",f.tabIndex=0,f.role="switch",f.setAttribute("aria-labelledby",`switch_${g}`),f.setAttribute("aria-checked","false"),f.setAttribute("data-checked","false"),p.appendChild(f);const m=document.createElement("div");m.className="switch-thumb",f.appendChild(m);const y=document.createElement("input");y.id=`
|
|
336
|
+
</svg>`;k.innerHTML=x;const S=document.createElement("span");S.innerText=l.otherText,m.appendChild(S);const E=document.createElement("div");p.appendChild(E);const L=document.createElement("input");L.type="text",L.name=w+"_other",L.className="inp-base",E.appendChild(L),y.addEventListener("change",this.changeListener),L.addEventListener("input",this.inputListener)}}if(b==="switch"){let g=this.getId();const v=document.createElement("label");if(v.className="field-label",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500" aria-hidden="true">*</span>':""),v.id=`switch_${g}`,p.appendChild(v),l.fieldNote){const x=document.createElement("div");x.className="field-note",x.innerHTML=l.fieldNote,p.appendChild(x)}const f=document.createElement("div");f.className="switch",f.tabIndex=0,f.role="switch",f.setAttribute("aria-labelledby",`switch_${g}`),f.setAttribute("aria-checked","false"),f.setAttribute("data-checked","false"),p.appendChild(f);const m=document.createElement("div");m.className="switch-thumb",f.appendChild(m);const y=document.createElement("input");y.id=`switch_input_${g}`,y.setAttribute("aria-hidden","true"),y.type="text",y.name=w,y.style.cssText="position:absolute;bottom:0px;left:25px;width:1px;height:1px;clip-path:inset(50%);overflow:hidden;",y.setAttribute("tabindex","-1"),l.isRequired&&(y.setAttribute("required","required"),y.setCustomValidity(this.out("Please toggle this switch to proceed.")),f.setAttribute("aria-required","true")),p.appendChild(y),l.value==="true"?(f.setAttribute("aria-checked","true"),f.setAttribute("data-checked","true"),y.value="true",l.isRequired&&y.setCustomValidity("")):(f.setAttribute("aria-checked","false"),f.setAttribute("data-checked","false"),y.value="false",l.isRequired&&y.setCustomValidity(this.out("Please toggle this switch to proceed."))),v.addEventListener("click",()=>{f.focus()});const k=()=>{const x=f.getAttribute("aria-checked")==="true";f.setAttribute("aria-checked",!x),f.setAttribute("data-checked",!x),x?(y.value="false",l.isRequired&&y.setCustomValidity(this.out("Please toggle this switch to proceed."))):(y.value="true",l.isRequired&&y.setCustomValidity(""));const S=this.getFormValues();this.settings.onInputChange&&this.settings.onInputChange(S)};f.addEventListener("keydown",x=>{(x.key===" "||x.key==="Enter")&&(x.preventDefault(),k())}),f.addEventListener("click",()=>{k()})}if(b==="dropdown"){let g=this.getId();const v=document.createElement("label");if(v.setAttribute("for",`dropdown_${g}`),v.className="field-label",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500" aria-hidden="true">*</span>':""),p.appendChild(v),l.fieldNote){const M=document.createElement("div");M.className="field-note",M.innerHTML=l.fieldNote,p.appendChild(M)}const f=document.createElement("div");f.className="relative",p.appendChild(f);const m=document.createElement("div");m.className="relative inline-block",f.appendChild(m);const y=document.createElement("select");y.id=`dropdown_${g}`,y.name=w,l.isRequired&&y.setAttribute("required","required"),m.appendChild(y);const k=document.createElement("option");if(k.setAttribute("selected","selected"),k.setAttribute("disabled","disabled"),k.value="",k.innerText=l.placeholder,y.appendChild(k),l.choices&&l.choices.forEach((M,C)=>{let D=M;l.choicesText&&(D=l.choicesText[C]||M);const O=document.createElement("option");O.value=M,O.innerText=D,y.appendChild(O),C===l.selected&&(k.remove(),O.setAttribute("selected","selected"))}),l.showOtherItem){const M=document.createElement("option");M.value="other",M.innerText=l.otherText,y.appendChild(M)}const x=document.createElement("div");x.className="select-arrow",m.appendChild(x),this.appendHtml(x,`
|
|
337
337
|
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
|
338
338
|
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
|
|
339
339
|
</svg>
|
|
340
|
-
`);const S=document.createElement("input");S.type="text",S.id=`input_other_${g}`,S.name=w+"_other",S.className="input-other hidden inp-base",p.appendChild(S);const E=p.querySelector(`#dropdown_${g}`),L=p.querySelector(`#input_other_${g}`);E.addEventListener("change",()=>{E.value==="other"?(L.classList.remove("hidden"),L.focus()):L.classList.add("hidden");const M=this.getFormValues();this.settings.onInputChange&&this.settings.onInputChange(M)}),S.addEventListener("input",this.inputListener)}if(b==="date"){let g=this.getId();const v=document.createElement("label");if(v.setAttribute("for",`date_${g}`),v.className="field-label",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500">*</span>':""),p.appendChild(v),l.fieldNote){const m=document.createElement("div");m.className="field-note",m.innerHTML=l.fieldNote,p.appendChild(m)}const f=document.createElement("input");f.id=`date_${g}`,f.type="date",f.name=w,f.className="inp-base",f.placeholder=l.placeholder,l.isRequired&&f.setAttribute("required","required"),p.appendChild(f),f.addEventListener("change",this.changeListener)}if(b==="time"){let g=this.getId();const v=document.createElement("label");if(v.setAttribute("for",`time_${g}`),v.className="field-label",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500">*</span>':""),p.appendChild(v),l.fieldNote){const m=document.createElement("div");m.className="field-note",m.innerHTML=l.fieldNote,p.appendChild(m)}const f=document.createElement("input");f.id=`time_${g}`,f.type="time",f.name=w,f.className="inp-base",f.placeholder=l.placeholder,l.isRequired&&f.setAttribute("required","required"),p.appendChild(f),f.addEventListener("change",this.changeListener)}if(b==="datetime"){let g=this.getId();const v=document.createElement("label");if(v.setAttribute("for",`datetime_${g}`),v.className="field-label",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500">*</span>':""),p.appendChild(v),l.fieldNote){const m=document.createElement("div");m.className="field-note",m.innerHTML=l.fieldNote,p.appendChild(m)}const f=document.createElement("input");f.id=`datetime_${g}`,f.type="datetime-local",f.name=w,f.className="inp-base",f.placeholder=l.placeholder,l.isRequired&&f.setAttribute("required","required"),p.appendChild(f),f.addEventListener("change",this.changeListener)}if(b==="color"){let g=this.getId();const v=document.createElement("label");if(v.setAttribute("for",`color_${g}`),v.className="field-label",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500">*</span>':""),p.appendChild(v),l.fieldNote){const m=document.createElement("div");m.className="field-note",m.innerHTML=l.fieldNote,p.appendChild(m)}const f=document.createElement("input");f.id=`color_${g}`,f.type="color",f.name=w,f.value=l.value||"",f.className="input-color",f.placeholder=l.placeholder,l.isRequired&&f.setAttribute("required","required"),p.appendChild(f),f.addEventListener("input",this.inputListener)}if(b==="file"||b==="multifile"){let g=this.getId();const v=document.createElement("label");if(v.setAttribute("for",`file_${g}`),v.className="field-label",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500">*</span>':""),p.appendChild(v),l.fieldNote){const I=document.createElement("div");I.className="field-note",I.innerHTML=l.fieldNote,p.appendChild(I)}const f=document.createElement("div");f.className="file-input-wrapper",b==="file"&&f.setAttribute("aria-label",this.out(this.settings.fileUploadText)),b==="multifile"&&f.setAttribute("aria-label",this.out(this.settings.multiFileUploadText)),p.appendChild(f);const m=document.createElement("input");m.id=`input_url_label_${g}`,m.type="text",m.name=w+"__url",m.value=l.value||"",m.className="inp-base input-file-url",m.placeholder=l.placeholder||this.out("Enter URL."),p.appendChild(m),m.addEventListener("input",()=>{const I=p.querySelector(".btn-clearfile");I&&I.click(),this.inputListener(),m.value!==""?l.isRequired&&y.removeAttribute("required"):l.isRequired&&y.setAttribute("required","required"),Ct(m.value),this.clearSelectedFiles()}),l.useURL?m.style.display="":m.style.display="none";const y=document.createElement("input");y.id=`file_${g}`,y.type="file",b==="multifile"&&(y.multiple=!0),y.name=w,l.isRequired&&y.setAttribute("required","required"),y.className="peer",f.appendChild(y);const k=document.createElement("div");k.className="file-drop-area",f.appendChild(k);const x=document.createElement("div");x.className="file-controls",x.id=`drag_message_${g}`,f.appendChild(x);let S;(!l.source||l.source&&l.source==="local"||l.source&&l.source==="local_and_camera")&&(S=document.createElement("div"),S.className="file-drop-info",b==="file"&&(S.innerHTML=this.out(this.settings.fileUploadText)),b==="multifile"&&(S.innerHTML=this.out(this.settings.multiFileUploadText)),x.appendChild(S));let E;(!l.source||l.source&&l.source==="local"||l.source&&l.source==="local_and_camera")&&(E=document.createElement("button"),E.className="btn-selectfile",E.innerHTML=`
|
|
340
|
+
`);const S=document.createElement("input");S.type="text",S.id=`input_other_${g}`,S.name=w+"_other",S.className="input-other hidden inp-base",p.appendChild(S);const E=p.querySelector(`#dropdown_${g}`),L=p.querySelector(`#input_other_${g}`);E.addEventListener("change",()=>{E.value==="other"?(L.classList.remove("hidden"),L.focus()):L.classList.add("hidden");const M=this.getFormValues();this.settings.onInputChange&&this.settings.onInputChange(M)}),S.addEventListener("input",this.inputListener)}if(b==="date"){let g=this.getId();const v=document.createElement("label");if(v.setAttribute("for",`date_${g}`),v.className="field-label",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500" aria-hidden="true">*</span>':""),p.appendChild(v),l.fieldNote){const m=document.createElement("div");m.className="field-note",m.innerHTML=l.fieldNote,p.appendChild(m)}const f=document.createElement("input");f.id=`date_${g}`,f.type="date",f.name=w,f.className="inp-base",f.placeholder=l.placeholder,l.isRequired&&f.setAttribute("required","required"),p.appendChild(f),f.addEventListener("change",this.changeListener)}if(b==="time"){let g=this.getId();const v=document.createElement("label");if(v.setAttribute("for",`time_${g}`),v.className="field-label",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500" aria-hidden="true">*</span>':""),p.appendChild(v),l.fieldNote){const m=document.createElement("div");m.className="field-note",m.innerHTML=l.fieldNote,p.appendChild(m)}const f=document.createElement("input");f.id=`time_${g}`,f.type="time",f.name=w,f.className="inp-base",f.placeholder=l.placeholder,l.isRequired&&f.setAttribute("required","required"),p.appendChild(f),f.addEventListener("change",this.changeListener)}if(b==="datetime"){let g=this.getId();const v=document.createElement("label");if(v.setAttribute("for",`datetime_${g}`),v.className="field-label",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500" aria-hidden="true">*</span>':""),p.appendChild(v),l.fieldNote){const m=document.createElement("div");m.className="field-note",m.innerHTML=l.fieldNote,p.appendChild(m)}const f=document.createElement("input");f.id=`datetime_${g}`,f.type="datetime-local",f.name=w,f.className="inp-base",f.placeholder=l.placeholder,l.isRequired&&f.setAttribute("required","required"),p.appendChild(f),f.addEventListener("change",this.changeListener)}if(b==="color"){let g=this.getId();const v=document.createElement("label");if(v.setAttribute("for",`color_${g}`),v.className="field-label",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500" aria-hidden="true">*</span>':""),p.appendChild(v),l.fieldNote){const m=document.createElement("div");m.className="field-note",m.innerHTML=l.fieldNote,p.appendChild(m)}const f=document.createElement("input");f.id=`color_${g}`,f.type="color",f.name=w,f.value=l.value||"",f.className="input-color",f.placeholder=l.placeholder,l.isRequired&&f.setAttribute("required","required"),p.appendChild(f),f.addEventListener("input",this.inputListener)}if(b==="file"||b==="multifile"){let g=this.getId();const v=document.createElement("label");if(v.setAttribute("for",`file_${g}`),v.className="field-label",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500" aria-hidden="true">*</span>':""),p.appendChild(v),l.fieldNote){const I=document.createElement("div");I.className="field-note",I.innerHTML=l.fieldNote,p.appendChild(I)}const f=document.createElement("div");f.className="file-input-wrapper",b==="file"&&f.setAttribute("aria-label",this.out(this.settings.fileUploadText)),b==="multifile"&&f.setAttribute("aria-label",this.out(this.settings.multiFileUploadText)),p.appendChild(f);const m=document.createElement("input");m.id=`input_url_label_${g}`,m.type="text",m.name=w+"__url",m.value=l.value||"",m.className="inp-base input-file-url",m.placeholder=l.placeholder||this.out("Enter URL."),p.appendChild(m),m.addEventListener("input",()=>{const I=p.querySelector(".btn-clearfile");I&&I.click(),this.inputListener(),m.value!==""?l.isRequired&&y.removeAttribute("required"):l.isRequired&&y.setAttribute("required","required"),Ct(m.value),this.clearSelectedFiles()}),l.useURL?m.style.display="":m.style.display="none";const y=document.createElement("input");y.id=`file_${g}`,y.type="file",b==="multifile"&&(y.multiple=!0),y.name=w,l.isRequired&&y.setAttribute("required","required"),y.className="peer",f.appendChild(y);const k=document.createElement("div");k.className="file-drop-area",f.appendChild(k);const x=document.createElement("div");x.className="file-controls",x.id=`drag_message_${g}`,f.appendChild(x);let S;(!l.source||l.source&&l.source==="local"||l.source&&l.source==="local_and_camera")&&(S=document.createElement("div"),S.className="file-drop-info",b==="file"&&(S.innerHTML=this.out(this.settings.fileUploadText)),b==="multifile"&&(S.innerHTML=this.out(this.settings.multiFileUploadText)),x.appendChild(S));let E;(!l.source||l.source&&l.source==="local"||l.source&&l.source==="local_and_camera")&&(E=document.createElement("button"),E.className="btn-selectfile",E.innerHTML=`
|
|
341
341
|
<svg style="fill:none"xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.2" stroke-linecap="round" stroke-linejoin="round" class="icon-folder-open"><path stroke="none" d="M0 0h24v24H0z" fill="none"/>
|
|
342
342
|
<path d="M5 19l2.757 -7.351a1 1 0 0 1 .936 -.649h12.307a1 1 0 0 1 .986 1.164l-.996 5.211a2 2 0 0 1 -1.964 1.625h-14.026a2 2 0 0 1 -2 -2v-11a2 2 0 0 1 2 -2h4l3 3h7a2 2 0 0 1 2 2v2" />
|
|
343
343
|
</svg>
|
|
@@ -391,7 +391,7 @@ Check the information and return the details.
|
|
|
391
391
|
<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24" stroke-width="1.5" stroke="currentColor">
|
|
392
392
|
<path stroke-linecap="round" stroke-linejoin="round" d="m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0" />
|
|
393
393
|
</svg>
|
|
394
|
-
`,ue.appendChild(pe),pe.addEventListener("click",j=>{const we=pe.closest(".image-item");we&&we.remove(),(bn=>{const mi=new DataTransfer,yn=y.files;Array.from(yn).forEach(bi=>{bi!==bn&&mi.items.add(bi)}),y.files=mi.files})(I);const He=document.querySelector(".formview-container .submit-container");He&&setTimeout(()=>{this.stickyElement(He)},1e3),j.preventDefault(),j.stopImmediatePropagation()}),I.type.startsWith("image/")){const j=new FileReader;j.onload=function(we){let Te=document.createElement("img");Te.className="img-preview",se.appendChild(Te),Te.src=we.target.result},j.readAsDataURL(I)}const K=this.getFormValues();this.settings.onInputChange&&this.settings.onInputChange(K);const ve=document.querySelector(".formview-container .submit-container");ve&&setTimeout(()=>{this.stickyElement(ve)},1e3)}}}if(b==="email"){let g=this.getId();const v=document.createElement("label");if(v.setAttribute("for",`email_label_${g}`),v.className="field-label",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500">*</span>':""),p.appendChild(v),l.fieldNote){const m=document.createElement("div");m.className="field-note",m.innerHTML=l.fieldNote,p.appendChild(m)}const f=document.createElement("input");f.id=`email_label_${g}`,f.type="email",f.name=w,f.className="inp-base",f.placeholder=l.placeholder,l.isRequired&&f.setAttribute("required","required"),p.appendChild(f),f.addEventListener("input",this.inputListener)}if(b==="phone"){let g=this.getId();const v=document.createElement("label");if(v.setAttribute("for",`phone_label_${g}`),v.className="field-label",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500">*</span>':""),p.appendChild(v),l.fieldNote){const m=document.createElement("div");m.className="field-note",m.innerHTML=l.fieldNote,p.appendChild(m)}const f=document.createElement("input");f.id=`phone_label_${g}`,f.type="tel",f.name=w,f.className="inp-base",f.placeholder=l.placeholder,l.isRequired&&f.setAttribute("required","required"),p.appendChild(f),f.addEventListener("input",this.inputListener)}if(b==="url"){let g=this.getId();const v=document.createElement("label");if(v.setAttribute("for",`url_label_${g}`),v.className="field-label",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500">*</span>':""),p.appendChild(v),l.fieldNote){const m=document.createElement("div");m.className="field-note",m.innerHTML=l.fieldNote,p.appendChild(m)}const f=document.createElement("input");f.id=`url_label_${g}`,f.type="url",f.name=w,f.value=l.value||"",f.className="inp-base",f.placeholder=l.placeholder,l.isRequired&&f.setAttribute("required","required"),p.appendChild(f),f.addEventListener("input",this.inputListener)}if(b==="hidden"){let g=this.getId();const v=document.createElement("label");v.setAttribute("for",`hidden_label_${g}`),v.className="field-label hidden",v.innerText=l.title,p.appendChild(v);const f=document.createElement("input");f.id=`hidden_label_${g}`,f.type="hidden",f.name=w,f.value=l.value,p.appendChild(f)}});const a=r.closest("[data-site-token]");if(a){const l=a.getAttribute("data-site-token"),h=document.createElement("input");h.type="hidden",h.name="form_token",h.value=l,r.appendChild(h)}if(this.settings.isBuilder){const l=document.createElement("div");l.className="submit-container",r.appendChild(l);let h=!0;if("hideReset"in i&&(h=i.hideReset),!h){const _=document.createElement("button");_.className="btn-resetform";const g=i.resetText||this.settings.resetText;_.innerText=g,l.appendChild(_),_.addEventListener("click",f=>{f.preventDefault();const m=_.closest("form");m&&(m.reset(),m.querySelectorAll(".btn-clearfile").forEach(x=>{x.click()}),m.querySelectorAll(".slider-container").forEach(x=>{const S=x.querySelector("input");x.querySelector(".current-value").textContent=S.value}))}),(i.fullWidthButton||!1)&&_.classList.add("w-full")}const p=document.createElement("button");p.className="btn-submitform";const b=i.submitText||this.settings.submitText;p.innerText=b,l.appendChild(p),(i.fullWidthButton||!1)&&p.classList.add("w-full"),this.settings.alwaysVisibleSubmit&&l.classList.add("always-visible"),this.stickyElement(l),r.addEventListener("submit",async _=>{_.preventDefault(),this.steps&&this.steps.length>0&&this.process()})}else{let l="Reference Code:",h="reference_code",p="reference_code";const b=document.createElement("div");b.className="form-field ",b.classList.add(p),r.appendChild(b);let w=this.getId();const _=document.createElement("label");_.setAttribute("for",`short_text_label_${w}`),_.className="field-label",_.innerHTML=l,b.appendChild(_);const g=document.createElement("input");if(g.id=`short_text_label_${w}`,g.type="text",g.name=h,g.autocomplete="off",g.setAttribute("aria-hidden","true"),g.setAttribute("tabindex","-1"),g.className="inp-base",b.appendChild(g),this.settings.captchaContainer){const v=this.settings.captchaContainerClassName,f=document.createElement("div");f.className="captcha-container",v&&f.classList.add(v),r.appendChild(f)}if(i.useSubmitButton){const v=document.createElement("div");v.className="submit-container",r.appendChild(v);let f=!0;if("hideReset"in i&&(f=i.hideReset),!f){const S=document.createElement("button");S.className="btn-resetform";const E=i.resetText||this.settings.resetText;S.innerText=E,v.appendChild(S),S.addEventListener("click",M=>{M.preventDefault();const C=S.closest("form");C&&(C.reset(),C.querySelectorAll(".btn-clearfile").forEach($=>{$.click()}),C.querySelectorAll(".slider-container").forEach($=>{const R=$.querySelector("input");$.querySelector(".current-value").textContent=R.value}))}),(i.fullWidthButton||!1)&&S.classList.add("w-full")}const m=document.createElement("button");m.className="btn-submitform";const y=i.submitText;m.innerText=y,v.appendChild(m),(i.fullWidthButton||!1)&&m.classList.add("w-full"),this.settings.alwaysVisibleSubmit&&v.classList.add("always-visible"),this.stickyElement(v),m.addEventListener("click",async S=>{this.trigger("submit",S)});const x=r.closest("form");x?x.addEventListener("submit",async S=>{this.steps&&this.steps.length>0&&(S.preventDefault(),S.stopImmediatePropagation(),this.process())}):m.addEventListener("click",async S=>{this.steps&&this.steps.length>0&&(S.preventDefault(),this.process())})}}let d,u;this.settings.resultSelector&&(d=document.querySelector(this.settings.resultSelector),d.classList.add("result-wrapper"),d.innerHTML="",u=document.createElement("div"),u.classList.add("result-container"),d.appendChild(u)),i.elements&&d&&i.elements.forEach(l=>{if(l.displayInOutput){if(l.type==="spacer"){const p=document.createElement("div");p.className="form-spacer",l.spacerHeight&&!isNaN(parseFloat(l.spacerHeight))&&(p.style.height=l.spacerHeight+"px"),u.appendChild(p);return}if(l.type==="separator"){const p=document.createElement("hr");p.style.borderTopColor=l.color,u.appendChild(p);return}if(l.type==="html"){if(l.html){const p=document.createElement("div");p.innerHTML=l.html,u.appendChild(p)}return}if(l.type==="heading"){const p=document.createElement(l.heading||"h2");p.innerHTML=l.headingText||this.out("Your Heading Here!"),u.appendChild(p);return}if(l.type==="paragraph"){const p=document.createElement("p");p.innerHTML=l.paragraphText||this.out("Your paragraph content here!"),u.appendChild(p);return}if(l.type==="media"){if(l.tag==="video"){const p=document.createElement("video");p.style.width="100%",p.style.height="auto",p.controls=!0;var h=document.createElement("source");h.src=l.url,h.type="video/mp4",p.appendChild(h),u.appendChild(p)}else if(l.tag==="audio"){const p=document.createElement("audio");p.controls=!0;let b=document.createElement("source");b.src=l.url,b.type="audio/mp3",p.appendChild(b),u.appendChild(p)}else if(l.tag==="img"){const p=document.createElement("img");p.src=l.url,p.setAttribute("alt",this.out("Output Image")),u.appendChild(p)}return}if(l.type==="image"){const p=document.createElement("img");p.src=l.url,p.setAttribute("alt",this.out("Output Image")),u.appendChild(p);return}if(l.type==="video"){const p=document.createElement("video");p.style.width="100%",p.style.height="auto",p.controls=!0;let b=document.createElement("source");b.src=l.url,b.type="video/mp4",p.appendChild(b),u.appendChild(p);return}if(l.type==="audio"){const p=document.createElement("audio");p.controls=!0;let b=document.createElement("source");b.src=l.url,b.type="audio/mp3",p.appendChild(b),u.appendChild(p);return}}})}if(this.settings.resultSelector&&document.querySelector(this.settings.resultSelector).classList.add("result-wrapper"),this.settings.saveResults&&this.settings.resultSelector&&localStorage.getItem("_results"))try{this.previousResults=JSON.parse(localStorage.getItem("_results"));let s=localStorage.getItem("_results_html");const r=document.querySelector(this.settings.resultSelector);r.innerHTML=s,this.addResultTool(),r.querySelectorAll(".link-download").forEach(a=>{a.addEventListener("click",async d=>{d.preventDefault();const u=d.target.href;try{const l=await fetch(u,{mode:"cors"});if(!l.ok)throw new Error("Failed to fetch the image.");const h=await l.blob(),p=u.substring(u.lastIndexOf("/")+1),b=document.createElement("a");b.href=URL.createObjectURL(h),b.download=p,b.click(),URL.revokeObjectURL(b.href)}catch(l){console.error("Error downloading the image:",l)}})})}catch{}const n=document.querySelector(".formview-container .submit-container");n&&setTimeout(()=>{this.stickyElement(n)},1e3)}abort(){this.controller&&this.controller.abort()}async search(e){let i={"Content-Type":"application/json",...this.settings.headers};try{const t=await fetch(this.settings.searchUrl,{method:"POST",headers:i,body:JSON.stringify({query:e,customData:this.settings.customData})});if(!t.ok)throw new Error("Failed to fetch data");const n=await t.json(),s=n.organic_results?"organic_results":"organic";return(n[s]||[]).map(r=>({title:r.title,link:r.link,snippet:r.snippet||r.description}))}catch(t){return console.error("Error in search:",t.message||t),[]}}async scrapeUrls(e){if(e.length===0)return{data:"",urls:[],failed:[]};this.settings.consoleLog&&console.log(e);let i={"Content-Type":"application/json",...this.settings.headers};const t=await fetch(this.settings.scrapeUrl,{method:"POST",headers:i,body:JSON.stringify({urls:e,customData:this.settings.customData})});if(!t.ok)throw new Error(`Error: ${t.statusText}`);let n="";const s=await t.json();if(this.settings.consoleLog&&console.log(s),s.error)return this.settings.consoleLog&&console.log(s.error),{data:"",urls:[],failed:[]};let r=[],o=[];if(this.settings.scrapeProvider==="firecrawl"&&s.forEach(a=>{if(a.success){const d=a.metadata.title,u=a.markdown,l=a.metadata.url;r.push(l),n+=`
|
|
394
|
+
`,ue.appendChild(pe),pe.addEventListener("click",j=>{const we=pe.closest(".image-item");we&&we.remove(),(bn=>{const mi=new DataTransfer,yn=y.files;Array.from(yn).forEach(bi=>{bi!==bn&&mi.items.add(bi)}),y.files=mi.files})(I);const He=document.querySelector(".formview-container .submit-container");He&&setTimeout(()=>{this.stickyElement(He)},1e3),j.preventDefault(),j.stopImmediatePropagation()}),I.type.startsWith("image/")){const j=new FileReader;j.onload=function(we){let Te=document.createElement("img");Te.className="img-preview",se.appendChild(Te),Te.src=we.target.result},j.readAsDataURL(I)}const K=this.getFormValues();this.settings.onInputChange&&this.settings.onInputChange(K);const ve=document.querySelector(".formview-container .submit-container");ve&&setTimeout(()=>{this.stickyElement(ve)},1e3)}}}if(b==="email"){let g=this.getId();const v=document.createElement("label");if(v.setAttribute("for",`email_label_${g}`),v.className="field-label",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500" aria-hidden="true">*</span>':""),p.appendChild(v),l.fieldNote){const m=document.createElement("div");m.className="field-note",m.innerHTML=l.fieldNote,p.appendChild(m)}const f=document.createElement("input");f.id=`email_label_${g}`,f.type="email",f.name=w,f.className="inp-base",f.placeholder=l.placeholder,l.isRequired&&f.setAttribute("required","required"),p.appendChild(f),f.addEventListener("input",this.inputListener)}if(b==="phone"){let g=this.getId();const v=document.createElement("label");if(v.setAttribute("for",`phone_label_${g}`),v.className="field-label",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500" aria-hidden="true">*</span>':""),p.appendChild(v),l.fieldNote){const m=document.createElement("div");m.className="field-note",m.innerHTML=l.fieldNote,p.appendChild(m)}const f=document.createElement("input");f.id=`phone_label_${g}`,f.type="tel",f.name=w,f.className="inp-base",f.placeholder=l.placeholder,l.isRequired&&f.setAttribute("required","required"),p.appendChild(f),f.addEventListener("input",this.inputListener)}if(b==="url"){let g=this.getId();const v=document.createElement("label");if(v.setAttribute("for",`url_label_${g}`),v.className="field-label",v.innerHTML=l.title+(l.isRequired?' <span class="text-red-500" aria-hidden="true">*</span>':""),p.appendChild(v),l.fieldNote){const m=document.createElement("div");m.className="field-note",m.innerHTML=l.fieldNote,p.appendChild(m)}const f=document.createElement("input");f.id=`url_label_${g}`,f.type="url",f.name=w,f.value=l.value||"",f.className="inp-base",f.placeholder=l.placeholder,l.isRequired&&f.setAttribute("required","required"),p.appendChild(f),f.addEventListener("input",this.inputListener)}if(b==="hidden"){let g=this.getId();const v=document.createElement("label");v.setAttribute("for",`hidden_label_${g}`),v.className="field-label hidden",v.innerText=l.title,p.appendChild(v);const f=document.createElement("input");f.id=`hidden_label_${g}`,f.type="hidden",f.name=w,f.value=l.value,p.appendChild(f)}});const a=r.closest("[data-site-token]");if(a){const l=a.getAttribute("data-site-token"),h=document.createElement("input");h.type="hidden",h.name="form_token",h.value=l,r.appendChild(h)}if(this.settings.isBuilder){const l=document.createElement("div");l.className="submit-container",r.appendChild(l);let h=!0;if("hideReset"in i&&(h=i.hideReset),!h){const _=document.createElement("button");_.className="btn-resetform";const g=i.resetText||this.settings.resetText;_.innerText=g,l.appendChild(_),_.addEventListener("click",f=>{f.preventDefault();const m=_.closest("form");m&&(m.reset(),m.querySelectorAll(".btn-clearfile").forEach(x=>{x.click()}),m.querySelectorAll(".slider-container").forEach(x=>{const S=x.querySelector("input");x.querySelector(".current-value").textContent=S.value}))}),(i.fullWidthButton||!1)&&_.classList.add("w-full")}const p=document.createElement("button");p.className="btn-submitform";const b=i.submitText||this.settings.submitText;p.innerText=b,l.appendChild(p),(i.fullWidthButton||!1)&&p.classList.add("w-full"),this.settings.alwaysVisibleSubmit&&l.classList.add("always-visible"),this.stickyElement(l),r.addEventListener("submit",async _=>{_.preventDefault(),this.steps&&this.steps.length>0&&this.process()})}else{let l="Reference Code:",h="reference_code",p="reference_code";const b=document.createElement("div");b.className="form-field ",b.classList.add(p),r.appendChild(b);let w=this.getId();const _=document.createElement("label");_.setAttribute("for",`short_text_label_${w}`),_.className="field-label",_.innerHTML=l,b.appendChild(_);const g=document.createElement("input");if(g.id=`short_text_label_${w}`,g.type="text",g.name=h,g.autocomplete="off",g.setAttribute("aria-hidden","true"),g.setAttribute("tabindex","-1"),g.className="inp-base",b.appendChild(g),this.settings.captchaContainer){const v=this.settings.captchaContainerClassName,f=document.createElement("div");f.className="captcha-container",v&&f.classList.add(v),r.appendChild(f)}if(i.useSubmitButton){const v=document.createElement("div");v.className="submit-container",r.appendChild(v);let f=!0;if("hideReset"in i&&(f=i.hideReset),!f){const S=document.createElement("button");S.className="btn-resetform";const E=i.resetText||this.settings.resetText;S.innerText=E,v.appendChild(S),S.addEventListener("click",M=>{M.preventDefault();const C=S.closest("form");C&&(C.reset(),C.querySelectorAll(".btn-clearfile").forEach($=>{$.click()}),C.querySelectorAll(".slider-container").forEach($=>{const R=$.querySelector("input");$.querySelector(".current-value").textContent=R.value}))}),(i.fullWidthButton||!1)&&S.classList.add("w-full")}const m=document.createElement("button");m.className="btn-submitform";const y=i.submitText;m.innerText=y,v.appendChild(m),(i.fullWidthButton||!1)&&m.classList.add("w-full"),this.settings.alwaysVisibleSubmit&&v.classList.add("always-visible"),this.stickyElement(v),m.addEventListener("click",async S=>{this.trigger("submit",S)});const x=r.closest("form");x?x.addEventListener("submit",async S=>{this.steps&&this.steps.length>0&&(S.preventDefault(),S.stopImmediatePropagation(),this.process())}):m.addEventListener("click",async S=>{this.steps&&this.steps.length>0&&(S.preventDefault(),this.process())})}}let d,u;this.settings.resultSelector&&(d=document.querySelector(this.settings.resultSelector),d.classList.add("result-wrapper"),d.innerHTML="",u=document.createElement("div"),u.classList.add("result-container"),d.appendChild(u)),i.elements&&d&&i.elements.forEach(l=>{if(l.displayInOutput){if(l.type==="spacer"){const p=document.createElement("div");p.className="form-spacer",l.spacerHeight&&!isNaN(parseFloat(l.spacerHeight))&&(p.style.height=l.spacerHeight+"px"),u.appendChild(p);return}if(l.type==="separator"){const p=document.createElement("hr");p.style.borderTopColor=l.color,u.appendChild(p);return}if(l.type==="html"){if(l.html){const p=document.createElement("div");p.innerHTML=l.html,u.appendChild(p)}return}if(l.type==="heading"){const p=document.createElement(l.heading||"h2");p.innerHTML=l.headingText||this.out("Your Heading Here!"),u.appendChild(p);return}if(l.type==="paragraph"){const p=document.createElement("p");p.innerHTML=l.paragraphText||this.out("Your paragraph content here!"),u.appendChild(p);return}if(l.type==="media"){if(l.tag==="video"){const p=document.createElement("video");p.style.width="100%",p.style.height="auto",p.controls=!0;var h=document.createElement("source");h.src=l.url,h.type="video/mp4",p.appendChild(h),u.appendChild(p)}else if(l.tag==="audio"){const p=document.createElement("audio");p.controls=!0;let b=document.createElement("source");b.src=l.url,b.type="audio/mp3",p.appendChild(b),u.appendChild(p)}else if(l.tag==="img"){const p=document.createElement("img");p.src=l.url,p.setAttribute("alt",this.out("Output Image")),u.appendChild(p)}return}if(l.type==="image"){const p=document.createElement("img");p.src=l.url,p.setAttribute("alt",this.out("Output Image")),u.appendChild(p);return}if(l.type==="video"){const p=document.createElement("video");p.style.width="100%",p.style.height="auto",p.controls=!0;let b=document.createElement("source");b.src=l.url,b.type="video/mp4",p.appendChild(b),u.appendChild(p);return}if(l.type==="audio"){const p=document.createElement("audio");p.controls=!0;let b=document.createElement("source");b.src=l.url,b.type="audio/mp3",p.appendChild(b),u.appendChild(p);return}}})}if(this.settings.resultSelector&&document.querySelector(this.settings.resultSelector).classList.add("result-wrapper"),this.settings.saveResults&&this.settings.resultSelector&&localStorage.getItem("_results"))try{this.previousResults=JSON.parse(localStorage.getItem("_results"));let s=localStorage.getItem("_results_html");const r=document.querySelector(this.settings.resultSelector);r.innerHTML=s,this.addResultTool(),r.querySelectorAll(".link-download").forEach(a=>{a.addEventListener("click",async d=>{d.preventDefault();const u=d.target.href;try{const l=await fetch(u,{mode:"cors"});if(!l.ok)throw new Error("Failed to fetch the image.");const h=await l.blob(),p=u.substring(u.lastIndexOf("/")+1),b=document.createElement("a");b.href=URL.createObjectURL(h),b.download=p,b.click(),URL.revokeObjectURL(b.href)}catch(l){console.error("Error downloading the image:",l)}})})}catch{}const n=document.querySelector(".formview-container .submit-container");n&&setTimeout(()=>{this.stickyElement(n)},1e3)}abort(){this.controller&&this.controller.abort()}async search(e){let i={"Content-Type":"application/json",...this.settings.headers};try{const t=await fetch(this.settings.searchUrl,{method:"POST",headers:i,body:JSON.stringify({query:e,customData:this.settings.customData})});if(!t.ok)throw new Error("Failed to fetch data");const n=await t.json(),s=n.organic_results?"organic_results":"organic";return(n[s]||[]).map(r=>({title:r.title,link:r.link,snippet:r.snippet||r.description}))}catch(t){return console.error("Error in search:",t.message||t),[]}}async scrapeUrls(e){if(e.length===0)return{data:"",urls:[],failed:[]};this.settings.consoleLog&&console.log(e);let i={"Content-Type":"application/json",...this.settings.headers};const t=await fetch(this.settings.scrapeUrl,{method:"POST",headers:i,body:JSON.stringify({urls:e,customData:this.settings.customData})});if(!t.ok)throw new Error(`Error: ${t.statusText}`);let n="";const s=await t.json();if(this.settings.consoleLog&&console.log(s),s.error)return this.settings.consoleLog&&console.log(s.error),{data:"",urls:[],failed:[]};let r=[],o=[];if(this.settings.scrapeProvider==="firecrawl"&&s.forEach(a=>{if(a.success){const d=a.metadata.title,u=a.markdown,l=a.metadata.url;r.push(l),n+=`
|
|
395
395
|
|
|
396
396
|
|
|
397
397
|
## ${d}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@innovastudio/contentbuilder-blocks-runtime",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.25",
|
|
5
5
|
"description": "Runtime libraries for ContentBuilder generated content",
|
|
6
6
|
"main": "dist/contentbuilder-blocks-runtime.esm.js",
|
|
7
7
|
"module": "dist/contentbuilder-blocks-runtime.esm.js",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@glidejs/glide": "^3.7.1",
|
|
33
|
-
"@innovastudio/formviewer": "^1.0.
|
|
33
|
+
"@innovastudio/formviewer": "^1.0.26",
|
|
34
34
|
"glightbox": "^3.3.1"
|
|
35
35
|
}
|
|
36
36
|
}
|