mirror of https://github.com/rocboss/paopao-ce
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
103 lines
13 KiB
103 lines
13 KiB
2 years ago
|
import{ap as ne,aq as Be,ar as Se,as as $e,r as D,k as ze,at as Me,m as Re,c as ae,f as t,au as oe,b as X,e as h,a as ie,d as L,u as Ve,x as le,o as Le,t as Fe,s as Te,y as E,z as k,av as Z,aw as f,A as Oe,ax as G,h as r,B as y,ay as Ee,az as Ae,w as J,W as z,Y as ee,Z as W,$ as Ne,al as Pe,a2 as De,a6 as Q,a5 as R,a4 as A,a3 as N,a7 as re,a9 as He,aa as Ie,af as We,K as Ke,aA as Ue}from"./index.d4f5aad2.js";let P=0;const je=typeof window!="undefined"&&window.matchMedia!==void 0,B=D(null);let c,C;function H(e){e.matches&&(B.value="dark")}function I(e){e.matches&&(B.value="light")}function qe(){c=window.matchMedia("(prefers-color-scheme: dark)"),C=window.matchMedia("(prefers-color-scheme: light)"),c.matches?B.value="dark":C.matches?B.value="light":B.value=null,c.addEventListener?(c.addEventListener("change",H),C.addEventListener("change",I)):c.addListener&&(c.addListener(H),C.addListener(I))}function Ye(){"removeEventListener"in c?(c.removeEventListener("change",H),C.removeEventListener("change",I)):"removeListener"in c&&(c.removeListener(H),C.removeListener(I)),c=void 0,C=void 0}let se=!0;function Xe(){return je?(P===0&&qe(),se&&(se=Be())&&(Se(()=>{P+=1}),$e(()=>{P-=1,P===0&&Ye()})),ne(B)):ne(B)}const Ze=e=>{const{primaryColor:o,opacityDisabled:i,borderRadius:s,textColor3:l}=e,v="rgba(0, 0, 0, .14)";return Object.assign(Object.assign({},Me),{iconColor:l,textColor:"white",loadingColor:o,opacityDisabled:i,railColor:v,railColorActive:o,buttonBoxShadow:"0 1px 4px 0 rgba(0, 0, 0, 0.3), inset 0 0 1px 0 rgba(0, 0, 0, 0.05)",buttonColor:"#FFF",railBorderRadiusSmall:s,railBorderRadiusMedium:s,railBorderRadiusLarge:s,buttonBorderRadiusSmall:s,buttonBorderRadiusMedium:s,buttonBorderRadiusLarge:s,boxShadowFocus:`0 0 0 2px ${Re(o,{alpha:.2})}`})},Ge={name:"Switch",common:ze,self:Ze};var Je=Ge,Qe=ae("switch",`
|
||
|
height: var(--n-height);
|
||
|
min-width: var(--n-width);
|
||
|
vertical-align: middle;
|
||
|
user-select: none;
|
||
|
-webkit-user-select: none;
|
||
|
display: inline-flex;
|
||
|
outline: none;
|
||
|
justify-content: center;
|
||
|
align-items: center;
|
||
|
`,[t("children-placeholder",`
|
||
|
height: var(--n-rail-height);
|
||
|
display: flex;
|
||
|
flex-direction: column;
|
||
|
overflow: hidden;
|
||
|
pointer-events: none;
|
||
|
visibility: hidden;
|
||
|
`),t("rail-placeholder",`
|
||
|
display: flex;
|
||
|
flex-wrap: none;
|
||
|
`),t("button-placeholder",`
|
||
|
width: calc(1.75 * var(--n-rail-height));
|
||
|
height: var(--n-rail-height);
|
||
|
`),ae("base-loading",`
|
||
|
position: absolute;
|
||
|
top: 50%;
|
||
|
left: 50%;
|
||
|
transform: translateX(-50%) translateY(-50%);
|
||
|
font-size: calc(var(--n-button-width) - 4px);
|
||
|
color: var(--n-loading-color);
|
||
|
transition: color .3s var(--n-bezier);
|
||
|
`,[oe({left:"50%",top:"50%",originalTransform:"translateX(-50%) translateY(-50%)"})]),t("checked, unchecked",`
|
||
|
transition: color .3s var(--n-bezier);
|
||
|
color: var(--n-text-color);
|
||
|
box-sizing: border-box;
|
||
|
position: absolute;
|
||
|
white-space: nowrap;
|
||
|
top: 0;
|
||
|
bottom: 0;
|
||
|
display: flex;
|
||
|
align-items: center;
|
||
|
line-height: 1;
|
||
|
`),t("checked",`
|
||
|
right: 0;
|
||
|
padding-right: calc(1.25 * var(--n-rail-height) - var(--n-offset));
|
||
|
`),t("unchecked",`
|
||
|
left: 0;
|
||
|
justify-content: flex-end;
|
||
|
padding-left: calc(1.25 * var(--n-rail-height) - var(--n-offset));
|
||
|
`),X("&:focus",[t("rail",`
|
||
|
box-shadow: var(--n-box-shadow-focus);
|
||
|
`)]),h("round",[t("rail","border-radius: calc(var(--n-rail-height) / 2);",[t("button","border-radius: calc(var(--n-button-height) / 2);")])]),ie("disabled",[ie("icon",[h("rubber-band",[h("pressed",[t("rail",[t("button","max-width: var(--n-button-width-pressed);")])]),t("rail",[X("&:active",[t("button","max-width: var(--n-button-width-pressed);")])]),h("active",[h("pressed",[t("rail",[t("button","left: calc(100% - var(--n-offset) - var(--n-button-width-pressed));")])]),t("rail",[X("&:active",[t("button","left: calc(100% - var(--n-offset) - var(--n-button-width-pressed));")])])])])])]),h("active",[t("rail",[t("button","left: calc(100% - var(--n-button-width) - var(--n-offset))")])]),t("rail",`
|
||
|
overflow: hidden;
|
||
|
height: var(--n-rail-height);
|
||
|
min-width: var(--n-rail-width);
|
||
|
border-radius: var(--n-rail-border-radius);
|
||
|
cursor: pointer;
|
||
|
position: relative;
|
||
|
transition:
|
||
|
opacity .3s var(--n-bezier),
|
||
|
background .3s var(--n-bezier),
|
||
|
box-shadow .3s var(--n-bezier);
|
||
|
background-color: var(--n-rail-color);
|
||
|
`,[t("button-icon",`
|
||
|
color: var(--n-icon-color);
|
||
|
transition: color .3s var(--n-bezier);
|
||
|
font-size: calc(var(--n-button-height) - 4px);
|
||
|
position: absolute;
|
||
|
left: 0;
|
||
|
right: 0;
|
||
|
top: 0;
|
||
|
bottom: 0;
|
||
|
display: flex;
|
||
|
justify-content: center;
|
||
|
align-items: center;
|
||
|
line-height: 1;
|
||
|
`,[oe()]),t("button",`
|
||
|
align-items: center;
|
||
|
top: var(--n-offset);
|
||
|
left: var(--n-offset);
|
||
|
height: var(--n-button-height);
|
||
|
width: var(--n-button-width-pressed);
|
||
|
max-width: var(--n-button-width);
|
||
|
border-radius: var(--n-button-border-radius);
|
||
|
background-color: var(--n-button-color);
|
||
|
box-shadow: var(--n-button-box-shadow);
|
||
|
box-sizing: border-box;
|
||
|
cursor: inherit;
|
||
|
content: "";
|
||
|
position: absolute;
|
||
|
transition:
|
||
|
background-color .3s var(--n-bezier),
|
||
|
left .3s var(--n-bezier),
|
||
|
opacity .3s var(--n-bezier),
|
||
|
max-width .3s var(--n-bezier),
|
||
|
box-shadow .3s var(--n-bezier);
|
||
|
`)]),h("active",[t("rail","background-color: var(--n-rail-color-active);")]),h("loading",[t("rail",`
|
||
|
cursor: wait;
|
||
|
`)]),h("disabled",[t("rail",`
|
||
|
cursor: not-allowed;
|
||
|
opacity: .5;
|
||
|
`)])]);const et=Object.assign(Object.assign({},le.props),{size:{type:String,default:"medium"},value:{type:[String,Number,Boolean],default:void 0},loading:Boolean,defaultValue:{type:[String,Number,Boolean],default:!1},disabled:{type:Boolean,default:void 0},round:{type:Boolean,default:!0},"onUpdate:value":[Function,Array],onUpdateValue:[Function,Array],checkedValue:{type:[String,Number,Boolean],default:!0},uncheckedValue:{type:[String,Number,Boolean],default:!1},railStyle:Function,rubberBand:{type:Boolean,default:!0},onChange:[Function,Array]});let V;var tt=L({name:"Switch",props:et,setup(e){V===void 0&&(typeof CSS!="undefined"?typeof CSS.supports!="undefined"?V=CSS.supports("width","max(1px)"):V=!1:V=!0);const{mergedClsPrefixRef:o,inlineThemeDisabled:i}=Ve(e),s=le("Switch","-switch",Qe,Je,e,o),l=Le(e),{mergedSizeRef:v,mergedDisabledRef:d}=l,S=D(e.defaultValue),g=Fe(e,"value"),u=Te(g,S),x=E(()=>u.value===e.checkedValue),b=D(!1),a=D(!1),m=E(()=>{const{railStyle:n}=e;if(!!n)return n({focused:a.value,checked:x.value})});function w(n){const{"onUpdate:value":F,onChange:T,onUpdateValue:O}=e,{nTriggerFormInput:K,nTriggerFormChange:U}=l;F&&J(F,n),O&&J(O,n),T&&J(T,n),S.value=n,K(),U()}function ce(){const{nTriggerFormFocus:n}=l;n()}function de(){const{nTriggerFormBlur:n}=l;n()}function ue(){e.loading||d.value||(u.value!==e.checkedValue?w(e.checkedValue):w(e.uncheckedValue))}function he(){a.value=!0,ce()}function fe(){a.value=!1,de(),b.value=!1}function ve(n){e.loading||d.value||n.key===" "&&(u.value!==e.checkedValue?w(e.checkedValue):w(e.uncheckedValue),b.value=!1)}function ge(n){e.loading||d.value||n.key===" "&&(n.preventDefault(),b.value=!0)}const te=E(()=>{const{value:n}=v,{self:{opacityDisabled:F,railColor:T,railColorActive:O,buttonBoxShadow:K,buttonColor:U,boxShadowFocus:be,loadingColor:me,textColor:we,iconColor:pe,[k("buttonHeight",n)]:p,[k("buttonWidth",n)]:_e,[k("buttonWidthPressed",n)]:xe,[k("railHeight",n)]:_,[k("railWidth",n)]:M,[k("railBorderRadius",n)]:ke,[k("buttonBorderRadius",n)]:ye},common:{cubicBezierEaseInOut:Ce}}=s.value;let j,q,Y;return V?(j=`calc((${_} - ${p}) / 2)`,q=`max(${_}, ${p})`,Y=`max(${M}, calc(${M} + ${p} - ${_}))`):(j=Z((f(_)-f(p))/2),q=Z(Math.max(f(_),f(p))),Y=f(_)>f(p)?M:Z(f(M)+f(p)-f(_))),{"--n-bezier":Ce,"--n-button-border-radius":ye,"--n-button-box-shadow":K,"--n-button-color":U,"--n-button-width":_e,"--n-button-width-pressed":xe,"--n-button-height":p,"--n-height":q,"--n-offset":j,"--n-opacity-disabled":F,"--n-rail-border-radius":ke,"--n-rail-color":T,"--n-rail-color-active":O,"--n-rail-height":_,"--n-rail-width":M,"--n-width":Y,"--n-box-shadow-focus":be,"--n-loading-color":me,"--n-text-color":we,"--n-icon-color":pe}}),$=i?Oe("switch",E(()=>v.value[0]),te,e):void 0;return{handleClick:ue,handleBlur:fe,handleFocus:he,handleKeyup:ve,handleKeydown:ge,mergedRailStyle:m,pressed:b,mergedClsPrefix:o,mergedValue:u,checked:x,mergedDisabled:d,cssVars:i?void 0:te,themeClass:$==null?void 0:$.themeClass,onRender:$==null?void 0:$.onRender}},render(){const{mergedClsPrefix:e,mergedDisabled:o,checked:i,mergedRailStyle:s,onRender:l,$slots:v}=this;l==null||l();const{checked:d,unchecked:S,icon:g,"checked-icon":u,"unchecked-icon":x}=v,b=!(G(g)&&G(u)&&G(x));return r("div",{role:"switch","aria-checked":i,class:[`${e}-switch`,this.themeClass,b&&`${e}-switch--icon`,i&&`${e}-switch--active`,o&&`${e}-switch--disabled`,this.round&&`${e}-switch--round`,this.loading&&`${e}-switch--loading`,this.pressed&&`${e}-switch--pressed`,this.rubberBand&&`${e}-switch--rubber-band`],tabindex:this.mergedDisabled?void 0:0,style:this.cssVars,onClick:this.handleClick,onFocus:this.handleFocus,onBlur:this.handleBlur,onKeyup:this.handleKeyup,onKeydown:this.handleKeydown},r("div",{class:`${e}-switch__rail`,"aria-hidden":"true",style:s},y(d,a=>y(S,m=>a||m?r("div",{"aria-hidden":!0,class:`${e}-switch__children-placeholder`},r("div",{class:`${e}-switch__rail-placeholder`},r("div",{class:`${e}-switch__button-placeholder`}),a),r("div",{class:`${e}-switch__rail-placeholder`},r("div",{class:`${e}-switch__button-placeholder`}),m)):null)),r("div",{class
|