mirror of
https://gitee.com/niucloud-team/niucloud-admin.git
synced 2026-01-04 20:31:10 +00:00
2 lines
17 KiB
JavaScript
2 lines
17 KiB
JavaScript
import{w as se,v as Pe}from"./index-331c6de1.js";import{E as ie}from"./index-91bdda63.js";import{i as Fe,b as Le,o as Ve,d as Te,C as J,p as He,u as Ie,E as ue,r as Be,a2 as Oe}from"./index-e37943c3.js";import{E as We}from"./index-45cca80f.js";import{E as De}from"./index-c1eb81db.js";import{d as I,b as D,s as ce,r as b,w as E,o as X,_ as z,e as M,f as A,g as $,n as g,j as V,P as te,c as L,m as Q,a2 as he,I as ze,a as Re,F as Ke,z as je,R as qe,E as K,J as Ue,v as j,x as T,Q as de,u as s,y as S,H as q,A as fe,B as pe,l as Xe}from"./base-d77b0726.js";import{a as oe}from"./position-09adcf79.js";import{U as ee,C as Ye,d as me}from"./event-e06a23af.js";import{u as Ge}from"./index-a20d1a31.js";import{u as Je,a as Qe}from"./index-6245131d.js";import{C as Ze}from"./index-ef0eb7b1.js";import{d as xe}from"./debounce-8a1738b0.js";let Z=!1;function W(t,o){if(!Fe)return;const n=function(a){var r;(r=o.drag)==null||r.call(o,a)},e=function(a){var r;document.removeEventListener("mousemove",n),document.removeEventListener("mouseup",e),document.removeEventListener("touchmove",n),document.removeEventListener("touchend",e),document.onselectstart=null,document.ondragstart=null,Z=!1,(r=o.end)==null||r.call(o,a)},l=function(a){var r;Z||(a.preventDefault(),document.onselectstart=()=>!1,document.ondragstart=()=>!1,document.addEventListener("mousemove",n),document.addEventListener("mouseup",e),document.addEventListener("touchmove",n),document.addEventListener("touchend",e),Z=!0,(r=o.start)==null||r.call(o,a))};t.addEventListener("mousedown",l),t.addEventListener("touchstart",l)}const et=I({name:"ElColorAlphaSlider",props:{color:{type:Object,required:!0},vertical:{type:Boolean,default:!1}},setup(t){const o=D("color-alpha-slider"),n=te(),e=ce(),l=ce(),a=b(0),r=b(0),u=b();E(()=>t.color.get("alpha"),()=>{v()}),E(()=>t.color.value,()=>{v()});function d(){if(!e.value||t.vertical)return 0;const i=n.vnode.el,c=t.color.get("alpha");return i?Math.round(c*(i.offsetWidth-e.value.offsetWidth/2)/100):0}function p(){if(!e.value)return 0;const i=n.vnode.el;if(!t.vertical)return 0;const c=t.color.get("alpha");return i?Math.round(c*(i.offsetHeight-e.value.offsetHeight/2)/100):0}function _(){if(t.color&&t.color.value){const{r:i,g:c,b:m}=t.color.toRgb();return`linear-gradient(to right, rgba(${i}, ${c}, ${m}, 0) 0%, rgba(${i}, ${c}, ${m}, 1) 100%)`}return""}function k(i){i.target!==e.value&&w(i)}function w(i){if(!l.value||!e.value)return;const m=n.vnode.el.getBoundingClientRect(),{clientX:N,clientY:C}=oe(i);if(t.vertical){let f=C-m.top;f=Math.max(e.value.offsetHeight/2,f),f=Math.min(f,m.height-e.value.offsetHeight/2),t.color.set("alpha",Math.round((f-e.value.offsetHeight/2)/(m.height-e.value.offsetHeight)*100))}else{let f=N-m.left;f=Math.max(e.value.offsetWidth/2,f),f=Math.min(f,m.width-e.value.offsetWidth/2),t.color.set("alpha",Math.round((f-e.value.offsetWidth/2)/(m.width-e.value.offsetWidth)*100))}}function v(){a.value=d(),r.value=p(),u.value=_()}return X(()=>{if(!l.value||!e.value)return;const i={drag:c=>{w(c)},end:c=>{w(c)}};W(l.value,i),W(e.value,i),v()}),{thumb:e,bar:l,thumbLeft:a,thumbTop:r,background:u,handleClick:k,update:v,ns:o}}});function tt(t,o,n,e,l,a){return M(),A("div",{class:g([t.ns.b(),t.ns.is("vertical",t.vertical)])},[$("div",{ref:"bar",class:g(t.ns.e("bar")),style:V({background:t.background}),onClick:o[0]||(o[0]=(...r)=>t.handleClick&&t.handleClick(...r))},null,6),$("div",{ref:"thumb",class:g(t.ns.e("thumb")),style:V({left:t.thumbLeft+"px",top:t.thumbTop+"px"})},null,6)],2)}var ot=z(et,[["render",tt],["__file","/home/runner/work/element-plus/element-plus/packages/components/color-picker/src/components/alpha-slider.vue"]]);const nt=I({name:"ElColorHueSlider",props:{color:{type:Object,required:!0},vertical:Boolean},setup(t){const o=D("color-hue-slider"),n=te(),e=b(),l=b(),a=b(0),r=b(0),u=L(()=>t.color.get("hue"));E(()=>u.value,()=>{w()});function d(v){v.target!==e.value&&p(v)}function p(v){if(!l.value||!e.value)return;const c=n.vnode.el.getBoundingClientRect(),{clientX:m,clientY:N}=oe(v);let C;if(t.vertical){let f=N-c.top;f=Math.min(f,c.height-e.value.offsetHeight/2),f=Math.max(e.value.offsetHeight/2,f),C=Math.round((f-e.value.offsetHeight/2)/(c.height-e.value.offsetHeight)*360)}else{let f=m-c.left;f=Math.min(f,c.width-e.value.offsetWidth/2),f=Math.max(e.value.offsetWidth/2,f),C=Math.round((f-e.value.offsetWidth/2)/(c.width-e.value.offsetWidth)*360)}t.color.set("hue",C)}function _(){if(!e.value)return 0;const v=n.vnode.el;if(t.vertical)return 0;const i=t.color.get("hue");return v?Math.round(i*(v.offsetWidth-e.value.offsetWidth/2)/360):0}function k(){if(!e.value)return 0;const v=n.vnode.el;if(!t.vertical)return 0;const i=t.color.get("hue");return v?Math.round(i*(v.offsetHeight-e.value.offsetHeight/2)/360):0}function w(){a.value=_(),r.value=k()}return X(()=>{if(!l.value||!e.value)return;const v={drag:i=>{p(i)},end:i=>{p(i)}};W(l.value,v),W(e.value,v),w()}),{bar:l,thumb:e,thumbLeft:a,thumbTop:r,hueValue:u,handleClick:d,update:w,ns:o}}});function at(t,o,n,e,l,a){return M(),A("div",{class:g([t.ns.b(),t.ns.is("vertical",t.vertical)])},[$("div",{ref:"bar",class:g(t.ns.e("bar")),onClick:o[0]||(o[0]=(...r)=>t.handleClick&&t.handleClick(...r))},null,2),$("div",{ref:"thumb",class:g(t.ns.e("thumb")),style:V({left:t.thumbLeft+"px",top:t.thumbTop+"px"})},null,6)],2)}var lt=z(nt,[["render",at],["__file","/home/runner/work/element-plus/element-plus/packages/components/color-picker/src/components/hue-slider.vue"]]);const rt=Le({modelValue:String,id:String,showAlpha:Boolean,colorFormat:String,disabled:Boolean,size:Ve,popperClass:{type:String,default:""},label:{type:String,default:void 0},tabindex:{type:[String,Number],default:0},predefine:{type:Te(Array)},validateEvent:{type:Boolean,default:!0}}),st={[ee]:t=>Q(t)||J(t),[Ye]:t=>Q(t)||J(t),activeChange:t=>Q(t)||J(t)},$e=Symbol("colorPickerContextKey"),ve=function(t,o,n){return[t,o*n/((t=(2-o)*n)<1?t:2-t)||0,t/2]},it=function(t){return typeof t=="string"&&t.includes(".")&&Number.parseFloat(t)===1},ut=function(t){return typeof t=="string"&&t.includes("%")},H=function(t,o){it(t)&&(t="100%");const n=ut(t);return t=Math.min(o,Math.max(0,Number.parseFloat(`${t}`))),n&&(t=Number.parseInt(`${t*o}`,10)/100),Math.abs(t-o)<1e-6?1:t%o/Number.parseFloat(o)},ge={10:"A",11:"B",12:"C",13:"D",14:"E",15:"F"},U=t=>{t=Math.min(Math.round(t),255);const o=Math.floor(t/16),n=t%16;return`${ge[o]||o}${ge[n]||n}`},be=function({r:t,g:o,b:n}){return Number.isNaN(+t)||Number.isNaN(+o)||Number.isNaN(+n)?"":`#${U(t)}${U(o)}${U(n)}`},x={A:10,B:11,C:12,D:13,E:14,F:15},F=function(t){return t.length===2?(x[t[0].toUpperCase()]||+t[0])*16+(x[t[1].toUpperCase()]||+t[1]):x[t[1].toUpperCase()]||+t[1]},ct=function(t,o,n){o=o/100,n=n/100;let e=o;const l=Math.max(n,.01);n*=2,o*=n<=1?n:2-n,e*=l<=1?l:2-l;const a=(n+o)/2,r=n===0?2*e/(l+e):2*o/(n+o);return{h:t,s:r*100,v:a*100}},ke=(t,o,n)=>{t=H(t,255),o=H(o,255),n=H(n,255);const e=Math.max(t,o,n),l=Math.min(t,o,n);let a;const r=e,u=e-l,d=e===0?0:u/e;if(e===l)a=0;else{switch(e){case t:{a=(o-n)/u+(o<n?6:0);break}case o:{a=(n-t)/u+2;break}case n:{a=(t-o)/u+4;break}}a/=6}return{h:a*360,s:d*100,v:r*100}},B=function(t,o,n){t=H(t,360)*6,o=H(o,100),n=H(n,100);const e=Math.floor(t),l=t-e,a=n*(1-o),r=n*(1-l*o),u=n*(1-(1-l)*o),d=e%6,p=[n,r,a,a,u,n][d],_=[u,n,n,r,a,a][d],k=[a,a,u,n,n,r][d];return{r:Math.round(p*255),g:Math.round(_*255),b:Math.round(k*255)}};class O{constructor(o={}){this._hue=0,this._saturation=100,this._value=100,this._alpha=100,this.enableAlpha=!1,this.format="hex",this.value="";for(const n in o)he(o,n)&&(this[n]=o[n]);o.value?this.fromString(o.value):this.doOnChange()}set(o,n){if(arguments.length===1&&typeof o=="object"){for(const e in o)he(o,e)&&this.set(e,o[e]);return}this[`_${o}`]=n,this.doOnChange()}get(o){return o==="alpha"?Math.floor(this[`_${o}`]):this[`_${o}`]}toRgb(){return B(this._hue,this._saturation,this._value)}fromString(o){if(!o){this._hue=0,this._saturation=100,this._value=100,this.doOnChange();return}const n=(e,l,a)=>{this._hue=Math.max(0,Math.min(360,e)),this._saturation=Math.max(0,Math.min(100,l)),this._value=Math.max(0,Math.min(100,a)),this.doOnChange()};if(o.includes("hsl")){const e=o.replace(/hsla|hsl|\(|\)/gm,"").split(/\s|,/g).filter(l=>l!=="").map((l,a)=>a>2?Number.parseFloat(l):Number.parseInt(l,10));if(e.length===4?this._alpha=Number.parseFloat(e[3])*100:e.length===3&&(this._alpha=100),e.length>=3){const{h:l,s:a,v:r}=ct(e[0],e[1],e[2]);n(l,a,r)}}else if(o.includes("hsv")){const e=o.replace(/hsva|hsv|\(|\)/gm,"").split(/\s|,/g).filter(l=>l!=="").map((l,a)=>a>2?Number.parseFloat(l):Number.parseInt(l,10));e.length===4?this._alpha=Number.parseFloat(e[3])*100:e.length===3&&(this._alpha=100),e.length>=3&&n(e[0],e[1],e[2])}else if(o.includes("rgb")){const e=o.replace(/rgba|rgb|\(|\)/gm,"").split(/\s|,/g).filter(l=>l!=="").map((l,a)=>a>2?Number.parseFloat(l):Number.parseInt(l,10));if(e.length===4?this._alpha=Number.parseFloat(e[3])*100:e.length===3&&(this._alpha=100),e.length>=3){const{h:l,s:a,v:r}=ke(e[0],e[1],e[2]);n(l,a,r)}}else if(o.includes("#")){const e=o.replace("#","").trim();if(!/^[0-9a-fA-F]{3}$|^[0-9a-fA-F]{6}$|^[0-9a-fA-F]{8}$/.test(e))return;let l,a,r;e.length===3?(l=F(e[0]+e[0]),a=F(e[1]+e[1]),r=F(e[2]+e[2])):(e.length===6||e.length===8)&&(l=F(e.slice(0,2)),a=F(e.slice(2,4)),r=F(e.slice(4,6))),e.length===8?this._alpha=F(e.slice(6))/255*100:(e.length===3||e.length===6)&&(this._alpha=100);const{h:u,s:d,v:p}=ke(l,a,r);n(u,d,p)}}compare(o){return Math.abs(o._hue-this._hue)<2&&Math.abs(o._saturation-this._saturation)<1&&Math.abs(o._value-this._value)<1&&Math.abs(o._alpha-this._alpha)<1}doOnChange(){const{_hue:o,_saturation:n,_value:e,_alpha:l,format:a}=this;if(this.enableAlpha)switch(a){case"hsl":{const r=ve(o,n/100,e/100);this.value=`hsla(${o}, ${Math.round(r[1]*100)}%, ${Math.round(r[2]*100)}%, ${this.get("alpha")/100})`;break}case"hsv":{this.value=`hsva(${o}, ${Math.round(n)}%, ${Math.round(e)}%, ${this.get("alpha")/100})`;break}case"hex":{this.value=`${be(B(o,n,e))}${U(l*255/100)}`;break}default:{const{r,g:u,b:d}=B(o,n,e);this.value=`rgba(${r}, ${u}, ${d}, ${this.get("alpha")/100})`}}else switch(a){case"hsl":{const r=ve(o,n/100,e/100);this.value=`hsl(${o}, ${Math.round(r[1]*100)}%, ${Math.round(r[2]*100)}%)`;break}case"hsv":{this.value=`hsv(${o}, ${Math.round(n)}%, ${Math.round(e)}%)`;break}case"rgb":{const{r,g:u,b:d}=B(o,n,e);this.value=`rgb(${r}, ${u}, ${d})`;break}default:this.value=be(B(o,n,e))}}}const ht=I({props:{colors:{type:Array,required:!0},color:{type:Object,required:!0}},setup(t){const o=D("color-predefine"),{currentColor:n}=ze($e),e=b(a(t.colors,t.color));E(()=>n.value,r=>{const u=new O;u.fromString(r),e.value.forEach(d=>{d.selected=u.compare(d)})}),Re(()=>{e.value=a(t.colors,t.color)});function l(r){t.color.fromString(t.colors[r])}function a(r,u){return r.map(d=>{const p=new O;return p.enableAlpha=!0,p.format="rgba",p.fromString(d),p.selected=p.value===u.value,p})}return{rgbaColors:e,handleSelect:l,ns:o}}}),dt=["onClick"];function ft(t,o,n,e,l,a){return M(),A("div",{class:g(t.ns.b())},[$("div",{class:g(t.ns.e("colors"))},[(M(!0),A(Ke,null,je(t.rgbaColors,(r,u)=>(M(),A("div",{key:t.colors[u],class:g([t.ns.e("color-selector"),t.ns.is("alpha",r._alpha<100),{selected:r.selected}]),onClick:d=>t.handleSelect(u)},[$("div",{style:V({backgroundColor:r.value})},null,4)],10,dt))),128))],2)],2)}var pt=z(ht,[["render",ft],["__file","/home/runner/work/element-plus/element-plus/packages/components/color-picker/src/components/predefine.vue"]]);const mt=I({name:"ElSlPanel",props:{color:{type:Object,required:!0}},setup(t){const o=D("color-svpanel"),n=te(),e=b(0),l=b(0),a=b("hsl(0, 100%, 50%)"),r=L(()=>{const p=t.color.get("hue"),_=t.color.get("value");return{hue:p,value:_}});function u(){const p=t.color.get("saturation"),_=t.color.get("value"),k=n.vnode.el,{clientWidth:w,clientHeight:v}=k;l.value=p*w/100,e.value=(100-_)*v/100,a.value=`hsl(${t.color.get("hue")}, 100%, 50%)`}function d(p){const k=n.vnode.el.getBoundingClientRect(),{clientX:w,clientY:v}=oe(p);let i=w-k.left,c=v-k.top;i=Math.max(0,i),i=Math.min(i,k.width),c=Math.max(0,c),c=Math.min(c,k.height),l.value=i,e.value=c,t.color.set({saturation:i/k.width*100,value:100-c/k.height*100})}return E(()=>r.value,()=>{u()}),X(()=>{W(n.vnode.el,{drag:p=>{d(p)},end:p=>{d(p)}}),u()}),{cursorTop:e,cursorLeft:l,background:a,colorValue:r,handleDrag:d,update:u,ns:o}}}),vt=$("div",null,null,-1),gt=[vt];function bt(t,o,n,e,l,a){return M(),A("div",{class:g(t.ns.b()),style:V({backgroundColor:t.background})},[$("div",{class:g(t.ns.e("white"))},null,2),$("div",{class:g(t.ns.e("black"))},null,2),$("div",{class:g(t.ns.e("cursor")),style:V({top:t.cursorTop+"px",left:t.cursorLeft+"px"})},gt,6)],6)}var kt=z(mt,[["render",bt],["__file","/home/runner/work/element-plus/element-plus/packages/components/color-picker/src/components/sv-panel.vue"]]);const $t=["id","aria-label","aria-labelledby","aria-description","tabindex","onKeydown"],Ct=I({name:"ElColorPicker"}),_t=I({...Ct,props:rt,emits:st,setup(t,{expose:o,emit:n}){const e=t,{t:l}=Ge(),a=D("color"),{formItem:r}=Je(),u=He(),d=Ie(),{inputId:p,isLabeledByFormItem:_}=Qe(e,{formItemContext:r}),k=b(),w=b(),v=b(),i=b();let c=!0;const m=qe(new O({enableAlpha:e.showAlpha,format:e.colorFormat||"",value:e.modelValue})),N=b(!1),C=b(!1),f=b(""),Ce=L(()=>!e.modelValue&&!C.value?"transparent":ye(m,e.showAlpha)),Y=L(()=>!e.modelValue&&!C.value?"":m.value),_e=L(()=>_.value?void 0:e.label||l("el.colorpicker.defaultLabel")),we=L(()=>_.value?r==null?void 0:r.labelId:void 0),Me=L(()=>[a.b("picker"),a.is("disabled",d.value),a.bm("picker",u.value)]);function ye(h,y){if(!(h instanceof O))throw new TypeError("color should be instance of _color Class");const{r:P,g:le,b:re}=h.toRgb();return y?`rgba(${P}, ${le}, ${re}, ${h.get("alpha")/100})`:`rgb(${P}, ${le}, ${re})`}function Ee(h){N.value=h}const R=xe(Ee,100);function Ne(){R(!1),G()}function G(){K(()=>{e.modelValue?m.fromString(e.modelValue):(m.value="",K(()=>{C.value=!1}))})}function ne(){d.value||R(!N.value)}function ae(){m.fromString(f.value)}function Se(){const h=m.value;n(ee,h),n("change",h),e.validateEvent&&(r==null||r.validate("change").catch(y=>me())),R(!1),K(()=>{const y=new O({enableAlpha:e.showAlpha,format:e.colorFormat||"",value:e.modelValue});m.compare(y)||G()})}function Ae(){R(!1),n(ee,null),n("change",null),e.modelValue!==null&&e.validateEvent&&(r==null||r.validate("change").catch(h=>me())),G()}return X(()=>{e.modelValue&&(f.value=Y.value)}),E(()=>e.modelValue,h=>{h?h&&h!==m.value&&(c=!1,m.fromString(h)):C.value=!1}),E(()=>Y.value,h=>{f.value=h,c&&n("activeChange",h),c=!0}),E(()=>m.value,()=>{!e.modelValue&&!C.value&&(C.value=!0)}),E(()=>N.value,()=>{K(()=>{var h,y,P;(h=k.value)==null||h.update(),(y=w.value)==null||y.update(),(P=v.value)==null||P.update()})}),Ue($e,{currentColor:Y}),o({color:m}),(h,y)=>(M(),j(s(We),{ref_key:"popper",ref:i,visible:N.value,"show-arrow":!1,"fallback-placements":["bottom","top","right","left"],offset:0,"gpu-acceleration":!1,"popper-class":[s(a).be("picker","panel"),s(a).b("dropdown"),h.popperClass],"stop-popper-mouse-event":!1,effect:"light",trigger:"click",transition:`${s(a).namespace.value}-zoom-in-top`,persistent:""},{content:T(()=>[de((M(),A("div",null,[$("div",{class:g(s(a).be("dropdown","main-wrapper"))},[S(lt,{ref_key:"hue",ref:k,class:"hue-slider",color:s(m),vertical:""},null,8,["color"]),S(kt,{ref:"svPanel",color:s(m)},null,8,["color"])],2),h.showAlpha?(M(),j(ot,{key:0,ref_key:"alpha",ref:v,color:s(m)},null,8,["color"])):q("v-if",!0),h.predefine?(M(),j(pt,{key:1,ref:"predefine",color:s(m),colors:h.predefine},null,8,["color","colors"])):q("v-if",!0),$("div",{class:g(s(a).be("dropdown","btns"))},[$("span",{class:g(s(a).be("dropdown","value"))},[S(s(De),{modelValue:f.value,"onUpdate:modelValue":y[0]||(y[0]=P=>f.value=P),"validate-event":!1,size:"small",onKeyup:se(ae,["enter"]),onBlur:ae},null,8,["modelValue","onKeyup"])],2),S(s(ie),{class:g(s(a).be("dropdown","link-btn")),text:"",size:"small",onClick:Ae},{default:T(()=>[fe(pe(s(l)("el.colorpicker.clear")),1)]),_:1},8,["class"]),S(s(ie),{plain:"",size:"small",class:g(s(a).be("dropdown","btn")),onClick:Se},{default:T(()=>[fe(pe(s(l)("el.colorpicker.confirm")),1)]),_:1},8,["class"])],2)])),[[s(Ze),Ne]])]),default:T(()=>[$("div",{id:s(p),class:g(s(Me)),role:"button","aria-label":s(_e),"aria-labelledby":s(we),"aria-description":s(l)("el.colorpicker.description",{color:h.modelValue||""}),tabindex:h.tabindex,onKeydown:se(ne,["enter"])},[s(d)?(M(),A("div",{key:0,class:g(s(a).be("picker","mask"))},null,2)):q("v-if",!0),$("div",{class:g(s(a).be("picker","trigger")),onClick:ne},[$("span",{class:g([s(a).be("picker","color"),s(a).is("alpha",h.showAlpha)])},[$("span",{class:g(s(a).be("picker","color-inner")),style:V({backgroundColor:s(Ce)})},[de(S(s(ue),{class:g([s(a).be("picker","icon"),s(a).is("icon-arrow-down")])},{default:T(()=>[S(s(Be))]),_:1},8,["class"]),[[Pe,h.modelValue||C.value]]),!h.modelValue&&!C.value?(M(),j(s(ue),{key:0,class:g([s(a).be("picker","empty"),s(a).is("icon-close")])},{default:T(()=>[S(s(Oe))]),_:1},8,["class"])):q("v-if",!0)],6)],2)],2)],42,$t)]),_:1},8,["visible","popper-class","transition"]))}});var wt=z(_t,[["__file","/home/runner/work/element-plus/element-plus/packages/components/color-picker/src/color-picker.vue"]]);const It=Xe(wt);export{It as E};
|