builder-settings-types 0.0.159 → 0.0.161
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.
- package/dist/builder-settings-types.cjs.js +17 -17
- package/dist/builder-settings-types.es.js +134 -92
- package/dist/index.d.ts +4 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let B=(c=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(c|=0));for(;c--;)t+=_[e[c]&63];return t};function S(c){if(c===null||typeof c!="object")return c;if(c instanceof Date)return new Date(c.getTime());if(Array.isArray(c)){const i=[];for(let s=0;s<c.length;s++)i[s]=S(c[s]);return i}const t={};for(const i in c)Object.prototype.hasOwnProperty.call(c,i)&&(t[i]=S(c[i]));const e=Object.getPrototypeOf(c);return e!==Object.prototype&&Object.setPrototypeOf(t,e),t}function j(c){switch(c){case"number":return 0;case"text":return"";case"select":return null;case"color":return"#000000";case"date":return new Date().toISOString().split("T")[0];case"button":return"";default:return""}}class g{constructor(t={}){this.props=t,this.id=t.id||B(),this.value=this.props.default,this.desktop=this.props.default,this.title=t.title||""}destroy(){throw new Error("Method not implemented.")}setOnChange(t){return this.onChange=t,this}setOnBlur(t){return this.onBlur=t,this}setValue(t){this.value=t,this.inputEl&&(this.inputEl.value=String(t)),this.onChange&&this.onChange(t),this.props.detectChange&&this.props.detectChange(t)}clone(){const t=this.constructor,e=S(this.props),i=new t(e);return i.value=S(this.value),i}createInput(t){t={...this.props.inputProps,...t};const e=document.createElement("div");if(e.className=t.wrapperClassName||"",t.title||t.icon){const o=document.createElement("div");if(o.className="icon-container",t.icon){const l=this.createIcon(t.icon,t.iconClassName);o.appendChild(l)}if(t.title){const l=this.createLabel(t.title,t.labelClassName);o.appendChild(l)}e.appendChild(o)}const i=document.createElement("div");i.className=t.wrapperClassName||"";const s=document.createElement("input");this.inputEl=s,s.value=String(t.value||j(t.inputType)),s.type=t.inputType,s.placeholder=t.placeholder||"",s.className=t.inputClassName||"";const n=o=>{const l=o.target;let r=l.value;switch(t.inputType){case"number":r=Number(l.value);break;case"color":r=l.value;break;case"date":r=l.value;break;case"select":r=l.value;break;case"text":r=l.value;break;case"button":r=l.value;break;default:r=l.value}this.value=r,this.onChange&&this.onChange(this.value),this.props.detectChange&&this.props.detectChange(this.value)},a=o=>{o.target,this.onBlur&&this.onBlur(this.value)};return s.addEventListener("input",n),s.addEventListener("change",n),s.addEventListener("blur",a),t.inputCustomizer&&t.inputCustomizer(s),i.appendChild(s),e.appendChild(i),e}createLabel(t,e){const i=document.createElement("span");return i.textContent=t,i.className="input-label "+(e||""),i}createIcon(t,e){const i=document.createElement("span");return i.className="input-icon "+(e||""),i.innerHTML=t,i}}function M(c,t){for(const e in c)if(c.hasOwnProperty(e)){const i=c[e];t(e,i)}}const x=class x{constructor(t){this.elementRef=null,this.isHidden=!1,this.custom=!1,this.initialValues={},this.changeTimeout=null,this.isHandlingChange=!1,this.changeHandlers=new Set,this.blurTimeout=null,this.lastValues={},this.lastChangeTime=0,this.CHANGE_DEBOUNCE=100,this.handleBlur=()=>{},this.pendingBlurHandler=null,this.id=t.id||B(),this.title=t.title,this.settings=t.settings,this.description=t.description,this.icon=t.icon,this.isCollapsed=t.collapsed??!1,this.isMain=t.main??!1,this.custom=t.custom??!1,this.hideCondition=t.hideCondition,this.onBlur=t.onBlur,Object.assign(this,t.settings),this.initialValues=this.getValues()}static hide(){this.hiddenElements.forEach(t=>{t&&(t.style.display="none")})}static show(){this.hiddenElements.forEach(t=>{t&&(t.style.display="")})}setOnChange(t){this.onChange=t;const e=()=>{this.isHandlingChange||(this.isHandlingChange=!0,this.changeTimeout&&clearTimeout(this.changeTimeout),this.changeTimeout=setTimeout(()=>{const i=this.getValues(),s=this.calculateChanges(this.initialValues,i);Object.keys(s).length>0&&(this.lastChangeTime=Date.now(),this.initialValues=i,t(i),this.updateVisibility()),this.isHandlingChange=!1},50))};return this.changeHandlers.clear(),M(this.settings,(i,s)=>{var n;if(s instanceof x)s.setOnChange(a=>{const o=this.getValues();this.initialValues=o,t(o)}),this.changeHandlers.add(()=>t(this.getValues()));else if(s instanceof g){const a=()=>{e()};this.changeHandlers.add(a),s.setOnChange(a)}else{const a=()=>{e()};this.changeHandlers.add(a),(n=s.setOnChange)==null||n.call(s,a)}}),this}setOnBlur(t){return this.onBlur=t,this.pendingBlurHandler=t,this.handleBlur=e=>{(e==null?void 0:e.target)instanceof HTMLElement&&e.target.closest(".setting-group")!==this.elementRef||(this.blurTimeout&&clearTimeout(this.blurTimeout),this.blurTimeout=setTimeout(()=>{t()},100))},this.elementRef&&this.setupBlurHandlers(),this}setupBlurHandlers(){this.elementRef&&this.elementRef.removeEventListener("focusout",this.handleBlur),this.elementRef&&this.elementRef.addEventListener("focusout",this.handleBlur,!0),M(this.settings,(t,e)=>{var i;if(e instanceof x)e.setOnBlur(this.handleBlur);else{const s=(i=this.elementRef)==null?void 0:i.querySelector(`[data-setting-id="${e.id}"]`);s&&s.addEventListener("focusout",this.handleBlur,!0)}})}cleanup(){this.changeTimeout&&(clearTimeout(this.changeTimeout),this.changeTimeout=null),this.blurTimeout&&(clearTimeout(this.blurTimeout),this.blurTimeout=null),this.elementRef&&this.elementRef.removeEventListener("focusout",this.handleBlur),this.changeHandlers.clear()}clone(){const t={};M(this.settings,(s,n)=>{typeof n.clone=="function"?t[s]=n.clone():(console.warn(`Setting with key '${s}' does not have a clone method. Copying reference.`),t[s]=n)});const e={title:this.title,settings:t,description:this.description,icon:this.icon,collapsed:this.isCollapsed,main:this.isMain,custom:this.custom,hideCondition:this.hideCondition},i=R(e);return i.initialValues=this.getValues(),i}setValue(t){if(!t||typeof t!="object")return;Object.entries(t).forEach(([i,s])=>{const n=this.settings[i];n&&(n instanceof x||n instanceof g)&&typeof n.setValue=="function"&&n.setValue(s)});const e=this.getValues();this.initialValues=e,this.onChange&&this.onChange(e)}calculateChanges(t,e){const i={};return new Set([...Object.keys(t),...Object.keys(e)]).forEach(n=>{const a=t[n],o=e[n];JSON.stringify(a)!==JSON.stringify(o)&&(i[n]={from:a,to:o})}),i}hide(){this.elementRef&&(this.elementRef.style.display="none",this.isHidden=!0)}show(){this.elementRef&&(this.elementRef.style.display="",this.isHidden=!1)}getValues(t){if(t===void 0){const e={};for(const i in this.settings)if(this.settings.hasOwnProperty(i)){const s=this.settings[i];s instanceof x?e[i]=s.getValues():e[i]=s.value}return e}else{const e=this.settings[t];return e?e instanceof x?e.getValues():e.value:void 0}}draw(){const t=document.createElement("div");t.className="setting-group",t.id=`setting-group-${this.id}`,x.hiddenElements.add(t),this.hideCondition&&this.hideCondition()&&(t.style.display="none"),this.isMain&&t.classList.add("main-group");const e=document.createElement("div");e.className="setting-group-title",this.isCollapsed&&e.classList.add("collapsed-view"),e.setAttribute("role","button"),e.setAttribute("aria-expanded",(!this.isCollapsed).toString()),e.setAttribute("tabindex","0");const i=document.createElement("div");if(i.className="title-section",this.icon){const h=document.createElement("span");h.className="group-icon",h.innerHTML=this.icon,i.appendChild(h)}this.custom&&t.classList.add("custom_class");const s=document.createElement("h3");s.textContent=this.title,i.appendChild(s);const n=document.createElement("div");if(n.className="actions-section",this.description&&this.isCollapsed){const h=document.createElement("span");h.className="info-marker",h.innerHTML=`
|
|
2
2
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
3
3
|
<path d="M8 5.33333V8M8 10.6667H8.00667M14 8C14 11.3137 11.3137 14 8 14C4.68629 14 2 11.3137 2 8C2 4.68629 4.68629 2 8 2C11.3137 2 14 4.68629 14 8Z"
|
|
4
4
|
stroke="currentColor" stroke-width="1.33333" stroke-linecap="round" stroke-linejoin="round"/>
|
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
<path d="M8 5.33333V8M8 10.6667H8.00667M14 8C14 11.3137 11.3137 14 8 14C4.68629 14 2 11.3137 2 8C2 4.68629 4.68629 2 8 2C11.3137 2 14 4.68629 14 8Z"
|
|
13
13
|
stroke="currentColor" stroke-width="1.33333" stroke-linecap="round" stroke-linejoin="round"/>
|
|
14
14
|
</svg>
|
|
15
|
-
`,d.title=this.description,n.insertBefore(d,a)}}else{if(!h){const d=document.createElement("div");d.className="setting-group-description",d.textContent=this.description,o.insertBefore(d,o.firstChild)}u&&u.remove()}};if(e.onclick=l,e.onkeydown=h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),l())},Object.keys(this.settings).length>0){for(const h in this.settings)if(this.settings.hasOwnProperty(h)){const u=this.settings[h];o.appendChild(u.draw())}}else{const h=document.createElement("div");h.className="setting-group-empty",h.textContent="No settings in this group",o.appendChild(h)}return e.appendChild(i),e.appendChild(n),t.appendChild(e),t.appendChild(o),this.elementRef=t,this.pendingBlurHandler&&(this.setupBlurHandlers(),this.pendingBlurHandler=null),t}collapse(){if(!this.elementRef||this.isCollapsed)return;const t=this.elementRef.querySelector(".setting-group-content"),e=this.elementRef.querySelector(".setting-group-arrow"),i=this.elementRef.querySelector(".setting-group-title");t&&e&&i&&(this.isCollapsed=!0,t.classList.add("collapsed"),e.classList.add("rotated"),i.setAttribute("aria-expanded","false"))}expand(){if(!this.elementRef||!this.isCollapsed)return;const t=this.elementRef.querySelector(".setting-group-content"),e=this.elementRef.querySelector(".setting-group-arrow"),i=this.elementRef.querySelector(".setting-group-title");t&&e&&i&&(this.isCollapsed=!1,t.classList.remove("collapsed"),e.classList.remove("rotated"),i.setAttribute("aria-expanded","true"))}updateVisibility(){this.elementRef&&this.hideCondition&&(this.elementRef.style.display=this.hideCondition()?"none":"")}toggle(){this.isHidden?this.show():this.hide()}getJson(){return JSON.stringify(this.getValues(),null,2)}setJson(t){try{const e=JSON.parse(t);this.
|
|
15
|
+
`,d.title=this.description,n.insertBefore(d,a)}}else{if(!h){const d=document.createElement("div");d.className="setting-group-description",d.textContent=this.description,o.insertBefore(d,o.firstChild)}u&&u.remove()}};if(e.onclick=l,e.onkeydown=h=>{(h.key==="Enter"||h.key===" ")&&(h.preventDefault(),l())},Object.keys(this.settings).length>0){for(const h in this.settings)if(this.settings.hasOwnProperty(h)){const u=this.settings[h];o.appendChild(u.draw())}}else{const h=document.createElement("div");h.className="setting-group-empty",h.textContent="No settings in this group",o.appendChild(h)}return e.appendChild(i),e.appendChild(n),t.appendChild(e),t.appendChild(o),this.elementRef=t,this.pendingBlurHandler&&(this.setupBlurHandlers(),this.pendingBlurHandler=null),t}collapse(){if(!this.elementRef||this.isCollapsed)return;const t=this.elementRef.querySelector(".setting-group-content"),e=this.elementRef.querySelector(".setting-group-arrow"),i=this.elementRef.querySelector(".setting-group-title");t&&e&&i&&(this.isCollapsed=!0,t.classList.add("collapsed"),e.classList.add("rotated"),i.setAttribute("aria-expanded","false"))}expand(){if(!this.elementRef||!this.isCollapsed)return;const t=this.elementRef.querySelector(".setting-group-content"),e=this.elementRef.querySelector(".setting-group-arrow"),i=this.elementRef.querySelector(".setting-group-title");t&&e&&i&&(this.isCollapsed=!1,t.classList.remove("collapsed"),e.classList.remove("rotated"),i.setAttribute("aria-expanded","true"))}updateVisibility(){this.elementRef&&this.hideCondition&&(this.elementRef.style.display=this.hideCondition()?"none":"")}toggle(){this.isHidden?this.show():this.hide()}getJson(){return JSON.stringify(this.getValues(),null,2)}setJson(t){try{const e=JSON.parse(t);let i=e;const s=Object.keys(this.settings),n=Object.keys(e);if(!s.some(o=>n.includes(o))&&n.length===1){const o=n[0];i=e[o]}this.setValue(i)}catch(e){throw console.error("Invalid JSON provided to setJson:",e),new Error("Invalid JSON format")}}};x.hiddenElements=new Set;let m=x;function R(c){return new m(c)}function G(c){return c}class T extends g{constructor(t={}){super(t),this.inputType="text",t.onChange&&this.setOnChange(t.onChange)}draw(){const t=e=>{this.props.maxLength!==void 0&&(e.maxLength=this.props.maxLength),this.props.className&&e.classList.add(this.props.className)};return this.createInput({value:this.value,inputType:this.inputType,title:this.props.title,placeholder:this.props.placeholder,icon:this.props.icon,inputClassName:"string-setting-input "+(this.props.inputClassName||""),wrapperClassName:"string-setting-wrapper "+(this.props.wrapperClassName||""),inputCustomizer:t})}}const I="<svg xmlns='http://www.w3.org/2000/svg' width='18' height='19' viewBox='0 0 18 19' fill='none'><path d='M8.99999 15.8542C9.79613 16.5667 10.8475 17 12 17C14.4853 17 16.5 14.9853 16.5 12.5C16.5 10.4248 15.0953 8.67769 13.1849 8.15763M4.81513 8.15762C2.9047 8.67768 1.5 10.4248 1.5 12.5C1.5 14.9853 3.51472 17 6 17C8.48528 17 10.5 14.9853 10.5 12.5C10.5 11.9146 10.3882 11.3554 10.1849 10.8424M13.5 6.5C13.5 8.98528 11.4853 11 9 11C6.51472 11 4.5 8.98528 4.5 6.5C4.5 4.01472 6.51472 2 9 2C11.4853 2 13.5 4.01472 13.5 6.5Z' stroke='#667085' stroke-linecap='round' stroke-linejoin='round'/></svg>";class k extends T{constructor(t){super({...t,icon:t.icon||I,title:t.title||"Color",default:t.default?k.normalizeRgbValue(t.default):t.default}),this.inputType="color",this.element=null,this.detectChange=t.detectChange}static normalizeRgbValue(t){const e=t.split(",").map(r=>parseInt(r.trim()));if(e.length!==3||e.some(isNaN))return console.warn(`Invalid RGB value "${t}", using default "0, 0, 0"`),"0, 0, 0";const[i,s,n]=e,a=Math.max(0,Math.min(255,i)),o=Math.max(0,Math.min(255,s)),l=Math.max(0,Math.min(255,n));return`${a}, ${o}, ${l}`}setValue(t){if(t===void 0){super.setValue("");return}if(typeof t=="string"){const e=k.normalizeRgbValue(t);super.setValue(e)}else super.setValue("")}hexToRgb(t){t=t.replace("#","");const e=parseInt(t.substring(0,2),16),i=parseInt(t.substring(2,4),16),s=parseInt(t.substring(4,6),16);return`${e}, ${i}, ${s}`}rgbToHex(t){const e=t.split(",").map(h=>parseInt(h.trim()));if(e.length!==3||e.some(isNaN))return"#000000";const[i,s,n]=e,a=Math.max(0,Math.min(255,i)),o=Math.max(0,Math.min(255,s)),l=Math.max(0,Math.min(255,n)),r=h=>{const u=h.toString(16);return u.length===1?"0"+u:u};return`#${r(a)}${r(o)}${r(l)}`}draw(){const t=document.createElement("div");t.className="color-setting-wrapper",this.element=t;const e=document.createElement("div");e.className="icon-container";const i=this.createIcon(this.props.icon||I),s=this.createLabel(this.title||"Color");e.appendChild(i),e.appendChild(s);const n=document.createElement("div");n.className="color-input-wrapper";const a=d=>{const f=d.value.trim();if(!f)return d.style.border="",!0;const p=f.split(",").map(w=>parseInt(w.trim()));if(p.length!==3||p.some(isNaN))return d.style.border="1px solid red",!1;const[C,v,H]=p,E=C>=0&&C<=255&&v>=0&&v<=255&&H>=0&&H<=255;return d.style.border=E?"":"1px solid red",E},o=document.createElement("div");o.className="color-preview",o.style.backgroundColor=this.value?`rgb(${this.value})`:"";const l=this.createInput({value:this.value,inputType:"text",inputClassName:"color-text-input"}),r=l.querySelector("input");r.readOnly=!0;const h=this.createInput({value:this.value?this.rgbToHex(this.value):"#000000",inputType:this.inputType,inputClassName:"color-picker"}),u=h.querySelector("input");return r.oninput=d=>{var p;let f=d.target.value.trim();a(r)&&(this.value=f,(p=this.onChange)==null||p.call(this,f),u.value=this.rgbToHex(f),o.style.backgroundColor=`rgb(${f})`)},u.oninput=d=>{var C,v;const f=d.target.value,p=this.hexToRgb(f);this.value=p,(C=this.onChange)==null||C.call(this,p),(v=this.detectChange)==null||v.call(this,p),r.value=p,o.style.backgroundColor=`rgb(${p})`},u.onchange=d=>{var C,v;const f=d.target.value,p=this.hexToRgb(f);this.value=p,(C=this.onChange)==null||C.call(this,p),(v=this.detectChange)==null||v.call(this,p),r.value=p,o.style.backgroundColor=`rgb(${p})`},n.appendChild(o),n.appendChild(h),n.appendChild(l),t.appendChild(e),t.appendChild(n),this.value&&(r.value=this.value,u.value=this.rgbToHex(this.value),o.style.backgroundColor=`rgb(${this.value})`),t}getElement(){return this.element}getNormalizedValue(){return this.value?k.normalizeRgbValue(this.value):"0, 0, 0"}isValidRgb(){if(!this.value)return!1;const t=this.value.split(",").map(n=>parseInt(n.trim()));if(t.length!==3||t.some(isNaN))return!1;const[e,i,s]=t;return e>=0&&e<=255&&i>=0&&i<=255&&s>=0&&s<=255}}class b extends g{constructor(t){super(t),this.inputType="number",this.inputElement=null,this.mobileValue=t.mobile,this.validateProps(),this.value=this.validateValue(this.value)}draw(){const t=s=>{this.props.minValue!==void 0&&(s.min=String(this.props.minValue)),this.props.maxValue!==void 0&&(s.max=String(this.props.maxValue)),this.props.className&&s.classList.add(this.props.className),s.addEventListener("input",()=>{const n=this.props.minValue??Number.MIN_SAFE_INTEGER,a=this.props.maxValue??Number.MAX_SAFE_INTEGER;let o=Number(s.value);o<n&&(o=n),o>a&&(o=a),String(o)!==s.value&&(s.value=String(o)),this.setValue(o)}),s.addEventListener("blur",()=>{var a,o;const n=this.validateValue(Number(s.value));n!==Number(s.value)&&(s.value=String(n),this.setValue(n)),(o=(a=this.props).onBlur)==null||o.call(a)})},e=this.createInput({value:this.value,inputType:this.inputType,title:this.props.title,icon:this.props.icon,inputClassName:"number-setting-input "+(this.props.inputClassName||""),wrapperClassName:"number-setting-wrapper "+(this.props.wrapperClassName||""),inputCustomizer:t});if(this.inputElement=e.querySelector("input.number-setting-input"),!this.props.suffix||this.props.suffix==="none")return e;e.classList.add("suffix-wrapper"),this.inputElement&&(this.inputElement.style.paddingRight="35px");const i=document.createElement("span");return i.className="suffix-label",i.textContent=this.props.suffix,e.appendChild(i),e}setValue(t){const e=this.validateValue(t);super.setValue(e),this.inputElement&&this.inputElement.value!==String(e)&&(this.inputElement.value=String(e??""))}validateValue(t){(t==null||isNaN(t))&&(t=this.props.default??0);const e=this.props.minValue??Number.MIN_SAFE_INTEGER,i=this.props.maxValue??Number.MAX_SAFE_INTEGER;let s=Number(t);return s<e&&(s=e),s>i&&(s=i),s}getMobileValue(){return this.mobileValue}setMobileValue(t){this.mobileValue=t}validateProps(){this.props.minValue!==void 0&&(this.props.default??0)<this.props.minValue&&console.warn(`Default value ${this.props.default} is less than minValue ${this.props.minValue}`),this.props.maxValue!==void 0&&(this.props.default??0)>this.props.maxValue&&console.warn(`Default value ${this.props.default} is greater than maxValue ${this.props.maxValue}`)}}const W=`
|
|
16
16
|
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
17
17
|
<path d="M9 17C13.4183 17 17 13.4183 17 9C17 4.58172 13.4183 1 9 1C4.58172 1 1 4.58172 1 9C1 13.4183 4.58172 17 9 17Z" stroke="#667085" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
18
18
|
<path d="M9 1V17C4.58172 17 1 13.4183 1 9C1 4.58172 4.58172 1 9 1Z" fill="#667085" stroke="#667085" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
19
|
-
</svg>`;class
|
|
19
|
+
</svg>`;class y extends b{constructor(t={}){const e={title:"Opacity",suffix:"%",minValue:0,maxValue:100,step:1,default:t.default??100,icon:W,...t};super(e),this.inputType="number",this.mobileValue=t.mobile}getMobileValue(){return this.mobileValue}}const q=`
|
|
20
20
|
<svg xmlns="http://www.w3.org/2000/svg" class="svg-select" 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">
|
|
21
21
|
<polyline points="6 9 12 15 18 9"></polyline>
|
|
22
22
|
</svg>
|
|
@@ -41,15 +41,15 @@
|
|
|
41
41
|
<path d="M13.5 15C14.1989 15 14.5484 15 14.824 14.8858C15.1916 14.7336 15.4836 14.4416 15.6358 14.074C15.75 13.7984 15.75 13.4489 15.75 12.75C15.75 12.0511 15.75 11.7016 15.6358 11.426C15.4836 11.0584 15.1916 10.7664 14.824 10.6142C14.5484 10.5 14.1989 10.5 13.5 10.5H4.5C3.80109 10.5 3.45163 10.5 3.17598 10.6142C2.80843 10.7664 2.51642 11.0584 2.36418 11.426C2.25 11.7016 2.25 12.0511 2.25 12.75C2.25 13.4489 2.25 13.7984 2.36418 14.074C2.51642 14.4416 2.80843 14.7336 3.17597 14.8858C3.45163 15 3.80109 15 4.5 15L13.5 15Z"
|
|
42
42
|
stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
|
|
43
43
|
</svg>
|
|
44
|
-
`}].forEach(n=>{const a=document.createElement("button");a.className="align-option-button",a.innerHTML=n.icon,this.value===n.name&&a.classList.add("selected"),a.addEventListener("click",()=>{var o;i.querySelectorAll(".align-option-button").forEach(l=>l.classList.remove("selected")),a.classList.add("selected"),this.value=n.name,(o=this.onChange)==null||o.call(this,this.value)}),i.appendChild(a)}),t.appendChild(i),t}}class D extends g{constructor(t){super(t),this.inputType="button"}draw(){const t=document.createElement("button");t.className="button-setting "+(this.props.className||""),t.textContent=this.props.label,t.addEventListener("click",()=>{this.props.onClick&&this.props.onClick()});const e=document.createElement("div");return e.className="button-setting-wrapper "+(this.props.wrapperClassName||""),e.appendChild(t),e}}class
|
|
44
|
+
`}].forEach(n=>{const a=document.createElement("button");a.className="align-option-button",a.innerHTML=n.icon,this.value===n.name&&a.classList.add("selected"),a.addEventListener("click",()=>{var o;i.querySelectorAll(".align-option-button").forEach(l=>l.classList.remove("selected")),a.classList.add("selected"),this.value=n.name,(o=this.onChange)==null||o.call(this,this.value)}),i.appendChild(a)}),t.appendChild(i),t}}class D extends g{constructor(t){super(t),this.inputType="button"}draw(){const t=document.createElement("button");t.className="button-setting "+(this.props.className||""),t.textContent=this.props.label,t.addEventListener("click",()=>{this.props.onClick&&this.props.onClick()});const e=document.createElement("div");return e.className="button-setting-wrapper "+(this.props.wrapperClassName||""),e.appendChild(t),e}}class z extends g{constructor(t={}){super(t),this.inputType={width:"number",height:"number"},this.aspectRatio=1,this.isUpdating=!1;const e=t.width||0,i=t.height||0;this.value||(this.value={width:e,height:i}),this.minWidth=t.minWidth??0,this.maxWidth=t.maxWidth,this.minHeight=t.minHeight??0,this.maxHeight=t.maxHeight,this.locked=t.locked??!1,this.value.height>0&&(this.aspectRatio=this.value.width/this.value.height),this.widthSetting=new b({title:"Width",default:this.value.width,suffix:"px",minValue:this.minWidth,maxValue:this.maxWidth,icon:F}),this.heightSetting=new b({title:"Height",default:this.value.height,suffix:"px",minValue:this.minHeight,maxValue:this.maxHeight,icon:U}),this.widthSetting.setOnChange(this.handleWidthChange.bind(this)),this.heightSetting.setOnChange(this.handleHeightChange.bind(this))}handleWidthChange(t){if(!this.isUpdating&&!isNaN(t)){this.maxWidth&&t>this.maxWidth&&(t=this.maxWidth),this.isUpdating=!0;try{let e=t,i=this.value.height;this.locked&&this.aspectRatio>0&&(i=Math.round(e/this.aspectRatio),this.maxHeight&&i>this.maxHeight&&(i=this.maxHeight,e=Math.round(i*this.aspectRatio),this.maxWidth&&e>this.maxWidth&&(e=this.maxWidth,i>0&&(this.aspectRatio=e/i)))),this.value={width:e,height:i},this.widthSetting.setValue(e),this.locked&&this.heightSetting.setValue(i),this.onChange&&this.onChange(this.value)}finally{this.isUpdating=!1}}}handleHeightChange(t){if(!this.isUpdating&&!isNaN(t)){this.maxHeight&&t>this.maxHeight&&(t=this.maxHeight),this.isUpdating=!0;try{let e=t,i=this.value.width;this.locked&&this.aspectRatio>0&&(i=Math.round(e*this.aspectRatio),this.maxWidth&&i>this.maxWidth&&(i=this.maxWidth,e=Math.round(i/this.aspectRatio),this.maxHeight&&e>this.maxHeight&&(e=this.maxHeight,e>0&&(this.aspectRatio=i/e)))),this.value={width:i,height:e},this.locked&&this.widthSetting.setValue(i),this.heightSetting.setValue(e),this.onChange&&this.onChange(this.value)}finally{this.isUpdating=!1}}}toggleLock(t){if(this.locked=!this.locked,this.locked&&this.value){const{width:i,height:s}=this.value;s>0&&(this.aspectRatio=i/s)}t.innerHTML=this.getLockSVG(this.locked),t.setAttribute("aria-pressed",String(this.locked)),t.title=this.locked?"Unlock aspect ratio":"Lock aspect ratio";const e=t.closest(".dimension-setting-container");e&&(this.locked?e.classList.add("aspect-locked"):e.classList.remove("aspect-locked"))}getLockSVG(t){return t?`
|
|
45
45
|
<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 10 10" fill="none">
|
|
46
46
|
<path d="M2.91663 4.58333V3.33333C2.91663 2.18274 3.84937 1.25 4.99996 1.25C6.00786 1.25 6.84859 1.96573 7.04162 2.91667M3.66663 8.75H6.33329C7.03336 8.75 7.38339 8.75 7.65078 8.61376C7.88598 8.49392 8.07721 8.30269 8.19705 8.06749C8.33329 7.8001 8.33329 7.45007 8.33329 6.75V6.58333C8.33329 5.88327 8.33329 5.53323 8.19705 5.26584C8.07721 5.03064 7.88598 4.83942 7.65078 4.71958C7.38339 4.58333 7.03336 4.58333 6.33329 4.58333H3.66663C2.96656 4.58333 2.61653 4.58333 2.34914 4.71958C2.11394 4.83942 1.92271 5.03064 1.80287 5.26584C1.66663 5.53323 1.66663 5.88327 1.66663 6.58333V6.75C1.66663 7.45007 1.66663 7.8001 1.80287 8.06749C1.92271 8.30269 2.11394 8.49392 2.34914 8.61376C2.61653 8.75 2.96656 8.75 3.66663 8.75Z" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
|
|
47
47
|
</svg>`:`
|
|
48
48
|
<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 10 10" fill="none">
|
|
49
49
|
<path d="M2.91663 4.58333V3.33333C2.91663 2.18274 3.84937 1.25 4.99996 1.25M3.66663 8.75H6.33329C7.03336 8.75 7.38339 8.75 7.65078 8.61376C7.88598 8.49392 8.07721 8.30269 8.19705 8.06749C8.33329 7.8001 8.33329 7.45007 8.33329 6.75V6.58333C8.33329 5.88327 8.33329 5.53323 8.19705 5.26584C8.07721 5.03064 7.88598 4.83942 7.65078 4.71958C7.38339 4.58333 7.03336 4.58333 6.33329 4.58333H3.66663C2.96656 4.58333 2.61653 4.58333 2.34914 4.71958C2.11394 4.83942 1.92271 5.03064 1.80287 5.26584C1.66663 5.53323 1.66663 5.88327 1.66663 6.58333V6.75C1.66663 7.45007 1.66663 7.8001 1.80287 8.06749C1.92271 8.30269 2.11394 8.49392 2.34914 8.61376C2.61653 8.75 2.96656 8.75 3.66663 8.75Z" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
|
|
50
|
-
</svg>`}setValue(t){if(t&&typeof t.width=="number"&&typeof t.height=="number"){let e=Math.max(this.minWidth,t.width);this.maxWidth&&(e=Math.min(this.maxWidth,e));let i=Math.max(this.minHeight,t.height);this.maxHeight&&(i=Math.min(this.maxHeight,i)),this.value={width:e,height:i},this.locked&&this.value.height>0&&(this.aspectRatio=this.value.width/this.value.height),this.isUpdating=!0;try{this.widthSetting.setValue(this.value.width),this.heightSetting.setValue(this.value.height)}finally{this.isUpdating=!1}}}draw(){const t=document.createElement("div");t.className="dimension-setting-container",this.locked&&t.classList.add("aspect-locked");const e=this.widthSetting.draw(),i=this.heightSetting.draw(),s=document.createElement("div");s.className="dimension-bracket";const n=document.createElement("button");return n.className="dimension-lock-icon",n.setAttribute("type","button"),n.setAttribute("aria-pressed",String(this.locked)),n.setAttribute("aria-label",this.locked?"Unlock aspect ratio":"Lock aspect ratio"),n.title=this.locked?"Unlock aspect ratio":"Lock aspect ratio",n.innerHTML=this.getLockSVG(this.locked),n.onclick=a=>{a.preventDefault(),this.toggleLock(n)},s.appendChild(n),t.appendChild(e),t.appendChild(s),t.appendChild(i),t}isLocked(){return this.locked}setLocked(t){if(this.locked!==t){if(this.locked=t,this.locked&&this.value){const{width:i,height:s}=this.value;s>0&&(this.aspectRatio=i/s)}const e=document.querySelector(".dimension-setting-container .dimension-lock-icon");if(e instanceof HTMLElement){e.innerHTML=this.getLockSVG(this.locked),e.setAttribute("aria-pressed",String(this.locked)),e.title=this.locked?"Unlock aspect ratio":"Lock aspect ratio";const i=e.closest(".dimension-setting-container");i&&(this.locked?i.classList.add("aspect-locked"):i.classList.remove("aspect-locked"))}}}}const
|
|
50
|
+
</svg>`}setValue(t){if(t&&typeof t.width=="number"&&typeof t.height=="number"){let e=Math.max(this.minWidth,t.width);this.maxWidth&&(e=Math.min(this.maxWidth,e));let i=Math.max(this.minHeight,t.height);this.maxHeight&&(i=Math.min(this.maxHeight,i)),this.value={width:e,height:i},this.locked&&this.value.height>0&&(this.aspectRatio=this.value.width/this.value.height),this.isUpdating=!0;try{this.widthSetting.setValue(this.value.width),this.heightSetting.setValue(this.value.height)}finally{this.isUpdating=!1}}}draw(){const t=document.createElement("div");t.className="dimension-setting-container",this.locked&&t.classList.add("aspect-locked");const e=this.widthSetting.draw(),i=this.heightSetting.draw(),s=document.createElement("div");s.className="dimension-bracket";const n=document.createElement("button");return n.className="dimension-lock-icon",n.setAttribute("type","button"),n.setAttribute("aria-pressed",String(this.locked)),n.setAttribute("aria-label",this.locked?"Unlock aspect ratio":"Lock aspect ratio"),n.title=this.locked?"Unlock aspect ratio":"Lock aspect ratio",n.innerHTML=this.getLockSVG(this.locked),n.onclick=a=>{a.preventDefault(),this.toggleLock(n)},s.appendChild(n),t.appendChild(e),t.appendChild(s),t.appendChild(i),t}isLocked(){return this.locked}setLocked(t){if(this.locked!==t){if(this.locked=t,this.locked&&this.value){const{width:i,height:s}=this.value;s>0&&(this.aspectRatio=i/s)}const e=document.querySelector(".dimension-setting-container .dimension-lock-icon");if(e instanceof HTMLElement){e.innerHTML=this.getLockSVG(this.locked),e.setAttribute("aria-pressed",String(this.locked)),e.title=this.locked?"Unlock aspect ratio":"Lock aspect ratio";const i=e.closest(".dimension-setting-container");i&&(this.locked?i.classList.add("aspect-locked"):i.classList.remove("aspect-locked"))}}}}const F=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
51
51
|
<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="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
|
|
52
|
-
</svg>`,
|
|
52
|
+
</svg>`,U=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
53
53
|
<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="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
|
|
54
54
|
</svg>`,O=`
|
|
55
55
|
<svg xmlns="http://www.w3.org/2000/svg" width="15" height="16" viewBox="0 0 15 16" fill="none">
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 12 12" fill="none">
|
|
65
65
|
<path d="M8 3V2.6C8 2.03995 8 1.75992 7.89101 1.54601C7.79513 1.35785 7.64215 1.20487 7.45399 1.10899C7.24008 1 6.96005 1 6.4 1H5.6C5.03995 1 4.75992 1 4.54601 1.10899C4.35785 1.20487 4.20487 1.35785 4.10899 1.54601C4 1.75992 4 2.03995 4 2.6V3M5 5.75V8.25M7 5.75V8.25M1.5 3H10.5M9.5 3V8.6C9.5 9.44008 9.5 9.86012 9.33651 10.181C9.1927 10.4632 8.96323 10.6927 8.68099 10.8365C8.36012 11 7.94008 11 7.1 11H4.9C4.05992 11 3.63988 11 3.31901 10.8365C3.03677 10.6927 2.8073 10.4632 2.66349 10.181C2.5 9.86012 2.5 9.44008 2.5 8.6V3" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
|
|
66
66
|
</svg>
|
|
67
|
-
`;class
|
|
67
|
+
`;class $ extends g{constructor(t={}){super(t),this.inputType="button",this.previewWrapper=null,this.previewEl=null,this.emptyStateEl=null,this.props.delete===void 0&&(this.props.delete=!0),!this.value&&t.defaultUrl&&t.defaultUrl!==""&&(this.value=t.defaultUrl)}updatePreviewState(t=null){if(!this.previewWrapper||!this.previewEl)return;const e=this.previewWrapper.parentElement,i=e==null?void 0:e.querySelector(".upload-button"),s=e==null?void 0:e.querySelector(".preview-placeholder");t&&t!==""?(this.previewWrapper.classList.add("has-image"),this.previewEl.src=t,this.previewWrapper.style.display="block",this.previewEl.style.display="block",s&&s instanceof HTMLElement&&(s.style.display="none"),e&&e.classList.remove("no-image"),i&&(i.innerHTML=`
|
|
68
68
|
<span class="upload-icon">${O}</span>
|
|
69
69
|
<span class="upload-label">Replace</span>
|
|
70
70
|
`)):(this.previewWrapper.classList.remove("has-image"),this.previewEl.src="",this.previewEl.style.display="none",this.previewWrapper.style.display="none",s&&s instanceof HTMLElement&&(s.style.display="block"),e&&e.classList.add("no-image"),i&&(i.innerHTML=`
|
|
@@ -73,15 +73,15 @@
|
|
|
73
73
|
`))}draw(){const t=document.createElement("div");t.className="upload-setting-wrapper",t.setAttribute("data-setting-id",this.id),t.addEventListener("focusout",l=>{var r;l.relatedTarget&&t.contains(l.relatedTarget)||(r=this.onBlur)==null||r.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 r=this.createIcon(this.props.icon);l.appendChild(r)}if(this.props.title){const r=this.createLabel(this.props.title);l.appendChild(r)}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=P,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=J,this.previewWrapper.appendChild(l),l.onclick=r=>{var h;r.stopPropagation(),this.value="",o.value="",this.updatePreviewState(null),(h=this.onChange)==null||h.call(this,"")}}this.previewWrapper.appendChild(this.previewEl);const a=document.createElement("button");a.className="upload-button",a.innerHTML=`
|
|
74
74
|
<span class="upload-icon">${O}</span>
|
|
75
75
|
<span class="upload-label">Upload</span>
|
|
76
|
-
`;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 r,h,u;const l=(r=o.files)==null?void 0:r[0];if(l)try{a.classList.add("loading"),a.disabled=!0;const d=new FormData,f=this.props.formFieldName||"file";d.append(f,l,l.name);const p=this.props.uploadUrl;if(!p)throw new Error("No uploadUrl provided to UploadSetting.");const C=this.props.requestMethod||"POST",v={...this.props.requestHeaders||{}},
|
|
76
|
+
`;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 r,h,u;const l=(r=o.files)==null?void 0:r[0];if(l)try{a.classList.add("loading"),a.disabled=!0;const d=new FormData,f=this.props.formFieldName||"file";d.append(f,l,l.name);const p=this.props.uploadUrl;if(!p)throw new Error("No uploadUrl provided to UploadSetting.");const C=this.props.requestMethod||"POST",v={...this.props.requestHeaders||{}},E=await(await fetch(p,{method:C,body:d,headers:v})).json();console.log("Upload response:",E);let w;if(this.props.parseResponse)w=this.props.parseResponse(E);else if(w=(h=E==null?void 0:E.data)==null?void 0:h.url,!w)throw new Error("No URL found in response. Provide a parseResponse if needed.");console.log("Final URL:",w),this.value=w,this.updatePreviewState(w),(u=this.onChange)==null||u.call(this,w)}catch(d){console.error("Error uploading file:",d)}finally{a.classList.remove("loading"),a.disabled=!1,o.value=""}else o.value=""},t}}class Z extends b{constructor(t={}){const e={title:t.title||"Height",suffix:"px",minValue:t.minValue??0,maxValue:t.maxValue,icon:t.icon||X,...t};super(e),this.inputType="number",this.mobileValue=t.mobile}getMobileValue(){return this.mobileValue}}const X=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
77
77
|
<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"/>
|
|
78
|
-
</svg>`;class
|
|
78
|
+
</svg>`;class K extends b{constructor(t={}){super({title:t.title||"Width",suffix:"px",minValue:t.minValue??0,maxValue:t.maxValue,icon:t.icon||Q,...t}),this.inputType="number",this.mobileValue=t.mobile}getMobileValue(){return this.mobileValue}}const Q=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
79
79
|
<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"/>
|
|
80
|
-
</svg>`,
|
|
80
|
+
</svg>`,Y=`
|
|
81
81
|
<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">
|
|
82
82
|
<polyline points="6 9 12 15 18 9"></polyline>
|
|
83
83
|
</svg>
|
|
84
|
-
`;class tt extends g{constructor(t={}){if(super(t),this.inputType="select",this._options=[],this.isOpen=!1,this.selectedOptionIndex=null,this.optionsListEl=null,this.svgContainer=null,this.buttonEl=null,this.isLoading=!1,this.container=null,this.hasInitializedOptions=!1,this.selectedOptionIndex=null,t.default!==void 0&&(this.value=t.default),this.initializeOptions(t),!t.getOptionsAsync&&this.value!==void 0){const e=this._options.findIndex(i=>JSON.stringify(i.value)===JSON.stringify(this.value));e!==-1&&(this.selectedOptionIndex=e)}t.onChange&&this.setOnChange(t.onChange),t.detectChange&&(this.detectChangeCallback=t.detectChange)}initializeOptions(t){this.hasInitializedOptions&&!t.getOptionsAsync||(this._options=[],t.options&&(this._options=[...t.options]),t.getOptions&&this._options.push(...t.getOptions()),t.getOptionsAsync?this.isLoading=!0:this.hasInitializedOptions=!0)}createOption(t,e){const i=document.createElement("li");i.classList.add("select-api-option"),i.textContent=t.name,i.dataset.index=String(e);const s=document.createElement("input");return s.type="radio",s.classList.add("select-api-radio"),s.name="select-api-radio-group",i.appendChild(s),this.selectedOptionIndex===e&&(s.checked=!0),i}draw(){const t=document.createElement("div");t.classList.add("select-api-container"),this.container=t;const e=document.createElement("div");if(e.classList.add("select-api-button"),this.props.title){e.classList.add("has-label");const n=document.createElement("div");n.className="select-label",n.textContent=this.props.title,e.appendChild(n);const a=document.createElement("span");if(a.className="select-value",this.isLoading)a.textContent=this.props.loadingText||"Loading options...";else{const o=this.selectedOptionIndex!==null&&this._options&&this.selectedOptionIndex>=0&&this.selectedOptionIndex<this._options.length?this._options[this.selectedOptionIndex]:null,l=o&&typeof o.name=="string"?o.name:"Select an option";a.textContent=l}e.appendChild(a)}else{const n=document.createElement("span");if(this.isLoading)n.textContent=this.props.loadingText||"Loading options...";else{const a=this.selectedOptionIndex!==null&&this._options&&this.selectedOptionIndex>=0&&this.selectedOptionIndex<this._options.length?this._options[this.selectedOptionIndex]:null,o=a&&typeof a.name=="string"?a.name:"Select an option";n.textContent=o}e.appendChild(n)}e.onclick=()=>{var n,a;this.isLoading||(this.isOpen=!this.isOpen,(n=this.optionsListEl)==null||n.classList.toggle("open",this.isOpen),(a=this.svgContainer)==null||a.classList.toggle("open",this.isOpen))},t.appendChild(e),this.buttonEl=e;const i=document.createElement("ul");i.classList.add("select-api-options"),this._options.forEach((n,a)=>{const o=this.createOption(n,a);o.onclick=l=>this.selectApiOption(l,a,e),i.appendChild(o)}),t.appendChild(i);const s=document.createElement("div");return s.classList.add("svg-container"),s.innerHTML=
|
|
84
|
+
`;class tt extends g{constructor(t={}){if(super(t),this.inputType="select",this._options=[],this.isOpen=!1,this.selectedOptionIndex=null,this.optionsListEl=null,this.svgContainer=null,this.buttonEl=null,this.isLoading=!1,this.container=null,this.hasInitializedOptions=!1,this.selectedOptionIndex=null,t.default!==void 0&&(this.value=t.default),this.initializeOptions(t),!t.getOptionsAsync&&this.value!==void 0){const e=this._options.findIndex(i=>JSON.stringify(i.value)===JSON.stringify(this.value));e!==-1&&(this.selectedOptionIndex=e)}t.onChange&&this.setOnChange(t.onChange),t.detectChange&&(this.detectChangeCallback=t.detectChange)}initializeOptions(t){this.hasInitializedOptions&&!t.getOptionsAsync||(this._options=[],t.options&&(this._options=[...t.options]),t.getOptions&&this._options.push(...t.getOptions()),t.getOptionsAsync?this.isLoading=!0:this.hasInitializedOptions=!0)}createOption(t,e){const i=document.createElement("li");i.classList.add("select-api-option"),i.textContent=t.name,i.dataset.index=String(e);const s=document.createElement("input");return s.type="radio",s.classList.add("select-api-radio"),s.name="select-api-radio-group",i.appendChild(s),this.selectedOptionIndex===e&&(s.checked=!0),i}draw(){const t=document.createElement("div");t.classList.add("select-api-container"),this.container=t;const e=document.createElement("div");if(e.classList.add("select-api-button"),this.props.title){e.classList.add("has-label");const n=document.createElement("div");n.className="select-label",n.textContent=this.props.title,e.appendChild(n);const a=document.createElement("span");if(a.className="select-value",this.isLoading)a.textContent=this.props.loadingText||"Loading options...";else{const o=this.selectedOptionIndex!==null&&this._options&&this.selectedOptionIndex>=0&&this.selectedOptionIndex<this._options.length?this._options[this.selectedOptionIndex]:null,l=o&&typeof o.name=="string"?o.name:"Select an option";a.textContent=l}e.appendChild(a)}else{const n=document.createElement("span");if(this.isLoading)n.textContent=this.props.loadingText||"Loading options...";else{const a=this.selectedOptionIndex!==null&&this._options&&this.selectedOptionIndex>=0&&this.selectedOptionIndex<this._options.length?this._options[this.selectedOptionIndex]:null,o=a&&typeof a.name=="string"?a.name:"Select an option";n.textContent=o}e.appendChild(n)}e.onclick=()=>{var n,a;this.isLoading||(this.isOpen=!this.isOpen,(n=this.optionsListEl)==null||n.classList.toggle("open",this.isOpen),(a=this.svgContainer)==null||a.classList.toggle("open",this.isOpen))},t.appendChild(e),this.buttonEl=e;const i=document.createElement("ul");i.classList.add("select-api-options"),this._options.forEach((n,a)=>{const o=this.createOption(n,a);o.onclick=l=>this.selectApiOption(l,a,e),i.appendChild(o)}),t.appendChild(i);const s=document.createElement("div");return s.classList.add("svg-container"),s.innerHTML=Y,t.appendChild(s),s.onclick=()=>{var n,a;this.isLoading||(this.isOpen=!this.isOpen,(n=this.optionsListEl)==null||n.classList.toggle("open",this.isOpen),(a=this.svgContainer)==null||a.classList.toggle("open",this.isOpen))},this.optionsListEl=i,this.svgContainer=s,this.props.getOptionsAsync&&!this.hasInitializedOptions?(this.isLoading=!0,this.updateButtonText(),this.props.getOptionsAsync().then(n=>{const a=new Set(this._options.map(l=>JSON.stringify(l.value))),o=n.filter(l=>!a.has(JSON.stringify(l.value)));if(this._options.push(...o),this.isLoading=!1,this.hasInitializedOptions=!0,this.value!==void 0){const l=this._options.findIndex(r=>JSON.stringify(r.value)===JSON.stringify(this.value));this.selectedOptionIndex=l!==-1?l:null}else this.selectedOptionIndex=null;this.updateOptionsList(),this.updateButtonText()}).catch(n=>{console.error("Failed to fetch async options:",n),this.isLoading=!1,this.updateButtonText(this.props.errorText||"Error: Could not load options",!0)})):this.props.getOptionsAsync&&this._options.length<=1&&(this.isLoading=!0,this.updateButtonText(),this.props.getOptionsAsync().then(n=>{const a=new Set(this._options.map(l=>JSON.stringify(l.value))),o=n.filter(l=>!a.has(JSON.stringify(l.value)));if(this._options.push(...o),this.isLoading=!1,this.value!==void 0){const l=this._options.findIndex(r=>JSON.stringify(r.value)===JSON.stringify(this.value));this.selectedOptionIndex=l!==-1?l:null}else this.selectedOptionIndex=null;this.updateOptionsList(),this.updateButtonText()}).catch(n=>{console.error("Failed to fetch async options:",n),this.isLoading=!1,this.updateButtonText(this.props.errorText||"Error: Could not load options",!0)})),t}selectApiOption(t,e,i){var l,r,h,u;const s=t.target,n=s.querySelector(".select-api-radio")||((l=s.closest(".select-api-option"))==null?void 0:l.querySelector(".select-api-radio"));n&&(n.checked=!0),this.selectedOptionIndex=e;const a=this._options[e].value;this.value=a;const o=i.querySelector(".select-value");if(o)o.textContent=this._options[e].name;else{const d=i.firstChild;d&&d.tagName==="SPAN"&&(d.textContent=this._options[e].name)}this.isOpen=!1,(r=this.optionsListEl)==null||r.classList.remove("open"),(h=this.svgContainer)==null||h.classList.remove("open"),(u=this.onChange)==null||u.call(this,a),this.detectChangeCallback&&this.detectChangeCallback(a)}updateOptionsList(){!this.optionsListEl||!this.buttonEl||(this.optionsListEl.innerHTML="",this._options.forEach((t,e)=>{var s;const i=this.createOption(t,e);i.onclick=n=>{this.buttonEl&&this.selectApiOption(n,e,this.buttonEl)},(s=this.optionsListEl)==null||s.appendChild(i)}))}updateButtonText(t,e=!1){if(!this.buttonEl)return;const i=this.buttonEl.querySelector(".select-value")||this.buttonEl.firstChild;if(i)if(e)i.textContent=t||"Error",this.buttonEl.classList.add("error"),this.buttonEl.setAttribute("disabled","true"),this.optionsListEl&&this.optionsListEl.classList.remove("open"),this.svgContainer&&(this.svgContainer.style.display="none");else if(this.isLoading)i.textContent=this.props.loadingText||"Loading options...",this.buttonEl.classList.remove("error"),this.buttonEl.removeAttribute("disabled"),this.svgContainer&&(this.svgContainer.style.display="");else{const s=this.selectedOptionIndex!==null&&this._options&&this.selectedOptionIndex>=0&&this.selectedOptionIndex<this._options.length?this._options[this.selectedOptionIndex]:null,n=s&&typeof s.name=="string"?s.name:"Select an option";i.textContent=t||n,this.buttonEl.classList.remove("error"),this.buttonEl.removeAttribute("disabled"),this.svgContainer&&(this.svgContainer.style.display="")}}setDetectChange(t){this.detectChangeCallback=t}setValue(t){this.value=t,this.selectedOptionIndex=this._options.findIndex(e=>JSON.stringify(e.value)===JSON.stringify(t)),this.updateButtonText()}}class et extends g{constructor(t){var e,i;super(t),this.inputType="text",this.value=t.default??((i=(e=t.options)==null?void 0:e[0])==null?void 0:i.value)??"",this.detectChangeCallback=t.detectChange}draw(){var a,o;const t=document.createElement("div");t.className="toggle-setting-container",this.props.icon&&t.classList.add("toggle-with-icon");const e=document.createElement("div");if(e.className="toggle-label",this.props.icon){const l=document.createElement("span");l.className="toggle-icon",l.innerHTML=this.props.icon,e.appendChild(l)}if(this.props.title){const l=document.createElement("span");l.textContent=this.props.title,e.appendChild(l)}t.appendChild(e);const i=document.createElement("label");i.className="toggle-switch";const s=document.createElement("input");s.type="checkbox",s.checked=((o=(a=this.props.options)==null?void 0:a.find(l=>l.value===this.value))==null?void 0:o.status)??!1,s.addEventListener("change",()=>{var r,h;const l=((h=(r=this.props.options)==null?void 0:r.find(u=>u.status===s.checked))==null?void 0:h.value)??"";this.value=l,this.onChange&&this.onChange(this.value),this.detectChangeCallback&&this.detectChangeCallback(this.value)});const n=document.createElement("span");if(n.className="toggle-slider",this.props.activeColor||this.props.inactiveColor){const l=document.createElement("style"),r=this.props.activeColor||"#4CAF50",h=this.props.inactiveColor||"#ccc";l.textContent=`
|
|
85
85
|
.toggle-switch input:checked + .toggle-slider {
|
|
86
86
|
background-color: ${r};
|
|
87
87
|
}
|
|
@@ -90,7 +90,7 @@
|
|
|
90
90
|
}
|
|
91
91
|
`,document.head.appendChild(l)}return i.appendChild(s),i.appendChild(n),t.appendChild(i),t}setDetectChange(t){this.detectChangeCallback=t}}const it=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
92
92
|
<path d="M13.3334 5.99996H2.66675M13.3334 9.99996H2.66675M5.33341 12.6666V3.33329M10.6667 12.6666V3.33329" stroke="#667085" stroke-width="1.33333" stroke-linecap="round" stroke-linejoin="round"/>
|
|
93
|
-
</svg>`;class st extends g{constructor(t={}){t.rowGap=t.rowGap??!0,t.columnGap=t.columnGap??!0,t.title=t.title??"Gap",t.icon=t.icon??it,t.suffix=t.suffix??"px",t.minValue=t.minValue??0,super(t),this.inputType="number",this.inputValues={},this.mobileValue=t.mobile,this.value=this.validateValue(t.default??0),t.rowGap&&(this.inputValues.row=this.value),t.columnGap&&(this.inputValues.column=this.value)}draw(){const t=document.createElement("div");t.className=`setting-container ${this.props.className||""}`,t.id=this.id;const e=document.createElement("div");e.className="setting-label-input-wrapper";const i=document.createElement("label");i.className="setting-label",i.setAttribute("for",this.id+"-input");const s=document.createElement("span");if(s.textContent=this.props.title??"Gap",i.appendChild(s),this.props.icon){const o=document.createElement("span");o.className="setting-icon",o.innerHTML=this.props.icon,i.insertBefore(o,s)}const n=document.createElement("div");n.className=`setting-input-wrapper ${this.props.wrapperClassName||""}`,n.classList.add("gap-setting-wrapper");const a=document.createElement("div");return a.className="gap-inputs-container",this.props.rowGap&&a.appendChild(this.createGapInput("row","Row")),this.props.columnGap&&a.appendChild(this.createGapInput("column","Col")),n.appendChild(a),e.appendChild(i),e.appendChild(n),t.appendChild(e),t}createGapInput(t,e){const i=document.createElement("div");i.className="gap-input-wrapper";const s=document.createElement("input");if(s.type="number",s.className=`gap-input gap-${t}-input ${this.props.inputClassName||""}`,s.id=`${this.id}-${t}-input`,s.min=String(this.props.minValue??0),this.props.maxValue!==void 0&&(s.max=String(this.props.maxValue)),s.step=String(this.props.step??1),s.value=String(this.inputValues[t]??this.value),s.title=e,s.addEventListener("input",n=>{const a=n.target;let o=parseFloat(a.value);o=this.validateValue(o),String(o)!==a.value&&(a.value=String(o)),this.inputValues[t]=o,this.setValue(o)}),s.addEventListener("blur",n=>{var l,r;const a=n.target;let o=parseFloat(a.value);o=this.validateValue(o),String(o)!==a.value&&(a.value=String(o),this.inputValues[t]=o,this.setValue(o)),(r=(l=this.props).onBlur)==null||r.call(l)}),i.appendChild(s),this.props.suffix&&this.props.suffix!=="none"){const n=document.createElement("span");n.className="gap-suffix",n.textContent=this.props.suffix,i.appendChild(n),s.style.paddingRight="30px"}return i}validateValue(t){(t==null||isNaN(t))&&(t=this.props.default??0);const e=this.props.minValue??Number.MIN_SAFE_INTEGER,i=this.props.maxValue??Number.MAX_SAFE_INTEGER;let s=Number(t);return s<e&&(s=e),s>i&&(s=i),s}getMobileValue(){return this.mobileValue}}class k extends m{constructor(t){var o;if(!t.tabs)throw new Error("Tabs array is required for TabsSettings");const e=t.tabs,i=t.activeTabId||((o=e[0])==null?void 0:o.id)||"",s=e.find(l=>l.id===i),n=s?s.settings:{},a={title:t.title||"",settings:n,collapsed:t.collapsed,main:t.main,description:t.description,icon:t.icon,custom:t.custom,hideCondition:t.hideCondition,onBlur:t.onBlur};super(a),this.tabs=[],this.activeTabId="",this.tabsContainer=null,this.previousTabId="",this.container=null,this.tabValues={},this.internalChangeTimeout=null,this.isHandlingInternalChange=!1,this.INTERNAL_CHANGE_DEBOUNCE=50,this.tabs=e,this.activeTabId=i,this.previousTabId=i,this.onStateChangeCallback=t.onStateChange,this.detectChangeCallback=t.detectChange,this.initializeTabValues(),this.connectChildChangeHandlers()}updateSettingsFromTab(t){const e=this.tabs.find(i=>i.id===t);e&&(this.settings=e.settings,this.tabValues[t]=this.getTabValues(e),this.initialValues={tabs:this.tabValues,activeTabId:this.activeTabId},Object.values(e.settings).forEach(i=>{i instanceof k&&(i._parentTabsSettings=this)}),this.connectChildChangeHandlers())}connectChildChangeHandlers(){if(!this.settings)return;const t=()=>{Promise.resolve().then(()=>{if(this.activeTabId){const e=this.tabs.find(i=>i.id===this.activeTabId);e&&(this.tabValues[this.activeTabId]=this.getTabValues(e))}this.initialValues={tabs:this.tabValues,activeTabId:this.activeTabId},this.triggerDebouncedChange()})};Object.values(this.settings).forEach(e=>{e instanceof m?e.setOnChange(()=>{t()}):e instanceof g&&e.setOnChange(()=>{t()})}),this.tabs.forEach(e=>{Object.entries(e.settings).forEach(([i,s])=>{(s instanceof m||s instanceof g)&&(s instanceof k?(s._parentTabsSettings=this,s.setOnChange(n=>{Promise.resolve().then(()=>{this.tabValues[e.id]=this.getTabValues(e),this.triggerDebouncedChange()})})):s instanceof m?s.setOnChange(()=>{Promise.resolve().then(()=>{this.tabValues[e.id]=this.getTabValues(e),this.triggerDebouncedChange()})}):s instanceof g&&s.setOnChange(()=>{Promise.resolve().then(()=>{this.tabValues[e.id]=this.getTabValues(e),this.triggerDebouncedChange()})}))})})}draw(){const t=super.draw();this.container=t,t.classList.add("tabs-settings-container");const e=document.createElement("div");e.classList.add("tabs-header"),this.main&&e.classList.add("main-header"),this.tabsContainer=e,this.tabs.forEach(s=>{const n=document.createElement("button");n.classList.add("tab-button"),s.id===this.activeTabId&&n.classList.add("active"),n.textContent=s.label,n.onclick=()=>this.handleTabClick(s.id),e.appendChild(n)});const i=t.querySelector(".setting-group-content");return i&&t.insertBefore(e,i),t}handleTabClick(t){var o,l;if(t===this.activeTabId)return;const e=this.tabs.find(r=>r.id===this.activeTabId);e&&(this.tabValues[this.activeTabId]=this.getTabValues(e)),this.previousTabId=this.activeTabId,this.activeTabId=t;const i=(o=this.tabsContainer)==null?void 0:o.querySelectorAll(".tab-button");i==null||i.forEach(r=>{if(r instanceof HTMLElement){const h=this.tabs.find(u=>u.label===r.textContent);r.classList.toggle("active",(h==null?void 0:h.id)===t)}}),this.updateSettingsFromTab(t);const s=(l=this.container)==null?void 0:l.querySelector(".setting-group-content");if(s){s.innerHTML="";const r=this.settings;Object.values(r).forEach(h=>{s.appendChild(h.draw())})}const n=this.getValues();this.initialValues={tabs:this.tabValues,activeTabId:this.activeTabId},this.connectChildChangeHandlers(),this.onStateChangeCallback&&this.onStateChangeCallback(t,n),this.detectChangeCallback&&this.detectChangeCallback(t,n),this.onChange&&this.onChange(n);const a=this.findParentTabsSettings();a&&a.onChange&&a.onChange(a.getValues())}findParentTabsSettings(){return this._parentTabsSettings||null}setOnStateChange(t){return this.onStateChangeCallback=t,this}setDetectChange(t){return this.detectChangeCallback=t,this}getActiveTabId(){return this.activeTabId}getValues(){return this.updateTabValues(),{tabs:this.tabValues,activeTabId:this.activeTabId}}updateTabValues(){!this.tabs||this.tabs.length===0||this.tabs.forEach(t=>{this.tabValues[t.id]=this.getTabValues(t)})}propagateChanges(){const t=this.findParentTabsSettings();t&&(t.updateTabValues(),t.triggerDebouncedChange())}triggerDebouncedChange(){this.isHandlingInternalChange||(this.isHandlingInternalChange=!0,this.internalChangeTimeout&&clearTimeout(this.internalChangeTimeout),this.internalChangeTimeout=setTimeout(()=>{this.onChange&&this.onChange(this.getValues()),this.isHandlingInternalChange=!1,this.internalChangeTimeout=null;const t=this.findParentTabsSettings();t&&t.triggerDebouncedChange()},this.INTERNAL_CHANGE_DEBOUNCE))}updateInitialValues(){!this.tabs||this.tabs.length===0||(this.updateTabValues(),this.initialValues={tabs:this.tabValues,activeTabId:this.activeTabId},this.tabs.forEach(t=>{Object.values(t.settings).forEach(e=>{e instanceof k&&e.updateInitialValues()})}))}setOnChange(t){return this.onChange=t,this.connectChildChangeHandlers(),this.updateTabValues(),this}initializeTabValues(){!this.tabs||this.tabs.length===0||(this.tabs.forEach(t=>{this.tabValues[t.id]=this.getTabValues(t)}),this.initialValues={tabs:this.tabValues,activeTabId:this.activeTabId})}getTabValues(t){const e={};return Object.entries(t.settings).forEach(([i,s])=>{s instanceof k||s instanceof m?e[i]=s.getValues():(s instanceof g,e[i]=s.value)}),e}clone(){const t=this.tabs.map(i=>{const s={};return Object.entries(i.settings).forEach(([n,a])=>{typeof a.clone=="function"?s[n]=a.clone():(console.warn(`Setting with key '${n}' in tab '${i.id}' does not have a clone method. Copying reference.`),s[n]=a)}),{...i,settings:s}}),e={title:this.title,tabs:t,activeTabId:this.activeTabId,collapsed:this.isCollapsed,main:this.isMain,description:this.description,icon:this.icon,custom:this.custom,hideCondition:this.hideCondition,settings:{}};return new k(e)}setValue(t){if(t&&typeof t=="object"){let e=!1;if(t.activeTabId&&t.activeTabId!==this.activeTabId&&(this.previousTabId=this.activeTabId,this.activeTabId=t.activeTabId,e=!0),t.tabs&&typeof t.tabs=="object"&&Object.entries(t.tabs).forEach(([i,s])=>{const n=this.tabs.find(a=>a.id===i);n&&s&&typeof s=="object"&&Object.entries(s).forEach(([a,o])=>{n.settings[a]&&typeof n.settings[a].setValue=="function"&&n.settings[a].setValue(o)})}),this.updateTabValues(),this.triggerDebouncedChange(),this.container){if(this.updateSettingsFromTab(this.activeTabId),this.tabsContainer){const s=this.tabsContainer.querySelectorAll(".tab-button");s==null||s.forEach(n=>{if(n instanceof HTMLElement){const a=this.tabs.find(o=>o.label===n.textContent);n.classList.toggle("active",(a==null?void 0:a.id)===this.activeTabId)}})}const i=this.container.querySelector(".setting-group-content");if(i){i.innerHTML="";const s=this.settings;Object.values(s).forEach(n=>{i.appendChild(n.draw())})}e&&this.onStateChangeCallback&&this.onStateChangeCallback(this.activeTabId,this.getValues())}this.initialValues={tabs:this.tabValues,activeTabId:this.activeTabId}}}updateTabSetting(t,e,i){const s=this.tabs.find(a=>a.id===t);if(!s||!s.settings[e])return;const n=s.settings[e];typeof n.setValue=="function"&&(n.setValue(i),this.tabValues[t]=this.getTabValues(s),t!==this.activeTabId&&this.onChange&&this.onChange(this.getValues()))}getTabsConfiguration(){return this.tabs}}const nt=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
93
|
+
</svg>`;class st extends g{constructor(t={}){t.rowGap=t.rowGap??!0,t.columnGap=t.columnGap??!0,t.title=t.title??"Gap",t.icon=t.icon??it,t.suffix=t.suffix??"px",t.minValue=t.minValue??0,super(t),this.inputType="number",this.inputValues={},this.mobileValue=t.mobile,this.value=this.validateValue(t.default??0),t.rowGap&&(this.inputValues.row=this.value),t.columnGap&&(this.inputValues.column=this.value)}draw(){const t=document.createElement("div");t.className=`setting-container ${this.props.className||""}`,t.id=this.id;const e=document.createElement("div");e.className="setting-label-input-wrapper";const i=document.createElement("label");i.className="setting-label",i.setAttribute("for",this.id+"-input");const s=document.createElement("span");if(s.textContent=this.props.title??"Gap",i.appendChild(s),this.props.icon){const o=document.createElement("span");o.className="setting-icon",o.innerHTML=this.props.icon,i.insertBefore(o,s)}const n=document.createElement("div");n.className=`setting-input-wrapper ${this.props.wrapperClassName||""}`,n.classList.add("gap-setting-wrapper");const a=document.createElement("div");return a.className="gap-inputs-container",this.props.rowGap&&a.appendChild(this.createGapInput("row","Row")),this.props.columnGap&&a.appendChild(this.createGapInput("column","Col")),n.appendChild(a),e.appendChild(i),e.appendChild(n),t.appendChild(e),t}createGapInput(t,e){const i=document.createElement("div");i.className="gap-input-wrapper";const s=document.createElement("input");if(s.type="number",s.className=`gap-input gap-${t}-input ${this.props.inputClassName||""}`,s.id=`${this.id}-${t}-input`,s.min=String(this.props.minValue??0),this.props.maxValue!==void 0&&(s.max=String(this.props.maxValue)),s.step=String(this.props.step??1),s.value=String(this.inputValues[t]??this.value),s.title=e,s.addEventListener("input",n=>{const a=n.target;let o=parseFloat(a.value);o=this.validateValue(o),String(o)!==a.value&&(a.value=String(o)),this.inputValues[t]=o,this.setValue(o)}),s.addEventListener("blur",n=>{var l,r;const a=n.target;let o=parseFloat(a.value);o=this.validateValue(o),String(o)!==a.value&&(a.value=String(o),this.inputValues[t]=o,this.setValue(o)),(r=(l=this.props).onBlur)==null||r.call(l)}),i.appendChild(s),this.props.suffix&&this.props.suffix!=="none"){const n=document.createElement("span");n.className="gap-suffix",n.textContent=this.props.suffix,i.appendChild(n),s.style.paddingRight="30px"}return i}validateValue(t){(t==null||isNaN(t))&&(t=this.props.default??0);const e=this.props.minValue??Number.MIN_SAFE_INTEGER,i=this.props.maxValue??Number.MAX_SAFE_INTEGER;let s=Number(t);return s<e&&(s=e),s>i&&(s=i),s}getMobileValue(){return this.mobileValue}}class V extends m{constructor(t){var o;if(!t.tabs)throw new Error("Tabs array is required for TabsSettings");const e=t.tabs,i=t.activeTabId||((o=e[0])==null?void 0:o.id)||"",s=e.find(l=>l.id===i),n=s?s.settings:{},a={title:t.title||"",settings:n,collapsed:t.collapsed,main:t.main,description:t.description,icon:t.icon,custom:t.custom,hideCondition:t.hideCondition,onBlur:t.onBlur};super(a),this.tabs=[],this.activeTabId="",this.tabsContainer=null,this.previousTabId="",this.container=null,this.tabValues={},this.internalChangeTimeout=null,this.isHandlingInternalChange=!1,this.INTERNAL_CHANGE_DEBOUNCE=50,this.tabs=e,this.activeTabId=i,this.previousTabId=i,this.onStateChangeCallback=t.onStateChange,this.detectChangeCallback=t.detectChange,this.initializeTabValues(),this.connectChildChangeHandlers()}updateSettingsFromTab(t){const e=this.tabs.find(i=>i.id===t);e&&(this.settings=e.settings,this.tabValues[t]=this.getTabValues(e),this.initialValues={tabs:this.tabValues,activeTabId:this.activeTabId},Object.values(e.settings).forEach(i=>{i instanceof V&&(i._parentTabsSettings=this)}),this.connectChildChangeHandlers())}connectChildChangeHandlers(){if(!this.settings)return;const t=()=>{Promise.resolve().then(()=>{if(this.activeTabId){const e=this.tabs.find(i=>i.id===this.activeTabId);e&&(this.tabValues[this.activeTabId]=this.getTabValues(e))}this.initialValues={tabs:this.tabValues,activeTabId:this.activeTabId},this.triggerDebouncedChange()})};Object.values(this.settings).forEach(e=>{e instanceof m?e.setOnChange(()=>{t()}):e instanceof g&&e.setOnChange(()=>{t()})}),this.tabs.forEach(e=>{Object.entries(e.settings).forEach(([i,s])=>{(s instanceof m||s instanceof g)&&(s instanceof V?(s._parentTabsSettings=this,s.setOnChange(n=>{Promise.resolve().then(()=>{this.tabValues[e.id]=this.getTabValues(e),this.triggerDebouncedChange()})})):s instanceof m?s.setOnChange(()=>{Promise.resolve().then(()=>{this.tabValues[e.id]=this.getTabValues(e),this.triggerDebouncedChange()})}):s instanceof g&&s.setOnChange(()=>{Promise.resolve().then(()=>{this.tabValues[e.id]=this.getTabValues(e),this.triggerDebouncedChange()})}))})})}draw(){const t=super.draw();this.container=t,t.classList.add("tabs-settings-container");const e=document.createElement("div");e.classList.add("tabs-header"),this.main&&e.classList.add("main-header"),this.tabsContainer=e,this.tabs.forEach(s=>{const n=document.createElement("button");n.classList.add("tab-button"),s.id===this.activeTabId&&n.classList.add("active"),n.textContent=s.label,n.onclick=()=>this.handleTabClick(s.id),e.appendChild(n)});const i=t.querySelector(".setting-group-content");return i&&t.insertBefore(e,i),t}handleTabClick(t){var o,l;if(t===this.activeTabId)return;const e=this.tabs.find(r=>r.id===this.activeTabId);e&&(this.tabValues[this.activeTabId]=this.getTabValues(e)),this.previousTabId=this.activeTabId,this.activeTabId=t;const i=(o=this.tabsContainer)==null?void 0:o.querySelectorAll(".tab-button");i==null||i.forEach(r=>{if(r instanceof HTMLElement){const h=this.tabs.find(u=>u.label===r.textContent);r.classList.toggle("active",(h==null?void 0:h.id)===t)}}),this.updateSettingsFromTab(t);const s=(l=this.container)==null?void 0:l.querySelector(".setting-group-content");if(s){s.innerHTML="";const r=this.settings;Object.values(r).forEach(h=>{s.appendChild(h.draw())})}const n=this.getValues();this.initialValues={tabs:this.tabValues,activeTabId:this.activeTabId},this.connectChildChangeHandlers(),this.onStateChangeCallback&&this.onStateChangeCallback(t,n),this.detectChangeCallback&&this.detectChangeCallback(t,n),this.onChange&&this.onChange(n);const a=this.findParentTabsSettings();a&&a.onChange&&a.onChange(a.getValues())}findParentTabsSettings(){return this._parentTabsSettings||null}setOnStateChange(t){return this.onStateChangeCallback=t,this}setDetectChange(t){return this.detectChangeCallback=t,this}getActiveTabId(){return this.activeTabId}getValues(){return this.updateTabValues(),{tabs:this.tabValues,activeTabId:this.activeTabId}}updateTabValues(){!this.tabs||this.tabs.length===0||this.tabs.forEach(t=>{this.tabValues[t.id]=this.getTabValues(t)})}propagateChanges(){const t=this.findParentTabsSettings();t&&(t.updateTabValues(),t.triggerDebouncedChange())}triggerDebouncedChange(){this.isHandlingInternalChange||(this.isHandlingInternalChange=!0,this.internalChangeTimeout&&clearTimeout(this.internalChangeTimeout),this.internalChangeTimeout=setTimeout(()=>{this.onChange&&this.onChange(this.getValues()),this.isHandlingInternalChange=!1,this.internalChangeTimeout=null;const t=this.findParentTabsSettings();t&&t.triggerDebouncedChange()},this.INTERNAL_CHANGE_DEBOUNCE))}updateInitialValues(){!this.tabs||this.tabs.length===0||(this.updateTabValues(),this.initialValues={tabs:this.tabValues,activeTabId:this.activeTabId},this.tabs.forEach(t=>{Object.values(t.settings).forEach(e=>{e instanceof V&&e.updateInitialValues()})}))}setOnChange(t){return this.onChange=t,this.connectChildChangeHandlers(),this.updateTabValues(),this}initializeTabValues(){!this.tabs||this.tabs.length===0||(this.tabs.forEach(t=>{this.tabValues[t.id]=this.getTabValues(t)}),this.initialValues={tabs:this.tabValues,activeTabId:this.activeTabId})}getTabValues(t){const e={};return Object.entries(t.settings).forEach(([i,s])=>{s instanceof V||s instanceof m?e[i]=s.getValues():(s instanceof g,e[i]=s.value)}),e}clone(){const t=this.tabs.map(i=>{const s={};return Object.entries(i.settings).forEach(([n,a])=>{typeof a.clone=="function"?s[n]=a.clone():(console.warn(`Setting with key '${n}' in tab '${i.id}' does not have a clone method. Copying reference.`),s[n]=a)}),{...i,settings:s}}),e={title:this.title,tabs:t,activeTabId:this.activeTabId,collapsed:this.isCollapsed,main:this.isMain,description:this.description,icon:this.icon,custom:this.custom,hideCondition:this.hideCondition,settings:{}};return new V(e)}setValue(t){if(t&&typeof t=="object"){let e=!1;if(t.activeTabId&&t.activeTabId!==this.activeTabId&&(this.previousTabId=this.activeTabId,this.activeTabId=t.activeTabId,e=!0),t.tabs&&typeof t.tabs=="object"&&Object.entries(t.tabs).forEach(([i,s])=>{const n=this.tabs.find(a=>a.id===i);n&&s&&typeof s=="object"&&Object.entries(s).forEach(([a,o])=>{n.settings[a]&&typeof n.settings[a].setValue=="function"&&n.settings[a].setValue(o)})}),this.updateTabValues(),this.triggerDebouncedChange(),this.container){if(this.updateSettingsFromTab(this.activeTabId),this.tabsContainer){const s=this.tabsContainer.querySelectorAll(".tab-button");s==null||s.forEach(n=>{if(n instanceof HTMLElement){const a=this.tabs.find(o=>o.label===n.textContent);n.classList.toggle("active",(a==null?void 0:a.id)===this.activeTabId)}})}const i=this.container.querySelector(".setting-group-content");if(i){i.innerHTML="";const s=this.settings;Object.values(s).forEach(n=>{i.appendChild(n.draw())})}e&&this.onStateChangeCallback&&this.onStateChangeCallback(this.activeTabId,this.getValues())}this.initialValues={tabs:this.tabValues,activeTabId:this.activeTabId}}}updateTabSetting(t,e,i){const s=this.tabs.find(a=>a.id===t);if(!s||!s.settings[e])return;const n=s.settings[e];typeof n.setValue=="function"&&(n.setValue(i),this.tabValues[t]=this.getTabValues(s),t!==this.activeTabId&&this.onChange&&this.onChange(this.getValues()))}getTabsConfiguration(){return this.tabs}}const nt=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
94
94
|
<path d="M2.25 11.75H15.75M5.85 2.75H12.15C13.4101 2.75 14.0402 2.75 14.5215 2.99524C14.9448 3.21095 15.289 3.55516 15.5048 3.97852C15.75 4.45982 15.75 5.08988 15.75 6.35V12.65C15.75 13.9101 15.75 14.5402 15.5048 15.0215C15.289 15.4448 14.9448 15.789 14.5215 16.0048C14.0402 16.25 13.4101 16.25 12.15 16.25H5.85C4.58988 16.25 3.95982 16.25 3.47852 16.0048C3.05516 15.789 2.71095 15.4448 2.49524 15.0215C2.25 14.5402 2.25 13.9101 2.25 12.65V6.35C2.25 5.08988 2.25 4.45982 2.49524 3.97852C2.71095 3.55516 3.05516 3.21095 3.47852 2.99524C3.95982 2.75 4.58988 2.75 5.85 2.75Z" stroke="#667085" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
95
95
|
</svg>`;class at extends b{constructor(t={}){super({...t,minValue:t.minValue??0,maxValue:t.maxValue??1e3,icon:t.icon||nt,title:t.title||"Margin Bottom",default:t.default??20,wrapperClassName:"margin-bottom-wrapper "+(t.wrapperClassName||"")}),this.inputType="number"}}const ot=`
|
|
96
96
|
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
101
101
|
<path d="M6 2.75H5.85C4.58988 2.75 3.95982 2.75 3.47852 2.99524C3.05516 3.21095 2.71095 3.55516 2.49524 3.97852C2.25 4.45982 2.25 5.08988 2.25 6.35V6.5M6 16.25H5.85C4.58988 16.25 3.95982 16.25 3.47852 16.0048C3.05516 15.789 2.71095 15.4448 2.49524 15.0215C2.25 14.5402 2.25 13.9101 2.25 12.65V12.5M15.75 6.5V6.35C15.75 5.08988 15.75 4.45982 15.5048 3.97852C15.289 3.55516 14.9448 3.21095 14.5215 2.99524C14.0402 2.75 13.4101 2.75 12.15 2.75H12M15.75 12.5V12.65C15.75 13.9101 15.75 14.5402 15.5048 15.0215C15.289 15.4448 14.9448 15.789 14.5215 16.0048C14.0402 16.25 13.4101 16.25 12.15 16.25H12" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
|
|
102
102
|
</svg>
|
|
103
|
-
`;class rt extends m{constructor(t){super({title:"Border",collapsed:t==null?void 0:t.collapsed,hideCondition:t==null?void 0:t.hideCondition,settings:{size:new b({title:"Size",icon:lt,default:(t==null?void 0:t.size)??0,suffix:"px"}),color:new
|
|
103
|
+
`;class rt extends m{constructor(t){super({title:"Border",collapsed:t==null?void 0:t.collapsed,hideCondition:t==null?void 0:t.hideCondition,settings:{size:new b({title:"Size",icon:lt,default:(t==null?void 0:t.size)??0,suffix:"px"}),color:new k({default:(t==null?void 0:t.color)??"0, 0, 30"}),opacity:new y({default:(t==null?void 0:t.opacity)??100,minValue:0,maxValue:100}),radius:new b({title:"Radius",icon:ot,default:(t==null?void 0:t.radius)??12,suffix:"px"})}})}getCssCode(){const t=this.settings.color.value??"#000000",e=this.settings.opacity.value??100,i=this.settings.radius.value??0,s=this.settings.size.value??0;return`
|
|
104
104
|
border-color: ${t};
|
|
105
105
|
border-width: ${s}px;
|
|
106
106
|
border-radius: ${i}px;
|
|
@@ -117,14 +117,14 @@
|
|
|
117
117
|
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
118
118
|
<path d="M6 5.75H12M9 5.75V13.25M5.85 16.25H12.15C13.4101 16.25 14.0402 16.25 14.5215 16.0048C14.9448 15.789 15.289 15.4448 15.5048 15.0215C15.75 14.5402 15.75 13.9101 15.75 12.65V6.35C15.75 5.08988 15.75 4.45982 15.5048 3.97852C15.289 3.55516 14.9448 3.21095 14.5215 2.99524C14.0402 2.75 13.4101 2.75 12.15 2.75H5.85C4.58988 2.75 3.95982 2.75 3.47852 2.99524C3.05516 3.21095 2.71095 3.55516 2.49524 3.97852C2.25 4.45982 2.25 5.08988 2.25 6.35V12.65C2.25 13.9101 2.25 14.5402 2.49524 15.0215C2.71095 15.4448 3.05516 15.789 3.47852 16.0048C3.95982 16.25 4.58988 16.25 5.85 16.25Z" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
|
|
119
119
|
</svg>
|
|
120
|
-
`;class ut extends m{constructor(t={}){super({title:t.title||"Typography",collapsed:t.collapsed,hideCondition:t.hideCondition,settings:{color:new
|
|
120
|
+
`;class ut extends m{constructor(t={}){super({title:t.title||"Typography",collapsed:t.collapsed,hideCondition:t.hideCondition,settings:{color:new k({default:t.colorDefault??"0, 0, 30"}),opacity:new y({default:t.colorOpacityDefault??100}),fontFamily:new N({title:"Font",icon:ht,default:t.fontFamilyDefault??"Satoshi",options:t.fontFamilyOptions??[{name:"Satoshi",value:"Satoshi"},{name:"Arial",value:"Arial"},{name:"Roboto",value:"Roboto"}],getOptions:t.fontFamilyGetOptions,getOptionsAsync:t.fontFamilyGetOptionsAsync}),fontWeight:new N({title:"Weight",icon:ct,default:t.fontWeightDefault??"400",options:t.fontWeightOptions??[{name:"Regular",value:"400"},{name:"Medium",value:"500"},{name:"Bold",value:"600"}],getOptions:t.fontWeightGetOptions,getOptionsAsync:t.fontWeightGetOptionsAsync}),fontSize:new b({title:"Size",icon:dt,default:t.fontSizeDefault??12,suffix:"px",mobile:t.fontSizeMobileDefault}),align:new A({title:"Align",default:t.alignDefault??"center"})}})}getCssCode(){const t=this.settings.color.value??"#000000",e=this.settings.opacity.value??100,i=this.settings.fontFamily.value??"Satoshi",s=this.settings.fontWeight.value??"bold",n=this.settings.fontSize.value??12,a=this.settings.align.value??"left";return`
|
|
121
121
|
color: ${t};
|
|
122
122
|
opacity: ${e/100};
|
|
123
123
|
font-family: ${i};
|
|
124
124
|
font-weight: ${s};
|
|
125
125
|
font-size: ${n}px;
|
|
126
126
|
text-align: ${a};
|
|
127
|
-
`}}class
|
|
127
|
+
`}}class L extends g{constructor(t){super({...t,default:t.default!==void 0?t.default:"auto"}),this.inputType="number",this.value=t.default!==void 0?t.default:"auto"}draw(){const t=this.value==="auto"?"text":"number",e=o=>{this.value!=="auto"&&(this.props.minValue!==void 0&&(o.min=String(this.props.minValue)),this.props.maxValue!==void 0&&(o.max=String(this.props.maxValue)),this.props.className&&o.classList.add(this.props.className),o.addEventListener("input",()=>{const l=this.props.minValue??Number.MIN_SAFE_INTEGER,r=this.props.maxValue??Number.MAX_SAFE_INTEGER;let h=Number(o.value);h<l&&(h=l),h>r&&(h=r),o.value=String(h)}))},i=this.createInput({value:this.value,inputType:t,title:this.props.title,icon:this.props.icon,inputClassName:"number-setting-input "+(this.props.inputClassName||""),wrapperClassName:"number-setting-wrapper "+(this.props.wrapperClassName||""),inputCustomizer:e,placeholder:this.value==="auto"?"auto":""});if(!this.props.suffix||this.props.suffix==="none")return i;i.classList.add("suffix-wrapper");const s=i.querySelector("input.number-setting-input");s&&(s.style.paddingRight="35px");const n=document.createElement("span");n.className="suffix-label",n.textContent=this.props.suffix,i.appendChild(n);const a=i.querySelector("input");return a&&(a.oninput=o=>{const l=o.target.value.trim();if(l.toLowerCase()==="auto")this.value="auto";else{const r=Number(l);isNaN(r)||(this.value=r)}this.onChange&&this.onChange(this.value)}),i}}class pt extends m{constructor(t){super({title:"Margins",collapsed:t==null?void 0:t.collapsed,hideCondition:t==null?void 0:t.hideCondition,settings:{marginTop:new L({title:"Top",icon:gt,suffix:"px",default:(t==null?void 0:t.marginTop)??"auto"}),marginRight:new L({title:"Right",icon:mt,suffix:"px",default:(t==null?void 0:t.marginRight)??0}),marginBottom:new L({title:"Bottom",icon:ft,suffix:"px",default:(t==null?void 0:t.marginBottom)??0}),marginLeft:new L({title:"Left",icon:Ct,suffix:"px",default:(t==null?void 0:t.marginLeft)??0})}})}getCssCode(){const t=typeof this.settings.marginTop.value=="number"?`${this.settings.marginTop.value}px`:this.settings.marginTop.value,e=typeof this.settings.marginRight.value=="number"?`${this.settings.marginRight.value}px`:this.settings.marginRight.value,i=typeof this.settings.marginBottom.value=="number"?`${this.settings.marginBottom.value}px`:this.settings.marginBottom.value,s=typeof this.settings.marginLeft.value=="number"?`${this.settings.marginLeft.value}px`:this.settings.marginLeft.value;return`
|
|
128
128
|
margin-top: ${t};
|
|
129
129
|
margin-right: ${e};
|
|
130
130
|
margin-bottom: ${i};
|
|
@@ -137,7 +137,7 @@
|
|
|
137
137
|
<path d="M2.25 2.75H2.2575M2.25 9.5H2.2575M2.25 12.875H2.2575M2.25 6.125H2.2575M5.625 2.75H5.6325M5.625 9.5H5.6325M12.375 2.75H12.3825M12.375 9.5H12.3825M9 2.75H9.0075M9 9.5H9.0075M9 12.875H9.0075M9 6.125H9.0075M15.75 2.75H15.7575M15.75 9.5H15.7575M15.75 12.875H15.7575M15.75 6.125H15.7575M15.75 16.25H2.25" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
|
|
138
138
|
</svg>`,Ct=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
139
139
|
<path d="M5.625 2.75H5.6325M5.625 9.5H5.6325M5.625 16.25H5.6325M12.375 2.75H12.3825M12.375 9.5H12.3825M12.375 16.25H12.3825M9 2.75H9.0075M9 9.5H9.0075M9 16.25H9.0075M9 12.875H9.0075M9 6.125H9.0075M15.75 2.75H15.7575M15.75 9.5H15.7575M15.75 16.25H15.7575M15.75 12.875H15.7575M15.75 6.125H15.7575M2.25 16.25V2.75" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
|
|
140
|
-
</svg>`;class vt extends m{constructor(t){super({title:"Background Image",collapsed:t==null?void 0:t.collapsed,hideCondition:t==null?void 0:t.hideCondition,settings:{backgroundImage:new
|
|
140
|
+
</svg>`;class vt extends m{constructor(t){super({title:"Background Image",collapsed:t==null?void 0:t.collapsed,hideCondition:t==null?void 0:t.hideCondition,settings:{backgroundImage:new $({...t==null?void 0:t.uploadProps,default:(t==null?void 0:t.backgroundImage)??""}),opacity:new y({default:(t==null?void 0:t.opacity)??100}),backgroundColor:new k({default:(t==null?void 0:t.backgroundColor)??"0, 0, 30"}),opacityBG:new y({default:(t==null?void 0:t.opacityBG)??100})}})}draw(){const t=super.draw(),e=t.querySelector(".setting-group-content");if(!e)return t;const i=Array.from(e.children),[s,n,a,o]=i;e.innerHTML="",e.appendChild(s),e.appendChild(n);const l=document.createElement("div");return l.className="bgset-or-label",l.textContent="OR",e.appendChild(l),e.appendChild(a),e.appendChild(o),t}getCssCode(){const t=this.settings.backgroundImage.value||"",e=this.settings.opacity.value??100,i=this.settings.backgroundColor.value||"0, 0, 30",s=this.settings.opacityBG.value??100;return t?`
|
|
141
141
|
background-image: url("${t}");
|
|
142
142
|
background-size: cover;
|
|
143
143
|
background-position: center;
|
|
@@ -166,4 +166,4 @@
|
|
|
166
166
|
</svg>
|
|
167
167
|
</span>
|
|
168
168
|
<span class="add-label">Add Tab</span>
|
|
169
|
-
`,i.onclick=()=>{this.addTab(),this.rerender()},e.appendChild(i),t.appendChild(e),t}rerender(){if(!this._el)return;const t=this._el.querySelector(".setting-group-content");t&&(t.innerHTML="",Object.keys(this.settings).forEach(e=>{const i=this.settings[e];t.appendChild(i.draw())}))}}function xt(c){return c instanceof m}function Et(c){return c instanceof g}exports.AlignSetting=A;exports.BackgroundSettingSet=vt;exports.BorderSettingSet=rt;exports.ButtonSetting=D;exports.ColorSetting=
|
|
169
|
+
`,i.onclick=()=>{this.addTab(),this.rerender()},e.appendChild(i),t.appendChild(e),t}rerender(){if(!this._el)return;const t=this._el.querySelector(".setting-group-content");t&&(t.innerHTML="",Object.keys(this.settings).forEach(e=>{const i=this.settings[e];t.appendChild(i.draw())}))}}function xt(c){return c instanceof m}function Et(c){return c instanceof g}exports.AlignSetting=A;exports.BackgroundSettingSet=vt;exports.BorderSettingSet=rt;exports.ButtonSetting=D;exports.ColorSetting=k;exports.DimensionSetting=z;exports.GapSetting=st;exports.HeaderTypographySettingSet=ut;exports.HeightSetting=Z;exports.MarginBottomSetting=at;exports.MarginSettingGroup=pt;exports.NumberSetting=b;exports.OpacitySetting=y;exports.SelectApiSettings=tt;exports.SelectSetting=N;exports.Setting=g;exports.SettingGroup=m;exports.StringSetting=T;exports.TabsContainerGroup=wt;exports.TabsSettings=V;exports.Toggle=et;exports.UploadSetting=$;exports.WidthSetting=K;exports.asSettingGroupWithSettings=G;exports.createSettingGroup=R;exports.isSetting=Et;exports.isSettingGroup=xt;exports.iterateSettings=M;
|
|
@@ -5,7 +5,7 @@ let B = (c = 21) => {
|
|
|
5
5
|
t += R[e[c] & 63];
|
|
6
6
|
return t;
|
|
7
7
|
};
|
|
8
|
-
function
|
|
8
|
+
function y(c) {
|
|
9
9
|
if (c === null || typeof c != "object")
|
|
10
10
|
return c;
|
|
11
11
|
if (c instanceof Date)
|
|
@@ -13,12 +13,12 @@ function V(c) {
|
|
|
13
13
|
if (Array.isArray(c)) {
|
|
14
14
|
const i = [];
|
|
15
15
|
for (let s = 0; s < c.length; s++)
|
|
16
|
-
i[s] =
|
|
16
|
+
i[s] = y(c[s]);
|
|
17
17
|
return i;
|
|
18
18
|
}
|
|
19
19
|
const t = {};
|
|
20
20
|
for (const i in c)
|
|
21
|
-
Object.prototype.hasOwnProperty.call(c, i) && (t[i] =
|
|
21
|
+
Object.prototype.hasOwnProperty.call(c, i) && (t[i] = y(c[i]));
|
|
22
22
|
const e = Object.getPrototypeOf(c);
|
|
23
23
|
return e !== Object.prototype && Object.setPrototypeOf(t, e), t;
|
|
24
24
|
}
|
|
@@ -58,8 +58,8 @@ class g {
|
|
|
58
58
|
}
|
|
59
59
|
// Basic clone method
|
|
60
60
|
clone() {
|
|
61
|
-
const t = this.constructor, e =
|
|
62
|
-
return i.value =
|
|
61
|
+
const t = this.constructor, e = y(this.props), i = new t(e);
|
|
62
|
+
return i.value = y(this.value), i;
|
|
63
63
|
}
|
|
64
64
|
createInput(t) {
|
|
65
65
|
t = { ...this.props.inputProps, ...t };
|
|
@@ -120,14 +120,14 @@ class g {
|
|
|
120
120
|
return i.className = "input-icon " + (e || ""), i.innerHTML = t, i;
|
|
121
121
|
}
|
|
122
122
|
}
|
|
123
|
-
function
|
|
123
|
+
function S(c, t) {
|
|
124
124
|
for (const e in c)
|
|
125
125
|
if (c.hasOwnProperty(e)) {
|
|
126
126
|
const i = c[e];
|
|
127
127
|
t(e, i);
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
-
const
|
|
130
|
+
const w = class w {
|
|
131
131
|
constructor(t) {
|
|
132
132
|
this.elementRef = null, this.isHidden = !1, this.custom = !1, this.initialValues = {}, this.changeTimeout = null, this.isHandlingChange = !1, this.changeHandlers = /* @__PURE__ */ new Set(), this.blurTimeout = null, this.lastValues = {}, this.lastChangeTime = 0, this.CHANGE_DEBOUNCE = 100, this.handleBlur = () => {
|
|
133
133
|
}, this.pendingBlurHandler = null, this.id = t.id || B(), this.title = t.title, this.settings = t.settings, this.description = t.description, this.icon = t.icon, this.isCollapsed = t.collapsed ?? !1, this.isMain = t.main ?? !1, this.custom = t.custom ?? !1, this.hideCondition = t.hideCondition, this.onBlur = t.onBlur, Object.assign(this, t.settings), this.initialValues = this.getValues();
|
|
@@ -153,9 +153,9 @@ const b = class b {
|
|
|
153
153
|
Object.keys(s).length > 0 && (this.lastChangeTime = Date.now(), this.initialValues = i, t(i), this.updateVisibility()), this.isHandlingChange = !1;
|
|
154
154
|
}, 50));
|
|
155
155
|
};
|
|
156
|
-
return this.changeHandlers.clear(),
|
|
156
|
+
return this.changeHandlers.clear(), S(this.settings, (i, s) => {
|
|
157
157
|
var n;
|
|
158
|
-
if (s instanceof
|
|
158
|
+
if (s instanceof w)
|
|
159
159
|
s.setOnChange((a) => {
|
|
160
160
|
const o = this.getValues();
|
|
161
161
|
this.initialValues = o, t(o);
|
|
@@ -188,9 +188,9 @@ const b = class b {
|
|
|
188
188
|
"focusout",
|
|
189
189
|
this.handleBlur,
|
|
190
190
|
!0
|
|
191
|
-
),
|
|
191
|
+
), S(this.settings, (t, e) => {
|
|
192
192
|
var i;
|
|
193
|
-
if (e instanceof
|
|
193
|
+
if (e instanceof w)
|
|
194
194
|
e.setOnBlur(this.handleBlur);
|
|
195
195
|
else {
|
|
196
196
|
const s = (i = this.elementRef) == null ? void 0 : i.querySelector(
|
|
@@ -212,7 +212,7 @@ const b = class b {
|
|
|
212
212
|
}
|
|
213
213
|
clone() {
|
|
214
214
|
const t = {};
|
|
215
|
-
|
|
215
|
+
S(this.settings, (s, n) => {
|
|
216
216
|
typeof n.clone == "function" ? t[s] = n.clone() : (console.warn(
|
|
217
217
|
`Setting with key '${s}' does not have a clone method. Copying reference.`
|
|
218
218
|
), t[s] = n);
|
|
@@ -226,14 +226,14 @@ const b = class b {
|
|
|
226
226
|
main: this.isMain,
|
|
227
227
|
custom: this.custom,
|
|
228
228
|
hideCondition: this.hideCondition
|
|
229
|
-
}, i =
|
|
229
|
+
}, i = $(e);
|
|
230
230
|
return i.initialValues = this.getValues(), i;
|
|
231
231
|
}
|
|
232
232
|
setValue(t) {
|
|
233
233
|
if (!t || typeof t != "object") return;
|
|
234
234
|
Object.entries(t).forEach(([i, s]) => {
|
|
235
235
|
const n = this.settings[i];
|
|
236
|
-
n && (n instanceof
|
|
236
|
+
n && (n instanceof w || n instanceof g) && typeof n.setValue == "function" && n.setValue(s);
|
|
237
237
|
});
|
|
238
238
|
const e = this.getValues();
|
|
239
239
|
this.initialValues = e, this.onChange && this.onChange(e);
|
|
@@ -263,17 +263,17 @@ const b = class b {
|
|
|
263
263
|
for (const i in this.settings)
|
|
264
264
|
if (this.settings.hasOwnProperty(i)) {
|
|
265
265
|
const s = this.settings[i];
|
|
266
|
-
s instanceof
|
|
266
|
+
s instanceof w ? e[i] = s.getValues() : e[i] = s.value;
|
|
267
267
|
}
|
|
268
268
|
return e;
|
|
269
269
|
} else {
|
|
270
270
|
const e = this.settings[t];
|
|
271
|
-
return e ? e instanceof
|
|
271
|
+
return e ? e instanceof w ? e.getValues() : e.value : void 0;
|
|
272
272
|
}
|
|
273
273
|
}
|
|
274
274
|
draw() {
|
|
275
275
|
const t = document.createElement("div");
|
|
276
|
-
t.className = "setting-group", t.id = `setting-group-${this.id}`,
|
|
276
|
+
t.className = "setting-group", t.id = `setting-group-${this.id}`, w.hiddenElements.add(t), this.hideCondition && this.hideCondition() && (t.style.display = "none"), this.isMain && t.classList.add("main-group");
|
|
277
277
|
const e = document.createElement("div");
|
|
278
278
|
e.className = "setting-group-title", this.isCollapsed && e.classList.add("collapsed-view"), e.setAttribute("role", "button"), e.setAttribute(
|
|
279
279
|
"aria-expanded",
|
|
@@ -382,21 +382,27 @@ const b = class b {
|
|
|
382
382
|
setJson(t) {
|
|
383
383
|
try {
|
|
384
384
|
const e = JSON.parse(t);
|
|
385
|
-
|
|
385
|
+
let i = e;
|
|
386
|
+
const s = Object.keys(this.settings), n = Object.keys(e);
|
|
387
|
+
if (!s.some((o) => n.includes(o)) && n.length === 1) {
|
|
388
|
+
const o = n[0];
|
|
389
|
+
i = e[o];
|
|
390
|
+
}
|
|
391
|
+
this.setValue(i);
|
|
386
392
|
} catch (e) {
|
|
387
393
|
throw console.error("Invalid JSON provided to setJson:", e), new Error("Invalid JSON format");
|
|
388
394
|
}
|
|
389
395
|
}
|
|
390
396
|
};
|
|
391
|
-
|
|
392
|
-
let m =
|
|
393
|
-
function
|
|
397
|
+
w.hiddenElements = /* @__PURE__ */ new Set();
|
|
398
|
+
let m = w;
|
|
399
|
+
function $(c) {
|
|
394
400
|
return new m(c);
|
|
395
401
|
}
|
|
396
402
|
function lt(c) {
|
|
397
403
|
return c;
|
|
398
404
|
}
|
|
399
|
-
class
|
|
405
|
+
class O extends g {
|
|
400
406
|
constructor(t = {}) {
|
|
401
407
|
super(t), this.inputType = "text", t.onChange && this.setOnChange(t.onChange);
|
|
402
408
|
}
|
|
@@ -417,27 +423,48 @@ class H extends g {
|
|
|
417
423
|
}
|
|
418
424
|
}
|
|
419
425
|
const N = "<svg xmlns='http://www.w3.org/2000/svg' width='18' height='19' viewBox='0 0 18 19' fill='none'><path d='M8.99999 15.8542C9.79613 16.5667 10.8475 17 12 17C14.4853 17 16.5 14.9853 16.5 12.5C16.5 10.4248 15.0953 8.67769 13.1849 8.15763M4.81513 8.15762C2.9047 8.67768 1.5 10.4248 1.5 12.5C1.5 14.9853 3.51472 17 6 17C8.48528 17 10.5 14.9853 10.5 12.5C10.5 11.9146 10.3882 11.3554 10.1849 10.8424M13.5 6.5C13.5 8.98528 11.4853 11 9 11C6.51472 11 4.5 8.98528 4.5 6.5C4.5 4.01472 6.51472 2 9 2C11.4853 2 13.5 4.01472 13.5 6.5Z' stroke='#667085' stroke-linecap='round' stroke-linejoin='round'/></svg>";
|
|
420
|
-
class
|
|
426
|
+
class k extends O {
|
|
421
427
|
constructor(t) {
|
|
422
428
|
super({
|
|
423
429
|
...t,
|
|
424
430
|
icon: t.icon || N,
|
|
425
|
-
title: t.title || "Color"
|
|
431
|
+
title: t.title || "Color",
|
|
432
|
+
// Normalize the default value if it's provided
|
|
433
|
+
default: t.default ? k.normalizeRgbValue(t.default) : t.default
|
|
426
434
|
}), this.inputType = "color", this.element = null, this.detectChange = t.detectChange;
|
|
427
435
|
}
|
|
436
|
+
static normalizeRgbValue(t) {
|
|
437
|
+
const e = t.split(",").map((r) => parseInt(r.trim()));
|
|
438
|
+
if (e.length !== 3 || e.some(isNaN))
|
|
439
|
+
return console.warn(`Invalid RGB value "${t}", using default "0, 0, 0"`), "0, 0, 0";
|
|
440
|
+
const [i, s, n] = e, a = Math.max(0, Math.min(255, i)), o = Math.max(0, Math.min(255, s)), l = Math.max(0, Math.min(255, n));
|
|
441
|
+
return `${a}, ${o}, ${l}`;
|
|
442
|
+
}
|
|
443
|
+
// Override setValue to validate and normalize RGB values
|
|
444
|
+
setValue(t) {
|
|
445
|
+
if (t === void 0) {
|
|
446
|
+
super.setValue("");
|
|
447
|
+
return;
|
|
448
|
+
}
|
|
449
|
+
if (typeof t == "string") {
|
|
450
|
+
const e = k.normalizeRgbValue(t);
|
|
451
|
+
super.setValue(e);
|
|
452
|
+
} else
|
|
453
|
+
super.setValue("");
|
|
454
|
+
}
|
|
428
455
|
hexToRgb(t) {
|
|
429
456
|
t = t.replace("#", "");
|
|
430
457
|
const e = parseInt(t.substring(0, 2), 16), i = parseInt(t.substring(2, 4), 16), s = parseInt(t.substring(4, 6), 16);
|
|
431
458
|
return `${e}, ${i}, ${s}`;
|
|
432
459
|
}
|
|
433
460
|
rgbToHex(t) {
|
|
434
|
-
const
|
|
435
|
-
if (
|
|
436
|
-
const n = (
|
|
437
|
-
const
|
|
438
|
-
return
|
|
461
|
+
const e = t.split(",").map((h) => parseInt(h.trim()));
|
|
462
|
+
if (e.length !== 3 || e.some(isNaN)) return "#000000";
|
|
463
|
+
const [i, s, n] = e, a = Math.max(0, Math.min(255, i)), o = Math.max(0, Math.min(255, s)), l = Math.max(0, Math.min(255, n)), r = (h) => {
|
|
464
|
+
const u = h.toString(16);
|
|
465
|
+
return u.length === 1 ? "0" + u : u;
|
|
439
466
|
};
|
|
440
|
-
return `#${
|
|
467
|
+
return `#${r(a)}${r(o)}${r(l)}`;
|
|
441
468
|
}
|
|
442
469
|
draw() {
|
|
443
470
|
const t = document.createElement("div");
|
|
@@ -449,11 +476,14 @@ class O extends H {
|
|
|
449
476
|
const n = document.createElement("div");
|
|
450
477
|
n.className = "color-input-wrapper";
|
|
451
478
|
const a = (d) => {
|
|
452
|
-
const f = d.value.
|
|
453
|
-
if (f
|
|
479
|
+
const f = d.value.trim();
|
|
480
|
+
if (!f)
|
|
481
|
+
return d.style.border = "", !0;
|
|
482
|
+
const p = f.split(",").map((b) => parseInt(b.trim()));
|
|
483
|
+
if (p.length !== 3 || p.some(isNaN))
|
|
454
484
|
return d.style.border = "1px solid red", !1;
|
|
455
|
-
const [
|
|
456
|
-
return d.style.border =
|
|
485
|
+
const [C, v, T] = p, E = C >= 0 && C <= 255 && v >= 0 && v <= 255 && T >= 0 && T <= 255;
|
|
486
|
+
return d.style.border = E ? "" : "1px solid red", E;
|
|
457
487
|
}, o = document.createElement("div");
|
|
458
488
|
o.className = "color-preview", o.style.backgroundColor = this.value ? `rgb(${this.value})` : "";
|
|
459
489
|
const l = this.createInput({
|
|
@@ -465,7 +495,7 @@ class O extends H {
|
|
|
465
495
|
);
|
|
466
496
|
r.readOnly = !0;
|
|
467
497
|
const h = this.createInput({
|
|
468
|
-
value: this.value ? this.rgbToHex(this.value) : "",
|
|
498
|
+
value: this.value ? this.rgbToHex(this.value) : "#000000",
|
|
469
499
|
inputType: this.inputType,
|
|
470
500
|
inputClassName: "color-picker"
|
|
471
501
|
}), u = h.querySelector(
|
|
@@ -488,8 +518,20 @@ class O extends H {
|
|
|
488
518
|
getElement() {
|
|
489
519
|
return this.element;
|
|
490
520
|
}
|
|
521
|
+
// Helper method to get normalized RGB value
|
|
522
|
+
getNormalizedValue() {
|
|
523
|
+
return this.value ? k.normalizeRgbValue(this.value) : "0, 0, 0";
|
|
524
|
+
}
|
|
525
|
+
// Helper method to check if current value is valid RGB
|
|
526
|
+
isValidRgb() {
|
|
527
|
+
if (!this.value) return !1;
|
|
528
|
+
const t = this.value.split(",").map((n) => parseInt(n.trim()));
|
|
529
|
+
if (t.length !== 3 || t.some(isNaN)) return !1;
|
|
530
|
+
const [e, i, s] = t;
|
|
531
|
+
return e >= 0 && e <= 255 && i >= 0 && i <= 255 && s >= 0 && s <= 255;
|
|
532
|
+
}
|
|
491
533
|
}
|
|
492
|
-
class
|
|
534
|
+
class x extends g {
|
|
493
535
|
constructor(t) {
|
|
494
536
|
super(t), this.inputType = "number", this.inputElement = null, this.mobileValue = t.mobile, this.validateProps(), this.value = this.validateValue(this.value);
|
|
495
537
|
}
|
|
@@ -539,12 +581,12 @@ class w extends g {
|
|
|
539
581
|
this.props.minValue !== void 0 && (this.props.default ?? 0) < this.props.minValue && console.warn(`Default value ${this.props.default} is less than minValue ${this.props.minValue}`), this.props.maxValue !== void 0 && (this.props.default ?? 0) > this.props.maxValue && console.warn(`Default value ${this.props.default} is greater than maxValue ${this.props.maxValue}`);
|
|
540
582
|
}
|
|
541
583
|
}
|
|
542
|
-
const
|
|
584
|
+
const _ = `
|
|
543
585
|
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
544
586
|
<path d="M9 17C13.4183 17 17 13.4183 17 9C17 4.58172 13.4183 1 9 1C4.58172 1 1 4.58172 1 9C1 13.4183 4.58172 17 9 17Z" stroke="#667085" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
545
587
|
<path d="M9 1V17C4.58172 17 1 13.4183 1 9C1 4.58172 4.58172 1 9 1Z" fill="#667085" stroke="#667085" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
546
588
|
</svg>`;
|
|
547
|
-
class
|
|
589
|
+
class M extends x {
|
|
548
590
|
constructor(t = {}) {
|
|
549
591
|
const e = {
|
|
550
592
|
title: "Opacity",
|
|
@@ -553,7 +595,7 @@ class y extends w {
|
|
|
553
595
|
maxValue: 100,
|
|
554
596
|
step: 1,
|
|
555
597
|
default: t.default ?? 100,
|
|
556
|
-
icon:
|
|
598
|
+
icon: _,
|
|
557
599
|
...t
|
|
558
600
|
};
|
|
559
601
|
super(e), this.inputType = "number", this.mobileValue = t.mobile;
|
|
@@ -724,14 +766,14 @@ class ht extends g {
|
|
|
724
766
|
this.value || (this.value = {
|
|
725
767
|
width: e,
|
|
726
768
|
height: i
|
|
727
|
-
}), this.minWidth = t.minWidth ?? 0, this.maxWidth = t.maxWidth, this.minHeight = t.minHeight ?? 0, this.maxHeight = t.maxHeight, this.locked = t.locked ?? !1, this.value.height > 0 && (this.aspectRatio = this.value.width / this.value.height), this.widthSetting = new
|
|
769
|
+
}), this.minWidth = t.minWidth ?? 0, this.maxWidth = t.maxWidth, this.minHeight = t.minHeight ?? 0, this.maxHeight = t.maxHeight, this.locked = t.locked ?? !1, this.value.height > 0 && (this.aspectRatio = this.value.width / this.value.height), this.widthSetting = new x({
|
|
728
770
|
title: "Width",
|
|
729
771
|
default: this.value.width,
|
|
730
772
|
suffix: "px",
|
|
731
773
|
minValue: this.minWidth,
|
|
732
774
|
maxValue: this.maxWidth,
|
|
733
775
|
icon: G
|
|
734
|
-
}), this.heightSetting = new
|
|
776
|
+
}), this.heightSetting = new x({
|
|
735
777
|
title: "Height",
|
|
736
778
|
default: this.value.height,
|
|
737
779
|
suffix: "px",
|
|
@@ -833,7 +875,7 @@ const G = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBo
|
|
|
833
875
|
<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="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
|
|
834
876
|
</svg>`, q = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
835
877
|
<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="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
|
|
836
|
-
</svg>`,
|
|
878
|
+
</svg>`, H = `
|
|
837
879
|
<svg xmlns="http://www.w3.org/2000/svg" width="15" height="16" viewBox="0 0 15 16" fill="none">
|
|
838
880
|
<path d="M5 10.5L7.5 8M7.5 8L10 10.5M7.5 8V13.625M12.5 10.9643C13.2634 10.3338 13.75 9.37996 13.75 8.3125C13.75 6.41402 12.211 4.875 10.3125 4.875C10.1759 4.875 10.0482 4.80375 9.97882 4.68609C9.16379 3.30302 7.65902 2.375 5.9375 2.375C3.34867 2.375 1.25 4.47367 1.25 7.0625C1.25 8.35381 1.77215 9.52317 2.61684 10.371" stroke="#475467" stroke-linecap="round" stroke-linejoin="round"/>
|
|
839
881
|
</svg>
|
|
@@ -842,12 +884,12 @@ const G = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBo
|
|
|
842
884
|
<rect width="91" height="71" rx="4" fill="#F2F4F7"/>
|
|
843
885
|
<path d="M37 31.5L39.5 29M39.5 29L42 31.5M39.5 29V34.625M44.5 31.9643C45.2634 31.3338 45.75 30.38 45.75 29.3125C45.75 27.414 44.211 25.875 42.3125 25.875C42.1759 25.875 42.0482 25.8037 41.9788 25.6861C41.1638 24.303 39.659 23.375 37.9375 23.375C35.3487 23.375 33.25 25.4737 33.25 28.0625C33.25 29.3538 33.7721 30.5232 34.6168 31.371" stroke="#475467" stroke-linecap="round" stroke-linejoin="round"/>
|
|
844
886
|
</svg>
|
|
845
|
-
`,
|
|
887
|
+
`, z = `
|
|
846
888
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 12 12" fill="none">
|
|
847
889
|
<path d="M8 3V2.6C8 2.03995 8 1.75992 7.89101 1.54601C7.79513 1.35785 7.64215 1.20487 7.45399 1.10899C7.24008 1 6.96005 1 6.4 1H5.6C5.03995 1 4.75992 1 4.54601 1.10899C4.35785 1.20487 4.20487 1.35785 4.10899 1.54601C4 1.75992 4 2.03995 4 2.6V3M5 5.75V8.25M7 5.75V8.25M1.5 3H10.5M9.5 3V8.6C9.5 9.44008 9.5 9.86012 9.33651 10.181C9.1927 10.4632 8.96323 10.6927 8.68099 10.8365C8.36012 11 7.94008 11 7.1 11H4.9C4.05992 11 3.63988 11 3.31901 10.8365C3.03677 10.6927 2.8073 10.4632 2.66349 10.181C2.5 9.86012 2.5 9.44008 2.5 8.6V3" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
|
|
848
890
|
</svg>
|
|
849
891
|
`;
|
|
850
|
-
class
|
|
892
|
+
class F extends g {
|
|
851
893
|
constructor(t = {}) {
|
|
852
894
|
super(t), this.inputType = "button", this.previewWrapper = null, this.previewEl = null, this.emptyStateEl = null, this.props.delete === void 0 && (this.props.delete = !0), !this.value && t.defaultUrl && t.defaultUrl !== "" && (this.value = t.defaultUrl);
|
|
853
895
|
}
|
|
@@ -857,10 +899,10 @@ class U extends g {
|
|
|
857
899
|
".preview-placeholder"
|
|
858
900
|
);
|
|
859
901
|
t && t !== "" ? (this.previewWrapper.classList.add("has-image"), this.previewEl.src = t, this.previewWrapper.style.display = "block", this.previewEl.style.display = "block", s && s instanceof HTMLElement && (s.style.display = "none"), e && e.classList.remove("no-image"), i && (i.innerHTML = `
|
|
860
|
-
<span class="upload-icon">${
|
|
902
|
+
<span class="upload-icon">${H}</span>
|
|
861
903
|
<span class="upload-label">Replace</span>
|
|
862
904
|
`)) : (this.previewWrapper.classList.remove("has-image"), this.previewEl.src = "", this.previewEl.style.display = "none", this.previewWrapper.style.display = "none", s && s instanceof HTMLElement && (s.style.display = "block"), e && e.classList.add("no-image"), i && (i.innerHTML = `
|
|
863
|
-
<span class="upload-icon">${
|
|
905
|
+
<span class="upload-icon">${H}</span>
|
|
864
906
|
<span class="upload-label">Upload</span>
|
|
865
907
|
`));
|
|
866
908
|
}
|
|
@@ -894,7 +936,7 @@ class U extends g {
|
|
|
894
936
|
const n = document.createElement("div");
|
|
895
937
|
if (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", this.props.delete) {
|
|
896
938
|
const l = document.createElement("button");
|
|
897
|
-
l.className = "delete-button", l.type = "button", l.title = "Delete image", l.innerHTML =
|
|
939
|
+
l.className = "delete-button", l.type = "button", l.title = "Delete image", l.innerHTML = z, this.previewWrapper.appendChild(l), l.onclick = (r) => {
|
|
898
940
|
var h;
|
|
899
941
|
r.stopPropagation(), this.value = "", o.value = "", this.updatePreviewState(null), (h = this.onChange) == null || h.call(this, "");
|
|
900
942
|
};
|
|
@@ -902,7 +944,7 @@ class U extends g {
|
|
|
902
944
|
this.previewWrapper.appendChild(this.previewEl);
|
|
903
945
|
const a = document.createElement("button");
|
|
904
946
|
a.className = "upload-button", a.innerHTML = `
|
|
905
|
-
<span class="upload-icon">${
|
|
947
|
+
<span class="upload-icon">${H}</span>
|
|
906
948
|
<span class="upload-label">Upload</span>
|
|
907
949
|
`;
|
|
908
950
|
const o = document.createElement("input");
|
|
@@ -919,20 +961,20 @@ class U extends g {
|
|
|
919
961
|
const p = this.props.uploadUrl;
|
|
920
962
|
if (!p)
|
|
921
963
|
throw new Error("No uploadUrl provided to UploadSetting.");
|
|
922
|
-
const C = this.props.requestMethod || "POST", v = { ...this.props.requestHeaders || {} },
|
|
964
|
+
const C = this.props.requestMethod || "POST", v = { ...this.props.requestHeaders || {} }, E = await (await fetch(p, {
|
|
923
965
|
method: C,
|
|
924
966
|
body: d,
|
|
925
967
|
headers: v
|
|
926
968
|
})).json();
|
|
927
|
-
console.log("Upload response:",
|
|
928
|
-
let
|
|
969
|
+
console.log("Upload response:", E);
|
|
970
|
+
let b;
|
|
929
971
|
if (this.props.parseResponse)
|
|
930
|
-
|
|
931
|
-
else if (
|
|
972
|
+
b = this.props.parseResponse(E);
|
|
973
|
+
else if (b = (h = E == null ? void 0 : E.data) == null ? void 0 : h.url, !b)
|
|
932
974
|
throw new Error(
|
|
933
975
|
"No URL found in response. Provide a parseResponse if needed."
|
|
934
976
|
);
|
|
935
|
-
console.log("Final URL:",
|
|
977
|
+
console.log("Final URL:", b), this.value = b, this.updatePreviewState(b), (u = this.onChange) == null || u.call(this, b);
|
|
936
978
|
} catch (d) {
|
|
937
979
|
console.error("Error uploading file:", d);
|
|
938
980
|
} finally {
|
|
@@ -943,7 +985,7 @@ class U extends g {
|
|
|
943
985
|
}, t;
|
|
944
986
|
}
|
|
945
987
|
}
|
|
946
|
-
class ct extends
|
|
988
|
+
class ct extends x {
|
|
947
989
|
// Store mobile value
|
|
948
990
|
constructor(t = {}) {
|
|
949
991
|
const e = {
|
|
@@ -951,7 +993,7 @@ class ct extends w {
|
|
|
951
993
|
suffix: "px",
|
|
952
994
|
minValue: t.minValue ?? 0,
|
|
953
995
|
maxValue: t.maxValue,
|
|
954
|
-
icon: t.icon ||
|
|
996
|
+
icon: t.icon || U,
|
|
955
997
|
...t
|
|
956
998
|
};
|
|
957
999
|
super(e), this.inputType = "number", this.mobileValue = t.mobile;
|
|
@@ -960,10 +1002,10 @@ class ct extends w {
|
|
|
960
1002
|
return this.mobileValue;
|
|
961
1003
|
}
|
|
962
1004
|
}
|
|
963
|
-
const
|
|
1005
|
+
const U = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
964
1006
|
<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"/>
|
|
965
1007
|
</svg>`;
|
|
966
|
-
class dt extends
|
|
1008
|
+
class dt extends x {
|
|
967
1009
|
constructor(t = {}) {
|
|
968
1010
|
super({
|
|
969
1011
|
title: t.title || "Width",
|
|
@@ -1228,7 +1270,7 @@ class gt extends g {
|
|
|
1228
1270
|
return this.mobileValue;
|
|
1229
1271
|
}
|
|
1230
1272
|
}
|
|
1231
|
-
class
|
|
1273
|
+
class V extends m {
|
|
1232
1274
|
constructor(t) {
|
|
1233
1275
|
var o;
|
|
1234
1276
|
if (!t.tabs)
|
|
@@ -1252,7 +1294,7 @@ class k extends m {
|
|
|
1252
1294
|
tabs: this.tabValues,
|
|
1253
1295
|
activeTabId: this.activeTabId
|
|
1254
1296
|
}, Object.values(e.settings).forEach((i) => {
|
|
1255
|
-
i instanceof
|
|
1297
|
+
i instanceof V && (i._parentTabsSettings = this);
|
|
1256
1298
|
}), this.connectChildChangeHandlers());
|
|
1257
1299
|
}
|
|
1258
1300
|
connectChildChangeHandlers() {
|
|
@@ -1277,7 +1319,7 @@ class k extends m {
|
|
|
1277
1319
|
});
|
|
1278
1320
|
}), this.tabs.forEach((e) => {
|
|
1279
1321
|
Object.entries(e.settings).forEach(([i, s]) => {
|
|
1280
|
-
(s instanceof m || s instanceof g) && (s instanceof
|
|
1322
|
+
(s instanceof m || s instanceof g) && (s instanceof V ? (s._parentTabsSettings = this, s.setOnChange((n) => {
|
|
1281
1323
|
Promise.resolve().then(() => {
|
|
1282
1324
|
this.tabValues[e.id] = this.getTabValues(e), this.triggerDebouncedChange();
|
|
1283
1325
|
});
|
|
@@ -1372,7 +1414,7 @@ class k extends m {
|
|
|
1372
1414
|
activeTabId: this.activeTabId
|
|
1373
1415
|
}, this.tabs.forEach((t) => {
|
|
1374
1416
|
Object.values(t.settings).forEach((e) => {
|
|
1375
|
-
e instanceof
|
|
1417
|
+
e instanceof V && e.updateInitialValues();
|
|
1376
1418
|
});
|
|
1377
1419
|
}));
|
|
1378
1420
|
}
|
|
@@ -1390,7 +1432,7 @@ class k extends m {
|
|
|
1390
1432
|
getTabValues(t) {
|
|
1391
1433
|
const e = {};
|
|
1392
1434
|
return Object.entries(t.settings).forEach(([i, s]) => {
|
|
1393
|
-
s instanceof
|
|
1435
|
+
s instanceof V || s instanceof m ? e[i] = s.getValues() : (s instanceof g, e[i] = s.value);
|
|
1394
1436
|
}), e;
|
|
1395
1437
|
}
|
|
1396
1438
|
clone() {
|
|
@@ -1416,7 +1458,7 @@ class k extends m {
|
|
|
1416
1458
|
hideCondition: this.hideCondition,
|
|
1417
1459
|
settings: {}
|
|
1418
1460
|
};
|
|
1419
|
-
return new
|
|
1461
|
+
return new V(
|
|
1420
1462
|
e
|
|
1421
1463
|
);
|
|
1422
1464
|
}
|
|
@@ -1472,7 +1514,7 @@ class k extends m {
|
|
|
1472
1514
|
const X = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
1473
1515
|
<path d="M2.25 11.75H15.75M5.85 2.75H12.15C13.4101 2.75 14.0402 2.75 14.5215 2.99524C14.9448 3.21095 15.289 3.55516 15.5048 3.97852C15.75 4.45982 15.75 5.08988 15.75 6.35V12.65C15.75 13.9101 15.75 14.5402 15.5048 15.0215C15.289 15.4448 14.9448 15.789 14.5215 16.0048C14.0402 16.25 13.4101 16.25 12.15 16.25H5.85C4.58988 16.25 3.95982 16.25 3.47852 16.0048C3.05516 15.789 2.71095 15.4448 2.49524 15.0215C2.25 14.5402 2.25 13.9101 2.25 12.65V6.35C2.25 5.08988 2.25 4.45982 2.49524 3.97852C2.71095 3.55516 3.05516 3.21095 3.47852 2.99524C3.95982 2.75 4.58988 2.75 5.85 2.75Z" stroke="#667085" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
1474
1516
|
</svg>`;
|
|
1475
|
-
class mt extends
|
|
1517
|
+
class mt extends x {
|
|
1476
1518
|
constructor(t = {}) {
|
|
1477
1519
|
super({
|
|
1478
1520
|
...t,
|
|
@@ -1485,11 +1527,11 @@ class mt extends w {
|
|
|
1485
1527
|
}), this.inputType = "number";
|
|
1486
1528
|
}
|
|
1487
1529
|
}
|
|
1488
|
-
const
|
|
1530
|
+
const K = `
|
|
1489
1531
|
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
1490
1532
|
<path d="M5.625 9.5H5.6325M12.375 9.5H12.3825M9 9.5H9.0075M9 12.875H9.0075M9 6.125H9.0075M2.25 6.35L2.25 12.65C2.25 13.9101 2.25 14.5402 2.49524 15.0215C2.71095 15.4448 3.05516 15.789 3.47852 16.0048C3.95982 16.25 4.58988 16.25 5.85 16.25H12.15C13.4101 16.25 14.0402 16.25 14.5215 16.0048C14.9448 15.789 15.289 15.4448 15.5048 15.0215C15.75 14.5402 15.75 13.9101 15.75 12.65V6.35C15.75 5.08988 15.75 4.45982 15.5048 3.97852C15.289 3.55516 14.9448 3.21095 14.5215 2.99524C14.0402 2.75 13.4101 2.75 12.15 2.75L5.85 2.75C4.58988 2.75 3.95982 2.75 3.47852 2.99524C3.05516 3.21095 2.71095 3.55516 2.49524 3.97852C2.25 4.45982 2.25 5.08988 2.25 6.35Z" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
|
|
1491
1533
|
</svg>
|
|
1492
|
-
`,
|
|
1534
|
+
`, Q = `
|
|
1493
1535
|
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
1494
1536
|
<path d="M6 2.75H5.85C4.58988 2.75 3.95982 2.75 3.47852 2.99524C3.05516 3.21095 2.71095 3.55516 2.49524 3.97852C2.25 4.45982 2.25 5.08988 2.25 6.35V6.5M6 16.25H5.85C4.58988 16.25 3.95982 16.25 3.47852 16.0048C3.05516 15.789 2.71095 15.4448 2.49524 15.0215C2.25 14.5402 2.25 13.9101 2.25 12.65V12.5M15.75 6.5V6.35C15.75 5.08988 15.75 4.45982 15.5048 3.97852C15.289 3.55516 14.9448 3.21095 14.5215 2.99524C14.0402 2.75 13.4101 2.75 12.15 2.75H12M15.75 12.5V12.65C15.75 13.9101 15.75 14.5402 15.5048 15.0215C15.289 15.4448 14.9448 15.789 14.5215 16.0048C14.0402 16.25 13.4101 16.25 12.15 16.25H12" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
|
|
1495
1537
|
</svg>
|
|
@@ -1501,23 +1543,23 @@ class ft extends m {
|
|
|
1501
1543
|
collapsed: t == null ? void 0 : t.collapsed,
|
|
1502
1544
|
hideCondition: t == null ? void 0 : t.hideCondition,
|
|
1503
1545
|
settings: {
|
|
1504
|
-
size: new
|
|
1546
|
+
size: new x({
|
|
1505
1547
|
title: "Size",
|
|
1506
|
-
icon:
|
|
1548
|
+
icon: Q,
|
|
1507
1549
|
default: (t == null ? void 0 : t.size) ?? 0,
|
|
1508
1550
|
suffix: "px"
|
|
1509
1551
|
}),
|
|
1510
|
-
color: new
|
|
1552
|
+
color: new k({
|
|
1511
1553
|
default: (t == null ? void 0 : t.color) ?? "0, 0, 30"
|
|
1512
1554
|
}),
|
|
1513
|
-
opacity: new
|
|
1555
|
+
opacity: new M({
|
|
1514
1556
|
default: (t == null ? void 0 : t.opacity) ?? 100,
|
|
1515
1557
|
minValue: 0,
|
|
1516
1558
|
maxValue: 100
|
|
1517
1559
|
}),
|
|
1518
|
-
radius: new
|
|
1560
|
+
radius: new x({
|
|
1519
1561
|
title: "Radius",
|
|
1520
|
-
icon:
|
|
1562
|
+
icon: K,
|
|
1521
1563
|
default: (t == null ? void 0 : t.radius) ?? 12,
|
|
1522
1564
|
suffix: "px"
|
|
1523
1565
|
})
|
|
@@ -1537,7 +1579,7 @@ class ft extends m {
|
|
|
1537
1579
|
`;
|
|
1538
1580
|
}
|
|
1539
1581
|
}
|
|
1540
|
-
const
|
|
1582
|
+
const Y = `
|
|
1541
1583
|
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="13" viewBox="0 0 14 13" fill="none">
|
|
1542
1584
|
<path d="M1 2.75C1 2.05109 1 1.70163 1.11418 1.42597C1.26642 1.05843 1.55843 0.766422 1.92597 0.614181C2.20163 0.5 2.55109 0.5 3.25 0.5H10.75C11.4489 0.5 11.7984 0.5 12.074 0.614181C12.4416 0.766422 12.7336 1.05843 12.8858 1.42597C13 1.70163 13 2.05109 13 2.75M4.75 12.5H9.25M7 0.5V12.5" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
|
|
1543
1585
|
</svg>
|
|
@@ -1557,15 +1599,15 @@ class Ct extends m {
|
|
|
1557
1599
|
collapsed: t.collapsed,
|
|
1558
1600
|
hideCondition: t.hideCondition,
|
|
1559
1601
|
settings: {
|
|
1560
|
-
color: new
|
|
1602
|
+
color: new k({
|
|
1561
1603
|
default: t.colorDefault ?? "0, 0, 30"
|
|
1562
1604
|
}),
|
|
1563
|
-
opacity: new
|
|
1605
|
+
opacity: new M({
|
|
1564
1606
|
default: t.colorOpacityDefault ?? 100
|
|
1565
1607
|
}),
|
|
1566
1608
|
fontFamily: new I({
|
|
1567
1609
|
title: "Font",
|
|
1568
|
-
icon:
|
|
1610
|
+
icon: Y,
|
|
1569
1611
|
default: t.fontFamilyDefault ?? "Satoshi",
|
|
1570
1612
|
options: t.fontFamilyOptions ?? [
|
|
1571
1613
|
{ name: "Satoshi", value: "Satoshi" },
|
|
@@ -1587,7 +1629,7 @@ class Ct extends m {
|
|
|
1587
1629
|
getOptions: t.fontWeightGetOptions,
|
|
1588
1630
|
getOptionsAsync: t.fontWeightGetOptionsAsync
|
|
1589
1631
|
}),
|
|
1590
|
-
fontSize: new
|
|
1632
|
+
fontSize: new x({
|
|
1591
1633
|
title: "Size",
|
|
1592
1634
|
icon: et,
|
|
1593
1635
|
default: t.fontSizeDefault ?? 12,
|
|
@@ -1743,17 +1785,17 @@ class bt extends m {
|
|
|
1743
1785
|
collapsed: t == null ? void 0 : t.collapsed,
|
|
1744
1786
|
hideCondition: t == null ? void 0 : t.hideCondition,
|
|
1745
1787
|
settings: {
|
|
1746
|
-
backgroundImage: new
|
|
1788
|
+
backgroundImage: new F({
|
|
1747
1789
|
...t == null ? void 0 : t.uploadProps,
|
|
1748
1790
|
default: (t == null ? void 0 : t.backgroundImage) ?? ""
|
|
1749
1791
|
}),
|
|
1750
|
-
opacity: new
|
|
1792
|
+
opacity: new M({
|
|
1751
1793
|
default: (t == null ? void 0 : t.opacity) ?? 100
|
|
1752
1794
|
}),
|
|
1753
|
-
backgroundColor: new
|
|
1795
|
+
backgroundColor: new k({
|
|
1754
1796
|
default: (t == null ? void 0 : t.backgroundColor) ?? "0, 0, 30"
|
|
1755
1797
|
}),
|
|
1756
|
-
opacityBG: new
|
|
1798
|
+
opacityBG: new M({
|
|
1757
1799
|
default: (t == null ? void 0 : t.opacityBG) ?? 100
|
|
1758
1800
|
})
|
|
1759
1801
|
}
|
|
@@ -1793,11 +1835,11 @@ class ot extends m {
|
|
|
1793
1835
|
hideCondition: i == null ? void 0 : i.hideCondition,
|
|
1794
1836
|
collapsed: i == null ? void 0 : i.collapsed,
|
|
1795
1837
|
settings: {
|
|
1796
|
-
name: new
|
|
1838
|
+
name: new O({
|
|
1797
1839
|
title: "Tab Name",
|
|
1798
1840
|
default: `Tab ${t + 1}`
|
|
1799
1841
|
}),
|
|
1800
|
-
content: new
|
|
1842
|
+
content: new O({
|
|
1801
1843
|
title: "Content",
|
|
1802
1844
|
default: ""
|
|
1803
1845
|
})
|
|
@@ -1910,28 +1952,28 @@ export {
|
|
|
1910
1952
|
bt as BackgroundSettingSet,
|
|
1911
1953
|
ft as BorderSettingSet,
|
|
1912
1954
|
rt as ButtonSetting,
|
|
1913
|
-
|
|
1955
|
+
k as ColorSetting,
|
|
1914
1956
|
ht as DimensionSetting,
|
|
1915
1957
|
gt as GapSetting,
|
|
1916
1958
|
Ct as HeaderTypographySettingSet,
|
|
1917
1959
|
ct as HeightSetting,
|
|
1918
1960
|
mt as MarginBottomSetting,
|
|
1919
1961
|
vt as MarginSettingGroup,
|
|
1920
|
-
|
|
1921
|
-
|
|
1962
|
+
x as NumberSetting,
|
|
1963
|
+
M as OpacitySetting,
|
|
1922
1964
|
ut as SelectApiSettings,
|
|
1923
1965
|
I as SelectSetting,
|
|
1924
1966
|
g as Setting,
|
|
1925
1967
|
m as SettingGroup,
|
|
1926
|
-
|
|
1968
|
+
O as StringSetting,
|
|
1927
1969
|
wt as TabsContainerGroup,
|
|
1928
|
-
|
|
1970
|
+
V as TabsSettings,
|
|
1929
1971
|
pt as Toggle,
|
|
1930
|
-
|
|
1972
|
+
F as UploadSetting,
|
|
1931
1973
|
dt as WidthSetting,
|
|
1932
1974
|
lt as asSettingGroupWithSettings,
|
|
1933
|
-
|
|
1975
|
+
$ as createSettingGroup,
|
|
1934
1976
|
Et as isSetting,
|
|
1935
1977
|
xt as isSettingGroup,
|
|
1936
|
-
|
|
1978
|
+
S as iterateSettings
|
|
1937
1979
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -104,10 +104,14 @@ export declare class ColorSetting extends StringSetting {
|
|
|
104
104
|
detectChange?: (value: string | undefined) => void;
|
|
105
105
|
private element;
|
|
106
106
|
constructor(props: ColorSettingProps);
|
|
107
|
+
private static normalizeRgbValue;
|
|
108
|
+
setValue(newValue: string | undefined): void;
|
|
107
109
|
private hexToRgb;
|
|
108
110
|
private rgbToHex;
|
|
109
111
|
draw(): HTMLElement;
|
|
110
112
|
getElement(): HTMLElement | null;
|
|
113
|
+
getNormalizedValue(): string;
|
|
114
|
+
isValidRgb(): boolean;
|
|
111
115
|
}
|
|
112
116
|
|
|
113
117
|
export declare interface ColorSettingProps extends StringSettingsProps {
|
package/package.json
CHANGED