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},H=(t,e)=>ve(t,ye(e));import{n as a,Z as k,S as Se,v as M,F as Ce,cB as xe,cC as ge,cD as he,_ as P,O as z,a as G,R as we,bq as Pe,az as ae,a2 as ue,U as _e,aa as $e,bE as re,f as N,aA as se,W as De,cl as Oe,V as je,b as Ie,cE as Ee,k as p,aH as Ne,cF as Re,cG as ke,cH as Me,aF as T,bd as Ae,aD as Le,cI as Be,N as ze}from"./index.c32990f8.js";import{g as Fe}from"./get.0f83bcc9.js";function B(t){return t!=null}var Ue=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 g;return a(_,{class:[(g={},k(g,"".concat(n,"-item-label"),B(i)),k(g,"".concat(n,"-item-content"),B(d)),g)],colSpan:r},{default:function(){return[B(i)&&a("span",{style:o},[i]),B(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"),k({},"".concat(n,"-item-no-colon"),!u)],style:o},[i]),d&&a("span",{class:"".concat(n,"-item-content"),style:c},[d])])]}})},q=Ue,We=function(e){var n=function(g,m,b){var E=m.colon,A=m.prefixCls,s=m.bordered,S=b.component,v=b.type,h=b.showLabel,D=b.showContent,O=b.labelStyle,$=b.contentStyle;return g.map(function(C,j){var I,x,f=C.props||{},L=f.prefixCls,F=L===void 0?A:L,Z=f.span,J=Z===void 0?1:Z,K=f.labelStyle,Q=K===void 0?f["label-style"]:K,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||(x=I.label)===null||x===void 0?void 0:x.call(I):ee,ne=xe(C),U=ge(C),W=he(C),V=C.key;return typeof S=="string"?a(q,{key:"".concat(v,"-").concat(String(V)||j),class:U,style:W,labelStyle:P(P({},O),Q),contentStyle:P(P({},$),Y),span:J,colon:E,component:S,itemPrefixCls:F,bordered:s,label:h?te:null,content:D?ne:null},null):[a(q,{key:"label-".concat(String(V)||j),class:U,style:P(P(P({},O),W),Q),span:1,colon:E,component:S[0],itemPrefixCls:F,bordered:s,label:te},null),a(q,{key:"content-".concat(String(V)||j),class:U,style:P(P(P({},$),W),Y),span:J*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:M({}),contentStyle:M({})}),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=We;z.any;var He=function(){return{prefixCls:String,label:z.any,labelStyle:{type:Object,default:void 0},contentStyle:{type:Object,default:void 0},span:{type:Number,default:1}}},Te=G({compatConfig:{MODE:3},name:"ADescriptionsItem",props:He(),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=Oe(t,{span:n}),je(e===void 0,"Descriptions","Sum of column `span` in a line not match `column` of Descriptions.")),l}function Ge(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 Ze=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"),R=G({compatConfig:{MODE:3},name:"ADescriptions",props:Ze(),slots:["title","extra"],Item:Te,setup:function(e,n){var l=n.slots,r=we("descriptions",e),o=r.prefixCls,c=r.direction,y,i=M({});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=N(function(){return qe(e.column,i.value)});return function(){var u,_,g,m,b=e.size,E=e.bordered,A=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,O=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):$,j=(g=l.default)===null||g===void 0?void 0:g.call(l),I=Ge(j,d.value);return a("div",{class:[o.value,(m={},k(m,"".concat(o.value,"-").concat(b),b!=="default"),k(m,"".concat(o.value,"-bordered"),!!A),k(m,"".concat(o.value,"-rtl"),c.value==="rtl"),m)]},[(O||C)&&a("div",{class:"".concat(o.value,"-header")},[O&&a("div",{class:"".concat(o.value,"-title")},[O]),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(x,f){return a(Ve,{key:f,index:f,colon:h,prefixCls:o.value,vertical:S==="vertical",bordered:A,row:x},null)})])])])])}}});R.install=function(t){return t.component(R.name,R),t.component(R.Item.name,R.Item),t};var ie=R;function Je(t){return typeof t=="function"||Object.prototype.toString.call(t)==="[object Object]"&&!Me(t)}const Ke={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 Qe=G({name:"Description",props:Ke,emits:["register"],setup(t,{slots:e,emit:n}){const l=M(null),{prefixCls:r}=Ie("description"),o=Ee(),c=N(()=>w(w({},t),p(l))),y=N(()=>H(w({},p(c)),{title:void 0})),i=N(()=>!!p(c).title),d=N(()=>w({canExpand:!1},p(y).collapseOptions)),u=N(()=>w(w({},p(o)),p(y)));function _(s){l.value=w(w({},p(l)),s)}function g({label:s,labelMinWidth:S,labelStyle:v}){if(!v&&!S)return s;const h=H(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:O,show:$,contentMinWidth:C}=v;if($&&T($)&&!$(S))return null;const j=()=>{var L;const x=(L=p(y))==null?void 0:L.data;if(!x)return null;const f=Fe(x,D);return f&&!Ae(x).hasOwnProperty(D)?T(h)?h("",x):"":T(h)?h(f,x):f!=null?f:""},I=C;return a(ie.Item,{label:g(v),key:D,span:O},{default:()=>{if(!C)return j();const x={minWidth:`${I}px`};return a("div",{style:x},[j()])}})}).filter(v=>!!v)}const b=()=>{let s;return a(ie,Ne({class:`${r}`},p(u)),Je(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(ke,{title:h,canExpan:S,helpMessage:v},{default:()=>s,action:()=>Re(e,"action")})};return n("register",{setDescProps:_}),()=>p(i)?E():b()}});function tt(t){if(!Le())throw new Error("useDescription() can only be used inside setup() or functional components!");const e=M(null),n=M(!1);function l(o){p(n)&&Be()||(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(Qe);export{nt as D,tt as u};
|