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