YiAi/YiAiQuickDeploy/public/assets/Select-394a57d0.js

10 lines
12 KiB
JavaScript

import{aG as Ne,aH as oe,cI as Le,d as $e,aM as Ee,aN as de,r as c,aP as N,aQ as re,e as g,c7 as We,cY as Ke,aO as He,w as qe,aR as Ge,bw as Qe,ct as $,ab as y,cC as Ye,cD as Ze,cZ as Je,cE as Xe,T as et,ae as tt,af as nt,bq as se,ck as lt,c_ as at,cl as it,c$ as ot,d0 as L,d1 as rt,d2 as st,cm as ue,d3 as ut,aW as m,co as dt}from"./index-9247ed63.js";const ct=Ne([oe("select",`
z-index: auto;
outline: none;
width: 100%;
position: relative;
`),oe("select-menu",`
margin: 4px 0;
box-shadow: var(--n-menu-box-shadow);
`,[Le({originalTransition:"background-color .3s var(--n-bezier), box-shadow .3s var(--n-bezier)"})])]),ft=Object.assign(Object.assign({},de.props),{to:$.propTo,bordered:{type:Boolean,default:void 0},clearable:Boolean,clearFilterAfterSelect:{type:Boolean,default:!0},options:{type:Array,default:()=>[]},defaultValue:{type:[String,Number,Array],default:null},keyboard:{type:Boolean,default:!0},value:[String,Number,Array],placeholder:String,menuProps:Object,multiple:Boolean,size:String,filterable:Boolean,disabled:{type:Boolean,default:void 0},remote:Boolean,loading:Boolean,filter:Function,placement:{type:String,default:"bottom-start"},widthMode:{type:String,default:"trigger"},tag:Boolean,onCreate:Function,fallbackOption:{type:[Function,Boolean],default:void 0},show:{type:Boolean,default:void 0},showArrow:{type:Boolean,default:!0},maxTagCount:[Number,String],ellipsisTagPopoverProps:Object,consistentMenuWidth:{type:Boolean,default:!0},virtualScroll:{type:Boolean,default:!0},labelField:{type:String,default:"label"},valueField:{type:String,default:"value"},childrenField:{type:String,default:"children"},renderLabel:Function,renderOption:Function,renderTag:Function,"onUpdate:value":[Function,Array],inputProps:Object,nodeProps:Function,ignoreComposition:{type:Boolean,default:!0},showOnFocus:Boolean,onUpdateValue:[Function,Array],onBlur:[Function,Array],onClear:[Function,Array],onFocus:[Function,Array],onScroll:[Function,Array],onSearch:[Function,Array],onUpdateShow:[Function,Array],"onUpdate:show":[Function,Array],displayDirective:{type:String,default:"show"},resetMenuOnOptionsChange:{type:Boolean,default:!0},status:String,showCheckmark:{type:Boolean,default:!0},onChange:[Function,Array],items:Array}),vt=$e({name:"Select",props:ft,setup(n){const{mergedClsPrefixRef:f,mergedBorderedRef:T,namespaceRef:h,inlineThemeDisabled:u}=Ee(n),E=de("Select","-select",ct,at,n,f),z=c(n.defaultValue),ce=N(n,"value"),M=re(ce,z),C=c(!1),w=c(""),fe=g(()=>{const{valueField:e,childrenField:t}=n,l=dt(e,t);return it(me.value,l)}),W=g(()=>ot(q.value,n.valueField,n.childrenField)),A=c(!1),v=re(N(n,"show"),A),d=c(null),K=c(null),R=c(null),{localeRef:he}=We("Select"),ve=g(()=>{var e;return(e=n.placeholder)!==null&&e!==void 0?e:he.value.placeholder}),U=Ke(n,["items","options"]),B=[],p=c([]),O=c([]),_=c(new Map),H=g(()=>{const{fallbackOption:e}=n;if(e===void 0){const{labelField:t,valueField:l}=n;return r=>({[t]:String(r),[l]:r})}return e===!1?!1:t=>Object.assign(e(t),{value:t})}),q=g(()=>O.value.concat(p.value).concat(U.value)),ge=g(()=>{const{filter:e}=n;if(e)return e;const{labelField:t,valueField:l}=n;return(r,i)=>{if(!i)return!1;const a=i[t];if(typeof a=="string")return L(r,a);const o=i[l];return typeof o=="string"?L(r,o):typeof o=="number"?L(r,String(o)):!1}}),me=g(()=>{if(n.remote)return U.value;{const{value:e}=q,{value:t}=w;return!t.length||!n.filterable?e:rt(e,ge.value,t,n.childrenField)}});function j(e){const t=n.remote,{value:l}=_,{value:r}=W,{value:i}=H,a=[];return e.forEach(o=>{if(r.has(o))a.push(r.get(o));else if(t&&l.has(o))a.push(l.get(o));else if(i){const s=i(o);s&&a.push(s)}}),a}const G=g(()=>{if(n.multiple){const{value:e}=M;return Array.isArray(e)?j(e):[]}return null}),Q=g(()=>{const{value:e}=M;return!n.multiple&&!Array.isArray(e)?e===null?null:j([e])[0]||null:null}),I=He(n),{mergedSizeRef:pe,mergedDisabledRef:k,mergedStatusRef:be}=I;function V(e,t){const{onChange:l,"onUpdate:value":r,onUpdateValue:i}=n,{nTriggerFormChange:a,nTriggerFormInput:o}=I;l&&m(l,e,t),i&&m(i,e,t),r&&m(r,e,t),z.value=e,a(),o()}function Y(e){const{onBlur:t}=n,{nTriggerFormBlur:l}=I;t&&m(t,e),l()}function Oe(){const{onClear:e}=n;e&&m(e)}function Fe(e){const{onFocus:t,showOnFocus:l}=n,{nTriggerFormFocus:r}=I;t&&m(t,e),r(),l&&P()}function ye(e){const{onSearch:t}=n;t&&m(t,e)}function we(e){const{onScroll:t}=n;t&&m(t,e)}function Z(){var e;const{remote:t,multiple:l}=n;if(t){const{value:r}=_;if(l){const{valueField:i}=n;(e=G.value)===null||e===void 0||e.forEach(a=>{r.set(a[i],a)})}else{const i=Q.value;i&&r.set(i[n.valueField],i)}}}function J(e){const{onUpdateShow:t,"onUpdate:show":l}=n;t&&m(t,e),l&&m(l,e),A.value=e}function P(){k.value||(J(!0),A.value=!0,n.filterable&&ae())}function b(){J(!1)}function X(){w.value="",O.value=B}const x=c(!1);function Se(){n.filterable&&(x.value=!0)}function Te(){n.filterable&&(x.value=!1,v.value||X())}function Me(){k.value||(v.value?n.filterable?ae():b():P())}function Ce(e){var t,l;!((l=(t=R.value)===null||t===void 0?void 0:t.selfRef)===null||l===void 0)&&l.contains(e.relatedTarget)||(C.value=!1,Y(e),b())}function Re(e){Fe(e),C.value=!0}function Be(e){C.value=!0}function Pe(e){var t;!((t=d.value)===null||t===void 0)&&t.$el.contains(e.relatedTarget)||(C.value=!1,Y(e),b())}function Ae(){var e;(e=d.value)===null||e===void 0||e.focus(),b()}function _e(e){var t;v.value&&(!((t=d.value)===null||t===void 0)&&t.$el.contains(st(e))||b())}function Ie(e){if(!Array.isArray(e))return[];if(H.value)return Array.from(e);{const{remote:t}=n,{value:l}=W;if(t){const{value:r}=_;return e.filter(i=>l.has(i)||r.has(i))}else return e.filter(r=>l.has(r))}}function ee(e){D(e.rawNode)}function D(e){if(k.value)return;const{tag:t,remote:l,clearFilterAfterSelect:r,valueField:i}=n;if(t&&!l){const{value:a}=O,o=a[0]||null;if(o){const s=p.value;s.length?s.push(o):p.value=[o],O.value=B}}if(l&&_.value.set(e[i],e),n.multiple){const a=Ie(M.value),o=a.findIndex(s=>s===e[i]);if(~o){if(a.splice(o,1),t&&!l){const s=te(e[i]);~s&&(p.value.splice(s,1),r&&(w.value=""))}}else a.push(e[i]),r&&(w.value="");V(a,j(a))}else{if(t&&!l){const a=te(e[i]);~a?p.value=[p.value[a]]:p.value=B}le(),b(),V(e[i],e)}}function te(e){return p.value.findIndex(l=>l[n.valueField]===e)}function ke(e){v.value||P();const{value:t}=e.target;w.value=t;const{tag:l,remote:r}=n;if(ye(t),l&&!r){if(!t){O.value=B;return}const{onCreate:i}=n,a=i?i(t):{[n.labelField]:t,[n.valueField]:t},{valueField:o,labelField:s}=n;U.value.some(F=>F[o]===a[o]||F[s]===a[s])||p.value.some(F=>F[o]===a[o]||F[s]===a[s])?O.value=B:O.value=[a]}}function Ve(e){e.stopPropagation();const{multiple:t}=n;!t&&n.filterable&&b(),Oe(),t?V([],[]):V(null,null)}function xe(e){!ue(e,"action")&&!ue(e,"empty")&&e.preventDefault()}function De(e){we(e)}function ne(e){var t,l,r,i,a;if(!n.keyboard){e.preventDefault();return}switch(e.key){case" ":if(n.filterable)break;e.preventDefault();case"Enter":if(!(!((t=d.value)===null||t===void 0)&&t.isComposing)){if(v.value){const o=(l=R.value)===null||l===void 0?void 0:l.getPendingTmNode();o?ee(o):n.filterable||(b(),le())}else if(P(),n.tag&&x.value){const o=O.value[0];if(o){const s=o[n.valueField],{value:F}=M;n.multiple&&Array.isArray(F)&&F.some(je=>je===s)||D(o)}}}e.preventDefault();break;case"ArrowUp":if(e.preventDefault(),n.loading)return;v.value&&((r=R.value)===null||r===void 0||r.prev());break;case"ArrowDown":if(e.preventDefault(),n.loading)return;v.value?(i=R.value)===null||i===void 0||i.next():P();break;case"Escape":v.value&&(ut(e),b()),(a=d.value)===null||a===void 0||a.focus();break}}function le(){var e;(e=d.value)===null||e===void 0||e.focus()}function ae(){var e;(e=d.value)===null||e===void 0||e.focusInput()}function ze(){var e;v.value&&((e=K.value)===null||e===void 0||e.syncPosition())}Z(),qe(N(n,"options"),Z);const Ue={focus:()=>{var e;(e=d.value)===null||e===void 0||e.focus()},focusInput:()=>{var e;(e=d.value)===null||e===void 0||e.focusInput()},blur:()=>{var e;(e=d.value)===null||e===void 0||e.blur()},blurInput:()=>{var e;(e=d.value)===null||e===void 0||e.blurInput()}},ie=g(()=>{const{self:{menuBoxShadow:e}}=E.value;return{"--n-menu-box-shadow":e}}),S=u?Ge("select",void 0,ie,n):void 0;return Object.assign(Object.assign({},Ue),{mergedStatus:be,mergedClsPrefix:f,mergedBordered:T,namespace:h,treeMate:fe,isMounted:Qe(),triggerRef:d,menuRef:R,pattern:w,uncontrolledShow:A,mergedShow:v,adjustedTo:$(n),uncontrolledValue:z,mergedValue:M,followerRef:K,localizedPlaceholder:ve,selectedOption:Q,selectedOptions:G,mergedSize:pe,mergedDisabled:k,focused:C,activeWithoutMenuOpen:x,inlineThemeDisabled:u,onTriggerInputFocus:Se,onTriggerInputBlur:Te,handleTriggerOrMenuResize:ze,handleMenuFocus:Be,handleMenuBlur:Pe,handleMenuTabOut:Ae,handleTriggerClick:Me,handleToggle:ee,handleDeleteOption:D,handlePatternInput:ke,handleClear:Ve,handleTriggerBlur:Ce,handleTriggerFocus:Re,handleKeydown:ne,handleMenuAfterLeave:X,handleMenuClickOutside:_e,handleMenuScroll:De,handleMenuKeydown:ne,handleMenuMousedown:xe,mergedTheme:E,cssVars:u?void 0:ie,themeClass:S==null?void 0:S.themeClass,onRender:S==null?void 0:S.onRender})},render(){return y("div",{class:`${this.mergedClsPrefix}-select`},y(Ye,null,{default:()=>[y(Ze,null,{default:()=>y(Je,{ref:"triggerRef",inlineThemeDisabled:this.inlineThemeDisabled,status:this.mergedStatus,inputProps:this.inputProps,clsPrefix:this.mergedClsPrefix,showArrow:this.showArrow,maxTagCount:this.maxTagCount,ellipsisTagPopoverProps:this.ellipsisTagPopoverProps,bordered:this.mergedBordered,active:this.activeWithoutMenuOpen||this.mergedShow,pattern:this.pattern,placeholder:this.localizedPlaceholder,selectedOption:this.selectedOption,selectedOptions:this.selectedOptions,multiple:this.multiple,renderTag:this.renderTag,renderLabel:this.renderLabel,filterable:this.filterable,clearable:this.clearable,disabled:this.mergedDisabled,size:this.mergedSize,theme:this.mergedTheme.peers.InternalSelection,labelField:this.labelField,valueField:this.valueField,themeOverrides:this.mergedTheme.peerOverrides.InternalSelection,loading:this.loading,focused:this.focused,onClick:this.handleTriggerClick,onDeleteOption:this.handleDeleteOption,onPatternInput:this.handlePatternInput,onClear:this.handleClear,onBlur:this.handleTriggerBlur,onFocus:this.handleTriggerFocus,onKeydown:this.handleKeydown,onPatternBlur:this.onTriggerInputBlur,onPatternFocus:this.onTriggerInputFocus,onResize:this.handleTriggerOrMenuResize,ignoreComposition:this.ignoreComposition},{arrow:()=>{var n,f;return[(f=(n=this.$slots).arrow)===null||f===void 0?void 0:f.call(n)]}})}),y(Xe,{ref:"followerRef",show:this.mergedShow,to:this.adjustedTo,teleportDisabled:this.adjustedTo===$.tdkey,containerClass:this.namespace,width:this.consistentMenuWidth?"target":void 0,minWidth:"target",placement:this.placement},{default:()=>y(et,{name:"fade-in-scale-up-transition",appear:this.isMounted,onAfterLeave:this.handleMenuAfterLeave},{default:()=>{var n,f,T;return this.mergedShow||this.displayDirective==="show"?((n=this.onRender)===null||n===void 0||n.call(this),tt(y(lt,Object.assign({},this.menuProps,{ref:"menuRef",onResize:this.handleTriggerOrMenuResize,inlineThemeDisabled:this.inlineThemeDisabled,virtualScroll:this.consistentMenuWidth&&this.virtualScroll,class:[`${this.mergedClsPrefix}-select-menu`,this.themeClass,(f=this.menuProps)===null||f===void 0?void 0:f.class],clsPrefix:this.mergedClsPrefix,focusable:!0,labelField:this.labelField,valueField:this.valueField,autoPending:!0,nodeProps:this.nodeProps,theme:this.mergedTheme.peers.InternalSelectMenu,themeOverrides:this.mergedTheme.peerOverrides.InternalSelectMenu,treeMate:this.treeMate,multiple:this.multiple,size:"medium",renderOption:this.renderOption,renderLabel:this.renderLabel,value:this.mergedValue,style:[(T=this.menuProps)===null||T===void 0?void 0:T.style,this.cssVars],onToggle:this.handleToggle,onScroll:this.handleMenuScroll,onFocus:this.handleMenuFocus,onBlur:this.handleMenuBlur,onKeydown:this.handleMenuKeydown,onTabOut:this.handleMenuTabOut,onMousedown:this.handleMenuMousedown,show:this.mergedShow,showCheckmark:this.showCheckmark,resetMenuOnOptionsChange:this.resetMenuOnOptionsChange}),{empty:()=>{var h,u;return[(u=(h=this.$slots).empty)===null||u===void 0?void 0:u.call(h)]},header:()=>{var h,u;return[(u=(h=this.$slots).header)===null||u===void 0?void 0:u.call(h)]},action:()=>{var h,u;return[(u=(h=this.$slots).action)===null||u===void 0?void 0:u.call(h)]}}),this.displayDirective==="show"?[[nt,this.mergedShow],[se,this.handleMenuClickOutside,void 0,{capture:!0}]]:[[se,this.handleMenuClickOutside,void 0,{capture:!0}]])):null}})})]}))}});export{vt as N};