el-descriptions-item-469f63f8.js 4.3 KB

12
  1. import{g as M,f as Q}from"./vnode-e253b113.js";import{m as N,ai as O,aF as R,t as T,P,by as k,aS as Y,j as V,k as Z,u as a,o as l,b as f,d as h,G as b,O as C,c as z,f as j,as as x,a3 as ee,ag as te,z as se,C as _,R as F,a2 as W,X as K,e as le,V as ae,al as re}from"./index-312d0758.js";import{_ as G}from"./plugin-vue_export-helper-1cff8a04.js";import{u as ne}from"./use-form-common-props-714f341f.js";const A=Symbol("elDescriptions");var E=N({name:"ElDescriptionsCell",props:{cell:{type:Object},tag:{type:String,default:"td"},type:{type:String}},setup(){return{descriptions:O(A,{})}},render(){var g,o,t,w,r,c,D;const i=M(this.cell),e=(((g=this.cell)==null?void 0:g.dirs)||[]).map(U=>{const{dir:X,arg:q,modifiers:H,value:J}=U;return[X,J,q,H]}),{border:d,direction:n}=this.descriptions,s=n==="vertical",v=((w=(t=(o=this.cell)==null?void 0:o.children)==null?void 0:t.label)==null?void 0:w.call(t))||i.label,u=(D=(c=(r=this.cell)==null?void 0:r.children)==null?void 0:c.default)==null?void 0:D.call(c),m=i.span,S=i.align?`is-${i.align}`:"",y=i.labelAlign?`is-${i.labelAlign}`:S,$=i.className,B=i.labelClassName,I={width:R(i.width),minWidth:R(i.minWidth)},p=T("descriptions");switch(this.type){case"label":return P(k(this.tag,{style:I,class:[p.e("cell"),p.e("label"),p.is("bordered-label",d),p.is("vertical-label",s),y,B],colSpan:s?m:1},v),e);case"content":return P(k(this.tag,{style:I,class:[p.e("cell"),p.e("content"),p.is("bordered-content",d),p.is("vertical-content",s),S,$],colSpan:s?m:m*2-1},u),e);default:return P(k("td",{style:I,class:[p.e("cell"),S],colSpan:m},[Y(v)?void 0:k("span",{class:[p.e("label"),B]},v),k("span",{class:[p.e("content"),$]},u)]),e)}}});const ie=V({row:{type:Z(Array),default:()=>[]}}),oe={key:1},ce=N({name:"ElDescriptionsRow"}),pe=N({...ce,props:ie,setup(g){const o=O(A,{});return(t,w)=>a(o).direction==="vertical"?(l(),f(b,{key:0},[h("tr",null,[(l(!0),f(b,null,C(t.row,(r,c)=>(l(),z(a(E),{key:`tr1-${c}`,cell:r,tag:"th",type:"label"},null,8,["cell"]))),128))]),h("tr",null,[(l(!0),f(b,null,C(t.row,(r,c)=>(l(),z(a(E),{key:`tr2-${c}`,cell:r,tag:"td",type:"content"},null,8,["cell"]))),128))])],64)):(l(),f("tr",oe,[(l(!0),f(b,null,C(t.row,(r,c)=>(l(),f(b,{key:`tr3-${c}`},[a(o).border?(l(),f(b,{key:0},[j(a(E),{cell:r,tag:"td",type:"label"},null,8,["cell"]),j(a(E),{cell:r,tag:"td",type:"content"},null,8,["cell"])],64)):(l(),z(a(E),{key:1,cell:r,tag:"td",type:"both"},null,8,["cell"]))],64))),128))]))}});var de=G(pe,[["__file","descriptions-row.vue"]]);const ue=V({border:{type:Boolean,default:!1},column:{type:Number,default:3},direction:{type:String,values:["horizontal","vertical"],default:"horizontal"},size:x,title:{type:String,default:""},extra:{type:String,default:""}}),me=N({name:"ElDescriptions"}),fe=N({...me,props:ue,setup(g){const o=g,t=T("descriptions"),w=ne(),r=ee();te(A,o);const c=se(()=>[t.b(),t.m(w.value)]),D=(e,d,n,s=!1)=>(e.props||(e.props={}),d>n&&(e.props.span=n),s&&(e.props.span=d),e),i=()=>{if(!r.default)return[];const e=Q(r.default()).filter(u=>{var m;return((m=u==null?void 0:u.type)==null?void 0:m.name)==="ElDescriptionsItem"}),d=[];let n=[],s=o.column,v=0;return e.forEach((u,m)=>{var S;const y=((S=u.props)==null?void 0:S.span)||1;if(m<e.length-1&&(v+=y>s?s:y),m===e.length-1){const $=o.column-v%o.column;n.push(D(u,$,s,!0)),d.push(n);return}y<s?(s-=y,n.push(u)):(n.push(D(u,y,s)),d.push(n),s=o.column,n=[])}),d};return(e,d)=>(l(),f("div",{class:_(a(c))},[e.title||e.extra||e.$slots.title||e.$slots.extra?(l(),f("div",{key:0,class:_(a(t).e("header"))},[h("div",{class:_(a(t).e("title"))},[F(e.$slots,"title",{},()=>[W(K(e.title),1)])],2),h("div",{class:_(a(t).e("extra"))},[F(e.$slots,"extra",{},()=>[W(K(e.extra),1)])],2)],2)):le("v-if",!0),h("div",{class:_(a(t).e("body"))},[h("table",{class:_([a(t).e("table"),a(t).is("bordered",e.border)])},[h("tbody",null,[(l(!0),f(b,null,C(i(),(n,s)=>(l(),z(de,{key:s,row:n},null,8,["row"]))),128))])],2)],2)],2))}});var ye=G(fe,[["__file","description.vue"]]);const be=V({label:{type:String,default:""},span:{type:Number,default:1},width:{type:[String,Number],default:""},minWidth:{type:[String,Number],default:""},align:{type:String,default:"left"},labelAlign:{type:String,default:""},className:{type:String,default:""},labelClassName:{type:String,default:""}}),L=N({name:"ElDescriptionsItem",props:be}),_e=ae(ye,{DescriptionsItem:L}),Ne=re(L);export{Ne as E,_e as a};