2 lines
7.9 KiB
JavaScript
2 lines
7.9 KiB
JavaScript
var pe=Object.defineProperty,ve=Object.defineProperties;var ye=Object.getOwnPropertyDescriptors;var le=Object.getOwnPropertySymbols;var me=Object.prototype.hasOwnProperty,be=Object.prototype.propertyIsEnumerable;var oe=(t,e,n)=>e in t?pe(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,w=(t,e)=>{for(var n in e||(e={}))me.call(e,n)&&oe(t,n,e[n]);if(le)for(var n of le(e))be.call(e,n)&&oe(t,n,e[n]);return t},W=(t,e)=>ve(t,ye(e));import{p as a,V as M,Z as Se,r as N,F as Ce,dH as ge,g1 as xe,g2 as he,_ as P,ai as z,a as Z,a3 as we,bp as Pe,au as ae,Q as ue,af as $e,$ as _e,bD as re,f as k,av as se,aI as De,cl as je,as as Oe,b as Ie,dT as Ee,k as p,aB as ke,dc as Le,g3 as Me,cB as Ne,az as H,bc as Re,ax as Be,de as Ae,L as ze}from"./index.6ea620a9.js";import{g as Fe}from"./get.05fd2a5a.js";function A(t){return t!=null}var Te=function(e){var n=e.itemPrefixCls,l=e.component,r=e.span,o=e.labelStyle,c=e.contentStyle,y=e.bordered,i=e.label,d=e.content,u=e.colon,$=l;if(y){var x;return a($,{class:[(x={},M(x,"".concat(n,"-item-label"),A(i)),M(x,"".concat(n,"-item-content"),A(d)),x)],colSpan:r},{default:function(){return[A(i)&&a("span",{style:o},[i]),A(d)&&a("span",{style:c},[d])]}})}return a($,{class:["".concat(n,"-item")],colSpan:r},{default:function(){return[a("div",{class:"".concat(n,"-item-container")},[i&&a("span",{class:["".concat(n,"-item-label"),M({},"".concat(n,"-item-no-colon"),!u)],style:o},[i]),d&&a("span",{class:"".concat(n,"-item-content"),style:c},[d])])]}})},Q=Te,Ue=function(e){var n=function(x,m,b){var E=m.colon,R=m.prefixCls,s=m.bordered,S=b.component,v=b.type,h=b.showLabel,D=b.showContent,j=b.labelStyle,_=b.contentStyle;return x.map(function(C,O){var I,g,f=C.props||{},B=f.prefixCls,F=B===void 0?R:B,q=f.span,G=q===void 0?1:q,J=f.labelStyle,K=J===void 0?f["label-style"]:J,X=f.contentStyle,Y=X===void 0?f["content-style"]:X,ee=f.label,te=ee===void 0?(I=C.children)===null||I===void 0||(g=I.label)===null||g===void 0?void 0:g.call(I):ee,ne=ge(C),T=xe(C),U=he(C),V=C.key;return typeof S=="string"?a(Q,{key:"".concat(v,"-").concat(String(V)||O),class:T,style:U,labelStyle:P(P({},j),K),contentStyle:P(P({},_),Y),span:G,colon:E,component:S,itemPrefixCls:F,bordered:s,label:h?te:null,content:D?ne:null},null):[a(Q,{key:"label-".concat(String(V)||O),class:T,style:P(P(P({},j),U),K),span:1,colon:E,component:S[0],itemPrefixCls:F,bordered:s,label:te},null),a(Q,{key:"content-".concat(String(V)||O),class:T,style:P(P(P({},_),U),Y),span:G*2-1,component:S[1],itemPrefixCls:F,bordered:s,content:ne},null)]})},l=e.prefixCls,r=e.vertical,o=e.row,c=e.index,y=e.bordered,i=Se(fe,{labelStyle:N({}),contentStyle:N({})}),d=i.labelStyle,u=i.contentStyle;return r?a(Ce,null,[a("tr",{key:"label-".concat(c),class:"".concat(l,"-row")},[n(o,e,{component:"th",type:"label",showLabel:!0,labelStyle:d.value,contentStyle:u.value})]),a("tr",{key:"content-".concat(c),class:"".concat(l,"-row")},[n(o,e,{component:"td",type:"content",showContent:!0,labelStyle:d.value,contentStyle:u.value})])]):a("tr",{key:c,class:"".concat(l,"-row")},[n(o,e,{component:y?["th","td"]:"td",type:"item",showLabel:!0,showContent:!0,labelStyle:d.value,contentStyle:u.value})])},Ve=Ue;z.any;var We=function(){return{prefixCls:String,label:z.any,labelStyle:{type:Object,default:void 0},contentStyle:{type:Object,default:void 0},span:{type:Number,default:1}}},He=Z({compatConfig:{MODE:3},name:"ADescriptionsItem",props:We(),slots:["label"],setup:function(e,n){var l=n.slots;return function(){var r;return(r=l.default)===null||r===void 0?void 0:r.call(l)}}}),de={xxxl:3,xxl:3,xl:3,lg:3,md:3,sm:2,xs:1};function Qe(t,e){if(typeof t=="number")return t;if(ue(t)==="object")for(var n=0;n<se.length;n++){var l=se[n];if(e[l]&&t[l]!==void 0)return t[l]||de[l]}return 3}function ce(t,e,n){var l=t;return(e===void 0||e>n)&&(l=je(t,{span:n}),Oe(e===void 0,"Descriptions","Sum of column `span` in a line not match `column` of Descriptions.")),l}function Ze(t,e){var n=De(t),l=[],r=[],o=e;return n.forEach(function(c,y){var i,d=(i=c.props)===null||i===void 0?void 0:i.span,u=d||1;if(y===n.length-1){r.push(ce(c,d,o)),l.push(r);return}u<o?(o-=u,r.push(c)):(r.push(ce(c,u,o)),l.push(r),o=e,r=[])}),l}var qe=function(){return{prefixCls:String,bordered:{type:Boolean,default:void 0},size:{type:String,default:"default"},title:z.any,extra:z.any,column:{type:[Number,Object],default:function(){return de}},layout:String,colon:{type:Boolean,default:void 0},labelStyle:{type:Object,default:void 0},contentStyle:{type:Object,default:void 0}}},fe=Symbol("descriptionsContext"),L=Z({compatConfig:{MODE:3},name:"ADescriptions",props:qe(),slots:["title","extra"],Item:He,setup:function(e,n){var l=n.slots,r=we("descriptions",e),o=r.prefixCls,c=r.direction,y,i=N({});Pe(function(){y=ae.subscribe(function(u){ue(e.column)==="object"&&(i.value=u)})}),$e(function(){ae.unsubscribe(y)}),_e(fe,{labelStyle:re(e,"labelStyle"),contentStyle:re(e,"contentStyle")});var d=k(function(){return Qe(e.column,i.value)});return function(){var u,$,x,m,b=e.size,E=e.bordered,R=E===void 0?!1:E,s=e.layout,S=s===void 0?"horizontal":s,v=e.colon,h=v===void 0?!0:v,D=e.title,j=D===void 0?(u=l.title)===null||u===void 0?void 0:u.call(l):D,_=e.extra,C=_===void 0?($=l.extra)===null||$===void 0?void 0:$.call(l):_,O=(x=l.default)===null||x===void 0?void 0:x.call(l),I=Ze(O,d.value);return a("div",{class:[o.value,(m={},M(m,"".concat(o.value,"-").concat(b),b!=="default"),M(m,"".concat(o.value,"-bordered"),!!R),M(m,"".concat(o.value,"-rtl"),c.value==="rtl"),m)]},[(j||C)&&a("div",{class:"".concat(o.value,"-header")},[j&&a("div",{class:"".concat(o.value,"-title")},[j]),C&&a("div",{class:"".concat(o.value,"-extra")},[C])]),a("div",{class:"".concat(o.value,"-view")},[a("table",null,[a("tbody",null,[I.map(function(g,f){return a(Ve,{key:f,index:f,colon:h,prefixCls:o.value,vertical:S==="vertical",bordered:R,row:g},null)})])])])])}}});L.install=function(t){return t.component(L.name,L),t.component(L.Item.name,L.Item),t};var ie=L;function Ge(t){return typeof t=="function"||Object.prototype.toString.call(t)==="[object Object]"&&!Ne(t)}const Je={useCollapse:{type:Boolean,default:!0},title:{type:String,default:""},size:{type:String,validator:t=>["small","default","middle",void 0].includes(t),default:"small"},bordered:{type:Boolean,default:!0},column:{type:[Number,Object],default:()=>({xxl:4,xl:3,lg:3,md:3,sm:2,xs:1})},collapseOptions:{type:Object,default:null},schema:{type:Array,default:()=>[]},data:{type:Object}};var Ke=Z({name:"Description",props:Je,emits:["register"],setup(t,{slots:e,emit:n}){const l=N(null),{prefixCls:r}=Ie("description"),o=Ee(),c=k(()=>w(w({},t),p(l))),y=k(()=>W(w({},p(c)),{title:void 0})),i=k(()=>!!p(c).title),d=k(()=>w({canExpand:!1},p(y).collapseOptions)),u=k(()=>w(w({},p(o)),p(y)));function $(s){l.value=w(w({},p(l)),s)}function x({label:s,labelMinWidth:S,labelStyle:v}){if(!v&&!S)return s;const h=W(w({},v),{minWidth:`${S}px `});return a("div",{style:h},[s])}function m(){const{schema:s,data:S}=p(y);return p(s).map(v=>{const{render:h,field:D,span:j,show:_,contentMinWidth:C}=v;if(_&&H(_)&&!_(S))return null;const O=()=>{var B;const g=(B=p(y))==null?void 0:B.data;if(!g)return null;const f=Fe(g,D);return f&&!Re(g).hasOwnProperty(D)?H(h)?h("",g):"":H(h)?h(f,g):f!=null?f:""},I=C;return a(ie.Item,{label:x(v),key:D,span:j},{default:()=>{if(!C)return O();const g={minWidth:`${I}px`};return a("div",{style:g},[O()])}})}).filter(v=>!!v)}const b=()=>{let s;return a(ie,ke({class:`${r}`},p(u)),Ge(s=m())?s:{default:()=>[s]})},E=()=>{const s=t.useCollapse?b():a("div",null,[b()]);if(!t.useCollapse)return s;const{canExpand:S,helpMessage:v}=p(d),{title:h}=p(c);return a(Me,{title:h,canExpan:S,helpMessage:v},{default:()=>s,action:()=>Le(e,"action")})};return n("register",{setDescProps:$}),()=>p(i)?E():b()}});function tt(t){if(!Be())throw new Error("useDescription() can only be used inside setup() or functional components!");const e=N(null),n=N(!1);function l(o){p(n)&&Ae()||(e.value=o,t&&o.setDescProps(t),n.value=!0)}return[l,{setDescProps:o=>{var c;(c=p(e))==null||c.setDescProps(o)}}]}const nt=ze(Ke);export{nt as D,tt as u};
|