2 lines
4.7 KiB
JavaScript
2 lines
4.7 KiB
JavaScript
import{b as B,aS as H,d as P,R as J,am as A,a as L,K as x,I as D,a8 as Q,B as q,f as d,o as c,c as f,q as v,M as g,ad as z,e as I,s as R,bF as T,n as _,h as j,x as K,aa as M,g as X,j as Y,F as Z,ab as ee,l as te}from"./index-Cqlj7vcl.js";import{g as se,f as le}from"./vnode-CbkaLjR-.js";import{e as ae}from"./index-D88lUnba.js";const O=["left","center","right"],re=B({border:Boolean,column:{type:Number,default:3},direction:{type:String,values:["horizontal","vertical"],default:"horizontal"},size:H,title:{type:String,default:""},extra:{type:String,default:""},labelWidth:{type:[String,Number]}}),U="ElDescriptionsItem",ne=B({label:{type:String,default:""},span:{type:Number,default:1},rowspan:{type:Number,default:1},width:{type:[String,Number],default:""},minWidth:{type:[String,Number],default:""},labelWidth:{type:[String,Number]},align:{type:String,values:O,default:"left"},labelAlign:{type:String,values:O},className:{type:String,default:""},labelClassName:{type:String,default:""}}),G=P({name:U,props:ne}),V=Symbol("elDescriptions"),ie=B({row:{type:J(Array),default:()=>[]}});var E=P({name:"ElDescriptionsCell",props:{cell:{type:Object},tag:{type:String,default:"td"},type:{type:String}},setup(){return{descriptions:q(V,{})}},render(){var y;const e=se(this.cell),u=(((y=this.cell)==null?void 0:y.dirs)||[]).map(n=>{const{dir:a,arg:l,modifiers:W,value:$}=n;return[a,$,l,W]}),{border:m,direction:C}=this.descriptions,r=C==="vertical",h=()=>{var n,a,l;return((l=(a=(n=this.cell)==null?void 0:n.children)==null?void 0:a.label)==null?void 0:l.call(a))||e.label},k=()=>{var n,a,l;return(l=(a=(n=this.cell)==null?void 0:n.children)==null?void 0:a.default)==null?void 0:l.call(a)},S=e.span,s=e.rowspan,b=e.align?`is-${e.align}`:"",p=e.labelAlign?`is-${e.labelAlign}`:b,i=e.className,w=e.labelClassName,o={width:A(this.type==="label"?e.labelWidth??this.descriptions.labelWidth??e.width:e.width),minWidth:A(e.minWidth)},t=L("descriptions");switch(this.type){case"label":return x(D(this.tag,{style:o,class:[t.e("cell"),t.e("label"),t.is("bordered-label",m),t.is("vertical-label",r),p,w],colSpan:r?S:1,rowspan:r?1:s},h()),u);case"content":return x(D(this.tag,{style:o,class:[t.e("cell"),t.e("content"),t.is("bordered-content",m),t.is("vertical-content",r),b,i],colSpan:r?S:S*2-1,rowspan:r?s*2-1:s},k()),u);default:{const n=h(),a={},l=A(e.labelWidth??this.descriptions.labelWidth);return l&&(a.width=l,a.display="inline-block"),x(D("td",{style:o,class:[t.e("cell"),b],colSpan:S,rowspan:s},[Q(n)?void 0:D("span",{style:a,class:[t.e("label"),w]},n),D("span",{class:[t.e("content"),i]},k())]),u)}}}});const oe={key:1};var ce=P({name:"ElDescriptionsRow",__name:"descriptions-row",props:ie,setup(e){const u=q(V,{});return(m,C)=>d(u).direction==="vertical"?(c(),f(g,{key:0},[v("tr",null,[(c(!0),f(g,null,z(e.row,(r,h)=>(c(),I(d(E),{key:`tr1-${h}`,cell:r,tag:"th",type:"label"},null,8,["cell"]))),128))]),v("tr",null,[(c(!0),f(g,null,z(e.row,(r,h)=>(c(),I(d(E),{key:`tr2-${h}`,cell:r,tag:"td",type:"content"},null,8,["cell"]))),128))])],64)):(c(),f("tr",oe,[(c(!0),f(g,null,z(e.row,(r,h)=>(c(),f(g,{key:`tr3-${h}`},[d(u).border?(c(),f(g,{key:0},[R(d(E),{cell:r,tag:"td",type:"label"},null,8,["cell"]),R(d(E),{cell:r,tag:"td",type:"content"},null,8,["cell"])],64)):(c(),I(d(E),{key:1,cell:r,tag:"td",type:"both"},null,8,["cell"]))],64))),128))]))}}),pe=ce,de=P({name:"ElDescriptions",__name:"description",props:re,setup(e){const u=e,m=L("descriptions"),C=ae(),r=T();Z(V,u);const h=Y(()=>[m.b(),m.m(C.value)]),k=(s,b,p,i=!1)=>(s.props||(s.props={}),b>p&&(s.props.span=p),i&&(s.props.span=b),s),S=()=>{if(!r.default)return[];const s=le(r.default()).filter(t=>{var y;return((y=t==null?void 0:t.type)==null?void 0:y.name)===U}),b=[];let p=[],i=u.column,w=0;const o=[];return s.forEach((t,y)=>{var W,$,F;const n=((W=t.props)==null?void 0:W.span)||1,a=(($=t.props)==null?void 0:$.rowspan)||1,l=b.length;if(o[l]||(o[l]=0),a>1)for(let N=1;N<a;N++)o[F=l+N]||(o[F]=0),o[l+N]++,w++;if(o[l]>0&&(i-=o[l],o[l]=0),y<s.length-1&&(w+=n>i?i:n),y===s.length-1){const N=u.column-w%u.column;p.push(k(t,N,i,!0)),b.push(p);return}n<i?(i-=n,p.push(t)):(p.push(k(t,n,i)),b.push(p),i=u.column,p=[])}),b};return(s,b)=>(c(),f("div",{class:_(h.value)},[e.title||e.extra||s.$slots.title||s.$slots.extra?(c(),f("div",{key:0,class:_(d(m).e("header"))},[v("div",{class:_(d(m).e("title"))},[j(s.$slots,"title",{},()=>[K(M(e.title),1)])],2),v("div",{class:_(d(m).e("extra"))},[j(s.$slots,"extra",{},()=>[K(M(e.extra),1)])],2)],2)):X("v-if",!0),v("div",{class:_(d(m).e("body"))},[v("table",{class:_([d(m).e("table"),d(m).is("bordered",e.border)])},[v("tbody",null,[(c(!0),f(g,null,z(S(),(p,i)=>(c(),I(pe,{key:i,row:p},null,8,["row"]))),128))])],2)],2)],2))}}),ue=de;const fe=te(ue,{DescriptionsItem:G}),ye=ee(G);export{ye as E,fe as a};
|