2023-11-15 15:57:04 +08:00

2 lines
4.2 KiB
JavaScript

import{g as H,f as J}from"./index-313cd2ce.js";import{e as A,b as W,_ as L,v as O}from"./index-cf9a2dd7.js";import{d as w,I as j,b as F,U as D,u as n,e as l,f as m,g,F as h,z,v as C,y as B,_ as K,R as Q,J as T,c as q,n as S,h as P,A as R,B as V,H as G,l as M,Q as X}from"./plugin-vue_export-helper-85a4d40b.js";const I="elDescriptions";var E=w({name:"ElDescriptionsCell",props:{cell:{type:Object},tag:{type:String},type:{type:String}},setup(){return{descriptions:j(I,{})}},render(){var v,o,t,N,s,d;const r=H(this.cell),{border:$,direction:e}=this.descriptions,c=e==="vertical",u=((t=(o=(v=this.cell)==null?void 0:v.children)==null?void 0:o.label)==null?void 0:t.call(o))||r.label,a=(d=(s=(N=this.cell)==null?void 0:N.children)==null?void 0:s.default)==null?void 0:d.call(s),p=r.span,_=r.align?`is-${r.align}`:"",f=r.labelAlign?`is-${r.labelAlign}`:_,b=r.className,k=r.labelClassName,y={width:A(r.width),minWidth:A(r.minWidth)},i=F("descriptions");switch(this.type){case"label":return D(this.tag,{style:y,class:[i.e("cell"),i.e("label"),i.is("bordered-label",$),i.is("vertical-label",c),f,k],colSpan:c?p:1},u);case"content":return D(this.tag,{style:y,class:[i.e("cell"),i.e("content"),i.is("bordered-content",$),i.is("vertical-content",c),_,b],colSpan:c?p:p*2-1},a);default:return D("td",{style:y,class:[i.e("cell"),_],colSpan:p},[D("span",{class:[i.e("label"),k]},u),D("span",{class:[i.e("content"),b]},a)])}}});const Y=W({row:{type:Array,default:()=>[]}}),Z={key:1},x=w({name:"ElDescriptionsRow"}),ee=w({...x,props:Y,setup(v){const o=j(I,{});return(t,N)=>n(o).direction==="vertical"?(l(),m(h,{key:0},[g("tr",null,[(l(!0),m(h,null,z(t.row,(s,d)=>(l(),C(n(E),{key:`tr1-${d}`,cell:s,tag:"th",type:"label"},null,8,["cell"]))),128))]),g("tr",null,[(l(!0),m(h,null,z(t.row,(s,d)=>(l(),C(n(E),{key:`tr2-${d}`,cell:s,tag:"td",type:"content"},null,8,["cell"]))),128))])],64)):(l(),m("tr",Z,[(l(!0),m(h,null,z(t.row,(s,d)=>(l(),m(h,{key:`tr3-${d}`},[n(o).border?(l(),m(h,{key:0},[B(n(E),{cell:s,tag:"td",type:"label"},null,8,["cell"]),B(n(E),{cell:s,tag:"td",type:"content"},null,8,["cell"])],64)):(l(),C(n(E),{key:1,cell:s,tag:"td",type:"both"},null,8,["cell"]))],64))),128))]))}});var te=K(ee,[["__file","/home/runner/work/element-plus/element-plus/packages/components/descriptions/src/descriptions-row.vue"]]);const se=W({border:{type:Boolean,default:!1},column:{type:Number,default:3},direction:{type:String,values:["horizontal","vertical"],default:"horizontal"},size:L,title:{type:String,default:""},extra:{type:String,default:""}}),le=w({name:"ElDescriptions"}),ne=w({...le,props:se,setup(v){const o=v,t=F("descriptions"),N=O(),s=Q();T(I,o);const d=q(()=>[t.b(),t.m(N.value)]),r=(e,c,u,a=!1)=>(e.props||(e.props={}),c>u&&(e.props.span=u),a&&(e.props.span=c),e),$=()=>{var e;const c=J((e=s.default)==null?void 0:e.call(s)).filter(f=>{var b;return((b=f==null?void 0:f.type)==null?void 0:b.name)==="ElDescriptionsItem"}),u=[];let a=[],p=o.column,_=0;return c.forEach((f,b)=>{var k;const y=((k=f.props)==null?void 0:k.span)||1;if(b<c.length-1&&(_+=y>p?p:y),b===c.length-1){const i=o.column-_%o.column;a.push(r(f,i,p,!0)),u.push(a);return}y<p?(p-=y,a.push(f)):(a.push(r(f,y,p)),u.push(a),p=o.column,a=[])}),u};return(e,c)=>(l(),m("div",{class:S(n(d))},[e.title||e.extra||e.$slots.title||e.$slots.extra?(l(),m("div",{key:0,class:S(n(t).e("header"))},[g("div",{class:S(n(t).e("title"))},[P(e.$slots,"title",{},()=>[R(V(e.title),1)])],2),g("div",{class:S(n(t).e("extra"))},[P(e.$slots,"extra",{},()=>[R(V(e.extra),1)])],2)],2)):G("v-if",!0),g("div",{class:S(n(t).e("body"))},[g("table",{class:S([n(t).e("table"),n(t).is("bordered",e.border)])},[g("tbody",null,[(l(!0),m(h,null,z($(),(u,a)=>(l(),C(te,{key:a,row:u},null,8,["row"]))),128))])],2)],2)],2))}});var re=K(ne,[["__file","/home/runner/work/element-plus/element-plus/packages/components/descriptions/src/description.vue"]]),U=w({name:"ElDescriptionsItem",props:{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:""}}});const ce=M(re,{DescriptionsItem:U}),pe=X(U);export{ce as E,pe as a};