Files
kefu/deploy/archive-performance-fix/admin-web/apps/web-antd/dist/js/mentions-xQgb6RLD.js
T
2026-09-21 10:34:06 +08:00

1 line
14 KiB
JavaScript

import{D as e,Ht as t,J as n,Ut as r,g as i,gn as a,gt as o,it as s,k as c,pt as l,tt as u,vn as d,wn as f,xn as p}from"./runtime-core.esm-bundler-DkysjgTd.js";import{r as m}from"./en_US-Cv9hrLhb.js";import{J as h,O as g,U as _,W as v,Z as y,g as b,m as x,rt as S,st as C,t as w,u as T,vt as E,wt as D}from"./useConfigInject-DomGmy3z.js";import{t as O}from"./initDefaultProps-D8Mki4gM.js";import{t as k}from"./BaseInput-TFtE0FzI.js";import{t as A}from"./omit-C0ksMpVM.js";import{t as j}from"./vue-types-CEi2nPn2.js";import{t as M}from"./vc-trigger-DaL-SGhM.js";import{t as N}from"./KeyCode-DNtAKsAc.js";import{i as P,n as F}from"./FormItemContext-CEmO5XmM.js";import{n as I,t as ee}from"./statusUtils-k563KlQ5.js";import{n as L,r as R,t as te}from"./menu-CgCnR5q_.js";import{c as z,l as B,n as ne,r as re,s as ie,t as ae}from"./style-DJWQcc0G.js";import{t as V}from"./spin-D95RVgwp.js";function oe(e){let{selectionStart:t}=e;return e.value.slice(0,t)}function se(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:``;return(Array.isArray(t)?t:[t]).reduce((t,n)=>{let r=e.lastIndexOf(n);return r>t.location?{location:r,prefix:n}:t},{location:-1,prefix:``})}function H(e){return(e||``).toLowerCase()}function ce(e,t,n){let r=e[0];if(!r||r===n)return e;let i=e,a=t.length;for(let e=0;e<a;e+=1)if(H(i[e])!==H(t[e])){i=i.slice(e);break}else e===a-1&&(i=i.slice(a));return i}function le(e,t){let{measureLocation:n,prefix:r,targetText:i,selectionStart:a,split:o}=t,s=e.slice(0,n);s[s.length-o.length]===o&&(s=s.slice(0,s.length-o.length)),s&&(s=`${s}${o}`);let c=ce(e.slice(a),i.slice(a-n-r.length),o);c.slice(0,o.length)===o&&(c=c.slice(o.length));let l=`${s}${r}${i}${o}`;return{text:`${l}${c}`,selectionLocation:l.length}}function ue(e,t){e.setSelectionRange(t,t),e.blur(),e.focus()}function de(e,t){let{split:n}=t;return!n||e.indexOf(n)===-1}function fe(e,t){let{value:n=``}=t,r=e.toLowerCase();return n.toLowerCase().indexOf(r)!==-1}var U=Symbol(`MentionsContextKey`);function pe(){}var me=c({compatConfig:{MODE:3},name:`DropdownMenu`,props:{prefixCls:String,options:{type:Array,default:()=>[]}},setup(t,r){let{slots:i}=r,{activeIndex:a,setActiveIndex:o,selectOption:c,onFocus:l=pe,loading:u}=n(U,{activeIndex:p(),loading:p(!1)}),d,f=e=>{clearTimeout(d),d=setTimeout(()=>{l(e)})};return s(()=>{clearTimeout(d)}),()=>{var n;let{prefixCls:r,options:s}=t,l=s[a.value]||{};return e(te,{prefixCls:`${r}-menu`,activeKey:l.value,onSelect:e=>{let{key:t}=e,n=s.find(e=>{let{value:n}=e;return n===t});c(n)},onMousedown:f},{default:()=>[!u.value&&s.map((t,n)=>{var r,a;let{value:s,disabled:c,label:l=t.value,class:u,style:d}=t;return e(L,{key:s,disabled:c,onMouseenter:()=>{o(n)},class:u,style:d},{default:()=>[(a=(r=i.option)==null?void 0:r.call(i,t))==null?typeof l==`function`?l(t):l:a]})}),!u.value&&s.length===0?e(L,{key:`notFoundContent`,disabled:!0},{default:()=>[(n=i.notFoundContent)==null?void 0:n.call(i)]}):null,u.value&&e(L,{key:`loading`,disabled:!0},{default:()=>[e(V,{size:`small`},null)]})]})}}}),he={bottomRight:{points:[`tl`,`br`],offset:[0,4],overflow:{adjustX:0,adjustY:1}},bottomLeft:{points:[`tr`,`bl`],offset:[0,4],overflow:{adjustX:0,adjustY:1}},topRight:{points:[`bl`,`tr`],offset:[0,-4],overflow:{adjustX:0,adjustY:1}},topLeft:{points:[`br`,`tl`],offset:[0,-4],overflow:{adjustX:0,adjustY:1}}},ge=c({compatConfig:{MODE:3},name:`KeywordTrigger`,props:{loading:{type:Boolean,default:void 0},options:{type:Array,default:()=>[]},prefixCls:String,placement:String,visible:{type:Boolean,default:void 0},transitionName:String,getPopupContainer:Function,direction:String,dropdownClassName:String},setup(t,n){let{slots:r}=n,a=()=>`${t.prefixCls}-dropdown`,o=()=>{let{options:n}=t;return e(me,{prefixCls:a(),options:n},{notFoundContent:r.notFoundContent,option:r.option})},s=i(()=>{let{placement:e,direction:n}=t,r=`topRight`;return r=n===`rtl`?e===`top`?`topLeft`:`bottomLeft`:e===`top`?`topRight`:`bottomRight`,r});return()=>{let{visible:n,transitionName:i,getPopupContainer:c}=t;return e(M,{prefixCls:a(),popupVisible:n,popup:o(),popupClassName:t.dropdownClassName,popupPlacement:s.value,popupTransitionName:i,builtinPlacements:he,getPopupContainer:c},{default:r.default})}}}),_e=y(`top`,`bottom`),W={autofocus:{type:Boolean,default:void 0},prefix:j.oneOfType([j.string,j.arrayOf(j.string)]),prefixCls:String,value:String,disabled:{type:Boolean,default:void 0},split:String,transitionName:String,placement:j.oneOf(_e),character:j.any,characterRender:Function,filterOption:{type:[Boolean,Function]},validateSearch:Function,getPopupContainer:{type:Function},options:v(),loading:{type:Boolean,default:void 0},rows:[Number,String],direction:{type:String}},G=m(m({},W),{dropdownClassName:String}),K={prefix:`@`,split:` `,rows:1,validateSearch:de,filterOption:()=>fe};O(G,K);var q=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};function J(){}var ve=c({compatConfig:{MODE:3},name:`Mentions`,inheritAttrs:!1,props:O(G,K),emits:[`change`,`select`,`search`,`focus`,`blur`,`pressenter`],setup(t,n){let{emit:s,attrs:c,expose:p,slots:h}=n,g=d(null),_=d(null),v=d(),y=a({value:t.value||``,measuring:!1,measureLocation:0,measureText:null,measurePrefix:``,activeIndex:0,isFocus:!1});r(()=>{y.value=t.value});let b=e=>{s(`change`,e)},x=e=>{let{target:{value:t}}=e;b(t)},S=(e,t,n)=>{m(y,{measuring:!0,measureText:e,measurePrefix:t,measureLocation:n,activeIndex:0})},C=e=>{m(y,{measuring:!1,measureLocation:0,measureText:null}),e==null||e()},w=e=>{let{which:t}=e;if(y.measuring){if(t===N.UP||t===N.DOWN){let n=R.value.length,r=t===N.UP?-1:1,i=(y.activeIndex+r+n)%n;y.activeIndex=i,e.preventDefault()}else if(t===N.ESC)C();else if(t===N.ENTER){if(e.preventDefault(),!R.value.length){C();return}let t=R.value[y.activeIndex];I(t)}}},T=e=>{let{key:n,which:r}=e,{measureText:i,measuring:a}=y,{prefix:o,validateSearch:c}=t,l=e.target;if(l.composing)return;let u=oe(l),{location:d,prefix:f}=se(u,o);if([N.ESC,N.UP,N.DOWN,N.ENTER].indexOf(r)===-1){if(d!==-1){let e=u.slice(d+f.length),r=c(e,t),o=!!L(e).length;r?(n===f||n===`Shift`||a||e!==i&&o)&&S(e,f,d):a&&C(),r&&s(`search`,e,f)}else a&&C()}},O=e=>{y.measuring||s(`pressenter`,e)},j=e=>{P(e)},M=e=>{F(e)},P=e=>{clearTimeout(v.value);let{isFocus:t}=y;!t&&e&&s(`focus`,e),y.isFocus=!0},F=e=>{v.value=setTimeout(()=>{y.isFocus=!1,C(),s(`blur`,e)},100)},I=e=>{let{split:n}=t,{value:r=``}=e,{text:i,selectionLocation:a}=le(y.value,{measureLocation:y.measureLocation,targetText:r,prefix:y.measurePrefix,selectionStart:_.value.getSelectionStart(),split:n});b(i),C(()=>{ue(_.value.input,a)}),s(`select`,e,y.measurePrefix)},ee=e=>{y.activeIndex=e},L=e=>{let n=e||y.measureText||``,{filterOption:r}=t;return t.options.filter(e=>!r||r(n,e))},R=i(()=>L());return p({blur:()=>{_.value.blur()},focus:()=>{_.value.focus()}}),o(U,{activeIndex:f(y,`activeIndex`),setActiveIndex:ee,selectOption:I,onFocus:P,onBlur:F,loading:f(t,`loading`)}),l(()=>{u(()=>{y.measuring&&(g.value.scrollTop=_.value.getScrollTop())})}),()=>{let{measureLocation:n,measurePrefix:r,measuring:i}=y,{prefixCls:a,placement:o,transitionName:s,getPopupContainer:l,direction:u}=t,d=q(t,[`prefixCls`,`placement`,`transitionName`,`getPopupContainer`,`direction`]),{class:f,style:p}=c,v=q(c,[`class`,`style`]),b=A(d,[`value`,`prefix`,`split`,`validateSearch`,`filterOption`,`options`,`loading`]),S=m(m(m({},b),v),{onChange:J,onSelect:J,value:y.value,onInput:x,onBlur:M,onKeydown:w,onKeyup:T,onFocus:j,onPressenter:O});return e(`div`,{class:E(a,f),style:p},[e(k,D(D({},S),{},{ref:_,tag:`textarea`}),null),i&&e(`div`,{ref:g,class:`${a}-measure`},[y.value.slice(0,n),e(ge,{prefixCls:a,transitionName:s,dropdownClassName:t.dropdownClassName,placement:o,options:i?R.value:[],visible:!0,direction:u,getPopupContainer:l},{default:()=>[e(`span`,null,[r])],notFoundContent:h.notFoundContent,option:h.option}),y.value.slice(n+r.length)])])}}}),ye={value:String,disabled:Boolean,payload:h()},Y=m(m({},ye),{label:_([])}),X={name:`Option`,props:Y,render(e,t){let{slots:n}=t;var r;return(r=n.default)==null?void 0:r.call(n)}};c(m({compatConfig:{MODE:3}},X));var be=ve,xe=e=>{let{componentCls:t,colorTextDisabled:n,controlItemBgHover:r,controlPaddingHorizontal:i,colorText:a,motionDurationSlow:o,lineHeight:s,controlHeight:c,inputPaddingHorizontal:l,inputPaddingVertical:u,fontSize:d,colorBgElevated:f,borderRadiusLG:p,boxShadowSecondary:h}=e,g=Math.round((e.controlHeight-e.fontSize*e.lineHeight)/2);return{[t]:m(m(m(m(m({},x(e)),ne(e)),{position:`relative`,display:`inline-block`,height:`auto`,padding:0,overflow:`hidden`,lineHeight:s,whiteSpace:`pre-wrap`,verticalAlign:`bottom`}),z(e,t)),{"&-disabled":{"> textarea":m({},re(e))},"&-focused":m({},ae(e)),[`&-affix-wrapper ${t}-suffix`]:{position:`absolute`,top:0,insetInlineEnd:l,bottom:0,zIndex:1,display:`inline-flex`,alignItems:`center`,margin:`auto`},[`> textarea, ${t}-measure`]:{color:a,boxSizing:`border-box`,minHeight:c-2,margin:0,padding:`${u}px ${l}px`,overflow:`inherit`,overflowX:`hidden`,overflowY:`auto`,fontWeight:`inherit`,fontSize:`inherit`,fontFamily:`inherit`,fontStyle:`inherit`,fontVariant:`inherit`,fontSizeAdjust:`inherit`,fontStretch:`inherit`,lineHeight:`inherit`,direction:`inherit`,letterSpacing:`inherit`,whiteSpace:`inherit`,textAlign:`inherit`,verticalAlign:`top`,wordWrap:`break-word`,wordBreak:`inherit`,tabSize:`inherit`},"> textarea":m({width:`100%`,border:`none`,outline:`none`,resize:`none`,backgroundColor:`inherit`},ie(e.colorTextPlaceholder)),[`${t}-measure`]:{position:`absolute`,top:0,insetInlineEnd:0,bottom:0,insetInlineStart:0,zIndex:-1,color:`transparent`,pointerEvents:`none`,"> span":{display:`inline-block`,minHeight:`1em`}},"&-dropdown":m(m({},x(e)),{position:`absolute`,top:-9999,insetInlineStart:-9999,zIndex:e.zIndexPopup,boxSizing:`border-box`,fontSize:d,fontVariant:`initial`,backgroundColor:f,borderRadius:p,outline:`none`,boxShadow:h,"&-hidden":{display:`none`},[`${t}-dropdown-menu`]:{maxHeight:e.dropdownHeight,marginBottom:0,paddingInlineStart:0,overflow:`auto`,listStyle:`none`,outline:`none`,"&-item":m(m({},b),{position:`relative`,display:`block`,minWidth:e.controlItemWidth,padding:`${g}px ${i}px`,color:a,fontWeight:`normal`,lineHeight:s,cursor:`pointer`,transition:`background ${o} ease`,"&:hover":{backgroundColor:r},"&:first-child":{borderStartStartRadius:p,borderStartEndRadius:p,borderEndStartRadius:0,borderEndEndRadius:0},"&:last-child":{borderStartStartRadius:0,borderStartEndRadius:0,borderEndStartRadius:p,borderEndEndRadius:p},"&-disabled":{color:n,cursor:`not-allowed`,"&:hover":{color:n,backgroundColor:r,cursor:`not-allowed`}},"&-selected":{color:a,fontWeight:e.fontWeightStrong,backgroundColor:r},"&-active":{backgroundColor:r}})}})})}},Se=T(`Mentions`,e=>[xe(B(e))],e=>({dropdownHeight:250,controlItemWidth:100,zIndexPopup:e.zIndexPopupBase+50})),Z=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(e!=null&&typeof Object.getOwnPropertySymbols==`function`)for(var i=0,r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]]);return n};function Ce(){return!0}var we=function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:``,{prefix:t=`@`,split:n=` `}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r=Array.isArray(t)?t:[t];return e.split(n).map(function(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:``,t=null;return r.some(n=>e.slice(0,n.length)===n&&(t=n,!0)),t===null?null:{prefix:t,value:e.slice(t.length)}}).filter(e=>!!e&&!!e.value)},Te=()=>m(m({},W),{loading:{type:Boolean,default:void 0},onFocus:{type:Function},onBlur:{type:Function},onSelect:{type:Function},onChange:{type:Function},onPressenter:{type:Function},"onUpdate:value":{type:Function},notFoundContent:j.any,defaultValue:String,id:String,status:String}),Q=c({compatConfig:{MODE:3},name:`AMentions`,inheritAttrs:!1,props:Te(),slots:Object,setup(n,r){let{slots:a,emit:o,attrs:s,expose:c}=r;var l,u;let{prefixCls:d,renderEmpty:f,direction:h}=w(`mentions`,n),[_,v]=Se(d),y=p(!1),b=p(null),x=p((u=(l=n.value)==null?n.defaultValue:l)==null?``:u),T=P(),O=F.useInject(),k=i(()=>ee(O.status,n.status));R({prefixCls:i(()=>`${d.value}-menu`),mode:i(()=>`vertical`),selectable:i(()=>!1),onClick:()=>{},validator:e=>{let{mode:t}=e;g(!t||t===`vertical`,`Mentions`,`mode="${t}" is not supported for Mentions's Menu.`)}}),t(()=>n.value,e=>{x.value=e});let j=e=>{y.value=!0,o(`focus`,e)},M=e=>{y.value=!1,o(`blur`,e),T.onFieldBlur()},N=function(){o(`select`,...arguments),y.value=!0},L=e=>{n.value===void 0&&(x.value=e),o(`update:value`,e),o(`change`,e),T.onFieldChange()},te=()=>{let e=n.notFoundContent;return e===void 0?a.notFoundContent?a.notFoundContent():f(`Select`):e},z=()=>{var e;return S(((e=a.default)==null?void 0:e.call(a))||[]).map(e=>{var t,n;return m(m({},C(e)),{label:(n=(t=e.children)==null?void 0:t.default)==null?void 0:n.call(t)})})};c({focus:()=>{b.value.focus()},blur:()=>{b.value.blur()}});let B=i(()=>n.loading?Ce:n.filterOption);return()=>{let{disabled:t,getPopupContainer:r,rows:i=1,id:o=T.id.value}=n,c=Z(n,[`disabled`,`getPopupContainer`,`rows`,`id`]),{hasFeedback:l,feedbackIcon:u}=O,{class:f}=s,p=Z(s,[`class`]),g=A(c,[`defaultValue`,`onUpdate:value`,`prefixCls`]),S=E({[`${d.value}-disabled`]:t,[`${d.value}-focused`]:y.value,[`${d.value}-rtl`]:h.value===`rtl`},I(d.value,k.value),!l&&f,v.value),C=m(m(m(m({prefixCls:d.value},g),{disabled:t,direction:h.value,filterOption:B.value,getPopupContainer:r,options:n.loading?[{value:`ANTDV_SEARCHING`,disabled:!0,label:e(V,{size:`small`},null)}]:n.options||z(),class:S}),p),{rows:i,onChange:L,onSelect:N,onFocus:j,onBlur:M,ref:b,value:x.value,id:o}),w=e(be,D(D({},C),{},{dropdownClassName:v.value}),{notFoundContent:te,option:a.option});return _(l?e(`div`,{class:E(`${d.value}-affix-wrapper`,I(`${d.value}-affix-wrapper`,k.value,l),f,v.value)},[w,e(`span`,{class:`${d.value}-suffix`},[u])]):w)}}}),$=c(m(m({compatConfig:{MODE:3}},X),{name:`AMentionsOption`,props:Y})),Ee=m(Q,{Option:$,getMentions:we,install:e=>(e.component(Q.name,Q),e.component($.name,$),e)});export{$ as MentionsOption,Ee as default,Te as mentionsProps};