builder-settings-types 0.0.282 → 0.0.284
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.
|
@@ -224,7 +224,7 @@
|
|
|
224
224
|
<button class="color-picker-copy-inside">Copy</button>
|
|
225
225
|
</div>
|
|
226
226
|
</div>
|
|
227
|
-
`;const e=at(i=>{this.applyRecentColor(i)},this.recentScope);return this.recentSectionRefresh=e.refresh,t.appendChild(e.container),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}=A(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}=A(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}}applyRecentColor(t){if(this.currentColor=t,!(t.includes("gradient")||t.includes("radial"))){this.updatePickerVisualState();const i=this.container.querySelector(".color-picker-format-select"),s=this.container.querySelector(".color-picker-color-input");this.updateColorInput(i,s)}this.triggerChange()}commitRecentColor(){var t;D.addColor(this.currentColor,this.recentScope),(t=this.recentSectionRefresh)==null||t.call(this)}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"),u=this.container.querySelector(".color-picker-opacity");this.updateColorInput(p,d),this.updateOpacityBackground(u),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,u=parseFloat(s.style.left||"50%")/100,g=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,u,1-g);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 G(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 F(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=Y(i,s,n);return F(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}=A(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}=A(t),u=h>=360?h%360:h;n.style.left=`${u/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(${u}, 100%, 50%))`,o.style.left=`${e}%`,this.updateOpacityBackground(a),this.updateColorInput(l,r)}}const T=class T extends b{constructor(t={}){const e=typeof t.default=="string"?void 0:t.default;super({...t,title:t.title||"Color",default:e}),this.inputType={type:"text",angle:"number",stops:"text"},this.element=null,this.previewEl=null,this.inputEl=void 0,this.popoverEl=null,this.backdropEl=null,this.isPopoverOpen=!1,this.isEditing=!1,this.previewUpdateTimeout=null,this.solidPicker=null,this.pendingSolidColor=null,this.onBackgroundClick=i=>{var d;if(!this.popoverEl||!this.isPopoverOpen)return;const s=i.target,n=this.popoverEl.contains(s),o=(d=this.element)==null?void 0:d.contains(s),a=document.querySelectorAll(".custom-color-picker"),l=Array.from(a).some(u=>u.contains(s)),r=s.closest(".gstop-color-input, .gradient-mini-preview, .gstop-color-preview"),h=s.classList.contains("color-picker-backdrop"),p=s.classList.contains("gradient-popover-backdrop");!n&&!o&&!l&&!r&&!h&&!p&&this.closePopover()},this.handlePopoverKeydown=i=>{if(this.isPopoverOpen){if(i.key==="Escape"){i.preventDefault(),this.closePopover();return}if(i.key==="Enter"){const s=i.target;if(s&&(s.tagName==="INPUT"||s.tagName==="TEXTAREA"))return;i.preventDefault(),this.closePopover()}}},this.detectChange=t.detectChange,this.originalDefault=t.default,this.value=this.defaultValue()}defaultValue(){const t=this.originalDefault;if(typeof t=="string"){const i=H(t);if(i)return B(i)}return B(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=H(t):t&&typeof t=="object"&&(e=B(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),this.pendingSolidColor=null}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=Ct(t.color,e)}else this.previewEl.style.background=V(this.value);this.inputEl&&this.value&&!this.isEditing&&(this.inputEl.value=et(this.value))}cssForTextValue(){return this.value?{background:V(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?V(this.value):"linear-gradient(90deg, #a84b4b 0%, #786666 100%)",this.previewEl.addEventListener("click",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?et(this.value):"",this.inputEl.readOnly=!1,this.inputEl.addEventListener("focus",()=>{if(this.isEditing=!0,this.value)if(this.value.type==="solid"){const i=this.value.stops[0];if(i){const s=i.color.toUpperCase(),n=i.opacity??100;if(n===100)this.inputEl.value=s;else{const a=Math.round(n/100*255).toString(16).toUpperCase().padStart(2,"0");this.inputEl.value=`${s}${a}`}}}else this.inputEl.value=V(this.value)}),this.inputEl.addEventListener("blur",()=>{this.isEditing=!1,this.value&&(this.inputEl.value=et(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=V(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.backdropEl=document.createElement("div"),this.backdropEl.className="gradient-popover-backdrop",this.backdropEl.style.display="none",this.backdropEl.addEventListener("click",a=>{a.preventDefault(),a.stopPropagation(),this.closePopover()}),this.popoverEl=document.createElement("div"),this.popoverEl.className="gradient-popover",this.popoverEl.style.display="none",this.popoverEl.addEventListener("click",a=>{a.stopPropagation()});const t=document.createElement("div");t.className="gradient-popover-header",t.style.cursor="move";const e=document.createElement("span");e.textContent="Fill";const i=document.createElement("button");i.type="button",i.className="gradient-popover-close",i.innerHTML=bt,i.addEventListener("click",()=>this.closePopover()),t.appendChild(e),t.appendChild(i),vt(t,this.popoverEl);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.backdropEl),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}]),t!=="solid"&&this.value.stops.length<2&&(this.value.angle=90),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 pe({initialColor:e.color,initialOpacity:e.opacity??100,onColorChange:(s,n)=>{if(this.value){const o=H(s);if(o&&o.type!=="solid"){this.value=o,this.switchType(o.type);return}this.value.stops[0].color=s,this.value.stops[0].opacity=n,this.updateUI(),this.triggerChange(),this.pendingSolidColor=s}}});this.solidPicker=i,t.appendChild(i.getElement())}renderGradient(t){this.solidPicker=null;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??90}°`,o.style.width="75px",o.style.textAlign="center",(!this.value.angle||this.value.stops.length<2)&&(this.value.angle=90,o.value="90°");const a=document.createElement("button");a.type="button",a.className="gradient-flip-btn",a.innerHTML=re,i.addEventListener("change",()=>{this.switchType(i.value==="radial"?"radial":"linear"),this.updateDegreeVisibility(o)}),o.addEventListener("focus",m=>{const f=m.target;f.value=f.value.replace(/[^0-9-]/g,""),setTimeout(()=>f.select(),0)}),o.addEventListener("input",m=>{const f=parseInt(m.target.value);!Number.isNaN(f)&&this.value&&(this.value.angle=Math.max(0,Math.min(360,f)),this.debouncedPreviewUpdate())}),o.addEventListener("blur",m=>{var y;this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null);const f=m.target;let C=parseInt(f.value);Number.isNaN(C)&&(C=((y=this.value)==null?void 0:y.angle)??0),C=Math.max(0,Math.min(360,C)),this.value&&(this.value.angle=C),f.value=`${C}°`,this.updateGradientPreview(),this.updateUI(),this.triggerChange()}),a.addEventListener("click",()=>{!this.value||!this.value.stops||(this.value.stops.forEach(m=>{m.position=100-m.position}),this.value.stops.sort((m,f)=>m.position-f.position),this.updateGradientPreview(l),this.createHandles(r,l),this.updateStopsList(u),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 u=document.createElement("div");u.className="gradient-stops",t.appendChild(h),t.appendChild(u),this.updateStopsList(u);const g=at(m=>{const f=H(m);f&&(this.value=f,this.switchType(f.type),this.updateUI(),this.triggerChange())},"all");this.recentGradientRefresh=g.refresh,t.appendChild(g.container),d.addEventListener("click",()=>{var m;this.addStop(),this.updateStopsList(u),this.updateGradientPreview(l),this.createHandles(r,l),this.updateUI(),((m=document.activeElement)==null?void 0:m.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=V(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=u=>{a=!0,l=u.clientX,r=this.value.stops[s].position,n.classList.add("selected"),document.addEventListener("mousemove",p),document.addEventListener("mouseup",d),u.preventDefault(),u.stopPropagation()},p=u=>{if(!a||!this.value)return;const g=e.getBoundingClientRect(),m=u.clientX-l;let f=r+m/g.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((u,g)=>u.position-g.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 U,lt;const a=this.value.stops.findIndex((v,w)=>v.position===n.position&&v.color===n.color&&v.opacity===n.opacity&&this.value.stops.slice(0,w).filter(x=>x.position===n.position&&x.color===n.color&&x.opacity===n.opacity).length===i.slice(0,o).filter(x=>x.position===n.position&&x.color===n.color&&x.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 u=document.createElement("div");u.className="gstop-color-preview",u.style.backgroundColor=n.color;const g=document.createElement("input");g.type="text",g.className="gstop-color-input",g.value=n.color.replace("#","").toUpperCase();const m=document.createElement("button");m.type="button",m.className="gstop-color-copy",m.textContent="Copy",d.appendChild(u),d.appendChild(g),d.appendChild(m);const f=document.createElement("button");f.type="button",f.className="gstop-del",f.innerHTML=ce,f.disabled=(((lt=(U=this.value)==null?void 0:U.stops)==null?void 0:lt.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 y=document.createElement("div");y.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 M=document.createElement("span");M.className="gstop-opacity-value",M.textContent=`${n.opacity??100}%`,y.appendChild(E),y.appendChild(M);const R=new he((v,w)=>{g.value=v.replace("#","").toUpperCase(),u.style.backgroundColor=v,this.value.stops[l].color=v,w!==void 0&&(this.value.stops[l].opacity=w,E.value=String(w),M.textContent=`${w}%`);const x=I(v);E.style.setProperty("--slider-color",`rgb(${x.r}, ${x.g}, ${x.b})`),this.updateGradientPreview(),this.createHandles(this.popoverEl.querySelector(".gradient-handles"),this.popoverEl.querySelector(".gradient-preview")),this.updateUI(),this.triggerChange()},"solid");g.addEventListener("click",v=>{v.preventDefault(),v.stopPropagation(),R.open(n.color,g,n.opacity??100)}),g.addEventListener("input",()=>{const v=g.value.trim(),w=v.startsWith("#")?v:`#${v}`;if(/^#[0-9A-Fa-f]{6}$/.test(w)){this.value.stops[l].color=w,u.style.backgroundColor=w;const x=I(w);E.style.setProperty("--slider-color",`rgb(${x.r}, ${x.g}, ${x.b})`),this.debouncedPreviewUpdate()}}),g.addEventListener("blur",()=>{this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null),this.updateGradientPreview(),this.updateUI(),this.triggerChange()}),m.addEventListener("click",async v=>{v.stopPropagation();try{await navigator.clipboard.writeText(`#${g.value}`)}catch{}}),p.addEventListener("focus",v=>{const w=v.target;w.value=w.value.replace("%",""),w.select()}),p.addEventListener("input",v=>{const w=v.target,x=parseInt(w.value.replace(/[^\d]/g,""),10);if(!Number.isNaN(x)){const z=Math.max(0,Math.min(100,x));this.value.stops[l].position=z,w.value=`${z}%`,this.debouncedPreviewUpdate()}}),p.addEventListener("blur",v=>{this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null);const w=v.target,x=parseInt(w.value.replace(/[^\d]/g,""),10);if(Number.isNaN(x))w.value=`${this.value.stops[l].position}%`;else{const z=Math.max(0,Math.min(100,x));this.value.stops[l].position=z,w.value=`${z}%`}this.updateGradientPreview(),this.createHandles(this.popoverEl.querySelector(".gradient-handles"),this.popoverEl.querySelector(".gradient-preview")),this.updateStopsList(),this.updateUI(),this.triggerChange()}),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)),M.textContent=`${this.value.stops[l].opacity}%`,this.debouncedPreviewUpdate()}),E.addEventListener("change",()=>{this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null),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&&(T.openInstance&&T.openInstance!==this&&T.openInstance.closePopover(),!this.isPopoverOpen)){if(this.isPopoverOpen=!0,T.openInstance=this,this.backdropEl&&(this.backdropEl.style.display="block",this.backdropEl.parentElement||document.body.appendChild(this.backdropEl)),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,u=t.top;u>=o+n?l=t.top-o-8:d>=o+n?l=t.bottom+8:u>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),200),document.addEventListener("keydown",this.handlePopoverKeydown,!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 u=n-e.bottom,g=e.top;g>=a+o?r=e.top-a-8:u>=a+o?r=e.bottom+8:g>u?(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,o;if(!this.popoverEl)return;const t=this.popoverEl.querySelectorAll(".gradient-type-tab");t.forEach(a=>a.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"),(o=this.recentGradientRefresh)==null||o.call(this)),this.popoverEl.offsetHeight;const s=this.popoverEl.querySelector(".gradient-editor-content");s&&this.updatePopoverContent(s)}closePopover(){if(!(!this.popoverEl||!this.isPopoverOpen)){if(this.isPopoverOpen=!1,this.backdropEl&&(this.backdropEl.style.display="none"),this.popoverEl.style.display="none",document.removeEventListener("click",this.onBackgroundClick,!0),document.removeEventListener("keydown",this.handlePopoverKeydown,!0),this.commitPendingSolidColor(),this.value&&this.value.type!=="solid"){const t=V(this.value);D.addColor(t,"gradient")}this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null),T.openInstance===this&&(T.openInstance=null)}}commitPendingSolidColor(){this.pendingSolidColor&&(this.solidPicker?this.solidPicker.commitRecentColor():D.addColor(this.pendingSolidColor,"solid"),this.pendingSolidColor=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=H(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?V(this.value):""}getCSSValue(){return this.value?V(this.value):""}getCSSForText(){return this.value?this.cssForTextValue():{}}getRawValue(){return this.value}};T.openInstance=null;let _=T;const de=`
|
|
227
|
+
`;const e=at(i=>{this.applyRecentColor(i)},this.recentScope);return this.recentSectionRefresh=e.refresh,t.appendChild(e.container),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}=A(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}=A(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}}applyRecentColor(t){if(this.currentColor=t,!(t.includes("gradient")||t.includes("radial"))){this.updatePickerVisualState();const i=this.container.querySelector(".color-picker-format-select"),s=this.container.querySelector(".color-picker-color-input");this.updateColorInput(i,s)}this.triggerChange()}commitRecentColor(){var t;D.addColor(this.currentColor,this.recentScope),(t=this.recentSectionRefresh)==null||t.call(this)}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"),u=this.container.querySelector(".color-picker-opacity");this.updateColorInput(p,d),this.updateOpacityBackground(u),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,u=parseFloat(s.style.left||"50%")/100,g=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,u,1-g);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 G(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 F(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=Y(i,s,n);return F(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}=A(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}=A(t),u=h>=360?h%360:h;n.style.left=`${u/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(${u}, 100%, 50%))`,o.style.left=`${e}%`,this.updateOpacityBackground(a),this.updateColorInput(l,r)}}const T=class T extends b{constructor(t={}){const e=typeof t.default=="string"?void 0:t.default;super({...t,title:t.title||"Color",default:e}),this.inputType={type:"text",angle:"number",stops:"text"},this.element=null,this.previewEl=null,this.inputEl=void 0,this.popoverEl=null,this.backdropEl=null,this.isPopoverOpen=!1,this.isEditing=!1,this.popoverPosition=null,this.previewUpdateTimeout=null,this.solidPicker=null,this.pendingSolidColor=null,this.onBackgroundClick=i=>{var d;if(!this.popoverEl||!this.isPopoverOpen)return;const s=i.target,n=this.popoverEl.contains(s),o=(d=this.element)==null?void 0:d.contains(s),a=document.querySelectorAll(".custom-color-picker"),l=Array.from(a).some(u=>u.contains(s)),r=s.closest(".gstop-color-input, .gradient-mini-preview, .gstop-color-preview"),h=s.classList.contains("color-picker-backdrop"),p=s.classList.contains("gradient-popover-backdrop");!n&&!o&&!l&&!r&&!h&&!p&&this.closePopover()},this.handlePopoverKeydown=i=>{if(this.isPopoverOpen){if(i.key==="Escape"){i.preventDefault(),this.closePopover();return}if(i.key==="Enter"){const s=i.target;if(s&&(s.tagName==="INPUT"||s.tagName==="TEXTAREA"))return;i.preventDefault(),this.closePopover()}}},this.detectChange=t.detectChange,this.originalDefault=t.default,this.value=this.defaultValue()}defaultValue(){const t=this.originalDefault;if(typeof t=="string"){const i=H(t);if(i)return B(i)}return B(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=H(t):t&&typeof t=="object"&&(e=B(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),this.pendingSolidColor=null}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=Ct(t.color,e)}else this.previewEl.style.background=V(this.value);this.inputEl&&this.value&&!this.isEditing&&(this.inputEl.value=et(this.value))}cssForTextValue(){return this.value?{background:V(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?V(this.value):"linear-gradient(90deg, #a84b4b 0%, #786666 100%)",this.previewEl.addEventListener("click",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?et(this.value):"",this.inputEl.readOnly=!1,this.inputEl.addEventListener("focus",()=>{if(this.isEditing=!0,this.value)if(this.value.type==="solid"){const i=this.value.stops[0];if(i){const s=i.color.toUpperCase(),n=i.opacity??100;if(n===100)this.inputEl.value=s;else{const a=Math.round(n/100*255).toString(16).toUpperCase().padStart(2,"0");this.inputEl.value=`${s}${a}`}}}else this.inputEl.value=V(this.value)}),this.inputEl.addEventListener("blur",()=>{this.isEditing=!1,this.value&&(this.inputEl.value=et(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=V(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.backdropEl=document.createElement("div"),this.backdropEl.className="gradient-popover-backdrop",this.backdropEl.style.display="none",this.backdropEl.addEventListener("click",a=>{a.preventDefault(),a.stopPropagation(),this.closePopover()}),this.popoverEl=document.createElement("div"),this.popoverEl.className="gradient-popover",this.popoverEl.style.display="none",this.popoverEl.addEventListener("click",a=>{a.stopPropagation()});const t=document.createElement("div");t.className="gradient-popover-header",t.style.cursor="move";const e=document.createElement("span");e.textContent="Fill";const i=document.createElement("button");i.type="button",i.className="gradient-popover-close",i.innerHTML=bt,i.addEventListener("click",()=>this.closePopover()),t.appendChild(e),t.appendChild(i),vt(t,this.popoverEl);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.backdropEl),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;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}]),t!=="solid"&&this.value.stops.length<2&&(this.value.angle=90),this.popoverEl){const s=this.popoverEl.querySelectorAll(".gradient-type-tab");s.forEach(a=>a.classList.remove("active"));const n=s[0],o=s[1];t==="solid"?n==null||n.classList.add("active"):o==null||o.classList.add("active")}const e=(i=this.popoverEl)==null?void 0:i.querySelector(".gradient-editor-content");e&&this.updatePopoverContent(e),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 pe({initialColor:e.color,initialOpacity:e.opacity??100,onColorChange:(s,n)=>{if(this.value){const o=H(s);if(o&&o.type!=="solid"){this.value=o,this.switchType(o.type);return}this.value.stops[0].color=s,this.value.stops[0].opacity=n,this.updateUI(),this.triggerChange(),this.pendingSolidColor=s}}});this.solidPicker=i,t.appendChild(i.getElement())}renderGradient(t){this.solidPicker=null;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??90}°`,o.style.width="75px",o.style.textAlign="center",(!this.value.angle||this.value.stops.length<2)&&(this.value.angle=90,o.value="90°");const a=document.createElement("button");a.type="button",a.className="gradient-flip-btn",a.innerHTML=re,i.addEventListener("change",()=>{this.switchType(i.value==="radial"?"radial":"linear"),this.updateDegreeVisibility(o)}),o.addEventListener("focus",m=>{const f=m.target;f.value=f.value.replace(/[^0-9-]/g,""),setTimeout(()=>f.select(),0)}),o.addEventListener("input",m=>{const f=parseInt(m.target.value);!Number.isNaN(f)&&this.value&&(this.value.angle=Math.max(0,Math.min(360,f)),this.debouncedPreviewUpdate())}),o.addEventListener("blur",m=>{var y;this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null);const f=m.target;let C=parseInt(f.value);Number.isNaN(C)&&(C=((y=this.value)==null?void 0:y.angle)??0),C=Math.max(0,Math.min(360,C)),this.value&&(this.value.angle=C),f.value=`${C}°`,this.updateGradientPreview(),this.updateUI(),this.triggerChange()}),a.addEventListener("click",()=>{!this.value||!this.value.stops||(this.value.stops.forEach(m=>{m.position=100-m.position}),this.value.stops.sort((m,f)=>m.position-f.position),this.updateGradientPreview(l),this.createHandles(r,l),this.updateStopsList(u),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 u=document.createElement("div");u.className="gradient-stops",t.appendChild(h),t.appendChild(u),this.updateStopsList(u);const g=at(m=>{const f=H(m);f&&(this.value=f,this.switchType(f.type),this.updateUI(),this.triggerChange())},"all");this.recentGradientRefresh=g.refresh,t.appendChild(g.container),d.addEventListener("click",()=>{var m;this.addStop(),this.updateStopsList(u),this.updateGradientPreview(l),this.createHandles(r,l),this.updateUI(),((m=document.activeElement)==null?void 0:m.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=V(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=u=>{a=!0,l=u.clientX,r=this.value.stops[s].position,n.classList.add("selected"),document.addEventListener("mousemove",p),document.addEventListener("mouseup",d),u.preventDefault(),u.stopPropagation()},p=u=>{if(!a||!this.value)return;const g=e.getBoundingClientRect(),m=u.clientX-l;let f=r+m/g.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((u,g)=>u.position-g.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 U,lt;const a=this.value.stops.findIndex((v,w)=>v.position===n.position&&v.color===n.color&&v.opacity===n.opacity&&this.value.stops.slice(0,w).filter(x=>x.position===n.position&&x.color===n.color&&x.opacity===n.opacity).length===i.slice(0,o).filter(x=>x.position===n.position&&x.color===n.color&&x.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 u=document.createElement("div");u.className="gstop-color-preview",u.style.backgroundColor=n.color;const g=document.createElement("input");g.type="text",g.className="gstop-color-input",g.value=n.color.replace("#","").toUpperCase();const m=document.createElement("button");m.type="button",m.className="gstop-color-copy",m.textContent="Copy",d.appendChild(u),d.appendChild(g),d.appendChild(m);const f=document.createElement("button");f.type="button",f.className="gstop-del",f.innerHTML=ce,f.disabled=(((lt=(U=this.value)==null?void 0:U.stops)==null?void 0:lt.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 y=document.createElement("div");y.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 M=document.createElement("span");M.className="gstop-opacity-value",M.textContent=`${n.opacity??100}%`,y.appendChild(E),y.appendChild(M);const R=new he((v,w)=>{g.value=v.replace("#","").toUpperCase(),u.style.backgroundColor=v,this.value.stops[l].color=v,w!==void 0&&(this.value.stops[l].opacity=w,E.value=String(w),M.textContent=`${w}%`);const x=I(v);E.style.setProperty("--slider-color",`rgb(${x.r}, ${x.g}, ${x.b})`),this.updateGradientPreview(),this.createHandles(this.popoverEl.querySelector(".gradient-handles"),this.popoverEl.querySelector(".gradient-preview")),this.updateUI(),this.triggerChange()},"solid");g.addEventListener("click",v=>{v.preventDefault(),v.stopPropagation(),R.open(n.color,g,n.opacity??100)}),g.addEventListener("input",()=>{const v=g.value.trim(),w=v.startsWith("#")?v:`#${v}`;if(/^#[0-9A-Fa-f]{6}$/.test(w)){this.value.stops[l].color=w,u.style.backgroundColor=w;const x=I(w);E.style.setProperty("--slider-color",`rgb(${x.r}, ${x.g}, ${x.b})`),this.debouncedPreviewUpdate()}}),g.addEventListener("blur",()=>{this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null),this.updateGradientPreview(),this.updateUI(),this.triggerChange()}),m.addEventListener("click",async v=>{v.stopPropagation();try{await navigator.clipboard.writeText(`#${g.value}`)}catch{}}),p.addEventListener("focus",v=>{const w=v.target;w.value=w.value.replace("%",""),w.select()}),p.addEventListener("input",v=>{const w=v.target,x=parseInt(w.value.replace(/[^\d]/g,""),10);if(!Number.isNaN(x)){const z=Math.max(0,Math.min(100,x));this.value.stops[l].position=z,w.value=`${z}%`,this.debouncedPreviewUpdate()}}),p.addEventListener("blur",v=>{this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null);const w=v.target,x=parseInt(w.value.replace(/[^\d]/g,""),10);if(Number.isNaN(x))w.value=`${this.value.stops[l].position}%`;else{const z=Math.max(0,Math.min(100,x));this.value.stops[l].position=z,w.value=`${z}%`}this.updateGradientPreview(),this.createHandles(this.popoverEl.querySelector(".gradient-handles"),this.popoverEl.querySelector(".gradient-preview")),this.updateStopsList(),this.updateUI(),this.triggerChange()}),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)),M.textContent=`${this.value.stops[l].opacity}%`,this.debouncedPreviewUpdate()}),E.addEventListener("change",()=>{this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null),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&&(T.openInstance&&T.openInstance!==this&&T.openInstance.closePopover(),!this.isPopoverOpen)){if(this.isPopoverOpen=!0,T.openInstance=this,this.backdropEl&&(this.backdropEl.style.display="block",this.backdropEl.parentElement||document.body.appendChild(this.backdropEl)),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,u=t.top;u>=o+n?l=t.top-o-8:d>=o+n?l=t.bottom+8:u>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`,this.popoverPosition={left:a,top:l}}setTimeout(()=>document.addEventListener("click",this.onBackgroundClick,!0),200),document.addEventListener("keydown",this.handlePopoverKeydown,!0)}}repositionPopover(){var t;if(!(!this.popoverEl||!this.isPopoverOpen||!this.element)&&((t=document.activeElement)==null?void 0:t.tagName)!=="INPUT"){if(this.popoverPosition){this.popoverEl.style.left=`${this.popoverPosition.left}px`,this.popoverEl.style.top=`${this.popoverPosition.top}px`;return}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 u=n-e.bottom,g=e.top;g>=a+o?r=e.top-a-8:u>=a+o?r=e.bottom+8:g>u?(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,o;if(!this.popoverEl)return;const t=this.popoverEl.querySelectorAll(".gradient-type-tab");t.forEach(a=>a.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"),(o=this.recentGradientRefresh)==null||o.call(this)),this.popoverEl.offsetHeight;const s=this.popoverEl.querySelector(".gradient-editor-content");s&&this.updatePopoverContent(s)}closePopover(){if(!(!this.popoverEl||!this.isPopoverOpen)){if(this.isPopoverOpen=!1,this.popoverPosition=null,this.backdropEl&&(this.backdropEl.style.display="none"),this.popoverEl.style.display="none",document.removeEventListener("click",this.onBackgroundClick,!0),document.removeEventListener("keydown",this.handlePopoverKeydown,!0),this.commitPendingSolidColor(),this.value&&this.value.type!=="solid"){const t=V(this.value);D.addColor(t,"gradient")}this.previewUpdateTimeout&&(clearTimeout(this.previewUpdateTimeout),this.previewUpdateTimeout=null),T.openInstance===this&&(T.openInstance=null)}}commitPendingSolidColor(){this.pendingSolidColor&&(this.solidPicker?this.solidPicker.commitRecentColor():D.addColor(this.pendingSolidColor,"solid"),this.pendingSolidColor=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=H(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?V(this.value):""}getCSSValue(){return this.value?V(this.value):""}getCSSForText(){return this.value?this.cssForTextValue():{}}getRawValue(){return this.value}};T.openInstance=null;let _=T;const de=`
|
|
228
228
|
<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
229
229
|
<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"/>
|
|
230
230
|
</svg>
|
|
@@ -237,7 +237,7 @@ function D(c) {
|
|
|
237
237
|
return c instanceof w;
|
|
238
238
|
}
|
|
239
239
|
function L(c) {
|
|
240
|
-
return c instanceof
|
|
240
|
+
return c instanceof P;
|
|
241
241
|
}
|
|
242
242
|
function at(c) {
|
|
243
243
|
return D(c) || L(c);
|
|
@@ -810,11 +810,11 @@ const Y = class Y {
|
|
|
810
810
|
}
|
|
811
811
|
};
|
|
812
812
|
Y.hiddenElements = /* @__PURE__ */ new Set();
|
|
813
|
-
let
|
|
813
|
+
let P = Y;
|
|
814
814
|
function le(c) {
|
|
815
815
|
return new wt(c);
|
|
816
816
|
}
|
|
817
|
-
class wt extends
|
|
817
|
+
class wt extends P {
|
|
818
818
|
constructor(t) {
|
|
819
819
|
super(t);
|
|
820
820
|
const e = Object.keys(this.settings)[0];
|
|
@@ -866,7 +866,7 @@ class wt extends T {
|
|
|
866
866
|
}
|
|
867
867
|
}
|
|
868
868
|
function xt(c) {
|
|
869
|
-
return new
|
|
869
|
+
return new P(c);
|
|
870
870
|
}
|
|
871
871
|
function re(c) {
|
|
872
872
|
return c;
|
|
@@ -1450,14 +1450,14 @@ class pe extends w {
|
|
|
1450
1450
|
suffix: "px",
|
|
1451
1451
|
minValue: this.minWidth,
|
|
1452
1452
|
maxValue: this.maxWidth,
|
|
1453
|
-
icon:
|
|
1453
|
+
icon: Pt
|
|
1454
1454
|
}), this.heightSetting = new I({
|
|
1455
1455
|
title: "Height",
|
|
1456
1456
|
default: this.value.height,
|
|
1457
1457
|
suffix: "px",
|
|
1458
1458
|
minValue: this.minHeight,
|
|
1459
1459
|
maxValue: this.maxHeight,
|
|
1460
|
-
icon:
|
|
1460
|
+
icon: Tt
|
|
1461
1461
|
}), this.widthSetting.setOnChange(this.handleWidthChange.bind(this)), this.heightSetting.setOnChange(this.handleHeightChange.bind(this));
|
|
1462
1462
|
}
|
|
1463
1463
|
handleWidthChange(t) {
|
|
@@ -1551,9 +1551,9 @@ class pe extends w {
|
|
|
1551
1551
|
}
|
|
1552
1552
|
}
|
|
1553
1553
|
}
|
|
1554
|
-
const
|
|
1554
|
+
const Pt = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
1555
1555
|
<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"/>
|
|
1556
|
-
</svg>`,
|
|
1556
|
+
</svg>`, Tt = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
1557
1557
|
<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"/>
|
|
1558
1558
|
</svg>`, Q = `
|
|
1559
1559
|
<svg xmlns="http://www.w3.org/2000/svg" width="15" height="16" viewBox="0 0 15 16" fill="none">
|
|
@@ -2659,10 +2659,10 @@ class Zt {
|
|
|
2659
2659
|
y.value = "hsl", y.textContent = "HSL", m.appendChild(f), m.appendChild(C), m.appendChild(y);
|
|
2660
2660
|
const E = document.createElement("input");
|
|
2661
2661
|
E.type = "text", E.className = "color-picker-color-input", E.value = this.currentColor, this.input = E;
|
|
2662
|
-
const
|
|
2663
|
-
|
|
2662
|
+
const T = document.createElement("div");
|
|
2663
|
+
T.className = "color-picker-input-container";
|
|
2664
2664
|
const k = document.createElement("button");
|
|
2665
|
-
return k.className = "color-picker-copy-inside", k.textContent = "Copy",
|
|
2665
|
+
return k.className = "color-picker-copy-inside", k.textContent = "Copy", T.appendChild(E), T.appendChild(k), g.appendChild(m), g.appendChild(T), t.appendChild(e), t.appendChild(n), t.appendChild(a), t.appendChild(p), t.appendChild(u.container), t.appendChild(g), t.addEventListener("click", (B) => B.stopPropagation()), this.bind(n, r, p, E, m, k, l), t;
|
|
2666
2666
|
}
|
|
2667
2667
|
createBackdrop() {
|
|
2668
2668
|
const t = document.createElement("div");
|
|
@@ -3074,7 +3074,7 @@ const V = class V extends w {
|
|
|
3074
3074
|
type: "text",
|
|
3075
3075
|
angle: "number",
|
|
3076
3076
|
stops: "text"
|
|
3077
|
-
}, this.element = null, this.previewEl = null, this.inputEl = void 0, this.popoverEl = null, this.backdropEl = null, this.isPopoverOpen = !1, this.isEditing = !1, this.previewUpdateTimeout = null, this.solidPicker = null, this.pendingSolidColor = null, this.onBackgroundClick = (i) => {
|
|
3077
|
+
}, this.element = null, this.previewEl = null, this.inputEl = void 0, this.popoverEl = null, this.backdropEl = null, this.isPopoverOpen = !1, this.isEditing = !1, this.popoverPosition = null, this.previewUpdateTimeout = null, this.solidPicker = null, this.pendingSolidColor = null, this.onBackgroundClick = (i) => {
|
|
3078
3078
|
var d;
|
|
3079
3079
|
if (!this.popoverEl || !this.isPopoverOpen) return;
|
|
3080
3080
|
const s = i.target, n = this.popoverEl.contains(s), o = (d = this.element) == null ? void 0 : d.contains(s), a = document.querySelectorAll(".custom-color-picker"), l = Array.from(a).some((u) => u.contains(s)), r = s.closest(
|
|
@@ -3208,19 +3208,19 @@ const V = class V extends w {
|
|
|
3208
3208
|
}), t.appendChild(e), t.appendChild(i), t;
|
|
3209
3209
|
}
|
|
3210
3210
|
switchType(t) {
|
|
3211
|
-
var i
|
|
3211
|
+
var i;
|
|
3212
3212
|
if (!this.value) return;
|
|
3213
3213
|
if (this.value.type = t, t !== "solid" && (!this.value.stops || this.value.stops.length === 0) && (this.value.stops = [
|
|
3214
3214
|
{ color: "#a84b4b", position: 0, opacity: 100 },
|
|
3215
3215
|
{ color: "#786666", position: 100, opacity: 100 }
|
|
3216
3216
|
]), t !== "solid" && this.value.stops.length < 2 && (this.value.angle = 90), this.popoverEl) {
|
|
3217
|
-
const
|
|
3218
|
-
|
|
3219
|
-
const
|
|
3220
|
-
t === "solid" ?
|
|
3217
|
+
const s = this.popoverEl.querySelectorAll(".gradient-type-tab");
|
|
3218
|
+
s.forEach((a) => a.classList.remove("active"));
|
|
3219
|
+
const n = s[0], o = s[1];
|
|
3220
|
+
t === "solid" ? n == null || n.classList.add("active") : o == null || o.classList.add("active");
|
|
3221
3221
|
}
|
|
3222
3222
|
const e = (i = this.popoverEl) == null ? void 0 : i.querySelector(".gradient-editor-content");
|
|
3223
|
-
e &&
|
|
3223
|
+
e && this.updatePopoverContent(e), this.updateUI(), this.triggerChange();
|
|
3224
3224
|
}
|
|
3225
3225
|
updatePopoverContent(t) {
|
|
3226
3226
|
t.innerHTML = "", this.value && (this.value.type === "solid" ? this.renderSolid(t) : this.renderGradient(t));
|
|
@@ -3369,10 +3369,10 @@ const V = class V extends w {
|
|
|
3369
3369
|
y.className = "gstop-opacity-group";
|
|
3370
3370
|
const E = document.createElement("input");
|
|
3371
3371
|
E.type = "range", E.className = "gstop-opacity-slider", E.min = "0", E.max = "100", E.value = String(n.opacity ?? 100);
|
|
3372
|
-
const
|
|
3372
|
+
const T = S(n.color);
|
|
3373
3373
|
E.style.setProperty(
|
|
3374
3374
|
"--slider-color",
|
|
3375
|
-
`rgb(${
|
|
3375
|
+
`rgb(${T.r}, ${T.g}, ${T.b})`
|
|
3376
3376
|
);
|
|
3377
3377
|
const k = document.createElement("span");
|
|
3378
3378
|
k.className = "gstop-opacity-value", k.textContent = `${n.opacity ?? 100}%`, y.appendChild(E), y.appendChild(k);
|
|
@@ -3470,7 +3470,7 @@ const V = class V extends w {
|
|
|
3470
3470
|
const r = i - t.right, h = t.left, p = e + n;
|
|
3471
3471
|
r < p && h > r + 100 && (a = t.left - e - 8);
|
|
3472
3472
|
const d = s - t.bottom, u = t.top;
|
|
3473
|
-
u >= o + n ? l = t.top - o - 8 : d >= o + n ? l = t.bottom + 8 : u > 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
|
|
3473
|
+
u >= o + n ? l = t.top - o - 8 : d >= o + n ? l = t.bottom + 8 : u > 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`, this.popoverPosition = { left: a, top: l };
|
|
3474
3474
|
}
|
|
3475
3475
|
setTimeout(
|
|
3476
3476
|
() => document.addEventListener("click", this.onBackgroundClick, !0),
|
|
@@ -3480,17 +3480,23 @@ const V = class V extends w {
|
|
|
3480
3480
|
}
|
|
3481
3481
|
repositionPopover() {
|
|
3482
3482
|
var t;
|
|
3483
|
-
!this.popoverEl || !this.isPopoverOpen || !this.element
|
|
3484
|
-
if (
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3483
|
+
if (!(!this.popoverEl || !this.isPopoverOpen || !this.element) && ((t = document.activeElement) == null ? void 0 : t.tagName) !== "INPUT") {
|
|
3484
|
+
if (this.popoverPosition) {
|
|
3485
|
+
this.popoverEl.style.left = `${this.popoverPosition.left}px`, this.popoverEl.style.top = `${this.popoverPosition.top}px`;
|
|
3486
|
+
return;
|
|
3487
|
+
}
|
|
3488
|
+
requestAnimationFrame(() => {
|
|
3489
|
+
if (!this.popoverEl || !this.element) return;
|
|
3490
|
+
const e = this.element.getBoundingClientRect(), i = 306, s = window.innerWidth, n = window.innerHeight, o = 16;
|
|
3491
|
+
this.popoverEl.style.left, this.popoverEl.style.top, this.popoverEl.style.left = "-9999px", this.popoverEl.style.top = "0px";
|
|
3492
|
+
const a = this.popoverEl.offsetHeight;
|
|
3493
|
+
let l = e.right + 8, r = e.top;
|
|
3494
|
+
const h = s - e.right, p = e.left, d = i + o;
|
|
3495
|
+
h < d && p > h + 100 && (l = e.left - i - 8);
|
|
3496
|
+
const u = n - e.bottom, g = e.top;
|
|
3497
|
+
g >= a + o ? r = e.top - a - 8 : u >= a + o ? r = e.bottom + 8 : g > u ? (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`;
|
|
3498
|
+
});
|
|
3499
|
+
}
|
|
3494
3500
|
}
|
|
3495
3501
|
refreshPopoverContent() {
|
|
3496
3502
|
var n, o;
|
|
@@ -3504,7 +3510,7 @@ const V = class V extends w {
|
|
|
3504
3510
|
}
|
|
3505
3511
|
closePopover() {
|
|
3506
3512
|
if (!(!this.popoverEl || !this.isPopoverOpen)) {
|
|
3507
|
-
if (this.isPopoverOpen = !1, this.backdropEl && (this.backdropEl.style.display = "none"), this.popoverEl.style.display = "none", document.removeEventListener("click", this.onBackgroundClick, !0), document.removeEventListener("keydown", this.handlePopoverKeydown, !0), this.commitPendingSolidColor(), this.value && this.value.type !== "solid") {
|
|
3513
|
+
if (this.isPopoverOpen = !1, this.popoverPosition = null, this.backdropEl && (this.backdropEl.style.display = "none"), this.popoverEl.style.display = "none", document.removeEventListener("click", this.onBackgroundClick, !0), document.removeEventListener("keydown", this.handlePopoverKeydown, !0), this.commitPendingSolidColor(), this.value && this.value.type !== "solid") {
|
|
3508
3514
|
const t = N(this.value);
|
|
3509
3515
|
A.addColor(t, "gradient");
|
|
3510
3516
|
}
|
|
@@ -3559,7 +3565,7 @@ const Yt = `
|
|
|
3559
3565
|
<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"/>
|
|
3560
3566
|
</svg>
|
|
3561
3567
|
`;
|
|
3562
|
-
class be extends
|
|
3568
|
+
class be extends P {
|
|
3563
3569
|
constructor(t) {
|
|
3564
3570
|
super({
|
|
3565
3571
|
title: "Border",
|
|
@@ -3614,7 +3620,7 @@ const te = `
|
|
|
3614
3620
|
<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"/>
|
|
3615
3621
|
</svg>
|
|
3616
3622
|
`;
|
|
3617
|
-
class we extends
|
|
3623
|
+
class we extends P {
|
|
3618
3624
|
constructor(t = {}) {
|
|
3619
3625
|
const { showAlign: e = t.showAlign ?? !0, ...i } = t;
|
|
3620
3626
|
super({
|
|
@@ -3739,7 +3745,7 @@ class _ extends w {
|
|
|
3739
3745
|
}), i;
|
|
3740
3746
|
}
|
|
3741
3747
|
}
|
|
3742
|
-
class xe extends
|
|
3748
|
+
class xe extends P {
|
|
3743
3749
|
constructor(t) {
|
|
3744
3750
|
super({
|
|
3745
3751
|
title: "Margins",
|
|
@@ -3791,7 +3797,7 @@ const se = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewB
|
|
|
3791
3797
|
</svg>`, ae = `<svg xmlns="http://www.w3.org/2000/svg" width="18" height="19" viewBox="0 0 18 19" fill="none">
|
|
3792
3798
|
<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"/>
|
|
3793
3799
|
</svg>`;
|
|
3794
|
-
class Le extends
|
|
3800
|
+
class Le extends P {
|
|
3795
3801
|
constructor(t) {
|
|
3796
3802
|
super({
|
|
3797
3803
|
title: "Background Image",
|
|
@@ -3853,7 +3859,7 @@ export {
|
|
|
3853
3859
|
ge as SelectApiSettings,
|
|
3854
3860
|
it as SelectSetting,
|
|
3855
3861
|
w as Setting,
|
|
3856
|
-
|
|
3862
|
+
P as SettingGroup,
|
|
3857
3863
|
Lt as StringSetting,
|
|
3858
3864
|
wt as TabSettingGroup,
|
|
3859
3865
|
wt as TabsSettingGroup,
|
|
@@ -14,6 +14,7 @@ export declare class GradientSetting extends Setting<GradientValue, SettingProps
|
|
|
14
14
|
private backdropEl;
|
|
15
15
|
private isPopoverOpen;
|
|
16
16
|
private isEditing;
|
|
17
|
+
private popoverPosition;
|
|
17
18
|
detectChange?: (value: GradientValue | undefined) => void;
|
|
18
19
|
private previewUpdateTimeout;
|
|
19
20
|
private solidPicker;
|
package/package.json
CHANGED