Cascader-61534244-1720699367816.js 28 KB

12
  1. import{af as A,dl as pt,d as re,dm as bt,al as z,r as S,p as yt,ad as d,_ as Se,dn as wt,a5 as kt,dp as Rt,dq as xt,dr as Ct,ds as St,dt as Mt,aa as Tt,a8 as Me,U as g,du as ce,n as Nt,dv as Pt,dw as $e,dx as Ft,dy as Ot,dz as Le,dA as he,dB as Lt,dC as Kt,dD as _t,a0 as qe,dE as We,dF as Ge,dG as Bt,dH as It,dI as At,dJ as Je,dK as zt,dL as Vt,ah as fe,dM as De,ag as Re,ai as U,ab as $t,ao as Qe,b2 as Dt,ak as je,dN as jt,dO as Ce,c3 as Et,A as Ee,a7 as Ut,dP as Ht,dQ as qt,ap as Wt,dR as Gt,dS as Jt,dT as Qt,dU as Ue,dV as Xt,av as Yt,dW as Zt,dX as Z,S as en}from"./index-b48b51d2-1720699367816.js";const tn=A("base-menu-mask","\n position: absolute;\n left: 0;\n right: 0;\n top: 0;\n bottom: 0;\n display: flex;\n align-items: center;\n justify-content: center;\n text-align: center;\n padding: 14px;\n overflow: hidden;\n",[pt()]),nn=re({name:"BaseMenuMask",props:{clsPrefix:{type:String,required:!0}},setup(t){bt("-base-menu-mask",tn,z(t,"clsPrefix"));const a=S(null);let o=null;const l=S(!1);return yt(()=>{o!==null&&window.clearTimeout(o)}),Object.assign({message:a,show:l},{showOnce(m,p=1500){o&&window.clearTimeout(o),l.value=!0,a.value=m,o=window.setTimeout(()=>{l.value=!1,a.value=null},p)}})},render(){return d(Se,{name:"fade-in-transition"},{default:()=>this.show?d("div",{class:"".concat(this.clsPrefix,"-base-menu-mask")},this.message):null})}}),on=t=>{const{borderRadius:a,boxShadow2:o,popoverColor:l,textColor2:c,textColor3:m,primaryColor:p,textColorDisabled:v,dividerColor:b,hoverColor:N,fontSizeMedium:k,heightMedium:F}=t;return{menuBorderRadius:a,menuColor:l,menuBoxShadow:o,menuDividerColor:b,menuHeight:"calc(var(--n-option-height) * 6.6)",optionArrowColor:m,optionHeight:F,optionFontSize:k,optionColorHover:N,optionTextColor:c,optionTextColorActive:p,optionTextColorDisabled:v,optionCheckMarkColor:p,loadingColor:p,columnWidth:"180px"}},ln=wt({name:"Cascader",common:kt,peers:{InternalSelectMenu:Rt,InternalSelection:xt,Scrollbar:Ct,Checkbox:St,Empty:Mt},self:on}),an=ln;function xe(t){return t?t.map(a=>a.rawNode):null}function rn(t,a,o,l){const c=[],m=[];function p(v){for(const b of v){if(b.disabled)continue;const{rawNode:N}=b;m.push(N),(b.isLeaf||!a)&&c.push({label:Ke(b,l,o),value:b.key,rawNode:b.rawNode,path:Array.from(m)}),!b.isLeaf&&b.children&&p(b.children),m.pop()}}return p(t),c}function Ke(t,a,o){const l=[];for(;t;)l.push(t.rawNode[o]),t=t.parent;return l.reverse().join(a)}const ve=Tt("n-cascader"),He=re({name:"NCascaderOption",props:{tmNode:{type:Object,required:!0}},setup(t){const{expandTriggerRef:a,remoteRef:o,multipleRef:l,mergedValueRef:c,checkedKeysRef:m,indeterminateKeysRef:p,hoverKeyPathRef:v,keyboardKeyRef:b,loadingKeySetRef:N,cascadeRef:k,mergedCheckStrategyRef:F,onLoadRef:V,mergedClsPrefixRef:B,mergedThemeRef:H,labelFieldRef:q,showCheckboxRef:ee,renderPrefixRef:y,renderSuffixRef:C,updateHoverKey:P,updateKeyboardKey:M,addLoadingKey:I,deleteLoadingKey:D,closeMenu:te,doCheck:Q,doUncheck:me,renderLabelRef:u}=Me(ve),w=g(()=>t.tmNode.key),O=g(()=>{const{value:T}=a,{value:E}=o;return!E&&T==="hover"}),K=g(()=>{if(O.value)return se}),W=g(()=>{if(O.value)return de}),j=ce(()=>{const{value:T}=l;return T?m.value.includes(w.value):c.value===w.value}),ne=ce(()=>l.value?p.value.includes(w.value):!1),Te=ce(()=>v.value.includes(w.value)),Ne=ce(()=>{const{value:T}=b;return T===null?!1:T===w.value}),G=ce(()=>o.value?N.value.has(w.value):!1),oe=g(()=>t.tmNode.isLeaf),$=g(()=>t.tmNode.disabled),J=g(()=>t.tmNode.rawNode[q.value]),X=g(()=>t.tmNode.shallowLoaded);function ie(T){if($.value)return;const{value:E}=o,{value:_}=N,{value:pe}=V,{value:L}=w,{value:be}=oe,{value:ye}=X;Le(T,"checkbox")||(E&&!ye&&!_.has(L)&&pe&&(I(L),pe(t.tmNode.rawNode).then(()=>{D(L)}).catch(()=>{D(L)})),P(L),M(L)),be&&ge()}function se(){if(!O.value||$.value)return;const{value:T}=w;P(T),M(T)}function de(){O.value&&se()}function Pe(){const{value:T}=oe;T||ge()}function ge(){const{value:T}=l,{value:E}=w;T?ne.value||j.value?me(E):Q(E):(Q(E),te(!0))}return{checkStrategy:F,multiple:l,cascade:k,checked:j,indeterminate:ne,hoverPending:Te,keyboardPending:Ne,isLoading:G,showCheckbox:ee,isLeaf:oe,disabled:$,label:J,mergedClsPrefix:B,mergedTheme:H,handleClick:ie,handleCheckboxUpdateValue:Pe,mergedHandleMouseEnter:K,mergedHandleMouseMove:W,renderLabel:u,renderPrefix:y,renderSuffix:C}},render(){const{mergedClsPrefix:t,showCheckbox:a,renderLabel:o,renderPrefix:l,renderSuffix:c}=this;let m=null;if(a||l){const b=this.showCheckbox?d(Nt,{focusable:!1,"data-checkbox":!0,disabled:this.disabled,checked:this.checked,indeterminate:this.indeterminate,theme:this.mergedTheme.peers.Checkbox,themeOverrides:this.mergedTheme.peerOverrides.Checkbox,onUpdateChecked:this.handleCheckboxUpdateValue}):null;m=d("div",{class:"".concat(t,"-cascader-option__prefix")},l?l({option:this.tmNode.rawNode,checked:this.checked,node:b}):b)}let p=null;const v=d("div",{class:"".concat(t,"-cascader-option-icon-placeholder")},this.isLeaf?this.checkStrategy==="child"&&!(this.multiple&&this.cascade)?d(Se,{name:"fade-in-scale-up-transition"},{default:()=>this.checked?d($e,{clsPrefix:t,class:"".concat(t,"-cascader-option-icon ").concat(t,"-cascader-option-icon--checkmark")},{default:()=>d(Ot,null)}):null}):null:d(Pt,{clsPrefix:t,scale:.85,strokeWidth:24,show:this.isLoading,class:"".concat(t,"-cascader-option-icon")},{default:()=>d($e,{clsPrefix:t,key:"arrow",class:"".concat(t,"-cascader-option-icon ").concat(t,"-cascader-option-icon--arrow")},{default:()=>d(Ft,null)})}));return p=d("div",{class:"".concat(t,"-cascader-option__suffix")},c?c({option:this.tmNode.rawNode,checked:this.checked,node:v}):v),d("div",{class:["".concat(t,"-cascader-option"),this.keyboardPending||this.hoverPending&&"".concat(t,"-cascader-option--pending"),this.disabled&&"".concat(t,"-cascader-option--disabled"),this.showCheckbox&&"".concat(t,"-cascader-option--show-prefix")],onMouseenter:this.mergedHandleMouseEnter,onMousemove:this.mergedHandleMouseMove,onClick:this.handleClick},m,d("span",{class:"".concat(t,"-cascader-option__label")},o?o(this.tmNode.rawNode,this.checked):this.label),p)}}),sn=re({name:"CascaderSubmenu",props:{depth:{type:Number,required:!0},tmNodes:{type:Array,required:!0}},setup(){const{virtualScrollRef:t,mergedClsPrefixRef:a,mergedThemeRef:o,optionHeightRef:l}=Me(ve),c=S(null),m=S(null),p={scroll(v,b){var N,k;t.value?(N=m.value)===null||N===void 0||N.scrollTo({index:v}):(k=c.value)===null||k===void 0||k.scrollTo({index:v,elSize:b})}};return Object.assign({mergedClsPrefix:a,mergedTheme:o,scrollbarInstRef:c,vlInstRef:m,virtualScroll:t,itemSize:g(()=>he(l.value)),handleVlScroll:()=>{var v;(v=c.value)===null||v===void 0||v.sync()},getVlContainer:()=>{var v;return(v=m.value)===null||v===void 0?void 0:v.listElRef},getVlContent:()=>{var v;return(v=m.value)===null||v===void 0?void 0:v.itemsElRef}},p)},render(){const{mergedClsPrefix:t,mergedTheme:a,virtualScroll:o}=this;return d("div",{class:[o&&"".concat(t,"-cascader-submenu--virtual"),"".concat(t,"-cascader-submenu")]},d(Lt,{ref:"scrollbarInstRef",theme:a.peers.Scrollbar,themeOverrides:a.peerOverrides.Scrollbar,container:o?this.getVlContainer:void 0,content:o?this.getVlContent:void 0},{default:()=>o?d(Kt,{items:this.tmNodes,itemSize:this.itemSize,onScroll:this.handleVlScroll,showScrollbar:!1,ref:"vlInstRef"},{default:({item:l})=>d(He,{key:l.key,tmNode:l})}):this.tmNodes.map(l=>d(He,{key:l.key,tmNode:l}))}))}}),dn=re({name:"NCascaderMenu",props:{value:[String,Number,Array],placement:{type:String,default:"bottom-start"},show:Boolean,menuModel:{type:Array,required:!0},loading:Boolean,onFocus:{type:Function,required:!0},onBlur:{type:Function,required:!0},onKeydown:{type:Function,required:!0},onMousedown:{type:Function,required:!0},onTabout:{type:Function,required:!0}},setup(t){const{localeRef:a,isMountedRef:o,mergedClsPrefixRef:l,syncCascaderMenuPosition:c,handleCascaderMenuClickOutside:m,mergedThemeRef:p,getColumnStyleRef:v}=Me(ve),b=[],N=S(null),k=S(null);function F(){c()}_t(k,F);function V(y){var C;const{value:{loadingRequiredMessage:P}}=a;(C=N.value)===null||C===void 0||C.showOnce(P(y))}function B(y){m(y)}function H(y){const{value:C}=k;C&&(C.contains(y.relatedTarget)||t.onFocus(y))}function q(y){const{value:C}=k;C&&(C.contains(y.relatedTarget)||t.onBlur(y))}return Object.assign({isMounted:o,mergedClsPrefix:l,selfElRef:k,submenuInstRefs:b,maskInstRef:N,mergedTheme:p,getColumnStyle:v,handleFocusin:H,handleFocusout:q,handleClickOutside:B},{scroll(y,C,P){const M=b[y];M&&M.scroll(C,P)},showErrorMessage:V})},render(){const{submenuInstRefs:t,mergedClsPrefix:a,mergedTheme:o}=this;return d(Se,{name:"fade-in-scale-up-transition",appear:this.isMounted},{default:()=>this.show?qe(d("div",{tabindex:"0",ref:"selfElRef",class:"".concat(a,"-cascader-menu"),onMousedown:this.onMousedown,onFocusin:this.handleFocusin,onFocusout:this.handleFocusout,onKeydown:this.onKeydown},this.menuModel[0].length?d("div",{class:"".concat(a,"-cascader-submenu-wrapper")},this.menuModel.map((l,c)=>{var m;return d(sn,{style:(m=this.getColumnStyle)===null||m===void 0?void 0:m.call(this,{level:c}),ref:p=>{p&&(t[c]=p)},key:c,tmNodes:l,depth:c+1})}),d(nn,{clsPrefix:a,ref:"maskInstRef"})):d("div",{class:"".concat(a,"-cascader-menu__empty")},Ge(this.$slots.empty,()=>[d(Bt,{theme:o.peers.Empty,themeOverrides:o.peerOverrides.Empty})])),It(this.$slots.action,l=>l&&d("div",{class:"".concat(a,"-cascader-menu-action"),"data-action":!0},l)),d(At,{onFocus:this.onTabout})),[[We,this.handleClickOutside,void 0,{capture:!0}]]):null})}}),un=re({name:"NCascaderSelectMenu",props:{value:{type:[String,Number,Array],default:null},show:Boolean,pattern:{type:String,default:""},multiple:Boolean,tmNodes:{type:Array,default:()=>[]},filter:Function,labelField:{type:String,required:!0},separator:{type:String,required:!0}},setup(t){const{isMountedRef:a,mergedValueRef:o,mergedClsPrefixRef:l,mergedThemeRef:c,mergedCheckStrategyRef:m,slots:p,syncSelectMenuPosition:v,closeMenu:b,handleSelectMenuClickOutside:N,doUncheck:k,doCheck:F,clearPattern:V}=Me(ve),B=S(null),H=g(()=>rn(t.tmNodes,m.value==="child",t.labelField,t.separator)),q=g(()=>{const{filter:u}=t;if(u)return u;const{labelField:w}=t;return(O,K,W)=>W.some(j=>j[w]&&~j[w].indexOf(O))}),ee=g(()=>{const{pattern:u}=t,{value:w}=q;return(u?H.value.filter(O=>w(u,O.rawNode,O.path)):H.value).map(O=>({value:O.value,label:O.label}))}),y=g(()=>Je(ee.value,zt("value","children")));function C(){v()}function P(u){M(u)}function M(u){if(t.multiple){const{value:w}=o;Array.isArray(w)?w.includes(u.key)?k(u.key):F(u.key):w===null&&F(u.key),V()}else F(u.key),b(!0)}function I(){var u;(u=B.value)===null||u===void 0||u.prev()}function D(){var u;(u=B.value)===null||u===void 0||u.next()}function te(){var u;if(B){const w=(u=B.value)===null||u===void 0?void 0:u.getPendingTmNode();return w&&M(w),!0}return!1}function Q(u){N(u)}return Object.assign({isMounted:a,mergedTheme:c,mergedClsPrefix:l,menuInstRef:B,selectTreeMate:y,handleResize:C,handleToggle:P,handleClickOutside:Q,cascaderSlots:p},{prev:I,next:D,enter:te})},render(){const{mergedClsPrefix:t,isMounted:a,mergedTheme:o,cascaderSlots:l}=this;return d(Se,{name:"fade-in-scale-up-transition",appear:a},{default:()=>this.show?qe(d(Vt,{ref:"menuInstRef",onResize:this.handleResize,clsPrefix:t,class:"".concat(t,"-cascader-menu"),autoPending:!0,themeOverrides:o.peerOverrides.InternalSelectMenu,theme:o.peers.InternalSelectMenu,treeMate:this.selectTreeMate,multiple:this.multiple,value:this.value,onToggle:this.handleToggle},{empty:()=>Ge(l["not-found"],()=>[])}),[[We,this.handleClickOutside,void 0,{capture:!0}]]):null})}}),cn=fe([A("cascader-menu","\n outline: none;\n position: relative;\n margin: 4px 0;\n display: flex;\n flex-flow: column nowrap;\n border-radius: var(--n-menu-border-radius);\n overflow: hidden;\n box-shadow: var(--n-menu-box-shadow);\n color: var(--n-option-text-color);\n background-color: var(--n-menu-color);\n ",[De({transformOrigin:"inherit",duration:"0.2s"}),Re("empty","\n display: flex;\n padding: 12px 32px;\n flex: 1;\n justify-content: center;\n "),A("scrollbar","\n width: 100%;\n "),A("base-menu-mask","\n background-color: var(--n-menu-mask-color);\n "),A("base-loading","\n color: var(--n-loading-color);\n "),A("cascader-submenu-wrapper","\n position: relative;\n display: flex;\n flex-wrap: nowrap;\n "),A("cascader-submenu","\n height: var(--n-menu-height);\n min-width: var(--n-column-width);\n position: relative;\n ",[U("virtual","\n width: var(--n-column-width);\n "),A("scrollbar-content","\n position: relative;\n "),fe("&:first-child","\n border-top-left-radius: var(--n-menu-border-radius);\n border-bottom-left-radius: var(--n-menu-border-radius);\n "),fe("&:last-child","\n border-top-right-radius: var(--n-menu-border-radius);\n border-bottom-right-radius: var(--n-menu-border-radius);\n "),fe("&:not(:first-child)","\n border-left: 1px solid var(--n-menu-divider-color);\n ")]),A("cascader-menu-action","\n box-sizing: border-box;\n padding: 8px;\n border-top: 1px solid var(--n-menu-divider-color);\n "),A("cascader-option","\n height: var(--n-option-height);\n line-height: var(--n-option-height);\n font-size: var(--n-option-font-size);\n padding: 0 0 0 18px;\n box-sizing: border-box;\n min-width: 182px;\n background-color: #0000;\n display: flex;\n align-items: center;\n white-space: nowrap;\n position: relative;\n cursor: pointer;\n transition:\n background-color .2s var(--n-bezier),\n color 0.2s var(--n-bezier);\n ",[U("show-prefix","\n padding-left: 0;\n "),Re("label","\n flex: 1 0 0;\n overflow: hidden;\n text-overflow: ellipsis;\n "),Re("prefix","\n min-width: 32px;\n display: flex;\n align-items: center;\n justify-content: center;\n "),Re("suffix","\n min-width: 32px;\n display: flex;\n align-items: center;\n justify-content: center;\n "),A("cascader-option-icon-placeholder","\n line-height: 0;\n position: relative;\n width: 16px;\n height: 16px;\n font-size: 16px;\n ",[A("cascader-option-icon",[U("checkmark","\n color: var(--n-option-check-mark-color);\n ",[De({originalTransition:"background-color .3s var(--n-bezier), box-shadow .3s var(--n-bezier)"})]),U("arrow","\n color: var(--n-option-arrow-color);\n ")])]),U("selected","\n color: var(--n-option-text-color-active);\n "),U("active","\n color: var(--n-option-text-color-active);\n background-color: var(--n-option-color-hover);\n "),U("pending","\n background-color: var(--n-option-color-hover);\n "),fe("&:hover","\n background-color: var(--n-option-color-hover);\n "),U("disabled","\n color: var(--n-option-text-color-disabled);\n background-color: #0000;\n cursor: not-allowed;\n ",[A("cascader-option-icon",[U("arrow","\n color: var(--n-option-text-color-disabled);\n ")])])])]),A("cascader","\n z-index: auto;\n position: relative;\n width: 100%;\n ")]),fn=Object.assign(Object.assign({},Qe.props),{allowCheckingNotLoaded:Boolean,to:Ce.propTo,bordered:{type:Boolean,default:void 0},options:{type:Array,default:()=>[]},value:[String,Number,Array],defaultValue:{type:[String,Number,Array],default:null},placeholder:String,multiple:Boolean,size:String,filterable:Boolean,disabled:{type:Boolean,default:void 0},disabledField:{type:String,default:"disabled"},expandTrigger:{type:String,default:"click"},clearable:Boolean,clearFilterAfterSelect:{type:Boolean,default:!0},remote:Boolean,onLoad:Function,separator:{type:String,default:" / "},filter:Function,placement:{type:String,default:"bottom-start"},cascade:{type:Boolean,default:!0},leafOnly:Boolean,showPath:{type:Boolean,default:!0},show:{type:Boolean,default:void 0},maxTagCount:[String,Number],ellipsisTagPopoverProps:Object,menuProps:Object,filterMenuProps:Object,virtualScroll:{type:Boolean,default:!0},checkStrategy:{type:String,default:"all"},valueField:{type:String,default:"value"},labelField:{type:String,default:"label"},childrenField:{type:String,default:"children"},renderLabel:Function,status:String,"onUpdate:value":[Function,Array],onUpdateValue:[Function,Array],"onUpdate:show":[Function,Array],onUpdateShow:[Function,Array],onBlur:Function,onFocus:Function,getColumnStyle:Function,renderPrefix:Function,renderSuffix:Function,onChange:[Function,Array]}),vn=re({name:"Cascader",props:fn,setup(t,{slots:a}){const{mergedBorderedRef:o,mergedClsPrefixRef:l,namespaceRef:c,inlineThemeDisabled:m}=$t(t),p=Qe("Cascader","-cascader",cn,an,t,l),{localeRef:v}=Dt("Cascader"),b=S(t.defaultValue),N=g(()=>t.value),k=je(N,b),F=g(()=>t.leafOnly?"child":t.checkStrategy),V=S(""),B=jt(t),{mergedSizeRef:H,mergedDisabledRef:q,mergedStatusRef:ee}=B,y=S(null),C=S(null),P=S(null),M=S(null),I=S(null),D=S(new Set),te=S(null),Q=S(null),me=Ce(t),u=S(!1),w=e=>{D.value.add(e)},O=e=>{D.value.delete(e)},K=g(()=>{const{valueField:e,childrenField:n,disabledField:r}=t;return Je(t.options,{getDisabled(f){return f[r]},getKey(f){return f[e]},getChildren(f){return f[n]}})}),W=g(()=>{const{cascade:e,multiple:n}=t;return n&&Array.isArray(k.value)?K.value.getCheckedKeys(k.value,{cascade:e,allowNotLoaded:t.allowCheckingNotLoaded}):{checkedKeys:[],indeterminateKeys:[]}}),j=g(()=>W.value.checkedKeys),ne=g(()=>W.value.indeterminateKeys),Te=g(()=>{const{treeNodePath:e,treeNode:n}=K.value.getPath(I.value);let r;return n===null?r=[K.value.treeNodes]:(r=e.map(f=>f.siblings),!n.isLeaf&&!D.value.has(n.key)&&n.children&&r.push(n.children)),r}),Ne=g(()=>{const{keyPath:e}=K.value.getPath(I.value);return e}),G=g(()=>p.value.self.optionHeight);Et(t.options)&&Ee(t.options,(e,n)=>{e!==n&&(I.value=null,M.value=null)});function oe(e){const{onUpdateShow:n,"onUpdate:show":r}=t;n&&Z(n,e),r&&Z(r,e),T.value=e}function $(e,n,r){const{onUpdateValue:f,"onUpdate:value":i,onChange:R}=t,{nTriggerFormInput:s,nTriggerFormChange:x}=B;f&&Z(f,e,n,r),i&&Z(i,e,n,r),R&&Z(R,e,n,r),b.value=e,s(),x()}function J(e){M.value=e}function X(e){I.value=e}function ie(e){const{value:{getNode:n}}=K;return e.map(r=>{var f;return((f=n(r))===null||f===void 0?void 0:f.rawNode)||null})}function se(e){var n;const{cascade:r,multiple:f,filterable:i}=t,{value:{check:R,getNode:s,getPath:x}}=K;if(f)try{const{checkedKeys:h}=R(e,W.value.checkedKeys,{cascade:r,checkStrategy:F.value,allowNotLoaded:t.allowCheckingNotLoaded});$(h,ie(h),h.map(ae=>{var ue;return xe((ue=x(ae))===null||ue===void 0?void 0:ue.treeNodePath)})),i&&Fe(),M.value=e,I.value=e}catch(h){if(h instanceof Xt){if(y.value){const ae=s(e);ae!==null&&y.value.showErrorMessage(ae.rawNode[t.labelField])}}else throw h}else if(F.value==="child"){const h=s(e);if(h!=null&&h.isLeaf)$(e,h.rawNode,xe(x(e).treeNodePath));else return!1}else{const h=s(e);$(e,(h==null?void 0:h.rawNode)||null,xe((n=x(e))===null||n===void 0?void 0:n.treeNodePath))}return!0}function de(e){const{cascade:n,multiple:r}=t;if(r){const{value:{uncheck:f,getNode:i,getPath:R}}=K,{checkedKeys:s}=f(e,W.value.checkedKeys,{cascade:n,checkStrategy:F.value,allowNotLoaded:t.allowCheckingNotLoaded});$(s,s.map(x=>{var h;return((h=i(x))===null||h===void 0?void 0:h.rawNode)||null}),s.map(x=>{var h;return xe((h=R(x))===null||h===void 0?void 0:h.treeNodePath)})),M.value=e,I.value=e}}const Pe=g(()=>{if(t.multiple){const{showPath:e,separator:n,labelField:r,cascade:f}=t,{getCheckedKeys:i,getNode:R}=K.value;return i(j.value,{cascade:f,checkStrategy:F.value,allowNotLoaded:t.allowCheckingNotLoaded}).checkedKeys.map(x=>{const h=R(x);return h===null?{label:String(x),value:x}:{label:e?Ke(h,n,r):h.rawNode[r],value:h.key}})}else return[]}),ge=g(()=>{const{multiple:e,showPath:n,separator:r,labelField:f}=t,{value:i}=k;if(!e&&!Array.isArray(i)){const{getNode:R}=K.value;if(i===null)return null;const s=R(i);return s===null?{label:String(i),value:i}:{label:n?Ke(s,r,f):s.rawNode[f],value:s.key}}else return null}),T=S(!1),E=z(t,"show"),_=je(E,T),pe=g(()=>{const{placeholder:e}=t;return e!==void 0?e:v.value.placeholder}),L=g(()=>!!(t.filterable&&V.value));Ee(_,e=>{if(!e||t.multiple)return;const{value:n}=k;!Array.isArray(n)&&n!==null?(M.value=n,I.value=n,en(()=>{var r;if(!_.value)return;const{value:f}=I;if(k.value!==null){const i=K.value.getNode(f);i&&((r=y.value)===null||r===void 0||r.scroll(i.level,i.index,he(G.value)))}})):(M.value=null,I.value=null)},{immediate:!0});function be(e){const{onBlur:n}=t,{nTriggerFormBlur:r}=B;n&&Z(n,e),r()}function ye(e){const{onFocus:n}=t,{nTriggerFormFocus:r}=B;n&&Z(n,e),r()}function Fe(){var e;(e=P.value)===null||e===void 0||e.focusInput()}function Xe(){var e;(e=P.value)===null||e===void 0||e.focus()}function we(){q.value||(V.value="",oe(!0),t.filterable&&Fe())}function Y(e=!1){e&&Xe(),oe(!1),V.value=""}function _e(e){var n;L.value||_.value&&(!((n=P.value)===null||n===void 0)&&n.$el.contains(Yt(e))||Y())}function Ye(e){L.value&&_e(e)}function Be(){t.clearFilterAfterSelect&&(V.value="")}function ke(e){var n,r,f;const{value:i}=M,{value:R}=K;switch(e){case"prev":if(i!==null){const s=R.getPrev(i,{loop:!0});s!==null&&(J(s.key),(n=y.value)===null||n===void 0||n.scroll(s.level,s.index,he(G.value)))}break;case"next":if(i===null){const s=R.getFirstAvailableNode();s!==null&&(J(s.key),(r=y.value)===null||r===void 0||r.scroll(s.level,s.index,he(G.value)))}else{const s=R.getNext(i,{loop:!0});s!==null&&(J(s.key),(f=y.value)===null||f===void 0||f.scroll(s.level,s.index,he(G.value)))}break;case"child":if(i!==null){const s=R.getNode(i);if(s!==null)if(s.shallowLoaded){const x=R.getChild(i);x!==null&&(X(i),J(x.key))}else{const{value:x}=D;if(!x.has(i)){w(i),X(i);const{onLoad:h}=t;h&&h(s.rawNode).then(()=>{O(i)}).catch(()=>{O(i)})}}}break;case"parent":if(i!==null){const s=R.getParent(i);if(s!==null){J(s.key);const x=s.getParent();X(x===null?null:x.key)}}break}}function Ie(e){var n,r;switch(e.key){case" ":case"ArrowDown":case"ArrowUp":if(t.filterable&&_.value)break;e.preventDefault();break}if(!Le(e,"action"))switch(e.key){case" ":if(t.filterable)return;case"Enter":if(!_.value)we();else{const{value:f}=L,{value:i}=M;if(f)C.value&&C.value.enter()&&Be();else if(i!==null)if(j.value.includes(i)||ne.value.includes(i))de(i);else{const R=se(i);!t.multiple&&R&&Y(!0)}}break;case"ArrowUp":e.preventDefault(),_.value&&(L.value?(n=C.value)===null||n===void 0||n.prev():ke("prev"));break;case"ArrowDown":e.preventDefault(),_.value?L.value?(r=C.value)===null||r===void 0||r.next():ke("next"):we();break;case"ArrowLeft":e.preventDefault(),_.value&&!L.value&&ke("parent");break;case"ArrowRight":e.preventDefault(),_.value&&!L.value&&ke("child");break;case"Escape":_.value&&(Zt(e),Y(!0))}}function Ze(e){Ie(e)}function et(e){e.stopPropagation(),t.multiple?$([],[],[]):$(null,null,null)}function tt(e){var n;!((n=y.value)===null||n===void 0)&&n.$el.contains(e.relatedTarget)||(u.value=!0,ye(e))}function nt(e){var n;!((n=y.value)===null||n===void 0)&&n.$el.contains(e.relatedTarget)||(u.value=!1,be(e),Y())}function ot(e){var n;!((n=P.value)===null||n===void 0)&&n.$el.contains(e.relatedTarget)||(u.value=!0,ye(e))}function lt(e){var n;!((n=P.value)===null||n===void 0)&&n.$el.contains(e.relatedTarget)||(u.value=!1,be(e))}function at(e){Le(e,"action")||t.multiple&&t.filter&&(e.preventDefault(),Fe())}function rt(){Y(!0)}function it(){t.filterable?we():_.value?Y(!0):we()}function st(e){V.value=e.target.value}function dt(e){const{multiple:n}=t,{value:r}=k;n&&Array.isArray(r)&&e.value!==void 0?de(e.value):$(null,null,null)}function Ae(){var e;(e=te.value)===null||e===void 0||e.syncPosition()}function ze(){var e;(e=Q.value)===null||e===void 0||e.syncPosition()}function ut(){_.value&&(L.value?Ae():ze())}const Oe=g(()=>!!(t.multiple&&t.cascade||F.value!=="child"));Ut(ve,{slots:a,mergedClsPrefixRef:l,mergedThemeRef:p,mergedValueRef:k,checkedKeysRef:j,indeterminateKeysRef:ne,hoverKeyPathRef:Ne,mergedCheckStrategyRef:F,showCheckboxRef:Oe,cascadeRef:z(t,"cascade"),multipleRef:z(t,"multiple"),keyboardKeyRef:M,hoverKeyRef:I,remoteRef:z(t,"remote"),loadingKeySetRef:D,expandTriggerRef:z(t,"expandTrigger"),isMountedRef:Ht(),onLoadRef:z(t,"onLoad"),virtualScrollRef:z(t,"virtualScroll"),optionHeightRef:G,localeRef:v,labelFieldRef:z(t,"labelField"),renderLabelRef:z(t,"renderLabel"),getColumnStyleRef:z(t,"getColumnStyle"),renderPrefixRef:z(t,"renderPrefix"),renderSuffixRef:z(t,"renderSuffix"),syncCascaderMenuPosition:ze,syncSelectMenuPosition:Ae,updateKeyboardKey:J,updateHoverKey:X,addLoadingKey:w,deleteLoadingKey:O,doCheck:se,doUncheck:de,closeMenu:Y,handleSelectMenuClickOutside:Ye,handleCascaderMenuClickOutside:_e,clearPattern:Be});const ct={focus:()=>{var e;(e=P.value)===null||e===void 0||e.focus()},blur:()=>{var e;(e=P.value)===null||e===void 0||e.blur()},getCheckedData:()=>{if(Oe.value){const e=j.value;return{keys:e,options:ie(e)}}return{keys:[],options:[]}},getIndeterminateData:()=>{if(Oe.value){const e=ne.value;return{keys:e,options:ie(e)}}return{keys:[],options:[]}}},Ve=g(()=>{const{self:{optionArrowColor:e,optionTextColor:n,optionTextColorActive:r,optionTextColorDisabled:f,optionCheckMarkColor:i,menuColor:R,menuBoxShadow:s,menuDividerColor:x,menuBorderRadius:h,menuHeight:ae,optionColorHover:ue,optionHeight:ft,optionFontSize:ht,loadingColor:vt,columnWidth:mt},common:{cubicBezierEaseInOut:gt}}=p.value;return{"--n-bezier":gt,"--n-menu-border-radius":h,"--n-menu-box-shadow":s,"--n-menu-height":ae,"--n-column-width":mt,"--n-menu-color":R,"--n-menu-divider-color":x,"--n-option-height":ft,"--n-option-font-size":ht,"--n-option-text-color":n,"--n-option-text-color-disabled":f,"--n-option-text-color-active":r,"--n-option-color-hover":ue,"--n-option-check-mark-color":i,"--n-option-arrow-color":e,"--n-menu-mask-color":qt(R,{alpha:.75}),"--n-loading-color":vt}}),le=m?Wt("cascader",void 0,Ve,t):void 0;return Object.assign(Object.assign({},ct),{handleTriggerResize:ut,mergedStatus:ee,selectMenuFollowerRef:te,cascaderMenuFollowerRef:Q,triggerInstRef:P,selectMenuInstRef:C,cascaderMenuInstRef:y,mergedBordered:o,mergedClsPrefix:l,namespace:c,mergedValue:k,mergedShow:_,showSelectMenu:L,pattern:V,treeMate:K,mergedSize:H,mergedDisabled:q,localizedPlaceholder:pe,selectedOption:ge,selectedOptions:Pe,adjustedTo:me,menuModel:Te,handleMenuTabout:rt,handleMenuFocus:ot,handleMenuBlur:lt,handleMenuKeydown:Ze,handleMenuMousedown:at,handleTriggerFocus:tt,handleTriggerBlur:nt,handleTriggerClick:it,handleClear:et,handleDeleteOption:dt,handlePatternInput:st,handleKeydown:Ie,focused:u,optionHeight:G,mergedTheme:p,cssVars:m?void 0:Ve,themeClass:le==null?void 0:le.themeClass,onRender:le==null?void 0:le.onRender})},render(){const{mergedClsPrefix:t}=this;return d("div",{class:"".concat(t,"-cascader")},d(Gt,null,{default:()=>[d(Jt,null,{default:()=>d(Qt,{onResize:this.handleTriggerResize,ref:"triggerInstRef",status:this.mergedStatus,clsPrefix:t,maxTagCount:this.maxTagCount,ellipsisTagPopoverProps:this.ellipsisTagPopoverProps,bordered:this.mergedBordered,size:this.mergedSize,theme:this.mergedTheme.peers.InternalSelection,themeOverrides:this.mergedTheme.peerOverrides.InternalSelection,active:this.mergedShow,pattern:this.pattern,placeholder:this.localizedPlaceholder,selectedOption:this.selectedOption,selectedOptions:this.selectedOptions,multiple:this.multiple,filterable:this.filterable,clearable:this.clearable,disabled:this.mergedDisabled,focused:this.focused,onFocus:this.handleTriggerFocus,onBlur:this.handleTriggerBlur,onClick:this.handleTriggerClick,onClear:this.handleClear,onDeleteOption:this.handleDeleteOption,onPatternInput:this.handlePatternInput,onKeydown:this.handleKeydown},{arrow:()=>{var a,o;return(o=(a=this.$slots).arrow)===null||o===void 0?void 0:o.call(a)}})}),d(Ue,{key:"cascaderMenu",ref:"cascaderMenuFollowerRef",show:this.mergedShow&&!this.showSelectMenu,containerClass:this.namespace,placement:this.placement,width:this.options.length?void 0:"target",teleportDisabled:this.adjustedTo===Ce.tdkey,to:this.adjustedTo},{default:()=>{var a;(a=this.onRender)===null||a===void 0||a.call(this);const{menuProps:o}=this;return d(dn,Object.assign({},o,{ref:"cascaderMenuInstRef",class:[this.themeClass,o==null?void 0:o.class],value:this.mergedValue,show:this.mergedShow&&!this.showSelectMenu,menuModel:this.menuModel,style:[this.cssVars,o==null?void 0:o.style],onFocus:this.handleMenuFocus,onBlur:this.handleMenuBlur,onKeydown:this.handleMenuKeydown,onMousedown:this.handleMenuMousedown,onTabout:this.handleMenuTabout}),{action:()=>{var l,c;return(c=(l=this.$slots).action)===null||c===void 0?void 0:c.call(l)},empty:()=>{var l,c;return(c=(l=this.$slots).empty)===null||c===void 0?void 0:c.call(l)}})}}),d(Ue,{key:"selectMenu",ref:"selectMenuFollowerRef",show:this.mergedShow&&this.showSelectMenu,containerClass:this.namespace,width:"target",placement:this.placement,to:this.adjustedTo,teleportDisabled:this.adjustedTo===Ce.tdkey},{default:()=>{var a;(a=this.onRender)===null||a===void 0||a.call(this);const{filterMenuProps:o}=this;return d(un,Object.assign({},o,{ref:"selectMenuInstRef",class:[this.themeClass,o==null?void 0:o.class],value:this.mergedValue,show:this.mergedShow&&this.showSelectMenu,pattern:this.pattern,multiple:this.multiple,tmNodes:this.treeMate.treeNodes,filter:this.filter,labelField:this.labelField,separator:this.separator,style:[this.cssVars,o==null?void 0:o.style]}))}})]}))}});export{vn as N};