generated from VLADIMIR/template_frontend
109 lines
16 KiB
JavaScript
109 lines
16 KiB
JavaScript
import{A as e,E as t,H as n,I as r,N as i,f as a,k as o,ot as s,p as c,rt as l,v as u,w as d}from"./vue-router-CyfP71JJ.js";import{B as f,G as p,I as m,J as h,K as g,M as _,N as v,V as y,X as b,Y as x,Z as S,a as C,i as w,o as T,r as E,z as D}from"./light-CPiNeYrP.js";import{a as O,n as k}from"./resolve-slot-tPBGpQg9.js";import{n as A,t as j}from"./call-ChHlm4-m.js";import{A as M,B as N,J as P,M as F,P as I,d as L,x as R}from"./index-_XzMCfId.js";var z=typeof document<`u`&&typeof window<`u`;function B(e,t=!0,n=[]){return e.forEach(e=>{if(e!==null){if(typeof e!=`object`){(typeof e==`string`||typeof e==`number`)&&n.push(d(String(e)));return}if(Array.isArray(e)){B(e,t,n);return}if(e.type===c){if(e.children===null)return;Array.isArray(e.children)&&B(e.children,t,n)}else{if(e.type===a&&t)return;n.push(e)}}}),n}var V=D(`n-form-item`);function H(t,{defaultSize:i=`medium`,mergedSize:a,mergedDisabled:o}={}){let s=e(V,null);n(V,null);let c=u(a?()=>a(s):()=>{let{size:e}=t;if(e)return e;if(s){let{mergedSize:e}=s;if(e.value!==void 0)return e.value}return i}),l=u(o?()=>o(s):()=>{let{disabled:e}=t;return e===void 0?s?s.disabled.value:!1:e}),d=u(()=>{let{status:e}=t;return e||s?.mergedValidationStatus.value});return r(()=>{s&&s.restoreValidation()}),{mergedSizeRef:c,mergedDisabledRef:l,mergedStatusRef:d,nTriggerFormBlur(){s&&s.handleContentBlur()},nTriggerFormChange(){s&&s.handleContentChange()},nTriggerFormFocus(){s&&s.handleContentFocus()},nTriggerFormInput(){s&&s.handleContentInput()}}}var{cubicBezierEaseInOut:U}=C;function W({duration:e=`.2s`,delay:t=`.1s`}={}){return[p(`&.fade-in-width-expand-transition-leave-from, &.fade-in-width-expand-transition-enter-to`,{opacity:1}),p(`&.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;
|
|
`),p(`&.fade-in-width-expand-transition-leave-active`,`
|
|
overflow: hidden;
|
|
transition:
|
|
opacity ${e} ${U},
|
|
max-width ${e} ${U} ${t},
|
|
margin-left ${e} ${U} ${t},
|
|
margin-right ${e} ${U} ${t};
|
|
`),p(`&.fade-in-width-expand-transition-enter-active`,`
|
|
overflow: hidden;
|
|
transition:
|
|
opacity ${e} ${U} ${t},
|
|
max-width ${e} ${U},
|
|
margin-left ${e} ${U},
|
|
margin-right ${e} ${U};
|
|
`)]}var G=g(`base-wave`,`
|
|
position: absolute;
|
|
left: 0;
|
|
right: 0;
|
|
top: 0;
|
|
bottom: 0;
|
|
border-radius: inherit;
|
|
`),K=t({name:`BaseWave`,props:{clsPrefix:{type:String,required:!0}},setup(e){w(`-base-wave`,G,s(e,`clsPrefix`));let t=l(null),n=l(!1),a=null;return r(()=>{a!==null&&window.clearTimeout(a)}),{active:n,selfRef:t,play(){a!==null&&(window.clearTimeout(a),n.value=!1,a=null),i(()=>{var e;(e=t.value)==null||e.offsetHeight,n.value=!0,a=window.setTimeout(()=>{n.value=!1,a=null},1e3)})}}},render(){let{clsPrefix:e}=this;return o(`div`,{ref:`selfRef`,"aria-hidden":!0,class:[`${e}-base-wave`,this.active&&`${e}-base-wave--active`]})}}),q=z&&`chrome`in window;z&&navigator.userAgent.includes(`Firefox`);var J=z&&navigator.userAgent.includes(`Safari`)&&!q;function Y(e){return y(e,[255,255,255,.16])}function X(e){return y(e,[0,0,0,.12])}var Z=D(`n-button-group`),Q=p([g(`button`,`
|
|
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);
|
|
`,[x(`color`,[h(`border`,{borderColor:`var(--n-border-color)`}),x(`disabled`,[h(`border`,{borderColor:`var(--n-border-color-disabled)`})]),b(`disabled`,[p(`&:focus`,[h(`state-border`,{borderColor:`var(--n-border-color-focus)`})]),p(`&:hover`,[h(`state-border`,{borderColor:`var(--n-border-color-hover)`})]),p(`&:active`,[h(`state-border`,{borderColor:`var(--n-border-color-pressed)`})]),x(`pressed`,[h(`state-border`,{borderColor:`var(--n-border-color-pressed)`})])])]),x(`disabled`,{backgroundColor:`var(--n-color-disabled)`,color:`var(--n-text-color-disabled)`},[h(`border`,{border:`var(--n-border-disabled)`})]),b(`disabled`,[p(`&:focus`,{backgroundColor:`var(--n-color-focus)`,color:`var(--n-text-color-focus)`},[h(`state-border`,{border:`var(--n-border-focus)`})]),p(`&:hover`,{backgroundColor:`var(--n-color-hover)`,color:`var(--n-text-color-hover)`},[h(`state-border`,{border:`var(--n-border-hover)`})]),p(`&:active`,{backgroundColor:`var(--n-color-pressed)`,color:`var(--n-text-color-pressed)`},[h(`state-border`,{border:`var(--n-border-pressed)`})]),x(`pressed`,{backgroundColor:`var(--n-color-pressed)`,color:`var(--n-text-color-pressed)`},[h(`state-border`,{border:`var(--n-border-pressed)`})])]),x(`loading`,`cursor: wait;`),g(`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);
|
|
`,[x(`active`,{zIndex:1,animationName:`button-wave-spread, button-wave-opacity`})]),z&&`MozBoxSizing`in document.createElement(`div`).style?p(`&::moz-focus-inner`,{border:0}):null,h(`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;
|
|
`),h(`border`,`
|
|
border: var(--n-border);
|
|
`),h(`state-border`,`
|
|
border: var(--n-border);
|
|
border-color: #0000;
|
|
z-index: 1;
|
|
`),h(`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;
|
|
`,[g(`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;
|
|
`,[I({top:`50%`,originalTransform:`translateY(-50%)`})]),W()]),h(`content`,`
|
|
display: flex;
|
|
align-items: center;
|
|
flex-wrap: nowrap;
|
|
min-width: 0;
|
|
`,[p(`~`,[h(`icon`,{margin:`var(--n-icon-margin)`,marginRight:0})])]),x(`block`,`
|
|
display: flex;
|
|
width: 100%;
|
|
`),x(`dashed`,[h(`border, state-border`,{borderStyle:`dashed !important`})]),x(`disabled`,{cursor:`not-allowed`,opacity:`var(--n-opacity-disabled)`})]),p(`@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)`}}),p(`@keyframes button-wave-opacity`,{from:{opacity:`var(--n-wave-opacity)`},to:{opacity:0}})]),$=t({name:`Button`,props:Object.assign(Object.assign({},E.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:!J},spinProps:Object}),slots:Object,setup(t){let n=l(null),r=l(null),i=l(!1),a=P(()=>!t.quaternary&&!t.tertiary&&!t.secondary&&!t.text&&(!t.color||t.ghost||t.dashed)&&t.bordered),o=e(Z,{}),{inlineThemeDisabled:s,mergedClsPrefixRef:c,mergedRtlRef:d,mergedComponentPropsRef:p}=v(t),{mergedSizeRef:m}=H({},{defaultSize:`medium`,mergedSize:e=>{let{size:n}=t;if(n)return n;let{size:r}=o;if(r)return r;let{mergedSize:i}=e||{};return i?i.value:p?.value?.Button?.size||`medium`}}),h=u(()=>t.focusable&&!t.disabled),g=e=>{var r;h.value||e.preventDefault(),!t.nativeFocusBehavior&&(e.preventDefault(),!t.disabled&&h.value&&((r=n.value)==null||r.focus({preventScroll:!0})))},y=e=>{var n;if(!t.disabled&&!t.loading){let{onClick:i}=t;i&&j(i,e),t.text||(n=r.value)==null||n.play()}},b=e=>{switch(e.key){case`Enter`:if(!t.keyboard)return;i.value=!1}},x=e=>{switch(e.key){case`Enter`:if(!t.keyboard||t.loading){e.preventDefault();return}i.value=!0}},C=()=>{i.value=!1},w=E(`Button`,`-button`,Q,R,t,c),D=T(`Button`,d,c),O=u(()=>{let{common:{cubicBezierEaseInOut:e,cubicBezierEaseOut:n},self:r}=w.value,{rippleDuration:i,opacityDisabled:a,fontWeight:o,fontWeightStrong:s}=r,c=m.value,{dashed:l,type:u,ghost:d,text:p,color:h,round:g,circle:_,textColor:v,secondary:y,tertiary:b,quaternary:x,strong:C}=t,T={"--n-font-weight":C?s:o},E={"--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`},D=u===`tertiary`,O=u==="default",k=D?`default`:u;if(p){let e=v||h;E={"--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":e||r[S(`textColorText`,k)],"--n-text-color-hover":e?Y(e):r[S(`textColorTextHover`,k)],"--n-text-color-pressed":e?X(e):r[S(`textColorTextPressed`,k)],"--n-text-color-focus":e?Y(e):r[S(`textColorTextHover`,k)],"--n-text-color-disabled":e||r[S(`textColorTextDisabled`,k)]}}else if(d||l){let e=v||h;E={"--n-color":`#0000`,"--n-color-hover":`#0000`,"--n-color-pressed":`#0000`,"--n-color-focus":`#0000`,"--n-color-disabled":`#0000`,"--n-ripple-color":h||r[S(`rippleColor`,k)],"--n-text-color":e||r[S(`textColorGhost`,k)],"--n-text-color-hover":e?Y(e):r[S(`textColorGhostHover`,k)],"--n-text-color-pressed":e?X(e):r[S(`textColorGhostPressed`,k)],"--n-text-color-focus":e?Y(e):r[S(`textColorGhostHover`,k)],"--n-text-color-disabled":e||r[S(`textColorGhostDisabled`,k)]}}else if(y){let e=O?r.textColor:D?r.textColorTertiary:r[S(`color`,k)],t=h||e,n=u!=="default"&&u!==`tertiary`;E={"--n-color":n?f(t,{alpha:Number(r.colorOpacitySecondary)}):r.colorSecondary,"--n-color-hover":n?f(t,{alpha:Number(r.colorOpacitySecondaryHover)}):r.colorSecondaryHover,"--n-color-pressed":n?f(t,{alpha:Number(r.colorOpacitySecondaryPressed)}):r.colorSecondaryPressed,"--n-color-focus":n?f(t,{alpha:Number(r.colorOpacitySecondaryHover)}):r.colorSecondaryHover,"--n-color-disabled":r.colorSecondary,"--n-ripple-color":`#0000`,"--n-text-color":t,"--n-text-color-hover":t,"--n-text-color-pressed":t,"--n-text-color-focus":t,"--n-text-color-disabled":t}}else if(b||x){let e=O?r.textColor:D?r.textColorTertiary:r[S(`color`,k)],t=h||e;b?(E[`--n-color`]=r.colorTertiary,E[`--n-color-hover`]=r.colorTertiaryHover,E[`--n-color-pressed`]=r.colorTertiaryPressed,E[`--n-color-focus`]=r.colorSecondaryHover,E[`--n-color-disabled`]=r.colorTertiary):(E[`--n-color`]=r.colorQuaternary,E[`--n-color-hover`]=r.colorQuaternaryHover,E[`--n-color-pressed`]=r.colorQuaternaryPressed,E[`--n-color-focus`]=r.colorQuaternaryHover,E[`--n-color-disabled`]=r.colorQuaternary),E[`--n-ripple-color`]=`#0000`,E[`--n-text-color`]=t,E[`--n-text-color-hover`]=t,E[`--n-text-color-pressed`]=t,E[`--n-text-color-focus`]=t,E[`--n-text-color-disabled`]=t}else E={"--n-color":h||r[S(`color`,k)],"--n-color-hover":h?Y(h):r[S(`colorHover`,k)],"--n-color-pressed":h?X(h):r[S(`colorPressed`,k)],"--n-color-focus":h?Y(h):r[S(`colorFocus`,k)],"--n-color-disabled":h||r[S(`colorDisabled`,k)],"--n-ripple-color":h||r[S(`rippleColor`,k)],"--n-text-color":v||(h?r.textColorPrimary:D?r.textColorTertiary:r[S(`textColor`,k)]),"--n-text-color-hover":v||(h?r.textColorHoverPrimary:r[S(`textColorHover`,k)]),"--n-text-color-pressed":v||(h?r.textColorPressedPrimary:r[S(`textColorPressed`,k)]),"--n-text-color-focus":v||(h?r.textColorFocusPrimary:r[S(`textColorFocus`,k)]),"--n-text-color-disabled":v||(h?r.textColorDisabledPrimary:r[S(`textColorDisabled`,k)])};let A={"--n-border":`initial`,"--n-border-hover":`initial`,"--n-border-pressed":`initial`,"--n-border-focus":`initial`,"--n-border-disabled":`initial`};A=p?{"--n-border":`none`,"--n-border-hover":`none`,"--n-border-pressed":`none`,"--n-border-focus":`none`,"--n-border-disabled":`none`}:{"--n-border":r[S(`border`,k)],"--n-border-hover":r[S(`borderHover`,k)],"--n-border-pressed":r[S(`borderPressed`,k)],"--n-border-focus":r[S(`borderFocus`,k)],"--n-border-disabled":r[S(`borderDisabled`,k)]};let{[S(`height`,c)]:j,[S(`fontSize`,c)]:M,[S(`padding`,c)]:N,[S(`paddingRound`,c)]:P,[S(`iconSize`,c)]:F,[S(`borderRadius`,c)]:I,[S(`iconMargin`,c)]:L,waveOpacity:R}=r,z={"--n-width":_&&!p?j:`initial`,"--n-height":p?`initial`:j,"--n-font-size":M,"--n-padding":_||p?`initial`:g?P:N,"--n-icon-size":F,"--n-icon-margin":L,"--n-border-radius":p?`initial`:_||g?j:I};return Object.assign(Object.assign(Object.assign(Object.assign({"--n-bezier":e,"--n-bezier-ease-out":n,"--n-ripple-duration":i,"--n-opacity-disabled":a,"--n-wave-opacity":R},T),E),A),z)}),k=s?_(`button`,u(()=>{let e=``,{dashed:n,type:r,ghost:i,text:a,color:o,round:s,circle:c,textColor:l,secondary:u,tertiary:d,quaternary:f,strong:p}=t;n&&(e+=`a`),i&&(e+=`b`),a&&(e+=`c`),s&&(e+=`d`),c&&(e+=`e`),u&&(e+=`f`),d&&(e+=`g`),f&&(e+=`h`),p&&(e+=`i`),o&&(e+=`j${A(o)}`),l&&(e+=`k${A(l)}`);let{value:h}=m;return e+=`l${h[0]}`,e+=`m${r[0]}`,e}),O,t):void 0;return{selfElRef:n,waveElRef:r,mergedClsPrefix:c,mergedFocusable:h,mergedSize:m,showBorder:a,enterPressed:i,rtlEnabled:D,handleMousedown:g,handleKeydown:x,handleBlur:C,handleKeyup:b,handleClick:y,customColorCssVars:u(()=>{let{color:e}=t;if(!e)return null;let n=Y(e);return{"--n-border-color":e,"--n-border-color-hover":n,"--n-border-color-pressed":X(e),"--n-border-color-focus":n,"--n-border-color-disabled":e}}),cssVars:s?void 0:O,themeClass:k?.themeClass,onRender:k?.onRender}},render(){let{mergedClsPrefix:e,tag:t,onRender:n}=this;n?.();let r=O(this.$slots.default,t=>t&&o(`span`,{class:`${e}-button__content`},t));return o(t,{ref:`selfElRef`,class:[this.themeClass,`${e}-button`,`${e}-button--${this.type}-type`,`${e}-button--${this.mergedSize}-type`,this.rtlEnabled&&`${e}-button--rtl`,this.disabled&&`${e}-button--disabled`,this.block&&`${e}-button--block`,this.enterPressed&&`${e}-button--pressed`,!this.text&&this.dashed&&`${e}-button--dashed`,this.color&&`${e}-button--color`,this.secondary&&`${e}-button--secondary`,this.loading&&`${e}-button--loading`,this.ghost&&`${e}-button--ghost`],tabindex:this.mergedFocusable?0:-1,type:this.attrType,style:this.cssVars,disabled:this.disabled,onClick:this.handleClick,onBlur:this.handleBlur,onMousedown:this.handleMousedown,onKeyup:this.handleKeyup,onKeydown:this.handleKeydown},this.iconPlacement===`right`&&r,o(F,{width:!0},{default:()=>O(this.$slots.icon,t=>(this.loading||this.renderIcon||t)&&o(`span`,{class:`${e}-button__icon`,style:{margin:k(this.$slots.default)?`0`:``}},o(N,null,{default:()=>this.loading?o(M,Object.assign({clsPrefix:e,key:`loading`,class:`${e}-icon-slot`,strokeWidth:20},this.spinProps)):o(`div`,{key:`icon`,class:`${e}-icon-slot`,role:`none`},this.renderIcon?this.renderIcon():t)})))}),this.iconPlacement===`left`&&r,this.text?null:o(K,{ref:`waveElRef`,clsPrefix:e}),this.showBorder?o(`div`,{"aria-hidden":!0,class:`${e}-button__border`,style:this.customColorCssVars}):null,this.showBorder?o(`div`,{"aria-hidden":!0,class:`${e}-button__state-border`,style:this.customColorCssVars}):null)}}),ee=$;function te(){let t=e(L,null);return t===null&&m(`use-message`,"No outer <n-message-provider /> founded. See prerequisite in https://www.naiveui.com/en-US/os-theme/components/message for more details. If you want to use `useMessage` outside setup, please check https://www.naiveui.com/zh-CN/os-theme/components/message#Q-&-A."),t}export{J as a,B as c,Z as i,z as l,$ as n,V as o,ee as r,H as s,te as t}; |