builder-settings-types 0.0.136 → 0.0.138
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 +14 -14
- package/dist/builder-settings-types.es.js +157 -169
- package/dist/index.d.ts +3 -0
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let R=(
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let R=(c=21)=>{let t="",e=crypto.getRandomValues(new Uint8Array(c|=0));for(;c--;)t+=_[e[c]&63];return t};function M(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]=M(c[s]);return i}const t={};for(const i in c)Object.prototype.hasOwnProperty.call(c,i)&&(t[i]=M(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 m{constructor(t={}){this.props=t,this.id=t.id||R(),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}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=M(this.props),i=new t(e);return i.value=M(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 a=document.createElement("div");if(a.className="icon-container",t.icon){const o=this.createIcon(t.icon,t.iconClassName);a.appendChild(o)}if(t.title){const o=this.createLabel(t.title,t.labelClassName);a.appendChild(o)}e.appendChild(a)}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=a=>{const o=a.target;let l=o.value;switch(t.inputType){case"number":l=Number(o.value);break;case"color":l=o.value;break;case"date":l=o.value;break;case"select":l=o.value;break;case"text":l=o.value;break;case"button":l=o.value;break;default:l=o.value}this.value=l,this.onChange&&this.onChange(this.value),this.props.detectChange&&this.props.detectChange(this.value)};return s.addEventListener("input",n),s.addEventListener("change",n),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 y(c,t){for(const e in c)if(c.hasOwnProperty(e)){const i=c[e];t(e,i)}}const w=class w{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||R(),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(),y(this.settings,(i,s)=>{var n;if(s instanceof w)s.setOnChange(a=>{const o=this.getValues();this.initialValues=o,t(o)}),this.changeHandlers.add(()=>t(this.getValues()));else if(s instanceof m){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),y(this.settings,(t,e)=>{var i;if(e instanceof w)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={};y(this.settings,(n,a)=>{typeof a.clone=="function"?t[n]=a.clone():(console.warn(`Setting with key '${n}' does not have a clone method. Copying reference.`),t[n]=a)});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=this.constructor,s=new i(e);return s.initialValues=this.getValues(),s}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 w?e[i]=s.getValues():e[i]=s.value}return e}else{const e=this.settings[t];return e?e instanceof w?e.getValues():e.value:void 0}}draw(){const t=document.createElement("div");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");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 r=document.createElement("span");r.className="group-icon",r.innerHTML=this.icon,i.appendChild(r)}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 r=document.createElement("span");r.className="info-marker",r.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"/>
|
|
@@ -7,12 +7,12 @@
|
|
|
7
7
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
8
8
|
<path d="M4 6L8 10L12 6" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
9
9
|
</svg>
|
|
10
|
-
`,this.isCollapsed&&a.classList.add("rotated"),n.appendChild(a);const o=document.createElement("div");if(o.className="setting-group-content",this.isCollapsed&&(o.classList.add("collapsed"),e.classList.add("collapsed-view"),a.classList.add("rotated"),t.classList.add("collapsed")),this.isMain&&o.classList.add("main-content"),this.description&&!this.isCollapsed){const r=document.createElement("div");r.className="setting-group-description",r.textContent=this.description,o.appendChild(r)}const l=()=>{this.isCollapsed=!this.isCollapsed,o.classList.toggle("collapsed"),e.classList.toggle("collapsed-view"),a.classList.toggle("rotated"),t.classList.toggle("collapsed",this.isCollapsed),e.setAttribute("aria-expanded",(!this.isCollapsed).toString());const r=o.querySelector(".setting-group-description"),
|
|
10
|
+
`,this.isCollapsed&&a.classList.add("rotated"),n.appendChild(a);const o=document.createElement("div");if(o.className="setting-group-content",this.isCollapsed&&(o.classList.add("collapsed"),e.classList.add("collapsed-view"),a.classList.add("rotated"),t.classList.add("collapsed")),this.isMain&&o.classList.add("main-content"),this.description&&!this.isCollapsed){const r=document.createElement("div");r.className="setting-group-description",r.textContent=this.description,o.appendChild(r)}const l=()=>{this.isCollapsed=!this.isCollapsed,o.classList.toggle("collapsed"),e.classList.toggle("collapsed-view"),a.classList.toggle("rotated"),t.classList.toggle("collapsed",this.isCollapsed),e.setAttribute("aria-expanded",(!this.isCollapsed).toString());const r=o.querySelector(".setting-group-description"),u=n.querySelector(".info-marker");if(this.description)if(this.isCollapsed){if(r&&r.remove(),!u){const d=document.createElement("span");d.className="info-marker",d.innerHTML=`
|
|
11
11
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
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(!r){const d=document.createElement("div");d.className="setting-group-description",d.textContent=this.description,o.insertBefore(d,o.firstChild)}
|
|
15
|
+
`,d.title=this.description,n.insertBefore(d,a)}}else{if(!r){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=r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),l())},Object.keys(this.settings).length>0){for(const r in this.settings)if(this.settings.hasOwnProperty(r)){const u=this.settings[r];o.appendChild(u.draw())}}else{const r=document.createElement("div");r.className="setting-group-empty",r.textContent="No settings in this group",o.appendChild(r)}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()}};w.hiddenElements=new Set;let f=w;class S extends m{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 B="<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 H extends S{constructor(t){super({...t,icon:t.icon||B,title:t.title||"Color"}),this.inputType="color",this.detectChange=t.detectChange}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,i,s]=t.split(",").map(a=>parseInt(a.trim()));if(isNaN(e)||isNaN(i)||isNaN(s))return"#000000";const n=a=>{const o=a.toString(16);return o.length===1?"0"+o:o};return`#${n(e)}${n(i)}${n(s)}`}draw(){const t=document.createElement("div");t.className="color-setting-wrapper";const e=document.createElement("div");e.className="icon-container";const i=this.createIcon(this.props.icon||B),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 g=d.value.split(",").map(I=>parseInt(I.trim()));if(g.length!==3||g.some(isNaN))return d.style.border="1px solid red",!1;const[p,C,v]=g,V=p>=0&&p<=255&&C>=0&&C<=255&&v>=0&&v<=255;return d.style.border=V?"":"1px solid red",V},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"}),h=l.querySelector("input");h.readOnly=!0;const r=this.createInput({value:this.value?this.rgbToHex(this.value):"",inputType:this.inputType,inputClassName:"color-picker"}),u=r.querySelector("input");return h.oninput=d=>{var p;let g=d.target.value.trim();a(h)&&(this.value=g,(p=this.onChange)==null||p.call(this,g),u.value=this.rgbToHex(g),o.style.backgroundColor=`rgb(${g})`)},u.oninput=d=>{var C,v;const g=d.target.value,p=this.hexToRgb(g);this.value=p,(C=this.onChange)==null||C.call(this,p),(v=this.detectChange)==null||v.call(this,p),h.value=p,o.style.backgroundColor=`rgb(${p})`},u.onchange=d=>{var C,v;const g=d.target.value,p=this.hexToRgb(g);this.value=p,(C=this.onChange)==null||C.call(this,p),(v=this.detectChange)==null||v.call(this,p),h.value=p,o.style.backgroundColor=`rgb(${p})`},n.appendChild(o),n.appendChild(r),n.appendChild(l),t.appendChild(e),t.appendChild(n),this.value&&(h.value=this.value,u.value=this.rgbToHex(this.value),o.style.backgroundColor=`rgb(${this.value})`),t}}class b extends m{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"/>
|
|
@@ -20,7 +20,7 @@
|
|
|
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>
|
|
23
|
-
`;class N extends m{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.clickOutsideListener=null,t.options&&(this._options=[...t.options]),t.getOptions&&this._options.push(...t.getOptions()),t.getOptionsAsync&&(this.isLoading=!0),this.value!==void 0){const e=this._options.findIndex(i=>i.value===this.value);e>=0&&(this.selectedOptionIndex=e)}}createOption(t,e){const i=document.createElement("li");return i.classList.add("select-option"),i.textContent=t.name,i.dataset.index=String(e),this.selectedOptionIndex===e&&i.classList.add("selected"),i}draw(){const t=document.createElement("div");if(t.classList.add("select-container"),this.container=t,this.props.icon||this.props.title){const n=document.createElement("div");if(n.className="icon-container",this.props.icon){const a=this.createIcon(this.props.icon);n.appendChild(a)}if(this.props.title){const a=this.createLabel(this.props.title);n.appendChild(a)}t.appendChild(n)}else{const n=document.createElement("div");t.appendChild(n)}const e=document.createElement("div");e.classList.add("select-button"),this.isLoading?e.classList.add("loading"):e.textContent=this.selectedOptionIndex!==null?this._options[this.selectedOptionIndex].name:this.props.placeholder||"Select an option",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-options"),this._options.forEach((n,a)=>{const o=this.createOption(n,a);o.onclick=l=>this.selectOption(l,a,e),i.appendChild(o)}),t.appendChild(i);const s=document.createElement("div");return s.classList.add("svg-container"),s.innerHTML=G,t.appendChild(s),this.optionsListEl=i,this.svgContainer=s,this.props.getOptionsAsync&&(this.isLoading=!0,this.updateButtonText(),this.props.getOptionsAsync().then(n=>{this._options.push(...n),this.isLoading=!1,this.updateOptionsList(),this.updateButtonText()}).catch(n=>{console.error("Failed to fetch async options:",n),this.isLoading=!1,this.updateButtonText("Failed to load options")})),this.clickOutsideListener&&document.removeEventListener("click",this.clickOutsideListener),this.clickOutsideListener=n=>{var a,o;this.isOpen&&!t.contains(n.target)&&(this.isOpen=!1,(a=this.optionsListEl)==null||a.classList.remove("open"),(o=this.svgContainer)==null||o.classList.remove("open"))},document.addEventListener("click",this.clickOutsideListener),t}selectOption(t,e,i){var n,a,o;const s=this._options[e];s&&(this.value=s.value,(n=this.onChange)==null||n.call(this,this.value),this.selectedOptionIndex=e,this.isOpen=!1,i.textContent=s.name,(a=this.optionsListEl)==null||a.classList.remove("open"),(o=this.svgContainer)==null||o.classList.remove("open"),this.optionsListEl&&this.optionsListEl.querySelectorAll(".select-option").forEach((
|
|
23
|
+
`;class N extends m{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.clickOutsideListener=null,t.options&&(this._options=[...t.options]),t.getOptions&&this._options.push(...t.getOptions()),t.getOptionsAsync&&(this.isLoading=!0),this.value!==void 0){const e=this._options.findIndex(i=>i.value===this.value);e>=0&&(this.selectedOptionIndex=e)}}createOption(t,e){const i=document.createElement("li");return i.classList.add("select-option"),i.textContent=t.name,i.dataset.index=String(e),this.selectedOptionIndex===e&&i.classList.add("selected"),i}draw(){const t=document.createElement("div");if(t.classList.add("select-container"),this.container=t,this.props.icon||this.props.title){const n=document.createElement("div");if(n.className="icon-container",this.props.icon){const a=this.createIcon(this.props.icon);n.appendChild(a)}if(this.props.title){const a=this.createLabel(this.props.title);n.appendChild(a)}t.appendChild(n)}else{const n=document.createElement("div");t.appendChild(n)}const e=document.createElement("div");e.classList.add("select-button"),this.isLoading?e.classList.add("loading"):e.textContent=this.selectedOptionIndex!==null?this._options[this.selectedOptionIndex].name:this.props.placeholder||"Select an option",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-options"),this._options.forEach((n,a)=>{const o=this.createOption(n,a);o.onclick=l=>this.selectOption(l,a,e),i.appendChild(o)}),t.appendChild(i);const s=document.createElement("div");return s.classList.add("svg-container"),s.innerHTML=G,t.appendChild(s),this.optionsListEl=i,this.svgContainer=s,this.props.getOptionsAsync&&(this.isLoading=!0,this.updateButtonText(),this.props.getOptionsAsync().then(n=>{this._options.push(...n),this.isLoading=!1,this.updateOptionsList(),this.updateButtonText()}).catch(n=>{console.error("Failed to fetch async options:",n),this.isLoading=!1,this.updateButtonText("Failed to load options")})),this.clickOutsideListener&&document.removeEventListener("click",this.clickOutsideListener),this.clickOutsideListener=n=>{var a,o;this.isOpen&&!t.contains(n.target)&&(this.isOpen=!1,(a=this.optionsListEl)==null||a.classList.remove("open"),(o=this.svgContainer)==null||o.classList.remove("open"))},document.addEventListener("click",this.clickOutsideListener),t}selectOption(t,e,i){var n,a,o;const s=this._options[e];s&&(this.value=s.value,(n=this.onChange)==null||n.call(this,this.value),this.selectedOptionIndex=e,this.isOpen=!1,i.textContent=s.name,(a=this.optionsListEl)==null||a.classList.remove("open"),(o=this.svgContainer)==null||o.classList.remove("open"),this.optionsListEl&&this.optionsListEl.querySelectorAll(".select-option").forEach((h,r)=>{r===e?h.classList.add("selected"):h.classList.remove("selected")}))}updateOptionsList(){if(this.optionsListEl){if(this.optionsListEl.innerHTML="",this._options.length===0){const t=document.createElement("li");t.classList.add("select-option","empty-message"),t.textContent="No options available",this.optionsListEl.appendChild(t);return}this._options.forEach((t,e)=>{const i=this.createOption(t,e);i.onclick=s=>{this.buttonEl&&this.selectOption(s,e,this.buttonEl)},this.optionsListEl.appendChild(i)})}}updateButtonText(t){if(!this.buttonEl)return;if(this.isLoading){this.buttonEl.classList.add("loading"),this.buttonEl.textContent=this.props.loadingText||"Loading options...";return}this.buttonEl.classList.remove("loading","error");let e;t?((t.includes("Failed")||t.includes("Error"))&&this.buttonEl.classList.add("error"),e=t):this.selectedOptionIndex!==null&&this._options[this.selectedOptionIndex]?e=this._options[this.selectedOptionIndex].name:e=this.props.placeholder||"Select an option",this.buttonEl.textContent=e}destroy(){this.clickOutsideListener&&(document.removeEventListener("click",this.clickOutsideListener),this.clickOutsideListener=null),super.destroy()}}class A extends m{constructor(t={}){super(t),this.inputType="button",this.value||(this.value="center")}draw(){const t=document.createElement("div");t.className="align-setting-wrapper";const e=document.createElement("label");e.className="align-setting-label",e.textContent=this.title||"Align",t.appendChild(e);const i=document.createElement("div");return i.className="align-options-container",[{name:"left",icon:`
|
|
24
24
|
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18" fill="none">
|
|
25
25
|
<path d="M10.5 7.5C11.1989 7.5 11.5484 7.5 11.824 7.38582C12.1916 7.23358 12.4836 6.94157 12.6358 6.57402C12.75 6.29837 12.75 5.94891 12.75 5.25C12.75 4.55109 12.75 4.20163 12.6358 3.92598C12.4836 3.55843 12.1916 3.26642 11.824 3.11418C11.5484 3 11.1989 3 10.5 3L4.5 3C3.80109 3 3.45163 3 3.17598 3.11418C2.80843 3.26642 2.51642 3.55843 2.36418 3.92597C2.25 4.20163 2.25 4.55109 2.25 5.25C2.25 5.94891 2.25 6.29837 2.36418 6.57402C2.51642 6.94157 2.80843 7.23358 3.17598 7.38582C3.45163 7.5 3.80109 7.5 4.5 7.5L10.5 7.5Z"
|
|
26
26
|
stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
|
|
@@ -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
|
|
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 q extends m{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 D extends m{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>`:`
|
|
@@ -55,12 +55,12 @@
|
|
|
55
55
|
<svg xmlns="http://www.w3.org/2000/svg" width="15" height="16" viewBox="0 0 15 16" fill="none">
|
|
56
56
|
<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"/>
|
|
57
57
|
</svg>
|
|
58
|
-
`,
|
|
58
|
+
`,P=`
|
|
59
59
|
<svg width="91" height="71" viewBox="0 0 91 71" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
60
60
|
<rect width="91" height="71" rx="4" fill="#F2F4F7"/>
|
|
61
61
|
<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"/>
|
|
62
62
|
</svg>
|
|
63
|
-
`,
|
|
63
|
+
`,z=`
|
|
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>
|
|
@@ -70,10 +70,10 @@
|
|
|
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=`
|
|
71
71
|
<span class="upload-icon">${O}</span>
|
|
72
72
|
<span class="upload-label">Upload</span>
|
|
73
|
-
`))}draw(){const t=document.createElement("div");t.className="upload-setting-wrapper",t.setAttribute("data-setting-id",this.id),t.addEventListener("focusout",l=>{var
|
|
73
|
+
`))}draw(){const t=document.createElement("div");t.className="upload-setting-wrapper",t.setAttribute("data-setting-id",this.id),t.addEventListener("focusout",l=>{var h;l.relatedTarget&&t.contains(l.relatedTarget)||(h=this.onBlur)==null||h.call(this)},!0);const e=!!(this.props.title||this.props.icon);if(e||t.classList.add("no-label"),e){const l=document.createElement("div");if(l.className="icon-title-container",this.props.icon){const h=this.createIcon(this.props.icon);l.appendChild(h)}if(this.props.title){const h=this.createLabel(this.props.title);l.appendChild(h)}t.appendChild(l)}const i=document.createElement("div");i.className="preview-button-container";const s=this.value&&this.value!=="";s||i.classList.add("no-image");const n=document.createElement("div");if(n.className="preview-placeholder",n.innerHTML=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=z,this.previewWrapper.appendChild(l),l.onclick=h=>{var r;h.stopPropagation(),this.value="",o.value="",this.updatePreviewState(null),(r=this.onChange)==null||r.call(this,"")}}this.previewWrapper.appendChild(this.previewEl);const a=document.createElement("button");a.className="upload-button",a.innerHTML=`
|
|
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
|
|
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 h,r,u,d;const l=(h=o.files)==null?void 0:h[0];if(l)try{a.classList.add("loading"),a.disabled=!0;const g=new FormData,p=this.props.formFieldName||"file";g.append(p,l,l.name);const C=this.props.uploadUrl;if(!C)throw new Error("No uploadUrl provided to UploadSetting.");const v=this.props.requestMethod||"POST",V={...this.props.requestHeaders||{}},k=await(await fetch(C,{method:v,body:g,headers:V})).json();console.log("Upload response:",k);let x;if(this.props.parseResponse)x=this.props.parseResponse(k);else if(x=(r=k==null?void 0:k.data)==null?void 0:r.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),(d=this.onBlur)==null||d.call(this)}catch(g){console.error("Error uploading file:",g)}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||J,...t};super(e),this.inputType="number",this.mobileValue=t.mobile}getMobileValue(){return this.mobileValue}}const J=`<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
78
|
</svg>`;class X extends b{constructor(t={}){const e={title:t.title||"Width",suffix:"px",minValue:t.minValue??0,maxValue:t.maxValue,icon:t.icon||Q,...t};super(e),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"/>
|
|
@@ -81,16 +81,16 @@
|
|
|
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 K extends m{constructor(t={}){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.initializeOptions(t),t.default!==void 0&&(this.value=t.default,this.selectedOptionIndex=this._options.findIndex(e=>JSON.stringify(e.value)===JSON.stringify(t.default))),t.onChange&&this.setOnChange(t.onChange),t.detectChange&&(this.detectChangeCallback=t.detectChange)}initializeOptions(t){this.hasInitializedOptions||(this._options=[],t.options&&(this._options=[...t.options]),t.getOptions&&this._options.push(...t.getOptions()),t.getOptionsAsync?(this.isLoading=!0,t.default!==void 0&&(this.value=t.default)):t.default!==void 0&&(this.selectedOptionIndex=this._options.findIndex(e=>JSON.stringify(e.value)===JSON.stringify(t.default))),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");a.className="select-value",this.isLoading?a.textContent=this.props.loadingText||"Loading options...":a.textContent=this.selectedOptionIndex!==null?this._options[this.selectedOptionIndex].name:"Select an option",e.appendChild(a)}else{const n=document.createElement("span");this.isLoading?n.textContent=this.props.loadingText||"Loading options...":n.textContent=this.selectedOptionIndex!==null?this._options[this.selectedOptionIndex].name:"Select an option",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=>{this._options.push(...n),this.isLoading=!1,this.value!==void 0&&this.selectedOptionIndex===null&&(this.selectedOptionIndex=this._options.findIndex(a=>JSON.stringify(a.value)===JSON.stringify(this.value))),this.updateOptionsList(),this.updateButtonText()}).catch(n=>{console.error("Failed to fetch async options:",n),this.isLoading=!1,this.updateButtonText("
|
|
84
|
+
`;class K extends m{constructor(t={}){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.initializeOptions(t),t.default!==void 0&&(this.value=t.default,this.selectedOptionIndex=this._options.findIndex(e=>JSON.stringify(e.value)===JSON.stringify(t.default))),t.onChange&&this.setOnChange(t.onChange),t.detectChange&&(this.detectChangeCallback=t.detectChange)}initializeOptions(t){this.hasInitializedOptions||(this._options=[],t.options&&(this._options=[...t.options]),t.getOptions&&this._options.push(...t.getOptions()),t.getOptionsAsync?(this.isLoading=!0,t.default!==void 0&&(this.value=t.default)):t.default!==void 0&&(this.selectedOptionIndex=this._options.findIndex(e=>JSON.stringify(e.value)===JSON.stringify(t.default))),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");a.className="select-value",this.isLoading?a.textContent=this.props.loadingText||"Loading options...":a.textContent=this.selectedOptionIndex!==null?this._options[this.selectedOptionIndex].name:"Select an option",e.appendChild(a)}else{const n=document.createElement("span");this.isLoading?n.textContent=this.props.loadingText||"Loading options...":n.textContent=this.selectedOptionIndex!==null?this._options[this.selectedOptionIndex].name:"Select an option",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=>{this._options.push(...n),this.isLoading=!1,this.value!==void 0&&this.selectedOptionIndex===null&&(this.selectedOptionIndex=this._options.findIndex(a=>JSON.stringify(a.value)===JSON.stringify(this.value))),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)));this._options.push(...o),this.isLoading=!1,this.value!==void 0&&this.selectedOptionIndex===null&&(this.selectedOptionIndex=this._options.findIndex(l=>JSON.stringify(l.value)===JSON.stringify(this.value))),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,h,r,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,(h=this.optionsListEl)==null||h.classList.remove("open"),(r=this.svgContainer)==null||r.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;i&&(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")):this.isLoading?(i.textContent=this.props.loadingText||"Loading options...",this.buttonEl.classList.remove("error"),this.buttonEl.removeAttribute("disabled"),this.svgContainer&&(this.svgContainer.style.display="")):(i.textContent=t||(this.selectedOptionIndex!==null&&this._options[this.selectedOptionIndex]?this._options[this.selectedOptionIndex].name:"Select an option"),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 tt extends m{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 h,r;const l=((r=(h=this.props.options)==null?void 0:h.find(u=>u.status===s.checked))==null?void 0:r.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"),h=this.props.activeColor||"#4CAF50",r=this.props.inactiveColor||"#ccc";l.textContent=`
|
|
85
85
|
.toggle-switch input:checked + .toggle-slider {
|
|
86
|
-
background-color: ${
|
|
86
|
+
background-color: ${h};
|
|
87
87
|
}
|
|
88
88
|
.toggle-switch .toggle-slider {
|
|
89
89
|
background-color: ${r};
|
|
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 et=`<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 it extends m{constructor(t={}){t.rowGap=t.rowGap??!0,t.columnGap=t.columnGap??!0,t.title=t.title??"Gap",t.icon=t.icon??et,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,c;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)),(c=(l=this.props).onBlur)==null||c.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 x extends f{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 x&&(i._parentTabsSettings=this)}),this.connectChildChangeHandlers())}connectChildChangeHandlers(){if(!this.settings)return;const t=()=>{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 f?e.setOnChange(()=>{t()}):e instanceof m&&e.setOnChange(()=>{t()})}),this.tabs.forEach(e=>{Object.entries(e.settings).forEach(([i,s])=>{(s instanceof f||s instanceof m)&&(s instanceof x?(s._parentTabsSettings=this,s.setOnChange(n=>{this.tabValues[e.id]=this.getTabValues(e),this.triggerDebouncedChange()})):s instanceof f?s.setOnChange(()=>{this.tabValues[e.id]=this.getTabValues(e),this.triggerDebouncedChange()}):s instanceof m&&s.setOnChange(()=>{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(c=>c.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(c=>{if(c instanceof HTMLElement){const r=this.tabs.find(p=>p.label===c.textContent);c.classList.toggle("active",(r==null?void 0:r.id)===t)}}),this.updateSettingsFromTab(t);const s=(l=this.container)==null?void 0:l.querySelector(".setting-group-content");if(s){s.innerHTML="";const c=this.settings;Object.values(c).forEach(r=>{s.appendChild(r.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 x&&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 x||s instanceof f?e[i]=s.getValues():(s instanceof m,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 x(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()))}}const st=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
93
|
+
</svg>`;class it extends m{constructor(t={}){t.rowGap=t.rowGap??!0,t.columnGap=t.columnGap??!0,t.title=t.title??"Gap",t.icon=t.icon??et,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,h;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)),(h=(l=this.props).onBlur)==null||h.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 E extends f{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 E&&(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 f?e.setOnChange(()=>{t()}):e instanceof m&&e.setOnChange(()=>{t()})}),this.tabs.forEach(e=>{Object.entries(e.settings).forEach(([i,s])=>{(s instanceof f||s instanceof m)&&(s instanceof E?(s._parentTabsSettings=this,s.setOnChange(n=>{Promise.resolve().then(()=>{this.tabValues[e.id]=this.getTabValues(e),this.triggerDebouncedChange()})})):s instanceof f?s.setOnChange(()=>{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()})}))})})}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(h=>h.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(h=>{if(h instanceof HTMLElement){const r=this.tabs.find(u=>u.label===h.textContent);h.classList.toggle("active",(r==null?void 0:r.id)===t)}}),this.updateSettingsFromTab(t);const s=(l=this.container)==null?void 0:l.querySelector(".setting-group-content");if(s){s.innerHTML="";const h=this.settings;Object.values(h).forEach(r=>{s.appendChild(r.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 E&&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 E||s instanceof f?e[i]=s.getValues():(s instanceof m,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 E(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 st=`<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 nt extends b{constructor(t={}){super({...t,minValue:t.minValue??0,maxValue:t.maxValue??1e3,icon:t.icon||st,title:t.title||"Margin Bottom",default:t.default??20,wrapperClassName:"margin-bottom-wrapper "+(t.wrapperClassName||"")}),this.inputType="number"}}const at=`
|
|
96
96
|
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
font-weight: ${s};
|
|
125
125
|
font-size: ${n}px;
|
|
126
126
|
text-align: ${a};
|
|
127
|
-
`}}class
|
|
127
|
+
`}}class T extends m{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,h=this.props.maxValue??Number.MAX_SAFE_INTEGER;let r=Number(o.value);r<l&&(r=l),r>h&&(r=h),o.value=String(r)}))},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 h=Number(l);isNaN(h)||(this.value=h)}this.onChange&&this.onChange(this.value)}),i}}class ut extends f{constructor(t){super({title:"Margins",collapsed:t==null?void 0:t.collapsed,hideCondition:t==null?void 0:t.hideCondition,settings:{marginTop:new T({title:"Top",icon:pt,suffix:"px",default:(t==null?void 0:t.marginTop)??"auto"}),marginRight:new T({title:"Right",icon:gt,suffix:"px",default:(t==null?void 0:t.marginRight)??0}),marginBottom:new T({title:"Bottom",icon:mt,suffix:"px",default:(t==null?void 0:t.marginBottom)??0}),marginLeft:new T({title:"Left",icon:ft,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
|
`:`
|
|
167
167
|
background-color: ${i};
|
|
168
168
|
opacity: ${s/100};
|
|
169
|
-
`}}exports.AlignSetting=A;exports.BackgroundSettingSet=bt;exports.BorderSettingSet=lt;exports.ButtonSetting=
|
|
169
|
+
`}}exports.AlignSetting=A;exports.BackgroundSettingSet=bt;exports.BorderSettingSet=lt;exports.ButtonSetting=q;exports.ColorSetting=H;exports.DimensionSetting=D;exports.GapSetting=it;exports.HeaderTypographySettingSet=dt;exports.HeightSetting=Z;exports.MarginBottomSetting=nt;exports.MarginSettingGroup=ut;exports.NumberSetting=b;exports.OpacitySetting=L;exports.SelectApiSettings=K;exports.SelectSetting=N;exports.Setting=m;exports.SettingGroup=f;exports.StringSetting=S;exports.TabsContainerGroup=vt;exports.TabsSettings=E;exports.Toggle=tt;exports.UploadSetting=$;exports.WidthSetting=X;exports.iterateSettings=y;
|
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
const A = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
2
|
-
let R = (
|
|
3
|
-
let t = "", e = crypto.getRandomValues(new Uint8Array(
|
|
4
|
-
for (;
|
|
5
|
-
t += A[e[
|
|
2
|
+
let R = (c = 21) => {
|
|
3
|
+
let t = "", e = crypto.getRandomValues(new Uint8Array(c |= 0));
|
|
4
|
+
for (; c--; )
|
|
5
|
+
t += A[e[c] & 63];
|
|
6
6
|
return t;
|
|
7
7
|
};
|
|
8
|
-
function
|
|
9
|
-
if (
|
|
10
|
-
return
|
|
11
|
-
if (
|
|
12
|
-
return new Date(
|
|
13
|
-
if (Array.isArray(
|
|
8
|
+
function T(c) {
|
|
9
|
+
if (c === null || typeof c != "object")
|
|
10
|
+
return c;
|
|
11
|
+
if (c instanceof Date)
|
|
12
|
+
return new Date(c.getTime());
|
|
13
|
+
if (Array.isArray(c)) {
|
|
14
14
|
const i = [];
|
|
15
|
-
for (let s = 0; s <
|
|
16
|
-
i[s] =
|
|
15
|
+
for (let s = 0; s < c.length; s++)
|
|
16
|
+
i[s] = T(c[s]);
|
|
17
17
|
return i;
|
|
18
18
|
}
|
|
19
19
|
const t = {};
|
|
20
|
-
for (const i in
|
|
21
|
-
Object.prototype.hasOwnProperty.call(
|
|
22
|
-
const e = Object.getPrototypeOf(
|
|
20
|
+
for (const i in c)
|
|
21
|
+
Object.prototype.hasOwnProperty.call(c, i) && (t[i] = T(c[i]));
|
|
22
|
+
const e = Object.getPrototypeOf(c);
|
|
23
23
|
return e !== Object.prototype && Object.setPrototypeOf(t, e), t;
|
|
24
24
|
}
|
|
25
|
-
function $(
|
|
26
|
-
switch (
|
|
25
|
+
function $(c) {
|
|
26
|
+
switch (c) {
|
|
27
27
|
case "number":
|
|
28
28
|
return 0;
|
|
29
29
|
case "text":
|
|
@@ -55,8 +55,8 @@ class m {
|
|
|
55
55
|
}
|
|
56
56
|
// Basic clone method
|
|
57
57
|
clone() {
|
|
58
|
-
const t = this.constructor, e =
|
|
59
|
-
return i.value =
|
|
58
|
+
const t = this.constructor, e = T(this.props), i = new t(e);
|
|
59
|
+
return i.value = T(this.value), i;
|
|
60
60
|
}
|
|
61
61
|
createInput(t) {
|
|
62
62
|
t = { ...this.props.inputProps, ...t };
|
|
@@ -115,10 +115,10 @@ class m {
|
|
|
115
115
|
return i.className = "input-icon " + (e || ""), i.innerHTML = t, i;
|
|
116
116
|
}
|
|
117
117
|
}
|
|
118
|
-
function
|
|
119
|
-
for (const e in
|
|
120
|
-
if (
|
|
121
|
-
const i =
|
|
118
|
+
function M(c, t) {
|
|
119
|
+
for (const e in c)
|
|
120
|
+
if (c.hasOwnProperty(e)) {
|
|
121
|
+
const i = c[e];
|
|
122
122
|
t(e, i);
|
|
123
123
|
}
|
|
124
124
|
}
|
|
@@ -148,7 +148,7 @@ const w = class w {
|
|
|
148
148
|
Object.keys(s).length > 0 && (this.lastChangeTime = Date.now(), this.initialValues = i, t(i), this.updateVisibility()), this.isHandlingChange = !1;
|
|
149
149
|
}, 50));
|
|
150
150
|
};
|
|
151
|
-
return this.changeHandlers.clear(),
|
|
151
|
+
return this.changeHandlers.clear(), M(this.settings, (i, s) => {
|
|
152
152
|
var n;
|
|
153
153
|
if (s instanceof w)
|
|
154
154
|
s.setOnChange((a) => {
|
|
@@ -176,7 +176,7 @@ const w = class w {
|
|
|
176
176
|
}, this.elementRef && this.setupBlurHandlers(), this;
|
|
177
177
|
}
|
|
178
178
|
setupBlurHandlers() {
|
|
179
|
-
this.elementRef && this.elementRef.removeEventListener("focusout", this.handleBlur), this.elementRef && this.elementRef.addEventListener("focusout", this.handleBlur, !0),
|
|
179
|
+
this.elementRef && this.elementRef.removeEventListener("focusout", this.handleBlur), this.elementRef && this.elementRef.addEventListener("focusout", this.handleBlur, !0), M(this.settings, (t, e) => {
|
|
180
180
|
var i;
|
|
181
181
|
if (e instanceof w)
|
|
182
182
|
e.setOnBlur(this.handleBlur);
|
|
@@ -193,7 +193,7 @@ const w = class w {
|
|
|
193
193
|
// Add the clone method here
|
|
194
194
|
clone() {
|
|
195
195
|
const t = {};
|
|
196
|
-
|
|
196
|
+
M(this.settings, (n, a) => {
|
|
197
197
|
typeof a.clone == "function" ? t[n] = a.clone() : (console.warn(`Setting with key '${n}' does not have a clone method. Copying reference.`), t[n] = a);
|
|
198
198
|
});
|
|
199
199
|
const e = {
|
|
@@ -287,10 +287,10 @@ const w = class w {
|
|
|
287
287
|
);
|
|
288
288
|
const r = o.querySelector(
|
|
289
289
|
".setting-group-description"
|
|
290
|
-
),
|
|
290
|
+
), u = n.querySelector(".info-marker");
|
|
291
291
|
if (this.description)
|
|
292
292
|
if (this.isCollapsed) {
|
|
293
|
-
if (r && r.remove(), !
|
|
293
|
+
if (r && r.remove(), !u) {
|
|
294
294
|
const d = document.createElement("span");
|
|
295
295
|
d.className = "info-marker", d.innerHTML = `
|
|
296
296
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
@@ -307,7 +307,7 @@ const w = class w {
|
|
|
307
307
|
o.firstChild
|
|
308
308
|
);
|
|
309
309
|
}
|
|
310
|
-
|
|
310
|
+
u && u.remove();
|
|
311
311
|
}
|
|
312
312
|
};
|
|
313
313
|
if (e.onclick = l, e.onkeydown = (r) => {
|
|
@@ -315,8 +315,8 @@ const w = class w {
|
|
|
315
315
|
}, Object.keys(this.settings).length > 0) {
|
|
316
316
|
for (const r in this.settings)
|
|
317
317
|
if (this.settings.hasOwnProperty(r)) {
|
|
318
|
-
const
|
|
319
|
-
o.appendChild(
|
|
318
|
+
const u = this.settings[r];
|
|
319
|
+
o.appendChild(u.draw());
|
|
320
320
|
}
|
|
321
321
|
} else {
|
|
322
322
|
const r = document.createElement("div");
|
|
@@ -372,7 +372,7 @@ class S extends m {
|
|
|
372
372
|
}
|
|
373
373
|
}
|
|
374
374
|
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>";
|
|
375
|
-
class
|
|
375
|
+
class O extends S {
|
|
376
376
|
constructor(t) {
|
|
377
377
|
super({
|
|
378
378
|
...t,
|
|
@@ -404,10 +404,10 @@ class N extends S {
|
|
|
404
404
|
const n = document.createElement("div");
|
|
405
405
|
n.className = "color-input-wrapper";
|
|
406
406
|
const a = (d) => {
|
|
407
|
-
const g = d.value.split(",").map((
|
|
407
|
+
const g = d.value.split(",").map((N) => parseInt(N.trim()));
|
|
408
408
|
if (g.length !== 3 || g.some(isNaN))
|
|
409
409
|
return d.style.border = "1px solid red", !1;
|
|
410
|
-
const [
|
|
410
|
+
const [p, C, v] = g, L = p >= 0 && p <= 255 && C >= 0 && C <= 255 && v >= 0 && v <= 255;
|
|
411
411
|
return d.style.border = L ? "" : "1px solid red", L;
|
|
412
412
|
}, o = document.createElement("div");
|
|
413
413
|
o.className = "color-preview", o.style.backgroundColor = this.value ? `rgb(${this.value})` : "";
|
|
@@ -415,24 +415,26 @@ class N extends S {
|
|
|
415
415
|
value: this.value,
|
|
416
416
|
inputType: "text",
|
|
417
417
|
inputClassName: "color-text-input"
|
|
418
|
-
}),
|
|
418
|
+
}), h = l.querySelector("input");
|
|
419
|
+
h.readOnly = !0;
|
|
420
|
+
const r = this.createInput({
|
|
419
421
|
value: this.value ? this.rgbToHex(this.value) : "",
|
|
420
422
|
inputType: this.inputType,
|
|
421
423
|
inputClassName: "color-picker"
|
|
422
|
-
}),
|
|
423
|
-
return
|
|
424
|
-
var
|
|
424
|
+
}), u = r.querySelector("input");
|
|
425
|
+
return h.oninput = (d) => {
|
|
426
|
+
var p;
|
|
425
427
|
let g = d.target.value.trim();
|
|
426
|
-
a(
|
|
427
|
-
},
|
|
428
|
+
a(h) && (this.value = g, (p = this.onChange) == null || p.call(this, g), u.value = this.rgbToHex(g), o.style.backgroundColor = `rgb(${g})`);
|
|
429
|
+
}, u.oninput = (d) => {
|
|
428
430
|
var C, v;
|
|
429
|
-
const g = d.target.value,
|
|
430
|
-
this.value =
|
|
431
|
-
},
|
|
431
|
+
const g = d.target.value, p = this.hexToRgb(g);
|
|
432
|
+
this.value = p, (C = this.onChange) == null || C.call(this, p), (v = this.detectChange) == null || v.call(this, p), h.value = p, o.style.backgroundColor = `rgb(${p})`;
|
|
433
|
+
}, u.onchange = (d) => {
|
|
432
434
|
var C, v;
|
|
433
|
-
const g = d.target.value,
|
|
434
|
-
this.value =
|
|
435
|
-
}, n.appendChild(o), n.appendChild(r), n.appendChild(l), t.appendChild(e), t.appendChild(n), this.value && (
|
|
435
|
+
const g = d.target.value, p = this.hexToRgb(g);
|
|
436
|
+
this.value = p, (C = this.onChange) == null || C.call(this, p), (v = this.detectChange) == null || v.call(this, p), h.value = p, o.style.backgroundColor = `rgb(${p})`;
|
|
437
|
+
}, n.appendChild(o), n.appendChild(r), n.appendChild(l), t.appendChild(e), t.appendChild(n), this.value && (h.value = this.value, u.value = this.rgbToHex(this.value), o.style.backgroundColor = `rgb(${this.value})`), t;
|
|
436
438
|
}
|
|
437
439
|
}
|
|
438
440
|
class b extends m {
|
|
@@ -490,7 +492,7 @@ const _ = `
|
|
|
490
492
|
<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"/>
|
|
491
493
|
<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"/>
|
|
492
494
|
</svg>`;
|
|
493
|
-
class
|
|
495
|
+
class y extends b {
|
|
494
496
|
constructor(t = {}) {
|
|
495
497
|
const e = {
|
|
496
498
|
title: "Opacity",
|
|
@@ -564,8 +566,8 @@ class B extends m {
|
|
|
564
566
|
selectOption(t, e, i) {
|
|
565
567
|
var n, a, o;
|
|
566
568
|
const s = this._options[e];
|
|
567
|
-
s && (this.value = s.value, (n = this.onChange) == null || n.call(this, this.value), this.selectedOptionIndex = e, this.isOpen = !1, i.textContent = s.name, (a = this.optionsListEl) == null || a.classList.remove("open"), (o = this.svgContainer) == null || o.classList.remove("open"), this.optionsListEl && this.optionsListEl.querySelectorAll(".select-option").forEach((
|
|
568
|
-
r === e ?
|
|
569
|
+
s && (this.value = s.value, (n = this.onChange) == null || n.call(this, this.value), this.selectedOptionIndex = e, this.isOpen = !1, i.textContent = s.name, (a = this.optionsListEl) == null || a.classList.remove("open"), (o = this.svgContainer) == null || o.classList.remove("open"), this.optionsListEl && this.optionsListEl.querySelectorAll(".select-option").forEach((h, r) => {
|
|
570
|
+
r === e ? h.classList.add("selected") : h.classList.remove("selected");
|
|
569
571
|
}));
|
|
570
572
|
}
|
|
571
573
|
updateOptionsList() {
|
|
@@ -683,7 +685,7 @@ class rt extends m {
|
|
|
683
685
|
suffix: "px",
|
|
684
686
|
minValue: this.minHeight,
|
|
685
687
|
maxValue: this.maxHeight,
|
|
686
|
-
icon:
|
|
688
|
+
icon: q
|
|
687
689
|
}), this.widthSetting.setOnChange(this.handleWidthChange.bind(this)), this.heightSetting.setOnChange(this.handleHeightChange.bind(this));
|
|
688
690
|
}
|
|
689
691
|
handleWidthChange(t) {
|
|
@@ -777,13 +779,13 @@ class rt extends m {
|
|
|
777
779
|
}
|
|
778
780
|
const G = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
779
781
|
<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"/>
|
|
780
|
-
</svg>`,
|
|
782
|
+
</svg>`, q = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
781
783
|
<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"/>
|
|
782
784
|
</svg>`, H = `
|
|
783
785
|
<svg xmlns="http://www.w3.org/2000/svg" width="15" height="16" viewBox="0 0 15 16" fill="none">
|
|
784
786
|
<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"/>
|
|
785
787
|
</svg>
|
|
786
|
-
`,
|
|
788
|
+
`, D = `
|
|
787
789
|
<svg width="91" height="71" viewBox="0 0 91 71" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
788
790
|
<rect width="91" height="71" rx="4" fill="#F2F4F7"/>
|
|
789
791
|
<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"/>
|
|
@@ -811,19 +813,19 @@ class U extends m {
|
|
|
811
813
|
draw() {
|
|
812
814
|
const t = document.createElement("div");
|
|
813
815
|
t.className = "upload-setting-wrapper", t.setAttribute("data-setting-id", this.id), t.addEventListener("focusout", (l) => {
|
|
814
|
-
var
|
|
815
|
-
l.relatedTarget && t.contains(l.relatedTarget) || (
|
|
816
|
+
var h;
|
|
817
|
+
l.relatedTarget && t.contains(l.relatedTarget) || (h = this.onBlur) == null || h.call(this);
|
|
816
818
|
}, !0);
|
|
817
819
|
const e = !!(this.props.title || this.props.icon);
|
|
818
820
|
if (e || t.classList.add("no-label"), e) {
|
|
819
821
|
const l = document.createElement("div");
|
|
820
822
|
if (l.className = "icon-title-container", this.props.icon) {
|
|
821
|
-
const
|
|
822
|
-
l.appendChild(
|
|
823
|
+
const h = this.createIcon(this.props.icon);
|
|
824
|
+
l.appendChild(h);
|
|
823
825
|
}
|
|
824
826
|
if (this.props.title) {
|
|
825
|
-
const
|
|
826
|
-
l.appendChild(
|
|
827
|
+
const h = this.createLabel(this.props.title);
|
|
828
|
+
l.appendChild(h);
|
|
827
829
|
}
|
|
828
830
|
t.appendChild(l);
|
|
829
831
|
}
|
|
@@ -832,11 +834,11 @@ class U extends m {
|
|
|
832
834
|
const s = this.value && this.value !== "";
|
|
833
835
|
s || i.classList.add("no-image");
|
|
834
836
|
const n = document.createElement("div");
|
|
835
|
-
if (n.className = "preview-placeholder", n.innerHTML =
|
|
837
|
+
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) {
|
|
836
838
|
const l = document.createElement("button");
|
|
837
|
-
l.className = "delete-button", l.type = "button", l.title = "Delete image", l.innerHTML = F, this.previewWrapper.appendChild(l), l.onclick = (
|
|
839
|
+
l.className = "delete-button", l.type = "button", l.title = "Delete image", l.innerHTML = F, this.previewWrapper.appendChild(l), l.onclick = (h) => {
|
|
838
840
|
var r;
|
|
839
|
-
|
|
841
|
+
h.stopPropagation(), this.value = "", o.value = "", this.updatePreviewState(null), (r = this.onChange) == null || r.call(this, "");
|
|
840
842
|
};
|
|
841
843
|
}
|
|
842
844
|
this.previewWrapper.appendChild(this.previewEl);
|
|
@@ -849,13 +851,13 @@ class U extends m {
|
|
|
849
851
|
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 = () => {
|
|
850
852
|
o.click();
|
|
851
853
|
}, o.onchange = async () => {
|
|
852
|
-
var
|
|
853
|
-
const l = (
|
|
854
|
+
var h, r, u, d;
|
|
855
|
+
const l = (h = o.files) == null ? void 0 : h[0];
|
|
854
856
|
if (l)
|
|
855
857
|
try {
|
|
856
858
|
a.classList.add("loading"), a.disabled = !0;
|
|
857
|
-
const g = new FormData(),
|
|
858
|
-
g.append(
|
|
859
|
+
const g = new FormData(), p = this.props.formFieldName || "file";
|
|
860
|
+
g.append(p, l, l.name);
|
|
859
861
|
const C = this.props.uploadUrl;
|
|
860
862
|
if (!C)
|
|
861
863
|
throw new Error("No uploadUrl provided to UploadSetting.");
|
|
@@ -865,14 +867,14 @@ class U extends m {
|
|
|
865
867
|
headers: L
|
|
866
868
|
})).json();
|
|
867
869
|
console.log("Upload response:", k);
|
|
868
|
-
let
|
|
870
|
+
let x;
|
|
869
871
|
if (this.props.parseResponse)
|
|
870
|
-
|
|
871
|
-
else if (
|
|
872
|
+
x = this.props.parseResponse(k);
|
|
873
|
+
else if (x = (r = k == null ? void 0 : k.data) == null ? void 0 : r.url, !x)
|
|
872
874
|
throw new Error(
|
|
873
875
|
"No URL found in response. Provide a parseResponse if needed."
|
|
874
876
|
);
|
|
875
|
-
console.log("Final URL:",
|
|
877
|
+
console.log("Final URL:", x), this.value = x, this.updatePreviewState(x), (u = this.onChange) == null || u.call(this, x), (d = this.onBlur) == null || d.call(this);
|
|
876
878
|
} catch (g) {
|
|
877
879
|
console.error("Error uploading file:", g);
|
|
878
880
|
} finally {
|
|
@@ -979,79 +981,53 @@ class dt extends m {
|
|
|
979
981
|
(a) => JSON.stringify(a.value) === JSON.stringify(this.value)
|
|
980
982
|
)), this.updateOptionsList(), this.updateButtonText();
|
|
981
983
|
}).catch((n) => {
|
|
982
|
-
console.error("Failed to fetch async options:", n), this.isLoading = !1, this.updateButtonText("
|
|
984
|
+
console.error("Failed to fetch async options:", n), this.isLoading = !1, this.updateButtonText(this.props.errorText || "Error: Could not load options", !0);
|
|
983
985
|
})) : this.props.getOptionsAsync && this._options.length <= 1 && (this.isLoading = !0, this.updateButtonText(), this.props.getOptionsAsync().then((n) => {
|
|
984
986
|
const a = new Set(this._options.map((l) => JSON.stringify(l.value))), o = n.filter((l) => !a.has(JSON.stringify(l.value)));
|
|
985
987
|
this._options.push(...o), this.isLoading = !1, this.value !== void 0 && this.selectedOptionIndex === null && (this.selectedOptionIndex = this._options.findIndex(
|
|
986
988
|
(l) => JSON.stringify(l.value) === JSON.stringify(this.value)
|
|
987
989
|
)), this.updateOptionsList(), this.updateButtonText();
|
|
988
990
|
}).catch((n) => {
|
|
989
|
-
console.error("Failed to fetch async options:", n), this.isLoading = !1, this.updateButtonText("
|
|
991
|
+
console.error("Failed to fetch async options:", n), this.isLoading = !1, this.updateButtonText(this.props.errorText || "Error: Could not load options", !0);
|
|
990
992
|
})), t;
|
|
991
993
|
}
|
|
992
994
|
selectApiOption(t, e, i) {
|
|
993
|
-
var
|
|
994
|
-
const s =
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
995
|
+
var l, h, r, u;
|
|
996
|
+
const s = t.target, n = s.querySelector(".select-api-radio") || ((l = s.closest(".select-api-option")) == null ? void 0 : l.querySelector(".select-api-radio"));
|
|
997
|
+
n && (n.checked = !0), this.selectedOptionIndex = e;
|
|
998
|
+
const a = this._options[e].value;
|
|
999
|
+
this.value = a;
|
|
1000
|
+
const o = i.querySelector(".select-value");
|
|
1001
|
+
if (o)
|
|
1002
|
+
o.textContent = this._options[e].name;
|
|
1003
|
+
else {
|
|
1004
|
+
const d = i.firstChild;
|
|
1005
|
+
d && d.tagName === "SPAN" && (d.textContent = this._options[e].name);
|
|
1002
1006
|
}
|
|
1007
|
+
this.isOpen = !1, (h = this.optionsListEl) == null || h.classList.remove("open"), (r = this.svgContainer) == null || r.classList.remove("open"), (u = this.onChange) == null || u.call(this, a), this.detectChangeCallback && this.detectChangeCallback(a);
|
|
1003
1008
|
}
|
|
1004
1009
|
updateOptionsList() {
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
}
|
|
1011
|
-
|
|
1012
|
-
const i = this.createOption(t, e);
|
|
1013
|
-
this.selectedOptionIndex === e && i.classList.add("selected"), i.onclick = (s) => {
|
|
1014
|
-
this.buttonEl && this.selectApiOption(s, e, this.buttonEl);
|
|
1015
|
-
}, i.tabIndex = 0, i.addEventListener("keydown", (s) => {
|
|
1016
|
-
(s.key === "Enter" || s.key === " ") && (s.preventDefault(), this.buttonEl && this.selectApiOption(s, e, this.buttonEl));
|
|
1017
|
-
}), this.optionsListEl.appendChild(i);
|
|
1018
|
-
});
|
|
1019
|
-
}
|
|
1010
|
+
!this.optionsListEl || !this.buttonEl || (this.optionsListEl.innerHTML = "", this._options.forEach((t, e) => {
|
|
1011
|
+
var s;
|
|
1012
|
+
const i = this.createOption(t, e);
|
|
1013
|
+
i.onclick = (n) => {
|
|
1014
|
+
this.buttonEl && this.selectApiOption(n, e, this.buttonEl);
|
|
1015
|
+
}, (s = this.optionsListEl) == null || s.appendChild(i);
|
|
1016
|
+
}));
|
|
1020
1017
|
}
|
|
1021
|
-
updateButtonText(t) {
|
|
1018
|
+
updateButtonText(t, e = !1) {
|
|
1022
1019
|
if (!this.buttonEl) return;
|
|
1023
|
-
const
|
|
1024
|
-
|
|
1025
|
-
this.buttonEl.classList.add("loading");
|
|
1026
|
-
const a = this.props.loadingText || "Loading options...";
|
|
1027
|
-
if (e)
|
|
1028
|
-
e.textContent = a;
|
|
1029
|
-
else if (i && this.props.title && !s) {
|
|
1030
|
-
this.buttonEl.innerHTML = "";
|
|
1031
|
-
const o = document.createElement("div");
|
|
1032
|
-
o.className = "select-label", o.textContent = this.props.title, this.buttonEl.appendChild(o);
|
|
1033
|
-
const l = document.createElement("span");
|
|
1034
|
-
l.className = "select-value", l.textContent = a, this.buttonEl.appendChild(l);
|
|
1035
|
-
} else
|
|
1036
|
-
this.buttonEl.textContent = a;
|
|
1037
|
-
return;
|
|
1038
|
-
}
|
|
1039
|
-
this.buttonEl.classList.remove("loading", "error");
|
|
1040
|
-
let n;
|
|
1041
|
-
if (t ? ((t.includes("Failed") || t.includes("Error")) && this.buttonEl.classList.add("error"), n = t) : this.selectedOptionIndex !== null && this._options[this.selectedOptionIndex] ? n = this._options[this.selectedOptionIndex].name : n = "Select an option", e)
|
|
1042
|
-
e.textContent = n;
|
|
1043
|
-
else if (i && this.props.title && !s) {
|
|
1044
|
-
this.buttonEl.innerHTML = "";
|
|
1045
|
-
const a = document.createElement("div");
|
|
1046
|
-
a.className = "select-label", a.textContent = this.props.title, this.buttonEl.appendChild(a);
|
|
1047
|
-
const o = document.createElement("span");
|
|
1048
|
-
o.className = "select-value", o.textContent = n, this.buttonEl.appendChild(o);
|
|
1049
|
-
} else
|
|
1050
|
-
this.buttonEl.textContent = n;
|
|
1020
|
+
const i = this.buttonEl.querySelector(".select-value") || this.buttonEl.firstChild;
|
|
1021
|
+
i && (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")) : this.isLoading ? (i.textContent = this.props.loadingText || "Loading options...", this.buttonEl.classList.remove("error"), this.buttonEl.removeAttribute("disabled"), this.svgContainer && (this.svgContainer.style.display = "")) : (i.textContent = t || (this.selectedOptionIndex !== null && this._options[this.selectedOptionIndex] ? this._options[this.selectedOptionIndex].name : "Select an option"), this.buttonEl.classList.remove("error"), this.buttonEl.removeAttribute("disabled"), this.svgContainer && (this.svgContainer.style.display = "")));
|
|
1051
1022
|
}
|
|
1052
1023
|
setDetectChange(t) {
|
|
1053
1024
|
this.detectChangeCallback = t;
|
|
1054
1025
|
}
|
|
1026
|
+
setValue(t) {
|
|
1027
|
+
this.value = t, this.selectedOptionIndex = this._options.findIndex(
|
|
1028
|
+
(e) => JSON.stringify(e.value) === JSON.stringify(t)
|
|
1029
|
+
), this.updateButtonText();
|
|
1030
|
+
}
|
|
1055
1031
|
}
|
|
1056
1032
|
class ut extends m {
|
|
1057
1033
|
constructor(t) {
|
|
@@ -1076,16 +1052,16 @@ class ut extends m {
|
|
|
1076
1052
|
i.className = "toggle-switch";
|
|
1077
1053
|
const s = document.createElement("input");
|
|
1078
1054
|
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", () => {
|
|
1079
|
-
var
|
|
1080
|
-
const l = ((r = (
|
|
1055
|
+
var h, r;
|
|
1056
|
+
const l = ((r = (h = this.props.options) == null ? void 0 : h.find((u) => u.status === s.checked)) == null ? void 0 : r.value) ?? "";
|
|
1081
1057
|
this.value = l, this.onChange && this.onChange(this.value), this.detectChangeCallback && this.detectChangeCallback(this.value);
|
|
1082
1058
|
});
|
|
1083
1059
|
const n = document.createElement("span");
|
|
1084
1060
|
if (n.className = "toggle-slider", this.props.activeColor || this.props.inactiveColor) {
|
|
1085
|
-
const l = document.createElement("style"),
|
|
1061
|
+
const l = document.createElement("style"), h = this.props.activeColor || "#4CAF50", r = this.props.inactiveColor || "#ccc";
|
|
1086
1062
|
l.textContent = `
|
|
1087
1063
|
.toggle-switch input:checked + .toggle-slider {
|
|
1088
|
-
background-color: ${
|
|
1064
|
+
background-color: ${h};
|
|
1089
1065
|
}
|
|
1090
1066
|
.toggle-switch .toggle-slider {
|
|
1091
1067
|
background-color: ${r};
|
|
@@ -1133,10 +1109,10 @@ class pt extends m {
|
|
|
1133
1109
|
let o = parseFloat(a.value);
|
|
1134
1110
|
o = this.validateValue(o), String(o) !== a.value && (a.value = String(o)), this.inputValues[t] = o, this.setValue(o);
|
|
1135
1111
|
}), s.addEventListener("blur", (n) => {
|
|
1136
|
-
var l,
|
|
1112
|
+
var l, h;
|
|
1137
1113
|
const a = n.target;
|
|
1138
1114
|
let o = parseFloat(a.value);
|
|
1139
|
-
o = this.validateValue(o), String(o) !== a.value && (a.value = String(o), this.inputValues[t] = o, this.setValue(o)), (
|
|
1115
|
+
o = this.validateValue(o), String(o) !== a.value && (a.value = String(o), this.inputValues[t] = o, this.setValue(o)), (h = (l = this.props).onBlur) == null || h.call(l);
|
|
1140
1116
|
}), i.appendChild(s), this.props.suffix && this.props.suffix !== "none") {
|
|
1141
1117
|
const n = document.createElement("span");
|
|
1142
1118
|
n.className = "gap-suffix", n.textContent = this.props.suffix, i.appendChild(n), s.style.paddingRight = "30px";
|
|
@@ -1153,7 +1129,7 @@ class pt extends m {
|
|
|
1153
1129
|
return this.mobileValue;
|
|
1154
1130
|
}
|
|
1155
1131
|
}
|
|
1156
|
-
class
|
|
1132
|
+
class E extends f {
|
|
1157
1133
|
// ms
|
|
1158
1134
|
constructor(t) {
|
|
1159
1135
|
var o;
|
|
@@ -1178,7 +1154,7 @@ class x extends f {
|
|
|
1178
1154
|
tabs: this.tabValues,
|
|
1179
1155
|
activeTabId: this.activeTabId
|
|
1180
1156
|
}, Object.values(e.settings).forEach((i) => {
|
|
1181
|
-
i instanceof
|
|
1157
|
+
i instanceof E && (i._parentTabsSettings = this);
|
|
1182
1158
|
}), this.connectChildChangeHandlers());
|
|
1183
1159
|
}
|
|
1184
1160
|
/**
|
|
@@ -1187,14 +1163,16 @@ class x extends f {
|
|
|
1187
1163
|
connectChildChangeHandlers() {
|
|
1188
1164
|
if (!this.settings) return;
|
|
1189
1165
|
const t = () => {
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1166
|
+
Promise.resolve().then(() => {
|
|
1167
|
+
if (this.activeTabId) {
|
|
1168
|
+
const e = this.tabs.find((i) => i.id === this.activeTabId);
|
|
1169
|
+
e && (this.tabValues[this.activeTabId] = this.getTabValues(e));
|
|
1170
|
+
}
|
|
1171
|
+
this.initialValues = {
|
|
1172
|
+
tabs: this.tabValues,
|
|
1173
|
+
activeTabId: this.activeTabId
|
|
1174
|
+
}, this.triggerDebouncedChange();
|
|
1175
|
+
});
|
|
1198
1176
|
};
|
|
1199
1177
|
Object.values(this.settings).forEach((e) => {
|
|
1200
1178
|
e instanceof f ? e.setOnChange(() => {
|
|
@@ -1204,12 +1182,18 @@ class x extends f {
|
|
|
1204
1182
|
});
|
|
1205
1183
|
}), this.tabs.forEach((e) => {
|
|
1206
1184
|
Object.entries(e.settings).forEach(([i, s]) => {
|
|
1207
|
-
(s instanceof f || s instanceof m) && (s instanceof
|
|
1208
|
-
|
|
1185
|
+
(s instanceof f || s instanceof m) && (s instanceof E ? (s._parentTabsSettings = this, s.setOnChange((n) => {
|
|
1186
|
+
Promise.resolve().then(() => {
|
|
1187
|
+
this.tabValues[e.id] = this.getTabValues(e), this.triggerDebouncedChange();
|
|
1188
|
+
});
|
|
1209
1189
|
})) : s instanceof f ? s.setOnChange(() => {
|
|
1210
|
-
|
|
1190
|
+
Promise.resolve().then(() => {
|
|
1191
|
+
this.tabValues[e.id] = this.getTabValues(e), this.triggerDebouncedChange();
|
|
1192
|
+
});
|
|
1211
1193
|
}) : s instanceof m && s.setOnChange(() => {
|
|
1212
|
-
|
|
1194
|
+
Promise.resolve().then(() => {
|
|
1195
|
+
this.tabValues[e.id] = this.getTabValues(e), this.triggerDebouncedChange();
|
|
1196
|
+
});
|
|
1213
1197
|
}));
|
|
1214
1198
|
});
|
|
1215
1199
|
});
|
|
@@ -1228,20 +1212,20 @@ class x extends f {
|
|
|
1228
1212
|
handleTabClick(t) {
|
|
1229
1213
|
var o, l;
|
|
1230
1214
|
if (t === this.activeTabId) return;
|
|
1231
|
-
const e = this.tabs.find((
|
|
1215
|
+
const e = this.tabs.find((h) => h.id === this.activeTabId);
|
|
1232
1216
|
e && (this.tabValues[this.activeTabId] = this.getTabValues(e)), this.previousTabId = this.activeTabId, this.activeTabId = t;
|
|
1233
1217
|
const i = (o = this.tabsContainer) == null ? void 0 : o.querySelectorAll(".tab-button");
|
|
1234
|
-
i == null || i.forEach((
|
|
1235
|
-
if (
|
|
1236
|
-
const r = this.tabs.find((
|
|
1237
|
-
|
|
1218
|
+
i == null || i.forEach((h) => {
|
|
1219
|
+
if (h instanceof HTMLElement) {
|
|
1220
|
+
const r = this.tabs.find((u) => u.label === h.textContent);
|
|
1221
|
+
h.classList.toggle("active", (r == null ? void 0 : r.id) === t);
|
|
1238
1222
|
}
|
|
1239
1223
|
}), this.updateSettingsFromTab(t);
|
|
1240
1224
|
const s = (l = this.container) == null ? void 0 : l.querySelector(".setting-group-content");
|
|
1241
1225
|
if (s) {
|
|
1242
1226
|
s.innerHTML = "";
|
|
1243
|
-
const
|
|
1244
|
-
Object.values(
|
|
1227
|
+
const h = this.settings;
|
|
1228
|
+
Object.values(h).forEach((r) => {
|
|
1245
1229
|
s.appendChild(r.draw());
|
|
1246
1230
|
});
|
|
1247
1231
|
}
|
|
@@ -1308,7 +1292,7 @@ class x extends f {
|
|
|
1308
1292
|
activeTabId: this.activeTabId
|
|
1309
1293
|
}, this.tabs.forEach((t) => {
|
|
1310
1294
|
Object.values(t.settings).forEach((e) => {
|
|
1311
|
-
e instanceof
|
|
1295
|
+
e instanceof E && e.updateInitialValues();
|
|
1312
1296
|
});
|
|
1313
1297
|
}));
|
|
1314
1298
|
}
|
|
@@ -1332,7 +1316,7 @@ class x extends f {
|
|
|
1332
1316
|
getTabValues(t) {
|
|
1333
1317
|
const e = {};
|
|
1334
1318
|
return Object.entries(t.settings).forEach(([i, s]) => {
|
|
1335
|
-
s instanceof
|
|
1319
|
+
s instanceof E || s instanceof f ? e[i] = s.getValues() : (s instanceof m, e[i] = s.value);
|
|
1336
1320
|
}), e;
|
|
1337
1321
|
}
|
|
1338
1322
|
/**
|
|
@@ -1360,7 +1344,7 @@ class x extends f {
|
|
|
1360
1344
|
settings: {}
|
|
1361
1345
|
// We don't clone callbacks - they should be set up again on the clone
|
|
1362
1346
|
};
|
|
1363
|
-
return new
|
|
1347
|
+
return new E(e);
|
|
1364
1348
|
}
|
|
1365
1349
|
/**
|
|
1366
1350
|
* Override setValue method to update the TabsSettings state
|
|
@@ -1409,6 +1393,10 @@ class x extends f {
|
|
|
1409
1393
|
const n = s.settings[e];
|
|
1410
1394
|
typeof n.setValue == "function" && (n.setValue(i), this.tabValues[t] = this.getTabValues(s), t !== this.activeTabId && this.onChange && this.onChange(this.getValues()));
|
|
1411
1395
|
}
|
|
1396
|
+
// Getter for tabs configuration
|
|
1397
|
+
getTabsConfiguration() {
|
|
1398
|
+
return this.tabs;
|
|
1399
|
+
}
|
|
1412
1400
|
}
|
|
1413
1401
|
const X = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
1414
1402
|
<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"/>
|
|
@@ -1448,10 +1436,10 @@ class mt extends f {
|
|
|
1448
1436
|
default: (t == null ? void 0 : t.size) ?? 0,
|
|
1449
1437
|
suffix: "px"
|
|
1450
1438
|
}),
|
|
1451
|
-
color: new
|
|
1439
|
+
color: new O({
|
|
1452
1440
|
default: (t == null ? void 0 : t.color) ?? "0, 0, 30"
|
|
1453
1441
|
}),
|
|
1454
|
-
opacity: new
|
|
1442
|
+
opacity: new y({
|
|
1455
1443
|
default: (t == null ? void 0 : t.opacity) ?? 100,
|
|
1456
1444
|
minValue: 0,
|
|
1457
1445
|
maxValue: 100
|
|
@@ -1498,10 +1486,10 @@ class ft extends f {
|
|
|
1498
1486
|
collapsed: t.collapsed,
|
|
1499
1487
|
hideCondition: t.hideCondition,
|
|
1500
1488
|
settings: {
|
|
1501
|
-
color: new
|
|
1489
|
+
color: new O({
|
|
1502
1490
|
default: t.colorDefault ?? "0, 0, 30"
|
|
1503
1491
|
}),
|
|
1504
|
-
opacity: new
|
|
1492
|
+
opacity: new y({
|
|
1505
1493
|
default: t.colorOpacityDefault ?? 100
|
|
1506
1494
|
}),
|
|
1507
1495
|
fontFamily: new B({
|
|
@@ -1564,9 +1552,9 @@ class V extends m {
|
|
|
1564
1552
|
draw() {
|
|
1565
1553
|
const t = this.value === "auto" ? "text" : "number", e = (o) => {
|
|
1566
1554
|
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", () => {
|
|
1567
|
-
const l = this.props.minValue ?? Number.MIN_SAFE_INTEGER,
|
|
1555
|
+
const l = this.props.minValue ?? Number.MIN_SAFE_INTEGER, h = this.props.maxValue ?? Number.MAX_SAFE_INTEGER;
|
|
1568
1556
|
let r = Number(o.value);
|
|
1569
|
-
r < l && (r = l), r >
|
|
1557
|
+
r < l && (r = l), r > h && (r = h), o.value = String(r);
|
|
1570
1558
|
}));
|
|
1571
1559
|
}, i = this.createInput({
|
|
1572
1560
|
value: this.value,
|
|
@@ -1593,8 +1581,8 @@ class V extends m {
|
|
|
1593
1581
|
if (l.toLowerCase() === "auto")
|
|
1594
1582
|
this.value = "auto";
|
|
1595
1583
|
else {
|
|
1596
|
-
const
|
|
1597
|
-
isNaN(
|
|
1584
|
+
const h = Number(l);
|
|
1585
|
+
isNaN(h) || (this.value = h);
|
|
1598
1586
|
}
|
|
1599
1587
|
this.onChange && this.onChange(this.value);
|
|
1600
1588
|
}), i;
|
|
@@ -1801,13 +1789,13 @@ class bt extends f {
|
|
|
1801
1789
|
...t == null ? void 0 : t.uploadProps,
|
|
1802
1790
|
default: (t == null ? void 0 : t.backgroundImage) ?? ""
|
|
1803
1791
|
}),
|
|
1804
|
-
opacity: new
|
|
1792
|
+
opacity: new y({
|
|
1805
1793
|
default: (t == null ? void 0 : t.opacity) ?? 100
|
|
1806
1794
|
}),
|
|
1807
|
-
backgroundColor: new
|
|
1795
|
+
backgroundColor: new O({
|
|
1808
1796
|
default: (t == null ? void 0 : t.backgroundColor) ?? "0, 0, 30"
|
|
1809
1797
|
}),
|
|
1810
|
-
opacityBG: new
|
|
1798
|
+
opacityBG: new y({
|
|
1811
1799
|
default: (t == null ? void 0 : t.opacityBG) ?? 100
|
|
1812
1800
|
})
|
|
1813
1801
|
}
|
|
@@ -1845,7 +1833,7 @@ export {
|
|
|
1845
1833
|
bt as BackgroundSettingSet,
|
|
1846
1834
|
mt as BorderSettingSet,
|
|
1847
1835
|
lt as ButtonSetting,
|
|
1848
|
-
|
|
1836
|
+
O as ColorSetting,
|
|
1849
1837
|
rt as DimensionSetting,
|
|
1850
1838
|
pt as GapSetting,
|
|
1851
1839
|
ft as HeaderTypographySettingSet,
|
|
@@ -1853,16 +1841,16 @@ export {
|
|
|
1853
1841
|
gt as MarginBottomSetting,
|
|
1854
1842
|
Ct as MarginSettingGroup,
|
|
1855
1843
|
b as NumberSetting,
|
|
1856
|
-
|
|
1844
|
+
y as OpacitySetting,
|
|
1857
1845
|
dt as SelectApiSettings,
|
|
1858
1846
|
B as SelectSetting,
|
|
1859
1847
|
m as Setting,
|
|
1860
1848
|
f as SettingGroup,
|
|
1861
1849
|
S as StringSetting,
|
|
1862
1850
|
vt as TabsContainerGroup,
|
|
1863
|
-
|
|
1851
|
+
E as TabsSettings,
|
|
1864
1852
|
ut as Toggle,
|
|
1865
1853
|
U as UploadSetting,
|
|
1866
1854
|
ct as WidthSetting,
|
|
1867
|
-
|
|
1855
|
+
M as iterateSettings
|
|
1868
1856
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -335,6 +335,7 @@ export declare interface SelectApiSettingProps<T = any> extends SettingProps<T>
|
|
|
335
335
|
getOptions?: () => SelectApiOption[];
|
|
336
336
|
getOptionsAsync?: () => Promise<SelectApiOption[]>;
|
|
337
337
|
loadingText?: string;
|
|
338
|
+
errorText?: string;
|
|
338
339
|
onChange?: (value: T) => void;
|
|
339
340
|
detectChange?: (value: T | undefined) => void;
|
|
340
341
|
}
|
|
@@ -359,6 +360,7 @@ export declare class SelectApiSettings<T = any> extends Setting<T, SelectApiSett
|
|
|
359
360
|
private updateOptionsList;
|
|
360
361
|
private updateButtonText;
|
|
361
362
|
setDetectChange(callback: (value: T | undefined) => void): void;
|
|
363
|
+
setValue(value: T): void;
|
|
362
364
|
}
|
|
363
365
|
|
|
364
366
|
export declare interface SelectOption {
|
|
@@ -615,6 +617,7 @@ export declare class TabsSettings<T extends Record<string, any>> extends Setting
|
|
|
615
617
|
* This allows programmatic updates to any tab, not just the active one
|
|
616
618
|
*/
|
|
617
619
|
updateTabSetting(tabId: string, settingKey: string, value: any): void;
|
|
620
|
+
getTabsConfiguration(): TabItem[];
|
|
618
621
|
}
|
|
619
622
|
|
|
620
623
|
declare interface TabsSettingsProps<T = any> extends SettingGroupProps<T> {
|
package/package.json
CHANGED