mirror of
https://gitee.com/niucloud-team/niucloud-admin.git
synced 2026-01-03 11:48:14 +00:00
2 lines
17 KiB
JavaScript
2 lines
17 KiB
JavaScript
import{U as ee,C as Fe,w as se,v as Le,f as ie}from"./event-a537c4cb.js";import{E as ue}from"./index-e09a20f5.js";import{i as Pe,b as Ve,o as Te,d as He,F as Z,p as Ie,q as Be,u as De,B as Oe,E as ce,s as We,a7 as ze}from"./index-72686045.js";import{E as Ke}from"./index-ef31373f.js";import{E as qe}from"./index-8cefa3ab.js";import{u as W,_ as z,w as Re}from"./base-0e92f4db.js";import{a as te}from"./position-c2e84b2a.js";import{d as I,s as he,r as b,w as E,o as U,b as M,e as A,f as $,n as g,h as V,K as ne,c as P,j as J,X as de,D as je,a as Xe,F as Ue,t as Ye,M as Ge,A as q,E as Ze,m as R,p as T,L as fe,u as s,q as S,C as j,v as pe,x as me}from"./runtime-core.esm-bundler-67034826.js";import{u as Je}from"./index-6cae7119.js";import{C as Qe}from"./index-c6aa1547.js";import{d as xe}from"./debounce-f6ba9d12.js";let Q=!1;function O(t,n){if(!Pe)return;const o=function(a){var r;(r=n.drag)==null||r.call(n,a)},e=function(a){var r;document.removeEventListener("mousemove",o),document.removeEventListener("mouseup",e),document.removeEventListener("touchmove",o),document.removeEventListener("touchend",e),document.onselectstart=null,document.ondragstart=null,Q=!1,(r=n.end)==null||r.call(n,a)},l=function(a){var r;Q||(a.preventDefault(),document.onselectstart=()=>!1,document.ondragstart=()=>!1,document.addEventListener("mousemove",o),document.addEventListener("mouseup",e),document.addEventListener("touchmove",o),document.addEventListener("touchend",e),Q=!0,(r=n.start)==null||r.call(n,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 n=W("color-alpha-slider"),o=ne(),e=he(),l=he(),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=o.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=o.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=o.vnode.el.getBoundingClientRect(),{clientX:N,clientY:C}=te(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 U(()=>{if(!l.value||!e.value)return;const i={drag:c=>{w(c)},end:c=>{w(c)}};O(l.value,i),O(e.value,i),v()}),{thumb:e,bar:l,thumbLeft:a,thumbTop:r,background:u,handleClick:k,update:v,ns:n}}});function tt(t,n,o,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:n[0]||(n[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 nt=z(et,[["render",tt],["__file","/home/runner/work/element-plus/element-plus/packages/components/color-picker/src/components/alpha-slider.vue"]]);const ot=I({name:"ElColorHueSlider",props:{color:{type:Object,required:!0},vertical:Boolean},setup(t){const n=W("color-hue-slider"),o=ne(),e=b(),l=b(),a=b(0),r=b(0),u=P(()=>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=o.vnode.el.getBoundingClientRect(),{clientX:m,clientY:N}=te(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=o.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=o.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 U(()=>{if(!l.value||!e.value)return;const v={drag:i=>{p(i)},end:i=>{p(i)}};O(l.value,v),O(e.value,v),w()}),{bar:l,thumb:e,thumbLeft:a,thumbTop:r,hueValue:u,handleClick:d,update:w,ns:n}}});function at(t,n,o,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:n[0]||(n[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(ot,[["render",at],["__file","/home/runner/work/element-plus/element-plus/packages/components/color-picker/src/components/hue-slider.vue"]]);const rt=Ve({modelValue:String,id:String,showAlpha:Boolean,colorFormat:String,disabled:Boolean,size:Te,popperClass:{type:String,default:""},label:{type:String,default:void 0},tabindex:{type:[String,Number],default:0},predefine:{type:He(Array)},validateEvent:{type:Boolean,default:!0}}),st={[ee]:t=>J(t)||Z(t),[Fe]:t=>J(t)||Z(t),activeChange:t=>J(t)||Z(t)},$e=Symbol("colorPickerContextKey"),ve=function(t,n,o){return[t,n*o/((t=(2-n)*o)<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,n){it(t)&&(t="100%");const o=ut(t);return t=Math.min(n,Math.max(0,Number.parseFloat(`${t}`))),o&&(t=Number.parseInt(`${t*n}`,10)/100),Math.abs(t-n)<1e-6?1:t%n/Number.parseFloat(n)},ge={10:"A",11:"B",12:"C",13:"D",14:"E",15:"F"},X=t=>{t=Math.min(Math.round(t),255);const n=Math.floor(t/16),o=t%16;return`${ge[n]||n}${ge[o]||o}`},be=function({r:t,g:n,b:o}){return Number.isNaN(+t)||Number.isNaN(+n)||Number.isNaN(+o)?"":`#${X(t)}${X(n)}${X(o)}`},x={A:10,B:11,C:12,D:13,E:14,F:15},L=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,n,o){n=n/100,o=o/100;let e=n;const l=Math.max(o,.01);o*=2,n*=o<=1?o:2-o,e*=l<=1?l:2-l;const a=(o+n)/2,r=o===0?2*e/(l+e):2*n/(o+n);return{h:t,s:r*100,v:a*100}},ke=(t,n,o)=>{t=H(t,255),n=H(n,255),o=H(o,255);const e=Math.max(t,n,o),l=Math.min(t,n,o);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=(n-o)/u+(n<o?6:0);break}case n:{a=(o-t)/u+2;break}case o:{a=(t-n)/u+4;break}}a/=6}return{h:a*360,s:d*100,v:r*100}},B=function(t,n,o){t=H(t,360)*6,n=H(n,100),o=H(o,100);const e=Math.floor(t),l=t-e,a=o*(1-n),r=o*(1-l*n),u=o*(1-(1-l)*n),d=e%6,p=[o,r,a,a,u,o][d],_=[u,o,o,r,a,a][d],k=[a,a,u,o,o,r][d];return{r:Math.round(p*255),g:Math.round(_*255),b:Math.round(k*255)}};class D{constructor(n={}){this._hue=0,this._saturation=100,this._value=100,this._alpha=100,this.enableAlpha=!1,this.format="hex",this.value="";for(const o in n)de(n,o)&&(this[o]=n[o]);n.value?this.fromString(n.value):this.doOnChange()}set(n,o){if(arguments.length===1&&typeof n=="object"){for(const e in n)de(n,e)&&this.set(e,n[e]);return}this[`_${n}`]=o,this.doOnChange()}get(n){return n==="alpha"?Math.floor(this[`_${n}`]):this[`_${n}`]}toRgb(){return B(this._hue,this._saturation,this._value)}fromString(n){if(!n){this._hue=0,this._saturation=100,this._value=100,this.doOnChange();return}const o=(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(n.includes("hsl")){const e=n.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]);o(l,a,r)}}else if(n.includes("hsv")){const e=n.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&&o(e[0],e[1],e[2])}else if(n.includes("rgb")){const e=n.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]);o(l,a,r)}}else if(n.includes("#")){const e=n.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=L(e[0]+e[0]),a=L(e[1]+e[1]),r=L(e[2]+e[2])):(e.length===6||e.length===8)&&(l=L(e.slice(0,2)),a=L(e.slice(2,4)),r=L(e.slice(4,6))),e.length===8?this._alpha=L(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);o(u,d,p)}}compare(n){return Math.abs(n._hue-this._hue)<2&&Math.abs(n._saturation-this._saturation)<1&&Math.abs(n._value-this._value)<1&&Math.abs(n._alpha-this._alpha)<1}doOnChange(){const{_hue:n,_saturation:o,_value:e,_alpha:l,format:a}=this;if(this.enableAlpha)switch(a){case"hsl":{const r=ve(n,o/100,e/100);this.value=`hsla(${n}, ${Math.round(r[1]*100)}%, ${Math.round(r[2]*100)}%, ${this.get("alpha")/100})`;break}case"hsv":{this.value=`hsva(${n}, ${Math.round(o)}%, ${Math.round(e)}%, ${this.get("alpha")/100})`;break}case"hex":{this.value=`${be(B(n,o,e))}${X(l*255/100)}`;break}default:{const{r,g:u,b:d}=B(n,o,e);this.value=`rgba(${r}, ${u}, ${d}, ${this.get("alpha")/100})`}}else switch(a){case"hsl":{const r=ve(n,o/100,e/100);this.value=`hsl(${n}, ${Math.round(r[1]*100)}%, ${Math.round(r[2]*100)}%)`;break}case"hsv":{this.value=`hsv(${n}, ${Math.round(o)}%, ${Math.round(e)}%)`;break}case"rgb":{const{r,g:u,b:d}=B(n,o,e);this.value=`rgb(${r}, ${u}, ${d})`;break}default:this.value=be(B(n,o,e))}}}const ht=I({props:{colors:{type:Array,required:!0},color:{type:Object,required:!0}},setup(t){const n=W("color-predefine"),{currentColor:o}=je($e),e=b(a(t.colors,t.color));E(()=>o.value,r=>{const u=new D;u.fromString(r),e.value.forEach(d=>{d.selected=u.compare(d)})}),Xe(()=>{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 D;return p.enableAlpha=!0,p.format="rgba",p.fromString(d),p.selected=p.value===u.value,p})}return{rgbaColors:e,handleSelect:l,ns:n}}}),dt=["onClick"];function ft(t,n,o,e,l,a){return M(),A("div",{class:g(t.ns.b())},[$("div",{class:g(t.ns.e("colors"))},[(M(!0),A(Ue,null,Ye(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 n=W("color-svpanel"),o=ne(),e=b(0),l=b(0),a=b("hsl(0, 100%, 50%)"),r=P(()=>{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=o.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=o.vnode.el.getBoundingClientRect(),{clientX:w,clientY:v}=te(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()}),U(()=>{O(o.vnode.el,{drag:p=>{d(p)},end:p=>{d(p)}}),u()}),{cursorTop:e,cursorLeft:l,background:a,colorValue:r,handleDrag:d,update:u,ns:n}}}),vt=$("div",null,null,-1),gt=[vt];function bt(t,n,o,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:n,emit:o}){const e=t,{t:l}=Je(),a=W("color"),{formItem:r}=Ie(),u=Be(),d=De(),{inputId:p,isLabeledByFormItem:_}=Oe(e,{formItemContext:r}),k=b(),w=b(),v=b(),i=b();let c=!0;const m=Ge(new D({enableAlpha:e.showAlpha,format:e.colorFormat||"",value:e.modelValue})),N=b(!1),C=b(!1),f=b(""),Ce=P(()=>!e.modelValue&&!C.value?"transparent":ye(m,e.showAlpha)),Y=P(()=>!e.modelValue&&!C.value?"":m.value),_e=P(()=>_.value?void 0:e.label||l("el.colorpicker.defaultLabel")),we=P(()=>_.value?r==null?void 0:r.labelId:void 0),Me=P(()=>[a.b("picker"),a.is("disabled",d.value),a.bm("picker",u.value)]);function ye(h,y){if(!(h instanceof D))throw new TypeError("color should be instance of _color Class");const{r:F,g:le,b:re}=h.toRgb();return y?`rgba(${F}, ${le}, ${re}, ${h.get("alpha")/100})`:`rgb(${F}, ${le}, ${re})`}function Ee(h){N.value=h}const K=xe(Ee,100);function Ne(){K(!1),G()}function G(){q(()=>{e.modelValue?m.fromString(e.modelValue):(m.value="",q(()=>{C.value=!1}))})}function oe(){d.value||K(!N.value)}function ae(){m.fromString(f.value)}function Se(){const h=m.value;o(ee,h),o("change",h),e.validateEvent&&(r==null||r.validate("change").catch(y=>ie())),K(!1),q(()=>{const y=new D({enableAlpha:e.showAlpha,format:e.colorFormat||"",value:e.modelValue});m.compare(y)||G()})}function Ae(){K(!1),o(ee,null),o("change",null),e.modelValue!==null&&e.validateEvent&&(r==null||r.validate("change").catch(h=>ie())),G()}return U(()=>{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&&o("activeChange",h),c=!0}),E(()=>m.value,()=>{!e.modelValue&&!C.value&&(C.value=!0)}),E(()=>N.value,()=>{q(()=>{var h,y,F;(h=k.value)==null||h.update(),(y=w.value)==null||y.update(),(F=v.value)==null||F.update()})}),Ze($e,{currentColor:Y}),n({color:m}),(h,y)=>(M(),R(s(Ke),{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(()=>[fe((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(),R(nt,{key:0,ref_key:"alpha",ref:v,color:s(m)},null,8,["color"])):j("v-if",!0),h.predefine?(M(),R(pt,{key:1,ref:"predefine",color:s(m),colors:h.predefine},null,8,["color","colors"])):j("v-if",!0),$("div",{class:g(s(a).be("dropdown","btns"))},[$("span",{class:g(s(a).be("dropdown","value"))},[S(s(qe),{modelValue:f.value,"onUpdate:modelValue":y[0]||(y[0]=F=>f.value=F),"validate-event":!1,size:"small",onKeyup:se(ae,["enter"]),onBlur:ae},null,8,["modelValue","onKeyup"])],2),S(s(ue),{class:g(s(a).be("dropdown","link-btn")),text:"",size:"small",onClick:Ae},{default:T(()=>[pe(me(s(l)("el.colorpicker.clear")),1)]),_:1},8,["class"]),S(s(ue),{plain:"",size:"small",class:g(s(a).be("dropdown","btn")),onClick:Se},{default:T(()=>[pe(me(s(l)("el.colorpicker.confirm")),1)]),_:1},8,["class"])],2)])),[[s(Qe),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(oe,["enter"])},[s(d)?(M(),A("div",{key:0,class:g(s(a).be("picker","mask"))},null,2)):j("v-if",!0),$("div",{class:g(s(a).be("picker","trigger")),onClick:oe},[$("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)})},[fe(S(s(ce),{class:g([s(a).be("picker","icon"),s(a).is("icon-arrow-down")])},{default:T(()=>[S(s(We))]),_:1},8,["class"]),[[Le,h.modelValue||C.value]]),!h.modelValue&&!C.value?(M(),R(s(ce),{key:0,class:g([s(a).be("picker","empty"),s(a).is("icon-close")])},{default:T(()=>[S(s(ze))]),_:1},8,["class"])):j("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 Ht=Re(wt);export{Ht as E};
|