@ccn-ui-kit/tree 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +1 -0
- package/dist/index.js +527 -0
- package/dist/packages/components/__tests__/loading.spec.d.ts +1 -0
- package/dist/packages/components/badge/index.d.ts +10 -0
- package/dist/packages/components/badge/src/badge.d.ts +25 -0
- package/dist/packages/components/breadcrumb/index.d.ts +12 -0
- package/dist/packages/components/breadcrumb/src/breadcrumb-item.d.ts +13 -0
- package/dist/packages/components/breadcrumb/src/breadcrumb.d.ts +10 -0
- package/dist/packages/components/button/index.d.ts +10 -0
- package/dist/packages/components/button/src/button.d.ts +25 -0
- package/dist/packages/components/date-picker/index.d.ts +10 -0
- package/dist/packages/components/date-picker/src/date-picker.d.ts +20 -0
- package/dist/packages/components/descriptions/index.d.ts +12 -0
- package/dist/packages/components/descriptions/src/descriptions-item.d.ts +13 -0
- package/dist/packages/components/descriptions/src/descriptions.d.ts +17 -0
- package/dist/packages/components/divider/index.d.ts +10 -0
- package/dist/packages/components/divider/src/divider.d.ts +20 -0
- package/dist/packages/components/dropdown/index.d.ts +12 -0
- package/dist/packages/components/dropdown/src/dropdown-item.d.ts +20 -0
- package/dist/packages/components/dropdown/src/dropdown.d.ts +46 -0
- package/dist/packages/components/form/index.d.ts +12 -0
- package/dist/packages/components/form/src/form-item.d.ts +45 -0
- package/dist/packages/components/form/src/form.d.ts +96 -0
- package/dist/packages/components/icon/index.d.ts +11 -0
- package/dist/packages/components/icon/src/icon.d.ts +18 -0
- package/dist/packages/components/icon/src/icons.d.ts +50 -0
- package/dist/packages/components/input/index.d.ts +10 -0
- package/dist/packages/components/input/src/input.d.ts +25 -0
- package/dist/packages/components/link/index.d.ts +10 -0
- package/dist/packages/components/link/src/link.d.ts +25 -0
- package/dist/packages/components/loading/index.d.ts +10 -0
- package/dist/packages/components/loading/src/loading.d.ts +15 -0
- package/dist/packages/components/menu/index.d.ts +14 -0
- package/dist/packages/components/menu/src/menu-item.d.ts +12 -0
- package/dist/packages/components/menu/src/menu.d.ts +40 -0
- package/dist/packages/components/menu/src/sub-menu.d.ts +12 -0
- package/dist/packages/components/message/index.d.ts +12 -0
- package/dist/packages/components/message/src/manager.d.ts +14 -0
- package/dist/packages/components/message/src/message.d.ts +28 -0
- package/dist/packages/components/modal/index.d.ts +10 -0
- package/dist/packages/components/modal/src/modal.d.ts +46 -0
- package/dist/packages/components/notification/index.d.ts +12 -0
- package/dist/packages/components/notification/src/manager.d.ts +14 -0
- package/dist/packages/components/notification/src/notification.d.ts +44 -0
- package/dist/packages/components/pagination/index.d.ts +10 -0
- package/dist/packages/components/pagination/src/pagination.d.ts +30 -0
- package/dist/packages/components/popconfirm/index.d.ts +10 -0
- package/dist/packages/components/popconfirm/src/popconfirm.d.ts +56 -0
- package/dist/packages/components/rich-editor/index.d.ts +10 -0
- package/dist/packages/components/rich-editor/src/rich-editor.d.ts +36 -0
- package/dist/packages/components/select/index.d.ts +10 -0
- package/dist/packages/components/select/src/select.d.ts +45 -0
- package/dist/packages/components/space/index.d.ts +10 -0
- package/dist/packages/components/space/src/space.d.ts +33 -0
- package/dist/packages/components/steps/index.d.ts +12 -0
- package/dist/packages/components/steps/src/step.d.ts +28 -0
- package/dist/packages/components/steps/src/steps.d.ts +46 -0
- package/dist/packages/components/table/index.d.ts +10 -0
- package/dist/packages/components/table/src/table.d.ts +56 -0
- package/dist/packages/components/tabs/index.d.ts +12 -0
- package/dist/packages/components/tabs/src/tab-pane.d.ts +22 -0
- package/dist/packages/components/tabs/src/tabs.d.ts +43 -0
- package/dist/packages/components/tree/index.d.ts +10 -0
- package/dist/packages/components/tree/src/tree-node.vue.d.ts +29 -0
- package/dist/packages/components/tree/src/tree.d.ts +134 -0
- package/dist/packages/components/tree/src/tree.vue.d.ts +167 -0
- package/dist/packages/components/upload/index.d.ts +10 -0
- package/dist/packages/components/upload/src/upload.d.ts +103 -0
- package/dist/packages/directives/index.d.ts +2 -0
- package/dist/packages/directives/loading/index.d.ts +11 -0
- package/dist/packages/directives/permission/index.d.ts +3 -0
- package/dist/packages/ui-kit/index.d.ts +34 -0
- package/dist/packages/utils/dom.d.ts +5 -0
- package/dist/packages/utils/index.d.ts +3 -0
- package/dist/packages/utils/types.d.ts +7 -0
- package/dist/packages/utils/vue-helper.d.ts +9 -0
- package/dist/play/main.d.ts +1 -0
- package/dist/play/vite.config.d.ts +2 -0
- package/package.json +27 -0
- package/style/index.scss +109 -0
package/dist/index.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),Q={name:{type:String,required:!0},size:{type:[Number,String],default:16},color:{type:String,default:""},spin:Boolean},q={search:'<circle cx="11" cy="11" r="8" /><line x1="21" y1="21" x2="16.65" y2="16.65" />',plus:'<line x1="12" y1="5" x2="12" y2="19" /><line x1="5" y1="12" x2="19" y2="12" />',minus:'<line x1="5" y1="12" x2="19" y2="12" />',close:'<line x1="18" y1="6" x2="6" y2="18" /><line x1="6" y1="6" x2="18" y2="18" />',check:'<polyline points="20 6 9 17 4 12" />',loading:'<path d="M21 12a9 9 0 1 1-6.219-8.56" />',refresh:'<polyline points="23 4 23 10 17 10" /><polyline points="1 20 1 14 7 14" /><path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15" />',edit:'<path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" /><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z" />',delete:'<polyline points="3 6 5 6 21 6" /><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" /><line x1="10" y1="11" x2="10" y2="17" /><line x1="14" y1="11" x2="14" y2="17" />',download:'<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" /><polyline points="7 10 12 15 17 10" /><line x1="12" y1="15" x2="12" y2="3" />',upload:'<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" /><polyline points="17 8 12 3 7 8" /><line x1="12" y1="3" x2="12" y2="15" />',setting:'<circle cx="12" cy="12" r="3" /><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z" />',user:'<path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2" /><circle cx="12" cy="7" r="4" />',home:'<path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z" /><polyline points="9 22 9 12 15 12 15 22" />',calendar:'<rect x="3" y="4" width="18" height="18" rx="2" ry="2" /><line x1="16" y1="2" x2="16" y2="6" /><line x1="8" y1="2" x2="8" y2="6" /><line x1="3" y1="10" x2="21" y2="10" />',clock:'<circle cx="12" cy="12" r="10" /><polyline points="12 6 12 12 16 14" />',star:'<polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2" />',heart:'<path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z" />',message:'<path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z" />',bell:'<path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9" /><path d="M13.73 21a2 2 0 0 1-3.46 0" />',mail:'<path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z" /><polyline points="22,6 12,13 2,6" />',eye:'<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" /><circle cx="12" cy="12" r="3" />',lock:'<rect x="3" y="11" width="18" height="11" rx="2" ry="2" /><path d="M7 11V7a5 5 0 0 1 10 0v4" />',link:'<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" /><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" />',"arrow-up":'<line x1="12" y1="19" x2="12" y2="5" /><polyline points="5 12 12 5 19 12" />',"arrow-down":'<line x1="12" y1="5" x2="12" y2="19" /><polyline points="19 12 12 19 5 12" />',"arrow-left":'<line x1="19" y1="12" x2="5" y2="12" /><polyline points="12 19 5 12 12 5" />',"arrow-right":'<line x1="5" y1="12" x2="19" y2="12" /><polyline points="12 5 19 12 12 19" />',"chevron-up":'<polyline points="18 15 12 9 6 15" />',"chevron-down":'<polyline points="6 9 12 15 18 9" />',"chevron-left":'<polyline points="15 18 9 12 15 6" />',"chevron-right":'<polyline points="9 18 15 12 9 6" />',more:'<circle cx="12" cy="12" r="1" /><circle cx="19" cy="12" r="1" /><circle cx="5" cy="12" r="1" />',menu:'<line x1="3" y1="12" x2="21" y2="12" /><line x1="3" y1="6" x2="21" y2="6" /><line x1="3" y1="18" x2="21" y2="18" />',filter:'<polygon points="22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3" />',copy:'<rect x="9" y="9" width="13" height="13" rx="2" ry="2" /><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" />',"external-link":'<path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" /><polyline points="15 3 21 3 21 9" /><line x1="10" y1="14" x2="21" y2="3" />',zap:'<polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2" />',"log-out":'<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" /><polyline points="16 17 21 12 16 7" /><line x1="21" y1="12" x2="9" y2="12" />',grid:'<rect x="3" y="3" width="7" height="7" /><rect x="14" y="3" width="7" height="7" /><rect x="14" y="14" width="7" height="7" /><rect x="3" y="14" width="7" height="7" />',info:'<circle cx="12" cy="12" r="10" /><line x1="12" y1="16" x2="12" y2="12" /><line x1="12" y1="8" x2="12.01" y2="8" />',success:'<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14" /><polyline points="22 4 12 14.01 9 11.01" />',warning:'<path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z" /><line x1="12" y1="9" x2="12" y2="13" /><line x1="12" y1="17" x2="12.01" y2="17" />',error:'<circle cx="12" cy="12" r="10" /><line x1="15" y1="9" x2="9" y2="15" /><line x1="9" y1="9" x2="15" y2="15" />',question:'<circle cx="12" cy="12" r="10" /><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3" /><line x1="12" y1="17" x2="12.01" y2="17" />',"plus-circle":'<circle cx="12" cy="12" r="10" /><line x1="12" y1="8" x2="12" y2="16" /><line x1="8" y1="12" x2="16" y2="12" />'};function W(y){return y in q}const X={viewBox:"0 0 24 24",fill:"none",stroke:"currentColor","stroke-width":"2","stroke-linecap":"round","stroke-linejoin":"round"},Y=["innerHTML"],F=e.defineComponent({__name:"icon",props:Q,setup(y){const d=y,a=e.computed(()=>W(d.name)?q[d.name]:""),o=e.computed(()=>({fontSize:typeof d.size=="number"?`${d.size}px`:d.size,...d.color?{color:d.color}:{}}));return(s,n)=>(e.openBlock(),e.createElementBlock("span",{class:e.normalizeClass(["ui-icon",{"is-spin":s.spin}]),style:e.normalizeStyle(o.value),role:"img"},[(e.openBlock(),e.createElementBlock("svg",X,[e.createElementVNode("g",{innerHTML:a.value},null,8,Y)]))],6))}}),H={label:"label",children:"children",disabled:"disabled",isLeaf:"isLeaf",key:"key"},R={data:{type:Array,default:()=>[]},props:{type:Object,default:()=>({})},nodeKey:{type:String,default:""},showCheckbox:Boolean,checkStrictly:Boolean,defaultExpandAll:Boolean,defaultExpandedKeys:{type:Array,default:()=>[]},defaultCheckedKeys:{type:Array,default:()=>[]},expandOnClickNode:{type:Boolean,default:!0},currentNodeKey:{type:[String,Number],default:null},lazy:Boolean,load:{type:Function,default:void 0},emptyText:{type:String,default:"暂无数据"}},U={"update:current-node-key":null,"update:checked-keys":null,"node-click":(y,d,a)=>a instanceof MouseEvent,"node-expand":()=>!0,"node-collapse":()=>!0,check:(y,d)=>!0,"check-change":(y,d,a)=>!0,"node-contextmenu":(y,d,a)=>!0},T=Symbol("ui-tree"),Z={key:2,class:"ui-tree-node__expand-placeholder"},ee=["checked","disabled"],le={key:0,class:"ui-tree-node__children"},te=e.defineComponent({__name:"tree-node",props:{node:{}},setup(y){const d=y,a=e.inject(T),o=e.ref(null),s=e.computed(()=>(a==null?void 0:a.config.value)??H),n=e.computed(()=>d.node),g=e.computed(()=>!!a&&a.expandedKeys.value.has(n.value.key)),u=e.computed(()=>!!a&&a.checkedKeys.value.has(n.value.key)),M=e.computed(()=>!!a&&a.halfCheckedKeys.value.has(n.value.key)),v=e.computed(()=>!!a&&a.selectedKey.value===n.value.key),c=e.computed(()=>!!n.value.data[s.value.disabled]),C=e.computed(()=>!!a&&a.loadingKeys.value.has(n.value.key)),m=e.computed(()=>!!a&&a.showCheckbox.value),x=e.computed(()=>n.value.children);e.watchEffect(()=>{o.value&&(o.value.indeterminate=M.value)}),e.watch([g,()=>x.value.length],([f,_])=>{!a||!f||_>0||a.lazy.value&&!n.value.isLeaf&&!C.value&&a.loadNodeData(n.value)},{immediate:!0});function E(){a==null||a.toggleExpand(n.value)}function N(){a==null||a.toggleCheck(n.value,n.value.data)}function B(f){a==null||a.handleNodeClick(n.value,n.value.data,f)}function z(f){a==null||a.handleNodeContextMenu(n.value,n.value.data,f)}return(f,_)=>{const S=e.resolveComponent("TreeNode",!0);return e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["ui-tree-node",{"is-current":v.value,"is-expanded":g.value}])},[e.createCommentVNode(" 节点行 "),e.createElementVNode("div",{class:"ui-tree-node__content",style:e.normalizeStyle({paddingLeft:`${(n.value.level-1)*18+4}px`}),onClick:B,onContextmenu:e.withModifiers(z,["prevent"])},[e.createElementVNode("span",{class:e.normalizeClass(["ui-tree-node__expand-icon",{"is-loading":C.value}]),onClick:e.withModifiers(E,["stop"])},[C.value?(e.openBlock(),e.createBlock(e.unref(F),{key:0,name:"loading",size:14,spin:""})):n.value.isLeaf?(e.openBlock(),e.createElementBlock("span",Z)):(e.openBlock(),e.createBlock(e.unref(F),{key:1,name:g.value?"chevron-down":"chevron-right",size:14},null,8,["name"]))],2),m.value?(e.openBlock(),e.createElementBlock("label",{key:0,class:"ui-tree-node__checkbox",onClick:_[0]||(_[0]=e.withModifiers(()=>{},["stop"]))},[e.createElementVNode("input",{ref_key:"checkboxEl",ref:o,type:"checkbox",checked:u.value,disabled:c.value,onChange:N},null,40,ee)])):e.createCommentVNode("v-if",!0),e.createElementVNode("span",{class:e.normalizeClass(["ui-tree-node__label",{"is-disabled":c.value}])},[e.renderSlot(f.$slots,"default",{node:n.value,data:n.value.data},()=>[e.createTextVNode(e.toDisplayString(n.value.data[s.value.label]),1)])],2)],36),e.createCommentVNode(" 子节点(v-if 移除空容器,v-show 负责展开动画) "),e.createVNode(e.Transition,{name:"ui-tree-node__fade"},{default:e.withCtx(()=>[x.value.length?e.withDirectives((e.openBlock(),e.createElementBlock("div",le,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(x.value,w=>(e.openBlock(),e.createBlock(S,{key:w.key,node:w},{default:e.withCtx(()=>[e.renderSlot(f.$slots,"default",{node:w,data:w.data})]),_:2},1032,["node"]))),128))],512)),[[e.vShow,g.value]]):e.createCommentVNode("v-if",!0)]),_:3})],2)}}}),ae={class:"ui-tree"},ne={key:0,class:"ui-tree__empty"},$=e.defineComponent({__name:"tree",props:R,emits:U,setup(y,{expose:d,emit:a}){const o=y,s=a,n=e.computed(()=>({...H,...o.props})),g=e.computed(()=>o.nodeKey||n.value.key||"key"),u=e.reactive(new Map),M=e.computed(()=>Array.from(u.values()).filter(l=>l.level===1)),v=e.ref(new Set),c=e.ref(new Set),C=e.ref(new Set),m=e.ref(null),x=e.ref(new Set),E=e.reactive(new Set);function N(l,t,i,p){l.forEach((r,h)=>{const k=t?`${t.path}-${h}`:`${h}`,b=r[g.value],j=b==null||b===""?`__gen-${k}`:b,A={key:j,data:r,parent:t,children:[],level:i,isLeaf:o.lazy?!!r[n.value.isLeaf]:!Array.isArray(r[n.value.children])||r[n.value.children].length===0,isLazy:o.lazy,path:k};u.set(j,A),t&&t.children.push(A);const V=r[n.value.children];Array.isArray(V)&&V.length&&N(V,A,i+1)})}let B=!1;function z(){u.clear(),N(o.data,null,1),B||(_(),B=!0),D()}function f(l){!o.load||x.value.has(l.key)||(x.value=new Set(x.value).add(l.key),o.load({key:l.key,level:l.level,data:l.data},t=>{const i=new Set(x.value);i.delete(l.key),x.value=i,E.add(l.key);const p=n.value.children,r=Array.isArray(l.data[p])?l.data[p]:[];l.data[p]=r.concat(t),t.length===0&&(l.data[n.value.isLeaf]=!0)}))}function _(){const l=new Set;o.defaultExpandAll&&u.forEach(t=>{t.isLeaf||l.add(t.key)}),o.defaultExpandedKeys.forEach(t=>l.add(t)),v.value=l,c.value=new Set(o.defaultCheckedKeys),m.value=o.currentNodeKey??null}e.watch(()=>o.currentNodeKey,l=>{m.value=l??null});function S(l){return!!l.data[n.value.disabled]}function w(l){let t=l.parent;for(;t;){if(!t.children.length){t=t.parent;continue}t.children.every(p=>c.value.has(p.key))?c.value.add(t.key):c.value.delete(t.key),t=t.parent}}function K(){const l=new Set;u.forEach(t=>{if(!t.children.length)return;const i=t.children.some(r=>c.value.has(r.key)),p=t.children.every(r=>c.value.has(r.key));i&&!p&&l.add(t.key)}),C.value=l}function D(){for(const l of c.value)u.has(l)||c.value.delete(l);o.checkStrictly||(u.forEach(l=>{l.children.length&&c.value.delete(l.key)}),Array.from(c.value).forEach(l=>{const t=u.get(l);t&&w(t)})),K()}function P(l,t){if(S(l))return;const i=!c.value.has(l.key),p=[],r=(h,k)=>{c.value.has(h.key)!==k&&p.push({node:h,checked:k}),k?c.value.add(h.key):c.value.delete(h.key)};if(o.checkStrictly)r(l,i);else{const h=k=>{r(k,i),k.children.forEach(h)};h(l),w(l),K()}p.forEach(({node:h,checked:k})=>s("check-change",h,h.data,k)),s("check",l,t),s("update:checked-keys",L())}function I(l){v.value.has(l.key)||(o.lazy&&!l.isLeaf&&l.children.length===0&&!E.has(l.key)&&f(l),v.value=new Set(v.value).add(l.key),s("node-expand",l,l.data))}function O(l){if(!l.isLeaf)if(v.value.has(l.key)){const t=new Set(v.value);t.delete(l.key),v.value=t,s("node-collapse",l,l.data)}else I(l)}function G(l,t,i){S(l)||(o.expandOnClickNode&&!l.isLeaf&&O(l),m.value=l.key,s("update:current-node-key",l.key),s("node-click",l,t,i))}function J(l,t,i){s("node-contextmenu",i,t,l)}function L(){return Array.from(c.value)}return e.provide(T,{config:n,nodeKeyField:g,expandedKeys:v,checkedKeys:c,halfCheckedKeys:C,selectedKey:m,loadingKeys:x,showCheckbox:e.computed(()=>o.showCheckbox),checkStrictly:e.computed(()=>o.checkStrictly),expandOnClickNode:e.computed(()=>o.expandOnClickNode),lazy:e.computed(()=>o.lazy),isDisabledNode:S,toggleExpand:O,handleNodeClick:G,handleNodeContextMenu:J,toggleCheck:P,loadNodeData:f}),e.watch(()=>o.data,()=>z(),{deep:!0,immediate:!0}),d({getNode:l=>u.get(l)??null,getCheckedKeys:L,getCheckedNodes:()=>Array.from(u.values()).filter(l=>c.value.has(l.key)),getHalfCheckedKeys:()=>Array.from(C.value),getCurrentKey:()=>m.value,setCurrentKey:l=>{m.value=l??null,s("update:current-node-key",m.value)},setCheckedKeys:l=>{c.value=new Set(l),o.checkStrictly?K():D(),s("update:checked-keys",L())},setChecked:(l,t)=>{const i=u.get(l);i&&c.value.has(l)!==t&&P(i,i.data)},expandAll:()=>{const l=new Set;u.forEach(t=>{t.isLeaf||l.add(t.key)}),v.value=l},collapseAll:()=>{v.value=new Set}}),(l,t)=>(e.openBlock(),e.createElementBlock("div",ae,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(M.value,i=>(e.openBlock(),e.createBlock(te,{key:i.key,node:i},{default:e.withCtx(({node:p,data:r})=>[e.renderSlot(l.$slots,"default",{node:p,data:r},()=>[e.createTextVNode(e.toDisplayString(r[n.value.label]),1)])]),_:3},8,["node"]))),128)),M.value.length?e.createCommentVNode("v-if",!0):(e.openBlock(),e.createElementBlock("div",ne,e.toDisplayString(l.emptyText),1))]))}}),oe={name:"UiTree",install(y){y.component("UiTree",$)}};exports.Tree=$;exports.TreePlugin=oe;exports.default=$;exports.defaultTreePropsConfig=H;exports.treeContextKey=T;exports.treeEmits=U;exports.treeProps=R;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,527 @@
|
|
|
1
|
+
import { defineComponent as G, computed as c, openBlock as y, createElementBlock as m, normalizeStyle as ae, normalizeClass as T, createElementVNode as K, inject as ue, ref as b, watchEffect as ye, watch as q, resolveComponent as he, createCommentVNode as z, withModifiers as P, createBlock as $, unref as Y, renderSlot as R, createTextVNode as le, toDisplayString as U, createVNode as pe, Transition as ve, withCtx as I, withDirectives as fe, Fragment as te, renderList as ne, vShow as xe, reactive as Z, provide as ke } from "vue";
|
|
2
|
+
const ge = {
|
|
3
|
+
// 图标名称,见 ./icons 注册表
|
|
4
|
+
name: { type: String, required: !0 },
|
|
5
|
+
// 尺寸:数字按 px 处理,字符串作为 CSS 长度(如 '1.5em')
|
|
6
|
+
size: { type: [Number, String], default: 16 },
|
|
7
|
+
// 颜色:缺省时继承 currentColor
|
|
8
|
+
color: { type: String, default: "" },
|
|
9
|
+
// 是否旋转(用于 loading 等图标)
|
|
10
|
+
spin: Boolean
|
|
11
|
+
}, ie = {
|
|
12
|
+
search: '<circle cx="11" cy="11" r="8" /><line x1="21" y1="21" x2="16.65" y2="16.65" />',
|
|
13
|
+
plus: '<line x1="12" y1="5" x2="12" y2="19" /><line x1="5" y1="12" x2="19" y2="12" />',
|
|
14
|
+
minus: '<line x1="5" y1="12" x2="19" y2="12" />',
|
|
15
|
+
close: '<line x1="18" y1="6" x2="6" y2="18" /><line x1="6" y1="6" x2="18" y2="18" />',
|
|
16
|
+
check: '<polyline points="20 6 9 17 4 12" />',
|
|
17
|
+
loading: '<path d="M21 12a9 9 0 1 1-6.219-8.56" />',
|
|
18
|
+
refresh: '<polyline points="23 4 23 10 17 10" /><polyline points="1 20 1 14 7 14" /><path d="M3.51 9a9 9 0 0 1 14.85-3.36L23 10M1 14l4.64 4.36A9 9 0 0 0 20.49 15" />',
|
|
19
|
+
edit: '<path d="M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" /><path d="M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z" />',
|
|
20
|
+
delete: '<polyline points="3 6 5 6 21 6" /><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6m3 0V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" /><line x1="10" y1="11" x2="10" y2="17" /><line x1="14" y1="11" x2="14" y2="17" />',
|
|
21
|
+
download: '<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" /><polyline points="7 10 12 15 17 10" /><line x1="12" y1="15" x2="12" y2="3" />',
|
|
22
|
+
upload: '<path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" /><polyline points="17 8 12 3 7 8" /><line x1="12" y1="3" x2="12" y2="15" />',
|
|
23
|
+
setting: '<circle cx="12" cy="12" r="3" /><path d="M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 0 1 0 2.83 2 2 0 0 1-2.83 0l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-2 2 2 2 0 0 1-2-2v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 0 1-2.83 0 2 2 0 0 1 0-2.83l.06-.06a1.65 1.65 0 0 0 .33-1.82 1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1-2-2 2 2 0 0 1 2-2h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 0 1 0-2.83 2 2 0 0 1 2.83 0l.06.06a1.65 1.65 0 0 0 1.82.33H9a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 2-2 2 2 0 0 1 2 2v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 0 1 2.83 0 2 2 0 0 1 0 2.83l-.06.06a1.65 1.65 0 0 0-.33 1.82V9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 2 2 2 2 0 0 1-2 2h-.09a1.65 1.65 0 0 0-1.51 1z" />',
|
|
24
|
+
user: '<path d="M20 21v-2a4 4 0 0 0-4-4H8a4 4 0 0 0-4 4v2" /><circle cx="12" cy="7" r="4" />',
|
|
25
|
+
home: '<path d="M3 9l9-7 9 7v11a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z" /><polyline points="9 22 9 12 15 12 15 22" />',
|
|
26
|
+
calendar: '<rect x="3" y="4" width="18" height="18" rx="2" ry="2" /><line x1="16" y1="2" x2="16" y2="6" /><line x1="8" y1="2" x2="8" y2="6" /><line x1="3" y1="10" x2="21" y2="10" />',
|
|
27
|
+
clock: '<circle cx="12" cy="12" r="10" /><polyline points="12 6 12 12 16 14" />',
|
|
28
|
+
star: '<polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2" />',
|
|
29
|
+
heart: '<path d="M20.84 4.61a5.5 5.5 0 0 0-7.78 0L12 5.67l-1.06-1.06a5.5 5.5 0 0 0-7.78 7.78l1.06 1.06L12 21.23l7.78-7.78 1.06-1.06a5.5 5.5 0 0 0 0-7.78z" />',
|
|
30
|
+
message: '<path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5z" />',
|
|
31
|
+
bell: '<path d="M18 8A6 6 0 0 0 6 8c0 7-3 9-3 9h18s-3-2-3-9" /><path d="M13.73 21a2 2 0 0 1-3.46 0" />',
|
|
32
|
+
mail: '<path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z" /><polyline points="22,6 12,13 2,6" />',
|
|
33
|
+
eye: '<path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z" /><circle cx="12" cy="12" r="3" />',
|
|
34
|
+
lock: '<rect x="3" y="11" width="18" height="11" rx="2" ry="2" /><path d="M7 11V7a5 5 0 0 1 10 0v4" />',
|
|
35
|
+
link: '<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" /><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" />',
|
|
36
|
+
"arrow-up": '<line x1="12" y1="19" x2="12" y2="5" /><polyline points="5 12 12 5 19 12" />',
|
|
37
|
+
"arrow-down": '<line x1="12" y1="5" x2="12" y2="19" /><polyline points="19 12 12 19 5 12" />',
|
|
38
|
+
"arrow-left": '<line x1="19" y1="12" x2="5" y2="12" /><polyline points="12 19 5 12 12 5" />',
|
|
39
|
+
"arrow-right": '<line x1="5" y1="12" x2="19" y2="12" /><polyline points="12 5 19 12 12 19" />',
|
|
40
|
+
"chevron-up": '<polyline points="18 15 12 9 6 15" />',
|
|
41
|
+
"chevron-down": '<polyline points="6 9 12 15 18 9" />',
|
|
42
|
+
"chevron-left": '<polyline points="15 18 9 12 15 6" />',
|
|
43
|
+
"chevron-right": '<polyline points="9 18 15 12 9 6" />',
|
|
44
|
+
more: '<circle cx="12" cy="12" r="1" /><circle cx="19" cy="12" r="1" /><circle cx="5" cy="12" r="1" />',
|
|
45
|
+
menu: '<line x1="3" y1="12" x2="21" y2="12" /><line x1="3" y1="6" x2="21" y2="6" /><line x1="3" y1="18" x2="21" y2="18" />',
|
|
46
|
+
filter: '<polygon points="22 3 2 3 10 12.46 10 19 14 21 14 12.46 22 3" />',
|
|
47
|
+
copy: '<rect x="9" y="9" width="13" height="13" rx="2" ry="2" /><path d="M5 15H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h9a2 2 0 0 1 2 2v1" />',
|
|
48
|
+
"external-link": '<path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" /><polyline points="15 3 21 3 21 9" /><line x1="10" y1="14" x2="21" y2="3" />',
|
|
49
|
+
zap: '<polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2" />',
|
|
50
|
+
"log-out": '<path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4" /><polyline points="16 17 21 12 16 7" /><line x1="21" y1="12" x2="9" y2="12" />',
|
|
51
|
+
grid: '<rect x="3" y="3" width="7" height="7" /><rect x="14" y="3" width="7" height="7" /><rect x="14" y="14" width="7" height="7" /><rect x="3" y="14" width="7" height="7" />',
|
|
52
|
+
info: '<circle cx="12" cy="12" r="10" /><line x1="12" y1="16" x2="12" y2="12" /><line x1="12" y1="8" x2="12.01" y2="8" />',
|
|
53
|
+
success: '<path d="M22 11.08V12a10 10 0 1 1-5.93-9.14" /><polyline points="22 4 12 14.01 9 11.01" />',
|
|
54
|
+
warning: '<path d="M10.29 3.86L1.82 18a2 2 0 0 0 1.71 3h16.94a2 2 0 0 0 1.71-3L13.71 3.86a2 2 0 0 0-3.42 0z" /><line x1="12" y1="9" x2="12" y2="13" /><line x1="12" y1="17" x2="12.01" y2="17" />',
|
|
55
|
+
error: '<circle cx="12" cy="12" r="10" /><line x1="15" y1="9" x2="9" y2="15" /><line x1="9" y1="9" x2="15" y2="15" />',
|
|
56
|
+
question: '<circle cx="12" cy="12" r="10" /><path d="M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3" /><line x1="12" y1="17" x2="12.01" y2="17" />',
|
|
57
|
+
"plus-circle": '<circle cx="12" cy="12" r="10" /><line x1="12" y1="8" x2="12" y2="16" /><line x1="8" y1="12" x2="16" y2="12" />'
|
|
58
|
+
};
|
|
59
|
+
function me(h) {
|
|
60
|
+
return h in ie;
|
|
61
|
+
}
|
|
62
|
+
const we = {
|
|
63
|
+
viewBox: "0 0 24 24",
|
|
64
|
+
fill: "none",
|
|
65
|
+
stroke: "currentColor",
|
|
66
|
+
"stroke-width": "2",
|
|
67
|
+
"stroke-linecap": "round",
|
|
68
|
+
"stroke-linejoin": "round"
|
|
69
|
+
}, Ce = ["innerHTML"], ee = /* @__PURE__ */ G({
|
|
70
|
+
__name: "icon",
|
|
71
|
+
props: ge,
|
|
72
|
+
setup(h) {
|
|
73
|
+
const d = h, l = c(() => me(d.name) ? ie[d.name] : ""), n = c(() => ({
|
|
74
|
+
fontSize: typeof d.size == "number" ? `${d.size}px` : d.size,
|
|
75
|
+
...d.color ? { color: d.color } : {}
|
|
76
|
+
}));
|
|
77
|
+
return (s, t) => (y(), m(
|
|
78
|
+
"span",
|
|
79
|
+
{
|
|
80
|
+
class: T(["ui-icon", { "is-spin": s.spin }]),
|
|
81
|
+
style: ae(n.value),
|
|
82
|
+
role: "img"
|
|
83
|
+
},
|
|
84
|
+
[
|
|
85
|
+
(y(), m("svg", we, [
|
|
86
|
+
K("g", { innerHTML: l.value }, null, 8, Ce)
|
|
87
|
+
]))
|
|
88
|
+
],
|
|
89
|
+
6
|
|
90
|
+
/* CLASS, STYLE */
|
|
91
|
+
));
|
|
92
|
+
}
|
|
93
|
+
}), oe = {
|
|
94
|
+
label: "label",
|
|
95
|
+
children: "children",
|
|
96
|
+
disabled: "disabled",
|
|
97
|
+
isLeaf: "isLeaf",
|
|
98
|
+
key: "key"
|
|
99
|
+
}, _e = {
|
|
100
|
+
/** 树数据 */
|
|
101
|
+
data: { type: Array, default: () => [] },
|
|
102
|
+
/** 字段映射:{ label, children, disabled, isLeaf, key },缺省用默认字段名 */
|
|
103
|
+
props: { type: Object, default: () => ({}) },
|
|
104
|
+
/** 节点唯一键字段,缺省取 props.key */
|
|
105
|
+
nodeKey: { type: String, default: "" },
|
|
106
|
+
/** 是否展示复选框 */
|
|
107
|
+
showCheckbox: Boolean,
|
|
108
|
+
/** 勾选是否严格(父子不联动,仅影响复选框) */
|
|
109
|
+
checkStrictly: Boolean,
|
|
110
|
+
/** 默认展开所有节点 */
|
|
111
|
+
defaultExpandAll: Boolean,
|
|
112
|
+
/** 默认展开的节点 key 列表 */
|
|
113
|
+
defaultExpandedKeys: {
|
|
114
|
+
type: Array,
|
|
115
|
+
default: () => []
|
|
116
|
+
},
|
|
117
|
+
/** 初始勾选的节点 key 列表(可在外部用 ref.setCheckedKeys 再控制) */
|
|
118
|
+
defaultCheckedKeys: {
|
|
119
|
+
type: Array,
|
|
120
|
+
default: () => []
|
|
121
|
+
},
|
|
122
|
+
/** 点击节点是否展开/收起(默认 true) */
|
|
123
|
+
expandOnClickNode: { type: Boolean, default: !0 },
|
|
124
|
+
/** 当前选中节点 key(v-model:current-node-key) */
|
|
125
|
+
currentNodeKey: {
|
|
126
|
+
type: [String, Number],
|
|
127
|
+
default: null
|
|
128
|
+
},
|
|
129
|
+
/** 懒加载(需配合 load 使用) */
|
|
130
|
+
lazy: Boolean,
|
|
131
|
+
/** 懒加载函数:(node, resolve) => void */
|
|
132
|
+
load: { type: Function, default: void 0 },
|
|
133
|
+
/** 空数据提示文案 */
|
|
134
|
+
emptyText: { type: String, default: "暂无数据" }
|
|
135
|
+
}, Me = {
|
|
136
|
+
"update:current-node-key": null,
|
|
137
|
+
"update:checked-keys": null,
|
|
138
|
+
/** 点击节点:node / data / 原生事件 */
|
|
139
|
+
"node-click": (h, d, l) => l instanceof MouseEvent,
|
|
140
|
+
/** 节点展开 */
|
|
141
|
+
"node-expand": () => !0,
|
|
142
|
+
/** 节点收起 */
|
|
143
|
+
"node-collapse": () => !0,
|
|
144
|
+
/** 复选框勾选状态改变 */
|
|
145
|
+
check: (h, d) => !0,
|
|
146
|
+
/** 节点勾选状态变化(含级联影响的节点) */
|
|
147
|
+
"check-change": (h, d, l) => !0,
|
|
148
|
+
/** 右键节点 */
|
|
149
|
+
"node-contextmenu": (h, d, l) => !0
|
|
150
|
+
}, ce = Symbol("ui-tree"), Se = {
|
|
151
|
+
key: 2,
|
|
152
|
+
class: "ui-tree-node__expand-placeholder"
|
|
153
|
+
}, be = ["checked", "disabled"], Ne = {
|
|
154
|
+
key: 0,
|
|
155
|
+
class: "ui-tree-node__children"
|
|
156
|
+
}, Ke = /* @__PURE__ */ G({
|
|
157
|
+
__name: "tree-node",
|
|
158
|
+
props: {
|
|
159
|
+
node: {}
|
|
160
|
+
},
|
|
161
|
+
setup(h) {
|
|
162
|
+
const d = h, l = ue(ce), n = b(null), s = c(
|
|
163
|
+
() => (l == null ? void 0 : l.config.value) ?? oe
|
|
164
|
+
), t = c(() => d.node), C = c(() => !!l && l.expandedKeys.value.has(t.value.key)), u = c(() => !!l && l.checkedKeys.value.has(t.value.key)), L = c(() => !!l && l.halfCheckedKeys.value.has(t.value.key)), f = c(() => !!l && l.selectedKey.value === t.value.key), i = c(() => !!t.value.data[s.value.disabled]), _ = c(() => !!l && l.loadingKeys.value.has(t.value.key)), w = c(() => !!l && l.showCheckbox.value), g = c(() => t.value.children);
|
|
165
|
+
ye(() => {
|
|
166
|
+
n.value && (n.value.indeterminate = L.value);
|
|
167
|
+
}), q(
|
|
168
|
+
[C, () => g.value.length],
|
|
169
|
+
([x, S]) => {
|
|
170
|
+
!l || !x || S > 0 || l.lazy.value && !t.value.isLeaf && !_.value && l.loadNodeData(t.value);
|
|
171
|
+
},
|
|
172
|
+
{ immediate: !0 }
|
|
173
|
+
);
|
|
174
|
+
function A() {
|
|
175
|
+
l == null || l.toggleExpand(t.value);
|
|
176
|
+
}
|
|
177
|
+
function E() {
|
|
178
|
+
l == null || l.toggleCheck(t.value, t.value.data);
|
|
179
|
+
}
|
|
180
|
+
function H(x) {
|
|
181
|
+
l == null || l.handleNodeClick(t.value, t.value.data, x);
|
|
182
|
+
}
|
|
183
|
+
function B(x) {
|
|
184
|
+
l == null || l.handleNodeContextMenu(t.value, t.value.data, x);
|
|
185
|
+
}
|
|
186
|
+
return (x, S) => {
|
|
187
|
+
const N = he("TreeNode", !0);
|
|
188
|
+
return y(), m(
|
|
189
|
+
"div",
|
|
190
|
+
{
|
|
191
|
+
class: T(["ui-tree-node", { "is-current": f.value, "is-expanded": C.value }])
|
|
192
|
+
},
|
|
193
|
+
[
|
|
194
|
+
z(" 节点行 "),
|
|
195
|
+
K(
|
|
196
|
+
"div",
|
|
197
|
+
{
|
|
198
|
+
class: "ui-tree-node__content",
|
|
199
|
+
style: ae({ paddingLeft: `${(t.value.level - 1) * 18 + 4}px` }),
|
|
200
|
+
onClick: H,
|
|
201
|
+
onContextmenu: P(B, ["prevent"])
|
|
202
|
+
},
|
|
203
|
+
[
|
|
204
|
+
K(
|
|
205
|
+
"span",
|
|
206
|
+
{
|
|
207
|
+
class: T(["ui-tree-node__expand-icon", { "is-loading": _.value }]),
|
|
208
|
+
onClick: P(A, ["stop"])
|
|
209
|
+
},
|
|
210
|
+
[
|
|
211
|
+
_.value ? (y(), $(Y(ee), {
|
|
212
|
+
key: 0,
|
|
213
|
+
name: "loading",
|
|
214
|
+
size: 14,
|
|
215
|
+
spin: ""
|
|
216
|
+
})) : t.value.isLeaf ? (y(), m("span", Se)) : (y(), $(Y(ee), {
|
|
217
|
+
key: 1,
|
|
218
|
+
name: C.value ? "chevron-down" : "chevron-right",
|
|
219
|
+
size: 14
|
|
220
|
+
}, null, 8, ["name"]))
|
|
221
|
+
],
|
|
222
|
+
2
|
|
223
|
+
/* CLASS */
|
|
224
|
+
),
|
|
225
|
+
w.value ? (y(), m("label", {
|
|
226
|
+
key: 0,
|
|
227
|
+
class: "ui-tree-node__checkbox",
|
|
228
|
+
onClick: S[0] || (S[0] = P(() => {
|
|
229
|
+
}, ["stop"]))
|
|
230
|
+
}, [
|
|
231
|
+
K("input", {
|
|
232
|
+
ref_key: "checkboxEl",
|
|
233
|
+
ref: n,
|
|
234
|
+
type: "checkbox",
|
|
235
|
+
checked: u.value,
|
|
236
|
+
disabled: i.value,
|
|
237
|
+
onChange: E
|
|
238
|
+
}, null, 40, be)
|
|
239
|
+
])) : z("v-if", !0),
|
|
240
|
+
K(
|
|
241
|
+
"span",
|
|
242
|
+
{
|
|
243
|
+
class: T(["ui-tree-node__label", { "is-disabled": i.value }])
|
|
244
|
+
},
|
|
245
|
+
[
|
|
246
|
+
R(x.$slots, "default", {
|
|
247
|
+
node: t.value,
|
|
248
|
+
data: t.value.data
|
|
249
|
+
}, () => [
|
|
250
|
+
le(
|
|
251
|
+
U(t.value.data[s.value.label]),
|
|
252
|
+
1
|
|
253
|
+
/* TEXT */
|
|
254
|
+
)
|
|
255
|
+
])
|
|
256
|
+
],
|
|
257
|
+
2
|
|
258
|
+
/* CLASS */
|
|
259
|
+
)
|
|
260
|
+
],
|
|
261
|
+
36
|
|
262
|
+
/* STYLE, NEED_HYDRATION */
|
|
263
|
+
),
|
|
264
|
+
z(" 子节点(v-if 移除空容器,v-show 负责展开动画) "),
|
|
265
|
+
pe(ve, { name: "ui-tree-node__fade" }, {
|
|
266
|
+
default: I(() => [
|
|
267
|
+
g.value.length ? fe((y(), m(
|
|
268
|
+
"div",
|
|
269
|
+
Ne,
|
|
270
|
+
[
|
|
271
|
+
(y(!0), m(
|
|
272
|
+
te,
|
|
273
|
+
null,
|
|
274
|
+
ne(g.value, (M) => (y(), $(N, {
|
|
275
|
+
key: M.key,
|
|
276
|
+
node: M
|
|
277
|
+
}, {
|
|
278
|
+
default: I(() => [
|
|
279
|
+
R(x.$slots, "default", {
|
|
280
|
+
node: M,
|
|
281
|
+
data: M.data
|
|
282
|
+
})
|
|
283
|
+
]),
|
|
284
|
+
_: 2
|
|
285
|
+
/* DYNAMIC */
|
|
286
|
+
}, 1032, ["node"]))),
|
|
287
|
+
128
|
|
288
|
+
/* KEYED_FRAGMENT */
|
|
289
|
+
))
|
|
290
|
+
],
|
|
291
|
+
512
|
|
292
|
+
/* NEED_PATCH */
|
|
293
|
+
)), [
|
|
294
|
+
[xe, C.value]
|
|
295
|
+
]) : z("v-if", !0)
|
|
296
|
+
]),
|
|
297
|
+
_: 3
|
|
298
|
+
/* FORWARDED */
|
|
299
|
+
})
|
|
300
|
+
],
|
|
301
|
+
2
|
|
302
|
+
/* CLASS */
|
|
303
|
+
);
|
|
304
|
+
};
|
|
305
|
+
}
|
|
306
|
+
}), ze = { class: "ui-tree" }, Le = {
|
|
307
|
+
key: 0,
|
|
308
|
+
class: "ui-tree__empty"
|
|
309
|
+
}, Ae = /* @__PURE__ */ G({
|
|
310
|
+
__name: "tree",
|
|
311
|
+
props: _e,
|
|
312
|
+
emits: Me,
|
|
313
|
+
setup(h, { expose: d, emit: l }) {
|
|
314
|
+
const n = h, s = l, t = c(() => ({
|
|
315
|
+
...oe,
|
|
316
|
+
...n.props
|
|
317
|
+
})), C = c(() => n.nodeKey || t.value.key || "key"), u = Z(/* @__PURE__ */ new Map()), L = c(
|
|
318
|
+
() => Array.from(u.values()).filter((e) => e.level === 1)
|
|
319
|
+
), f = b(/* @__PURE__ */ new Set()), i = b(/* @__PURE__ */ new Set()), _ = b(/* @__PURE__ */ new Set()), w = b(null), g = b(/* @__PURE__ */ new Set()), A = Z(/* @__PURE__ */ new Set());
|
|
320
|
+
function E(e, a, o, p) {
|
|
321
|
+
e.forEach((r, v) => {
|
|
322
|
+
const k = a ? `${a.path}-${v}` : `${v}`, V = r[C.value], X = V == null || V === "" ? `__gen-${k}` : V, j = {
|
|
323
|
+
key: X,
|
|
324
|
+
data: r,
|
|
325
|
+
parent: a,
|
|
326
|
+
children: [],
|
|
327
|
+
level: o,
|
|
328
|
+
isLeaf: n.lazy ? !!r[t.value.isLeaf] : !Array.isArray(r[t.value.children]) || r[t.value.children].length === 0,
|
|
329
|
+
isLazy: n.lazy,
|
|
330
|
+
path: k
|
|
331
|
+
};
|
|
332
|
+
u.set(X, j), a && a.children.push(j);
|
|
333
|
+
const F = r[t.value.children];
|
|
334
|
+
Array.isArray(F) && F.length && E(F, j, o + 1);
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
let H = !1;
|
|
338
|
+
function B() {
|
|
339
|
+
u.clear(), E(n.data, null, 1), H || (S(), H = !0), J();
|
|
340
|
+
}
|
|
341
|
+
function x(e) {
|
|
342
|
+
!n.load || g.value.has(e.key) || (g.value = new Set(g.value).add(e.key), n.load(
|
|
343
|
+
{ key: e.key, level: e.level, data: e.data },
|
|
344
|
+
(a) => {
|
|
345
|
+
const o = new Set(g.value);
|
|
346
|
+
o.delete(e.key), g.value = o, A.add(e.key);
|
|
347
|
+
const p = t.value.children, r = Array.isArray(e.data[p]) ? e.data[p] : [];
|
|
348
|
+
e.data[p] = r.concat(a), a.length === 0 && (e.data[t.value.isLeaf] = !0);
|
|
349
|
+
}
|
|
350
|
+
));
|
|
351
|
+
}
|
|
352
|
+
function S() {
|
|
353
|
+
const e = /* @__PURE__ */ new Set();
|
|
354
|
+
n.defaultExpandAll && u.forEach((a) => {
|
|
355
|
+
a.isLeaf || e.add(a.key);
|
|
356
|
+
}), n.defaultExpandedKeys.forEach((a) => e.add(a)), f.value = e, i.value = new Set(n.defaultCheckedKeys), w.value = n.currentNodeKey ?? null;
|
|
357
|
+
}
|
|
358
|
+
q(
|
|
359
|
+
() => n.currentNodeKey,
|
|
360
|
+
(e) => {
|
|
361
|
+
w.value = e ?? null;
|
|
362
|
+
}
|
|
363
|
+
);
|
|
364
|
+
function N(e) {
|
|
365
|
+
return !!e.data[t.value.disabled];
|
|
366
|
+
}
|
|
367
|
+
function M(e) {
|
|
368
|
+
let a = e.parent;
|
|
369
|
+
for (; a; ) {
|
|
370
|
+
if (!a.children.length) {
|
|
371
|
+
a = a.parent;
|
|
372
|
+
continue;
|
|
373
|
+
}
|
|
374
|
+
a.children.every((p) => i.value.has(p.key)) ? i.value.add(a.key) : i.value.delete(a.key), a = a.parent;
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
function D() {
|
|
378
|
+
const e = /* @__PURE__ */ new Set();
|
|
379
|
+
u.forEach((a) => {
|
|
380
|
+
if (!a.children.length) return;
|
|
381
|
+
const o = a.children.some((r) => i.value.has(r.key)), p = a.children.every((r) => i.value.has(r.key));
|
|
382
|
+
o && !p && e.add(a.key);
|
|
383
|
+
}), _.value = e;
|
|
384
|
+
}
|
|
385
|
+
function J() {
|
|
386
|
+
for (const e of i.value)
|
|
387
|
+
u.has(e) || i.value.delete(e);
|
|
388
|
+
n.checkStrictly || (u.forEach((e) => {
|
|
389
|
+
e.children.length && i.value.delete(e.key);
|
|
390
|
+
}), Array.from(i.value).forEach((e) => {
|
|
391
|
+
const a = u.get(e);
|
|
392
|
+
a && M(a);
|
|
393
|
+
})), D();
|
|
394
|
+
}
|
|
395
|
+
function Q(e, a) {
|
|
396
|
+
if (N(e)) return;
|
|
397
|
+
const o = !i.value.has(e.key), p = [], r = (v, k) => {
|
|
398
|
+
i.value.has(v.key) !== k && p.push({ node: v, checked: k }), k ? i.value.add(v.key) : i.value.delete(v.key);
|
|
399
|
+
};
|
|
400
|
+
if (n.checkStrictly)
|
|
401
|
+
r(e, o);
|
|
402
|
+
else {
|
|
403
|
+
const v = (k) => {
|
|
404
|
+
r(k, o), k.children.forEach(v);
|
|
405
|
+
};
|
|
406
|
+
v(e), M(e), D();
|
|
407
|
+
}
|
|
408
|
+
p.forEach(({ node: v, checked: k }) => s("check-change", v, v.data, k)), s("check", e, a), s("update:checked-keys", O());
|
|
409
|
+
}
|
|
410
|
+
function re(e) {
|
|
411
|
+
f.value.has(e.key) || (n.lazy && !e.isLeaf && e.children.length === 0 && !A.has(e.key) && x(e), f.value = new Set(f.value).add(e.key), s("node-expand", e, e.data));
|
|
412
|
+
}
|
|
413
|
+
function W(e) {
|
|
414
|
+
if (!e.isLeaf)
|
|
415
|
+
if (f.value.has(e.key)) {
|
|
416
|
+
const a = new Set(f.value);
|
|
417
|
+
a.delete(e.key), f.value = a, s("node-collapse", e, e.data);
|
|
418
|
+
} else
|
|
419
|
+
re(e);
|
|
420
|
+
}
|
|
421
|
+
function de(e, a, o) {
|
|
422
|
+
N(e) || (n.expandOnClickNode && !e.isLeaf && W(e), w.value = e.key, s("update:current-node-key", e.key), s("node-click", e, a, o));
|
|
423
|
+
}
|
|
424
|
+
function se(e, a, o) {
|
|
425
|
+
s("node-contextmenu", o, a, e);
|
|
426
|
+
}
|
|
427
|
+
function O() {
|
|
428
|
+
return Array.from(i.value);
|
|
429
|
+
}
|
|
430
|
+
return ke(ce, {
|
|
431
|
+
config: t,
|
|
432
|
+
nodeKeyField: C,
|
|
433
|
+
expandedKeys: f,
|
|
434
|
+
checkedKeys: i,
|
|
435
|
+
halfCheckedKeys: _,
|
|
436
|
+
selectedKey: w,
|
|
437
|
+
loadingKeys: g,
|
|
438
|
+
showCheckbox: c(() => n.showCheckbox),
|
|
439
|
+
checkStrictly: c(() => n.checkStrictly),
|
|
440
|
+
expandOnClickNode: c(() => n.expandOnClickNode),
|
|
441
|
+
lazy: c(() => n.lazy),
|
|
442
|
+
isDisabledNode: N,
|
|
443
|
+
toggleExpand: W,
|
|
444
|
+
handleNodeClick: de,
|
|
445
|
+
handleNodeContextMenu: se,
|
|
446
|
+
toggleCheck: Q,
|
|
447
|
+
loadNodeData: x
|
|
448
|
+
}), q(
|
|
449
|
+
() => n.data,
|
|
450
|
+
() => B(),
|
|
451
|
+
{ deep: !0, immediate: !0 }
|
|
452
|
+
), d({
|
|
453
|
+
/** 按 key 取节点模型 */
|
|
454
|
+
getNode: (e) => u.get(e) ?? null,
|
|
455
|
+
getCheckedKeys: O,
|
|
456
|
+
getCheckedNodes: () => Array.from(u.values()).filter((e) => i.value.has(e.key)),
|
|
457
|
+
getHalfCheckedKeys: () => Array.from(_.value),
|
|
458
|
+
getCurrentKey: () => w.value,
|
|
459
|
+
setCurrentKey: (e) => {
|
|
460
|
+
w.value = e ?? null, s("update:current-node-key", w.value);
|
|
461
|
+
},
|
|
462
|
+
setCheckedKeys: (e) => {
|
|
463
|
+
i.value = new Set(e), n.checkStrictly ? D() : J(), s("update:checked-keys", O());
|
|
464
|
+
},
|
|
465
|
+
setChecked: (e, a) => {
|
|
466
|
+
const o = u.get(e);
|
|
467
|
+
o && i.value.has(e) !== a && Q(o, o.data);
|
|
468
|
+
},
|
|
469
|
+
expandAll: () => {
|
|
470
|
+
const e = /* @__PURE__ */ new Set();
|
|
471
|
+
u.forEach((a) => {
|
|
472
|
+
a.isLeaf || e.add(a.key);
|
|
473
|
+
}), f.value = e;
|
|
474
|
+
},
|
|
475
|
+
collapseAll: () => {
|
|
476
|
+
f.value = /* @__PURE__ */ new Set();
|
|
477
|
+
}
|
|
478
|
+
}), (e, a) => (y(), m("div", ze, [
|
|
479
|
+
(y(!0), m(
|
|
480
|
+
te,
|
|
481
|
+
null,
|
|
482
|
+
ne(L.value, (o) => (y(), $(Ke, {
|
|
483
|
+
key: o.key,
|
|
484
|
+
node: o
|
|
485
|
+
}, {
|
|
486
|
+
default: I(({ node: p, data: r }) => [
|
|
487
|
+
R(e.$slots, "default", {
|
|
488
|
+
node: p,
|
|
489
|
+
data: r
|
|
490
|
+
}, () => [
|
|
491
|
+
le(
|
|
492
|
+
U(r[t.value.label]),
|
|
493
|
+
1
|
|
494
|
+
/* TEXT */
|
|
495
|
+
)
|
|
496
|
+
])
|
|
497
|
+
]),
|
|
498
|
+
_: 3
|
|
499
|
+
/* FORWARDED */
|
|
500
|
+
}, 8, ["node"]))),
|
|
501
|
+
128
|
|
502
|
+
/* KEYED_FRAGMENT */
|
|
503
|
+
)),
|
|
504
|
+
L.value.length ? z("v-if", !0) : (y(), m(
|
|
505
|
+
"div",
|
|
506
|
+
Le,
|
|
507
|
+
U(e.emptyText),
|
|
508
|
+
1
|
|
509
|
+
/* TEXT */
|
|
510
|
+
))
|
|
511
|
+
]));
|
|
512
|
+
}
|
|
513
|
+
}), He = {
|
|
514
|
+
name: "UiTree",
|
|
515
|
+
install(h) {
|
|
516
|
+
h.component("UiTree", Ae);
|
|
517
|
+
}
|
|
518
|
+
};
|
|
519
|
+
export {
|
|
520
|
+
Ae as Tree,
|
|
521
|
+
He as TreePlugin,
|
|
522
|
+
Ae as default,
|
|
523
|
+
oe as defaultTreePropsConfig,
|
|
524
|
+
ce as treeContextKey,
|
|
525
|
+
Me as treeEmits,
|
|
526
|
+
_e as treeProps
|
|
527
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { ExtractPropTypes } from 'vue';
|
|
2
|
+
|
|
3
|
+
export declare const badgeProps: {
|
|
4
|
+
readonly value: {
|
|
5
|
+
readonly type: [NumberConstructor, StringConstructor];
|
|
6
|
+
readonly default: 0;
|
|
7
|
+
};
|
|
8
|
+
readonly max: {
|
|
9
|
+
readonly type: NumberConstructor;
|
|
10
|
+
readonly default: undefined;
|
|
11
|
+
};
|
|
12
|
+
readonly isDot: {
|
|
13
|
+
readonly type: BooleanConstructor;
|
|
14
|
+
readonly default: false;
|
|
15
|
+
};
|
|
16
|
+
readonly hidden: {
|
|
17
|
+
readonly type: BooleanConstructor;
|
|
18
|
+
readonly default: false;
|
|
19
|
+
};
|
|
20
|
+
readonly type: {
|
|
21
|
+
readonly type: StringConstructor;
|
|
22
|
+
readonly default: "danger";
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
export type BadgeProps = ExtractPropTypes<typeof badgeProps>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { App } from 'vue';
|
|
2
|
+
import { default as Breadcrumb } from './src/breadcrumb.vue';
|
|
3
|
+
import { default as BreadcrumbItem } from './src/breadcrumb-item.vue';
|
|
4
|
+
|
|
5
|
+
export declare const BreadcrumbPlugin: {
|
|
6
|
+
name: string;
|
|
7
|
+
install(app: App): void;
|
|
8
|
+
};
|
|
9
|
+
export { Breadcrumb, BreadcrumbItem };
|
|
10
|
+
export default Breadcrumb;
|
|
11
|
+
export * from './src/breadcrumb';
|
|
12
|
+
export * from './src/breadcrumb-item';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ExtractPropTypes } from 'vue';
|
|
2
|
+
|
|
3
|
+
export declare const breadcrumbItemProps: {
|
|
4
|
+
readonly to: {
|
|
5
|
+
readonly type: StringConstructor;
|
|
6
|
+
readonly default: "";
|
|
7
|
+
};
|
|
8
|
+
readonly replace: {
|
|
9
|
+
readonly type: BooleanConstructor;
|
|
10
|
+
readonly default: false;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export type BreadcrumbItemProps = ExtractPropTypes<typeof breadcrumbItemProps>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ExtractPropTypes, InjectionKey } from 'vue';
|
|
2
|
+
|
|
3
|
+
export declare const breadcrumbProps: {
|
|
4
|
+
readonly separator: {
|
|
5
|
+
readonly type: StringConstructor;
|
|
6
|
+
readonly default: "/";
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
export type BreadcrumbProps = ExtractPropTypes<typeof breadcrumbProps>;
|
|
10
|
+
export declare const breadcrumbSeparatorKey: InjectionKey<string>;
|