@mtn-ui/components 1.0.9 → 1.0.11
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 -1
- package/dist/index.js +30 -26
- package/dist/index.mjs +52 -48
- package/dist/types/packages/components/src/antd-wrapped/action-group/action-group.vue.d.ts +122 -0
- package/dist/types/packages/components/src/antd-wrapped/action-group/types.d.ts +1 -1
- package/dist/types/packages/components/src/antd-wrapped/delete-button/delete-button.vue.d.ts +263 -0
- package/package.json +51 -51
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const T=require("@mtn-ui/shared"),e=require("vue"),Pe=require("class-variance-authority"),k=require("ant-design-vue"),J=require("@vueuse/core"),F=require("@ant-design/icons-vue"),Q={type:{type:String,default:"default"},color:{type:String}},Te=Pe.cva("inline-flex items-center px-2 py-0.5 rounded text-xs font-medium border transition-colors",{variants:{type:{default:"bg-gray-100 text-gray-800 border-gray-200",success:"bg-green-100 text-green-800 border-green-200",processing:"bg-blue-100 text-blue-800 border-blue-200",error:"bg-red-100 text-red-800 border-red-200",warning:"bg-orange-100 text-orange-800 border-orange-200"}},defaultVariants:{type:"default"}}),we=e.defineComponent({name:"MTag",props:Q,setup(t,{slots:a,attrs:o}){return()=>{var c;const{type:r}=t;return e.createVNode("span",{class:T.cn(Te({type:r}),o.class)},[(c=a.default)==null?void 0:c.call(a)])}}}),ee=T.withInstall(we),te={type:{type:String,default:"default"},size:{type:String,default:"middle"},loading:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},danger:{type:Boolean,default:!1},block:{type:Boolean,default:!1},ghost:{type:Boolean,default:!1},shape:{type:String,default:"default"},htmlType:{type:String,default:"button"},icon:{type:Object},permission:{type:[String,Array],default:void 0},permissionAction:{type:String,default:"hide"}};function ne(t){const{permission:a,permissionAction:o="hide"}=t,r=e.inject(T.PERMISSION_CHECKER_KEY,e.ref(T.defaultPermissionChecker)),c=e.computed(()=>a?r.value(a):!0),f=e.computed(()=>!c.value&&o==="hide"),d=e.computed(()=>!c.value&&o==="disable");return{hasPermission:c,shouldHide:f,shouldDisable:d}}function De(t,a){return t.map(o=>{if(!o||o.type==="divider"||!o.permission)return o;if(!a(o.permission)){const c=o.permissionAction||"hide";if(c==="hide")return null;if(c==="disable")return{...o,disabled:!0}}return o}).filter(Boolean)}const V=e.defineComponent({name:"MButton",props:te,emits:["click"],setup(t,{slots:a,attrs:o,emit:r}){const{shouldHide:c,shouldDisable:f}=ne({permission:t.permission,permissionAction:t.permissionAction}),d=p=>{r("click",p)};return()=>c.value?null:e.createVNode(k.Button,e.mergeProps({type:t.type,size:t.size,loading:t.loading,disabled:t.disabled||f.value,danger:t.danger,block:t.block,ghost:t.ghost,shape:t.shape,htmlType:t.htmlType,icon:t.icon},o,{class:["mtn-button",o.class],onClick:d}),{default:()=>{var p;return(p=a.default)==null?void 0:p.call(a)},icon:()=>{var p;return(p=a.icon)==null?void 0:p.call(a)}})}}),oe={size:{type:String,default:"middle"},compact:{type:Boolean,default:!0},gap:{type:[Number,String],default:8},vertical:{type:Boolean,default:!1},block:{type:Boolean,default:!1}},U=e.defineComponent({name:"MButtonGroup",props:oe,setup(t,{slots:a,attrs:o}){return()=>e.createVNode(e.Fragment,null,[t.compact?e.createVNode(k.Space.Compact,e.mergeProps({size:t.size,direction:t.vertical?"vertical":"horizontal",block:t.block},o,{class:["mtn-button-group","mtn-button-group--compact",o.class]}),{default:()=>{var r;return[(r=a.default)==null?void 0:r.call(a)]}}):e.createVNode(k.Space,e.mergeProps({size:typeof t.gap=="number"?t.gap:parseInt(t.gap)||8,direction:t.vertical?"vertical":"horizontal"},o,{class:["mtn-button-group","mtn-button-group--normal",o.class]}),{default:()=>{var r;return[(r=a.default)==null?void 0:r.call(a)]}})])}}),ze={text:{type:String,default:"Dropdown"},type:{type:String,default:"default"},size:{type:String,default:"middle"},menu:{type:Array,default:void 0},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},danger:{type:Boolean,default:!1},placement:{type:String,default:"bottomLeft"},trigger:{type:Array,default:()=>["click"]},permission:{type:[String,Array],default:void 0},permissionAction:{type:String,default:"hide"}},G=e.defineComponent({name:"MDropdownButton",props:ze,emits:["click"],setup(t,{slots:a,attrs:o,emit:r}){const{shouldHide:c,shouldDisable:f}=ne({permission:t.permission,permissionAction:t.permissionAction}),d=e.inject(T.PERMISSION_CHECKER_KEY,e.ref(T.defaultPermissionChecker)),p=y=>{r("click",y)};return()=>{if(c.value)return null;const y={};if(a.overlay)y.overlay=a.overlay;else if(t.menu&&t.menu.length>0){const g=De(t.menu,d.value);y.overlay=()=>e.h(k.Menu,{items:g})}return a.icon&&(y.icon=a.icon),!(a.default||t.text)?e.createVNode(k.Dropdown,e.mergeProps({placement:t.placement,trigger:t.trigger},o,{class:["mtn-dropdown-button",o.class]}),{default:()=>[e.createVNode(k.Button,{type:t.type,size:t.size==="middle"?void 0:t.size,disabled:t.disabled||f.value,loading:t.loading,danger:t.danger,onClick:p},{default:()=>{var g;return[(g=a.icon)==null?void 0:g.call(a)]}})],...y}):e.createVNode(k.Dropdown.Button,e.mergeProps({type:t.type,size:t.size==="middle"?void 0:t.size,disabled:t.disabled||f.value,loading:t.loading,danger:t.danger,placement:t.placement,trigger:t.trigger},o,{class:["mtn-dropdown-button",o.class],onClick:p}),{default:()=>{var g;return[((g=a.default)==null?void 0:g.call(a))||t.text]},...y})}}}),Ae={actions:{type:Array,default:void 0},mode:{type:String,default:"default"},maxItems:{type:Number,default:3},gap:{type:Number,default:8},moreText:{type:String,default:"更多"},moreIcon:{type:Object,default:void 0},moreProps:{type:Object,default:()=>({})},size:{type:String,default:"middle"},compact:{type:Boolean,default:!1},vertical:{type:Boolean,default:!1},block:{type:Boolean,default:!1},disableCollapse:{type:Boolean,default:!1}};function Ee(t){return t?t.filter(a=>a.type!==e.Comment&&a.type!==e.Text&&a.type!==Symbol.for("v-fgt")):[]}function Ne(t,a){var o,r;if(t.key!==null&&t.key!==void 0)return typeof t.key=="symbol"?t.key.toString():t.key;if(((o=t.props)==null?void 0:o.key)!==null&&((r=t.props)==null?void 0:r.key)!==void 0){const c=t.props.key;return typeof c=="symbol"?c.toString():c}return`button-${a}`}const H="link",Z="small",Me=150,Ve=e.defineComponent({name:"MActionGroup",inheritAttrs:!1,__name:"action-group",props:Ae,emits:["action-click"],setup(t,{emit:a}){const o=t,r=a,c=e.useSlots(),f=e.useAttrs(),d=e.ref(),p=e.ref(),y=e.ref(),_=e.inject(T.PERMISSION_CHECKER_KEY,e.ref(T.defaultPermissionChecker)),g=e.computed(()=>o.mode==="table"),w=e.computed(()=>g.value?"small":o.size),l=e.computed(()=>g.value?"link":"default"),u=e.computed(()=>g.value?"":o.moreText),x=e.computed(()=>o.moreIcon||F.MoreOutlined);function S(n){return n?_.value(n):!0}const K=e.computed(()=>{var n;return Ee((n=c.default)==null?void 0:n.call(c))}),D=e.shallowRef([]);function q(n){var b,v,B;const s=n.icon&&(n.icon.name||n.icon.__name)||"",i=n.component&&(n.component.name||n.component.__name)||"";return[n.key??"",n.label??"",s,i,Array.isArray(n.permission)?n.permission.join(","):n.permission??"",n.permissionAction??"",String(n.disabled??!1),String(((b=n.componentProps)==null?void 0:b.confirm)??""),String(((v=n.componentProps)==null?void 0:v.showSuccess)??""),String(((B=n.componentProps)==null?void 0:B.danger)??"")].join("|")}e.watch(()=>o.actions,n=>{if(!n){D.value=[];return}if(D.value.length!==n.length){D.value=n;return}const s=n.map(q).join("||"),i=D.value.map(q).join("||");s!==i&&(D.value=n)},{immediate:!0,deep:!1});const j=e.computed(()=>D.value.length?D.value.filter(n=>S(n.permission)):[]),C=e.computed(()=>o.actions?j.value.length:K.value.length),I=e.computed(()=>o.actions?j.value.map((n,s)=>({key:he(n,s),label:n.label||"",icon:n.icon||null,component:ke(n),props:be(n),menuProps:Be(n),handler:()=>Ce(n)})):K.value.filter(n=>{const s=n.props||{};return s.permission&&s.permissionAction==="hide"?S(s.permission):!0}).map((n,s)=>{var v,B;const i=Ne(n,s),m=e.cloneVNode(n,{type:((v=n.props)==null?void 0:v.type)??(g.value?l.value:void 0),size:((B=n.props)==null?void 0:B.size)??w.value}),b=e.cloneVNode(n,{...n.props,type:H,size:Z});return{key:i,label:"",icon:null,component:m,props:{},menuProps:{},handler:null,vnode:m,menuVnode:b}})),W=e.computed(()=>I.value.slice(0,Y.value)),$=e.computed(()=>I.value.slice(Y.value)),pe=e.computed(()=>({size:w.value,compact:o.compact,vertical:o.vertical,block:o.block,...f})),fe=e.computed(()=>({text:u.value,size:w.value,type:l.value,...o.moreProps})),O=e.ref(o.maxItems);function me(){if(!d.value||!p.value||!y.value)return Math.min(o.maxItems,C.value);const n=d.value.clientWidth,s=p.value.querySelectorAll(".measure-item");if(s.length===0)return Math.min(o.maxItems,C.value);const i=C.value,m=[];for(let h=0;h<Math.min(i,s.length);h++)m.push(s[h].offsetWidth);const b=y.value.offsetWidth??0;let v=0,B=0;for(let h=0;h<m.length;h++){const P=m[h],A=v===0?P:v+o.gap+P,E=m.length-(h+1)>0?v===0?b:o.gap+b:0;if(A+E<=n){v=A,B++;continue}break}return Math.max(0,Math.min(B,o.maxItems,i))}const L=()=>{if(o.disableCollapse){O.value=C.value;return}if(C.value<=1){O.value=C.value;return}O.value=me()},z=J.useDebounceFn(()=>{L()},Me),N=(n=!1)=>{n?(typeof z=="function"&&"cancel"in z&&z.cancel(),L()):z()};N.cancel=()=>{typeof z=="function"&&"cancel"in z&&z.cancel()};let M=null;const ye=async()=>{await e.nextTick(),L(),d.value&&typeof ResizeObserver<"u"&&(M=new ResizeObserver(n=>{n[0].contentRect.width>0&&N()}),M.observe(d.value))},ge=()=>{M&&d.value&&M.unobserve(d.value),M=null,"cancel"in N&&N.cancel()};e.onMounted(async()=>{L(),await e.nextTick(),ye()}),e.onUnmounted(()=>{ge()}),e.watch([j,C,()=>o.maxItems,()=>o.gap],async()=>{await e.nextTick(),N(!0)},{deep:!1});const Y=e.computed(()=>o.disableCollapse||C.value<=1?C.value:p.value&&y.value&&d.value?O.value:Math.min(o.maxItems,C.value)),ve=e.computed(()=>o.disableCollapse?!1:$.value.length>0);function ke(n){return n.component||V}function he(n,s){return n.key||n.label||`action-${s}`}function X(n){const{label:s,key:i,onClick:m,permission:b,permissionAction:v,icon:B,component:h,componentProps:P,slot:A,type:R,size:E,disabled:Se,...xe}=n;return{component:h,componentProps:P,type:R,size:E,rest:xe,permission:b,permissionAction:v,disabled:Se}}function be(n){const{component:s,componentProps:i,type:m,rest:b,permission:v,permissionAction:B,disabled:h}=X(n),P={type:m||l.value,size:w.value,disabled:h||!S(v)&&B==="disable",...b};if(s&&i){const A={...P,...i};return g.value&&(A.type="link"),A}return P}function Be(n){const{component:s,componentProps:i,rest:m,permission:b,permissionAction:v,disabled:B}=X(n),h={type:H,size:Z,disabled:B||!S(b)&&v==="disable",...m};if(s&&i){const{type:P,size:A,...R}=i,E={...h,...R};return E.type=H,E}return h}function Ce(n){n.onClick&&n.onClick(n),r("action-click",n)}return(n,s)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"containerRef",ref:d,class:"mtn-action-group"},[e.createVNode(e.unref(U),e.normalizeProps(e.guardReactiveProps(pe.value)),{default:e.withCtx(()=>[o.actions?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(W.value,i=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(i.component),e.mergeProps({key:i.key,ref_for:!0},i.props,{onClick:i.handler}),e.createSlots({default:e.withCtx(()=>[e.createTextVNode(" "+e.toDisplayString(i.label),1)]),_:2},[i.icon?{name:"icon",fn:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(i.icon)))]),key:"0"}:void 0]),1040,["onClick"]))),128)):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(W.value,i=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(i.vnode),{key:i.key}))),128)),ve.value?(e.openBlock(),e.createBlock(e.unref(G),e.normalizeProps(e.mergeProps({key:2},fe.value)),{icon:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(x.value)))]),overlay:e.withCtx(()=>[e.createVNode(e.unref(k.Menu),null,{default:e.withCtx(()=>[o.actions?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList($.value,i=>(e.openBlock(),e.createBlock(e.unref(k.Menu).Item,{key:i.key},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(i.component),e.mergeProps({ref_for:!0},i.menuProps,{onClick:i.handler}),e.createSlots({default:e.withCtx(()=>[e.createTextVNode(" "+e.toDisplayString(i.label),1)]),_:2},[i.icon?{name:"icon",fn:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(i.icon)))]),key:"0"}:void 0]),1040,["onClick"]))]),_:2},1024))),128)):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList($.value,i=>(e.openBlock(),e.createBlock(e.unref(k.Menu).Item,{key:i.key},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(i.menuVnode)))]),_:2},1024))),128))]),_:1})]),_:1},16)):e.createCommentVNode("",!0)]),_:1},16),e.createElementVNode("div",{ref_key:"measureRef",ref:p,class:"mtn-action-group-measure",style:e.normalizeStyle({gap:`${o.gap}px`})},[o.actions?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(I.value,(i,m)=>(e.openBlock(),e.createElementBlock("span",{key:m,class:"measure-item"},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(i.component),e.mergeProps({ref_for:!0},i.props),e.createSlots({default:e.withCtx(()=>[e.createTextVNode(" "+e.toDisplayString(i.label),1)]),_:2},[i.icon?{name:"icon",fn:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(i.icon)))]),key:"0"}:void 0]),1040))]))),128)):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(I.value,(i,m)=>(e.openBlock(),e.createElementBlock("span",{key:m,class:"measure-item"},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(i.vnode)))]))),128)),e.createElementVNode("span",{ref_key:"moreTriggerRef",ref:y,class:"measure-item"},[e.createVNode(e.unref(G),{text:u.value,size:w.value,type:l.value},{icon:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(x.value)))]),_:1},8,["text","size","type"])],512)],4)],512))}}),re=(t,a)=>{const o=t.__vccOpts||t;for(const[r,c]of a)o[r]=c;return o},ae=re(Ve,[["__scopeId","data-v-29d941f4"]]),_e={...te,loading:{type:Boolean,default:void 0},confirm:{type:[String,Boolean,Function],default:"确定要删除吗?"},confirmType:{type:String,default:"modal"},confirmTitle:{type:String,default:"确认删除"},okText:{type:String,default:"确定"},cancelText:{type:String,default:"取消"},hideIcon:{type:Boolean,default:!1},autoLoading:{type:Boolean,default:!0},beforeDelete:{type:Function,default:void 0},count:{type:Number,default:1},showSuccess:{type:Boolean,default:!1},successText:{type:String,default:"删除成功"},showError:{type:Boolean,default:!0},debounce:{type:Number,default:300},onDelete:{type:Function,default:void 0}},Ie=e.defineComponent({name:"MDeleteButton",inheritAttrs:!1,__name:"delete-button",props:_e,emits:["delete","success","error"],setup(t,{emit:a}){const o=a,r=t,c=e.ref(!1),f=e.ref(null),d=e.computed(()=>r.loading!==void 0?r.loading:r.autoLoading?c.value:!1),p=e.computed(()=>typeof r.confirm=="function"?r.confirm(r.count):r.confirm);e.watch(d,l=>{f.value&&e.nextTick(()=>{var u;(u=f.value)==null||u.update({okButtonProps:{loading:l}})})},{flush:"post"}),e.onBeforeUnmount(()=>{f.value&&(f.value.destroy(),f.value=null)});const y=async()=>{try{if(r.beforeDelete&&await r.beforeDelete()===!1)return;r.autoLoading&&r.loading===void 0&&(c.value=!0);let l=!1;const u=()=>{l||(l=!0,r.autoLoading&&r.loading===void 0&&(c.value=!1))};if(r.onDelete){const x=r.onDelete(u);if(x&&typeof x.then=="function")try{const S=await x;l||u(),_(S)}catch(S){throw l||u(),S}}else o("delete",u),r.autoLoading&&r.loading===void 0&&setTimeout(()=>{l||u()},5e3)}catch(l){r.autoLoading&&r.loading===void 0&&(c.value=!1);const u=l instanceof Error?l:new Error(String(l));o("error",u),r.showError&&k.message.error(u.message||"删除失败,请重试")}},_=l=>{r.showSuccess&&k.message.success(r.successText||"删除成功"),o("success",l)},g=r.debounce>0?J.useDebounceFn(y,r.debounce):y,w=()=>{if(!p.value){g();return}if(r.confirmType==="popconfirm")return;const l=()=>{f.value=k.Modal.confirm({title:r.confirmTitle,content:p.value,okText:r.okText,cancelText:r.cancelText,okType:"danger",okButtonProps:{loading:d.value},onOk:async()=>{try{return await y(),new Promise(u=>{if(!d.value){u();return}const x=e.watch(d,S=>{S||(x(),u())})})}catch(u){throw u}},onCancel:()=>{f.value=null},afterClose:()=>{f.value=null}})};e.nextTick(l)};return(l,u)=>p.value&&l.confirmType==="popconfirm"?(e.openBlock(),e.createBlock(e.unref(k.Popconfirm),{key:0,title:p.value,"ok-text":l.okText,"cancel-text":l.cancelText,"ok-button-props":{loading:d.value,danger:!0},onConfirm:e.unref(g)},{icon:e.withCtx(()=>[e.renderSlot(l.$slots,"popconfirmIcon",{},()=>[e.createVNode(e.unref(F.ExclamationCircleOutlined),{class:"text-[--color-ant-error]"})],!0)]),default:e.withCtx(()=>[e.createVNode(e.unref(V),e.mergeProps(l.$attrs,{type:l.type,size:l.size,danger:!0,loading:d.value,disabled:l.disabled,permission:l.permission,"permission-action":l.permissionAction,class:"group"}),e.createSlots({default:e.withCtx(()=>[e.renderSlot(l.$slots,"default",{},()=>[u[0]||(u[0]=e.createTextVNode("删除",-1))],!0)]),_:2},[l.hideIcon?void 0:{name:"icon",fn:e.withCtx(()=>[e.renderSlot(l.$slots,"icon",{},()=>[e.createVNode(e.unref(F.DeleteOutlined))],!0)]),key:"0"}]),1040,["type","size","loading","disabled","permission","permission-action"])]),_:3},8,["title","ok-text","cancel-text","ok-button-props","onConfirm"])):(e.openBlock(),e.createBlock(e.unref(V),e.mergeProps({key:1},l.$attrs,{type:l.type,size:l.size,danger:!0,loading:d.value,disabled:l.disabled,permission:l.permission,"permission-action":l.permissionAction,onClick:w}),e.createSlots({default:e.withCtx(()=>[e.renderSlot(l.$slots,"default",{},()=>[u[1]||(u[1]=e.createTextVNode("删除",-1))],!0)]),_:2},[l.hideIcon?void 0:{name:"icon",fn:e.withCtx(()=>[e.renderSlot(l.$slots,"icon",{},()=>[e.createVNode(e.unref(F.DeleteOutlined))],!0)]),key:"0"}]),1040,["type","size","loading","disabled","permission","permission-action"]))}}),ie=re(Ie,[["__scopeId","data-v-a943bc19"]]);var le=(t=>(t.TEXT="text",t.TAG="tag",t.DATE="date",t.DATETIME="dateTime",t.SELECT="select",t.STATUS="status",t.CUSTOM="custom",t))(le||{}),ce=(t=>(t.LEFT="left",t.CENTER="center",t.RIGHT="right",t))(ce||{}),ue=(t=>(t.SMALL="small",t.MIDDLE="middle",t.LARGE="large",t))(ue||{}),se=(t=>(t.CHECKBOX="checkbox",t.RADIO="radio",t))(se||{}),de=(t=>(t.LEFT="left",t.RIGHT="right",t))(de||{});const Oe=[V,U,G,ae,ie,ee,k.Table],Le={install(t){Oe.forEach(a=>{t.component(a.name||"",a)})}};Object.defineProperty(exports,"Table",{enumerable:!0,get:()=>k.Table});exports.ActionGroup=ae;exports.Button=V;exports.ButtonGroup=U;exports.ButtonPositionEnum=de;exports.DeleteButton=ie;exports.DropdownButton=G;exports.TableColumnAlignEnum=ce;exports.TableColumnTypeEnum=le;exports.TableSelectionTypeEnum=se;exports.TableSizeEnum=ue;exports.Tag=ee;exports.buttonGroupProps=oe;exports.default=Le;exports.tagProps=Q;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const T=require("@mtn-ui/shared"),e=require("vue"),Pe=require("class-variance-authority"),k=require("ant-design-vue"),J=require("@vueuse/core"),F=require("@ant-design/icons-vue"),Q={type:{type:String,default:"default"},color:{type:String}},Te=Pe.cva("inline-flex items-center px-2 py-0.5 rounded text-xs font-medium border transition-colors",{variants:{type:{default:"bg-gray-100 text-gray-800 border-gray-200",success:"bg-green-100 text-green-800 border-green-200",processing:"bg-blue-100 text-blue-800 border-blue-200",error:"bg-red-100 text-red-800 border-red-200",warning:"bg-orange-100 text-orange-800 border-orange-200"}},defaultVariants:{type:"default"}}),we=e.defineComponent({name:"MTag",props:Q,setup(t,{slots:a,attrs:o}){return()=>{var c;const{type:r}=t;return e.createVNode("span",{class:T.cn(Te({type:r}),o.class)},[(c=a.default)==null?void 0:c.call(a)])}}}),ee=T.withInstall(we),te={type:{type:String,default:"default"},size:{type:String,default:"middle"},loading:{type:Boolean,default:!1},disabled:{type:Boolean,default:!1},danger:{type:Boolean,default:!1},block:{type:Boolean,default:!1},ghost:{type:Boolean,default:!1},shape:{type:String,default:"default"},htmlType:{type:String,default:"button"},icon:{type:Object},permission:{type:[String,Array],default:void 0},permissionAction:{type:String,default:"hide"}};function ne(t){const{permission:a,permissionAction:o="hide"}=t,r=e.inject(T.PERMISSION_CHECKER_KEY,e.ref(T.defaultPermissionChecker)),c=e.computed(()=>a?r.value(a):!0),f=e.computed(()=>!c.value&&o==="hide"),d=e.computed(()=>!c.value&&o==="disable");return{hasPermission:c,shouldHide:f,shouldDisable:d}}function De(t,a){return t.map(o=>{if(!o||o.type==="divider"||!o.permission)return o;if(!a(o.permission)){const c=o.permissionAction||"hide";if(c==="hide")return null;if(c==="disable")return{...o,disabled:!0}}return o}).filter(Boolean)}const M=e.defineComponent({name:"MButton",props:te,emits:["click"],setup(t,{slots:a,attrs:o,emit:r}){const{shouldHide:c,shouldDisable:f}=ne({permission:t.permission,permissionAction:t.permissionAction}),d=p=>{r("click",p)};return()=>c.value?null:e.createVNode(k.Button,e.mergeProps({type:t.type,size:t.size,loading:t.loading,disabled:t.disabled||f.value,danger:t.danger,block:t.block,ghost:t.ghost,shape:t.shape,htmlType:t.htmlType,icon:t.icon},o,{class:["mtn-button",o.class],onClick:d}),{default:()=>{var p;return(p=a.default)==null?void 0:p.call(a)},icon:()=>{var p;return(p=a.icon)==null?void 0:p.call(a)}})}}),oe={size:{type:String,default:"middle"},compact:{type:Boolean,default:!0},gap:{type:[Number,String],default:8},vertical:{type:Boolean,default:!1},block:{type:Boolean,default:!1}},U=e.defineComponent({name:"MButtonGroup",props:oe,setup(t,{slots:a,attrs:o}){return()=>e.createVNode(e.Fragment,null,[t.compact?e.createVNode(k.Space.Compact,e.mergeProps({size:t.size,direction:t.vertical?"vertical":"horizontal",block:t.block},o,{class:["mtn-button-group","mtn-button-group--compact",o.class]}),{default:()=>{var r;return[(r=a.default)==null?void 0:r.call(a)]}}):e.createVNode(k.Space,e.mergeProps({size:typeof t.gap=="number"?t.gap:parseInt(t.gap)||8,direction:t.vertical?"vertical":"horizontal"},o,{class:["mtn-button-group","mtn-button-group--normal",o.class]}),{default:()=>{var r;return[(r=a.default)==null?void 0:r.call(a)]}})])}}),ze={text:{type:String,default:"Dropdown"},type:{type:String,default:"default"},size:{type:String,default:"middle"},menu:{type:Array,default:void 0},disabled:{type:Boolean,default:!1},loading:{type:Boolean,default:!1},danger:{type:Boolean,default:!1},placement:{type:String,default:"bottomLeft"},trigger:{type:Array,default:()=>["click"]},permission:{type:[String,Array],default:void 0},permissionAction:{type:String,default:"hide"}},G=e.defineComponent({name:"MDropdownButton",props:ze,emits:["click"],setup(t,{slots:a,attrs:o,emit:r}){const{shouldHide:c,shouldDisable:f}=ne({permission:t.permission,permissionAction:t.permissionAction}),d=e.inject(T.PERMISSION_CHECKER_KEY,e.ref(T.defaultPermissionChecker)),p=y=>{r("click",y)};return()=>{if(c.value)return null;const y={};if(a.overlay)y.overlay=a.overlay;else if(t.menu&&t.menu.length>0){const g=De(t.menu,d.value);y.overlay=()=>e.h(k.Menu,{items:g})}return a.icon&&(y.icon=a.icon),!(a.default||t.text)?e.createVNode(k.Dropdown,e.mergeProps({placement:t.placement,trigger:t.trigger},o,{class:["mtn-dropdown-button",o.class]}),{default:()=>[e.createVNode(k.Button,{type:t.type,size:t.size==="middle"?void 0:t.size,disabled:t.disabled||f.value,loading:t.loading,danger:t.danger,onClick:p},{default:()=>{var g;return[(g=a.icon)==null?void 0:g.call(a)]}})],...y}):e.createVNode(k.Dropdown.Button,e.mergeProps({type:t.type,size:t.size==="middle"?void 0:t.size,disabled:t.disabled||f.value,loading:t.loading,danger:t.danger,placement:t.placement,trigger:t.trigger},o,{class:["mtn-dropdown-button",o.class],onClick:p}),{default:()=>{var g;return[((g=a.default)==null?void 0:g.call(a))||t.text]},...y})}}}),Ae={actions:{type:Array,default:void 0},mode:{type:String,default:"default"},maxItems:{type:Number,default:3},gap:{type:Number,default:8},moreText:{type:String,default:"更多"},moreIcon:{type:Object,default:void 0},moreProps:{type:Object,default:()=>({})},size:{type:String,default:"middle"},compact:{type:Boolean,default:!1},vertical:{type:Boolean,default:!1},block:{type:Boolean,default:!1},disableCollapse:{type:Boolean,default:!1}};function Ee(t){return t?t.filter(a=>a.type!==e.Comment&&a.type!==e.Text&&a.type!==Symbol.for("v-fgt")):[]}function Ne(t,a){var o,r;if(t.key!==null&&t.key!==void 0)return typeof t.key=="symbol"?t.key.toString():t.key;if(((o=t.props)==null?void 0:o.key)!==null&&((r=t.props)==null?void 0:r.key)!==void 0){const c=t.props.key;return typeof c=="symbol"?c.toString():c}return`button-${a}`}const H="link",Z="small",_e=150,Me=e.defineComponent({name:"MActionGroup",inheritAttrs:!1,__name:"action-group",props:Ae,emits:["action-click"],setup(t,{emit:a}){const o=t,r=a,c=e.useSlots(),f=e.useAttrs(),d=e.ref(),p=e.ref(),y=e.ref(),V=e.inject(T.PERMISSION_CHECKER_KEY,e.ref(T.defaultPermissionChecker)),g=e.computed(()=>o.mode==="table"),w=e.computed(()=>g.value?"small":o.size),l=e.computed(()=>g.value?"link":"default"),u=e.computed(()=>g.value?"":o.moreText),x=e.computed(()=>o.moreIcon||F.MoreOutlined);function S(n){return n?V.value(n):!0}const K=e.computed(()=>{var n;return Ee((n=c.default)==null?void 0:n.call(c))}),D=e.shallowRef([]);function q(n){var b,v,B;const s=n.icon&&(n.icon.name||n.icon.__name)||"",i=n.component&&(n.component.name||n.component.__name)||"";return[n.key??"",n.label??"",s,i,Array.isArray(n.permission)?n.permission.join(","):n.permission??"",n.permissionAction??"",String(n.disabled??!1),String(((b=n.componentProps)==null?void 0:b.confirm)??""),String(((v=n.componentProps)==null?void 0:v.showSuccess)??""),String(((B=n.componentProps)==null?void 0:B.danger)??"")].join("|")}e.watch(()=>o.actions,n=>{if(!n){D.value=[];return}if(D.value.length!==n.length){D.value=n;return}const s=n.map(q).join("||"),i=D.value.map(q).join("||");s!==i&&(D.value=n)},{immediate:!0,deep:!1});const j=e.computed(()=>D.value.length?D.value.filter(n=>S(n.permission)):[]),C=e.computed(()=>o.actions?j.value.length:K.value.length),I=e.computed(()=>o.actions?j.value.map((n,s)=>({key:he(n,s),label:n.label||"",icon:n.icon||null,component:ke(n),props:be(n),menuProps:Be(n),handler:()=>Ce(n)})):K.value.filter(n=>{const s=n.props||{};return s.permission&&s.permissionAction==="hide"?S(s.permission):!0}).map((n,s)=>{var v,B;const i=Ne(n,s),m=e.cloneVNode(n,{type:((v=n.props)==null?void 0:v.type)??(g.value?l.value:void 0),size:((B=n.props)==null?void 0:B.size)??w.value}),b=e.cloneVNode(n,{...n.props,type:H,size:Z});return{key:i,label:"",icon:null,component:m,props:{},menuProps:{},handler:null,vnode:m,menuVnode:b}})),W=e.computed(()=>I.value.slice(0,Y.value)),$=e.computed(()=>I.value.slice(Y.value)),pe=e.computed(()=>({size:w.value,compact:o.compact,vertical:o.vertical,block:o.block,...f})),fe=e.computed(()=>({text:u.value,size:w.value,type:l.value,...o.moreProps})),O=e.ref(o.maxItems);function me(){if(!d.value||!p.value||!y.value)return Math.min(o.maxItems,C.value);const n=d.value.clientWidth,s=p.value.querySelectorAll(".measure-item");if(s.length===0)return Math.min(o.maxItems,C.value);const i=C.value,m=[];for(let h=0;h<Math.min(i,s.length);h++)m.push(s[h].offsetWidth);const b=y.value.offsetWidth??0;let v=0,B=0;for(let h=0;h<m.length;h++){const P=m[h],A=v===0?P:v+o.gap+P,E=m.length-(h+1)>0?v===0?b:o.gap+b:0;if(A+E<=n){v=A,B++;continue}break}return Math.max(0,Math.min(B,o.maxItems,i))}const L=()=>{if(o.disableCollapse){O.value=C.value;return}if(C.value<=1){O.value=C.value;return}O.value=me()},z=J.useDebounceFn(()=>{L()},_e),N=(n=!1)=>{n?(typeof z=="function"&&"cancel"in z&&z.cancel(),L()):z()};N.cancel=()=>{typeof z=="function"&&"cancel"in z&&z.cancel()};let _=null;const ye=async()=>{await e.nextTick(),L(),d.value&&typeof ResizeObserver<"u"&&(_=new ResizeObserver(n=>{n[0].contentRect.width>0&&N()}),_.observe(d.value))},ge=()=>{_&&d.value&&_.unobserve(d.value),_=null,"cancel"in N&&N.cancel()};e.onMounted(async()=>{L(),await e.nextTick(),ye()}),e.onUnmounted(()=>{ge()}),e.watch([j,C,()=>o.maxItems,()=>o.gap],async()=>{await e.nextTick(),N(!0)},{deep:!1});const Y=e.computed(()=>o.disableCollapse||C.value<=1?C.value:p.value&&y.value&&d.value?O.value:Math.min(o.maxItems,C.value)),ve=e.computed(()=>o.disableCollapse?!1:$.value.length>0);function ke(n){return n.component||M}function he(n,s){return n.key||n.label||`action-${s}`}function X(n){const{label:s,key:i,onClick:m,permission:b,permissionAction:v,icon:B,component:h,componentProps:P,slot:A,type:R,size:E,disabled:Se,...xe}=n;return{component:h,componentProps:P,type:R,size:E,rest:xe,permission:b,permissionAction:v,disabled:Se}}function be(n){const{component:s,componentProps:i,type:m,rest:b,permission:v,permissionAction:B,disabled:h}=X(n),P={type:m||l.value,size:w.value,disabled:h||!S(v)&&B==="disable",...b};if(s&&i){const A={...P,...i};return g.value&&(A.type="link"),A}return P}function Be(n){const{component:s,componentProps:i,rest:m,permission:b,permissionAction:v,disabled:B}=X(n),h={type:H,size:Z,disabled:B||!S(b)&&v==="disable",...m};if(s&&i){const{type:P,size:A,...R}=i,E={...h,...R};return E.type=H,E}return h}function Ce(n){n.onClick&&n.onClick(n),r("action-click",n)}return(n,s)=>(e.openBlock(),e.createElementBlock("div",{ref_key:"containerRef",ref:d,class:"mtn-action-group"},[e.createVNode(e.unref(U),e.normalizeProps(e.guardReactiveProps(pe.value)),{default:e.withCtx(()=>[o.actions?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(W.value,i=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(i.component),e.mergeProps({key:i.key,ref_for:!0},i.props,{onClick:i.handler}),e.createSlots({default:e.withCtx(()=>[e.createTextVNode(" "+e.toDisplayString(i.label),1)]),_:2},[i.icon?{name:"icon",fn:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(i.icon)))]),key:"0"}:void 0]),1040,["onClick"]))),128)):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(W.value,i=>(e.openBlock(),e.createBlock(e.resolveDynamicComponent(i.vnode),{key:i.key}))),128)),ve.value?(e.openBlock(),e.createBlock(e.unref(G),e.normalizeProps(e.mergeProps({key:2},fe.value)),{icon:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(x.value)))]),overlay:e.withCtx(()=>[e.createVNode(e.unref(k.Menu),null,{default:e.withCtx(()=>[o.actions?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList($.value,i=>(e.openBlock(),e.createBlock(e.unref(k.Menu).Item,{key:i.key},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(i.component),e.mergeProps({ref_for:!0},i.menuProps,{onClick:i.handler}),e.createSlots({default:e.withCtx(()=>[e.createTextVNode(" "+e.toDisplayString(i.label),1)]),_:2},[i.icon?{name:"icon",fn:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(i.icon)))]),key:"0"}:void 0]),1040,["onClick"]))]),_:2},1024))),128)):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList($.value,i=>(e.openBlock(),e.createBlock(e.unref(k.Menu).Item,{key:i.key},{default:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(i.menuVnode)))]),_:2},1024))),128))]),_:1})]),_:1},16)):e.createCommentVNode("",!0)]),_:1},16),e.createElementVNode("div",{ref_key:"measureRef",ref:p,class:"mtn-action-group-measure",style:e.normalizeStyle({gap:`${o.gap}px`})},[o.actions?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:0},e.renderList(I.value,(i,m)=>(e.openBlock(),e.createElementBlock("span",{key:m,class:"measure-item"},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(i.component),e.mergeProps({ref_for:!0},i.props),e.createSlots({default:e.withCtx(()=>[e.createTextVNode(" "+e.toDisplayString(i.label),1)]),_:2},[i.icon?{name:"icon",fn:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(i.icon)))]),key:"0"}:void 0]),1040))]))),128)):(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(I.value,(i,m)=>(e.openBlock(),e.createElementBlock("span",{key:m,class:"measure-item"},[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(i.vnode)))]))),128)),e.createElementVNode("span",{ref_key:"moreTriggerRef",ref:y,class:"measure-item"},[e.createVNode(e.unref(G),{text:u.value,size:w.value,type:l.value},{icon:e.withCtx(()=>[(e.openBlock(),e.createBlock(e.resolveDynamicComponent(x.value)))]),_:1},8,["text","size","type"])],512)],4)],512))}}),re=(t,a)=>{const o=t.__vccOpts||t;for(const[r,c]of a)o[r]=c;return o},ae=re(Me,[["__scopeId","data-v-29d941f4"]]),Ve={...te,loading:{type:Boolean,default:void 0},confirm:{type:[String,Boolean,Function],default:"确定要删除吗?"},confirmType:{type:String,default:"modal"},confirmTitle:{type:String,default:"确认删除"},okText:{type:String,default:"确定"},cancelText:{type:String,default:"取消"},hideIcon:{type:Boolean,default:!1},autoLoading:{type:Boolean,default:!0},beforeDelete:{type:Function,default:void 0},count:{type:Number,default:1},showSuccess:{type:Boolean,default:!1},successText:{type:String,default:"删除成功"},showError:{type:Boolean,default:!0},debounce:{type:Number,default:300},onDelete:{type:Function,default:void 0}},Ie=e.defineComponent({name:"MDeleteButton",inheritAttrs:!1,__name:"delete-button",props:Ve,emits:["delete","success","error"],setup(t,{emit:a}){const o=a,r=t,c=e.ref(!1),f=e.ref(null),d=e.computed(()=>r.loading!==void 0?r.loading:r.autoLoading?c.value:!1),p=e.computed(()=>typeof r.confirm=="function"?r.confirm(r.count):r.confirm);e.watch(d,l=>{f.value&&e.nextTick(()=>{var u;(u=f.value)==null||u.update({okButtonProps:{loading:l}})})},{flush:"post"}),e.onBeforeUnmount(()=>{f.value&&(f.value.destroy(),f.value=null)});const y=async()=>{try{if(r.beforeDelete&&await r.beforeDelete()===!1)return;r.autoLoading&&r.loading===void 0&&(c.value=!0);let l=!1;const u=()=>{l||(l=!0,r.autoLoading&&r.loading===void 0&&(c.value=!1))};if(r.onDelete){const x=r.onDelete(u);if(x&&typeof x.then=="function")try{const S=await x;l||u(),V(S)}catch(S){throw l||u(),S}}else o("delete",u),r.autoLoading&&r.loading===void 0&&setTimeout(()=>{l||u()},5e3)}catch(l){r.autoLoading&&r.loading===void 0&&(c.value=!1);const u=l instanceof Error?l:new Error(String(l));o("error",u),r.showError&&k.message.error(u.message||"删除失败,请重试")}},V=l=>{r.showSuccess&&k.message.success(r.successText||"删除成功"),o("success",l)},g=r.debounce>0?J.useDebounceFn(y,r.debounce):y,w=()=>{if(!p.value){g();return}if(r.confirmType==="popconfirm")return;const l=()=>{f.value=k.Modal.confirm({title:r.confirmTitle,content:p.value,okText:r.okText,cancelText:r.cancelText,okType:"danger",okButtonProps:{loading:d.value},onOk:async()=>{try{return await y(),new Promise(u=>{if(!d.value){u();return}const x=e.watch(d,S=>{S||(x(),u())})})}catch(u){throw u}},onCancel:()=>{f.value=null},afterClose:()=>{f.value=null}})};e.nextTick(l)};return(l,u)=>p.value&&l.confirmType==="popconfirm"?(e.openBlock(),e.createBlock(e.unref(k.Popconfirm),{key:0,title:p.value,"ok-text":l.okText,"cancel-text":l.cancelText,"ok-button-props":{loading:d.value,danger:!0},onConfirm:e.unref(g)},{icon:e.withCtx(()=>[e.renderSlot(l.$slots,"popconfirmIcon",{},()=>[e.createVNode(e.unref(F.ExclamationCircleOutlined),{class:"text-[--color-ant-error]"})],!0)]),default:e.withCtx(()=>[e.createVNode(e.unref(M),e.mergeProps(l.$attrs,{type:l.type,size:l.size,danger:!0,loading:d.value,disabled:l.disabled,permission:l.permission,"permission-action":l.permissionAction,class:"group"}),e.createSlots({default:e.withCtx(()=>[e.renderSlot(l.$slots,"default",{},()=>[u[0]||(u[0]=e.createTextVNode("删除",-1))],!0)]),_:2},[l.hideIcon?void 0:{name:"icon",fn:e.withCtx(()=>[e.renderSlot(l.$slots,"icon",{},()=>[e.createVNode(e.unref(F.DeleteOutlined))],!0)]),key:"0"}]),1040,["type","size","loading","disabled","permission","permission-action"])]),_:3},8,["title","ok-text","cancel-text","ok-button-props","onConfirm"])):(e.openBlock(),e.createBlock(e.unref(M),e.mergeProps({key:1},l.$attrs,{type:l.type,size:l.size,danger:!0,loading:d.value,disabled:l.disabled,permission:l.permission,"permission-action":l.permissionAction,onClick:w}),e.createSlots({default:e.withCtx(()=>[e.renderSlot(l.$slots,"default",{},()=>[u[1]||(u[1]=e.createTextVNode("删除",-1))],!0)]),_:2},[l.hideIcon?void 0:{name:"icon",fn:e.withCtx(()=>[e.renderSlot(l.$slots,"icon",{},()=>[e.createVNode(e.unref(F.DeleteOutlined))],!0)]),key:"0"}]),1040,["type","size","loading","disabled","permission","permission-action"]))}}),ie=re(Ie,[["__scopeId","data-v-a943bc19"]]);var le=(t=>(t.TEXT="text",t.TAG="tag",t.DATE="date",t.DATETIME="dateTime",t.SELECT="select",t.STATUS="status",t.CUSTOM="custom",t))(le||{}),ce=(t=>(t.LEFT="left",t.CENTER="center",t.RIGHT="right",t))(ce||{}),ue=(t=>(t.SMALL="small",t.MIDDLE="middle",t.LARGE="large",t))(ue||{}),se=(t=>(t.CHECKBOX="checkbox",t.RADIO="radio",t))(se||{}),de=(t=>(t.LEFT="left",t.RIGHT="right",t))(de||{});const Oe=[M,U,G,ae,ie,ee,k.Table],Le={install(t){Oe.forEach(a=>{const o=a.name||a.__name;if(o){const r=t._context.components;(!r||!r[o])&&t.component(o,a)}})}};Object.defineProperty(exports,"Table",{enumerable:!0,get:()=>k.Table});exports.ActionGroup=ae;exports.Button=M;exports.ButtonGroup=U;exports.ButtonPositionEnum=de;exports.DeleteButton=ie;exports.DropdownButton=G;exports.TableColumnAlignEnum=ce;exports.TableColumnTypeEnum=le;exports.TableSelectionTypeEnum=se;exports.TableSizeEnum=ue;exports.Tag=ee;exports.buttonGroupProps=oe;exports.default=Le;exports.tagProps=Q;
|
package/dist/index.js
CHANGED
|
@@ -1,35 +1,39 @@
|
|
|
1
|
-
import { Tag as
|
|
1
|
+
import { Tag as e } from "./data-display/tag/index.js";
|
|
2
2
|
import m from "./antd-wrapped/button/button.js";
|
|
3
|
-
import
|
|
4
|
-
import { buttonGroupProps as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import { Table as
|
|
9
|
-
import { Table as
|
|
10
|
-
import { ButtonPositionEnum as A, TableColumnAlignEnum as
|
|
11
|
-
import { tagProps as
|
|
12
|
-
const l = [m,
|
|
13
|
-
install(
|
|
3
|
+
import p from "./antd-wrapped/button-group/button-group.js";
|
|
4
|
+
import { buttonGroupProps as G } from "./antd-wrapped/button-group/props.js";
|
|
5
|
+
import i from "./antd-wrapped/dropdown-button/dropdown-button.js";
|
|
6
|
+
import u from "./antd-wrapped/action-group/action-group.vue.js";
|
|
7
|
+
import f from "./antd-wrapped/delete-button/delete-button.vue.js";
|
|
8
|
+
import { Table as a } from "ant-design-vue";
|
|
9
|
+
import { Table as _ } from "ant-design-vue";
|
|
10
|
+
import { ButtonPositionEnum as A, TableColumnAlignEnum as D, TableColumnTypeEnum as S, TableSelectionTypeEnum as h, TableSizeEnum as w } from "./antd-wrapped/table/table.js";
|
|
11
|
+
import { tagProps as j } from "./data-display/tag/props.js";
|
|
12
|
+
const l = [m, p, i, u, f, e, a], d = {
|
|
13
|
+
install(n) {
|
|
14
14
|
l.forEach((o) => {
|
|
15
|
-
t
|
|
15
|
+
const t = o.name || o.__name;
|
|
16
|
+
if (t) {
|
|
17
|
+
const r = n._context.components;
|
|
18
|
+
(!r || !r[t]) && n.component(t, o);
|
|
19
|
+
}
|
|
16
20
|
});
|
|
17
21
|
}
|
|
18
22
|
};
|
|
19
23
|
export {
|
|
20
|
-
|
|
24
|
+
u as ActionGroup,
|
|
21
25
|
m as Button,
|
|
22
|
-
|
|
26
|
+
p as ButtonGroup,
|
|
23
27
|
A as ButtonPositionEnum,
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
28
|
+
f as DeleteButton,
|
|
29
|
+
i as DropdownButton,
|
|
30
|
+
_ as Table,
|
|
31
|
+
D as TableColumnAlignEnum,
|
|
32
|
+
S as TableColumnTypeEnum,
|
|
33
|
+
h as TableSelectionTypeEnum,
|
|
34
|
+
w as TableSizeEnum,
|
|
35
|
+
e as Tag,
|
|
36
|
+
G as buttonGroupProps,
|
|
37
|
+
d as default,
|
|
38
|
+
j as tagProps
|
|
35
39
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { cn as Ue, withInstall as je, PERMISSION_CHECKER_KEY as le, defaultPermissionChecker as se } from "@mtn-ui/shared";
|
|
2
|
-
import { defineComponent as G, createVNode as B, inject as ue, ref as
|
|
2
|
+
import { defineComponent as G, createVNode as B, inject as ue, ref as M, computed as p, mergeProps as x, Fragment as R, h as Fe, Comment as He, Text as Ke, useSlots as We, useAttrs as Ye, shallowRef as Xe, watch as ee, cloneVNode as ye, onMounted as qe, nextTick as H, onUnmounted as Ze, createElementBlock as I, openBlock as s, createElementVNode as ge, unref as P, normalizeProps as ve, guardReactiveProps as Je, withCtx as m, createBlock as h, createCommentVNode as Qe, renderList as $, resolveDynamicComponent as A, createSlots as K, createTextVNode as W, toDisplayString as re, normalizeStyle as et, onBeforeUnmount as tt, renderSlot as F } from "vue";
|
|
3
3
|
import { cva as nt } from "class-variance-authority";
|
|
4
4
|
import { Button as ze, Space as be, Dropdown as ke, Menu as Q, Popconfirm as ot, message as he, Modal as rt, Table as at } from "ant-design-vue";
|
|
5
5
|
import { Table as Vt } from "ant-design-vue";
|
|
@@ -107,7 +107,7 @@ const st = {
|
|
|
107
107
|
}
|
|
108
108
|
};
|
|
109
109
|
function Te(e) {
|
|
110
|
-
const { permission: r, permissionAction: n = "hide" } = e, o = ue(le,
|
|
110
|
+
const { permission: r, permissionAction: n = "hide" } = e, o = ue(le, M(se)), l = p(() => r ? o.value(r) : !0), y = p(() => !l.value && n === "hide"), d = p(() => !l.value && n === "disable");
|
|
111
111
|
return {
|
|
112
112
|
hasPermission: l,
|
|
113
113
|
shouldHide: y,
|
|
@@ -304,7 +304,7 @@ const te = /* @__PURE__ */ G({
|
|
|
304
304
|
} = Te({
|
|
305
305
|
permission: e.permission,
|
|
306
306
|
permissionAction: e.permissionAction
|
|
307
|
-
}), d = ue(le,
|
|
307
|
+
}), d = ue(le, M(se)), f = (v) => {
|
|
308
308
|
o("click", v);
|
|
309
309
|
};
|
|
310
310
|
return () => {
|
|
@@ -470,8 +470,8 @@ const ae = "link", Be = "small", bt = 150, kt = /* @__PURE__ */ G({
|
|
|
470
470
|
props: yt,
|
|
471
471
|
emits: ["action-click"],
|
|
472
472
|
setup(e, { emit: r }) {
|
|
473
|
-
const n = e, o = r, l = We(), y = Ye(), d =
|
|
474
|
-
function
|
|
473
|
+
const n = e, o = r, l = We(), y = Ye(), d = M(), f = M(), v = M(), Y = ue(le, M(se)), b = p(() => n.mode === "table"), E = p(() => b.value ? "small" : n.size), i = p(() => b.value ? "link" : "default"), u = p(() => b.value ? "" : n.moreText), w = p(() => n.moreIcon || it);
|
|
474
|
+
function _(t) {
|
|
475
475
|
return t ? Y.value(t) : !0;
|
|
476
476
|
}
|
|
477
477
|
const ce = p(() => {
|
|
@@ -510,7 +510,7 @@ const ae = "link", Be = "small", bt = 150, kt = /* @__PURE__ */ G({
|
|
|
510
510
|
},
|
|
511
511
|
{ immediate: !0, deep: !1 }
|
|
512
512
|
);
|
|
513
|
-
const ne = p(() => O.value.length ? O.value.filter((t) =>
|
|
513
|
+
const ne = p(() => O.value.length ? O.value.filter((t) => _(t.permission)) : []), T = p(() => n.actions ? ne.value.length : ce.value.length), X = p(() => n.actions ? ne.value.map((t, c) => ({
|
|
514
514
|
key: Le(t, c),
|
|
515
515
|
label: t.label || "",
|
|
516
516
|
icon: t.icon || null,
|
|
@@ -520,7 +520,7 @@ const ae = "link", Be = "small", bt = 150, kt = /* @__PURE__ */ G({
|
|
|
520
520
|
handler: () => Ve(t)
|
|
521
521
|
})) : ce.value.filter((t) => {
|
|
522
522
|
const c = t.props || {};
|
|
523
|
-
return c.permission && c.permissionAction === "hide" ?
|
|
523
|
+
return c.permission && c.permissionAction === "hide" ? _(c.permission) : !0;
|
|
524
524
|
}).map((t, c) => {
|
|
525
525
|
var k, C;
|
|
526
526
|
const a = vt(t, c), g = ye(t, {
|
|
@@ -548,19 +548,19 @@ const ae = "link", Be = "small", bt = 150, kt = /* @__PURE__ */ G({
|
|
|
548
548
|
menuVnode: z
|
|
549
549
|
// 保存菜单模式的 vnode
|
|
550
550
|
};
|
|
551
|
-
})), fe = p(() => X.value.slice(0, pe.value)), oe = p(() => X.value.slice(pe.value)),
|
|
551
|
+
})), fe = p(() => X.value.slice(0, pe.value)), oe = p(() => X.value.slice(pe.value)), _e = p(() => ({
|
|
552
552
|
size: E.value,
|
|
553
553
|
compact: n.compact,
|
|
554
554
|
vertical: n.vertical,
|
|
555
555
|
block: n.block,
|
|
556
556
|
...y
|
|
557
|
-
})),
|
|
557
|
+
})), we = p(() => ({
|
|
558
558
|
text: u.value,
|
|
559
559
|
size: E.value,
|
|
560
560
|
type: i.value,
|
|
561
561
|
...n.moreProps
|
|
562
|
-
})), q =
|
|
563
|
-
function
|
|
562
|
+
})), q = M(n.maxItems);
|
|
563
|
+
function Ie() {
|
|
564
564
|
if (!d.value || !f.value || !v.value)
|
|
565
565
|
return Math.min(n.maxItems, T.value);
|
|
566
566
|
const t = d.value.clientWidth, c = f.value.querySelectorAll(".measure-item");
|
|
@@ -571,7 +571,7 @@ const ae = "link", Be = "small", bt = 150, kt = /* @__PURE__ */ G({
|
|
|
571
571
|
const z = v.value.offsetWidth ?? 0;
|
|
572
572
|
let k = 0, C = 0;
|
|
573
573
|
for (let S = 0; S < g.length; S++) {
|
|
574
|
-
const
|
|
574
|
+
const D = g[S], N = k === 0 ? D : k + n.gap + D, V = g.length - (S + 1) > 0 ? k === 0 ? z : n.gap + z : 0;
|
|
575
575
|
if (N + V <= t) {
|
|
576
576
|
k = N, C++;
|
|
577
577
|
continue;
|
|
@@ -589,7 +589,7 @@ const ae = "link", Be = "small", bt = 150, kt = /* @__PURE__ */ G({
|
|
|
589
589
|
q.value = T.value;
|
|
590
590
|
return;
|
|
591
591
|
}
|
|
592
|
-
q.value =
|
|
592
|
+
q.value = Ie();
|
|
593
593
|
}, L = Ce(() => {
|
|
594
594
|
Z();
|
|
595
595
|
}, bt), U = (t = !1) => {
|
|
@@ -599,17 +599,17 @@ const ae = "link", Be = "small", bt = 150, kt = /* @__PURE__ */ G({
|
|
|
599
599
|
typeof L == "function" && "cancel" in L && L.cancel();
|
|
600
600
|
};
|
|
601
601
|
let j = null;
|
|
602
|
-
const
|
|
602
|
+
const Me = async () => {
|
|
603
603
|
await H(), Z(), d.value && typeof ResizeObserver < "u" && (j = new ResizeObserver((t) => {
|
|
604
604
|
t[0].contentRect.width > 0 && U();
|
|
605
605
|
}), j.observe(d.value));
|
|
606
|
-
},
|
|
606
|
+
}, De = () => {
|
|
607
607
|
j && d.value && j.unobserve(d.value), j = null, "cancel" in U && U.cancel();
|
|
608
608
|
};
|
|
609
609
|
qe(async () => {
|
|
610
|
-
Z(), await H(),
|
|
610
|
+
Z(), await H(), Me();
|
|
611
611
|
}), Ze(() => {
|
|
612
|
-
|
|
612
|
+
De();
|
|
613
613
|
}), ee(
|
|
614
614
|
[ne, T, () => n.maxItems, () => n.gap],
|
|
615
615
|
async () => {
|
|
@@ -633,7 +633,7 @@ const ae = "link", Be = "small", bt = 150, kt = /* @__PURE__ */ G({
|
|
|
633
633
|
permissionAction: k,
|
|
634
634
|
icon: C,
|
|
635
635
|
component: S,
|
|
636
|
-
componentProps:
|
|
636
|
+
componentProps: D,
|
|
637
637
|
slot: N,
|
|
638
638
|
type: J,
|
|
639
639
|
size: V,
|
|
@@ -642,7 +642,7 @@ const ae = "link", Be = "small", bt = 150, kt = /* @__PURE__ */ G({
|
|
|
642
642
|
} = t;
|
|
643
643
|
return {
|
|
644
644
|
component: S,
|
|
645
|
-
componentProps:
|
|
645
|
+
componentProps: D,
|
|
646
646
|
type: J,
|
|
647
647
|
size: V,
|
|
648
648
|
rest: Ge,
|
|
@@ -652,27 +652,27 @@ const ae = "link", Be = "small", bt = 150, kt = /* @__PURE__ */ G({
|
|
|
652
652
|
};
|
|
653
653
|
}
|
|
654
654
|
function Ne(t) {
|
|
655
|
-
const { component: c, componentProps: a, type: g, rest: z, permission: k, permissionAction: C, disabled: S } = me(t),
|
|
655
|
+
const { component: c, componentProps: a, type: g, rest: z, permission: k, permissionAction: C, disabled: S } = me(t), D = {
|
|
656
656
|
type: g || i.value,
|
|
657
657
|
size: E.value,
|
|
658
|
-
disabled: S || !
|
|
658
|
+
disabled: S || !_(k) && C === "disable",
|
|
659
659
|
...z
|
|
660
660
|
};
|
|
661
661
|
if (c && a) {
|
|
662
|
-
const N = { ...
|
|
662
|
+
const N = { ...D, ...a };
|
|
663
663
|
return b.value && (N.type = "link"), N;
|
|
664
664
|
}
|
|
665
|
-
return
|
|
665
|
+
return D;
|
|
666
666
|
}
|
|
667
667
|
function Re(t) {
|
|
668
668
|
const { component: c, componentProps: a, rest: g, permission: z, permissionAction: k, disabled: C } = me(t), S = {
|
|
669
669
|
type: ae,
|
|
670
670
|
size: Be,
|
|
671
|
-
disabled: C || !
|
|
671
|
+
disabled: C || !_(z) && k === "disable",
|
|
672
672
|
...g
|
|
673
673
|
};
|
|
674
674
|
if (c && a) {
|
|
675
|
-
const { type:
|
|
675
|
+
const { type: D, size: N, ...J } = a, V = { ...S, ...J };
|
|
676
676
|
return V.type = ae, V;
|
|
677
677
|
}
|
|
678
678
|
return S;
|
|
@@ -680,14 +680,14 @@ const ae = "link", Be = "small", bt = 150, kt = /* @__PURE__ */ G({
|
|
|
680
680
|
function Ve(t) {
|
|
681
681
|
t.onClick && t.onClick(t), o("action-click", t);
|
|
682
682
|
}
|
|
683
|
-
return (t, c) => (s(),
|
|
683
|
+
return (t, c) => (s(), I("div", {
|
|
684
684
|
ref_key: "containerRef",
|
|
685
685
|
ref: d,
|
|
686
686
|
class: "mtn-action-group"
|
|
687
687
|
}, [
|
|
688
|
-
B(P(Ae), ve(Je(
|
|
688
|
+
B(P(Ae), ve(Je(_e.value)), {
|
|
689
689
|
default: m(() => [
|
|
690
|
-
n.actions ? (s(!0),
|
|
690
|
+
n.actions ? (s(!0), I(R, { key: 0 }, $(fe.value, (a) => (s(), h(A(a.component), x({
|
|
691
691
|
key: a.key,
|
|
692
692
|
ref_for: !0
|
|
693
693
|
}, a.props, {
|
|
@@ -705,17 +705,17 @@ const ae = "link", Be = "small", bt = 150, kt = /* @__PURE__ */ G({
|
|
|
705
705
|
]),
|
|
706
706
|
key: "0"
|
|
707
707
|
} : void 0
|
|
708
|
-
]), 1040, ["onClick"]))), 128)) : (s(!0),
|
|
708
|
+
]), 1040, ["onClick"]))), 128)) : (s(!0), I(R, { key: 1 }, $(fe.value, (a) => (s(), h(A(a.vnode), {
|
|
709
709
|
key: a.key
|
|
710
710
|
}))), 128)),
|
|
711
|
-
Ee.value ? (s(), h(P(ie), ve(x({ key: 2 },
|
|
711
|
+
Ee.value ? (s(), h(P(ie), ve(x({ key: 2 }, we.value)), {
|
|
712
712
|
icon: m(() => [
|
|
713
|
-
(s(), h(A(
|
|
713
|
+
(s(), h(A(w.value)))
|
|
714
714
|
]),
|
|
715
715
|
overlay: m(() => [
|
|
716
716
|
B(P(Q), null, {
|
|
717
717
|
default: m(() => [
|
|
718
|
-
n.actions ? (s(!0),
|
|
718
|
+
n.actions ? (s(!0), I(R, { key: 0 }, $(oe.value, (a) => (s(), h(P(Q).Item, {
|
|
719
719
|
key: a.key
|
|
720
720
|
}, {
|
|
721
721
|
default: m(() => [
|
|
@@ -737,7 +737,7 @@ const ae = "link", Be = "small", bt = 150, kt = /* @__PURE__ */ G({
|
|
|
737
737
|
]), 1040, ["onClick"]))
|
|
738
738
|
]),
|
|
739
739
|
_: 2
|
|
740
|
-
}, 1024))), 128)) : (s(!0),
|
|
740
|
+
}, 1024))), 128)) : (s(!0), I(R, { key: 1 }, $(oe.value, (a) => (s(), h(P(Q).Item, {
|
|
741
741
|
key: a.key
|
|
742
742
|
}, {
|
|
743
743
|
default: m(() => [
|
|
@@ -760,7 +760,7 @@ const ae = "link", Be = "small", bt = 150, kt = /* @__PURE__ */ G({
|
|
|
760
760
|
class: "mtn-action-group-measure",
|
|
761
761
|
style: et({ gap: `${n.gap}px` })
|
|
762
762
|
}, [
|
|
763
|
-
n.actions ? (s(!0),
|
|
763
|
+
n.actions ? (s(!0), I(R, { key: 0 }, $(X.value, (a, g) => (s(), I("span", {
|
|
764
764
|
key: g,
|
|
765
765
|
class: "measure-item"
|
|
766
766
|
}, [
|
|
@@ -778,7 +778,7 @@ const ae = "link", Be = "small", bt = 150, kt = /* @__PURE__ */ G({
|
|
|
778
778
|
key: "0"
|
|
779
779
|
} : void 0
|
|
780
780
|
]), 1040))
|
|
781
|
-
]))), 128)) : (s(!0),
|
|
781
|
+
]))), 128)) : (s(!0), I(R, { key: 1 }, $(X.value, (a, g) => (s(), I("span", {
|
|
782
782
|
key: g,
|
|
783
783
|
class: "measure-item"
|
|
784
784
|
}, [
|
|
@@ -795,7 +795,7 @@ const ae = "link", Be = "small", bt = 150, kt = /* @__PURE__ */ G({
|
|
|
795
795
|
type: i.value
|
|
796
796
|
}, {
|
|
797
797
|
icon: m(() => [
|
|
798
|
-
(s(), h(A(
|
|
798
|
+
(s(), h(A(w.value)))
|
|
799
799
|
]),
|
|
800
800
|
_: 1
|
|
801
801
|
}, 8, ["text", "size", "type"])
|
|
@@ -893,7 +893,7 @@ const ae = "link", Be = "small", bt = 150, kt = /* @__PURE__ */ G({
|
|
|
893
893
|
props: St,
|
|
894
894
|
emits: ["delete", "success", "error"],
|
|
895
895
|
setup(e, { emit: r }) {
|
|
896
|
-
const n = r, o = e, l =
|
|
896
|
+
const n = r, o = e, l = M(!1), y = M(null), d = p(() => o.loading !== void 0 ? o.loading : o.autoLoading ? l.value : !1), f = p(() => typeof o.confirm == "function" ? o.confirm(o.count) : o.confirm);
|
|
897
897
|
ee(d, (i) => {
|
|
898
898
|
y.value && H(() => {
|
|
899
899
|
var u;
|
|
@@ -914,13 +914,13 @@ const ae = "link", Be = "small", bt = 150, kt = /* @__PURE__ */ G({
|
|
|
914
914
|
i || (i = !0, o.autoLoading && o.loading === void 0 && (l.value = !1));
|
|
915
915
|
};
|
|
916
916
|
if (o.onDelete) {
|
|
917
|
-
const
|
|
918
|
-
if (
|
|
917
|
+
const w = o.onDelete(u);
|
|
918
|
+
if (w && typeof w.then == "function")
|
|
919
919
|
try {
|
|
920
|
-
const
|
|
921
|
-
i || u(), Y(
|
|
922
|
-
} catch (
|
|
923
|
-
throw i || u(),
|
|
920
|
+
const _ = await w;
|
|
921
|
+
i || u(), Y(_);
|
|
922
|
+
} catch (_) {
|
|
923
|
+
throw i || u(), _;
|
|
924
924
|
}
|
|
925
925
|
} else
|
|
926
926
|
n("delete", u), o.autoLoading && o.loading === void 0 && setTimeout(() => {
|
|
@@ -954,8 +954,8 @@ const ae = "link", Be = "small", bt = 150, kt = /* @__PURE__ */ G({
|
|
|
954
954
|
u();
|
|
955
955
|
return;
|
|
956
956
|
}
|
|
957
|
-
const
|
|
958
|
-
|
|
957
|
+
const w = ee(d, (_) => {
|
|
958
|
+
_ || (w(), u());
|
|
959
959
|
});
|
|
960
960
|
});
|
|
961
961
|
} catch (u) {
|
|
@@ -1044,10 +1044,14 @@ const ae = "link", Be = "small", bt = 150, kt = /* @__PURE__ */ G({
|
|
|
1044
1044
|
}
|
|
1045
1045
|
}), zt = /* @__PURE__ */ xe(Bt, [["__scopeId", "data-v-a943bc19"]]);
|
|
1046
1046
|
var Ct = /* @__PURE__ */ ((e) => (e.TEXT = "text", e.TAG = "tag", e.DATE = "date", e.DATETIME = "dateTime", e.SELECT = "select", e.STATUS = "status", e.CUSTOM = "custom", e))(Ct || {}), Pt = /* @__PURE__ */ ((e) => (e.LEFT = "left", e.CENTER = "center", e.RIGHT = "right", e))(Pt || {}), Tt = /* @__PURE__ */ ((e) => (e.SMALL = "small", e.MIDDLE = "middle", e.LARGE = "large", e))(Tt || {}), At = /* @__PURE__ */ ((e) => (e.CHECKBOX = "checkbox", e.RADIO = "radio", e))(At || {}), xt = /* @__PURE__ */ ((e) => (e.LEFT = "left", e.RIGHT = "right", e))(xt || {});
|
|
1047
|
-
const
|
|
1047
|
+
const _t = [te, Ae, ie, ht, zt, dt, at], Lt = {
|
|
1048
1048
|
install(e) {
|
|
1049
|
-
|
|
1050
|
-
|
|
1049
|
+
_t.forEach((r) => {
|
|
1050
|
+
const n = r.name || r.__name;
|
|
1051
|
+
if (n) {
|
|
1052
|
+
const o = e._context.components;
|
|
1053
|
+
(!o || !o[n]) && e.component(n, r);
|
|
1054
|
+
}
|
|
1051
1055
|
});
|
|
1052
1056
|
}
|
|
1053
1057
|
};
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { ActionItem } from './types';
|
|
2
|
+
declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
3
|
+
actions: {
|
|
4
|
+
type: import('vue').PropType<ActionItem[]>;
|
|
5
|
+
default: undefined;
|
|
6
|
+
};
|
|
7
|
+
mode: {
|
|
8
|
+
type: import('vue').PropType<import('./types').ActionGroupMode>;
|
|
9
|
+
default: string;
|
|
10
|
+
};
|
|
11
|
+
maxItems: {
|
|
12
|
+
type: NumberConstructor;
|
|
13
|
+
default: number;
|
|
14
|
+
};
|
|
15
|
+
gap: {
|
|
16
|
+
type: NumberConstructor;
|
|
17
|
+
default: number;
|
|
18
|
+
};
|
|
19
|
+
moreText: {
|
|
20
|
+
type: StringConstructor;
|
|
21
|
+
default: string;
|
|
22
|
+
};
|
|
23
|
+
moreIcon: {
|
|
24
|
+
type: ObjectConstructor;
|
|
25
|
+
default: undefined;
|
|
26
|
+
};
|
|
27
|
+
moreProps: {
|
|
28
|
+
type: import('vue').PropType<Partial<import('..').DropdownButtonProps>>;
|
|
29
|
+
default: () => {};
|
|
30
|
+
};
|
|
31
|
+
size: {
|
|
32
|
+
type: import('vue').PropType<import('..').ButtonSize>;
|
|
33
|
+
default: string;
|
|
34
|
+
};
|
|
35
|
+
compact: {
|
|
36
|
+
type: BooleanConstructor;
|
|
37
|
+
default: boolean;
|
|
38
|
+
};
|
|
39
|
+
vertical: {
|
|
40
|
+
type: BooleanConstructor;
|
|
41
|
+
default: boolean;
|
|
42
|
+
};
|
|
43
|
+
block: {
|
|
44
|
+
type: BooleanConstructor;
|
|
45
|
+
default: boolean;
|
|
46
|
+
};
|
|
47
|
+
disableCollapse: {
|
|
48
|
+
type: BooleanConstructor;
|
|
49
|
+
default: boolean;
|
|
50
|
+
};
|
|
51
|
+
}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {} & {
|
|
52
|
+
"action-click": (action: ActionItem) => any;
|
|
53
|
+
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
54
|
+
actions: {
|
|
55
|
+
type: import('vue').PropType<ActionItem[]>;
|
|
56
|
+
default: undefined;
|
|
57
|
+
};
|
|
58
|
+
mode: {
|
|
59
|
+
type: import('vue').PropType<import('./types').ActionGroupMode>;
|
|
60
|
+
default: string;
|
|
61
|
+
};
|
|
62
|
+
maxItems: {
|
|
63
|
+
type: NumberConstructor;
|
|
64
|
+
default: number;
|
|
65
|
+
};
|
|
66
|
+
gap: {
|
|
67
|
+
type: NumberConstructor;
|
|
68
|
+
default: number;
|
|
69
|
+
};
|
|
70
|
+
moreText: {
|
|
71
|
+
type: StringConstructor;
|
|
72
|
+
default: string;
|
|
73
|
+
};
|
|
74
|
+
moreIcon: {
|
|
75
|
+
type: ObjectConstructor;
|
|
76
|
+
default: undefined;
|
|
77
|
+
};
|
|
78
|
+
moreProps: {
|
|
79
|
+
type: import('vue').PropType<Partial<import('..').DropdownButtonProps>>;
|
|
80
|
+
default: () => {};
|
|
81
|
+
};
|
|
82
|
+
size: {
|
|
83
|
+
type: import('vue').PropType<import('..').ButtonSize>;
|
|
84
|
+
default: string;
|
|
85
|
+
};
|
|
86
|
+
compact: {
|
|
87
|
+
type: BooleanConstructor;
|
|
88
|
+
default: boolean;
|
|
89
|
+
};
|
|
90
|
+
vertical: {
|
|
91
|
+
type: BooleanConstructor;
|
|
92
|
+
default: boolean;
|
|
93
|
+
};
|
|
94
|
+
block: {
|
|
95
|
+
type: BooleanConstructor;
|
|
96
|
+
default: boolean;
|
|
97
|
+
};
|
|
98
|
+
disableCollapse: {
|
|
99
|
+
type: BooleanConstructor;
|
|
100
|
+
default: boolean;
|
|
101
|
+
};
|
|
102
|
+
}>> & Readonly<{
|
|
103
|
+
"onAction-click"?: ((action: ActionItem) => any) | undefined;
|
|
104
|
+
}>, {
|
|
105
|
+
size: import('..').ButtonSize;
|
|
106
|
+
block: boolean;
|
|
107
|
+
compact: boolean;
|
|
108
|
+
gap: number;
|
|
109
|
+
vertical: boolean;
|
|
110
|
+
mode: import('./types').ActionGroupMode;
|
|
111
|
+
actions: ActionItem[];
|
|
112
|
+
maxItems: number;
|
|
113
|
+
moreText: string;
|
|
114
|
+
moreIcon: Record<string, any>;
|
|
115
|
+
moreProps: Partial<import('..').DropdownButtonProps>;
|
|
116
|
+
disableCollapse: boolean;
|
|
117
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {
|
|
118
|
+
containerRef: HTMLDivElement;
|
|
119
|
+
measureRef: HTMLDivElement;
|
|
120
|
+
moreTriggerRef: HTMLSpanElement;
|
|
121
|
+
}, any>;
|
|
122
|
+
export default _default;
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
declare function __VLS_template(): {
|
|
2
|
+
attrs: Partial<{}>;
|
|
3
|
+
slots: {
|
|
4
|
+
popconfirmIcon?(_: {}): any;
|
|
5
|
+
icon?(_: {}): any;
|
|
6
|
+
icon?(_: {}): any;
|
|
7
|
+
default?(_: {}): any;
|
|
8
|
+
default?(_: {}): any;
|
|
9
|
+
};
|
|
10
|
+
refs: {};
|
|
11
|
+
rootEl: any;
|
|
12
|
+
};
|
|
13
|
+
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
14
|
+
declare const __VLS_component: import('vue').DefineComponent<import('vue').ExtractPropTypes<{
|
|
15
|
+
loading: {
|
|
16
|
+
type: BooleanConstructor;
|
|
17
|
+
default: undefined;
|
|
18
|
+
};
|
|
19
|
+
confirm: {
|
|
20
|
+
type: import('vue').PropType<string | false | ((count?: number) => string)>;
|
|
21
|
+
default: string;
|
|
22
|
+
};
|
|
23
|
+
confirmType: {
|
|
24
|
+
type: import('vue').PropType<"modal" | "popconfirm">;
|
|
25
|
+
default: string;
|
|
26
|
+
};
|
|
27
|
+
confirmTitle: {
|
|
28
|
+
type: StringConstructor;
|
|
29
|
+
default: string;
|
|
30
|
+
};
|
|
31
|
+
okText: {
|
|
32
|
+
type: StringConstructor;
|
|
33
|
+
default: string;
|
|
34
|
+
};
|
|
35
|
+
cancelText: {
|
|
36
|
+
type: StringConstructor;
|
|
37
|
+
default: string;
|
|
38
|
+
};
|
|
39
|
+
hideIcon: {
|
|
40
|
+
type: BooleanConstructor;
|
|
41
|
+
default: boolean;
|
|
42
|
+
};
|
|
43
|
+
autoLoading: {
|
|
44
|
+
type: BooleanConstructor;
|
|
45
|
+
default: boolean;
|
|
46
|
+
};
|
|
47
|
+
beforeDelete: {
|
|
48
|
+
type: import('vue').PropType<() => boolean | Promise<boolean>>;
|
|
49
|
+
default: undefined;
|
|
50
|
+
};
|
|
51
|
+
count: {
|
|
52
|
+
type: NumberConstructor;
|
|
53
|
+
default: number;
|
|
54
|
+
};
|
|
55
|
+
showSuccess: {
|
|
56
|
+
type: BooleanConstructor;
|
|
57
|
+
default: boolean;
|
|
58
|
+
};
|
|
59
|
+
successText: {
|
|
60
|
+
type: StringConstructor;
|
|
61
|
+
default: string;
|
|
62
|
+
};
|
|
63
|
+
showError: {
|
|
64
|
+
type: BooleanConstructor;
|
|
65
|
+
default: boolean;
|
|
66
|
+
};
|
|
67
|
+
debounce: {
|
|
68
|
+
type: NumberConstructor;
|
|
69
|
+
default: number;
|
|
70
|
+
};
|
|
71
|
+
onDelete: {
|
|
72
|
+
type: import('vue').PropType<(done: () => void) => void | Promise<void>>;
|
|
73
|
+
default: undefined;
|
|
74
|
+
};
|
|
75
|
+
type: {
|
|
76
|
+
type: import('vue').PropType<"primary" | "default" | "dashed" | "text" | "link">;
|
|
77
|
+
default: string;
|
|
78
|
+
};
|
|
79
|
+
size: {
|
|
80
|
+
type: import('vue').PropType<"small" | "middle" | "large">;
|
|
81
|
+
default: string;
|
|
82
|
+
};
|
|
83
|
+
disabled: {
|
|
84
|
+
type: BooleanConstructor;
|
|
85
|
+
default: boolean;
|
|
86
|
+
};
|
|
87
|
+
danger: {
|
|
88
|
+
type: BooleanConstructor;
|
|
89
|
+
default: boolean;
|
|
90
|
+
};
|
|
91
|
+
block: {
|
|
92
|
+
type: BooleanConstructor;
|
|
93
|
+
default: boolean;
|
|
94
|
+
};
|
|
95
|
+
ghost: {
|
|
96
|
+
type: BooleanConstructor;
|
|
97
|
+
default: boolean;
|
|
98
|
+
};
|
|
99
|
+
shape: {
|
|
100
|
+
type: import('vue').PropType<"default" | "circle" | "round">;
|
|
101
|
+
default: string;
|
|
102
|
+
};
|
|
103
|
+
htmlType: {
|
|
104
|
+
type: import('vue').PropType<"button" | "submit" | "reset">;
|
|
105
|
+
default: string;
|
|
106
|
+
};
|
|
107
|
+
icon: {
|
|
108
|
+
type: import('vue').PropType<any>;
|
|
109
|
+
};
|
|
110
|
+
permission: {
|
|
111
|
+
type: import('vue').PropType<string | string[]>;
|
|
112
|
+
default: undefined;
|
|
113
|
+
};
|
|
114
|
+
permissionAction: {
|
|
115
|
+
type: import('vue').PropType<"hide" | "disable">;
|
|
116
|
+
default: string;
|
|
117
|
+
};
|
|
118
|
+
}>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
119
|
+
success: (result?: any) => any;
|
|
120
|
+
error: (error: Error) => any;
|
|
121
|
+
delete: (done: () => void) => any;
|
|
122
|
+
}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<{
|
|
123
|
+
loading: {
|
|
124
|
+
type: BooleanConstructor;
|
|
125
|
+
default: undefined;
|
|
126
|
+
};
|
|
127
|
+
confirm: {
|
|
128
|
+
type: import('vue').PropType<string | false | ((count?: number) => string)>;
|
|
129
|
+
default: string;
|
|
130
|
+
};
|
|
131
|
+
confirmType: {
|
|
132
|
+
type: import('vue').PropType<"modal" | "popconfirm">;
|
|
133
|
+
default: string;
|
|
134
|
+
};
|
|
135
|
+
confirmTitle: {
|
|
136
|
+
type: StringConstructor;
|
|
137
|
+
default: string;
|
|
138
|
+
};
|
|
139
|
+
okText: {
|
|
140
|
+
type: StringConstructor;
|
|
141
|
+
default: string;
|
|
142
|
+
};
|
|
143
|
+
cancelText: {
|
|
144
|
+
type: StringConstructor;
|
|
145
|
+
default: string;
|
|
146
|
+
};
|
|
147
|
+
hideIcon: {
|
|
148
|
+
type: BooleanConstructor;
|
|
149
|
+
default: boolean;
|
|
150
|
+
};
|
|
151
|
+
autoLoading: {
|
|
152
|
+
type: BooleanConstructor;
|
|
153
|
+
default: boolean;
|
|
154
|
+
};
|
|
155
|
+
beforeDelete: {
|
|
156
|
+
type: import('vue').PropType<() => boolean | Promise<boolean>>;
|
|
157
|
+
default: undefined;
|
|
158
|
+
};
|
|
159
|
+
count: {
|
|
160
|
+
type: NumberConstructor;
|
|
161
|
+
default: number;
|
|
162
|
+
};
|
|
163
|
+
showSuccess: {
|
|
164
|
+
type: BooleanConstructor;
|
|
165
|
+
default: boolean;
|
|
166
|
+
};
|
|
167
|
+
successText: {
|
|
168
|
+
type: StringConstructor;
|
|
169
|
+
default: string;
|
|
170
|
+
};
|
|
171
|
+
showError: {
|
|
172
|
+
type: BooleanConstructor;
|
|
173
|
+
default: boolean;
|
|
174
|
+
};
|
|
175
|
+
debounce: {
|
|
176
|
+
type: NumberConstructor;
|
|
177
|
+
default: number;
|
|
178
|
+
};
|
|
179
|
+
onDelete: {
|
|
180
|
+
type: import('vue').PropType<(done: () => void) => void | Promise<void>>;
|
|
181
|
+
default: undefined;
|
|
182
|
+
};
|
|
183
|
+
type: {
|
|
184
|
+
type: import('vue').PropType<"primary" | "default" | "dashed" | "text" | "link">;
|
|
185
|
+
default: string;
|
|
186
|
+
};
|
|
187
|
+
size: {
|
|
188
|
+
type: import('vue').PropType<"small" | "middle" | "large">;
|
|
189
|
+
default: string;
|
|
190
|
+
};
|
|
191
|
+
disabled: {
|
|
192
|
+
type: BooleanConstructor;
|
|
193
|
+
default: boolean;
|
|
194
|
+
};
|
|
195
|
+
danger: {
|
|
196
|
+
type: BooleanConstructor;
|
|
197
|
+
default: boolean;
|
|
198
|
+
};
|
|
199
|
+
block: {
|
|
200
|
+
type: BooleanConstructor;
|
|
201
|
+
default: boolean;
|
|
202
|
+
};
|
|
203
|
+
ghost: {
|
|
204
|
+
type: BooleanConstructor;
|
|
205
|
+
default: boolean;
|
|
206
|
+
};
|
|
207
|
+
shape: {
|
|
208
|
+
type: import('vue').PropType<"default" | "circle" | "round">;
|
|
209
|
+
default: string;
|
|
210
|
+
};
|
|
211
|
+
htmlType: {
|
|
212
|
+
type: import('vue').PropType<"button" | "submit" | "reset">;
|
|
213
|
+
default: string;
|
|
214
|
+
};
|
|
215
|
+
icon: {
|
|
216
|
+
type: import('vue').PropType<any>;
|
|
217
|
+
};
|
|
218
|
+
permission: {
|
|
219
|
+
type: import('vue').PropType<string | string[]>;
|
|
220
|
+
default: undefined;
|
|
221
|
+
};
|
|
222
|
+
permissionAction: {
|
|
223
|
+
type: import('vue').PropType<"hide" | "disable">;
|
|
224
|
+
default: string;
|
|
225
|
+
};
|
|
226
|
+
}>> & Readonly<{
|
|
227
|
+
onSuccess?: ((result?: any) => any) | undefined;
|
|
228
|
+
onError?: ((error: Error) => any) | undefined;
|
|
229
|
+
onDelete?: ((done: () => void) => any) | undefined;
|
|
230
|
+
}>, {
|
|
231
|
+
type: "default" | "link" | "text" | "primary" | "dashed";
|
|
232
|
+
size: "small" | "middle" | "large";
|
|
233
|
+
loading: boolean;
|
|
234
|
+
disabled: boolean;
|
|
235
|
+
danger: boolean;
|
|
236
|
+
block: boolean;
|
|
237
|
+
ghost: boolean;
|
|
238
|
+
shape: "default" | "circle" | "round";
|
|
239
|
+
htmlType: "button" | "submit" | "reset";
|
|
240
|
+
permission: string | string[];
|
|
241
|
+
permissionAction: "hide" | "disable";
|
|
242
|
+
confirm: string | false | ((count?: number) => string);
|
|
243
|
+
showSuccess: boolean;
|
|
244
|
+
confirmType: "modal" | "popconfirm";
|
|
245
|
+
confirmTitle: string;
|
|
246
|
+
okText: string;
|
|
247
|
+
cancelText: string;
|
|
248
|
+
hideIcon: boolean;
|
|
249
|
+
autoLoading: boolean;
|
|
250
|
+
beforeDelete: () => boolean | Promise<boolean>;
|
|
251
|
+
count: number;
|
|
252
|
+
successText: string;
|
|
253
|
+
showError: boolean;
|
|
254
|
+
debounce: number;
|
|
255
|
+
onDelete: (done: () => void) => void | Promise<void>;
|
|
256
|
+
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
257
|
+
declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, __VLS_TemplateResult["slots"]>;
|
|
258
|
+
export default _default;
|
|
259
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
260
|
+
new (): {
|
|
261
|
+
$slots: S;
|
|
262
|
+
};
|
|
263
|
+
};
|
package/package.json
CHANGED
|
@@ -1,53 +1,53 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
2
|
+
"name": "@mtn-ui/components",
|
|
3
|
+
"version": "1.0.11",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Core components for mtn-ui",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.mjs",
|
|
8
|
+
"types": "./dist/types/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/types/index.d.ts",
|
|
12
|
+
"import": "./dist/index.mjs",
|
|
13
|
+
"require": "./dist/index.cjs",
|
|
14
|
+
"default": "./dist/index.mjs"
|
|
15
|
+
},
|
|
16
|
+
"./style": "./dist/components.css"
|
|
15
17
|
},
|
|
16
|
-
"
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
"
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
}
|
|
18
|
+
"publishConfig": {
|
|
19
|
+
"access": "public"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "vite build && node scripts/fix-types.js",
|
|
26
|
+
"dev": "vite build --watch",
|
|
27
|
+
"test": "vitest run",
|
|
28
|
+
"test:watch": "vitest"
|
|
29
|
+
},
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@ant-design/icons-vue": "^7.0.1",
|
|
32
|
+
"@mtn-ui/shared": "^1.0.0",
|
|
33
|
+
"@mtn-ui/theme": "^1.0.0",
|
|
34
|
+
"@vueuse/core": "^14.1.0",
|
|
35
|
+
"ant-design-vue": "^4.2.6",
|
|
36
|
+
"class-variance-authority": "latest",
|
|
37
|
+
"radix-vue": "latest"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@tailwindcss/vite": "^4.0.0",
|
|
41
|
+
"@vitejs/plugin-vue": "^5.2.1",
|
|
42
|
+
"@vitejs/plugin-vue-jsx": "^4.1.1",
|
|
43
|
+
"@vue/test-utils": "^2.4.6",
|
|
44
|
+
"jsdom": "^24.1.0",
|
|
45
|
+
"vite": "^6.0.0",
|
|
46
|
+
"vite-plugin-dts": "^4.0.0",
|
|
47
|
+
"vitest": "^3.0.0",
|
|
48
|
+
"vue": "^3.5.0"
|
|
49
|
+
},
|
|
50
|
+
"peerDependencies": {
|
|
51
|
+
"vue": "^3.5.0"
|
|
52
|
+
}
|
|
53
|
+
}
|