|
|
import{i as ar}from"./browser-DLIXj5nt.js";import{u as ir}from"./use-rtl-CRyak7TN.js";import{c as lr}from"./context-KbjOeZY_.js";import{d as Z,G as a,s as w,t as ue,i as sr,c as F,O as ge,v as cr,R as ur,E as be,P as dr,F as fr,Q as me}from"./index-bVOhw2NF.js";import{b as hr,r as q,a as se}from"./resolve-slot-Dzko3qih.js";import{c as b,a as l,b as C,d as z,e as K,u as vr,f as Ae,g as ce,h as pr}from"./light-Cua7cqmF.js";import{i as gr}from"./light-MOj96jwO.js";import{u as br}from"./use-style-qLHIyj3D.js";import{u as mr}from"./use-locale-CFjRjALw.js";import{u as xr}from"./use-merged-state-CzrzZJbg.js";import{u as wr}from"./use-form-item-CNgNT5jP.js";import{u as xe}from"./use-memo-BgHp9YyU.js";import{g as yr}from"./index-C-nsH7mf.js";import{N as we,a as Cr}from"./Suffix-BqBRFVnL.js";import{S as zr}from"./Scrollbar-DVK2lT9w.js";import{V as Sr}from"./VResizeObserver-Tzd5ds8d.js";import{o as ye,a as Ce}from"./delegate-CI_DDEu_.js";import{c as y}from"./call-f2ri57Kd.js";import{N as ze}from"./Icon-Ck7Ij_E6.js";const Ar=Z({name:"Eye",render(){return a("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512"},a("path",{d:"M255.66 112c-77.94 0-157.89 45.11-220.83 135.33a16 16 0 0 0-.27 17.77C82.92 340.8 161.8 400 255.66 400c92.84 0 173.34-59.38 221.79-135.25a16.14 16.14 0 0 0 0-17.47C428.89 172.28 347.8 112 255.66 112z",fill:"none",stroke:"currentColor","stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"32"}),a("circle",{cx:"256",cy:"256",r:"80",fill:"none",stroke:"currentColor","stroke-miterlimit":"10","stroke-width":"32"}))}}),_r=Z({name:"EyeOff",render(){return a("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 512 512"},a("path",{d:"M432 448a15.92 15.92 0 0 1-11.31-4.69l-352-352a16 16 0 0 1 22.62-22.62l352 352A16 16 0 0 1 432 448z",fill:"currentColor"}),a("path",{d:"M255.66 384c-41.49 0-81.5-12.28-118.92-36.5c-34.07-22-64.74-53.51-88.7-91v-.08c19.94-28.57 41.78-52.73 65.24-72.21a2 2 0 0 0 .14-2.94L93.5 161.38a2 2 0 0 0-2.71-.12c-24.92 21-48.05 46.76-69.08 76.92a31.92 31.92 0 0 0-.64 35.54c26.41 41.33 60.4 76.14 98.28 100.65C162 402 207.9 416 255.66 416a239.13 239.13 0 0 0 75.8-12.58a2 2 0 0 0 .77-3.31l-21.58-21.58a4 4 0 0 0-3.83-1a204.8 204.8 0 0 1-51.16 6.47z",fill:"currentColor"}),a("path",{d:"M490.84 238.6c-26.46-40.92-60.79-75.68-99.27-100.53C349 110.55 302 96 255.66 96a227.34 227.34 0 0 0-74.89 12.83a2 2 0 0 0-.75 3.31l21.55 21.55a4 4 0 0 0 3.88 1a192.82 192.82 0 0 1 50.21-6.69c40.69 0 80.58 12.43 118.55 37c34.71 22.4 65.74 53.88 89.76 91a.13.13 0 0 1 0 .16a310.72 310.72 0 0 1-64.12 72.73a2 2 0 0 0-.15 2.95l19.9 19.89a2 2 0 0 0 2.7.13a343.49 343.49 0 0 0 68.64-78.48a32.2 32.2 0 0 0-.1-34.78z",fill:"currentColor"}),a("path",{d:"M256 160a95.88 95.88 0 0 0-21.37 2.4a2 2 0 0 0-1 3.38l112.59 112.56a2 2 0 0 0 3.38-1A96 96 0 0 0 256 160z",fill:"currentColor"}),a("path",{d:"M165.78 233.66a2 2 0 0 0-3.38 1a96 96 0 0 0 115 115a2 2 0 0 0 1-3.38z",fill:"currentColor"}))}}),_e=lr("n-input");function Rr(r){let m=0;for(const n of r)m++;return m}function J(r){return r===""||r==null}function Fr(r){const m=w(null);function n(){const{value:g}=r;if(!(g!=null&&g.focus)){_();return}const{selectionStart:f,selectionEnd:s,value:u}=g;if(f==null||s==null){_();return}m.value={start:f,end:s,beforeText:u.slice(0,f),afterText:u.slice(s)}}function A(){var g;const{value:f}=m,{value:s}=r;if(!f||!s)return;const{value:u}=s,{start:c,beforeText:i,afterText:p}=f;let x=u.length;if(u.endsWith(p))x=u.length-p.length;else if(u.startsWith(i))x=i.length;else{const T=i[c-1],S=u.indexOf(T,c-1);S!==-1&&(x=S+1)}(g=s.setSelectionRange)===null||g===void 0||g.call(s,x,x)}function _(){m.value=null}return ue(r,_),{recordCursor:n,restoreCursor:A}}const Se=Z({name:"InputWordCount",setup(r,{slots:m}){const{mergedValueRef:n,maxlengthRef:A,mergedClsPrefixRef:_,countGraphemesRef:g}=sr(_e),f=F(()=>{const{value:s}=n;return s===null||Array.isArray(s)?0:(g.value||Rr)(s)});return()=>{const{value:s}=A,{value:u}=n;return a("span",{class:`${_.value}-input-word-count`},hr(m.default,{value:u===null||Array.isArray(u)?"":u},()=>[s===void 0?f.value:`${f.value} /
max-width: 100%; cursor: text; line-height: 1.5; z-index: auto; outline: none; box-sizing: border-box; position: relative; display: inline-flex; border-radius: var(--n-border-radius); background-color: var(--n-color); transition: background-color .3s var(--n-bezier); font-size: var(--n-font-size); --n-padding-vertical: calc((var(--n-height) - 1.5 * var(--n-font-size)) / 2);`,[l("input, textarea",` overflow: hidden; flex-grow: 1; position: relative; `),l("input-el, textarea-el, input-mirror, textarea-mirror, separator, placeholder",` box-sizing: border-box; font-size: inherit; line-height: 1.5; font-family: inherit; border: none; outline: none; background-color: #0000; text-align: inherit; transition: -webkit-text-fill-color .3s var(--n-bezier), caret-color .3s var(--n-bezier), color .3s var(--n-bezier), text-decoration-color .3s var(--n-bezier); `),l("input-el, textarea-el",` -webkit-appearance: none; scrollbar-width: none; width: 100%; min-width: 0; text-decoration-color: var(--n-text-decoration-color); color: var(--n-text-color); caret-color: var(--n-caret-color); background-color: transparent; `,[C("&::-webkit-scrollbar, &::-webkit-scrollbar-track-piece, &::-webkit-scrollbar-thumb",` width: 0; height: 0; display: none; `),C("&::placeholder",` color: #0000; -webkit-text-fill-color: transparent !important; `),C("&:-webkit-autofill ~",[l("placeholder","display: none;")])]),z("round",[K("textarea","border-radius: calc(var(--n-height) / 2);")]),l("placeholder",` pointer-events: none; position: absolute; left: 0; right: 0; top: 0; bottom: 0; overflow: hidden; color: var(--n-placeholder-color); `,[C("span",` width: 100%; display: inline-block; `)]),z("textarea",[l("placeholder","overflow: visible;")]),K("autosize","width: 100%;"),z("autosize",[l("textarea-el, input-el",` position: absolute; top: 0; left: 0; height: 100%; `)]),b("input-wrapper",` overflow: hidden; display: inline-flex; flex-grow: 1; position: relative; padding-left: var(--n-padding-left); padding-right: var(--n-padding-right); `),l("input-mirror",` padding: 0; height: var(--n-height); line-height: var(--n-height); overflow: hidden; visibility: hidden; position: static; white-space: pre; pointer-events: none; `),l("input-el",` padding: 0; height: var(--n-height); line-height: var(--n-height); `,[C("&[type=password]::-ms-reveal","display: none;"),C("+",[l("placeholder",` display: flex; align-items: center; `)])]),K("textarea",[l("placeholder","white-space: nowrap;")]),l("eye",` display: flex; align-items: center; justify-content: center; transition: color .3s var(--n-bezier); `),z("textarea","width: 100%;",[b("input-word-count",` position: absolute; right: var(--n-padding-right); bottom: var(--n-padding-vertical); `),z("resizable",[b("input-wrapper",` resize: vertical; min-height: var(--n-height); `)]),l("textarea-el, textarea-mirror, placeholder",` height: 100%; padding-left: 0; padding-right: 0; padding-top: var(--n-padding-vertical); padding-bottom: var(--n-padding-vertical); word-break: break-word; display: inline-block; vertical-align: bottom; box-sizing: border-box; line-height: var(--n-line-height-textarea); margin: 0; resize: none; white-space: pre-wrap; scroll-padding-block-end: var(--n-padding-vertical); `),l("textarea-mirror",` width: 100%; pointer-events: none; overflow: hidden; visibility: hidden; position: static; white-space: pre-wrap; overflow-wrap: break-word; `)]),z("pair",[l("input-el, placeholder","text-align: center;"),l("separator",` display: flex; align-items: center; transition: color .3s var(--n-bezier); color: var(--n-text-color); white-space: nowrap; `,[b("icon",` color: var(--n-icon-color); `),b("base-icon",` color: var(--n-icon-color); `)])]),z("disabled",` cursor: not-allowed; background-color: var(--n-color-disabled); `,[l("border","border: var(--n-border-disabled);"),l("input-el, textarea-el",` cursor: not-allowed; color: var(--n-text-color-disabled); text-decoration-color: var(--n-text-color-disabled); `),l("placeholder","color: var(--n-placeholder-color-disabled);"),l("separator","color: var(--n-text-color-disabled);",[b("icon",` color: var(--n-icon-color-disabled); `),b("base-icon",` color: var(--n-icon-color-disabled); `)]),b("input-word-count",` color: var(--n-count-text-color-disabled); `),l("suffix, prefix","color: var(--n-text-color-disabled);",[b("icon",` color: var(--n-icon-color-disabled); `),b("internal-icon",` color: var(--n-icon-color-disabled); `)])]),K("disabled",[l("eye",` color: var(--n-icon-color); cursor: pointer; `,[C("&:hover",` color: var(--n-icon-color-hover); `),C("&:active",` color: var(--n-icon-color-pressed); `)]),C("&:hover",[l("state-border","border: var(--n-border-hover);")]),z("focus","background-color: var(--n-color-focus);",[l("state-border",` border: var(--n-border-focus); box-shadow: var(--n-box-shadow-focus); `)])]),l("border, state-border",` box-sizing: border-box; position: absolute; left: 0; right: 0; top: 0; bottom: 0; pointer-events: none; border-radius: inherit; border: var(--n-border); transition: box-shadow .3s var(--n-bezier), border-color .3s var(--n-bezier); `),l("state-border",` border-color: #0000; z-index: 1; `),l("prefix","margin-right: 4px;"),l("suffix",` margin-left: 4px; `),l("suffix, prefix",` transition: color .3s var(--n-bezier); flex-wrap: nowrap; flex-shrink: 0; line-height: var(--n-height); white-space: nowrap; display: inline-flex; align-items: center; justify-content: center; color: var(--n-suffix-text-color); `,[b("base-loading",` font-size: var(--n-icon-size); margin: 0 2px; color: var(--n-loading-color); `),b("base-clear",` font-size: var(--n-icon-size); `,[l("placeholder",[b("base-icon",` transition: color .3s var(--n-bezier); color: var(--n-icon-color); font-size: var(--n-icon-size); `)])]),C(">",[b("icon",` transition: color .3s var(--n-bezier); color: var(--n-icon-color); font-size: var(--n-icon-size); `)]),b("base-icon",` font-size: var(--n-icon-size); `)]),b("input-word-count",` pointer-events: none; line-height: 1.5; font-size: .85em; color: var(--n-count-text-color); transition: color .3s var(--n-bezier); margin-left: 4px; font-variant: tabular-nums; `),["warning","error"].map(r=>z(`${r}-status`,[K("disabled",[b("base-loading",` color: var(--n-loading-color-${r}) `),l("input-el, textarea-el",` caret-color: var(--n-caret-color-${r}); `),l("state-border",` border: var(--n-border-${r}); `),C("&:hover",[l("state-border",` border: var(--n-border-hover-${r}); `)]),C("&:focus",` background-color: var(--n-color-focus-${r}); `,[l("state-border",` box-shadow: var(--n-box-shadow-focus-${r}); border: var(--n-border-focus-${r}); `)]),z("focus",` background-color: var(--n-color-focus-${r}); `,[l("state-border",` box-shadow: var(--n-box-shadow-focus-${r}); border: var(--n-border-focus-${r}); `)])])]))]),Er=b("input",[z("disabled",[l("input-el, textarea-el",` -webkit-text-fill-color: var(--n-text-color-disabled); `)])]),Pr=Object.assign(Object.assign({},Ae.props),{bordered:{type:Boolean,default:void 0},type:{type:String,default:"text"},placeholder:[Array,String],defaultValue:{type:[String,Array],default:null},value:[String,Array],disabled:{type:Boolean,default:void 0},size:String,rows:{type:[Number,String],default:3},round:Boolean,minlength:[String,Number],maxlength:[String,Number],clearable:Boolean,autosize:{type:[Boolean,Object],default:!1},pair:Boolean,separator:String,readonly:{type:[String,Boolean],default:!1},passivelyActivated:Boolean,showPasswordOn:String,stateful:{type:Boolean,default:!0},autofocus:Boolean,inputProps:Object,resizable:{type:Boolean,default:!0},showCount:Boolean,loading:{type:Boolean,default:void 0},allowInput:Function,renderCount:Function,onMousedown:Function,onKeydown:Function,onKeyup:[Function,Array],onInput:[Function,Array],onFocus:[Function,Array],onBlur:[Function,Array],onClick:[Function,Array],onChange:[Function,Array],onClear:[Function,Array],countGraphemes:Function,status:String,"onUpdate:value":[Function,Array],onUpdateValue:[Function,Array],textDecoration:[String,Array],attrSize:{type:Number,default:20},onInputBlur:[Function,Array],onInputFocus:[Function,Array],onDeactivate:[Function,Array],onActivate:[Function,Array],onWrapperFocus:[Function,Array],onWrapperBlur:[Function,Array],internalDeactivateOnEnter:Boolean,internalForceFocus:Boolean,internalLoadingBeforeSuffix:{type:Boolean,default:!0},showPasswordToggle:Boolean}),qr=Z({name:"Input",props:Pr,setup(r){const{mergedClsPrefixRef:m,mergedBorderedRef:n,inlineThemeDisabled:A,mergedRtlRef:_}=vr(r),g=Ae("Input","-input",Br,gr,r,m);ar&&br("-input-safari",Er,m);const f=w(null),s=w(null),u=w(null),c=w(null),i=w(null),p=w(null),x=w(null),T=Fr(x),S=w(null),{localeRef:Re}=mr("Input"),j=w(r.defaultValue),Fe=ge(r,"value"),R=xr(Fe,j),V=wr(r),{mergedSizeRef:ee,mergedDisabledRef:I,mergedStatusRef:Be}=V,k=w(!1),W=w(!1),B=w(!1),D=w(!1);let oe=null;const re=F(()=>{const{placeholder:e,pair:o}=r;return o?Array.isArray(e)?e:e===void 0?["",""]:[e,e]:e===void 0?[Re.value.placeholder]:[e]}),Ee=F(()=>{const{value:e}=B,{value:o}=R,{value:t}=re;return!e&&(J(o)||Array.isArray(o)&&J(o[0]))&&t[0]}),Pe=F(()=>{const{value:e}=B,{value:o}=R,{value:t}=re;return!e&&t[1]&&(J(o)||Array.isArray(o)&&J(o[1]))}),te=xe(()=>r.internalForceFocus||k.value),$e=xe(()=>{if(I.value||r.readonly||!r.clearable||!te.value&&!W.value)return!1;const{value:e}=R,{value:o}=te;return r.pair?!!(Array.isArray(e)&&(e[0]||e[1]))&&(W.value||o):!!e&&(W.value||o)}),ne=F(()=>{const{showPasswordOn:e}=r;if(e)return e;if(r.showPasswordToggle)return"click"}),O=w(!1),Te=F(()=>{const{textDecoration:e}=r;return e?Array.isArray(e)?e.map(o=>({textDecoration:o})):[{textDecoration:e}]:["",""]}),de=w(void 0),Ie=()=>{var e,o;if(r.type==="textarea"){const{autosize:t}=r;if(t&&(de.value=(o=(e=S.value)===null||e===void 0?void 0:e.$el)===null||o===void 0?void 0:o.offsetWidth),!s.value||typeof t=="boolean")return;const{paddingTop:h,paddingBottom:v,lineHeight:d}=window.getComputedStyle(s.value),E=Number(h.slice(0,-2)),P=Number(v.slice(0,-2)),$=Number(d.slice(0,-2)),{value:N}=u;if(!N)return;if(t.minRows){const H=Math.max(t.minRows,1),le=`${E+P+$*H}px`;N.style.minHeight=le}if(t.maxRows){const H=`${E+P+$*t.maxRows}px`;N.style.maxHeight=H}}},ke=F(()=>{const{maxlength:e}=r;return e===void 0?void 0:Number(e)});cr(()=>{const{value:e}=R;Array.isArray(e)||ie(e)});const Me=ur().proxy;function U(e,o){const{onUpdateValue:t,"onUpdate:value":h,onInput:v}=r,{nTriggerFormInput:d}=V;t&&y(t,e,o),h&&y(h,e,o),v&&y(v,e,o),j.value=e,d()}function L(e,o){const{onChange:t}=r,{nTriggerFormChange:h}=V;t&&y(t,e,o),j.value=e,h()}function Ve(e){const{onBlur:o}=r,{nTriggerFormBlur:t}=V;o&&y(o,e),t()}function We(e){const{onFocus:o}=r,{nTriggerFormFocus:t}=V;o&&y(o,e),t()}function De(e){const{onClear:o}=r;o&&y(o,e)}function Oe(e){const{onInputBlur:o}=r;o&&y(o,e)}function Ne(e){const{onInputFocus:o}=r;o&&y(o,e)}function He(){const{onDeactivate:e}=r;e&&y(e)}function Ke(){const{onActivate:e}=r;e&&y(e)}function je(e){const{onClick:o}=r;o&&y(o,e)}function Ue(e){cons
`)}else{const{value:v}=c;v&&(e?v.textContent=e:v.innerHTML=" ")}}function bo(){Ie()}const ve=w({top:"0"});function mo(e){var o;const{scrollTop:t}=e.target;ve.value.top=`${-t}px`,(o=S.value)===null||o===void 0||o.syncUnifiedContainer()}let Y=null;be(()=>{const{autosize:e,type:o}=r;e&&o==="textarea"?Y=ue(R,t=>{!Array.isArray(t)&&t!==oe&&ie(t)}):Y==null||Y()});let Q=null;be(()=>{r.type==="textarea"?Q=ue(R,e=>{var o;!Array.isArray(e)&&e!==oe&&((o=S.value)===null||o===void 0||o.syncUnifiedContainer())}):Q==null||Q()}),dr(_e,{mergedValueRef:R,maxlengthRef:ke,mergedClsPrefixRef:m,countGraphemesRef:ge(r,"countGraphemes")});const xo={wrapperElRef:f,inputElRef:i,textareaElRef:s,isCompositing:B,clear:fe,focus:he,blur:fo,select:ho,deactivate:po,activate:vo,scrollTo:go},wo=ir("Input",_,m),pe=F(()=>{const{value:e}=ee,{common:{cubicBezierEaseInOut:o},self:{color:t,borderRadius:h,textColor:v,caretColor:d,caretColorError:E,caretColorWarning:P,textDecorationColor:$,border:N,borderDisabled:H,borderHover:le,borderFocus:yo,placeholderColor:Co,placeholderColorDisabled:zo,lineHeightTextarea:So,colorDisabled:Ao,colorFocus:_o,textColorDisabled:Ro,boxShadowFocus:Fo,iconSize:Bo,colorFocusWarning:Eo,boxShadowFocusWarning:Po,borderWarning:$o,borderFocusWarning:To,borderHoverWarning:Io,colorFocusError:ko,boxShadowFocusError:Mo,borderError:Vo,borderFocusError:Wo,borderHoverError:Do,clearSize:Oo,clearColor:No,clearColorHover:Ho,clearColorPressed:Ko,iconColor:jo,iconColorDisabled:Uo,suffixTextColor:Lo,countTextColor:Go,countTextColorDisabled:Xo,iconColorHover:Yo,iconColorPressed:Qo,loadingColor:qo,loadingColorError:Jo,loadingColorWarning:Zo,[ce("padding",e)]:er,[ce("fontSize",e)]:or,[ce("height",e)]:rr}}=g.value,{left:tr,right:nr}=yr(er);return{"--n-bezier":o,"--n-count-text-color":Go,"--n-count-text-color-disabled":Xo,"--n-color":t,"--n-font-size":or,"--n-border-radius":h,"--n-height":rr,"--n-padding-left":tr,"--n-padding-right":nr,"--n-text-color":v,"--n-caret-color":d,"--n-text-decoration-color":$,"--n-border":N,"--n-border-disabled":H,"--n-border-hover":le,"--n-border-focus":yo,"--n-placeholder-color":Co,"--n-placeholder-color-disabled":zo,"--n-icon-size":Bo,"--n-line-height-textarea":So,"--n-color-disabled":Ao,"--n-color-focus":_o,"--n-text-color-disabled":Ro,"--n-box-shadow-focus":Fo,"--n-loading-color":qo,"--n-caret-color-warning":P,"--n-color-focus-warning":Eo,"--n-box-shadow-focus-warning":Po,"--n-border-warning":$o,"--n-border-focus-warning":To,"--n-border-hover-warning":Io,"--n-loading-color-warning":Zo,"--n-caret-color-error":E,"--n-color-focus-error":ko,"--n-box-shadow-focus-error":Mo,"--n-border-error":Vo,"--n-border-focus-error":Wo,"--n-border-hover-error":Do,"--n-loading-color-error":Jo,"--n-clear-color":No,"--n-clear-size":Oo,"--n-clear-color-hover":Ho,"--n-clear-color-pressed":Ko,"--n-icon-color":jo,"--n-icon-color-hover":Yo,"--n-icon-color-pressed":Qo,"--n-icon-color-disabled":Uo,"--n-suffix-text-color":Lo}}),M=A?pr("input",F(()=>{const{value:e}=ee;return e[0]}),pe,r):void 0;return Object.assign(Object.assign({},xo),{wrapperElRef:f,inputElRef:i,inputMirrorElRef:c,inputEl2Ref:p,textareaElRef:s,textareaMirrorElRef:u,textareaScrollbarInstRef:S,rtlEnabled:wo,uncontrolledValue:j,mergedValue:R,passwordVisible:O,mergedPlaceholder:re,showPlaceholder1:Ee,showPlaceholder2:Pe,mergedFocus:te,isComposing:B,activated:D,showClearButton:$e,mergedSize:ee,mergedDisabled:I,textDecorationStyle:Te,mergedClsPrefix:m,mergedBordered:n,mergedShowPasswordOn:ne,placeholderStyle:ve,mergedStatus:Be,textAreaScrollContainerWidth:de,handleTextAreaScroll:mo,handleCompositionStart:Ge,handleCompositionEnd:Xe,handleInput:G,handleInputBlur:Qe,handleInputFocus:qe,handleWrapperBlur:Je,handleWrapperFocus:Ze,handleMouseEnter:no,handleMouseLeave:ao,handleMouseDown:to,handleChange:eo,handleClick:oo,handleClear:ro,handlePasswordToggleClick:io,handlePasswordToggleMousedown:lo,handleWrapperKeydown:co,handleWrapperKeyup:so,handleTextAreaMirrorResize:bo,getTextareaScrollContainer:()=>s.value,mergedTheme:g,cssVars:A?void 0:pe,themeClass:M==null?void 0:M.themeClass,onRender:M==
|