|
|
import{c as Z,b as S,s as $o,x as co,y as To,d as F,a as v,e as so,f as uo,u as wo,g as n,z as X,h as Ho}from"./light-Cua7cqmF.js";import{c as zo}from"./context-KbjOeZY_.js";import{u as Eo}from"./use-rtl-CRyak7TN.js";import{i as Bo}from"./browser-DLIXj5nt.js";import{i as Wo,N as Fo}from"./icon-switch.cssr-BCTOxvoq.js";import{i as Do}from"./is-browser-DqcmxZSF.js";import{u as Io}from"./use-memo-BgHp9YyU.js";import{u as Go}from"./use-form-item-CNgNT5jP.js";import{c as lo}from"./color-to-class-B0iQgAn2.js";import{r as ao,i as Ro}from"./resolve-slot-Dzko3qih.js";import{u as ko}from"./use-style-qLHIyj3D.js";import{d as to,G as E,U as Oo,T as Mo,O as Lo,s as K,S as jo,Q as No,i as _o,c as Y}from"./index-bVOhw2NF.js";import{N as Ao}from"./Loading-CByrJVhO.js";import{c as Ko}from"./call-f2ri57Kd.js";const Qo=to({name:"FadeInExpandTransition",props:{appear:Boolean,group:Boolean,mode:String,onLeave:Function,onAfterLeave:Function,onAfterEnter:Function,width:Boolean,reverse:Boolean},setup(o,{slots:p}){function y(r){o.width?r.style.maxWidth=`${r.offsetWidth}px`:r.style.maxHeight=`${r.offsetHeight}px`,r.offsetWidth}function u(r){o.width?r.style.maxWidth="0":r.style.maxHeight="0",r.offsetWidth;const{onLeave:x}=o;x&&x()}function C(r){o.width?r.style.maxWidth="":r.style.maxHeight="";const{onAfterLeave:x}=o;x&&x()}function I(r){if(r.style.transition="none",o.width){const x=r.offsetWidth;r.style.maxWidth="0",r.offsetWidth,r.style.transition="",r.style.maxWidth=`${x}px`}else if(o.reverse)r.style.maxHeight=`${r.offsetHeight}px`,r.offsetHeight,r.style.transition="",r.style.maxHeight="0";else{const x=r.offsetHeight;r.style.maxHeight="0",r.offsetWidth,r.style.transition="",r.style.maxHeight=`${x}px`}r.offsetWidth}function O(r){var x;o.width?r.style.maxWidth="":o.reverse||(r.style.maxHeight=""),(x=o.onAfterEnter)===null||x===void 0||x.call(o)}return()=>{const{group:r,width:x,appear:_,mode:A}=o,g=r?Oo:Mo,j={name:x?"fade-in-width-expand-transition":"fade-in-height-expand-transition",appear:_,onEnter:I,onAfterEnter:O,onBeforeLeave:y,onLeave:u,onAfterLeave:C};return r||(j.mode=A),E(g,j,p)}}}),Vo=Z("base-wave",`
position: absolute; left: 0; right: 0; top: 0; bottom: 0; border-radius: inherit;`),qo=to({name:"BaseWave",props:{clsPrefix:{type:String,required:!0}},setup(o){ko("-base-wave",Vo,Lo(o,"clsPrefix"));const p=K(null),y=K(!1);let u=null;return jo(()=>{u!==null&&window.clearTimeout(u)}),{active:y,selfRef:p,play(){u!==null&&(window.clearTimeout(u),y.value=!1,u=null),No(()=>{var C;(C=p.value)===null||C===void 0||C.offsetHeight,y.value=!0,u=window.setTimeout(()=>{y.value=!1,u=null},1e3)})}}},render(){const{clsPrefix:o}=this;return E("div",{ref:"selfRef","aria-hidden":!0,class:[`${o}-base-wave`,this.active&&`${o}-base-wave--active`]})}}),{cubicBezierEaseInOut:k}=$o;function Uo({duration:o=".2s",delay:p=".1s"}={}){return[S("&.fade-in-width-expand-transition-leave-from, &.fade-in-width-expand-transition-enter-to",{opacity:1}),S("&.fade-in-width-expand-transition-leave-to, &.fade-in-width-expand-transition-enter-from",` opacity: 0!important; margin-left: 0!important; margin-right: 0!important; `),S("&.fade-in-width-expand-transition-leave-active",` overflow: hidden; transition: opacity ${o} ${k}, max-width ${o} ${k} ${p}, margin-left ${o} ${k} ${p}, margin-right ${o} ${k} ${p}; `),S("&.fade-in-width-expand-transition-enter-active",` overflow: hidden; transition: opacity ${o} ${k} ${p}, max-width ${o} ${k}, margin-left ${o} ${k}, margin-right ${o} ${k}; `)]}function L(o){return co(o,[255,255,255,.16])}function J(o){return co(o,[0,0,0,.12])}const Xo=zo("n-button-group"),Yo={paddingTiny:"0 6px",paddingSmall:"0 10px",paddingMedium:"0 14px",paddingLarge:"0 18px",paddingRoundTiny:"0 10px",paddingRoundSmall:"0 14px",paddingRoundMedium:"0 18px",paddingRoundLarge:"0 22px",iconMarginTiny:"6px",iconMarginSmall:"6px",iconMarginMedium:"6px",iconMarginLarge:"6px",iconSizeTiny:"14px",iconSizeSmall:"18px",iconSizeMedium:"18px",iconSizeLarge:"20px",rippleDuration:".6s"};function Jo(o){const{heightTiny:p,heightSmall:y,heightMedium:u,heightLarge:C,borderRadius:I,fontSizeTiny:O,fontSizeSmall:r,fontSizeMedium:x,fontSizeLarge:_,opacityDisabled:A,textColor2:g,textColor3:j,primaryColorHover:b,primaryColorPressed:T,borderColor:Q,primaryColor:B,baseColor:s,infoColor:W,infoColorHover:P,infoColorPressed:t,successColor:l,successColorHover:h,successColorPressed:e,warningColor:w,warningColorHover:$,warningColorPressed:G,errorColor:H,errorColorHover:f,errorColorPressed:R,fontWeight:D,buttonColor2:N,buttonColor2Hover:z,buttonColor2Pressed:a,fontWeightStrong:V}=o;return Object.assign(Object.assign({},Yo),{heightTiny:p,heightSmall:y,heightMedium:u,heightLarge:C,borderRadiusTiny:I,borderRadiusSmall:I,borderRadiusMedium:I,borderRadiusLarge:I,fontSizeTiny:O,fontSizeSmall:r,fontSizeMedium:x,fontSizeLarge:_,opacityDisabled:A,colorOpacitySecondary:"0.16",colorOpacitySecondaryHover:"0.22",colorOpacitySecondaryPressed:"0.28",colorSecondary:N,colorSecondaryHover:z,colorSecondaryPressed:a,colorTertiary:N,colorTertiaryHover:z,colorTertiaryPressed:a,colorQuaternary:"#0000",colorQuaternaryHover:z,colorQuaternaryPressed:a,color:"#0000",colorHover:"#0000",colorPressed:"#0000",colorFocus:"#0000",colorDisabled:"#0000",textColor:g,textColorTertiary:j,textColorHover:b,textColorPressed:T,textColorFocus:b,textColorDisabled:g,textColorText:g,textColorTextHover:b,textColorTextPressed:T,textColorTextFocus:b,textColorTextDisabled:g,textColorGhost:g,textColorGhostHover:b,textColorGhostPressed:T,textColorGhostFocus:b,textColorGhostDisabled:g,border:`1px solid ${Q}`,borderHover:`1px solid ${b}`,borderPressed:`1px solid ${T}`,borderFocus:`1px solid ${b}`,borderDisabled:`1px solid ${Q}`,rippleColor:B,colorPrimary:B,colorHoverPrimary:b,colorPressedPrimary:T,colorFocusPrimary:b,colorDisabledPrimary:B,textColorPrimary:s,textColorHoverPrimary:s,textColorPressedPrimary:s,textColorFocusPrimary:s,textColorDisabledPrimary:s,textColorTextPrimary:B,textColorTextHoverPrimary:b,textColorTextPressedPrimary:T,textColorTextFocusPrimary:b,textColorTextDisabledPrimary:g,textColorGhostPrimary:B,textColorGhostHoverPrimary:b,textColorGhostPressedPrimary:T,textColorGhostFocusPrimary:b,textColorGhostDisabledPrimary:B,borderPrimary:`1px solid ${B}`,borderHoverPrimary:`1px solid ${b}`,borderPressedPrimary:`1px solid ${T}`,borderFocusPrimary:`1px solid ${b}`,borderDisabledPrimary:`1px solid ${B}`,rippleColorPrimary:B,colorInfo:W,colorHoverInfo:P,colorPressedInfo:t,colorFocusInfo:P,colorDisabledInfo:W,textColorInfo:s,textColorHoverInfo:s,textColorPressedInfo:s,textColorFocusInfo:s,textColorDisabledInfo:s,textColorTextInfo:W,textColorTextHoverInfo:P,textColorTextPressedInfo:t,textColorTextFocusInfo:P,textColorTextDisabledInfo:g,textColorGhostInfo:W,textColorGhostHoverInfo:P,textColorGhostPressedInfo:t,textColorGhostFocusInfo:P,textColorGhostDisabledInfo:W,borderInfo:`1px solid ${W}`,borderHoverInfo:`1px solid ${P}`,borderPressedInfo:`1px solid ${t}`,borderFocusInfo:`1px solid ${P}`,borderDisabledInfo:`1px solid ${W}`,rippleColorInfo:W,colorSuccess:l,colorHoverSuccess:h,colorPressedSuccess:e,colorFocusSuccess:h,colorDisabledSuccess:l,textColorSuccess:s,textColorHoverSuccess:s,textColorPressedSuccess:s,textColorFocusSuccess:s,textColorDisabledSuccess:s,textColorTextSuccess:l,textColorTextHoverSuccess:h,textColorTextPressedSuccess:e,textColorTextFocusSuccess:h,textColorTextDisabledSuccess:g,textColorGhostSuccess:l,textColorGhostHoverSuccess:h,textColorGhostPressedSuccess:e,textColorGhostFocusSuccess:h,textColorGhostDisabledSuccess:l,borderSuccess:`1px solid ${ margin: 0; font-weight: var(--n-font-weight); line-height: 1; font-family: inherit; padding: var(--n-padding); height: var(--n-height); font-size: var(--n-font-size); border-radius: var(--n-border-radius); color: var(--n-text-color); background-color: var(--n-color); width: var(--n-width); white-space: nowrap; outline: none; position: relative; z-index: auto; border: none; display: inline-flex; flex-wrap: nowrap; flex-shrink: 0; align-items: center; justify-content: center; user-select: none; -webkit-user-select: none; text-align: center; cursor: pointer; text-decoration: none; transition: color .3s var(--n-bezier), background-color .3s var(--n-bezier), opacity .3s var(--n-bezier), border-color .3s var(--n-bezier); `,[F("color",[v("border",{borderColor:"var(--n-border-color)"}),F("disabled",[v("border",{borderColor:"var(--n-border-color-disabled)"})]),so("disabled",[S("&:focus",[v("state-border",{borderColor:"var(--n-border-color-focus)"})]),S("&:hover",[v("state-border",{borderColor:"var(--n-border-color-hover)"})]),S("&:active",[v("state-border",{borderColor:"var(--n-border-color-pressed)"})]),F("pressed",[v("state-border",{borderColor:"var(--n-border-color-pressed)"})])])]),F("disabled",{backgroundColor:"var(--n-color-disabled)",color:"var(--n-text-color-disabled)"},[v("border",{border:"var(--n-border-disabled)"})]),so("disabled",[S("&:focus",{backgroundColor:"var(--n-color-focus)",color:"var(--n-text-color-focus)"},[v("state-border",{border:"var(--n-border-focus)"})]),S("&:hover",{backgroundColor:"var(--n-color-hover)",color:"var(--n-text-color-hover)"},[v("state-border",{border:"var(--n-border-hover)"})]),S("&:active",{backgroundColor:"var(--n-color-pressed)",color:"var(--n-text-color-pressed)"},[v("state-border",{border:"var(--n-border-pressed)"})]),F("pressed",{backgroundColor:"var(--n-color-pressed)",color:"var(--n-text-color-pressed)"},[v("state-border",{border:"var(--n-border-pressed)"})])]),F("loading","cursor: wait;"),Z("base-wave",` pointer-events: none; top: 0; right: 0; bottom: 0; left: 0; animation-iteration-count: 1; animation-duration: var(--n-ripple-duration); animation-timing-function: var(--n-bezier-ease-out), var(--n-bezier-ease-out); `,[F("active",{zIndex:1,animationName:"button-wave-spread, button-wave-opacity"})]),Do&&"MozBoxSizing"in document.createElement("div").style?S("&::moz-focus-inner",{border:0}):null,v("border, state-border",` position: absolute; left: 0; top: 0; right: 0; bottom: 0; border-radius: inherit; transition: border-color .3s var(--n-bezier); pointer-events: none; `),v("border",{border:"var(--n-border)"}),v("state-border",{border:"var(--n-border)",borderColor:"#0000",zIndex:1}),v("icon",` margin: var(--n-icon-margin); margin-left: 0; height: var(--n-icon-size); width: var(--n-icon-size); max-width: var(--n-icon-size); font-size: var(--n-icon-size); position: relative; flex-shrink: 0; `,[Z("icon-slot",` height: var(--n-icon-size); width: var(--n-icon-size); position: absolute; left: 0; top: 50%; transform: translateY(-50%); display: flex; align-items: center; justify-content: center; `,[Wo({top:"50%",originalTransform:"translateY(-50%)"})]),Uo()]),v("content",` display: flex; align-items: center; flex-wrap: nowrap; min-width: 0; `,[S("~",[v("icon",{margin:"var(--n-icon-margin)",marginRight:0})])]),F("block",` display: flex; width: 100%; `),F("dashed",[v("border, state-border",{borderStyle:"dashed !important"})]),F("disabled",{cursor:"not-allowed",opacity:"var(--n-opacity-disabled)"})]),S("@keyframes button-wave-spread",{from:{boxShadow:"0 0 0.5px 0 var(--n-ripple-color)"},to:{boxShadow:"0 0 0.5px 4.5px var(--n-ripple-color)"}}),S("@keyframes button-wave-opacity",{from:{opacity:"var(--n-wave-opacity)"},to:{opacity:0}})]),ee=Object.assign(Object.assign({},uo.props),{color:String,textColor:String,text:Boolean,block:Boolean,loading:Boolean,disabled:Boolean,circle:Boolean,size:String,ghost:Boolean,round:Boolean,secondary:Boolean,tertiary:Boolean,quaternary:Boolean,strong:Boolean,focusable:{type:Boolean,default:!0},keyboard:{type:Boolean,default:!0},tag:{type:String,default:"button"},type:{type:String,default:"default"},dashed:Boolean,renderIcon:Function,iconPlacement:{type:String,default:"left"},attrType:{type:String,default:"button"},bordered:{type:Boolean,default:!0},onClick:[Function,Array],nativeFocusBehavior:{type:Boolean,default:!Bo}}),re=to({name:"Button",props:ee,setup(o){const p=K(null),y=K(null),u=K(!1),C=Io(()=>!o.quaternary&&!o.tertiary&&!o.secondary&&!o.text&&(!o.color||o.ghost||o.dashed)&&o.bordered),I=_o(Xo,{}),{mergedSizeRef:O}=Go({},{defaultSize:"medium",mergedSize:t=>{const{size:l}=o;if(l)return l;const{size:h}=I;if(h)return h;const{mergedSize:e}=t||{};return e?e.value:"medium"}}),r=Y(()=>o.focusable&&!o.disabled),x=t=>{var l;r.value||t.preventDefault(),!o.nativeFocusBehavior&&(t.preventDefault(),!o.disabled&&r.value&&((l=p.value)===null||l===void 0||l.focus({preventScroll:!0})))},_=t=>{var l;if(!o.disabled&&!o.loading){const{onClick:h}=o;h&&Ko(h,t),o.text||(l=y.value)===null||l===void 0||l.play()}},A=t=>{switch(t.key){case"Enter":if(!o.keyboard)return;u.value=!1}},g=t=>{switch(t.key){case"Enter":if(!o.keyboard||o.loading){t.preventDefault();return}u.value=!0}},j=()=>{u.value=!1},{inlineThemeDisabled:b,mergedClsPrefixRef:T,mergedRtlRef:Q}=wo(o),B=uo("Button","-button",oe,Zo,o,T),s=Eo("Button",Q,T),W=Y(()=>{const t=B.value,{common:{cubicBezierEaseInOut:l,cubicBezierEaseOut:h},self:e}=t,{rippleDuration:w,opacityDisabled:$,fontWeight:G,fontWeightStrong:H}=e,f=O.value,{dashed:R,type:D,ghost:N,text:z,color:a,round:V,circle:oo,textColor:M,secondary:xo,tertiary:no,quaternary:bo,strong:fo}=o,ho={"font-weight":fo?H:G};let d={"--n-color":"initial","--n-color-hover":"initial","--n-color-pressed":"initial","--n-color-focus":"initial","--n-color-disabled":"initial","--n-ripple-color":"initial","--n-text-color":"initial","--n-text-color-hover":"initial","--n-text-color-pressed":"initial","--n-text-color-focus":"initial","--n-text-color-disabled":"initial"};const q=D==="tertiary",io=D==="default",i=q?"default":D;if(z){const c=M||a;d={"--n-color":"#0000","--n-color-hover":"#0000","--n-color-pressed":"#0000","--n-color-focus":"#0000","--n-color-disabled":"#0000","--n-ripple-color":"#0000","--n-text-color":c||e[n("textColorText",i)],"--n-text-color-hover":c?L(c):e[n("textColorTextHover",i)],"--n-text-color-pressed":c?J(c):e[n("textColorTextPressed",i)],"--n-text-color-focus":c?L(c):e[n("textColorTextHover",i)],"--n-text-color-disabled":c||e[n("textColorTextDisabled",i)]}}else if(N||R){const c=M||a;d={"--n-color":"#0000","--n-color-hover":"#0000","--n-color-pressed":"#0000","--n-color-focus":"#0000","--n-color-disabled":"#0000","--n-ripple-color":a||e[n("rippleColor",i)],"--n-text-color":c||e[n("textColorGhost",i)],"--n-text-color-hover":c?L(c):e[n("textColorGhostHover",i)],"--n-text-color-pressed":c?J(c):e[n("textColorGhostPressed",i)],"--n-text-color-focus":c?L(c):e[n("textColorGhostHover",i)],"--n-text-color-disabled":c||e[n("textColorGhostDisabled",i)]}}else if(xo){const c=io?e.textColor:q?e.textColorTertiary:e[n("color",i)],m=a||c,U=D!=="default"&&D!=="tertiary";d={"--n-color":U?X(m,{alpha:Number(e.colorOpacitySecondary)}):e.colorSecondary,"--n-color-hover":U?X(m,{alpha:Number(e.colorOpacitySecondaryHover)}):e.colorSecondaryHover,"--n-color-pressed":U?X(m,{alpha:Number(e.colorOpacitySecondaryPressed)}):e.colorSecondaryPressed,"--n-color-focus":U?X(m,{a
|