builder-settings-types 0.0.161 → 0.0.162
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.
|
@@ -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 j="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let B=(c=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(c|=0));for(;c--;)t+=j[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 G(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||G(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 L(c,t){for(const e in c)if(c.hasOwnProperty(e)){const i=c[e];t(e,i)}}const C=class C{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(),L(this.settings,(i,s)=>{var n;if(s instanceof C)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),L(this.settings,(t,e)=>{var i;if(e instanceof C)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={};L(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 C||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 C?e[i]=s.getValues():e[i]=s.value}return e}else{const e=this.settings[t];return e?e instanceof C?e.getValues():e.value:void 0}}getMobileValues(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 C?e[i]=s.getMobileValues():typeof s.getMobileValue=="function"&&(e[i]=s.getMobileValue())}return e}else{const e=this.settings[t];return e?e instanceof C?e.getMobileValues():typeof e.getMobileValue=="function"?e.getMobileValue():void 0:void 0}}setMobileValues(t){!t||typeof t!="object"||Object.entries(t).forEach(([e,i])=>{const s=this.settings[e];s&&(s instanceof C?typeof i=="object"&&i!==null&&s.setMobileValues(i):typeof s.setMobileValue=="function"&&s.setMobileValue(i))})}draw(){const t=document.createElement("div");t.className="setting-group",t.id=`setting-group-${this.id}`,C.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);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")}}};
|
|
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")}}};C.hiddenElements=new Set;let m=C;function R(c){return new m(c)}function _(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(x=>parseInt(x.trim()));if(p.length!==3||p.some(isNaN))return d.style.border="1px solid red",!1;const[v,b,H]=p,E=v>=0&&v<=255&&b>=0&&b<=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 v,b;const f=d.target.value,p=this.hexToRgb(f);this.value=p,(v=this.onChange)==null||v.call(this,p),(b=this.detectChange)==null||b.call(this,p),r.value=p,o.style.backgroundColor=`rgb(${p})`},u.onchange=d=>{var v,b;const f=d.target.value,p=this.hexToRgb(f);this.value=p,(v=this.onChange)==null||v.call(this,p),(b=this.detectChange)==null||b.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 w 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 y extends
|
|
19
|
+
</svg>`;class y extends w{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,7 +41,7 @@
|
|
|
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 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
|
|
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 w({title:"Width",default:this.value.width,suffix:"px",minValue:this.minWidth,maxValue:this.maxWidth,icon:F}),this.heightSetting=new w({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>`:`
|
|
@@ -73,9 +73,9 @@
|
|
|
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
|
|
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 v=this.props.requestMethod||"POST",b={...this.props.requestHeaders||{}},E=await(await fetch(p,{method:v,body:d,headers:b})).json();console.log("Upload response:",E);let x;if(this.props.parseResponse)x=this.props.parseResponse(E);else if(x=(h=E==null?void 0:E.data)==null?void 0:h.url,!x)throw new Error("No URL found in response. Provide a parseResponse if needed.");console.log("Final URL:",x),this.value=x,this.updatePreviewState(x),(u=this.onChange)==null||u.call(this,x)}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 w{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 K extends
|
|
78
|
+
</svg>`;class K extends w{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
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">
|
|
@@ -92,7 +92,7 @@
|
|
|
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
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
|
-
</svg>`;class at extends
|
|
95
|
+
</svg>`;class at extends w{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">
|
|
97
97
|
<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"/>
|
|
98
98
|
</svg>
|
|
@@ -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
|
|
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 w({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 w({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 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
|
|
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 w({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 M 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 M({title:"Top",icon:gt,suffix:"px",default:(t==null?void 0:t.marginTop)??"auto"}),marginRight:new M({title:"Right",icon:mt,suffix:"px",default:(t==null?void 0:t.marginRight)??0}),marginBottom:new M({title:"Bottom",icon:ft,suffix:"px",default:(t==null?void 0:t.marginBottom)??0}),marginLeft:new M({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};
|
|
@@ -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=k;exports.DimensionSetting=z;exports.GapSetting=st;exports.HeaderTypographySettingSet=ut;exports.HeightSetting=Z;exports.MarginBottomSetting=at;exports.MarginSettingGroup=pt;exports.NumberSetting=
|
|
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=w;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=_;exports.createSettingGroup=R;exports.isSetting=Et;exports.isSettingGroup=xt;exports.iterateSettings=L;
|
|
@@ -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 L(c) {
|
|
9
9
|
if (c === null || typeof c != "object")
|
|
10
10
|
return c;
|
|
11
11
|
if (c instanceof Date)
|
|
@@ -13,12 +13,12 @@ function y(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] = L(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] = L(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 = L(this.props), i = new t(e);
|
|
62
|
+
return i.value = L(this.value), i;
|
|
63
63
|
}
|
|
64
64
|
createInput(t) {
|
|
65
65
|
t = { ...this.props.inputProps, ...t };
|
|
@@ -127,7 +127,7 @@ function S(c, t) {
|
|
|
127
127
|
t(e, i);
|
|
128
128
|
}
|
|
129
129
|
}
|
|
130
|
-
const
|
|
130
|
+
const C = class C {
|
|
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();
|
|
@@ -155,7 +155,7 @@ const w = class w {
|
|
|
155
155
|
};
|
|
156
156
|
return this.changeHandlers.clear(), S(this.settings, (i, s) => {
|
|
157
157
|
var n;
|
|
158
|
-
if (s instanceof
|
|
158
|
+
if (s instanceof C)
|
|
159
159
|
s.setOnChange((a) => {
|
|
160
160
|
const o = this.getValues();
|
|
161
161
|
this.initialValues = o, t(o);
|
|
@@ -190,7 +190,7 @@ const w = class w {
|
|
|
190
190
|
!0
|
|
191
191
|
), S(this.settings, (t, e) => {
|
|
192
192
|
var i;
|
|
193
|
-
if (e instanceof
|
|
193
|
+
if (e instanceof C)
|
|
194
194
|
e.setOnBlur(this.handleBlur);
|
|
195
195
|
else {
|
|
196
196
|
const s = (i = this.elementRef) == null ? void 0 : i.querySelector(
|
|
@@ -233,7 +233,7 @@ const w = class w {
|
|
|
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 C || 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,37 @@ const w = class w {
|
|
|
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 C ? 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 C ? e.getValues() : e.value : void 0;
|
|
272
272
|
}
|
|
273
273
|
}
|
|
274
|
+
getMobileValues(t) {
|
|
275
|
+
if (t === void 0) {
|
|
276
|
+
const e = {};
|
|
277
|
+
for (const i in this.settings)
|
|
278
|
+
if (this.settings.hasOwnProperty(i)) {
|
|
279
|
+
const s = this.settings[i];
|
|
280
|
+
s instanceof C ? e[i] = s.getMobileValues() : typeof s.getMobileValue == "function" && (e[i] = s.getMobileValue());
|
|
281
|
+
}
|
|
282
|
+
return e;
|
|
283
|
+
} else {
|
|
284
|
+
const e = this.settings[t];
|
|
285
|
+
return e ? e instanceof C ? e.getMobileValues() : typeof e.getMobileValue == "function" ? e.getMobileValue() : void 0 : void 0;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
setMobileValues(t) {
|
|
289
|
+
!t || typeof t != "object" || Object.entries(t).forEach(([e, i]) => {
|
|
290
|
+
const s = this.settings[e];
|
|
291
|
+
s && (s instanceof C ? typeof i == "object" && i !== null && s.setMobileValues(i) : typeof s.setMobileValue == "function" && s.setMobileValue(i));
|
|
292
|
+
});
|
|
293
|
+
}
|
|
274
294
|
draw() {
|
|
275
295
|
const t = document.createElement("div");
|
|
276
|
-
t.className = "setting-group", t.id = `setting-group-${this.id}`,
|
|
296
|
+
t.className = "setting-group", t.id = `setting-group-${this.id}`, C.hiddenElements.add(t), this.hideCondition && this.hideCondition() && (t.style.display = "none"), this.isMain && t.classList.add("main-group");
|
|
277
297
|
const e = document.createElement("div");
|
|
278
298
|
e.className = "setting-group-title", this.isCollapsed && e.classList.add("collapsed-view"), e.setAttribute("role", "button"), e.setAttribute(
|
|
279
299
|
"aria-expanded",
|
|
@@ -384,7 +404,9 @@ const w = class w {
|
|
|
384
404
|
const e = JSON.parse(t);
|
|
385
405
|
let i = e;
|
|
386
406
|
const s = Object.keys(this.settings), n = Object.keys(e);
|
|
387
|
-
if (!s.some(
|
|
407
|
+
if (!s.some(
|
|
408
|
+
(o) => n.includes(o)
|
|
409
|
+
) && n.length === 1) {
|
|
388
410
|
const o = n[0];
|
|
389
411
|
i = e[o];
|
|
390
412
|
}
|
|
@@ -394,8 +416,8 @@ const w = class w {
|
|
|
394
416
|
}
|
|
395
417
|
}
|
|
396
418
|
};
|
|
397
|
-
|
|
398
|
-
let m =
|
|
419
|
+
C.hiddenElements = /* @__PURE__ */ new Set();
|
|
420
|
+
let m = C;
|
|
399
421
|
function $(c) {
|
|
400
422
|
return new m(c);
|
|
401
423
|
}
|
|
@@ -479,10 +501,10 @@ class k extends O {
|
|
|
479
501
|
const f = d.value.trim();
|
|
480
502
|
if (!f)
|
|
481
503
|
return d.style.border = "", !0;
|
|
482
|
-
const p = f.split(",").map((
|
|
504
|
+
const p = f.split(",").map((w) => parseInt(w.trim()));
|
|
483
505
|
if (p.length !== 3 || p.some(isNaN))
|
|
484
506
|
return d.style.border = "1px solid red", !1;
|
|
485
|
-
const [
|
|
507
|
+
const [v, b, T] = p, E = v >= 0 && v <= 255 && b >= 0 && b <= 255 && T >= 0 && T <= 255;
|
|
486
508
|
return d.style.border = E ? "" : "1px solid red", E;
|
|
487
509
|
}, o = document.createElement("div");
|
|
488
510
|
o.className = "color-preview", o.style.backgroundColor = this.value ? `rgb(${this.value})` : "";
|
|
@@ -506,13 +528,13 @@ class k extends O {
|
|
|
506
528
|
let f = d.target.value.trim();
|
|
507
529
|
a(r) && (this.value = f, (p = this.onChange) == null || p.call(this, f), u.value = this.rgbToHex(f), o.style.backgroundColor = `rgb(${f})`);
|
|
508
530
|
}, u.oninput = (d) => {
|
|
509
|
-
var
|
|
531
|
+
var v, b;
|
|
510
532
|
const f = d.target.value, p = this.hexToRgb(f);
|
|
511
|
-
this.value = p, (
|
|
533
|
+
this.value = p, (v = this.onChange) == null || v.call(this, p), (b = this.detectChange) == null || b.call(this, p), r.value = p, o.style.backgroundColor = `rgb(${p})`;
|
|
512
534
|
}, u.onchange = (d) => {
|
|
513
|
-
var
|
|
535
|
+
var v, b;
|
|
514
536
|
const f = d.target.value, p = this.hexToRgb(f);
|
|
515
|
-
this.value = p, (
|
|
537
|
+
this.value = p, (v = this.onChange) == null || v.call(this, p), (b = this.detectChange) == null || b.call(this, p), r.value = p, o.style.backgroundColor = `rgb(${p})`;
|
|
516
538
|
}, 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;
|
|
517
539
|
}
|
|
518
540
|
getElement() {
|
|
@@ -581,7 +603,7 @@ class x extends g {
|
|
|
581
603
|
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}`);
|
|
582
604
|
}
|
|
583
605
|
}
|
|
584
|
-
const
|
|
606
|
+
const j = `
|
|
585
607
|
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
586
608
|
<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"/>
|
|
587
609
|
<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"/>
|
|
@@ -595,7 +617,7 @@ class M extends x {
|
|
|
595
617
|
maxValue: 100,
|
|
596
618
|
step: 1,
|
|
597
619
|
default: t.default ?? 100,
|
|
598
|
-
icon:
|
|
620
|
+
icon: j,
|
|
599
621
|
...t
|
|
600
622
|
};
|
|
601
623
|
super(e), this.inputType = "number", this.mobileValue = t.mobile;
|
|
@@ -604,7 +626,7 @@ class M extends x {
|
|
|
604
626
|
return this.mobileValue;
|
|
605
627
|
}
|
|
606
628
|
}
|
|
607
|
-
const
|
|
629
|
+
const _ = `
|
|
608
630
|
<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">
|
|
609
631
|
<polyline points="6 9 12 15 18 9"></polyline>
|
|
610
632
|
</svg>
|
|
@@ -648,7 +670,7 @@ class I extends g {
|
|
|
648
670
|
o.onclick = (l) => this.selectOption(l, a, e), i.appendChild(o);
|
|
649
671
|
}), t.appendChild(i);
|
|
650
672
|
const s = document.createElement("div");
|
|
651
|
-
return s.classList.add("svg-container"), s.innerHTML =
|
|
673
|
+
return s.classList.add("svg-container"), s.innerHTML = _, t.appendChild(s), this.optionsListEl = i, this.svgContainer = s, this.props.getOptionsAsync && (this.isLoading = !0, this.updateButtonText(), this.props.getOptionsAsync().then((n) => {
|
|
652
674
|
this._options.push(...n), this.isLoading = !1, this.updateOptionsList(), this.updateButtonText();
|
|
653
675
|
}).catch((n) => {
|
|
654
676
|
console.error("Failed to fetch async options:", n), this.isLoading = !1, this.updateButtonText("Failed to load options");
|
|
@@ -961,20 +983,20 @@ class F extends g {
|
|
|
961
983
|
const p = this.props.uploadUrl;
|
|
962
984
|
if (!p)
|
|
963
985
|
throw new Error("No uploadUrl provided to UploadSetting.");
|
|
964
|
-
const
|
|
965
|
-
method:
|
|
986
|
+
const v = this.props.requestMethod || "POST", b = { ...this.props.requestHeaders || {} }, E = await (await fetch(p, {
|
|
987
|
+
method: v,
|
|
966
988
|
body: d,
|
|
967
|
-
headers:
|
|
989
|
+
headers: b
|
|
968
990
|
})).json();
|
|
969
991
|
console.log("Upload response:", E);
|
|
970
|
-
let
|
|
992
|
+
let w;
|
|
971
993
|
if (this.props.parseResponse)
|
|
972
|
-
|
|
973
|
-
else if (
|
|
994
|
+
w = this.props.parseResponse(E);
|
|
995
|
+
else if (w = (h = E == null ? void 0 : E.data) == null ? void 0 : h.url, !w)
|
|
974
996
|
throw new Error(
|
|
975
997
|
"No URL found in response. Provide a parseResponse if needed."
|
|
976
998
|
);
|
|
977
|
-
console.log("Final URL:",
|
|
999
|
+
console.log("Final URL:", w), this.value = w, this.updatePreviewState(w), (u = this.onChange) == null || u.call(this, w);
|
|
978
1000
|
} catch (d) {
|
|
979
1001
|
console.error("Error uploading file:", d);
|
|
980
1002
|
} finally {
|
|
@@ -1655,7 +1677,7 @@ class Ct extends m {
|
|
|
1655
1677
|
`;
|
|
1656
1678
|
}
|
|
1657
1679
|
}
|
|
1658
|
-
class
|
|
1680
|
+
class y extends g {
|
|
1659
1681
|
constructor(t) {
|
|
1660
1682
|
super({
|
|
1661
1683
|
...t,
|
|
@@ -1708,25 +1730,25 @@ class vt extends m {
|
|
|
1708
1730
|
collapsed: t == null ? void 0 : t.collapsed,
|
|
1709
1731
|
hideCondition: t == null ? void 0 : t.hideCondition,
|
|
1710
1732
|
settings: {
|
|
1711
|
-
marginTop: new
|
|
1733
|
+
marginTop: new y({
|
|
1712
1734
|
title: "Top",
|
|
1713
1735
|
icon: it,
|
|
1714
1736
|
suffix: "px",
|
|
1715
1737
|
default: (t == null ? void 0 : t.marginTop) ?? "auto"
|
|
1716
1738
|
}),
|
|
1717
|
-
marginRight: new
|
|
1739
|
+
marginRight: new y({
|
|
1718
1740
|
title: "Right",
|
|
1719
1741
|
icon: st,
|
|
1720
1742
|
suffix: "px",
|
|
1721
1743
|
default: (t == null ? void 0 : t.marginRight) ?? 0
|
|
1722
1744
|
}),
|
|
1723
|
-
marginBottom: new
|
|
1745
|
+
marginBottom: new y({
|
|
1724
1746
|
title: "Bottom",
|
|
1725
1747
|
icon: nt,
|
|
1726
1748
|
suffix: "px",
|
|
1727
1749
|
default: (t == null ? void 0 : t.marginBottom) ?? 0
|
|
1728
1750
|
}),
|
|
1729
|
-
marginLeft: new
|
|
1751
|
+
marginLeft: new y({
|
|
1730
1752
|
title: "Left",
|
|
1731
1753
|
icon: at,
|
|
1732
1754
|
suffix: "px",
|
package/dist/index.d.ts
CHANGED
|
@@ -484,6 +484,8 @@ export declare class SettingGroup<T extends Record<string, Setting<any, any> | S
|
|
|
484
484
|
hide(): void;
|
|
485
485
|
show(): void;
|
|
486
486
|
getValues<K extends keyof T>(childKey?: K): any;
|
|
487
|
+
getMobileValues<K extends keyof T>(childKey?: K): any;
|
|
488
|
+
setMobileValues(values: Record<string, any>): void;
|
|
487
489
|
draw(): HTMLElement;
|
|
488
490
|
collapse(): void;
|
|
489
491
|
expand(): void;
|
package/package.json
CHANGED