builder-settings-types 0.0.274 → 0.0.275
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.
|
@@ -84,7 +84,7 @@
|
|
|
84
84
|
<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"/>
|
|
85
85
|
<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="0.5" stroke-linecap="round" stroke-linejoin="round" opacity="0.5"/>
|
|
86
86
|
<path d="M9 1V17C4.58172 17 1 13.4183 1 9C1 4.58172 4.58172 1 9 1Z" fill="#667085" stroke="#667085" stroke-width="0.5" stroke-linecap="round" stroke-linejoin="round" opacity="0.5"/>
|
|
87
|
-
</svg>`;class H extends y{constructor(t={}){super({...t,icon:t.icon||It,title:t.title||"Color & Opacity",default:t.default||"#000000FF"}),this.inputType="color",this.element=null,this.colorInputEl=null,this.textInputEl=null,this.opacityInputEl=null,this.colorPreviewEl=null,this.detectChange=t.detectChange,this.value&&(this.value=H.normalizeHexWithOpacity(this.value))}static normalizeHexWithOpacity(t){return t=t.replace("#",""),t.length===3&&(t=t.split("").map(e=>e+e).join("")),t.length===6&&(t=t+"FF"),t.length===8&&/^[0-9A-Fa-f]{8}$/.test(t)?`#${t.toUpperCase()}`:(console.warn(`Invalid hex value "${t}", using default "#000000FF"`),"#000000FF")}getRgbColor(){return this.value?this.value.substring(0,7):"#000000"}getOpacityPercent(){if(!this.value)return 100;const t=this.value.substring(7,9),e=parseInt(t,16)/255;return Math.round(e*100)}static combineColorOpacity(t,e){const i=t.replace("#","").substring(0,6),n=Math.round(e/100*255).toString(16).toUpperCase().padStart(2,"0");return`#${i}${n}`}setValue(t){t===void 0||t===""?this.value="#000000FF":this.value=H.normalizeHexWithOpacity(t),this.updateInputElements(),this.updateColorPreview(),this.onChange&&this.onChange(this.value),this.detectChange&&this.detectChange(this.value)}updateInputElements(){this.value&&(this.colorInputEl&&(this.colorInputEl.value=this.getRgbColor()),this.textInputEl&&(this.textInputEl.value=this.value),this.opacityInputEl&&(this.opacityInputEl.value=this.getOpacityPercent().toString()))}updateColorPreview(){if(!this.colorPreviewEl||!this.value)return;const t=this.getRgbColor(),e=this.getOpacityPercent()/100,i=t.replace("#",""),s=parseInt(i.substring(0,2),16),n=parseInt(i.substring(2,4),16),o=parseInt(i.substring(4,6),16);this.colorPreviewEl.style.backgroundColor=`rgba(${s}, ${n}, ${o}, ${e})`}handleColorChange(t){const e=this.getOpacityPercent(),i=H.combineColorOpacity(t,e);this.setValue(i)}handleTextInput(t){const e=/^#[0-9A-Fa-f]{8}$/.test(t.trim()),i=/^#[0-9A-Fa-f]{6}$/.test(t.trim());return e||i?(this.setValue(t),!0):!1}handleOpacityChange(t){const e=this.getRgbColor(),i=Math.max(0,Math.min(100,t)),s=H.combineColorOpacity(e,i);this.setValue(s)}draw(){const t=document.createElement("div");if(t.className="color-with-opacity-setting-wrapper "+(this.props.wrapperClassName||""),this.props.title||this.props.icon){const o=document.createElement("div");if(o.className="icon-container",this.props.icon){const a=document.createElement("span");a.className="input-icon",a.innerHTML=this.props.icon,o.appendChild(a)}if(this.props.title){const a=document.createElement("span");a.className="input-label",a.textContent=this.props.title,o.appendChild(a)}t.appendChild(o)}const e=document.createElement("div");e.className="color-with-opacity-input-wrapper",this.colorInputEl=document.createElement("input"),this.colorInputEl.type="color",this.colorInputEl.className="color-with-opacity-picker",this.getDataPropsPath()&&this.colorInputEl.setAttribute("data-test-id",`${this.getDataPropsPath()}_color`),this.colorPreviewEl=document.createElement("div"),this.colorPreviewEl.className="color-with-opacity-preview",this.textInputEl=document.createElement("input"),this.textInputEl.type="text",this.textInputEl.className="color-with-opacity-text-input",this.textInputEl.placeholder="#000000FF",this.getDataPropsPath()&&this.textInputEl.setAttribute("data-test-id",`${this.getDataPropsPath()}_text`),this.updateInputElements(),this.updateColorPreview(),this.colorInputEl.addEventListener("input",o=>{const a=o.target;this.handleColorChange(a.value),this.textInputEl&&(this.textInputEl.value=this.value||"#000000FF"),this.updateColorPreview()}),this.textInputEl.addEventListener("input",o=>{const a=o.target;this.handleTextInput(a.value)?(this.colorInputEl&&(this.colorInputEl.value=this.getRgbColor()),this.updateColorPreview(),e.classList.remove("error")):a.value.trim()===""?e.classList.remove("error"):e.classList.add("error")}),this.textInputEl.addEventListener("blur",o=>{const a=o.target;a.value.trim()===""&&(a.value=this.value||"#000000FF",e.classList.remove("error"))}),this.colorPreviewEl.addEventListener("click",()=>{var o;(o=this.colorInputEl)==null||o.click()}),e.appendChild(this.colorInputEl),e.appendChild(this.colorPreviewEl),e.appendChild(this.textInputEl);const i=document.createElement("div");i.className="color-with-opacity-opacity-wrapper",this.opacityInputEl=document.createElement("input"),this.opacityInputEl.type="number",this.opacityInputEl.className="color-with-opacity-opacity-input",this.opacityInputEl.value=this.getOpacityPercent().toString(),this.opacityInputEl.min="0",this.opacityInputEl.max="100",this.opacityInputEl.step="1",this.opacityInputEl.placeholder="100",this.getDataPropsPath()&&this.opacityInputEl.setAttribute("data-test-id",`${this.getDataPropsPath()}_opacity`);const s=document.createElement("span");s.className="color-with-opacity-opacity-suffix",s.textContent="%",this.opacityInputEl.addEventListener("input",o=>{const a=o.target,l=parseFloat(a.value);isNaN(l)||(this.handleOpacityChange(l),this.textInputEl&&(this.textInputEl.value=this.value||"#000000FF"),this.updateColorPreview())}),this.opacityInputEl.addEventListener("blur",o=>{const a=o.target;let l=parseFloat(a.value);isNaN(l)&&(l=this.getOpacityPercent()),l=Math.max(0,Math.min(100,l)),a.value=l.toString(),this.handleOpacityChange(l),this.textInputEl&&(this.textInputEl.value=this.value||"#000000FF"),this.updateColorPreview()}),i.appendChild(this.opacityInputEl),i.appendChild(s);const n=document.createElement("div");return n.className="color-with-opacity-controls-wrapper",n.appendChild(e),n.appendChild(i),t.appendChild(n),this.element=t,this.updateInputElements(),this.updateColorPreview(),t}getElement(){return this.element}getValue(){return this.value}getRgbaValue(){if(!this.value)return"rgba(0, 0, 0, 1)";const t=this.getRgbColor(),e=this.getOpacityPercent()/100,i=t.replace("#",""),s=parseInt(i.substring(0,2),16),n=parseInt(i.substring(2,4),16),o=parseInt(i.substring(4,6),16);return`rgba(${s}, ${n}, ${o}, ${e})`}getColorAndOpacity(){return{color:this.getRgbColor(),opacity:this.getOpacityPercent()}}}class Nt extends y{constructor(t={}){super(t),this.inputType="text",t.onChange&&this.setOnChange(t.onChange)}setValue(t){this.value=t,this.textareaEl&&(this.textareaEl.value=t),this.onChange&&this.onChange(t),this.props.detectChange&&this.props.detectChange(t)}draw(){const t=document.createElement("div");if(t.className="html-setting-wrapper "+(this.props.wrapperClassName||""),this.props.title||this.props.icon){const n=document.createElement("div");if(n.className="icon-container",this.props.icon){const o=this.createIcon(this.props.icon);n.appendChild(o)}if(this.props.title){const o=this.createLabel(this.props.title);n.appendChild(o)}t.appendChild(n)}const e=document.createElement("textarea");this.textareaEl=e,e.value=this.value||"",e.placeholder=this.props.placeholder||"Paste your HTML here...",e.className="html-setting-textarea "+(this.props.textareaClassName||""),e.rows=this.props.rows||6,this.getDataPropsPath()&&e.setAttribute("data-test-id",this.getDataPropsPath()),this.props.maxLength!==void 0&&(e.maxLength=this.props.maxLength),this.props.className&&e.classList.add(this.props.className);const i=n=>{const a=n.target.value;this.value=a,this.onChange&&this.onChange(this.value),this.props.detectChange&&this.props.detectChange(this.value)},s=n=>{this.onBlur&&this.value!==void 0&&this.onBlur(this.value)};return e.addEventListener("input",i),e.addEventListener("change",i),e.addEventListener("blur",s),t.appendChild(e),t}}class M extends y{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=document.createElement("div");if(t.className="number-setting-wrapper "+(this.props.wrapperClassName||""),this.props.title||this.props.icon){const s=document.createElement("div");if(s.className="icon-container",this.props.icon){const n=document.createElement("span");n.className="input-icon",n.innerHTML=this.props.icon,s.appendChild(n)}if(this.props.title){const n=document.createElement("span");n.className="input-label",n.textContent=this.props.title,s.appendChild(n)}t.appendChild(s)}const e=document.createElement("div");e.className="number-setting-input-container";const i=document.createElement("input");if(i.type="number",i.className="number-setting-input "+(this.props.inputClassName||""),i.value=String(this.value??""),i.placeholder=this.props.placeholder||"",this.getDataPropsPath()&&i.setAttribute("data-test-id",this.getDataPropsPath()),this.props.minValue!==void 0&&(i.min=String(this.props.minValue)),this.props.maxValue!==void 0&&(i.max=String(this.props.maxValue)),this.props.step!==void 0&&(i.step=String(this.props.step)),i.addEventListener("input",()=>{const s=this.props.minValue??Number.MIN_SAFE_INTEGER,n=this.props.maxValue??Number.MAX_SAFE_INTEGER;let o=Number(i.value);o<s&&(o=s),o>n&&(o=n),String(o)!==i.value&&(i.value=String(o)),this.setValue(o)}),i.addEventListener("blur",()=>{var n,o;const s=this.validateValue(Number(i.value));s!==Number(i.value)&&(i.value=String(s),this.setValue(s)),(o=(n=this.props).onBlur)==null||o.call(n)}),e.appendChild(i),this.props.suffix&&this.props.suffix!=="none"){const s=document.createElement("span");s.className="suffix-label",s.textContent=this.props.suffix,e.appendChild(s)}return t.appendChild(e),this.inputElement=i,t}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,t!==void 0&&this.setValue(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 Vt=`
|
|
87
|
+
</svg>`;class T extends y{constructor(t={}){super({...t,icon:t.icon||It,title:t.title||"Color & Opacity",default:t.default||"#000000FF"}),this.inputType="color",this.element=null,this.colorInputEl=null,this.textInputEl=null,this.opacityInputEl=null,this.colorPreviewEl=null,this.detectChange=t.detectChange,this.value&&(this.value=T.normalizeHexWithOpacity(this.value))}static normalizeHexWithOpacity(t){return t=t.replace("#",""),t.length===3&&(t=t.split("").map(e=>e+e).join("")),t.length===6&&(t=t+"FF"),t.length===8&&/^[0-9A-Fa-f]{8}$/.test(t)?`#${t.toUpperCase()}`:(console.warn(`Invalid hex value "${t}", using default "#000000FF"`),"#000000FF")}getRgbColor(){return this.value?this.value.substring(0,7):"#000000"}getOpacityPercent(){if(!this.value)return 100;const t=this.value.substring(7,9),e=parseInt(t,16)/255;return Math.round(e*100)}static combineColorOpacity(t,e){const i=t.replace("#","").substring(0,6),n=Math.round(e/100*255).toString(16).toUpperCase().padStart(2,"0");return`#${i}${n}`}setValue(t){t===void 0||t===""?this.value="#000000FF":this.value=T.normalizeHexWithOpacity(t),this.updateInputElements(),this.updateColorPreview(),this.onChange&&this.onChange(this.value),this.detectChange&&this.detectChange(this.value)}updateInputElements(){this.value&&(this.colorInputEl&&(this.colorInputEl.value=this.getRgbColor()),this.textInputEl&&(this.textInputEl.value=this.value),this.opacityInputEl&&(this.opacityInputEl.value=this.getOpacityPercent().toString()))}updateColorPreview(){if(!this.colorPreviewEl||!this.value)return;const t=this.getRgbColor(),e=this.getOpacityPercent()/100,i=t.replace("#",""),s=parseInt(i.substring(0,2),16),n=parseInt(i.substring(2,4),16),o=parseInt(i.substring(4,6),16);this.colorPreviewEl.style.backgroundColor=`rgba(${s}, ${n}, ${o}, ${e})`}handleColorChange(t){const e=this.getOpacityPercent(),i=T.combineColorOpacity(t,e);this.setValue(i)}handleTextInput(t){const e=/^#[0-9A-Fa-f]{8}$/.test(t.trim()),i=/^#[0-9A-Fa-f]{6}$/.test(t.trim());return e||i?(this.setValue(t),!0):!1}handleOpacityChange(t){const e=this.getRgbColor(),i=Math.max(0,Math.min(100,t)),s=T.combineColorOpacity(e,i);this.setValue(s)}draw(){const t=document.createElement("div");if(t.className="color-with-opacity-setting-wrapper "+(this.props.wrapperClassName||""),this.props.title||this.props.icon){const o=document.createElement("div");if(o.className="icon-container",this.props.icon){const a=document.createElement("span");a.className="input-icon",a.innerHTML=this.props.icon,o.appendChild(a)}if(this.props.title){const a=document.createElement("span");a.className="input-label",a.textContent=this.props.title,o.appendChild(a)}t.appendChild(o)}const e=document.createElement("div");e.className="color-with-opacity-input-wrapper",this.colorInputEl=document.createElement("input"),this.colorInputEl.type="color",this.colorInputEl.className="color-with-opacity-picker",this.getDataPropsPath()&&this.colorInputEl.setAttribute("data-test-id",`${this.getDataPropsPath()}_color`),this.colorPreviewEl=document.createElement("div"),this.colorPreviewEl.className="color-with-opacity-preview",this.textInputEl=document.createElement("input"),this.textInputEl.type="text",this.textInputEl.className="color-with-opacity-text-input",this.textInputEl.placeholder="#000000FF",this.getDataPropsPath()&&this.textInputEl.setAttribute("data-test-id",`${this.getDataPropsPath()}_text`),this.updateInputElements(),this.updateColorPreview(),this.colorInputEl.addEventListener("input",o=>{const a=o.target;this.handleColorChange(a.value),this.textInputEl&&(this.textInputEl.value=this.value||"#000000FF"),this.updateColorPreview()}),this.textInputEl.addEventListener("input",o=>{const a=o.target;this.handleTextInput(a.value)?(this.colorInputEl&&(this.colorInputEl.value=this.getRgbColor()),this.updateColorPreview(),e.classList.remove("error")):a.value.trim()===""?e.classList.remove("error"):e.classList.add("error")}),this.textInputEl.addEventListener("blur",o=>{const a=o.target;a.value.trim()===""&&(a.value=this.value||"#000000FF",e.classList.remove("error"))}),this.colorPreviewEl.addEventListener("click",()=>{var o;(o=this.colorInputEl)==null||o.click()}),e.appendChild(this.colorInputEl),e.appendChild(this.colorPreviewEl),e.appendChild(this.textInputEl);const i=document.createElement("div");i.className="color-with-opacity-opacity-wrapper",this.opacityInputEl=document.createElement("input"),this.opacityInputEl.type="number",this.opacityInputEl.className="color-with-opacity-opacity-input",this.opacityInputEl.value=this.getOpacityPercent().toString(),this.opacityInputEl.min="0",this.opacityInputEl.max="100",this.opacityInputEl.step="1",this.opacityInputEl.placeholder="100",this.getDataPropsPath()&&this.opacityInputEl.setAttribute("data-test-id",`${this.getDataPropsPath()}_opacity`);const s=document.createElement("span");s.className="color-with-opacity-opacity-suffix",s.textContent="%",this.opacityInputEl.addEventListener("input",o=>{const a=o.target,l=parseFloat(a.value);isNaN(l)||(this.handleOpacityChange(l),this.textInputEl&&(this.textInputEl.value=this.value||"#000000FF"),this.updateColorPreview())}),this.opacityInputEl.addEventListener("blur",o=>{const a=o.target;let l=parseFloat(a.value);isNaN(l)&&(l=this.getOpacityPercent()),l=Math.max(0,Math.min(100,l)),a.value=l.toString(),this.handleOpacityChange(l),this.textInputEl&&(this.textInputEl.value=this.value||"#000000FF"),this.updateColorPreview()}),i.appendChild(this.opacityInputEl),i.appendChild(s);const n=document.createElement("div");return n.className="color-with-opacity-controls-wrapper",n.appendChild(e),n.appendChild(i),t.appendChild(n),this.element=t,this.updateInputElements(),this.updateColorPreview(),t}getElement(){return this.element}getValue(){return this.value}getRgbaValue(){if(!this.value)return"rgba(0, 0, 0, 1)";const t=this.getRgbColor(),e=this.getOpacityPercent()/100,i=t.replace("#",""),s=parseInt(i.substring(0,2),16),n=parseInt(i.substring(2,4),16),o=parseInt(i.substring(4,6),16);return`rgba(${s}, ${n}, ${o}, ${e})`}getColorAndOpacity(){return{color:this.getRgbColor(),opacity:this.getOpacityPercent()}}}class Nt extends y{constructor(t={}){super(t),this.inputType="text",t.onChange&&this.setOnChange(t.onChange)}setValue(t){this.value=t,this.textareaEl&&(this.textareaEl.value=t),this.onChange&&this.onChange(t),this.props.detectChange&&this.props.detectChange(t)}draw(){const t=document.createElement("div");if(t.className="html-setting-wrapper "+(this.props.wrapperClassName||""),this.props.title||this.props.icon){const n=document.createElement("div");if(n.className="icon-container",this.props.icon){const o=this.createIcon(this.props.icon);n.appendChild(o)}if(this.props.title){const o=this.createLabel(this.props.title);n.appendChild(o)}t.appendChild(n)}const e=document.createElement("textarea");this.textareaEl=e,e.value=this.value||"",e.placeholder=this.props.placeholder||"Paste your HTML here...",e.className="html-setting-textarea "+(this.props.textareaClassName||""),e.rows=this.props.rows||6,this.getDataPropsPath()&&e.setAttribute("data-test-id",this.getDataPropsPath()),this.props.maxLength!==void 0&&(e.maxLength=this.props.maxLength),this.props.className&&e.classList.add(this.props.className);const i=n=>{const a=n.target.value;this.value=a,this.onChange&&this.onChange(this.value),this.props.detectChange&&this.props.detectChange(this.value)},s=n=>{this.onBlur&&this.value!==void 0&&this.onBlur(this.value)};return e.addEventListener("input",i),e.addEventListener("change",i),e.addEventListener("blur",s),t.appendChild(e),t}}class M extends y{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=document.createElement("div");if(t.className="number-setting-wrapper "+(this.props.wrapperClassName||""),this.props.title||this.props.icon){const s=document.createElement("div");if(s.className="icon-container",this.props.icon){const n=document.createElement("span");n.className="input-icon",n.innerHTML=this.props.icon,s.appendChild(n)}if(this.props.title){const n=document.createElement("span");n.className="input-label",n.textContent=this.props.title,s.appendChild(n)}t.appendChild(s)}const e=document.createElement("div");e.className="number-setting-input-container";const i=document.createElement("input");if(i.type="number",i.className="number-setting-input "+(this.props.inputClassName||""),i.value=String(this.value??""),i.placeholder=this.props.placeholder||"",this.getDataPropsPath()&&i.setAttribute("data-test-id",this.getDataPropsPath()),this.props.minValue!==void 0&&(i.min=String(this.props.minValue)),this.props.maxValue!==void 0&&(i.max=String(this.props.maxValue)),this.props.step!==void 0&&(i.step=String(this.props.step)),i.addEventListener("input",()=>{const s=this.props.minValue??Number.MIN_SAFE_INTEGER,n=this.props.maxValue??Number.MAX_SAFE_INTEGER;let o=Number(i.value);o<s&&(o=s),o>n&&(o=n),String(o)!==i.value&&(i.value=String(o)),this.setValue(o)}),i.addEventListener("blur",()=>{var n,o;const s=this.validateValue(Number(i.value));s!==Number(i.value)&&(i.value=String(s),this.setValue(s)),(o=(n=this.props).onBlur)==null||o.call(n)}),e.appendChild(i),this.props.suffix&&this.props.suffix!=="none"){const s=document.createElement("span");s.className="suffix-label",s.textContent=this.props.suffix,e.appendChild(s)}return t.appendChild(e),this.inputElement=i,t}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,t!==void 0&&this.setValue(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 Vt=`
|
|
88
88
|
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
89
89
|
<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"/>
|
|
90
90
|
<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"/>
|
|
@@ -113,13 +113,13 @@
|
|
|
113
113
|
<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"
|
|
114
114
|
stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
|
|
115
115
|
</svg>
|
|
116
|
-
`}].forEach(n=>{const o=document.createElement("button");o.className="align-option-button",o.innerHTML=n.icon,this.getDataPropsPath()&&o.setAttribute("data-test-id",`${this.getDataPropsPath()}_${n.name}`),this.value===n.name&&o.classList.add("selected"),o.addEventListener("click",()=>{var a;i.querySelectorAll(".align-option-button").forEach(l=>l.classList.remove("selected")),o.classList.add("selected"),this.value=n.name,(a=this.onChange)==null||a.call(this,this.value)}),i.appendChild(o)}),t.appendChild(i),t}}class
|
|
116
|
+
`}].forEach(n=>{const o=document.createElement("button");o.className="align-option-button",o.innerHTML=n.icon,this.getDataPropsPath()&&o.setAttribute("data-test-id",`${this.getDataPropsPath()}_${n.name}`),this.value===n.name&&o.classList.add("selected"),o.addEventListener("click",()=>{var a;i.querySelectorAll(".align-option-button").forEach(l=>l.classList.remove("selected")),o.classList.add("selected"),this.value=n.name,(a=this.onChange)==null||a.call(this,this.value)}),i.appendChild(o)}),t.appendChild(i),t}}class Tt extends y{constructor(t){super(t),this.inputType="button",this.bgWithAlpha="rgba(145, 158, 171, 0.08)"}draw(){const t=document.createElement("button");t.className="button-setting "+(this.props.className||""),t.textContent=this.props.label,t.style.borderColor=this.props.borderColor||"rgba(145, 158, 171, 0.32)",this.getDataPropsPath()&&t.setAttribute("data-test-id",this.getDataPropsPath());const e=this.props.backgroundColor||"rgba(0,0,0,0)",i=this.props.textColor||"black";t.style.backgroundColor=e,t.style.color=i;let s=e;const n=e.match(/^rgba\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)\s*\)$/i);if(n){let a=+n[1],l=+n[2],r=+n[3],h=+n[4];h>=1?(a=Math.round(a*.9),l=Math.round(l*.9),r=Math.round(r*.9)):h=Math.min(1,h+.12),s=`rgba(${a},${l},${r},${h})`}t.addEventListener("mouseenter",()=>{console.log("hoverBg",s),t.style.setProperty("background-color",s,"important")}),t.addEventListener("mouseleave",()=>{t.style.setProperty("background-color",e,"important")}),t.addEventListener("click",()=>{var a,l;return(l=(a=this.props).onClick)==null?void 0:l.call(a)});const o=document.createElement("div");return o.className="button-setting-wrapper "+(this.props.wrapperClassName||""),o.appendChild(t),o}}class Ht extends y{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 M({title:"Width",default:this.value.width,suffix:"px",minValue:this.minWidth,maxValue:this.maxWidth,icon:Pt}),this.heightSetting=new M({title:"Height",default:this.value.height,suffix:"px",minValue:this.minHeight,maxValue:this.maxHeight,icon:$t}),this.widthSetting.setOnChange(this.handleWidthChange.bind(this)),this.heightSetting.setOnChange(this.handleHeightChange.bind(this))}handleWidthChange(t){if(!this.isUpdating&&!(isNaN(t)||t<0)){t=Math.max(this.minWidth,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)||t<0)){t=Math.max(this.minHeight,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")),t.style.transform="scale(0.9)",setTimeout(()=>{t.style.transform="scale(1)"},100)}getLockSVG(t){return t?`
|
|
117
117
|
<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 10 10" fill="none">
|
|
118
118
|
<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"/>
|
|
119
119
|
</svg>`:`
|
|
120
120
|
<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10" viewBox="0 0 10 10" fill="none">
|
|
121
121
|
<path d="M2.91663 4.58333V3.33333C2.91663 2.18274 3.84937 1.25 4.99996 1.25M3.66663 8.75H6.33329C7.03336 8.75 7.38339 8.75 7.65078 8.61376C7.88598 8.49392 8.07721 8.30269 8.19705 8.06749C8.33329 7.8001 8.33329 7.45007 8.33329 6.75V6.58333C8.33329 5.88327 8.33329 5.53323 8.19705 5.26584C8.07721 5.03064 7.88598 4.83942 7.65078 4.71958C7.38339 4.58333 7.03336 4.58333 6.33329 4.58333H3.66663C2.96656 4.58333 2.61653 4.58333 2.34914 4.71958C2.11394 4.83942 1.92271 5.03064 1.80287 5.26584C1.66663 5.53323 1.66663 5.88327 1.66663 6.58333V6.75C1.66663 7.45007 1.66663 7.8001 1.80287 8.06749C1.92271 8.30269 2.11394 8.49392 2.34914 8.61376C2.61653 8.75 2.96656 8.75 3.66663 8.75Z" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"/>
|
|
122
|
-
</svg>`}setValue(t){if(t&&typeof t.width=="number"&&typeof t.height=="number"){let e=Math.max(this.minWidth,t.width);this.maxWidth&&(e=Math.min(this.maxWidth,e));let i=Math.max(this.minHeight,t.height);this.maxHeight&&(i=Math.min(this.maxHeight,i)),this.value={width:e,height:i},this.locked&&this.value.height>0&&(this.aspectRatio=this.value.width/this.value.height),this.isUpdating=!0;try{this.widthSetting.setValue(this.value.width),this.heightSetting.setValue(this.value.height)}finally{this.isUpdating=!1}}}draw(){const t=document.createElement("div");t.className="dimension-setting-container",this.locked&&t.classList.add("aspect-locked");const e=this.widthSetting.draw(),i=this.heightSetting.draw(),s=document.createElement("div");s.className="dimension-bracket";const n=document.createElement("button");return n.className="dimension-lock-icon",n.setAttribute("type","button"),n.setAttribute("aria-pressed",String(this.locked)),n.setAttribute("aria-label",this.locked?"Unlock aspect ratio":"Lock aspect ratio"),n.title=this.locked?"Unlock aspect ratio":"Lock aspect ratio",n.innerHTML=this.getLockSVG(this.locked),n.onclick=o=>{o.preventDefault(),this.toggleLock(n)},s.appendChild(n),t.appendChild(e),t.appendChild(s),t.appendChild(i),t}isLocked(){return this.locked}setLocked(t){if(this.locked!==t){if(this.locked=t,this.locked&&this.value){const{width:i,height:s}=this.value;s>0&&(this.aspectRatio=i/s)}const e=document.querySelector(".dimension-setting-container .dimension-lock-icon");if(e instanceof HTMLElement){e.innerHTML=this.getLockSVG(this.locked),e.setAttribute("aria-pressed",String(this.locked)),e.title=this.locked?"Unlock aspect ratio":"Lock aspect ratio";const i=e.closest(".dimension-setting-container");i&&(this.locked?i.classList.add("aspect-locked"):i.classList.remove("aspect-locked"))}}}}const
|
|
122
|
+
</svg>`}setValue(t){if(t&&typeof t.width=="number"&&typeof t.height=="number"){let e=Math.max(this.minWidth,t.width);this.maxWidth&&(e=Math.min(this.maxWidth,e));let i=Math.max(this.minHeight,t.height);this.maxHeight&&(i=Math.min(this.maxHeight,i)),this.value={width:e,height:i},this.locked&&this.value.height>0&&(this.aspectRatio=this.value.width/this.value.height),this.isUpdating=!0;try{this.widthSetting.setValue(this.value.width),this.heightSetting.setValue(this.value.height)}finally{this.isUpdating=!1}}}draw(){const t=document.createElement("div");t.className="dimension-setting-container",this.locked&&t.classList.add("aspect-locked");const e=this.widthSetting.draw(),i=this.heightSetting.draw(),s=document.createElement("div");s.className="dimension-bracket";const n=document.createElement("button");return n.className="dimension-lock-icon",n.setAttribute("type","button"),n.setAttribute("aria-pressed",String(this.locked)),n.setAttribute("aria-label",this.locked?"Unlock aspect ratio":"Lock aspect ratio"),n.title=this.locked?"Unlock aspect ratio":"Lock aspect ratio",n.innerHTML=this.getLockSVG(this.locked),n.onclick=o=>{o.preventDefault(),this.toggleLock(n)},s.appendChild(n),t.appendChild(e),t.appendChild(s),t.appendChild(i),t}isLocked(){return this.locked}setLocked(t){if(this.locked!==t){if(this.locked=t,this.locked&&this.value){const{width:i,height:s}=this.value;s>0&&(this.aspectRatio=i/s)}const e=document.querySelector(".dimension-setting-container .dimension-lock-icon");if(e instanceof HTMLElement){e.innerHTML=this.getLockSVG(this.locked),e.setAttribute("aria-pressed",String(this.locked)),e.title=this.locked?"Unlock aspect ratio":"Lock aspect ratio";const i=e.closest(".dimension-setting-container");i&&(this.locked?i.classList.add("aspect-locked"):i.classList.remove("aspect-locked"))}}}}const Pt=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
123
123
|
<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"/>
|
|
124
124
|
</svg>`,$t=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
125
125
|
<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"/>
|
|
@@ -172,7 +172,7 @@
|
|
|
172
172
|
<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">
|
|
173
173
|
<polyline points="6 9 12 15 18 9"></polyline>
|
|
174
174
|
</svg>
|
|
175
|
-
`;class
|
|
175
|
+
`;class Ut extends y{constructor(t={}){if(super(t),this.inputType="select",this._options=[],this.isOpen=!1,this.selectedOptionIndex=null,this.optionsListEl=null,this.svgContainer=null,this.buttonEl=null,this.isLoading=!1,this.container=null,this.hasInitializedOptions=!1,this.selectedOptionIndex=null,t.default!==void 0&&(this.value=t.default),this.initializeOptions(t),!t.getOptionsAsync&&this.value!==void 0){const e=this._options.findIndex(i=>JSON.stringify(i.value)===JSON.stringify(this.value));e!==-1&&(this.selectedOptionIndex=e)}t.onChange&&this.setOnChange(t.onChange),t.detectChange&&(this.detectChangeCallback=t.detectChange)}initializeOptions(t){this.hasInitializedOptions&&!t.getOptionsAsync||(this._options=[],t.options&&(this._options=[...t.options]),t.getOptions&&this._options.push(...t.getOptions()),t.getOptionsAsync?this.isLoading=!0:this.hasInitializedOptions=!0)}createOption(t,e){const i=document.createElement("li");i.classList.add("select-api-option"),i.textContent=t.name,i.dataset.index=String(e);const s=document.createElement("input");return s.type="radio",s.classList.add("select-api-radio"),s.name="select-api-radio-group",i.appendChild(s),this.selectedOptionIndex===e&&(s.checked=!0),i}draw(){const t=document.createElement("div");t.classList.add("select-api-container"),this.container=t;const e=document.createElement("div");if(e.classList.add("select-api-button"),this.getDataPropsPath()&&e.setAttribute("data-test-id",this.getDataPropsPath()),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 o=document.createElement("span");if(o.className="select-value",this.isLoading)o.textContent=this.props.loadingText||"Loading options...";else{const a=this.selectedOptionIndex!==null&&this._options&&this.selectedOptionIndex>=0&&this.selectedOptionIndex<this._options.length?this._options[this.selectedOptionIndex]:null,l=a&&typeof a.name=="string"?a.name:"Select an option";o.textContent=l}e.appendChild(o)}else{const n=document.createElement("span");if(this.isLoading)n.textContent=this.props.loadingText||"Loading options...";else{const o=this.selectedOptionIndex!==null&&this._options&&this.selectedOptionIndex>=0&&this.selectedOptionIndex<this._options.length?this._options[this.selectedOptionIndex]:null,a=o&&typeof o.name=="string"?o.name:"Select an option";n.textContent=a}e.appendChild(n)}e.onclick=()=>{var n,o;this.isLoading||(this.isOpen=!this.isOpen,(n=this.optionsListEl)==null||n.classList.toggle("open",this.isOpen),(o=this.svgContainer)==null||o.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,o)=>{const a=this.createOption(n,o);a.onclick=l=>this.selectApiOption(l,o,e),i.appendChild(a)}),t.appendChild(i);const s=document.createElement("div");return s.classList.add("svg-container"),s.innerHTML=zt,t.appendChild(s),s.onclick=()=>{var n,o;this.isLoading||(this.isOpen=!this.isOpen,(n=this.optionsListEl)==null||n.classList.toggle("open",this.isOpen),(o=this.svgContainer)==null||o.classList.toggle("open",this.isOpen))},this.optionsListEl=i,this.svgContainer=s,this.props.getOptionsAsync&&!this.hasInitializedOptions?(this.isLoading=!0,this.updateButtonText(),this.props.getOptionsAsync().then(n=>{const o=new Set(this._options.map(l=>JSON.stringify(l.value))),a=n.filter(l=>!o.has(JSON.stringify(l.value)));if(this._options.push(...a),this.isLoading=!1,this.hasInitializedOptions=!0,this.value!==void 0){const l=this._options.findIndex(r=>JSON.stringify(r.value)===JSON.stringify(this.value));this.selectedOptionIndex=l!==-1?l:null}else this.selectedOptionIndex=null;this.updateOptionsList(),this.updateButtonText()}).catch(n=>{console.error("Failed to fetch async options:",n),this.isLoading=!1,this.updateButtonText(this.props.errorText||"Error: Could not load options",!0)})):this.props.getOptionsAsync&&this._options.length<=1&&(this.isLoading=!0,this.updateButtonText(),this.props.getOptionsAsync().then(n=>{const o=new Set(this._options.map(l=>JSON.stringify(l.value))),a=n.filter(l=>!o.has(JSON.stringify(l.value)));if(this._options.push(...a),this.isLoading=!1,this.value!==void 0){const l=this._options.findIndex(r=>JSON.stringify(r.value)===JSON.stringify(this.value));this.selectedOptionIndex=l!==-1?l:null}else this.selectedOptionIndex=null;this.updateOptionsList(),this.updateButtonText()}).catch(n=>{console.error("Failed to fetch async options:",n),this.isLoading=!1,this.updateButtonText(this.props.errorText||"Error: Could not load options",!0)})),t}getJson(t=!0){return JSON.stringify(t?{}:{value:this.value},null,2)}selectApiOption(t,e,i){var l,r,h,p;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 o=this._options[e].value;this.value=o;const a=i.querySelector(".select-value");if(a)a.textContent=this._options[e].name;else{const d=i.firstChild;d&&d.tagName==="SPAN"&&(d.textContent=this._options[e].name)}this.isOpen=!1,(r=this.optionsListEl)==null||r.classList.remove("open"),(h=this.svgContainer)==null||h.classList.remove("open"),(p=this.onChange)==null||p.call(this,o),this.detectChangeCallback&&this.detectChangeCallback(o)}updateOptionsList(){!this.optionsListEl||!this.buttonEl||(this.optionsListEl.innerHTML="",this._options.forEach((t,e)=>{var s;const i=this.createOption(t,e);i.onclick=n=>{this.buttonEl&&this.selectApiOption(n,e,this.buttonEl)},(s=this.optionsListEl)==null||s.appendChild(i)}))}updateButtonText(t,e=!1){if(!this.buttonEl)return;const i=this.buttonEl.querySelector(".select-value")||this.buttonEl.firstChild;if(i)if(e)i.textContent=t||"Error",this.buttonEl.classList.add("error"),this.buttonEl.setAttribute("disabled","true"),this.optionsListEl&&this.optionsListEl.classList.remove("open"),this.svgContainer&&(this.svgContainer.style.display="none");else if(this.isLoading)i.textContent=this.props.loadingText||"Loading options...",this.buttonEl.classList.remove("error"),this.buttonEl.removeAttribute("disabled"),this.svgContainer&&(this.svgContainer.style.display="");else{const s=this.selectedOptionIndex!==null&&this._options&&this.selectedOptionIndex>=0&&this.selectedOptionIndex<this._options.length?this._options[this.selectedOptionIndex]:null,n=s&&typeof s.name=="string"?s.name:"Select an option";i.textContent=t||n,this.buttonEl.classList.remove("error"),this.buttonEl.removeAttribute("disabled"),this.svgContainer&&(this.svgContainer.style.display="")}}setDetectChange(t){this.detectChangeCallback=t}setValue(t){this.value=t,this.selectedOptionIndex=this._options.findIndex(e=>JSON.stringify(e.value)===JSON.stringify(t)),this.updateButtonText()}}class qt extends y{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 o,a;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=((a=(o=this.props.options)==null?void 0:o.find(l=>l.value===this.value))==null?void 0:a.status)??!1,this.getDataPropsPath()&&s.setAttribute("data-test-id",this.getDataPropsPath()),s.addEventListener("change",()=>{var r,h;const l=((h=(r=this.props.options)==null?void 0:r.find(p=>p.status===s.checked))==null?void 0:h.value)??"";this.value=l,this.onChange&&this.onChange(this.value),this.detectChangeCallback&&this.detectChangeCallback(this.value)});const n=document.createElement("span");if(n.className="toggle-slider",this.props.activeColor||this.props.inactiveColor){const l=document.createElement("style"),r=this.props.activeColor||"#4CAF50",h=this.props.inactiveColor||"#ccc";l.textContent=`
|
|
176
176
|
.toggle-switch input:checked + .toggle-slider {
|
|
177
177
|
background-color: ${r};
|
|
178
178
|
}
|
|
@@ -186,7 +186,7 @@
|
|
|
186
186
|
</svg>`;class Zt extends M{constructor(t={}){super({...t,minValue:t.minValue??0,maxValue:t.maxValue??1e3,icon:t.icon||Jt,title:t.title||"Margin Bottom",default:t.default??20,wrapperClassName:"margin-bottom-wrapper "+(t.wrapperClassName||"")}),this.inputType="number"}}const Xt=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
187
187
|
<path d="M15.75 7.25H2.25m9.9 9h-6.3c-1.26 0-1.89 0-2.371-.245a2.25 2.25 0 0 1-.984-.983c-.245-.482-.245-1.112-.245-2.372v-6.3c0-1.26 0-1.89.245-2.371a2.25 2.25 0 0 1 .984-.984c.48-.245 1.11-.245 2.371-.245h6.3c1.26 0 1.89 0 2.371.245.424.216.768.56.984.984.245.48.245 1.11.245 2.371v6.3c0 1.26 0 1.89-.245 2.371-.216.424-.56.768-.984.984-.48.245-1.11.245-2.371.245"
|
|
188
188
|
stroke="#667085" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
|
|
189
|
-
</svg>`;class Yt extends M{constructor(t={}){super({...t,minValue:t.minValue??0,maxValue:t.maxValue??1e3,icon:t.icon||Xt,title:t.title||"Margin Top",default:t.default??20,wrapperClassName:"margin-top-wrapper "+(t.wrapperClassName||"")}),this.inputType="number"}}class Kt extends y{constructor(t){super(t),this.inputType={},this.container=null,this.defaultLanguage="",this.uploadSettings=new Map,t.default?this.value={...t.default}:this.value||(this.value={}),this.defaultLanguage=t.languages.includes(y.DefaultLanguage)?y.DefaultLanguage:t.languages[0];const e=t.defaultValue||`Enter text in ${this.capitalizeFirstLetter(this.defaultLanguage)}`;t.languages.forEach(i=>{var s,n;i in(this.value||{})||(this.value||(this.value={}),i===this.defaultLanguage&&e?this.value[i]=((s=t.default)==null?void 0:s[i])||e:this.value[i]=((n=t.default)==null?void 0:n[i])||"")})}capitalizeFirstLetter(t){return String(t).charAt(0).toUpperCase()+String(t).slice(1)}measureTextWidth(t,e){this.textMeasureCanvas||(this.textMeasureCanvas=document.createElement("canvas"));const i=this.textMeasureCanvas.getContext("2d");if(!i)return t.length*10;const s=`${e.fontStyle} ${e.fontWeight} ${e.fontSize} ${e.fontFamily}`.trim();return i.font=s,i.measureText(t).width}adaptPlaceholderToSingleLine(t,e){const i=window.getComputedStyle(t),s=parseFloat(i.paddingLeft)||0,n=parseFloat(i.paddingRight)||0,o=parseFloat(i.borderLeftWidth)||0,a=parseFloat(i.borderRightWidth)||0,l=Math.max(0,t.clientWidth-s-n-o-a);if(l<=0){t.placeholder=e;return}if(this.measureTextWidth(e,i)<=l){t.placeholder=e;return}const h="...";let p=0,d=e.length,g=0;for(;p<=d;){const m=Math.floor((p+d)/2),f=e.slice(0,m).trimEnd()+h;this.measureTextWidth(f,i)<=l?(g=m,p=m+1):d=m-1}const u=e.slice(0,g).trimEnd()+h;t.placeholder=u}autosizeTextarea(t,e=3){t.style.height="auto";const i=window.getComputedStyle(t),s=parseFloat(i.lineHeight)||20,n=parseFloat(i.paddingTop)+parseFloat(i.paddingBottom),o=parseFloat(i.borderTopWidth)+parseFloat(i.borderBottomWidth),a=s*e+n+o,l=Math.min(t.scrollHeight||44,a);t.style.height=`${l}px`,t.scrollHeight>a?t.style.overflowY="auto":t.style.overflowY="hidden"}createTextareaRow(t,e){const i=document.createElement("div");i.classList.add("simple-multi-language-row");const s=document.createElement("label");if(s.classList.add("simple-language-label"),s.textContent=t.toUpperCase(),s.setAttribute("for",`textarea-${t}`),i.appendChild(s),this.props.multiImg){const n=new ot({defaultUrl:e||"",title:"",id:`${this.id}_upload_${t}`});n.setOnChange(a=>{this.updateLanguageValue(t,a),t===this.defaultLanguage&&this.updateOtherLanguagePlaceholders(a)}),this.uploadSettings.set(t,n);const o=n.draw();o.classList.add("simple-language-upload"),i.appendChild(o)}else{const n=document.createElement("textarea");n.id=`textarea-${t}`,n.classList.add("simple-language-textarea"),n.value=e||"",n.rows=1,n.style.overflowY="hidden";let o=this.props.placeholder||"Enter text in {language}...";o.includes("{language}")&&(o=o.replace("{language}",t.toUpperCase())),n.setAttribute("data-full-placeholder",o),this.adaptPlaceholderToSingleLine(n,o),this.getDataPropsPath()&&n.setAttribute("data-test-id",`${this.getDataPropsPath()}_${t}`),n.addEventListener("input",l=>{const r=l.target;this.updateLanguageValue(t,r.value),t===this.defaultLanguage&&this.updateOtherLanguagePlaceholders(r.value),this.autosizeTextarea(r,3);const h=n.getAttribute("data-full-placeholder")||"";h&&this.adaptPlaceholderToSingleLine(n,h)}),i.appendChild(n),(l=>(typeof queueMicrotask=="function"?queueMicrotask:r=>setTimeout(r,0))(l))(()=>{this.autosizeTextarea(n,3);const l=n.getAttribute("data-full-placeholder")||"";l&&this.adaptPlaceholderToSingleLine(n,l)})}return i}updateLanguageValue(t,e){this.value||(this.value={});const i={...this.value,[t]:e};this.setValue(i)}updateOtherLanguagePlaceholders(t){this.container&&this.props.languages.forEach(e=>{var s,n;if(e===this.defaultLanguage)return;const i=(s=this.container)==null?void 0:s.querySelector(`#textarea-${e}`);if(i&&(!i.value||i.value.trim()==="")){const o=t||((n=this.props.placeholder)==null?void 0:n.replace("{language}",e.toUpperCase()))||`Enter text in ${e.toUpperCase()}...`;i.setAttribute("data-full-placeholder",o),this.adaptPlaceholderToSingleLine(i,o)}})}draw(){const t=document.createElement("div");if(t.classList.add("simple-multi-language-wrapper"),this.props.title){const s=document.createElement("div");s.classList.add("simple-multi-language-title"),s.textContent=this.props.title,t.appendChild(s)}const e=document.createElement("div");e.classList.add("simple-multi-language-content"),this.props.languages.forEach(s=>{var a;const n=((a=this.value)==null?void 0:a[s])||"",o=this.createTextareaRow(s,n);e.appendChild(o)}),t.appendChild(e),this.container=t;const i=()=>{if(!this.container)return;this.container.querySelectorAll(".simple-language-textarea").forEach(n=>{const o=n.getAttribute("data-full-placeholder")||"";o&&this.adaptPlaceholderToSingleLine(n,o)})};return window.addEventListener("resize",i),t}setValue(t){super.setValue(t),this.container&&this.props.languages.forEach(e=>{var i;if(this.props.multiImg){const s=this.uploadSettings.get(e);s&&s.setValue((t==null?void 0:t[e])||"")}else{const s=(i=this.container)==null?void 0:i.querySelector(`#textarea-${e}`);if(s){s.value=(t==null?void 0:t[e])||"",this.autosizeTextarea(s,3);const n=s.getAttribute("data-full-placeholder")||"";n&&this.adaptPlaceholderToSingleLine(s,n)}}})}}class Qt extends y{constructor(t={}){super(t),this.inputType="select";const e=[{name:"None",value:"none"},{name:"Fade",value:"fade 1.5s ease-in-out infinite"},{name:"Slide",value:"slide 1.5s ease-in-out infinite"},{name:"Zoom",value:"zoom 1.5s ease-in-out infinite"},{name:"Bounce",value:"bounce 1.5s ease-in-out infinite"},{name:"Pulse",value:"pulse 1.5s ease-in-out infinite"}];this.selectSetting=new Z({title:this.title||"Animation",options:e,default:this.props.default||"none"}),this.selectSetting.onChange=i=>{var s;this.value=i,(s=this.onChange)==null||s.call(this,i)}}draw(){return this.selectSetting.draw()}destroy(){this.selectSetting.destroy(),super.destroy()}}const te=(c,t)=>{let e=!1,i=0,s=0,n=0,o=0;const a=h=>{if(h.target.closest("button"))return;e=!0,i=h.clientX,s=h.clientY;const p=t.getBoundingClientRect();n=p.left,o=p.top,document.addEventListener("mousemove",l),document.addEventListener("mouseup",r),document.body.style.userSelect="none"},l=h=>{if(!e)return;const p=h.clientX-i,d=h.clientY-s,g=window.innerWidth,u=window.innerHeight,m=t.offsetWidth,f=t.offsetHeight;let C=n+p,L=o+d;C=Math.max(8,Math.min(g-m-8,C)),L=Math.max(8,Math.min(u-f-8,L)),t.style.left=`${C}px`,t.style.top=`${L}px`},r=()=>{e=!1,document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",r),document.body.style.userSelect=""};c.addEventListener("mousedown",a)},F=c=>{if(!c)return null;let t=c.trim();return!t.startsWith("#")||(t=t.slice(1),t.length===3&&(t=t.split("").map(e=>e+e).join("")),!/^[0-9a-fA-F]{6}$/.test(t))?null:`#${t.toUpperCase()}`},R=(c,t,e)=>`#${[c,t,e].map(i=>Math.max(0,Math.min(255,i)).toString(16).padStart(2,"0")).join("")}`,I=c=>{const t=c.replace("#",""),e=t.length===3?t.split("").map(i=>i+i).join(""):t;return{r:parseInt(e.slice(0,2),16),g:parseInt(e.slice(2,4),16),b:parseInt(e.slice(4,6),16)}},B=c=>{const{r:t,g:e,b:i}=I(c),s=t/255,n=e/255,o=i/255,a=Math.max(s,n,o),l=Math.min(s,n,o),r=a-l;let h=0;r!==0&&(a===s?h=(n-o)/r%6:a===n?h=(o-s)/r+2:h=(s-n)/r+4),h<0&&(h+=6);const p=a===0?0:r/a,d=a;return{h:h*60,s:p,v:d}},q=(c,t,e)=>{const i=(c%360+360)%360,s=e*t,n=s*(1-Math.abs(i/60%2-1)),o=e-s;let a=0,l=0,r=0;return i<60?(a=s,l=n,r=0):i<120?(a=n,l=s,r=0):i<180?(a=0,l=s,r=n):i<240?(a=0,l=n,r=s):i<300?(a=n,l=0,r=s):(a=s,l=0,r=n),R(Math.round((a+o)*255),Math.round((l+o)*255),Math.round((r+o)*255))},ee=(c,t,e)=>{const i=e*(1-t/2),s=i===0||i===1?0:(e-i)/Math.min(i,1-i);return{hue:c,sat:s,lightness:i}},X=(c,t,e)=>{const i=(1-Math.abs(2*e-1))*t,s=i*(1-Math.abs(c/60%2-1)),n=e-i/2;let o=0,a=0,l=0;return c<60?(o=i,a=s,l=0):c<120?(o=s,a=i,l=0):c<180?(o=0,a=i,l=s):c<240?(o=0,a=s,l=i):c<300?(o=s,a=0,l=i):(o=i,a=0,l=s),{r:Math.round((o+n)*255),g:Math.round((a+n)*255),b:Math.round((l+n)*255)}},ft=(c,t)=>{const e=Math.max(0,Math.min(100,t))/100;if(c.startsWith("#")){const{r:s,g:n,b:o}=I(c);return`rgba(${s}, ${n}, ${o}, ${e})`}if(c.startsWith("rgba("))return c.replace(/,\s*[\d.]+\)$/,`, ${e})`);if(c.startsWith("rgb("))return c.replace("rgb(","rgba(").replace(")",`, ${e})`);if(c.startsWith("hsl(")){const s=c.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(s){const{r:n,g:o,b:a}=X(parseInt(s[1]),parseInt(s[2])/100,parseInt(s[3])/100);return`rgba(${n}, ${o}, ${a}, ${e})`}}if(c.startsWith("hsla(")){const s=c.match(/hsla\((\d+),\s*(\d+)%,\s*(\d+)%,\s*[\d.]+\)/);if(s){const{r:n,g:o,b:a}=X(parseInt(s[1]),parseInt(s[2])/100,parseInt(s[3])/100);return`rgba(${n}, ${o}, ${a}, ${e})`}}const i=F(c);if(i){const{r:s,g:n,b:o}=I(i);return`rgba(${s}, ${n}, ${o}, ${e})`}return c},ie=c=>["red","green","blue","yellow","orange","purple","pink","brown","black","white","gray","grey","cyan","magenta","lime","navy","maroon","olive","aqua","silver","teal","fuchsia","transparent"].includes(c.toLowerCase()),vt=c=>[/^#[0-9a-fA-F]{3,8}$/,/^rgba?\s*\([^)]+\)$/,/^hsla?\s*\([^)]+\)$/,/^[a-zA-Z]+$/].some(e=>e.test(c.trim())),se=c=>{if(typeof document>"u")return vt(c)||!!F(c);const t=document.createElement("div");return t.style.color=c,t.style.color!==""},Ct=c=>{const t=c.trim();if(/^#[0-9A-Fa-f]{8}$/.test(t)){const n=t.slice(1),o=parseInt(n.slice(0,2),16),a=parseInt(n.slice(2,4),16),l=parseInt(n.slice(4,6),16),r=parseInt(n.slice(6,8),16);return{color:R(o,a,l),position:0,opacity:Math.round(r/255*100)}}const e=t.match(/rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?\s*\)/);if(e){const n=parseInt(e[1]),o=parseInt(e[2]),a=parseInt(e[3]),l=e[4]?parseFloat(e[4]):1;return{color:R(n,o,a),position:0,opacity:Math.round(l*100)}}const i=t.match(/hsla?\s*\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*([\d.]+))?\s*\)/);if(i){const{r:n,g:o,b:a}=X(parseFloat(i[1]),parseFloat(i[2])/100,parseFloat(i[3])/100),l=i[4]?parseFloat(i[4]):1;return{color:R(n,o,a),position:0,opacity:Math.round(l*100)}}return{color:F(t)||t,position:0,opacity:100}},U=class U{static defaults(){return{solid:[],gradient:[]}}static ensureLoaded(){var t;if(!this.colors&&(this.colors=this.defaults(),!(typeof window>"u")))try{const e=(t=window.sessionStorage)==null?void 0:t.getItem(this.STORAGE_KEY);if(!e)return;const i=JSON.parse(e);["solid","gradient"].forEach(s=>{const n=Array.isArray(i==null?void 0:i[s])?i[s]:[];this.colors[s]=n.map(o=>F(o)).filter(o=>!!o)})}catch{this.colors=this.defaults()}}static persist(){var t;if(!(typeof window>"u"))try{(t=window.sessionStorage)==null||t.setItem(this.STORAGE_KEY,JSON.stringify(this.colors||this.defaults()))}catch{}}static list(t){return this.ensureLoaded(),this.colors||(this.colors=this.defaults()),this.colors[t]}static getColors(t){return[...this.list(t)]}static addColor(t,e){const i=F(t);if(!i)return;const s=this.list(e),n=s.indexOf(i);n!==-1&&s.splice(n,1),s.unshift(i),s.length>this.MAX_COLORS&&(s.length=this.MAX_COLORS),this.persist()}};U.STORAGE_KEY="settingsLib_recentColors",U.MAX_COLORS=12,U.colors=null;let O=U;const ne=(c,t)=>{const e=document.createElement("div");e.className="color-picker-recent-section";const i=document.createElement("div");i.className="color-picker-recent-title",i.textContent="Recently Used Colors";const s=document.createElement("div");s.className="color-picker-recent-grid";const n=document.createElement("div");n.className="color-picker-recent-placeholder",n.textContent="No recent colors yet",e.appendChild(i),e.appendChild(s),e.appendChild(n);const o=()=>{s.innerHTML="";const a=O.getColors(t);if(a.length===0){s.style.display="none",n.style.display="block";return}s.style.display="grid",n.style.display="none",a.forEach(l=>{const r=document.createElement("button");r.type="button",r.className="color-picker-recent-swatch",r.title=l,r.setAttribute("aria-label",`Use color ${l}`),r.style.background=l,r.style.borderColor=l,r.addEventListener("click",()=>c(l)),s.appendChild(r)})};return o(),{container:e,refresh:o}},yt=`<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
189
|
+
</svg>`;class Yt extends M{constructor(t={}){super({...t,minValue:t.minValue??0,maxValue:t.maxValue??1e3,icon:t.icon||Xt,title:t.title||"Margin Top",default:t.default??20,wrapperClassName:"margin-top-wrapper "+(t.wrapperClassName||"")}),this.inputType="number"}}class Kt extends y{constructor(t){super(t),this.inputType={},this.container=null,this.defaultLanguage="",this.uploadSettings=new Map,t.default?this.value={...t.default}:this.value||(this.value={}),this.defaultLanguage=t.languages.includes(y.DefaultLanguage)?y.DefaultLanguage:t.languages[0];const e=t.defaultValue||`Enter text in ${this.capitalizeFirstLetter(this.defaultLanguage)}`;t.languages.forEach(i=>{var s,n;i in(this.value||{})||(this.value||(this.value={}),i===this.defaultLanguage&&e?this.value[i]=((s=t.default)==null?void 0:s[i])||e:this.value[i]=((n=t.default)==null?void 0:n[i])||"")})}capitalizeFirstLetter(t){return String(t).charAt(0).toUpperCase()+String(t).slice(1)}measureTextWidth(t,e){this.textMeasureCanvas||(this.textMeasureCanvas=document.createElement("canvas"));const i=this.textMeasureCanvas.getContext("2d");if(!i)return t.length*10;const s=`${e.fontStyle} ${e.fontWeight} ${e.fontSize} ${e.fontFamily}`.trim();return i.font=s,i.measureText(t).width}adaptPlaceholderToSingleLine(t,e){const i=window.getComputedStyle(t),s=parseFloat(i.paddingLeft)||0,n=parseFloat(i.paddingRight)||0,o=parseFloat(i.borderLeftWidth)||0,a=parseFloat(i.borderRightWidth)||0,l=Math.max(0,t.clientWidth-s-n-o-a);if(l<=0){t.placeholder=e;return}if(this.measureTextWidth(e,i)<=l){t.placeholder=e;return}const h="...";let p=0,d=e.length,g=0;for(;p<=d;){const m=Math.floor((p+d)/2),f=e.slice(0,m).trimEnd()+h;this.measureTextWidth(f,i)<=l?(g=m,p=m+1):d=m-1}const u=e.slice(0,g).trimEnd()+h;t.placeholder=u}autosizeTextarea(t,e=3){t.style.height="auto";const i=window.getComputedStyle(t),s=parseFloat(i.lineHeight)||20,n=parseFloat(i.paddingTop)+parseFloat(i.paddingBottom),o=parseFloat(i.borderTopWidth)+parseFloat(i.borderBottomWidth),a=s*e+n+o,l=Math.min(t.scrollHeight||44,a);t.style.height=`${l}px`,t.scrollHeight>a?t.style.overflowY="auto":t.style.overflowY="hidden"}createTextareaRow(t,e){const i=document.createElement("div");i.classList.add("simple-multi-language-row");const s=document.createElement("label");if(s.classList.add("simple-language-label"),s.textContent=t.toUpperCase(),s.setAttribute("for",`textarea-${t}`),i.appendChild(s),this.props.multiImg){const n=new ot({defaultUrl:e||"",title:"",id:`${this.id}_upload_${t}`});n.setOnChange(a=>{this.updateLanguageValue(t,a),t===this.defaultLanguage&&this.updateOtherLanguagePlaceholders(a)}),this.uploadSettings.set(t,n);const o=n.draw();o.classList.add("simple-language-upload"),i.appendChild(o)}else{const n=document.createElement("textarea");n.id=`textarea-${t}`,n.classList.add("simple-language-textarea"),n.value=e||"",n.rows=1,n.style.overflowY="hidden";let o=this.props.placeholder||"Enter text in {language}...";o.includes("{language}")&&(o=o.replace("{language}",t.toUpperCase())),n.setAttribute("data-full-placeholder",o),this.adaptPlaceholderToSingleLine(n,o),this.getDataPropsPath()&&n.setAttribute("data-test-id",`${this.getDataPropsPath()}_${t}`),n.addEventListener("input",l=>{const r=l.target;this.updateLanguageValue(t,r.value),t===this.defaultLanguage&&this.updateOtherLanguagePlaceholders(r.value),this.autosizeTextarea(r,3);const h=n.getAttribute("data-full-placeholder")||"";h&&this.adaptPlaceholderToSingleLine(n,h)}),i.appendChild(n),(l=>(typeof queueMicrotask=="function"?queueMicrotask:r=>setTimeout(r,0))(l))(()=>{this.autosizeTextarea(n,3);const l=n.getAttribute("data-full-placeholder")||"";l&&this.adaptPlaceholderToSingleLine(n,l)})}return i}updateLanguageValue(t,e){this.value||(this.value={});const i={...this.value,[t]:e};this.setValue(i)}updateOtherLanguagePlaceholders(t){this.container&&this.props.languages.forEach(e=>{var s,n;if(e===this.defaultLanguage)return;const i=(s=this.container)==null?void 0:s.querySelector(`#textarea-${e}`);if(i&&(!i.value||i.value.trim()==="")){const o=t||((n=this.props.placeholder)==null?void 0:n.replace("{language}",e.toUpperCase()))||`Enter text in ${e.toUpperCase()}...`;i.setAttribute("data-full-placeholder",o),this.adaptPlaceholderToSingleLine(i,o)}})}draw(){const t=document.createElement("div");if(t.classList.add("simple-multi-language-wrapper"),this.props.title){const s=document.createElement("div");s.classList.add("simple-multi-language-title"),s.textContent=this.props.title,t.appendChild(s)}const e=document.createElement("div");e.classList.add("simple-multi-language-content"),this.props.languages.forEach(s=>{var a;const n=((a=this.value)==null?void 0:a[s])||"",o=this.createTextareaRow(s,n);e.appendChild(o)}),t.appendChild(e),this.container=t;const i=()=>{if(!this.container)return;this.container.querySelectorAll(".simple-language-textarea").forEach(n=>{const o=n.getAttribute("data-full-placeholder")||"";o&&this.adaptPlaceholderToSingleLine(n,o)})};return window.addEventListener("resize",i),t}setValue(t){super.setValue(t),this.container&&this.props.languages.forEach(e=>{var i;if(this.props.multiImg){const s=this.uploadSettings.get(e);s&&s.setValue((t==null?void 0:t[e])||"")}else{const s=(i=this.container)==null?void 0:i.querySelector(`#textarea-${e}`);if(s){s.value=(t==null?void 0:t[e])||"",this.autosizeTextarea(s,3);const n=s.getAttribute("data-full-placeholder")||"";n&&this.adaptPlaceholderToSingleLine(s,n)}}})}}class Qt extends y{constructor(t={}){super(t),this.inputType="select";const e=[{name:"None",value:"none"},{name:"Fade",value:"fade 1.5s ease-in-out infinite"},{name:"Slide",value:"slide 1.5s ease-in-out infinite"},{name:"Zoom",value:"zoom 1.5s ease-in-out infinite"},{name:"Bounce",value:"bounce 1.5s ease-in-out infinite"},{name:"Pulse",value:"pulse 1.5s ease-in-out infinite"}];this.selectSetting=new Z({title:this.title||"Animation",options:e,default:this.props.default||"none"}),this.selectSetting.onChange=i=>{var s;this.value=i,(s=this.onChange)==null||s.call(this,i)}}draw(){return this.selectSetting.draw()}destroy(){this.selectSetting.destroy(),super.destroy()}}const te=(c,t)=>{let e=!1,i=0,s=0,n=0,o=0;const a=h=>{if(h.target.closest("button"))return;e=!0,i=h.clientX,s=h.clientY;const p=t.getBoundingClientRect();n=p.left,o=p.top,document.addEventListener("mousemove",l),document.addEventListener("mouseup",r),document.body.style.userSelect="none"},l=h=>{if(!e)return;const p=h.clientX-i,d=h.clientY-s,g=window.innerWidth,u=window.innerHeight,m=t.offsetWidth,f=t.offsetHeight;let C=n+p,L=o+d;C=Math.max(8,Math.min(g-m-8,C)),L=Math.max(8,Math.min(u-f-8,L)),t.style.left=`${C}px`,t.style.top=`${L}px`},r=()=>{e=!1,document.removeEventListener("mousemove",l),document.removeEventListener("mouseup",r),document.body.style.userSelect=""};c.addEventListener("mousedown",a)},F=c=>{if(!c)return null;let t=c.trim();return!t.startsWith("#")||(t=t.slice(1),t.length===3&&(t=t.split("").map(e=>e+e).join("")),!/^[0-9a-fA-F]{6}$/.test(t))?null:`#${t.toUpperCase()}`},R=(c,t,e)=>`#${[c,t,e].map(i=>Math.max(0,Math.min(255,i)).toString(16).padStart(2,"0")).join("")}`,I=c=>{const t=c.replace("#",""),e=t.length===3?t.split("").map(i=>i+i).join(""):t;return{r:parseInt(e.slice(0,2),16),g:parseInt(e.slice(2,4),16),b:parseInt(e.slice(4,6),16)}},B=c=>{const{r:t,g:e,b:i}=I(c),s=t/255,n=e/255,o=i/255,a=Math.max(s,n,o),l=Math.min(s,n,o),r=a-l;let h=0;r!==0&&(a===s?h=(n-o)/r%6:a===n?h=(o-s)/r+2:h=(s-n)/r+4),h<0&&(h+=6);const p=a===0?0:r/a,d=a;return{h:h*60,s:p,v:d}},U=(c,t,e)=>{const i=(c%360+360)%360,s=e*t,n=s*(1-Math.abs(i/60%2-1)),o=e-s;let a=0,l=0,r=0;return i<60?(a=s,l=n,r=0):i<120?(a=n,l=s,r=0):i<180?(a=0,l=s,r=n):i<240?(a=0,l=n,r=s):i<300?(a=n,l=0,r=s):(a=s,l=0,r=n),R(Math.round((a+o)*255),Math.round((l+o)*255),Math.round((r+o)*255))},ee=(c,t,e)=>{const i=e*(1-t/2),s=i===0||i===1?0:(e-i)/Math.min(i,1-i);return{hue:c,sat:s,lightness:i}},X=(c,t,e)=>{const i=(1-Math.abs(2*e-1))*t,s=i*(1-Math.abs(c/60%2-1)),n=e-i/2;let o=0,a=0,l=0;return c<60?(o=i,a=s,l=0):c<120?(o=s,a=i,l=0):c<180?(o=0,a=i,l=s):c<240?(o=0,a=s,l=i):c<300?(o=s,a=0,l=i):(o=i,a=0,l=s),{r:Math.round((o+n)*255),g:Math.round((a+n)*255),b:Math.round((l+n)*255)}},ft=(c,t)=>{const e=Math.max(0,Math.min(100,t))/100;if(c.startsWith("#")){const{r:s,g:n,b:o}=I(c);return`rgba(${s}, ${n}, ${o}, ${e})`}if(c.startsWith("rgba("))return c.replace(/,\s*[\d.]+\)$/,`, ${e})`);if(c.startsWith("rgb("))return c.replace("rgb(","rgba(").replace(")",`, ${e})`);if(c.startsWith("hsl(")){const s=c.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(s){const{r:n,g:o,b:a}=X(parseInt(s[1]),parseInt(s[2])/100,parseInt(s[3])/100);return`rgba(${n}, ${o}, ${a}, ${e})`}}if(c.startsWith("hsla(")){const s=c.match(/hsla\((\d+),\s*(\d+)%,\s*(\d+)%,\s*[\d.]+\)/);if(s){const{r:n,g:o,b:a}=X(parseInt(s[1]),parseInt(s[2])/100,parseInt(s[3])/100);return`rgba(${n}, ${o}, ${a}, ${e})`}}const i=F(c);if(i){const{r:s,g:n,b:o}=I(i);return`rgba(${s}, ${n}, ${o}, ${e})`}return c},ie=c=>["red","green","blue","yellow","orange","purple","pink","brown","black","white","gray","grey","cyan","magenta","lime","navy","maroon","olive","aqua","silver","teal","fuchsia","transparent"].includes(c.toLowerCase()),vt=c=>[/^#[0-9a-fA-F]{3,8}$/,/^rgba?\s*\([^)]+\)$/,/^hsla?\s*\([^)]+\)$/,/^[a-zA-Z]+$/].some(e=>e.test(c.trim())),se=c=>{if(typeof document>"u")return vt(c)||!!F(c);const t=document.createElement("div");return t.style.color=c,t.style.color!==""},Ct=c=>{const t=c.trim();if(/^#[0-9A-Fa-f]{8}$/.test(t)){const n=t.slice(1),o=parseInt(n.slice(0,2),16),a=parseInt(n.slice(2,4),16),l=parseInt(n.slice(4,6),16),r=parseInt(n.slice(6,8),16);return{color:R(o,a,l),position:0,opacity:Math.round(r/255*100)}}const e=t.match(/rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*([\d.]+))?\s*\)/);if(e){const n=parseInt(e[1]),o=parseInt(e[2]),a=parseInt(e[3]),l=e[4]?parseFloat(e[4]):1;return{color:R(n,o,a),position:0,opacity:Math.round(l*100)}}const i=t.match(/hsla?\s*\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*([\d.]+))?\s*\)/);if(i){const{r:n,g:o,b:a}=X(parseFloat(i[1]),parseFloat(i[2])/100,parseFloat(i[3])/100),l=i[4]?parseFloat(i[4]):1;return{color:R(n,o,a),position:0,opacity:Math.round(l*100)}}return{color:F(t)||t,position:0,opacity:100}},q=class q{static defaults(){return{solid:[],gradient:[]}}static ensureLoaded(){var t;if(!this.colors&&(this.colors=this.defaults(),!(typeof window>"u")))try{const e=(t=window.sessionStorage)==null?void 0:t.getItem(this.STORAGE_KEY);if(!e)return;const i=JSON.parse(e);["solid","gradient"].forEach(s=>{const n=Array.isArray(i==null?void 0:i[s])?i[s]:[];this.colors[s]=n.map(o=>F(o)).filter(o=>!!o)})}catch{this.colors=this.defaults()}}static persist(){var t;if(!(typeof window>"u"))try{(t=window.sessionStorage)==null||t.setItem(this.STORAGE_KEY,JSON.stringify(this.colors||this.defaults()))}catch{}}static list(t){return this.ensureLoaded(),this.colors||(this.colors=this.defaults()),this.colors[t]}static getColors(t){return[...this.list(t)]}static addColor(t,e){const i=F(t);if(!i)return;const s=this.list(e),n=s.indexOf(i);n!==-1&&s.splice(n,1),s.unshift(i),s.length>this.MAX_COLORS&&(s.length=this.MAX_COLORS),this.persist()}};q.STORAGE_KEY="settingsLib_recentColors",q.MAX_COLORS=12,q.colors=null;let O=q;const ne=(c,t)=>{const e=document.createElement("div");e.className="color-picker-recent-section";const i=document.createElement("div");i.className="color-picker-recent-title",i.textContent="Recently Used Colors";const s=document.createElement("div");s.className="color-picker-recent-grid";const n=document.createElement("div");n.className="color-picker-recent-placeholder",n.textContent="No recent colors yet",e.appendChild(i),e.appendChild(s),e.appendChild(n);const o=()=>{s.innerHTML="";const a=O.getColors(t);if(a.length===0){s.style.display="none",n.style.display="block";return}s.style.display="grid",n.style.display="none",a.forEach(l=>{const r=document.createElement("button");r.type="button",r.className="color-picker-recent-swatch",r.title=l,r.setAttribute("aria-label",`Use color ${l}`),r.style.background=l,r.style.borderColor=l,r.addEventListener("click",()=>c(l)),s.appendChild(r)})};return o(),{container:e,refresh:o}},yt=`<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
190
190
|
<path fill-rule="evenodd" clip-rule="evenodd"
|
|
191
191
|
d="M6.12347 4.96653L1.41158 0.254304C1.25449 0.102568 1.04409 0.0186071 0.825694 0.0205049C0.607302 0.0224037 0.398393 0.110007 0.24396 0.26445C0.0895282 0.418893 0.0019303 0.627818 3.24698e-05 0.846225C-0.00186536 1.06463 0.0820894 1.27505 0.233815 1.43215L4.9457 6.14438L0.233814 10.8566C0.0820886 11.0137 -0.00186625 11.2241 3.15434e-05 11.4425C0.00192934 11.6609 0.0895272 11.8699 0.243959 12.0243C0.398392 12.1787 0.607301 12.2663 0.825693 12.2682C1.04408 12.2701 1.25449 12.1862 1.41158 12.0344L6.12347 7.32222L10.8354 12.0344C10.9932 12.1824 11.2023 12.2632 11.4186 12.2597C11.6349 12.2562 11.8414 12.1687 11.9943 12.0156C12.1472 11.8626 12.2346 11.6561 12.2379 11.4398C12.2413 11.2234 12.1604 11.0143 12.0123 10.8566L7.30123 6.14438L12.0131 1.43215C12.0927 1.35531 12.1561 1.2634 12.1998 1.16177C12.2434 1.06014 12.2664 0.950833 12.2674 0.84023C12.2683 0.729626 12.2473 0.61994 12.2054 0.517568C12.1635 0.415196 12.1017 0.322191 12.0234 0.243979C11.9452 0.165768 11.8522 0.103916 11.7499 0.0620327C11.6475 0.0201492 11.5378 -0.000927989 11.4272 3.33052e-05C11.3166 0.000993646 11.2073 0.0239743 11.1057 0.0676297C11.0041 0.111286 10.9122 0.174745 10.8354 0.254305L6.12347 4.96653Z"
|
|
192
192
|
fill="#919EAB"/>
|
|
@@ -198,7 +198,7 @@
|
|
|
198
198
|
<path d="M14.1333 12.4667H0.8M0.8 12.4667L4.13333 9.13332M0.8 12.4667L4.13333 15.8M0.8 4.13332H14.1333M14.1333 4.13332L10.8 0.799988M14.1333 4.13332L10.8 7.46665" stroke="#919EAB" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
|
|
199
199
|
</svg>`,le=`<svg width="14" height="2" viewBox="0 0 14 2" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
200
200
|
<path d="M0.8 0.800003H12.4667" stroke="#919EAB" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round"/>
|
|
201
|
-
</svg>`;class re{constructor(t,e="gradient"){this.isOpen=!1,this.currentColor="#FF0000",this.currentOpacity=100,this.outsideClick=i=>{if(!this.isOpen)return;const s=i.target;if(this.element.contains(s))return;const n=document.querySelectorAll(".gstop-color-input");Array.from(n).some(a=>a.contains(s))||(i.preventDefault(),i.stopPropagation(),this.close(!1))},this.keyDown=i=>{if(this.isOpen){if(i.key==="Escape")i.preventDefault(),this.close(!0);else if(i.key==="Enter"){const s=i.target;if(s&&(s.tagName==="INPUT"||s.tagName==="TEXTAREA"))return;i.preventDefault(),this.close(!0)}}},this.onChange=t,this.recentScope=e,this.element=this.build(),this.backdrop=this.createBackdrop()}parsePercentage(t){const e=parseFloat(t);return isNaN(e)?0:e/100}build(){const t=document.createElement("div");t.className="custom-color-picker",t.style.display="none";const e=document.createElement("div");e.className="color-picker-header",e.style.cursor="move";const i=document.createElement("span");i.textContent="Color";const s=document.createElement("button");s.className="color-picker-close",s.innerHTML=yt,s.addEventListener("click",()=>this.close(!0)),e.appendChild(i),e.appendChild(s),te(e,t);const n=document.createElement("div");n.className="color-picker-area",this.colorArea=n;const o=document.createElement("div");o.className="color-picker-marker",this.colorMarker=o,n.appendChild(o);const a=document.createElement("div");a.className="color-picker-hue-container";const l=document.createElement("button");l.className="color-picker-eyedropper",l.type="button",l.innerHTML=oe;const r=document.createElement("div");r.className="color-picker-hue",this.hueSlider=r;const h=document.createElement("div");h.className="color-picker-hue-marker",this.hueMarker=h,r.appendChild(h),a.appendChild(l),a.appendChild(r);const p=document.createElement("div");p.className="color-picker-opacity",this.opacitySlider=p;const d=document.createElement("div");d.className="color-picker-opacity-marker",this.opacityMarker=d,p.appendChild(d);const g=ne($=>{var G,W;this.setColor($),(G=this.onChange)==null||G.call(this,$,this.currentOpacity),O.addColor($,this.recentScope),(W=this.recentSectionRefresh)==null||W.call(this)},this.recentScope);this.recentSectionRefresh=g.refresh;const u=document.createElement("div");u.className="color-picker-format-section";const m=document.createElement("select");m.className="color-picker-format-select",this.select=m;const f=document.createElement("option");f.value="hex",f.textContent="HEX";const C=document.createElement("option");C.value="rgb",C.textContent="RGB";const L=document.createElement("option");L.value="hsl",L.textContent="HSL",m.appendChild(f),m.appendChild(C),m.appendChild(L);const E=document.createElement("input");E.type="text",E.className="color-picker-color-input",E.value=this.currentColor,this.input=E;const P=document.createElement("div");P.className="color-picker-input-container";const S=document.createElement("button");return S.className="color-picker-copy-inside",S.textContent="Copy",P.appendChild(E),P.appendChild(S),u.appendChild(m),u.appendChild(P),t.appendChild(e),t.appendChild(n),t.appendChild(a),t.appendChild(p),t.appendChild(g.container),t.appendChild(u),t.addEventListener("click",$=>$.stopPropagation()),this.bind(n,r,p,E,m,S,l),t}createBackdrop(){const t=document.createElement("div");return t.className="color-picker-backdrop",t.style.display="none",t.addEventListener("click",e=>{e.preventDefault(),e.stopPropagation(),this.close(!1)}),t}bind(t,e,i,s,n,o,a){const l=p=>{var L;const d=t.getBoundingClientRect(),g=Math.max(0,Math.min(1,(p.clientX-d.left)/d.width)),u=Math.max(0,Math.min(1,(p.clientY-d.top)/d.height));this.colorMarker.style.left=`${g*100}%`,this.colorMarker.style.top=`${u*100}%`;const f=this.parsePercentage(this.hueMarker.style.left||"0%")*360,C=q(f,g,1-u);this.currentColor=C,this.syncInput(),this.updateOpacityBg(),(L=this.onChange)==null||L.call(this,C,this.currentOpacity)},r=p=>{var L;const d=e.getBoundingClientRect();let g=Math.max(0,Math.min(1,(p.clientX-d.left)/d.width));this.hueMarker.style.left=`${g*100}%`;const u=g*360,m=this.parsePercentage(this.colorMarker.style.left||"0%"),f=this.parsePercentage(this.colorMarker.style.top||"0%"),C=q(u,m,1-f);this.currentColor=C,this.colorArea.style.background=`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${u}, 100%, 50%))`,this.syncInput(),this.updateOpacityBg(),(L=this.onChange)==null||L.call(this,C,this.currentOpacity)},h=p=>{var u;const d=i.getBoundingClientRect(),g=Math.max(0,Math.min(1,(p.clientX-d.left)/d.width));this.opacityMarker.style.left=`${g*100}%`,this.currentOpacity=Math.round(g*100),(u=this.onChange)==null||u.call(this,this.currentColor,this.currentOpacity)};t.addEventListener("mousedown",p=>{p.preventDefault(),l(p);const d=u=>l(u),g=()=>{var u;document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",g),O.addColor(this.currentColor,this.recentScope),(u=this.recentSectionRefresh)==null||u.call(this)};document.addEventListener("mousemove",d),document.addEventListener("mouseup",g)}),e.addEventListener("mousedown",p=>{p.preventDefault(),r(p);const d=u=>r(u),g=()=>{var u;document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",g),O.addColor(this.currentColor,this.recentScope),(u=this.recentSectionRefresh)==null||u.call(this)};document.addEventListener("mousemove",d),document.addEventListener("mouseup",g)}),i.addEventListener("mousedown",p=>{p.preventDefault(),h(p);const d=u=>h(u),g=()=>{var u;document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",g),O.addColor(this.currentColor,this.recentScope),(u=this.recentSectionRefresh)==null||u.call(this)};document.addEventListener("mousemove",d),document.addEventListener("mouseup",g)}),n.addEventListener("change",()=>this.syncInput()),s.addEventListener("input",()=>this.applyFromInput()),s.addEventListener("blur",()=>this.syncInput()),s.addEventListener("keydown",p=>{p.key==="Enter"&&(p.preventDefault(),this.syncInput(),s.blur())}),o.addEventListener("click",async()=>{try{await navigator.clipboard.writeText(s.value)}catch{s.select(),document.execCommand("copy")}}),a.addEventListener("click",async()=>{var p,d;if(!("EyeDropper"in window)){alert("EyeDropper API is not supported in this browser.");return}try{const g=new window.EyeDropper,{sRGBHex:u}=await g.open();this.setColor(u),(p=this.onChange)==null||p.call(this,u,this.currentOpacity),O.addColor(u,this.recentScope),(d=this.recentSectionRefresh)==null||d.call(this)}catch{}}),document.addEventListener("keydown",this.keyDown,!0),setTimeout(()=>document.addEventListener("click",this.outsideClick,!0),0)}setColor(t){var o;this.currentColor=t;const{h:e,s:i,v:s}=B(t),n=e>=360?e%360:e;this.hueMarker.style.left=`${n/360*100}%`,this.colorMarker.style.left=`${i*100}%`,this.colorMarker.style.top=`${(1-s)*100}%`,this.colorArea.style.background=`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${n}, 100%, 50%))`,this.syncInput(),this.updateOpacityBg(),(o=this.onChange)==null||o.call(this,t,this.currentOpacity)}syncInput(){const t=this.select.value,{h:e,s:i,v:s}=B(this.currentColor);if(t==="hex")this.input.value=this.currentColor;else if(t==="rgb"){const{r:n,g:o,b:a}=I(this.currentColor);this.input.value=`rgb(${n}, ${o}, ${a})`}else{const{hue:n,sat:o,lightness:a}=ee(e,i,s);this.input.value=`hsl(${Math.round(n)}, ${Math.round(o*100)}%, ${Math.round(a*100)}%)`}}applyFromInput(){const t=this.input.value.trim();let e="";if(/^#[0-9A-Fa-f]{6}$/.test(t))e=t;else{const i=t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(i){const s=parseInt(i[1]),n=parseInt(i[2]),o=parseInt(i[3]);s<=255&&n<=255&&o<=255&&(e=`#${[s,n,o].map(a=>a.toString(16).padStart(2,"0")).join("")}`)}else{const s=t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(s){const n=parseInt(s[1]),o=parseInt(s[2])/100,a=parseInt(s[3])/100,l=a+o*Math.min(a,1-a),r=l===0?0:2*(1-a/l);e=q(n,r,l)}}}e&&this.setColor(e)}updateOpacityBg(){const{r:t,g:e,b:i}=I(this.currentColor);this.opacitySlider.style.setProperty("--base-color",`rgb(${t}, ${e}, ${i})`)}open(t,e,i){var E;this.currentColor=t,this.currentOpacity=i??100,this.syncInput();const{h:s,s:n,v:o}=B(t);this.hueMarker.style.left=`${s/360*100}%`,this.colorMarker.style.left=`${n*100}%`,this.colorMarker.style.top=`${(1-o)*100}%`,this.colorArea.style.background=`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${s}, 100%, 50%))`,this.updateOpacityBg(),this.opacityMarker.style.left=`${this.currentOpacity}%`,(E=this.recentSectionRefresh)==null||E.call(this),this.isOpen=!0,this.backdrop.style.display="block",this.backdrop.parentElement||document.body.appendChild(this.backdrop),this.element.style.display="block",this.element.style.position="fixed",this.element.style.zIndex="10002",this.element.style.left="-9999px",this.element.style.top="0px",this.element.parentElement||document.body.appendChild(this.element);const a=this.element.offsetWidth,l=this.element.offsetHeight,r=e.getBoundingClientRect(),h=window.innerWidth,p=window.innerHeight,d=16;let g=r.right+8,u=r.top;const m=h-r.right,f=r.left;m>=a+d?g=r.right+8:f>=a+d?g=r.left-a-8:g=Math.max(d,(h-a)/2);const C=p-r.bottom,L=r.top;C>=l+d?u=r.bottom+8:L>=l+d?u=r.top-l-8:C>L?(u=r.bottom+8,u+l>p-d&&(u=p-l-d)):(u=r.top-l-8,u<d&&(u=d)),this.element.style.left=`${g}px`,this.element.style.top=`${u}px`}close(t){var e;this.isOpen&&(this.isOpen=!1,this.backdrop.style.display="none",this.element.style.display="none",document.removeEventListener("click",this.outsideClick,!0),document.removeEventListener("keydown",this.keyDown,!0),t&&(O.addColor(this.currentColor,this.recentScope),(e=this.recentSectionRefresh)==null||e.call(this)))}getElement(){return this.element}}class ce{constructor(t){this.currentColor=t.initialColor,this.currentOpacity=t.initialOpacity,this.onColorChange=t.onColorChange,this.container=this.createContainer(),this.initializePicker()}createContainer(){const t=document.createElement("div");return t.className="embedded-color-picker-content",t.innerHTML=`
|
|
201
|
+
</svg>`;class re{constructor(t,e="gradient"){this.isOpen=!1,this.currentColor="#FF0000",this.currentOpacity=100,this.outsideClick=i=>{if(!this.isOpen)return;const s=i.target;if(this.element.contains(s))return;const n=document.querySelectorAll(".gstop-color-input");Array.from(n).some(a=>a.contains(s))||(i.preventDefault(),i.stopPropagation(),this.close(!1))},this.keyDown=i=>{if(this.isOpen){if(i.key==="Escape")i.preventDefault(),this.close(!0);else if(i.key==="Enter"){const s=i.target;if(s&&(s.tagName==="INPUT"||s.tagName==="TEXTAREA"))return;i.preventDefault(),this.close(!0)}}},this.onChange=t,this.recentScope=e,this.element=this.build(),this.backdrop=this.createBackdrop()}parsePercentage(t){const e=parseFloat(t);return isNaN(e)?0:e/100}build(){const t=document.createElement("div");t.className="custom-color-picker",t.style.display="none";const e=document.createElement("div");e.className="color-picker-header",e.style.cursor="move";const i=document.createElement("span");i.textContent="Color";const s=document.createElement("button");s.className="color-picker-close",s.innerHTML=yt,s.addEventListener("click",()=>this.close(!0)),e.appendChild(i),e.appendChild(s),te(e,t);const n=document.createElement("div");n.className="color-picker-area",this.colorArea=n;const o=document.createElement("div");o.className="color-picker-marker",this.colorMarker=o,n.appendChild(o);const a=document.createElement("div");a.className="color-picker-hue-container";const l=document.createElement("button");l.className="color-picker-eyedropper",l.type="button",l.innerHTML=oe;const r=document.createElement("div");r.className="color-picker-hue",this.hueSlider=r;const h=document.createElement("div");h.className="color-picker-hue-marker",this.hueMarker=h,r.appendChild(h),a.appendChild(l),a.appendChild(r);const p=document.createElement("div");p.className="color-picker-opacity",this.opacitySlider=p;const d=document.createElement("div");d.className="color-picker-opacity-marker",this.opacityMarker=d,p.appendChild(d);const g=ne($=>{var G,W;this.setColor($),(G=this.onChange)==null||G.call(this,$,this.currentOpacity),O.addColor($,this.recentScope),(W=this.recentSectionRefresh)==null||W.call(this)},this.recentScope);this.recentSectionRefresh=g.refresh;const u=document.createElement("div");u.className="color-picker-format-section";const m=document.createElement("select");m.className="color-picker-format-select",this.select=m;const f=document.createElement("option");f.value="hex",f.textContent="HEX";const C=document.createElement("option");C.value="rgb",C.textContent="RGB";const L=document.createElement("option");L.value="hsl",L.textContent="HSL",m.appendChild(f),m.appendChild(C),m.appendChild(L);const E=document.createElement("input");E.type="text",E.className="color-picker-color-input",E.value=this.currentColor,this.input=E;const H=document.createElement("div");H.className="color-picker-input-container";const S=document.createElement("button");return S.className="color-picker-copy-inside",S.textContent="Copy",H.appendChild(E),H.appendChild(S),u.appendChild(m),u.appendChild(H),t.appendChild(e),t.appendChild(n),t.appendChild(a),t.appendChild(p),t.appendChild(g.container),t.appendChild(u),t.addEventListener("click",$=>$.stopPropagation()),this.bind(n,r,p,E,m,S,l),t}createBackdrop(){const t=document.createElement("div");return t.className="color-picker-backdrop",t.style.display="none",t.addEventListener("click",e=>{e.preventDefault(),e.stopPropagation(),this.close(!1)}),t}bind(t,e,i,s,n,o,a){const l=p=>{var L;const d=t.getBoundingClientRect(),g=Math.max(0,Math.min(1,(p.clientX-d.left)/d.width)),u=Math.max(0,Math.min(1,(p.clientY-d.top)/d.height));this.colorMarker.style.left=`${g*100}%`,this.colorMarker.style.top=`${u*100}%`;const f=this.parsePercentage(this.hueMarker.style.left||"0%")*360,C=U(f,g,1-u);this.currentColor=C,this.syncInput(),this.updateOpacityBg(),(L=this.onChange)==null||L.call(this,C,this.currentOpacity)},r=p=>{var L;const d=e.getBoundingClientRect();let g=Math.max(0,Math.min(1,(p.clientX-d.left)/d.width));this.hueMarker.style.left=`${g*100}%`;const u=g*360,m=this.parsePercentage(this.colorMarker.style.left||"0%"),f=this.parsePercentage(this.colorMarker.style.top||"0%"),C=U(u,m,1-f);this.currentColor=C,this.colorArea.style.background=`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${u}, 100%, 50%))`,this.syncInput(),this.updateOpacityBg(),(L=this.onChange)==null||L.call(this,C,this.currentOpacity)},h=p=>{var u;const d=i.getBoundingClientRect(),g=Math.max(0,Math.min(1,(p.clientX-d.left)/d.width));this.opacityMarker.style.left=`${g*100}%`,this.currentOpacity=Math.round(g*100),(u=this.onChange)==null||u.call(this,this.currentColor,this.currentOpacity)};t.addEventListener("mousedown",p=>{p.preventDefault(),l(p);const d=u=>l(u),g=()=>{var u;document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",g),O.addColor(this.currentColor,this.recentScope),(u=this.recentSectionRefresh)==null||u.call(this)};document.addEventListener("mousemove",d),document.addEventListener("mouseup",g)}),e.addEventListener("mousedown",p=>{p.preventDefault(),r(p);const d=u=>r(u),g=()=>{var u;document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",g),O.addColor(this.currentColor,this.recentScope),(u=this.recentSectionRefresh)==null||u.call(this)};document.addEventListener("mousemove",d),document.addEventListener("mouseup",g)}),i.addEventListener("mousedown",p=>{p.preventDefault(),h(p);const d=u=>h(u),g=()=>{var u;document.removeEventListener("mousemove",d),document.removeEventListener("mouseup",g),O.addColor(this.currentColor,this.recentScope),(u=this.recentSectionRefresh)==null||u.call(this)};document.addEventListener("mousemove",d),document.addEventListener("mouseup",g)}),n.addEventListener("change",()=>this.syncInput()),s.addEventListener("input",()=>this.applyFromInput()),s.addEventListener("blur",()=>this.syncInput()),s.addEventListener("keydown",p=>{p.key==="Enter"&&(p.preventDefault(),this.syncInput(),s.blur())}),o.addEventListener("click",async()=>{try{await navigator.clipboard.writeText(s.value)}catch{s.select(),document.execCommand("copy")}}),a.addEventListener("click",async()=>{var p,d;if(!("EyeDropper"in window)){alert("EyeDropper API is not supported in this browser.");return}try{const g=new window.EyeDropper,{sRGBHex:u}=await g.open();this.setColor(u),(p=this.onChange)==null||p.call(this,u,this.currentOpacity),O.addColor(u,this.recentScope),(d=this.recentSectionRefresh)==null||d.call(this)}catch{}}),document.addEventListener("keydown",this.keyDown,!0),setTimeout(()=>document.addEventListener("click",this.outsideClick,!0),0)}setColor(t){var o;this.currentColor=t;const{h:e,s:i,v:s}=B(t),n=e>=360?e%360:e;this.hueMarker.style.left=`${n/360*100}%`,this.colorMarker.style.left=`${i*100}%`,this.colorMarker.style.top=`${(1-s)*100}%`,this.colorArea.style.background=`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${n}, 100%, 50%))`,this.syncInput(),this.updateOpacityBg(),(o=this.onChange)==null||o.call(this,t,this.currentOpacity)}syncInput(){const t=this.select.value,{h:e,s:i,v:s}=B(this.currentColor);if(t==="hex")this.input.value=this.currentColor;else if(t==="rgb"){const{r:n,g:o,b:a}=I(this.currentColor);this.input.value=`rgb(${n}, ${o}, ${a})`}else{const{hue:n,sat:o,lightness:a}=ee(e,i,s);this.input.value=`hsl(${Math.round(n)}, ${Math.round(o*100)}%, ${Math.round(a*100)}%)`}}applyFromInput(){const t=this.input.value.trim();let e="";if(/^#[0-9A-Fa-f]{6}$/.test(t))e=t;else{const i=t.match(/rgb\((\d+),\s*(\d+),\s*(\d+)\)/);if(i){const s=parseInt(i[1]),n=parseInt(i[2]),o=parseInt(i[3]);s<=255&&n<=255&&o<=255&&(e=`#${[s,n,o].map(a=>a.toString(16).padStart(2,"0")).join("")}`)}else{const s=t.match(/hsl\((\d+),\s*(\d+)%,\s*(\d+)%\)/);if(s){const n=parseInt(s[1]),o=parseInt(s[2])/100,a=parseInt(s[3])/100,l=a+o*Math.min(a,1-a),r=l===0?0:2*(1-a/l);e=U(n,r,l)}}}e&&this.setColor(e)}updateOpacityBg(){const{r:t,g:e,b:i}=I(this.currentColor);this.opacitySlider.style.setProperty("--base-color",`rgb(${t}, ${e}, ${i})`)}open(t,e,i){var E;this.currentColor=t,this.currentOpacity=i??100,this.syncInput();const{h:s,s:n,v:o}=B(t);this.hueMarker.style.left=`${s/360*100}%`,this.colorMarker.style.left=`${n*100}%`,this.colorMarker.style.top=`${(1-o)*100}%`,this.colorArea.style.background=`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${s}, 100%, 50%))`,this.updateOpacityBg(),this.opacityMarker.style.left=`${this.currentOpacity}%`,(E=this.recentSectionRefresh)==null||E.call(this),this.isOpen=!0,this.backdrop.style.display="block",this.backdrop.parentElement||document.body.appendChild(this.backdrop),this.element.style.display="block",this.element.style.position="fixed",this.element.style.zIndex="10002",this.element.style.left="-9999px",this.element.style.top="0px",this.element.parentElement||document.body.appendChild(this.element);const a=this.element.offsetWidth,l=this.element.offsetHeight,r=e.getBoundingClientRect(),h=window.innerWidth,p=window.innerHeight,d=16;let g=r.right+8,u=r.top;const m=h-r.right,f=r.left;m>=a+d?g=r.right+8:f>=a+d?g=r.left-a-8:g=Math.max(d,(h-a)/2);const C=p-r.bottom,L=r.top;C>=l+d?u=r.bottom+8:L>=l+d?u=r.top-l-8:C>L?(u=r.bottom+8,u+l>p-d&&(u=p-l-d)):(u=r.top-l-8,u<d&&(u=d)),this.element.style.left=`${g}px`,this.element.style.top=`${u}px`}close(t){var e;this.isOpen&&(this.isOpen=!1,this.backdrop.style.display="none",this.element.style.display="none",document.removeEventListener("click",this.outsideClick,!0),document.removeEventListener("keydown",this.keyDown,!0),t&&(O.addColor(this.currentColor,this.recentScope),(e=this.recentSectionRefresh)==null||e.call(this)))}getElement(){return this.element}}class ce{constructor(t){this.currentColor=t.initialColor,this.currentOpacity=t.initialOpacity,this.onColorChange=t.onColorChange,this.container=this.createContainer(),this.initializePicker()}createContainer(){const t=document.createElement("div");return t.className="embedded-color-picker-content",t.innerHTML=`
|
|
202
202
|
<div class="color-picker-area embedded">
|
|
203
203
|
<div class="color-picker-marker"></div>
|
|
204
204
|
</div>
|
|
@@ -226,7 +226,7 @@
|
|
|
226
226
|
<button class="color-picker-copy-inside">Copy</button>
|
|
227
227
|
</div>
|
|
228
228
|
</div>
|
|
229
|
-
`,t}initializePicker(){const t=this.container.querySelector(".color-picker-area"),e=this.container.querySelector(".color-picker-marker"),i=this.container.querySelector(".color-picker-hue"),s=this.container.querySelector(".color-picker-hue-marker"),n=this.container.querySelector(".color-picker-opacity"),o=this.container.querySelector(".color-picker-opacity-marker"),a=this.container.querySelector(".color-picker-format-select"),l=this.container.querySelector(".color-picker-color-input"),r=this.container.querySelector(".color-picker-copy-inside"),{h,s:p,v:d}=B(this.currentColor);s.style.left=`${h/360*100}%`,e.style.left=`${p*100}%`,e.style.top=`${(1-d)*100}%`,t.style.background=`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${h}, 100%, 50%))`,o.style.left=`${this.currentOpacity}%`,this.updateOpacityBackground(n),this.updateColorInput(a,l),this.setupColorAreaEvents(t,e,s),this.setupHueSliderEvents(i,s,t,e,a,l,n),this.setupOpacitySliderEvents(n,o),this.setupFormatEvents(a,l,r)}updateOpacityBackground(t){const e=I(this.currentColor);t.style.setProperty("--base-color",`rgb(${e.r}, ${e.g}, ${e.b})`)}updateColorInput(t,e){switch(t.value){case"hex":e.value=this.currentColor;break;case"rgb":const s=I(this.currentColor);e.value=`rgb(${s.r}, ${s.g}, ${s.b})`;break;case"hsl":const{h:n,s:o,v:a}=B(this.currentColor),l=a*(1-o/2),r=l===0||l===1?0:(a-l)/Math.min(l,1-l);e.value=`hsl(${Math.round(n)}, ${Math.round(r*100)}%, ${Math.round(l*100)}%)`;break}}setupColorAreaEvents(t,e,i){const s=n=>{const o=t.getBoundingClientRect(),a=Math.max(0,Math.min(1,(n.clientX-o.left)/o.width)),l=Math.max(0,Math.min(1,(n.clientY-o.top)/o.height));e.style.left=`${a*100}%`,e.style.top=`${l*100}%`;const r=parseFloat(i.style.left||"0%")/100*360,h=q(r,a,1-l);this.currentColor=h;const p=this.container.querySelector(".color-picker-format-select"),d=this.container.querySelector(".color-picker-color-input"),g=this.container.querySelector(".color-picker-opacity");this.updateColorInput(p,d),this.updateOpacityBackground(g),this.triggerChange()};t.addEventListener("mousedown",n=>{n.preventDefault(),s(n);const o=l=>s(l),a=()=>{document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",a)};document.addEventListener("mousemove",o),document.addEventListener("mouseup",a)})}setupHueSliderEvents(t,e,i,s,n,o,a){const l=r=>{const h=t.getBoundingClientRect();let p=(r.clientX-h.left)/h.width;p=Math.max(0,Math.min(1,p)),e.style.left=`${p*100}%`;const d=p*360,g=parseFloat(s.style.left||"50%")/100,u=parseFloat(s.style.top||"50%")/100;i.style.background=`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${d}, 100%, 50%))`;const m=q(d,g,1-u);this.currentColor=m,this.updateColorInput(n,o),this.updateOpacityBackground(a),this.triggerChange()};t.addEventListener("mousedown",r=>{r.preventDefault(),l(r);const h=d=>l(d),p=()=>{document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",p)};document.addEventListener("mousemove",h),document.addEventListener("mouseup",p)})}setupOpacitySliderEvents(t,e){const i=s=>{const n=t.getBoundingClientRect(),o=Math.max(0,Math.min(1,(s.clientX-n.left)/n.width));e.style.left=`${o*100}%`,this.currentOpacity=Math.round(o*100),this.triggerChange()};t.addEventListener("mousedown",s=>{s.preventDefault(),i(s);const n=a=>i(a),o=()=>{document.removeEventListener("mousemove",n),document.removeEventListener("mouseup",o)};document.addEventListener("mousemove",n),document.addEventListener("mouseup",o)})}setupFormatEvents(t,e,i){t.addEventListener("change",()=>{this.updateColorInput(t,e)}),i.addEventListener("click",()=>{navigator.clipboard.writeText(e.value).catch(()=>{e.select(),document.execCommand("copy")})}),e.addEventListener("input",()=>{this.handleManualColorInput(e.value,t)}),e.addEventListener("blur",()=>{this.updateColorInput(t,e)})}handleManualColorInput(t,e){const i=t.trim();let s=null;switch(e.value){case"hex":s=this.parseHexInput(i);break;case"rgb":s=this.parseRgbInput(i);break;case"hsl":s=this.parseHslInput(i);break}s||(s=this.autoDetectColorFormat(i)),s&&(this.currentColor=s,this.updatePickerVisualState(),this.triggerChange())}parseHexInput(t){const e=t.startsWith("#")?t:`#${t}`;return F(e)}parseRgbInput(t){const e=t.match(/rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*[\d.]+)?\s*\)/);if(e){const i=parseInt(e[1]),s=parseInt(e[2]),n=parseInt(e[3]);if(i<=255&&s<=255&&n<=255)return R(i,s,n)}return null}parseHslInput(t){const e=t.match(/hsla?\s*\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*[\d.]+)?\s*\)/);if(e){const i=parseFloat(e[1]),s=parseFloat(e[2])/100,n=parseFloat(e[3])/100;if(i>=0&&i<=360&&s>=0&&s<=1&&n>=0&&n<=1){const o=X(i,s,n);return R(o.r,o.g,o.b)}}return null}autoDetectColorFormat(t){const e=this.parseHexInput(t);if(e)return e;const i=this.parseRgbInput(t);if(i)return i;const s=this.parseHslInput(t);return s||null}updatePickerVisualState(){const t=this.container.querySelector(".color-picker-area"),e=this.container.querySelector(".color-picker-marker"),i=this.container.querySelector(".color-picker-hue-marker"),s=this.container.querySelector(".color-picker-opacity"),{h:n,s:o,v:a}=B(this.currentColor);i.style.left=`${n/360*100}%`,e.style.left=`${o*100}%`,e.style.top=`${(1-a)*100}%`,t.style.background=`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${n}, 100%, 50%))`,this.updateOpacityBackground(s)}triggerChange(){this.onColorChange(this.currentColor,this.currentOpacity)}getElement(){return this.container}updateColor(t,e){this.currentColor=t,this.currentOpacity=e;const i=this.container.querySelector(".color-picker-area"),s=this.container.querySelector(".color-picker-marker"),n=this.container.querySelector(".color-picker-hue-marker"),o=this.container.querySelector(".color-picker-opacity-marker"),a=this.container.querySelector(".color-picker-opacity"),l=this.container.querySelector(".color-picker-format-select"),r=this.container.querySelector(".color-picker-color-input"),{h,s:p,v:d}=B(t),g=h>=360?h%360:h;n.style.left=`${g/360*100}%`,s.style.left=`${p*100}%`,s.style.top=`${(1-d)*100}%`,i.style.background=`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${g}, 100%, 50%))`,o.style.left=`${e}%`,this.updateOpacityBackground(a),this.updateColorInput(l,r)}}const rt=c=>{const t=[];let e="",i=0;for(let s=0;s<c.length;s++){const n=c[s];if(n==="(")i++;else if(n===")")i--;else if(n===","&&i===0){t.push(e.trim()),e="";continue}e+=n}return e.trim()&&t.push(e.trim()),t},ct=(c,t)=>{const e=new RegExp(`${t}\\s*\\(`,"i"),i=c.match(e);if(!i)return null;const s=i.index+i[0].length;let n=1,o=s;for(let a=s;a<c.length&&n>0;a++)c[a]==="("?n++:c[a]===")"&&n--,o=a;return n===0?c.substring(s,o):null},he=c=>{const t=c.split(" ")[0].toLowerCase();return["circle","ellipse","closest-side","closest-corner","farthest-side","farthest-corner","at","contain","cover"].includes(t)?!1:/^#[0-9a-f]{3,8}$/i.test(t)||/^rgb/i.test(c)||/^hsl/i.test(c)||ie(t)},ht=c=>{const t=[];return c.forEach((e,i)=>{const s=e.trim();if(!s)return;let n="",o=0;const a=s.match(/^(.+?)\s+(\d+(?:\.\d+)?)%?\s*$/);a&&vt(a[1].trim())?(n=a[1].trim(),o=parseFloat(a[2])):(n=s,o=c.length===1?0:i/(c.length-1)*100);const l=Ct(n);l.position=Math.max(0,Math.min(100,Math.round(o))),t.push(l)}),t},D=c=>{const t=c.stops&&c.stops.length?c.stops:[{color:"#000000",position:0,opacity:100}];return{type:c.type&&["linear","radial","solid"].includes(c.type)?c.type:"linear",angle:typeof c.angle=="number"?c.angle:90,stops:t.map((e,i)=>({color:e.color||"#000000",position:typeof e.position=="number"?e.position:t.length===1?0:Math.round(i/(t.length-1)*100),opacity:e.opacity===void 0||Number.isNaN(e.opacity)?100:e.opacity}))}},Q=c=>{const t=c.replace(/;$/,"").trim();if(se(t)){const s=Ct(t);return D({type:"solid",angle:0,stops:[s]})}const e=ct(t,"linear-gradient");if(e){const s=rt(e);let n=90,o=s;const a=s[0];if(a.includes("deg")){const r=a.match(/(-?\d+(?:\.\d+)?)deg/);r&&(n=parseFloat(r[1]),o=s.slice(1))}else a.includes("to ")&&(n={"to right":90,"to left":270,"to bottom":180,"to top":0,"to bottom right":135,"to bottom left":225,"to top right":45,"to top left":315}[a]??90,o=s.slice(1));const l=ht(o);return l.length?D({type:"linear",angle:n,stops:l}):null}const i=ct(t,"radial-gradient");if(i){const s=rt(i),n=s[0]&&!he(s[0])?s.slice(1):s,o=ht(n);return o.length?D({type:"radial",angle:0,stops:o}):null}return null},T=c=>{if(c.type==="solid"){const e=c.stops[0],i=e.opacity??100,s=e.color.replace("#",""),n=Math.round(i/100*255).toString(16).toUpperCase().padStart(2,"0");return`#${s}${n}`}const t=c.stops.map(e=>`${ft(e.color,e.opacity??100)} ${e.position}%`).join(", ");return c.type==="radial"?`radial-gradient(circle, ${t})`:`linear-gradient(${c.angle}deg, ${t})`},tt=c=>{if(c.type==="solid"){const t=c.stops[0];return t?t.color.replace("#","").toUpperCase():"Color"}return c.type==="linear"?`Linear ${c.angle}°`:"Radial Gradient"},V=class V extends y{constructor(t={}){const e=typeof t.default=="string"?void 0:t.default;super({...t,title:t.title||"Gradient",default:e}),this.inputType={type:"text",angle:"number",stops:"text"},this.element=null,this.previewEl=null,this.inputEl=void 0,this.popoverEl=null,this.isPopoverOpen=!1,this.isEditing=!1,this.onBackgroundClick=i=>{var p;if(!this.popoverEl||!this.isPopoverOpen)return;const s=i.target,n=this.popoverEl.contains(s),o=(p=this.element)==null?void 0:p.contains(s),a=document.querySelectorAll(".custom-color-picker"),l=Array.from(a).some(d=>d.contains(s)),r=s.closest(".gstop-color-input, .gradient-mini-preview, .gstop-color-preview"),h=s.classList.contains("color-picker-backdrop");!n&&!o&&!l&&!r&&!h&&this.closePopover()},this.detectChange=t.detectChange,this.forText=t.forText||!1,this.originalDefault=t.default,this.value=this.defaultValue()}defaultValue(){const t=this.originalDefault;if(typeof t=="string"){const i=Q(t);if(i)return D(i)}return D(t&&typeof t=="object"?t:{type:"linear",angle:90,stops:[{color:"#a84b4b",position:0,opacity:100},{color:"#786666",position:100,opacity:100}]})}setValue(t){var i,s;let e=null;typeof t=="string"?e=Q(t):t&&typeof t=="object"&&(e=D(t)),e||(e=this.defaultValue()),this.value=e,this.updateUI(),this.isPopoverOpen&&this.refreshPopoverContent(),(i=this.onChange)==null||i.call(this,this.value),(s=this.detectChange)==null||s.call(this,this.value)}updateUI(){if(this.previewEl&&this.value)if(this.value.type==="solid"){const t=this.value.stops[0],e=t.opacity??100;this.previewEl.style.background=ft(t.color,e)}else this.previewEl.style.background=T(this.value);this.inputEl&&this.value&&!this.isEditing&&(this.inputEl.value=tt(this.value))}cssForTextValue(){return this.value?{background:T(this.value),"-webkit-background-clip":"text","background-clip":"text",color:"transparent","-webkit-text-fill-color":"transparent"}:{}}draw(){const t=document.createElement("div");if(t.className="gradient-setting-wrapper",this.props.title){const i=document.createElement("div");i.className="icon-container";const s=document.createElement("span");s.className="input-label",s.textContent=this.props.title,i.appendChild(s),t.appendChild(i)}const e=document.createElement("div");return e.className="gradient-input-wrapper",this.previewEl=document.createElement("div"),this.previewEl.className="gradient-mini-preview",this.previewEl.style.background=this.value?T(this.value):"linear-gradient(90deg, #a84b4b 0%, #786666 100%)",this.previewEl.addEventListener("mousedown",i=>{i.preventDefault(),i.stopPropagation(),this.openPopover()}),this.inputEl=document.createElement("input"),this.inputEl.type="text",this.inputEl.className="gradient-text-input",this.inputEl.placeholder="Enter gradient CSS or paste color...",this.inputEl.value=this.value?tt(this.value):"",this.inputEl.readOnly=!1,this.inputEl.addEventListener("focus",()=>{this.isEditing=!0,this.value&&(this.inputEl.value=T(this.value))}),this.inputEl.addEventListener("blur",()=>{this.isEditing=!1,this.value&&(this.inputEl.value=tt(this.value))}),this.inputEl.addEventListener("paste",i=>this.handlePaste(i)),this.inputEl.addEventListener("input",i=>this.handleTextInput(i)),this.inputEl.addEventListener("keydown",i=>{i.key==="Enter"&&(this.handleTextInput(i),this.inputEl.blur()),i.key==="Escape"&&(this.value&&(this.inputEl.value=T(this.value)),this.inputEl.blur())}),e.appendChild(this.previewEl),e.appendChild(this.inputEl),t.appendChild(e),this.createPopover(),this.element=t,t}createPopover(){if(this.popoverEl)return;this.popoverEl=document.createElement("div"),this.popoverEl.className="gradient-popover",this.popoverEl.style.display="none";const t=document.createElement("div");t.className="gradient-popover-header";const e=document.createElement("span");e.textContent="Fill";const i=document.createElement("button");i.type="button",i.className="gradient-popover-close",i.innerHTML=yt,i.addEventListener("click",()=>this.closePopover()),t.appendChild(e),t.appendChild(i);const s=document.createElement("div");s.className="gradient-editor";const n=this.createTypeTabs();s.appendChild(n);const o=document.createElement("div");o.className="gradient-editor-content",this.updatePopoverContent(o),s.appendChild(o),this.popoverEl.appendChild(t),this.popoverEl.appendChild(s),document.body.appendChild(this.popoverEl)}createTypeTabs(){var s,n;const t=document.createElement("div");t.className="gradient-type-tabs";const e=document.createElement("button");e.type="button",e.className=`gradient-type-tab ${((s=this.value)==null?void 0:s.type)==="solid"?"active":""}`,e.textContent="Solid",e.addEventListener("click",()=>this.switchType("solid"));const i=document.createElement("button");return i.type="button",i.className=`gradient-type-tab ${((n=this.value)==null?void 0:n.type)!=="solid"?"active":""}`,i.textContent="Gradient",i.addEventListener("click",()=>{var a,l;const o=((a=this.value)==null?void 0:a.type)==="solid"?"linear":((l=this.value)==null?void 0:l.type)||"linear";this.switchType(o)}),t.appendChild(e),t.appendChild(i),t}switchType(t){var i,s;if(!this.value)return;if(this.value.type=t,t!=="solid"&&(!this.value.stops||this.value.stops.length===0)&&(this.value.stops=[{color:"#a84b4b",position:0,opacity:100},{color:"#786666",position:100,opacity:100}]),this.popoverEl){const n=this.popoverEl.querySelectorAll(".gradient-type-tab");n.forEach(l=>l.classList.remove("active"));const o=n[0],a=n[1];t==="solid"?o==null||o.classList.add("active"):a==null||a.classList.add("active")}const e=(i=this.popoverEl)==null?void 0:i.querySelector(".gradient-editor-content");e&&(this.updatePopoverContent(e),((s=document.activeElement)==null?void 0:s.tagName)!=="INPUT"&&this.repositionPopover()),this.updateUI(),this.triggerChange()}updatePopoverContent(t){t.innerHTML="",this.value&&(this.value.type==="solid"?this.renderSolid(t):this.renderGradient(t))}renderSolid(t){(!this.value||!this.value.stops||!this.value.stops.length)&&(this.value||(this.value=this.defaultValue()),this.value.stops=[{color:"#000000",position:0,opacity:100}]);const e=this.value.stops[0],i=new ce({initialColor:e.color,initialOpacity:e.opacity??100,onColorChange:(s,n)=>{this.value&&(this.value.stops[0].color=s,this.value.stops[0].opacity=n,this.updateUI(),this.triggerChange())}});t.appendChild(i.getElement())}renderGradient(t){const e=document.createElement("div");e.className="gradient-subtype-inline";const i=document.createElement("select");i.className="gradient-subtype-select";const s=document.createElement("option");s.value="linear",s.textContent="Linear";const n=document.createElement("option");n.value="radial",n.textContent="Radial",i.appendChild(s),i.appendChild(n),i.value=this.value.type==="radial"?"radial":"linear";const o=document.createElement("input");o.type="text",o.inputMode="numeric",o.className="gradient-degree-input",o.value=`${this.value.angle??0}°`,o.style.width="75px",o.style.textAlign="center";const a=document.createElement("button");a.type="button",a.className="gradient-flip-btn",a.innerHTML=ae,i.addEventListener("change",()=>{this.switchType(i.value==="radial"?"radial":"linear"),this.updateDegreeVisibility(o)}),o.addEventListener("focus",u=>{const m=u.target;m.value=m.value.replace(/[^0-9-]/g,""),setTimeout(()=>m.select(),0)}),o.addEventListener("input",u=>{const m=parseInt(u.target.value);!Number.isNaN(m)&&this.value&&(this.value.angle=Math.max(0,Math.min(360,m)),this.updateGradientPreview(),this.triggerChange())}),o.addEventListener("blur",u=>{var C;const m=u.target;let f=parseInt(m.value);Number.isNaN(f)&&(f=((C=this.value)==null?void 0:C.angle)??0),f=Math.max(0,Math.min(360,f)),this.value&&(this.value.angle=f),m.value=`${f}°`,this.updateGradientPreview(),this.updateUI(),this.triggerChange()}),a.addEventListener("click",()=>{!this.value||!this.value.stops||(this.value.stops.forEach(u=>{u.position=100-u.position}),this.value.stops.sort((u,m)=>u.position-m.position),this.updateGradientPreview(l),this.createHandles(r,l),this.updateStopsList(g),this.updateUI(),this.triggerChange())}),e.appendChild(i),e.appendChild(o),e.appendChild(a),t.appendChild(e),this.updateDegreeVisibility(o);const l=document.createElement("div");l.className="gradient-preview",this.updateGradientPreview(l);const r=document.createElement("div");r.className="gradient-handles",l.appendChild(r),t.appendChild(l),this.createHandles(r,l);const h=document.createElement("div");h.className="gradient-stops-header";const p=document.createElement("span");p.textContent="Stops";const d=document.createElement("button");d.type="button",d.className="gradient-add-stop",d.textContent="+",h.appendChild(p),h.appendChild(d);const g=document.createElement("div");g.className="gradient-stops",t.appendChild(h),t.appendChild(g),this.updateStopsList(g),d.addEventListener("click",()=>{var u;this.addStop(),this.updateStopsList(g),this.updateGradientPreview(l),this.createHandles(r,l),this.updateUI(),((u=document.activeElement)==null?void 0:u.tagName)!=="INPUT"&&this.repositionPopover(),this.triggerChange()})}updateDegreeVisibility(t){var e;((e=this.value)==null?void 0:e.type)==="radial"?(t.disabled=!0,t.style.opacity="0.5"):(t.disabled=!1,t.style.opacity="1")}updateGradientPreview(t){var i;const e=t||((i=this.popoverEl)==null?void 0:i.querySelector(".gradient-preview"));e&&this.value&&(e.style.background=T(this.value))}createHandles(t,e){t.innerHTML="",!(!this.value||this.value.type==="solid"||!this.value.stops)&&this.value.stops.forEach((i,s)=>{const n=document.createElement("div");n.className="gstop-handle",n.style.left=`${Math.max(0,Math.min(100,i.position))}%`,n.style.top="0%";const o=document.createElement("div");o.className="gstop-chip",o.style.backgroundColor=i.color,n.appendChild(o);let a=!1,l=0,r=0;const h=g=>{a=!0,l=g.clientX,r=this.value.stops[s].position,n.classList.add("selected"),document.addEventListener("mousemove",p),document.addEventListener("mouseup",d),g.preventDefault(),g.stopPropagation()},p=g=>{if(!a||!this.value)return;const u=e.getBoundingClientRect(),m=g.clientX-l;let f=r+m/u.width*100;f=Math.max(0,Math.min(100,f)),this.value.stops[s].position=Math.round(f),n.style.left=`${f}%`,this.updateGradientPreview(),this.updateUI()},d=()=>{a&&(a=!1,n.classList.remove("selected"),document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",d),this.value&&(this.value.stops.sort((g,u)=>g.position-u.position),this.createHandles(t,e)),this.updateStopsList(),this.updateUI(),this.triggerChange())};n.addEventListener("mousedown",h),t.appendChild(n)})}updateStopsList(t){var s;const e=t||((s=this.popoverEl)==null?void 0:s.querySelector(".gradient-stops"));if(!e||!this.value||this.value.type==="solid"||!this.value.stops)return;e.innerHTML="";const i=[...this.value.stops].sort((n,o)=>n.position-o.position);i.forEach((n,o)=>{var G,W;const a=this.value.stops.findIndex((v,b)=>v.position===n.position&&v.color===n.color&&v.opacity===n.opacity&&this.value.stops.slice(0,b).filter(w=>w.position===n.position&&w.color===n.color&&w.opacity===n.opacity).length===i.slice(0,o).filter(w=>w.position===n.position&&w.color===n.color&&w.opacity===n.opacity).length),l=a!==-1?a:o,r=document.createElement("div");r.className="gstop-row";const h=document.createElement("div");h.className="gstop-position-group";const p=document.createElement("input");p.type="text",p.className="gstop-position-input",p.value=`${n.position}%`,p.style.width="60px",h.appendChild(p);const d=document.createElement("div");d.className="gstop-color-container";const g=document.createElement("div");g.className="gstop-color-preview",g.style.backgroundColor=n.color;const u=document.createElement("input");u.type="text",u.className="gstop-color-input",u.value=n.color.replace("#","").toUpperCase();const m=document.createElement("button");m.type="button",m.className="gstop-color-copy",m.textContent="Copy",d.appendChild(g),d.appendChild(u),d.appendChild(m);const f=document.createElement("button");f.type="button",f.className="gstop-del",f.innerHTML=le,f.disabled=(((W=(G=this.value)==null?void 0:G.stops)==null?void 0:W.length)||0)<=2,r.appendChild(h),r.appendChild(d),r.appendChild(f),e.appendChild(r);const C=document.createElement("span");C.className="gstop-opacity-label",C.textContent="Opacity";const L=document.createElement("div");L.className="gstop-opacity-group";const E=document.createElement("input");E.type="range",E.className="gstop-opacity-slider",E.min="0",E.max="100",E.value=String(n.opacity??100);const P=I(n.color);E.style.setProperty("--slider-color",`rgb(${P.r}, ${P.g}, ${P.b})`);const S=document.createElement("span");S.className="gstop-opacity-value",S.textContent=`${n.opacity??100}%`,L.appendChild(E),L.appendChild(S);const $=new re((v,b)=>{u.value=v.replace("#","").toUpperCase(),g.style.backgroundColor=v,this.value.stops[l].color=v,b!==void 0&&(this.value.stops[l].opacity=b,E.value=String(b),S.textContent=`${b}%`);const w=I(v);E.style.setProperty("--slider-color",`rgb(${w.r}, ${w.g}, ${w.b})`),this.updateGradientPreview(),this.createHandles(this.popoverEl.querySelector(".gradient-handles"),this.popoverEl.querySelector(".gradient-preview")),this.updateUI(),this.triggerChange()},"gradient");u.addEventListener("click",v=>{v.preventDefault(),v.stopPropagation(),$.open(n.color,u,n.opacity??100)}),u.addEventListener("input",()=>{const v=u.value.trim(),b=v.startsWith("#")?v:`#${v}`;if(/^#[0-9A-Fa-f]{6}$/.test(b)){this.value.stops[l].color=b,g.style.backgroundColor=b;const w=I(b);E.style.setProperty("--slider-color",`rgb(${w.r}, ${w.g}, ${w.b})`),this.updateGradientPreview(),this.updateUI(),this.triggerChange()}}),m.addEventListener("click",async v=>{v.stopPropagation();try{await navigator.clipboard.writeText(`#${u.value}`)}catch{}}),p.addEventListener("focus",v=>{const b=v.target;b.value=b.value.replace("%",""),b.select()}),p.addEventListener("input",v=>{const b=v.target,w=parseInt(b.value.replace(/[^\d]/g,""),10);if(!Number.isNaN(w)){const at=Math.max(0,Math.min(100,w));this.value.stops[l].position=at,b.value=`${at}%`,this.updateGradientPreview(),this.createHandles(this.popoverEl.querySelector(".gradient-handles"),this.popoverEl.querySelector(".gradient-preview")),this.updateUI(),this.triggerChange()}}),p.addEventListener("blur",v=>{const b=v.target,w=parseInt(b.value.replace(/[^\d]/g,""),10);Number.isNaN(w)?b.value=`${this.value.stops[l].position}%`:b.value=`${Math.max(0,Math.min(100,w))}%`}),f.addEventListener("click",()=>{var v;(this.value.stops.length||0)<=2||(this.value.stops.splice(l,1),this.createHandles(this.popoverEl.querySelector(".gradient-handles"),this.popoverEl.querySelector(".gradient-preview")),this.updateStopsList(),this.updateGradientPreview(),this.updateUI(),((v=document.activeElement)==null?void 0:v.tagName)!=="INPUT"&&this.repositionPopover(),this.triggerChange())}),E.addEventListener("input",()=>{const v=parseInt(E.value,10);this.value.stops[l].opacity=Math.max(0,Math.min(100,v)),S.textContent=`${this.value.stops[l].opacity}%`,this.updateGradientPreview(),this.updateUI(),this.triggerChange()})})}addStop(){if(!this.value||this.value.type==="solid"||!this.value.stops)return;const t=this.value.stops.map(o=>o.position).sort((o,a)=>o-a);let e=50,i=0;for(let o=0;o<t.length-1;o++){const a=t[o+1]-t[o];a>i&&(i=a,e=t[o]+a/2)}const s=this.value.stops.reduce((o,a)=>Math.abs(a.position-e)<Math.abs(o.position-e)?a:o),n={position:Math.round(e),color:s.color,opacity:s.opacity??100};this.value.stops.push(n),this.value.stops.sort((o,a)=>o.position-a.position)}openPopover(){if(this.popoverEl&&(V.openInstance&&V.openInstance!==this&&V.openInstance.closePopover(),!this.isPopoverOpen)){if(this.isPopoverOpen=!0,V.openInstance=this,this.popoverEl.style.display="flex",this.refreshPopoverContent(),this.element){const t=this.element.getBoundingClientRect(),e=306,i=window.innerWidth,s=window.innerHeight,n=16;this.popoverEl.style.position="fixed",this.popoverEl.style.zIndex="10000",this.popoverEl.style.left="-9999px",this.popoverEl.style.top="0px";const o=this.popoverEl.offsetHeight;let a=t.right+8,l=t.top;const r=i-t.right,h=t.left,p=e+n;r<p&&h>r+100&&(a=t.left-e-8);const d=s-t.bottom,g=t.top;g>=o+n?l=t.top-o-8:d>=o+n?l=t.bottom+8:g>d?(l=t.top-o-8,l<n&&(l=n)):(l=t.bottom+8,l+o>s-n&&(l=s-o-n)),this.popoverEl.style.left=`${a}px`,this.popoverEl.style.top=`${l}px`}setTimeout(()=>document.addEventListener("click",this.onBackgroundClick,!0),0)}}repositionPopover(){var t;!this.popoverEl||!this.isPopoverOpen||!this.element||((t=document.activeElement)==null?void 0:t.tagName)!=="INPUT"&&requestAnimationFrame(()=>{if(!this.popoverEl||!this.element)return;const e=this.element.getBoundingClientRect(),i=306,s=window.innerWidth,n=window.innerHeight,o=16;this.popoverEl.style.left,this.popoverEl.style.top,this.popoverEl.style.left="-9999px",this.popoverEl.style.top="0px";const a=this.popoverEl.offsetHeight;let l=e.right+8,r=e.top;const h=s-e.right,p=e.left,d=i+o;h<d&&p>h+100&&(l=e.left-i-8);const g=n-e.bottom,u=e.top;u>=a+o?r=e.top-a-8:g>=a+o?r=e.bottom+8:u>g?(r=e.top-a-8,r<o&&(r=o)):(r=e.bottom+8,r+a>n-o&&(r=n-a-o)),this.popoverEl.style.left=`${l}px`,this.popoverEl.style.top=`${r}px`})}refreshPopoverContent(){var n;if(!this.popoverEl)return;const t=this.popoverEl.querySelectorAll(".gradient-type-tab");t.forEach(o=>o.classList.remove("active"));const e=t[0],i=t[1];((n=this.value)==null?void 0:n.type)==="solid"?e.classList.add("active"):i.classList.add("active"),this.popoverEl.offsetHeight;const s=this.popoverEl.querySelector(".gradient-editor-content");s&&this.updatePopoverContent(s)}closePopover(){!this.popoverEl||!this.isPopoverOpen||(this.isPopoverOpen=!1,this.popoverEl.style.display="none",document.removeEventListener("click",this.onBackgroundClick,!0),V.openInstance===this&&(V.openInstance=null))}handlePaste(t){var i;t.preventDefault();const e=((i=t.clipboardData)==null?void 0:i.getData("text"))||"";this.parseAndSet(e)}handleTextInput(t){const e=t.target;this.parseAndSet(e.value)}parseAndSet(t){const e=Q(t.trim());e&&this.setValue(e)}triggerChange(){var t,e;this.value&&((t=this.onChange)==null||t.call(this,this.value),(e=this.detectChange)==null||e.call(this,this.value))}getElement(){return this.element}getValue(){return this.value?this.forText?this.cssForTextValue():T(this.value):this.forText?{}:""}getCSSValue(){return this.value?T(this.value):""}getRawValue(){return this.value}};V.openInstance=null;let st=V;const pe=`
|
|
229
|
+
`,t}initializePicker(){const t=this.container.querySelector(".color-picker-area"),e=this.container.querySelector(".color-picker-marker"),i=this.container.querySelector(".color-picker-hue"),s=this.container.querySelector(".color-picker-hue-marker"),n=this.container.querySelector(".color-picker-opacity"),o=this.container.querySelector(".color-picker-opacity-marker"),a=this.container.querySelector(".color-picker-format-select"),l=this.container.querySelector(".color-picker-color-input"),r=this.container.querySelector(".color-picker-copy-inside"),{h,s:p,v:d}=B(this.currentColor);s.style.left=`${h/360*100}%`,e.style.left=`${p*100}%`,e.style.top=`${(1-d)*100}%`,t.style.background=`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${h}, 100%, 50%))`,o.style.left=`${this.currentOpacity}%`,this.updateOpacityBackground(n),this.updateColorInput(a,l),this.setupColorAreaEvents(t,e,s),this.setupHueSliderEvents(i,s,t,e,a,l,n),this.setupOpacitySliderEvents(n,o),this.setupFormatEvents(a,l,r)}updateOpacityBackground(t){const e=I(this.currentColor);t.style.setProperty("--base-color",`rgb(${e.r}, ${e.g}, ${e.b})`)}updateColorInput(t,e){switch(t.value){case"hex":e.value=this.currentColor;break;case"rgb":const s=I(this.currentColor);e.value=`rgb(${s.r}, ${s.g}, ${s.b})`;break;case"hsl":const{h:n,s:o,v:a}=B(this.currentColor),l=a*(1-o/2),r=l===0||l===1?0:(a-l)/Math.min(l,1-l);e.value=`hsl(${Math.round(n)}, ${Math.round(r*100)}%, ${Math.round(l*100)}%)`;break}}setupColorAreaEvents(t,e,i){const s=n=>{const o=t.getBoundingClientRect(),a=Math.max(0,Math.min(1,(n.clientX-o.left)/o.width)),l=Math.max(0,Math.min(1,(n.clientY-o.top)/o.height));e.style.left=`${a*100}%`,e.style.top=`${l*100}%`;const r=parseFloat(i.style.left||"0%")/100*360,h=U(r,a,1-l);this.currentColor=h;const p=this.container.querySelector(".color-picker-format-select"),d=this.container.querySelector(".color-picker-color-input"),g=this.container.querySelector(".color-picker-opacity");this.updateColorInput(p,d),this.updateOpacityBackground(g),this.triggerChange()};t.addEventListener("mousedown",n=>{n.preventDefault(),s(n);const o=l=>s(l),a=()=>{document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",a)};document.addEventListener("mousemove",o),document.addEventListener("mouseup",a)})}setupHueSliderEvents(t,e,i,s,n,o,a){const l=r=>{const h=t.getBoundingClientRect();let p=(r.clientX-h.left)/h.width;p=Math.max(0,Math.min(1,p)),e.style.left=`${p*100}%`;const d=p*360,g=parseFloat(s.style.left||"50%")/100,u=parseFloat(s.style.top||"50%")/100;i.style.background=`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${d}, 100%, 50%))`;const m=U(d,g,1-u);this.currentColor=m,this.updateColorInput(n,o),this.updateOpacityBackground(a),this.triggerChange()};t.addEventListener("mousedown",r=>{r.preventDefault(),l(r);const h=d=>l(d),p=()=>{document.removeEventListener("mousemove",h),document.removeEventListener("mouseup",p)};document.addEventListener("mousemove",h),document.addEventListener("mouseup",p)})}setupOpacitySliderEvents(t,e){const i=s=>{const n=t.getBoundingClientRect(),o=Math.max(0,Math.min(1,(s.clientX-n.left)/n.width));e.style.left=`${o*100}%`,this.currentOpacity=Math.round(o*100),this.triggerChange()};t.addEventListener("mousedown",s=>{s.preventDefault(),i(s);const n=a=>i(a),o=()=>{document.removeEventListener("mousemove",n),document.removeEventListener("mouseup",o)};document.addEventListener("mousemove",n),document.addEventListener("mouseup",o)})}setupFormatEvents(t,e,i){t.addEventListener("change",()=>{this.updateColorInput(t,e)}),i.addEventListener("click",()=>{navigator.clipboard.writeText(e.value).catch(()=>{e.select(),document.execCommand("copy")})}),e.addEventListener("input",()=>{this.handleManualColorInput(e.value,t)}),e.addEventListener("blur",()=>{this.updateColorInput(t,e)})}handleManualColorInput(t,e){const i=t.trim();let s=null;switch(e.value){case"hex":s=this.parseHexInput(i);break;case"rgb":s=this.parseRgbInput(i);break;case"hsl":s=this.parseHslInput(i);break}s||(s=this.autoDetectColorFormat(i)),s&&(this.currentColor=s,this.updatePickerVisualState(),this.triggerChange())}parseHexInput(t){const e=t.startsWith("#")?t:`#${t}`;return F(e)}parseRgbInput(t){const e=t.match(/rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)(?:\s*,\s*[\d.]+)?\s*\)/);if(e){const i=parseInt(e[1]),s=parseInt(e[2]),n=parseInt(e[3]);if(i<=255&&s<=255&&n<=255)return R(i,s,n)}return null}parseHslInput(t){const e=t.match(/hsla?\s*\(\s*([\d.]+)\s*,\s*([\d.]+)%\s*,\s*([\d.]+)%(?:\s*,\s*[\d.]+)?\s*\)/);if(e){const i=parseFloat(e[1]),s=parseFloat(e[2])/100,n=parseFloat(e[3])/100;if(i>=0&&i<=360&&s>=0&&s<=1&&n>=0&&n<=1){const o=X(i,s,n);return R(o.r,o.g,o.b)}}return null}autoDetectColorFormat(t){const e=this.parseHexInput(t);if(e)return e;const i=this.parseRgbInput(t);if(i)return i;const s=this.parseHslInput(t);return s||null}updatePickerVisualState(){const t=this.container.querySelector(".color-picker-area"),e=this.container.querySelector(".color-picker-marker"),i=this.container.querySelector(".color-picker-hue-marker"),s=this.container.querySelector(".color-picker-opacity"),{h:n,s:o,v:a}=B(this.currentColor);i.style.left=`${n/360*100}%`,e.style.left=`${o*100}%`,e.style.top=`${(1-a)*100}%`,t.style.background=`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${n}, 100%, 50%))`,this.updateOpacityBackground(s)}triggerChange(){this.onColorChange(this.currentColor,this.currentOpacity)}getElement(){return this.container}updateColor(t,e){this.currentColor=t,this.currentOpacity=e;const i=this.container.querySelector(".color-picker-area"),s=this.container.querySelector(".color-picker-marker"),n=this.container.querySelector(".color-picker-hue-marker"),o=this.container.querySelector(".color-picker-opacity-marker"),a=this.container.querySelector(".color-picker-opacity"),l=this.container.querySelector(".color-picker-format-select"),r=this.container.querySelector(".color-picker-color-input"),{h,s:p,v:d}=B(t),g=h>=360?h%360:h;n.style.left=`${g/360*100}%`,s.style.left=`${p*100}%`,s.style.top=`${(1-d)*100}%`,i.style.background=`linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, hsl(${g}, 100%, 50%))`,o.style.left=`${e}%`,this.updateOpacityBackground(a),this.updateColorInput(l,r)}}const rt=c=>{const t=[];let e="",i=0;for(let s=0;s<c.length;s++){const n=c[s];if(n==="(")i++;else if(n===")")i--;else if(n===","&&i===0){t.push(e.trim()),e="";continue}e+=n}return e.trim()&&t.push(e.trim()),t},ct=(c,t)=>{const e=new RegExp(`${t}\\s*\\(`,"i"),i=c.match(e);if(!i)return null;const s=i.index+i[0].length;let n=1,o=s;for(let a=s;a<c.length&&n>0;a++)c[a]==="("?n++:c[a]===")"&&n--,o=a;return n===0?c.substring(s,o):null},he=c=>{const t=c.split(" ")[0].toLowerCase();return["circle","ellipse","closest-side","closest-corner","farthest-side","farthest-corner","at","contain","cover"].includes(t)?!1:/^#[0-9a-f]{3,8}$/i.test(t)||/^rgb/i.test(c)||/^hsl/i.test(c)||ie(t)},ht=c=>{const t=[];return c.forEach((e,i)=>{const s=e.trim();if(!s)return;let n="",o=0;const a=s.match(/^(.+?)\s+(\d+(?:\.\d+)?)%?\s*$/);a&&vt(a[1].trim())?(n=a[1].trim(),o=parseFloat(a[2])):(n=s,o=c.length===1?0:i/(c.length-1)*100);const l=Ct(n);l.position=Math.max(0,Math.min(100,Math.round(o))),t.push(l)}),t},D=c=>{const t=c.stops&&c.stops.length?c.stops:[{color:"#000000",position:0,opacity:100}];return{type:c.type&&["linear","radial","solid"].includes(c.type)?c.type:"linear",angle:typeof c.angle=="number"?c.angle:90,stops:t.map((e,i)=>({color:e.color||"#000000",position:typeof e.position=="number"?e.position:t.length===1?0:Math.round(i/(t.length-1)*100),opacity:e.opacity===void 0||Number.isNaN(e.opacity)?100:e.opacity}))}},Q=c=>{const t=c.replace(/;$/,"").trim();if(se(t)){const s=Ct(t);return D({type:"solid",angle:0,stops:[s]})}const e=ct(t,"linear-gradient");if(e){const s=rt(e);let n=90,o=s;const a=s[0];if(a.includes("deg")){const r=a.match(/(-?\d+(?:\.\d+)?)deg/);r&&(n=parseFloat(r[1]),o=s.slice(1))}else a.includes("to ")&&(n={"to right":90,"to left":270,"to bottom":180,"to top":0,"to bottom right":135,"to bottom left":225,"to top right":45,"to top left":315}[a]??90,o=s.slice(1));const l=ht(o);return l.length?D({type:"linear",angle:n,stops:l}):null}const i=ct(t,"radial-gradient");if(i){const s=rt(i),n=s[0]&&!he(s[0])?s.slice(1):s,o=ht(n);return o.length?D({type:"radial",angle:0,stops:o}):null}return null},P=c=>{if(c.type==="solid"){const e=c.stops[0],i=e.opacity??100,s=e.color.replace("#",""),n=Math.round(i/100*255).toString(16).toUpperCase().padStart(2,"0");return`#${s}${n}`}const t=c.stops.map(e=>`${ft(e.color,e.opacity??100)} ${e.position}%`).join(", ");return c.type==="radial"?`radial-gradient(circle, ${t})`:`linear-gradient(${c.angle}deg, ${t})`},tt=c=>{if(c.type==="solid"){const t=c.stops[0];return t?t.color.replace("#","").toUpperCase():"Color"}return c.type==="linear"?`Linear ${c.angle}°`:"Radial Gradient"},V=class V extends y{constructor(t={}){const e=typeof t.default=="string"?void 0:t.default;super({...t,title:t.title||"Gradient",default:e}),this.inputType={type:"text",angle:"number",stops:"text"},this.element=null,this.previewEl=null,this.inputEl=void 0,this.popoverEl=null,this.isPopoverOpen=!1,this.isEditing=!1,this.previewUpdateTimeout=null,this.onBackgroundClick=i=>{var p;if(!this.popoverEl||!this.isPopoverOpen)return;const s=i.target,n=this.popoverEl.contains(s),o=(p=this.element)==null?void 0:p.contains(s),a=document.querySelectorAll(".custom-color-picker"),l=Array.from(a).some(d=>d.contains(s)),r=s.closest(".gstop-color-input, .gradient-mini-preview, .gstop-color-preview"),h=s.classList.contains("color-picker-backdrop");!n&&!o&&!l&&!r&&!h&&this.closePopover()},this.detectChange=t.detectChange,this.forText=t.forText||!1,this.originalDefault=t.default,this.value=this.defaultValue()}defaultValue(){const t=this.originalDefault;if(typeof t=="string"){const i=Q(t);if(i)return D(i)}return D(t&&typeof t=="object"?t:{type:"linear",angle:90,stops:[{color:"#a84b4b",position:0,opacity:100},{color:"#786666",position:100,opacity:100}]})}setValue(t){var i,s;let e=null;typeof t=="string"?e=Q(t):t&&typeof t=="object"&&(e=D(t)),e||(e=this.defaultValue()),this.value=e,this.updateUI(),this.isPopoverOpen&&this.refreshPopoverContent(),(i=this.onChange)==null||i.call(this,this.value),(s=this.detectChange)==null||s.call(this,this.value)}updateUI(){if(this.previewEl&&this.value)if(this.value.type==="solid"){const t=this.value.stops[0],e=t.opacity??100;this.previewEl.style.background=ft(t.color,e)}else this.previewEl.style.background=P(this.value);this.inputEl&&this.value&&!this.isEditing&&(this.inputEl.value=tt(this.value))}cssForTextValue(){return this.value?{background:P(this.value),"-webkit-background-clip":"text","background-clip":"text",color:"transparent","-webkit-text-fill-color":"transparent"}:{}}draw(){const t=document.createElement("div");if(t.className="gradient-setting-wrapper",this.props.title){const i=document.createElement("div");i.className="icon-container";const s=document.createElement("span");s.className="input-label",s.textContent=this.props.title,i.appendChild(s),t.appendChild(i)}const e=document.createElement("div");return e.className="gradient-input-wrapper",this.previewEl=document.createElement("div"),this.previewEl.className="gradient-mini-preview",this.previewEl.style.background=this.value?P(this.value):"linear-gradient(90deg, #a84b4b 0%, #786666 100%)",this.previewEl.addEventListener("mousedown",i=>{i.preventDefault(),i.stopPropagation(),this.openPopover()}),this.inputEl=document.createElement("input"),this.inputEl.type="text",this.inputEl.className="gradient-text-input",this.inputEl.placeholder="Enter gradient CSS or paste color...",this.inputEl.value=this.value?tt(this.value):"",this.inputEl.readOnly=!1,this.inputEl.addEventListener("focus",()=>{this.isEditing=!0,this.value&&(this.inputEl.value=P(this.value))}),this.inputEl.addEventListener("blur",()=>{this.isEditing=!1,this.value&&(this.inputEl.value=tt(this.value))}),this.inputEl.addEventListener("paste",i=>this.handlePaste(i)),this.inputEl.addEventListener("input",i=>this.handleTextInput(i)),this.inputEl.addEventListener("keydown",i=>{i.key==="Enter"&&(this.handleTextInput(i),this.inputEl.blur()),i.key==="Escape"&&(this.value&&(this.inputEl.value=P(this.value)),this.inputEl.blur())}),e.appendChild(this.previewEl),e.appendChild(this.inputEl),t.appendChild(e),this.createPopover(),this.element=t,t}createPopover(){if(this.popoverEl)return;this.popoverEl=document.createElement("div"),this.popoverEl.className="gradient-popover",this.popoverEl.style.display="none";const t=document.createElement("div");t.className="gradient-popover-header";const e=document.createElement("span");e.textContent="Fill";const i=document.createElement("button");i.type="button",i.className="gradient-popover-close",i.innerHTML=yt,i.addEventListener("click",()=>this.closePopover()),t.appendChild(e),t.appendChild(i);const s=document.createElement("div");s.className="gradient-editor";const n=this.createTypeTabs();s.appendChild(n);const o=document.createElement("div");o.className="gradient-editor-content",this.updatePopoverContent(o),s.appendChild(o),this.popoverEl.appendChild(t),this.popoverEl.appendChild(s),document.body.appendChild(this.popoverEl)}createTypeTabs(){var s,n;const t=document.createElement("div");t.className="gradient-type-tabs";const e=document.createElement("button");e.type="button",e.className=`gradient-type-tab ${((s=this.value)==null?void 0:s.type)==="solid"?"active":""}`,e.textContent="Solid",e.addEventListener("click",()=>this.switchType("solid"));const i=document.createElement("button");return i.type="button",i.className=`gradient-type-tab ${((n=this.value)==null?void 0:n.type)!=="solid"?"active":""}`,i.textContent="Gradient",i.addEventListener("click",()=>{var a,l;const o=((a=this.value)==null?void 0:a.type)==="solid"?"linear":((l=this.value)==null?void 0:l.type)||"linear";this.switchType(o)}),t.appendChild(e),t.appendChild(i),t}switchType(t){var i,s;if(!this.value)return;if(this.value.type=t,t!=="solid"&&(!this.value.stops||this.value.stops.length===0)&&(this.value.stops=[{color:"#a84b4b",position:0,opacity:100},{color:"#786666",position:100,opacity:100}]),this.popoverEl){const n=this.popoverEl.querySelectorAll(".gradient-type-tab");n.forEach(l=>l.classList.remove("active"));const o=n[0],a=n[1];t==="solid"?o==null||o.classList.add("active"):a==null||a.classList.add("active")}const e=(i=this.popoverEl)==null?void 0:i.querySelector(".gradient-editor-content");e&&(this.updatePopoverContent(e),((s=document.activeElement)==null?void 0:s.tagName)!=="INPUT"&&this.repositionPopover()),this.updateUI(),this.triggerChange()}updatePopoverContent(t){t.innerHTML="",this.value&&(this.value.type==="solid"?this.renderSolid(t):this.renderGradient(t))}renderSolid(t){(!this.value||!this.value.stops||!this.value.stops.length)&&(this.value||(this.value=this.defaultValue()),this.value.stops=[{color:"#000000",position:0,opacity:100}]);const e=this.value.stops[0],i=new ce({initialColor:e.color,initialOpacity:e.opacity??100,onColorChange:(s,n)=>{this.value&&(this.value.stops[0].color=s,this.value.stops[0].opacity=n,this.updateUI(),this.triggerChange())}});t.appendChild(i.getElement())}renderGradient(t){const e=document.createElement("div");e.className="gradient-subtype-inline";const i=document.createElement("select");i.className="gradient-subtype-select";const s=document.createElement("option");s.value="linear",s.textContent="Linear";const n=document.createElement("option");n.value="radial",n.textContent="Radial",i.appendChild(s),i.appendChild(n),i.value=this.value.type==="radial"?"radial":"linear";const o=document.createElement("input");o.type="text",o.inputMode="numeric",o.className="gradient-degree-input",o.value=`${this.value.angle??0}°`,o.style.width="75px",o.style.textAlign="center";const a=document.createElement("button");a.type="button",a.className="gradient-flip-btn",a.innerHTML=ae,i.addEventListener("change",()=>{this.switchType(i.value==="radial"?"radial":"linear"),this.updateDegreeVisibility(o)}),o.addEventListener("focus",u=>{const m=u.target;m.value=m.value.replace(/[^0-9-]/g,""),setTimeout(()=>m.select(),0)}),o.addEventListener("input",u=>{const m=parseInt(u.target.value);!Number.isNaN(m)&&this.value&&(this.value.angle=Math.max(0,Math.min(360,m)),this.debouncedPreviewUpdate())}),o.addEventListener("blur",u=>{var C;this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null);const m=u.target;let f=parseInt(m.value);Number.isNaN(f)&&(f=((C=this.value)==null?void 0:C.angle)??0),f=Math.max(0,Math.min(360,f)),this.value&&(this.value.angle=f),m.value=`${f}°`,this.updateGradientPreview(),this.updateUI(),this.triggerChange()}),a.addEventListener("click",()=>{!this.value||!this.value.stops||(this.value.stops.forEach(u=>{u.position=100-u.position}),this.value.stops.sort((u,m)=>u.position-m.position),this.updateGradientPreview(l),this.createHandles(r,l),this.updateStopsList(g),this.updateUI(),this.triggerChange())}),e.appendChild(i),e.appendChild(o),e.appendChild(a),t.appendChild(e),this.updateDegreeVisibility(o);const l=document.createElement("div");l.className="gradient-preview",this.updateGradientPreview(l);const r=document.createElement("div");r.className="gradient-handles",l.appendChild(r),t.appendChild(l),this.createHandles(r,l);const h=document.createElement("div");h.className="gradient-stops-header";const p=document.createElement("span");p.textContent="Stops";const d=document.createElement("button");d.type="button",d.className="gradient-add-stop",d.textContent="+",h.appendChild(p),h.appendChild(d);const g=document.createElement("div");g.className="gradient-stops",t.appendChild(h),t.appendChild(g),this.updateStopsList(g),d.addEventListener("click",()=>{var u;this.addStop(),this.updateStopsList(g),this.updateGradientPreview(l),this.createHandles(r,l),this.updateUI(),((u=document.activeElement)==null?void 0:u.tagName)!=="INPUT"&&this.repositionPopover(),this.triggerChange()})}updateDegreeVisibility(t){var e;((e=this.value)==null?void 0:e.type)==="radial"?(t.disabled=!0,t.style.opacity="0.5"):(t.disabled=!1,t.style.opacity="1")}updateGradientPreview(t){var i;const e=t||((i=this.popoverEl)==null?void 0:i.querySelector(".gradient-preview"));e&&this.value&&(e.style.background=P(this.value))}debouncedPreviewUpdate(t){this.previewUpdateTimeout&&clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=window.setTimeout(()=>{this.updateGradientPreview(t),this.previewUpdateTimeout=null},16)}createHandles(t,e){t.innerHTML="",!(!this.value||this.value.type==="solid"||!this.value.stops)&&this.value.stops.forEach((i,s)=>{const n=document.createElement("div");n.className="gstop-handle",n.style.left=`${Math.max(0,Math.min(100,i.position))}%`,n.style.top="0%";const o=document.createElement("div");o.className="gstop-chip",o.style.backgroundColor=i.color,n.appendChild(o);let a=!1,l=0,r=0;const h=g=>{a=!0,l=g.clientX,r=this.value.stops[s].position,n.classList.add("selected"),document.addEventListener("mousemove",p),document.addEventListener("mouseup",d),g.preventDefault(),g.stopPropagation()},p=g=>{if(!a||!this.value)return;const u=e.getBoundingClientRect(),m=g.clientX-l;let f=r+m/u.width*100;f=Math.max(0,Math.min(100,f)),this.value.stops[s].position=Math.round(f),n.style.left=`${f}%`,this.updateGradientPreview(),this.updateUI()},d=()=>{a&&(a=!1,n.classList.remove("selected"),document.removeEventListener("mousemove",p),document.removeEventListener("mouseup",d),this.value&&(this.value.stops.sort((g,u)=>g.position-u.position),this.createHandles(t,e)),this.updateStopsList(),this.updateUI(),this.triggerChange())};n.addEventListener("mousedown",h),t.appendChild(n)})}updateStopsList(t){var s;const e=t||((s=this.popoverEl)==null?void 0:s.querySelector(".gradient-stops"));if(!e||!this.value||this.value.type==="solid"||!this.value.stops)return;e.innerHTML="";const i=[...this.value.stops].sort((n,o)=>n.position-o.position);i.forEach((n,o)=>{var G,W;const a=this.value.stops.findIndex((v,b)=>v.position===n.position&&v.color===n.color&&v.opacity===n.opacity&&this.value.stops.slice(0,b).filter(w=>w.position===n.position&&w.color===n.color&&w.opacity===n.opacity).length===i.slice(0,o).filter(w=>w.position===n.position&&w.color===n.color&&w.opacity===n.opacity).length),l=a!==-1?a:o,r=document.createElement("div");r.className="gstop-row";const h=document.createElement("div");h.className="gstop-position-group";const p=document.createElement("input");p.type="text",p.className="gstop-position-input",p.value=`${n.position}%`,p.style.width="60px",h.appendChild(p);const d=document.createElement("div");d.className="gstop-color-container";const g=document.createElement("div");g.className="gstop-color-preview",g.style.backgroundColor=n.color;const u=document.createElement("input");u.type="text",u.className="gstop-color-input",u.value=n.color.replace("#","").toUpperCase();const m=document.createElement("button");m.type="button",m.className="gstop-color-copy",m.textContent="Copy",d.appendChild(g),d.appendChild(u),d.appendChild(m);const f=document.createElement("button");f.type="button",f.className="gstop-del",f.innerHTML=le,f.disabled=(((W=(G=this.value)==null?void 0:G.stops)==null?void 0:W.length)||0)<=2,r.appendChild(h),r.appendChild(d),r.appendChild(f),e.appendChild(r);const C=document.createElement("span");C.className="gstop-opacity-label",C.textContent="Opacity";const L=document.createElement("div");L.className="gstop-opacity-group";const E=document.createElement("input");E.type="range",E.className="gstop-opacity-slider",E.min="0",E.max="100",E.value=String(n.opacity??100);const H=I(n.color);E.style.setProperty("--slider-color",`rgb(${H.r}, ${H.g}, ${H.b})`);const S=document.createElement("span");S.className="gstop-opacity-value",S.textContent=`${n.opacity??100}%`,L.appendChild(E),L.appendChild(S);const $=new re((v,b)=>{u.value=v.replace("#","").toUpperCase(),g.style.backgroundColor=v,this.value.stops[l].color=v,b!==void 0&&(this.value.stops[l].opacity=b,E.value=String(b),S.textContent=`${b}%`);const w=I(v);E.style.setProperty("--slider-color",`rgb(${w.r}, ${w.g}, ${w.b})`),this.updateGradientPreview(),this.createHandles(this.popoverEl.querySelector(".gradient-handles"),this.popoverEl.querySelector(".gradient-preview")),this.updateUI(),this.triggerChange()},"gradient");u.addEventListener("click",v=>{v.preventDefault(),v.stopPropagation(),$.open(n.color,u,n.opacity??100)}),u.addEventListener("input",()=>{const v=u.value.trim(),b=v.startsWith("#")?v:`#${v}`;if(/^#[0-9A-Fa-f]{6}$/.test(b)){this.value.stops[l].color=b,g.style.backgroundColor=b;const w=I(b);E.style.setProperty("--slider-color",`rgb(${w.r}, ${w.g}, ${w.b})`),this.updateGradientPreview(),this.updateUI(),this.triggerChange()}}),m.addEventListener("click",async v=>{v.stopPropagation();try{await navigator.clipboard.writeText(`#${u.value}`)}catch{}}),p.addEventListener("focus",v=>{const b=v.target;b.value=b.value.replace("%",""),b.select()}),p.addEventListener("input",v=>{const b=v.target,w=parseInt(b.value.replace(/[^\d]/g,""),10);if(!Number.isNaN(w)){const at=Math.max(0,Math.min(100,w));this.value.stops[l].position=at,b.value=`${at}%`,this.updateGradientPreview(),this.createHandles(this.popoverEl.querySelector(".gradient-handles"),this.popoverEl.querySelector(".gradient-preview")),this.updateUI(),this.triggerChange()}}),p.addEventListener("blur",v=>{const b=v.target,w=parseInt(b.value.replace(/[^\d]/g,""),10);Number.isNaN(w)?b.value=`${this.value.stops[l].position}%`:b.value=`${Math.max(0,Math.min(100,w))}%`}),f.addEventListener("click",()=>{var v;(this.value.stops.length||0)<=2||(this.value.stops.splice(l,1),this.createHandles(this.popoverEl.querySelector(".gradient-handles"),this.popoverEl.querySelector(".gradient-preview")),this.updateStopsList(),this.updateGradientPreview(),this.updateUI(),((v=document.activeElement)==null?void 0:v.tagName)!=="INPUT"&&this.repositionPopover(),this.triggerChange())}),E.addEventListener("input",()=>{const v=parseInt(E.value,10);this.value.stops[l].opacity=Math.max(0,Math.min(100,v)),S.textContent=`${this.value.stops[l].opacity}%`,this.updateGradientPreview(),this.updateUI(),this.triggerChange()})})}addStop(){if(!this.value||this.value.type==="solid"||!this.value.stops)return;const t=this.value.stops.map(o=>o.position).sort((o,a)=>o-a);let e=50,i=0;for(let o=0;o<t.length-1;o++){const a=t[o+1]-t[o];a>i&&(i=a,e=t[o]+a/2)}const s=this.value.stops.reduce((o,a)=>Math.abs(a.position-e)<Math.abs(o.position-e)?a:o),n={position:Math.round(e),color:s.color,opacity:s.opacity??100};this.value.stops.push(n),this.value.stops.sort((o,a)=>o.position-a.position)}openPopover(){if(this.popoverEl&&(V.openInstance&&V.openInstance!==this&&V.openInstance.closePopover(),!this.isPopoverOpen)){if(this.isPopoverOpen=!0,V.openInstance=this,this.popoverEl.style.display="flex",this.refreshPopoverContent(),this.element){const t=this.element.getBoundingClientRect(),e=306,i=window.innerWidth,s=window.innerHeight,n=16;this.popoverEl.style.position="fixed",this.popoverEl.style.zIndex="10000",this.popoverEl.style.left="-9999px",this.popoverEl.style.top="0px";const o=this.popoverEl.offsetHeight;let a=t.right+8,l=t.top;const r=i-t.right,h=t.left,p=e+n;r<p&&h>r+100&&(a=t.left-e-8);const d=s-t.bottom,g=t.top;g>=o+n?l=t.top-o-8:d>=o+n?l=t.bottom+8:g>d?(l=t.top-o-8,l<n&&(l=n)):(l=t.bottom+8,l+o>s-n&&(l=s-o-n)),this.popoverEl.style.left=`${a}px`,this.popoverEl.style.top=`${l}px`}setTimeout(()=>document.addEventListener("click",this.onBackgroundClick,!0),0)}}repositionPopover(){var t;!this.popoverEl||!this.isPopoverOpen||!this.element||((t=document.activeElement)==null?void 0:t.tagName)!=="INPUT"&&requestAnimationFrame(()=>{if(!this.popoverEl||!this.element)return;const e=this.element.getBoundingClientRect(),i=306,s=window.innerWidth,n=window.innerHeight,o=16;this.popoverEl.style.left,this.popoverEl.style.top,this.popoverEl.style.left="-9999px",this.popoverEl.style.top="0px";const a=this.popoverEl.offsetHeight;let l=e.right+8,r=e.top;const h=s-e.right,p=e.left,d=i+o;h<d&&p>h+100&&(l=e.left-i-8);const g=n-e.bottom,u=e.top;u>=a+o?r=e.top-a-8:g>=a+o?r=e.bottom+8:u>g?(r=e.top-a-8,r<o&&(r=o)):(r=e.bottom+8,r+a>n-o&&(r=n-a-o)),this.popoverEl.style.left=`${l}px`,this.popoverEl.style.top=`${r}px`})}refreshPopoverContent(){var n;if(!this.popoverEl)return;const t=this.popoverEl.querySelectorAll(".gradient-type-tab");t.forEach(o=>o.classList.remove("active"));const e=t[0],i=t[1];((n=this.value)==null?void 0:n.type)==="solid"?e.classList.add("active"):i.classList.add("active"),this.popoverEl.offsetHeight;const s=this.popoverEl.querySelector(".gradient-editor-content");s&&this.updatePopoverContent(s)}closePopover(){!this.popoverEl||!this.isPopoverOpen||(this.isPopoverOpen=!1,this.popoverEl.style.display="none",document.removeEventListener("click",this.onBackgroundClick,!0),this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null),V.openInstance===this&&(V.openInstance=null))}handlePaste(t){var i;t.preventDefault();const e=((i=t.clipboardData)==null?void 0:i.getData("text"))||"";this.parseAndSet(e)}handleTextInput(t){const e=t.target;this.parseAndSet(e.value)}parseAndSet(t){const e=Q(t.trim());e&&this.setValue(e)}triggerChange(){var t,e;this.value&&((t=this.onChange)==null||t.call(this,this.value),(e=this.detectChange)==null||e.call(this,this.value))}getElement(){return this.element}getValue(){return this.value?this.forText?this.cssForTextValue():P(this.value):this.forText?{}:""}getCSSValue(){return this.value?P(this.value):""}getRawValue(){return this.value}};V.openInstance=null;let st=V;const pe=`
|
|
230
230
|
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
231
231
|
<path d="M5.625 9.5H5.6325M12.375 9.5H12.3825M9 9.5H9.0075M9 12.875H9.0075M9 6.125H9.0075M2.25 6.35L2.25 12.65C2.25 13.9101 2.25 14.5402 2.49524 15.0215C2.71095 15.4448 3.05516 15.789 3.47852 16.0048C3.95982 16.25 4.58988 16.25 5.85 16.25H12.15C13.4101 16.25 14.0402 16.25 14.5215 16.0048C14.9448 15.789 15.289 15.4448 15.5048 15.0215C15.75 14.5402 15.75 13.9101 15.75 12.65V6.35C15.75 5.08988 15.75 4.45982 15.5048 3.97852C15.289 3.55516 14.9448 3.21095 14.5215 2.99524C14.0402 2.75 13.4101 2.75 12.15 2.75L5.85 2.75C4.58988 2.75 3.95982 2.75 3.47852 2.99524C3.05516 3.21095 2.71095 3.55516 2.49524 3.97852C2.25 4.45982 2.25 5.08988 2.25 6.35Z" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
|
|
232
232
|
</svg>
|
|
@@ -234,7 +234,7 @@
|
|
|
234
234
|
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
235
235
|
<path d="M6 2.75H5.85C4.58988 2.75 3.95982 2.75 3.47852 2.99524C3.05516 3.21095 2.71095 3.55516 2.49524 3.97852C2.25 4.45982 2.25 5.08988 2.25 6.35V6.5M6 16.25H5.85C4.58988 16.25 3.95982 16.25 3.47852 16.0048C3.05516 15.789 2.71095 15.4448 2.49524 15.0215C2.25 14.5402 2.25 13.9101 2.25 12.65V12.5M15.75 6.5V6.35C15.75 5.08988 15.75 4.45982 15.5048 3.97852C15.289 3.55516 14.9448 3.21095 14.5215 2.99524C14.0402 2.75 13.4101 2.75 12.15 2.75H12M15.75 12.5V12.65C15.75 13.9101 15.75 14.5402 15.5048 15.0215C15.289 15.4448 14.9448 15.789 14.5215 16.0048C14.0402 16.25 13.4101 16.25 12.15 16.25H12" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
|
|
236
236
|
</svg>
|
|
237
|
-
`;class ue extends N{constructor(t){super({title:"Border",collapsed:t==null?void 0:t.collapsed,settings:{size:new M({title:"Size",icon:de,default:(t==null?void 0:t.size)??0,suffix:"px"}),color:new
|
|
237
|
+
`;class ue extends N{constructor(t){super({title:"Border",collapsed:t==null?void 0:t.collapsed,settings:{size:new M({title:"Size",icon:de,default:(t==null?void 0:t.size)??0,suffix:"px"}),color:new T({default:(t==null?void 0:t.color)??"0, 0, 30"}),radius:new M({title:"Radius",icon:pe,default:(t==null?void 0:t.radius)??12,suffix:"px"})}})}getCssCode(){const t=this.settings.color.value??"#000000",e=this.settings.radius.value??0,i=this.settings.size.value??0;return`
|
|
238
238
|
border-color: ${t};
|
|
239
239
|
border-width: ${i}px;
|
|
240
240
|
border-radius: ${e}px;
|
|
@@ -250,7 +250,7 @@
|
|
|
250
250
|
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
251
251
|
<path d="M6 5.75H12M9 5.75V13.25M5.85 16.25H12.15C13.4101 16.25 14.0402 16.25 14.5215 16.0048C14.9448 15.789 15.289 15.4448 15.5048 15.0215C15.75 14.5402 15.75 13.9101 15.75 12.65V6.35C15.75 5.08988 15.75 4.45982 15.5048 3.97852C15.289 3.55516 14.9448 3.21095 14.5215 2.99524C14.0402 2.75 13.4101 2.75 12.15 2.75H5.85C4.58988 2.75 3.95982 2.75 3.47852 2.99524C3.05516 3.21095 2.71095 3.55516 2.49524 3.97852C2.25 4.45982 2.25 5.08988 2.25 6.35V12.65C2.25 13.9101 2.25 14.5402 2.49524 15.0215C2.71095 15.4448 3.05516 15.789 3.47852 16.0048C3.95982 16.25 4.58988 16.25 5.85 16.25Z" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
|
|
252
252
|
</svg>
|
|
253
|
-
`;class ve extends N{constructor(t={}){const{showAlign:e=t.showAlign??!0,...i}=t;super({title:i.title||"Typography",collapsed:i.collapsed,settings:(()=>{const s={color:new
|
|
253
|
+
`;class ve extends N{constructor(t={}){const{showAlign:e=t.showAlign??!0,...i}=t;super({title:i.title||"Typography",collapsed:i.collapsed,settings:(()=>{const s={color:new T({default:i.colorDefault??"0, 0, 30"}),fontFamily:new Z({title:"Font",icon:ge,default:i.fontFamilyDefault??"Satoshi",options:i.fontFamilyOptions??[{name:"Alt",value:"Croco Sans Black Caps Alt"},{name:"Regular",value:"Croco Sans Caps Regular"},{name:"Caps",value:"Croco Sans Black Caps"},{name:"FaraGo",value:"'FiraGO', sans-serif"}],getOptions:i.fontFamilyGetOptions,getOptionsAsync:i.fontFamilyGetOptionsAsync}),fontWeight:new Z({title:"Weight",icon:me,default:i.fontWeightDefault??"400",options:i.fontWeightOptions??[{name:"Regular",value:"400"},{name:"Medium",value:"500"},{name:"Bold",value:"600"}],getOptions:i.fontWeightGetOptions,getOptionsAsync:i.fontWeightGetOptionsAsync}),fontSize:new M({title:"Size",icon:fe,default:i.fontSizeDefault??12,suffix:"px",mobile:i.fontSizeMobileDefault})};return e?{...s,align:new mt({title:"Align",default:i.alignDefault??"center"})}:s})()})}getCssCode(){var o;const t=this.settings.color.value??"#000000",e=this.settings.fontFamily.value??"Satoshi",i=this.settings.fontWeight.value??"bold",s=this.settings.fontSize.value??12,n=((o=this.settings.align)==null?void 0:o.value)??"left";return`
|
|
254
254
|
color: ${t};
|
|
255
255
|
font-family: ${e};
|
|
256
256
|
font-weight: ${i};
|
|
@@ -269,11 +269,11 @@
|
|
|
269
269
|
<path d="M2.25 2.75H2.2575M2.25 9.5H2.2575M2.25 12.875H2.2575M2.25 6.125H2.2575M5.625 2.75H5.6325M5.625 9.5H5.6325M12.375 2.75H12.3825M12.375 9.5H12.3825M9 2.75H9.0075M9 9.5H9.0075M9 12.875H9.0075M9 6.125H9.0075M15.75 2.75H15.7575M15.75 9.5H15.7575M15.75 12.875H15.7575M15.75 6.125H15.7575M15.75 16.25H2.25" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
|
|
270
270
|
</svg>`,we=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
271
271
|
<path d="M5.625 2.75H5.6325M5.625 9.5H5.6325M5.625 16.25H5.6325M12.375 2.75H12.3825M12.375 9.5H12.3825M12.375 16.25H12.3825M9 2.75H9.0075M9 9.5H9.0075M9 16.25H9.0075M9 12.875H9.0075M9 6.125H9.0075M15.75 2.75H15.7575M15.75 9.5H15.7575M15.75 16.25H15.7575M15.75 12.875H15.7575M15.75 6.125H15.7575M2.25 16.25V2.75" stroke="#667085" stroke-linecap="round" stroke-linejoin="round"/>
|
|
272
|
-
</svg>`;class xe extends N{constructor(t){super({title:"Background Image",collapsed:t==null?void 0:t.collapsed,settings:{backgroundImage:new ot({...t==null?void 0:t.uploadProps,default:(t==null?void 0:t.backgroundImage)??""}),opacity:new gt({default:(t==null?void 0:t.opacity)??100}),backgroundColor:new
|
|
272
|
+
</svg>`;class xe extends N{constructor(t){super({title:"Background Image",collapsed:t==null?void 0:t.collapsed,settings:{backgroundImage:new ot({...t==null?void 0:t.uploadProps,default:(t==null?void 0:t.backgroundImage)??""}),opacity:new gt({default:(t==null?void 0:t.opacity)??100}),backgroundColor:new T({default:(t==null?void 0:t.backgroundColor)??"0, 0, 30"})}})}draw(){const t=super.draw(),e=t.querySelector(".setting-group-content");if(!e)return t;const i=Array.from(e.children),[s,n,o]=i;e.innerHTML="",e.appendChild(s),e.appendChild(n);const a=document.createElement("div");return a.className="bgset-or-label",a.textContent="OR",e.appendChild(a),e.appendChild(o),t}getCssCode(){const t=this.settings.backgroundImage.value||"",e=this.settings.opacity.value??100,i=this.settings.backgroundColor.value||"#000000";return t?`
|
|
273
273
|
background-image: url("${t}");
|
|
274
274
|
background-size: cover;
|
|
275
275
|
background-position: center;
|
|
276
276
|
opacity: ${e/100};
|
|
277
277
|
`:`
|
|
278
278
|
background-color: ${i};
|
|
279
|
-
`}}exports.AlignSetting=mt;exports.AnimationSetting=Qt;exports.BackgroundSettingSet=xe;exports.BorderSettingSet=ue;exports.ButtonSetting=
|
|
279
|
+
`}}exports.AlignSetting=mt;exports.AnimationSetting=Qt;exports.BackgroundSettingSet=xe;exports.BorderSettingSet=ue;exports.ButtonSetting=Tt;exports.ColorSetting=k;exports.ColorWithOpacitySetting=T;exports.DimensionSetting=Ht;exports.GapSetting=_t;exports.GradientSetting=st;exports.HeaderTypographySettingSet=ve;exports.HeightSetting=Rt;exports.HtmlSetting=Nt;exports.MarginBottomSetting=Zt;exports.MarginSettingGroup=Ce;exports.MarginTopSetting=Yt;exports.MultiLanguageSetting=Kt;exports.NumberSetting=M;exports.OpacitySetting=gt;exports.SelectApiSettings=Ut;exports.SelectSetting=Z;exports.Setting=y;exports.SettingGroup=N;exports.StringSetting=ut;exports.TabSettingGroup=nt;exports.TabsSettingGroup=nt;exports.Toggle=qt;exports.UploadSetting=ot;exports.WidthSetting=Gt;exports.asSettingGroupWithSettings=Mt;exports.createSettingGroup=dt;exports.createTabSettingGroup=kt;exports.isSetting=A;exports.isSettingChild=it;exports.isSettingGroup=x;exports.iterateSettings=z;
|
|
@@ -242,7 +242,7 @@ function L(c) {
|
|
|
242
242
|
function nt(c) {
|
|
243
243
|
return D(c) || L(c);
|
|
244
244
|
}
|
|
245
|
-
function
|
|
245
|
+
function q(c, t) {
|
|
246
246
|
for (const e in c)
|
|
247
247
|
if (Object.prototype.hasOwnProperty.call(c, e)) {
|
|
248
248
|
const i = c[e];
|
|
@@ -256,7 +256,7 @@ const X = class X {
|
|
|
256
256
|
}
|
|
257
257
|
propagateNestingLevel() {
|
|
258
258
|
const t = this.nestingLevel + 1;
|
|
259
|
-
|
|
259
|
+
q(this.settings, (e, i) => {
|
|
260
260
|
L(i) && (i.nestingLevel = t, i.propagateNestingLevel());
|
|
261
261
|
});
|
|
262
262
|
}
|
|
@@ -273,7 +273,7 @@ const X = class X {
|
|
|
273
273
|
this.dataPropsPath = t, this.propagateDataPropsPath();
|
|
274
274
|
}
|
|
275
275
|
propagateDataPropsPath() {
|
|
276
|
-
|
|
276
|
+
q(this.settings, (t, e) => {
|
|
277
277
|
const i = String(t), s = this.dataPropsPath ? `${this.dataPropsPath}_${i}` : i;
|
|
278
278
|
(L(e) || D(e) && typeof e.setDataPropsPath == "function") && e.setDataPropsPath(s);
|
|
279
279
|
});
|
|
@@ -328,7 +328,7 @@ const X = class X {
|
|
|
328
328
|
}
|
|
329
329
|
clone() {
|
|
330
330
|
const t = {};
|
|
331
|
-
|
|
331
|
+
q(this.settings, (s, n) => {
|
|
332
332
|
const o = String(s);
|
|
333
333
|
typeof n.clone == "function" ? t[o] = n.clone() : (console.warn(
|
|
334
334
|
`Setting with key '${o}' does not have a clone method. Copying reference.`
|
|
@@ -391,7 +391,7 @@ const X = class X {
|
|
|
391
391
|
Object.keys(s).length > 0 && (this.lastChangeTime = Date.now(), this.initialValues = i, t(i), this.updateVisibility()), this.isHandlingChange = !1;
|
|
392
392
|
}, 50));
|
|
393
393
|
};
|
|
394
|
-
return this.changeHandlers.clear(),
|
|
394
|
+
return this.changeHandlers.clear(), q(this.settings, (i, s) => {
|
|
395
395
|
var n;
|
|
396
396
|
if (L(s))
|
|
397
397
|
s.setOnChange(() => {
|
|
@@ -1001,14 +1001,14 @@ const Lt = `
|
|
|
1001
1001
|
<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="0.5" stroke-linecap="round" stroke-linejoin="round" opacity="0.5"/>
|
|
1002
1002
|
<path d="M9 1V17C4.58172 17 1 13.4183 1 9C1 4.58172 4.58172 1 9 1Z" fill="#667085" stroke="#667085" stroke-width="0.5" stroke-linecap="round" stroke-linejoin="round" opacity="0.5"/>
|
|
1003
1003
|
</svg>`;
|
|
1004
|
-
class
|
|
1004
|
+
class H extends b {
|
|
1005
1005
|
constructor(t = {}) {
|
|
1006
1006
|
super({
|
|
1007
1007
|
...t,
|
|
1008
1008
|
icon: t.icon || Lt,
|
|
1009
1009
|
title: t.title || "Color & Opacity",
|
|
1010
1010
|
default: t.default || "#000000FF"
|
|
1011
|
-
}), this.inputType = "color", this.element = null, this.colorInputEl = null, this.textInputEl = null, this.opacityInputEl = null, this.colorPreviewEl = null, this.detectChange = t.detectChange, this.value && (this.value =
|
|
1011
|
+
}), this.inputType = "color", this.element = null, this.colorInputEl = null, this.textInputEl = null, this.opacityInputEl = null, this.colorPreviewEl = null, this.detectChange = t.detectChange, this.value && (this.value = H.normalizeHexWithOpacity(this.value));
|
|
1012
1012
|
}
|
|
1013
1013
|
static normalizeHexWithOpacity(t) {
|
|
1014
1014
|
return t = t.replace("#", ""), t.length === 3 && (t = t.split("").map((e) => e + e).join("")), t.length === 6 && (t = t + "FF"), t.length === 8 && /^[0-9A-Fa-f]{8}$/.test(t) ? `#${t.toUpperCase()}` : (console.warn(`Invalid hex value "${t}", using default "#000000FF"`), "#000000FF");
|
|
@@ -1026,7 +1026,7 @@ class T extends b {
|
|
|
1026
1026
|
return `#${i}${n}`;
|
|
1027
1027
|
}
|
|
1028
1028
|
setValue(t) {
|
|
1029
|
-
t === void 0 || t === "" ? this.value = "#000000FF" : this.value =
|
|
1029
|
+
t === void 0 || t === "" ? this.value = "#000000FF" : this.value = H.normalizeHexWithOpacity(t), this.updateInputElements(), this.updateColorPreview(), this.onChange && this.onChange(this.value), this.detectChange && this.detectChange(this.value);
|
|
1030
1030
|
}
|
|
1031
1031
|
updateInputElements() {
|
|
1032
1032
|
this.value && (this.colorInputEl && (this.colorInputEl.value = this.getRgbColor()), this.textInputEl && (this.textInputEl.value = this.value), this.opacityInputEl && (this.opacityInputEl.value = this.getOpacityPercent().toString()));
|
|
@@ -1037,7 +1037,7 @@ class T extends b {
|
|
|
1037
1037
|
this.colorPreviewEl.style.backgroundColor = `rgba(${s}, ${n}, ${o}, ${e})`;
|
|
1038
1038
|
}
|
|
1039
1039
|
handleColorChange(t) {
|
|
1040
|
-
const e = this.getOpacityPercent(), i =
|
|
1040
|
+
const e = this.getOpacityPercent(), i = H.combineColorOpacity(
|
|
1041
1041
|
t,
|
|
1042
1042
|
e
|
|
1043
1043
|
);
|
|
@@ -1048,7 +1048,7 @@ class T extends b {
|
|
|
1048
1048
|
return e || i ? (this.setValue(t), !0) : !1;
|
|
1049
1049
|
}
|
|
1050
1050
|
handleOpacityChange(t) {
|
|
1051
|
-
const e = this.getRgbColor(), i = Math.max(0, Math.min(100, t)), s =
|
|
1051
|
+
const e = this.getRgbColor(), i = Math.max(0, Math.min(100, t)), s = H.combineColorOpacity(
|
|
1052
1052
|
e,
|
|
1053
1053
|
i
|
|
1054
1054
|
);
|
|
@@ -1570,7 +1570,7 @@ const Nt = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewB
|
|
|
1570
1570
|
<rect width="91" height="71" rx="4" fill="#F2F4F7"/>
|
|
1571
1571
|
<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"/>
|
|
1572
1572
|
</svg>
|
|
1573
|
-
`,
|
|
1573
|
+
`, Tt = `
|
|
1574
1574
|
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 12 12" fill="none">
|
|
1575
1575
|
<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"/>
|
|
1576
1576
|
</svg>
|
|
@@ -1693,7 +1693,7 @@ class ht extends b {
|
|
|
1693
1693
|
const n = document.createElement("div");
|
|
1694
1694
|
if (n.className = "preview-placeholder", n.innerHTML = Ot, this.previewWrapper = document.createElement("div"), this.previewWrapper.className = "preview-wrapper", this.loadingSpinner = document.createElement("div"), this.loadingSpinner.className = "loading-spinner", this.loadingSpinner.innerHTML = Pt, this.loadingSpinner.style.display = "none", this.previewWrapper.appendChild(this.loadingSpinner), this.previewEl = document.createElement("img"), this.previewEl.className = "upload-preview", this.props.delete) {
|
|
1695
1695
|
const a = document.createElement("button");
|
|
1696
|
-
a.className = "delete-button", a.type = "button", a.title = "Delete image", a.innerHTML =
|
|
1696
|
+
a.className = "delete-button", a.type = "button", a.title = "Delete image", a.innerHTML = Tt, this.previewWrapper.appendChild(a), a.onclick = (l) => {
|
|
1697
1697
|
var r;
|
|
1698
1698
|
l.stopPropagation(), this.value = "", this.updatePreviewState(null), (r = this.onChange) == null || r.call(this, ""), this.hideError();
|
|
1699
1699
|
};
|
|
@@ -1721,7 +1721,7 @@ class pe extends I {
|
|
|
1721
1721
|
title: t.title || "Height",
|
|
1722
1722
|
suffix: t.suffix || "px",
|
|
1723
1723
|
minValue: t.minValue ?? 0,
|
|
1724
|
-
icon: t.icon ||
|
|
1724
|
+
icon: t.icon || Ht,
|
|
1725
1725
|
default: t.default ?? 100
|
|
1726
1726
|
}), this.inputType = "number", this.mobileValue = t.mobile;
|
|
1727
1727
|
}
|
|
@@ -1732,7 +1732,7 @@ class pe extends I {
|
|
|
1732
1732
|
this.mobileValue = t, t !== void 0 && this.setValue(t);
|
|
1733
1733
|
}
|
|
1734
1734
|
}
|
|
1735
|
-
const
|
|
1735
|
+
const Ht = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
1736
1736
|
<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"/>
|
|
1737
1737
|
</svg>`;
|
|
1738
1738
|
class de extends I {
|
|
@@ -2382,7 +2382,7 @@ const Ft = (c, t) => {
|
|
|
2382
2382
|
};
|
|
2383
2383
|
}
|
|
2384
2384
|
return { color: F(t) || t, position: 0, opacity: 100 };
|
|
2385
|
-
},
|
|
2385
|
+
}, U = class U {
|
|
2386
2386
|
static defaults() {
|
|
2387
2387
|
return { solid: [], gradient: [] };
|
|
2388
2388
|
}
|
|
@@ -2425,9 +2425,9 @@ const Ft = (c, t) => {
|
|
|
2425
2425
|
n !== -1 && s.splice(n, 1), s.unshift(i), s.length > this.MAX_COLORS && (s.length = this.MAX_COLORS), this.persist();
|
|
2426
2426
|
}
|
|
2427
2427
|
};
|
|
2428
|
-
|
|
2429
|
-
let V =
|
|
2430
|
-
const
|
|
2428
|
+
U.STORAGE_KEY = "settingsLib_recentColors", U.MAX_COLORS = 12, U.colors = null;
|
|
2429
|
+
let V = U;
|
|
2430
|
+
const Ut = (c, t) => {
|
|
2431
2431
|
const e = document.createElement("div");
|
|
2432
2432
|
e.className = "color-picker-recent-section";
|
|
2433
2433
|
const i = document.createElement("div");
|
|
@@ -2453,7 +2453,7 @@ const qt = (c, t) => {
|
|
|
2453
2453
|
<path fill-rule="evenodd" clip-rule="evenodd"
|
|
2454
2454
|
d="M6.12347 4.96653L1.41158 0.254304C1.25449 0.102568 1.04409 0.0186071 0.825694 0.0205049C0.607302 0.0224037 0.398393 0.110007 0.24396 0.26445C0.0895282 0.418893 0.0019303 0.627818 3.24698e-05 0.846225C-0.00186536 1.06463 0.0820894 1.27505 0.233815 1.43215L4.9457 6.14438L0.233814 10.8566C0.0820886 11.0137 -0.00186625 11.2241 3.15434e-05 11.4425C0.00192934 11.6609 0.0895272 11.8699 0.243959 12.0243C0.398392 12.1787 0.607301 12.2663 0.825693 12.2682C1.04408 12.2701 1.25449 12.1862 1.41158 12.0344L6.12347 7.32222L10.8354 12.0344C10.9932 12.1824 11.2023 12.2632 11.4186 12.2597C11.6349 12.2562 11.8414 12.1687 11.9943 12.0156C12.1472 11.8626 12.2346 11.6561 12.2379 11.4398C12.2413 11.2234 12.1604 11.0143 12.0123 10.8566L7.30123 6.14438L12.0131 1.43215C12.0927 1.35531 12.1561 1.2634 12.1998 1.16177C12.2434 1.06014 12.2664 0.950833 12.2674 0.84023C12.2683 0.729626 12.2473 0.61994 12.2054 0.517568C12.1635 0.415196 12.1017 0.322191 12.0234 0.243979C11.9452 0.165768 11.8522 0.103916 11.7499 0.0620327C11.6475 0.0201492 11.5378 -0.000927989 11.4272 3.33052e-05C11.3166 0.000993646 11.2073 0.0239743 11.1057 0.0676297C11.0041 0.111286 10.9122 0.174745 10.8354 0.254305L6.12347 4.96653Z"
|
|
2455
2455
|
fill="#919EAB"/>
|
|
2456
|
-
</svg>`,
|
|
2456
|
+
</svg>`, qt = `<svg width="23" height="23" viewBox="0 0 23 23" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2457
2457
|
<path fill-rule="evenodd" clip-rule="evenodd"
|
|
2458
2458
|
d="M19.1972 3.29156C18.936 3.03034 18.6259 2.82313 18.2847 2.68176C17.9434 2.54039 17.5777 2.46763 17.2083 2.46763C16.8389 2.46763 16.4731 2.54039 16.1319 2.68176C15.7906 2.82313 15.4805 3.03034 15.2194 3.29156L13.7822 4.72875C13.2585 4.4772 12.6697 4.39449 12.097 4.49207C11.5243 4.58964 10.9961 4.86267 10.5853 5.27343L9.91687 5.94281C9.74268 6.11693 9.6045 6.32366 9.51023 6.5512C9.41595 6.77873 9.36743 7.02261 9.36743 7.2689C9.36743 7.5152 9.41595 7.75907 9.51023 7.98661C9.6045 8.21414 9.74268 8.42088 9.91687 8.595L3.83625 14.6747C3.57512 14.936 3.36803 15.2462 3.2268 15.5875C3.08556 15.9288 3.01296 16.2947 3.01312 16.6641V18.3516C3.01312 18.6499 3.13165 18.9361 3.34263 19.1471C3.55361 19.358 3.83975 19.4766 4.13812 19.4766H5.82562C6.57129 19.4759 7.28618 19.1792 7.81312 18.6516L13.8937 12.5728C14.0679 12.747 14.2746 12.8852 14.5021 12.9795C14.7297 13.0737 14.9735 13.1223 15.2198 13.1223C15.4661 13.1223 15.71 13.0737 15.9375 12.9795C16.1651 12.8852 16.3718 12.747 16.5459 12.5728L17.2153 11.9025C17.6261 11.4917 17.8991 10.9635 17.9967 10.3908C18.0942 9.81811 18.0115 9.22926 17.76 8.70562L19.1972 7.26937C19.4584 7.0082 19.6656 6.69813 19.807 6.35687C19.9484 6.01561 20.0211 5.64985 20.0211 5.28047C20.0211 4.91108 19.9484 4.54532 19.807 4.20406C19.6656 3.8628 19.4584 3.55273 19.1972 3.29156Z"
|
|
2459
2459
|
fill="#353C47"/>
|
|
@@ -2504,7 +2504,7 @@ class Jt {
|
|
|
2504
2504
|
const a = document.createElement("div");
|
|
2505
2505
|
a.className = "color-picker-hue-container";
|
|
2506
2506
|
const l = document.createElement("button");
|
|
2507
|
-
l.className = "color-picker-eyedropper", l.type = "button", l.innerHTML =
|
|
2507
|
+
l.className = "color-picker-eyedropper", l.type = "button", l.innerHTML = qt;
|
|
2508
2508
|
const r = document.createElement("div");
|
|
2509
2509
|
r.className = "color-picker-hue", this.hueSlider = r;
|
|
2510
2510
|
const h = document.createElement("div");
|
|
@@ -2513,7 +2513,7 @@ class Jt {
|
|
|
2513
2513
|
p.className = "color-picker-opacity", this.opacitySlider = p;
|
|
2514
2514
|
const d = document.createElement("div");
|
|
2515
2515
|
d.className = "color-picker-opacity-marker", this.opacityMarker = d, p.appendChild(d);
|
|
2516
|
-
const g =
|
|
2516
|
+
const g = Ut(($) => {
|
|
2517
2517
|
var G, W;
|
|
2518
2518
|
this.setColor($), (G = this.onChange) == null || G.call(this, $, this.currentOpacity), V.addColor($, this.recentScope), (W = this.recentSectionRefresh) == null || W.call(this);
|
|
2519
2519
|
}, this.recentScope);
|
|
@@ -2530,10 +2530,10 @@ class Jt {
|
|
|
2530
2530
|
x.value = "hsl", x.textContent = "HSL", m.appendChild(f), m.appendChild(C), m.appendChild(x);
|
|
2531
2531
|
const y = document.createElement("input");
|
|
2532
2532
|
y.type = "text", y.className = "color-picker-color-input", y.value = this.currentColor, this.input = y;
|
|
2533
|
-
const
|
|
2534
|
-
|
|
2533
|
+
const T = document.createElement("div");
|
|
2534
|
+
T.className = "color-picker-input-container";
|
|
2535
2535
|
const k = document.createElement("button");
|
|
2536
|
-
return k.className = "color-picker-copy-inside", k.textContent = "Copy",
|
|
2536
|
+
return k.className = "color-picker-copy-inside", k.textContent = "Copy", T.appendChild(y), T.appendChild(k), u.appendChild(m), u.appendChild(T), t.appendChild(e), t.appendChild(n), t.appendChild(a), t.appendChild(p), t.appendChild(g.container), t.appendChild(u), t.addEventListener("click", ($) => $.stopPropagation()), this.bind(n, r, p, y, m, k, l), t;
|
|
2537
2537
|
}
|
|
2538
2538
|
createBackdrop() {
|
|
2539
2539
|
const t = document.createElement("div");
|
|
@@ -3033,7 +3033,7 @@ const ot = (c) => {
|
|
|
3033
3033
|
type: "text",
|
|
3034
3034
|
angle: "number",
|
|
3035
3035
|
stops: "text"
|
|
3036
|
-
}, this.element = null, this.previewEl = null, this.inputEl = void 0, this.popoverEl = null, this.isPopoverOpen = !1, this.isEditing = !1, this.onBackgroundClick = (i) => {
|
|
3036
|
+
}, this.element = null, this.previewEl = null, this.inputEl = void 0, this.popoverEl = null, this.isPopoverOpen = !1, this.isEditing = !1, this.previewUpdateTimeout = null, this.onBackgroundClick = (i) => {
|
|
3037
3037
|
var p;
|
|
3038
3038
|
if (!this.popoverEl || !this.isPopoverOpen) return;
|
|
3039
3039
|
const s = i.target, n = this.popoverEl.contains(s), o = (p = this.element) == null ? void 0 : p.contains(s), a = document.querySelectorAll(".custom-color-picker"), l = Array.from(a).some((d) => d.contains(s)), r = s.closest(
|
|
@@ -3180,9 +3180,10 @@ const ot = (c) => {
|
|
|
3180
3180
|
m.value = m.value.replace(/[^0-9-]/g, ""), setTimeout(() => m.select(), 0);
|
|
3181
3181
|
}), o.addEventListener("input", (u) => {
|
|
3182
3182
|
const m = parseInt(u.target.value);
|
|
3183
|
-
!Number.isNaN(m) && this.value && (this.value.angle = Math.max(0, Math.min(360, m)), this.
|
|
3183
|
+
!Number.isNaN(m) && this.value && (this.value.angle = Math.max(0, Math.min(360, m)), this.debouncedPreviewUpdate());
|
|
3184
3184
|
}), o.addEventListener("blur", (u) => {
|
|
3185
3185
|
var C;
|
|
3186
|
+
this.previewUpdateTimeout && (clearTimeout(this.previewUpdateTimeout), this.previewUpdateTimeout = null);
|
|
3186
3187
|
const m = u.target;
|
|
3187
3188
|
let f = parseInt(m.value);
|
|
3188
3189
|
Number.isNaN(f) && (f = ((C = this.value) == null ? void 0 : C.angle) ?? 0), f = Math.max(0, Math.min(360, f)), this.value && (this.value.angle = f), m.value = `${f}°`, this.updateGradientPreview(), this.updateUI(), this.triggerChange();
|
|
@@ -3216,6 +3217,11 @@ const ot = (c) => {
|
|
|
3216
3217
|
const e = t || ((i = this.popoverEl) == null ? void 0 : i.querySelector(".gradient-preview"));
|
|
3217
3218
|
e && this.value && (e.style.background = P(this.value));
|
|
3218
3219
|
}
|
|
3220
|
+
debouncedPreviewUpdate(t) {
|
|
3221
|
+
this.previewUpdateTimeout && clearTimeout(this.previewUpdateTimeout), this.previewUpdateTimeout = window.setTimeout(() => {
|
|
3222
|
+
this.updateGradientPreview(t), this.previewUpdateTimeout = null;
|
|
3223
|
+
}, 16);
|
|
3224
|
+
}
|
|
3219
3225
|
createHandles(t, e) {
|
|
3220
3226
|
t.innerHTML = "", !(!this.value || this.value.type === "solid" || !this.value.stops) && this.value.stops.forEach((i, s) => {
|
|
3221
3227
|
const n = document.createElement("div");
|
|
@@ -3275,10 +3281,10 @@ const ot = (c) => {
|
|
|
3275
3281
|
x.className = "gstop-opacity-group";
|
|
3276
3282
|
const y = document.createElement("input");
|
|
3277
3283
|
y.type = "range", y.className = "gstop-opacity-slider", y.min = "0", y.max = "100", y.value = String(n.opacity ?? 100);
|
|
3278
|
-
const
|
|
3284
|
+
const T = S(n.color);
|
|
3279
3285
|
y.style.setProperty(
|
|
3280
3286
|
"--slider-color",
|
|
3281
|
-
`rgb(${
|
|
3287
|
+
`rgb(${T.r}, ${T.g}, ${T.b})`
|
|
3282
3288
|
);
|
|
3283
3289
|
const k = document.createElement("span");
|
|
3284
3290
|
k.className = "gstop-opacity-value", k.textContent = `${n.opacity ?? 100}%`, x.appendChild(y), x.appendChild(k);
|
|
@@ -3398,7 +3404,7 @@ const ot = (c) => {
|
|
|
3398
3404
|
s && this.updatePopoverContent(s);
|
|
3399
3405
|
}
|
|
3400
3406
|
closePopover() {
|
|
3401
|
-
!this.popoverEl || !this.isPopoverOpen || (this.isPopoverOpen = !1, this.popoverEl.style.display = "none", document.removeEventListener("click", this.onBackgroundClick, !0), N.openInstance === this && (N.openInstance = null));
|
|
3407
|
+
!this.popoverEl || !this.isPopoverOpen || (this.isPopoverOpen = !1, this.popoverEl.style.display = "none", document.removeEventListener("click", this.onBackgroundClick, !0), this.previewUpdateTimeout && (clearTimeout(this.previewUpdateTimeout), this.previewUpdateTimeout = null), N.openInstance === this && (N.openInstance = null));
|
|
3402
3408
|
}
|
|
3403
3409
|
handlePaste(t) {
|
|
3404
3410
|
var i;
|
|
@@ -3454,7 +3460,7 @@ class Ee extends O {
|
|
|
3454
3460
|
default: (t == null ? void 0 : t.size) ?? 0,
|
|
3455
3461
|
suffix: "px"
|
|
3456
3462
|
}),
|
|
3457
|
-
color: new
|
|
3463
|
+
color: new H({
|
|
3458
3464
|
default: (t == null ? void 0 : t.color) ?? "0, 0, 30"
|
|
3459
3465
|
}),
|
|
3460
3466
|
radius: new I({
|
|
@@ -3499,7 +3505,7 @@ class be extends O {
|
|
|
3499
3505
|
collapsed: i.collapsed,
|
|
3500
3506
|
settings: (() => {
|
|
3501
3507
|
const s = {
|
|
3502
|
-
color: new
|
|
3508
|
+
color: new H({
|
|
3503
3509
|
default: i.colorDefault ?? "0, 0, 30"
|
|
3504
3510
|
}),
|
|
3505
3511
|
fontFamily: new et({
|
|
@@ -3668,7 +3674,7 @@ class xe extends O {
|
|
|
3668
3674
|
opacity: new Mt({
|
|
3669
3675
|
default: (t == null ? void 0 : t.opacity) ?? 100
|
|
3670
3676
|
}),
|
|
3671
|
-
backgroundColor: new
|
|
3677
|
+
backgroundColor: new H({
|
|
3672
3678
|
default: (t == null ? void 0 : t.backgroundColor) ?? "0, 0, 30"
|
|
3673
3679
|
})
|
|
3674
3680
|
}
|
|
@@ -3701,7 +3707,7 @@ export {
|
|
|
3701
3707
|
Ee as BorderSettingSet,
|
|
3702
3708
|
ce as ButtonSetting,
|
|
3703
3709
|
M as ColorSetting,
|
|
3704
|
-
|
|
3710
|
+
H as ColorWithOpacitySetting,
|
|
3705
3711
|
he as DimensionSetting,
|
|
3706
3712
|
me as GapSetting,
|
|
3707
3713
|
rt as GradientSetting,
|
|
@@ -3730,5 +3736,5 @@ export {
|
|
|
3730
3736
|
D as isSetting,
|
|
3731
3737
|
nt as isSettingChild,
|
|
3732
3738
|
L as isSettingGroup,
|
|
3733
|
-
|
|
3739
|
+
q as iterateSettings
|
|
3734
3740
|
};
|
|
@@ -15,6 +15,7 @@ export declare class GradientSetting extends Setting<GradientValue, SettingProps
|
|
|
15
15
|
private isEditing;
|
|
16
16
|
private forText;
|
|
17
17
|
detectChange?: (value: GradientValue | undefined) => void;
|
|
18
|
+
private previewUpdateTimeout;
|
|
18
19
|
constructor(props?: GradientSettingProps);
|
|
19
20
|
private originalDefault;
|
|
20
21
|
private defaultValue;
|
|
@@ -30,6 +31,7 @@ export declare class GradientSetting extends Setting<GradientValue, SettingProps
|
|
|
30
31
|
private renderGradient;
|
|
31
32
|
private updateDegreeVisibility;
|
|
32
33
|
private updateGradientPreview;
|
|
34
|
+
private debouncedPreviewUpdate;
|
|
33
35
|
private createHandles;
|
|
34
36
|
private updateStopsList;
|
|
35
37
|
private addStop;
|
package/package.json
CHANGED