UNPKG

ll-package

Version:

2 lines (1 loc) 6.27 kB
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("../../../@babel/runtime/helpers/esm/objectSpread2.js"),u=require("../../../@babel/runtime/helpers/esm/extends.js"),n=require("vue"),U=require("../vc-tree-select/TreeSelect.js"),j=require("../vc-tree-select/TreeNode.js"),x=require("../vc-tree-select/utils/strategyUtil.js"),_=require("../_util/classNames.js"),Pe=require("../_util/props-util/initDefaultProps.js"),M=require("../_util/omit.js"),$e=require("../_util/vue-types/index.js"),ye=require("../config-provider/hooks/useConfigInject.js"),T=require("../vc-util/devWarning.js"),Fe=require("../select/utils/iconUtil.js"),He=require("../tree/utils/iconUtil.js"),Ae=require("../vc-util/warning.js"),De=require("../_util/props-util/index.js"),E=require("../form/FormItemContext.js"),_e=require("../_util/transition.js"),L=require("../_util/statusUtils.js"),r=require("../_util/type.js"),Ee=require("../select/style/index.js"),Le=require("./style/index.js"),Oe=require("../space/Compact.js"),Ue=require("../config-provider/DisabledContext.js"),O=(e,v,i)=>i!==void 0?i:`${e}-${v}`;function W(){return u.default(u.default({},M.default(U.treeSelectProps(),["showTreeIcon","treeMotion","inputIcon","getInputElement","treeLine","customSlots"])),{suffixIcon:$e.default.any,size:r.stringType(),bordered:r.booleanType(),treeLine:r.someType([Boolean,Object]),replaceFields:r.objectType(),placement:r.stringType(),status:r.stringType(),popupClassName:String,dropdownClassName:String,"onUpdate:value":r.functionType(),"onUpdate:treeExpandedKeys":r.functionType(),"onUpdate:searchValue":r.functionType()})}const b=n.defineComponent({compatConfig:{MODE:3},name:"ATreeSelect",inheritAttrs:!1,props:Pe.default(W(),{choiceTransitionName:"",listHeight:256,treeIcon:!1,listItemHeight:26,bordered:!0}),slots:Object,setup(e,v){let{attrs:i,slots:l,expose:z,emit:s}=v;Ae.warning(!(e.treeData===void 0&&l.default),"`children` of TreeSelect is deprecated. Please use `treeData` instead."),T.default(e.multiple!==!1||!e.treeCheckable,"TreeSelect","`multiple` will always be `true` when `treeCheckable` is true"),T.default(e.replaceFields===void 0,"TreeSelect","`replaceFields` is deprecated, please use fieldNames instead"),T.default(!e.dropdownClassName,"TreeSelect","`dropdownClassName` is deprecated. Please use `popupClassName` instead.");const p=E.useInjectFormItemContext(),N=E.FormItemInputContext.useInject(),R=n.computed(()=>L.getMergedStatus(N.status,e.status)),{prefixCls:o,renderEmpty:V,direction:d,virtual:k,dropdownMatchSelectWidth:B,size:K,getPopupContainer:h,getPrefixCls:C,disabled:G}=ye.default("select",e),{compactSize:J,compactItemClassnames:Q}=Oe.useCompactItemContext(o,d),q=n.computed(()=>J.value||K.value),X=Ue.useInjectDisabled(),Y=n.computed(()=>{var t;return(t=G.value)!==null&&t!==void 0?t:X.value}),P=n.computed(()=>C()),$=n.computed(()=>e.placement!==void 0?e.placement:d.value==="rtl"?"bottomRight":"bottomLeft"),Z=n.computed(()=>O(P.value,_e.getTransitionDirection($.value),e.transitionName)),ee=n.computed(()=>O(P.value,"",e.choiceTransitionName)),y=n.computed(()=>C("select-tree",e.prefixCls)),m=n.computed(()=>C("tree-select",e.prefixCls)),[te,F]=Ee.default(o),[ne]=Le.default(m,y),ae=n.computed(()=>_.default(e.popupClassName||e.dropdownClassName,`${m.value}-dropdown`,{[`${m.value}-dropdown-rtl`]:d.value==="rtl"},F.value)),H=n.computed(()=>!!(e.treeCheckable||e.multiple)),le=n.computed(()=>e.showArrow!==void 0?e.showArrow:e.loading||!H.value),g=n.ref();z({focus(){var t,a;(a=(t=g.value).focus)===null||a===void 0||a.call(t)},blur(){var t,a;(a=(t=g.value).blur)===null||a===void 0||a.call(t)}});const oe=function(){for(var t=arguments.length,a=new Array(t),c=0;c<t;c++)a[c]=arguments[c];s("update:value",a[0]),s("change",...a),p.onFieldChange()},re=t=>{s("update:treeExpandedKeys",t),s("treeExpand",t)},ue=t=>{s("update:searchValue",t),s("search",t)},se=t=>{s("blur",t),p.onFieldBlur()};return()=>{var t,a;const{notFoundContent:c=(t=l.notFoundContent)===null||t===void 0?void 0:t.call(l),prefixCls:ce,bordered:ie,listHeight:de,listItemHeight:me,multiple:fe,treeIcon:ve,treeLine:A,showArrow:pe,switcherIcon:he=(a=l.switcherIcon)===null||a===void 0?void 0:a.call(l),fieldNames:Ce=e.replaceFields,id:ge=p.id.value}=e,{isFormItemInput:Se,hasFeedback:S,feedbackIcon:Ie}=N,{suffixIcon:xe,removeIcon:Te,clearIcon:be}=Fe.default(u.default(u.default({},e),{multiple:H.value,showArrow:le.value,hasFeedback:S,feedbackIcon:Ie,prefixCls:o.value}),l);let I;c!==void 0?I=c:I=V("Select");const we=M.default(e,["suffixIcon","itemIcon","removeIcon","clearIcon","switcherIcon","bordered","status","onUpdate:value","onUpdate:treeExpandedKeys","onUpdate:searchValue"]),Ne=_.default(!ce&&m.value,{[`${o.value}-lg`]:q.value==="large",[`${o.value}-sm`]:q.value==="small",[`${o.value}-rtl`]:d.value==="rtl",[`${o.value}-borderless`]:!ie,[`${o.value}-in-form-item`]:Se},L.getStatusClassNames(o.value,R.value,S),Q.value,i.class,F.value),D={};return e.treeData===void 0&&l.default&&(D.children=De.flattenChildren(l.default())),te(ne(n.createVNode(U.default,f.default(f.default(f.default(f.default({},i),we),{},{disabled:Y.value,virtual:k.value,dropdownMatchSelectWidth:B.value,id:ge,fieldNames:Ce,ref:g,prefixCls:o.value,class:Ne,listHeight:de,listItemHeight:me,treeLine:!!A,inputIcon:xe,multiple:fe,removeIcon:Te,clearIcon:be,switcherIcon:qe=>He.default(y.value,he,qe,l.leafIcon,A),showTreeIcon:ve,notFoundContent:I,getPopupContainer:h==null?void 0:h.value,treeMotion:null,dropdownClassName:ae.value,choiceTransitionName:ee.value,onChange:oe,onBlur:se,onSearch:ue,onTreeExpand:re},D),{},{transitionName:Z.value,customSlots:u.default(u.default({},l),{treeCheckable:()=>n.createVNode("span",{class:`${o.value}-tree-checkbox-inner`},null)}),maxTagPlaceholder:e.maxTagPlaceholder||l.maxTagPlaceholder,placement:$.value,showArrow:S||pe}),u.default(u.default({},l),{treeCheckable:()=>n.createVNode("span",{class:`${o.value}-tree-checkbox-inner`},null)}))))}}}),w=j.default,je=u.default(b,{TreeNode:j.default,SHOW_ALL:x.SHOW_ALL,SHOW_PARENT:x.SHOW_PARENT,SHOW_CHILD:x.SHOW_CHILD,install:e=>(e.component(b.name,b),e.component(w.displayName,w),e)});exports.TreeSelectNode=w;exports.default=je;exports.treeSelectProps=W;