Files
2026-07-13 15:23:29 +08:00

1 line
9.3 KiB
JavaScript

import{$t as e,Bt as t,In as n,Ln as r,Or as i,Sr as a,St as o,Tr as s,Y as c,an as l,cn as u,fn as d,hn as f,sn as p,st as m,vn as h,xn as g}from"./jsx-runtime-NwRKtVrk.js";import{r as _,t as v}from"./useBreakpoint-BdDQSe50.js";import{n as y,t as b}from"./row-Ddb-vj9X.js";import{t as x}from"./pagination-BnmIuxKW.js";import{t as S}from"./spin-DV35Mdw9.js";import{U as C}from"./index-B7MUL4ct.js";var w=i(s()),T=w.createContext({});T.Consumer;var E=({prefixCls:e,className:t,avatar:n,title:r,description:i,...o})=>{let{getPrefixCls:s}=(0,w.useContext)(p),c=s(`list`,e),l=a(`${c}-item-meta`,t),u=w.createElement(`div`,{className:`${c}-item-meta-content`},r&&w.createElement(`h4`,{className:`${c}-item-meta-title`},r),i&&w.createElement(`div`,{className:`${c}-item-meta-description`},i));return w.createElement(`div`,{...o,className:l},n&&w.createElement(`div`,{className:`${c}-item-meta-avatar`},n),(r||i)&&u)},D=w.forwardRef((e,t)=>{let{prefixCls:n,children:i,actions:o,extra:s,styles:c,className:l,classNames:u,colStyle:d,...f}=e,{grid:g,itemLayout:_}=(0,w.useContext)(T),{getPrefixCls:v,list:b}=(0,w.useContext)(p),x=e=>a(b?.item?.classNames?.[e],u?.[e]),S=e=>({...b?.item?.styles?.[e],...c?.[e]}),C=()=>{let e=r(i);return e.some(h)&&e.length>1},E=()=>_===`vertical`?!!s:!C(),D=v(`list`,n),O=o&&o.length>0&&w.createElement(`ul`,{className:a(`${D}-item-action`,x(`actions`)),key:`actions`,style:S(`actions`)},o.map((e,t)=>w.createElement(`li`,{key:`${D}-item-action-${t}`},e,t!==o.length-1&&w.createElement(`em`,{className:`${D}-item-action-split`})))),k=g?`div`:`li`,A=w.createElement(k,{...f,...g?{}:{ref:t},className:a(`${D}-item`,{[`${D}-item-no-flex`]:!E()},l)},_===`vertical`&&s?[w.createElement(`div`,{className:`${D}-item-main`,key:`content`},i,O),w.createElement(`div`,{className:a(`${D}-item-extra`,x(`extra`)),key:`extra`,style:S(`extra`)},s)]:[i,O,m(s,{key:`extra`})]);return g?w.createElement(y,{ref:t,flex:1,style:d},A):A});D.Meta=E;var O=e=>{let{listBorderedCls:t,componentCls:n,paddingLG:r,margin:i,itemPaddingSM:a,itemPaddingLG:o,marginLG:s,borderRadiusLG:c}=e,u=l(e.calc(c).sub(e.lineWidth).equal());return{[t]:{border:`${l(e.lineWidth)} ${e.lineType} ${e.colorBorder}`,borderRadius:c,[`${n}-header`]:{borderRadius:`${u} ${u} 0 0`},[`${n}-footer`]:{borderRadius:`0 0 ${u} ${u}`},[`${n}-header,${n}-footer,${n}-item`]:{paddingInline:r},[`${n}-pagination`]:{margin:`${l(i)} ${l(s)}`}},[`${t}${n}-sm`]:{[`${n}-item,${n}-header,${n}-footer`]:{padding:a}},[`${t}${n}-lg`]:{[`${n}-item,${n}-header,${n}-footer`]:{padding:o}}}},k=e=>{let{componentCls:t,screenSM:n,screenMD:r,marginLG:i,marginSM:a,margin:o}=e;return{[`@media screen and (max-width:${r}px)`]:{[t]:{[`${t}-item`]:{[`${t}-item-action`]:{marginInlineStart:i}}},[`${t}-vertical`]:{[`${t}-item`]:{[`${t}-item-extra`]:{marginInlineStart:i}}}},[`@media screen and (max-width: ${n}px)`]:{[t]:{[`${t}-item`]:{flexWrap:`wrap`,[`${t}-action`]:{marginInlineStart:a}}},[`${t}-vertical`]:{[`${t}-item`]:{flexWrap:`wrap-reverse`,[`${t}-item-main`]:{minWidth:e.contentWidth},[`${t}-item-extra`]:{margin:`auto auto ${l(o)}`}}}}}},A=t=>{let{componentCls:n,antCls:r,controlHeight:i,minHeight:a,paddingSM:o,marginLG:s,padding:c,itemPadding:u,colorPrimary:d,itemPaddingSM:f,itemPaddingLG:p,paddingXS:m,margin:h,colorText:g,colorTextDescription:_,motionDurationSlow:v,lineWidth:y,headerBg:b,footerBg:x,emptyTextPadding:S,metaMarginBottom:C,avatarMarginRight:w,titleMarginBottom:T,descriptionFontSize:E}=t;return{[n]:{...e(t),position:`relative`,"--rc-virtual-list-scrollbar-bg":t.colorSplit,"*":{outline:`none`},[`${n}-header`]:{background:b},[`${n}-footer`]:{background:x},[`${n}-header, ${n}-footer`]:{paddingBlock:o},[`${n}-pagination`]:{marginBlockStart:s,[`${r}-pagination-options`]:{textAlign:`start`}},[`${n}-spin`]:{minHeight:a,textAlign:`center`},[`${n}-items`]:{margin:0,padding:0,listStyle:`none`},[`${n}-item`]:{display:`flex`,alignItems:`center`,justifyContent:`space-between`,padding:u,color:g,[`${n}-item-meta`]:{display:`flex`,flex:1,alignItems:`flex-start`,maxWidth:`100%`,[`${n}-item-meta-avatar`]:{marginInlineEnd:w},[`${n}-item-meta-content`]:{flex:`1 0`,width:0,color:g},[`${n}-item-meta-title`]:{margin:`0 0 ${l(t.marginXXS)} 0`,color:g,fontSize:t.fontSize,lineHeight:t.lineHeight,"> a":{color:g,transition:`all ${v}`,"&:hover":{color:d}}},[`${n}-item-meta-description`]:{color:_,fontSize:E,lineHeight:t.lineHeight}},[`${n}-item-action`]:{flex:`0 0 auto`,marginInlineStart:t.marginXXL,padding:0,fontSize:0,listStyle:`none`,"& > li":{position:`relative`,display:`inline-block`,padding:`0 ${l(m)}`,color:_,fontSize:t.fontSize,lineHeight:t.lineHeight,textAlign:`center`,"&:first-child":{paddingInlineStart:0}},[`${n}-item-action-split`]:{position:`absolute`,insetBlockStart:`50%`,insetInlineEnd:0,width:y,height:t.calc(t.fontHeight).sub(t.calc(t.marginXXS).mul(2)).equal(),transform:`translateY(-50%)`,backgroundColor:t.colorSplit}}},[`${n}-empty`]:{padding:`${l(c)} 0`,color:_,fontSize:t.fontSizeSM,textAlign:`center`},[`${n}-empty-text`]:{padding:S,color:t.colorTextDisabled,fontSize:t.fontSize,textAlign:`center`},[`${n}-item-no-flex`]:{display:`block`}},[`${n}-grid ${r}-col > ${n}-item`]:{display:`block`,maxWidth:`100%`,marginBlockEnd:h,paddingBlock:0,borderBlockEnd:`none`},[`${n}-vertical ${n}-item`]:{alignItems:`initial`,[`${n}-item-main`]:{display:`block`,flex:1},[`${n}-item-extra`]:{marginInlineStart:s},[`${n}-item-meta`]:{marginBlockEnd:C,[`${n}-item-meta-title`]:{marginBlockStart:0,marginBlockEnd:T,color:g,fontSize:t.fontSizeLG,lineHeight:t.lineHeightLG}},[`${n}-item-action`]:{marginBlockStart:c,marginInlineStart:`auto`,"> li":{padding:`0 ${l(c)}`,"&:first-child":{paddingInlineStart:0}}}},[`${n}-split ${n}-item`]:{borderBlockEnd:`${l(t.lineWidth)} ${t.lineType} ${t.colorSplit}`,"&:last-child":{borderBlockEnd:`none`}},[`${n}-split ${n}-header`]:{borderBlockEnd:`${l(t.lineWidth)} ${t.lineType} ${t.colorSplit}`},[`${n}-split${n}-empty ${n}-footer`]:{borderTop:`${l(t.lineWidth)} ${t.lineType} ${t.colorSplit}`},[`${n}-loading ${n}-spin-nested-loading`]:{minHeight:i},[`${n}-split${n}-something-after-last-item ${r}-spin-container > ${n}-items > ${n}-item:last-child`]:{borderBlockEnd:`${l(t.lineWidth)} ${t.lineType} ${t.colorSplit}`},[`${n}-lg ${n}-item`]:{padding:p},[`${n}-sm ${n}-item`]:{padding:f},[`${n}:not(${n}-vertical)`]:{[`${n}-item-no-flex`]:{[`${n}-item-action`]:{float:`right`}}}}},ee=o(`List`,e=>{let n=t(e,{listBorderedCls:`${e.componentCls}-bordered`,minHeight:e.controlHeightLG});return[A(n),O(n),k(n)]},e=>({contentWidth:220,itemPadding:`${l(e.paddingContentVertical)} 0`,itemPaddingSM:`${l(e.paddingContentVerticalSM)} ${l(e.paddingContentHorizontal)}`,itemPaddingLG:`${l(e.paddingContentVerticalLG)} ${l(e.paddingContentHorizontalLG)}`,headerBg:`transparent`,footerBg:`transparent`,emptyTextPadding:e.padding,metaMarginBottom:e.padding,avatarMarginRight:e.padding,titleMarginBottom:e.paddingSM,descriptionFontSize:e.fontSize}),{extraCssVarPrefixCls:({prefixCls:e})=>[`${e}-container`]}),j=w.forwardRef((e,t)=>{let{pagination:r=!1,prefixCls:i,bordered:o=!1,split:s=!0,className:l,rootClassName:m,style:h,children:y,itemLayout:E,loadMore:D,grid:O,dataSource:k=[],size:A,header:j,footer:M,loading:te=!1,rowKey:N,renderItem:P,locale:ne,...re}=e,F=f(r)?r:{},[ie,ae]=w.useState(F.defaultCurrent||1),[oe,se]=w.useState(F.defaultPageSize||10),{getPrefixCls:ce,direction:I,className:L,style:R}=u(`list`),{renderEmpty:z}=w.useContext(p),le={current:1,total:0,position:`bottom`},B=e=>(t,n)=>{ae(t),se(n),r&&r?.[e]?.(t,n)},ue=B(`onChange`),de=B(`onShowSizeChange`),fe=(e,t)=>{if(!P)return null;let n;return n=d(N)?N(e):N?e[N]:e.key,n||=`list-item-${t}`,w.createElement(w.Fragment,{key:n},P(e,t))},pe=!!(D||r||M),V=ce(`list`,i),[me,H]=ee(V),U=te;typeof U==`boolean`&&(U={spinning:U});let W=!!U?.spinning,he=c(A),G=``;switch(he){case`large`:G=`lg`;break;case`small`:G=`sm`;break;default:break}let ge=a(V,{[`${V}-vertical`]:E===`vertical`,[`${V}-${G}`]:G,[`${V}-split`]:s,[`${V}-bordered`]:o,[`${V}-loading`]:W,[`${V}-grid`]:!!O,[`${V}-something-after-last-item`]:pe,[`${V}-rtl`]:I===`rtl`},L,l,m,me,H),K=`${V}-container`,q=n(le,{total:k.length,current:ie,pageSize:oe},r||{}),_e=Math.ceil(q.total/q.pageSize);q.current=Math.min(q.current,_e);let J=r&&w.createElement(`div`,{className:a(`${V}-pagination`)},w.createElement(x,{align:`end`,...q,onChange:ue,onShowSizeChange:de})),Y=g(k);r&&k.length>(q.current-1)*q.pageSize&&(Y=g(k).splice((q.current-1)*q.pageSize,q.pageSize));let X=v(Object.keys(O||{}).some(e=>_.includes(e))),Z=w.useMemo(()=>{for(let e=0;e<_.length;e+=1){let t=_[e];if(X[t])return t}},[X]),ve=w.useMemo(()=>{if(!O)return;let e=Z&&O[Z]?O[Z]:O.column;if(e)return{width:`${100/e}%`,maxWidth:`${100/e}%`}},[JSON.stringify(O),Z]),Q=W&&w.createElement(`div`,{style:{minHeight:53}});if(Y.length>0){let e=Y.map(fe);Q=O?w.createElement(b,{className:a(K,H),gutter:O.gutter},w.Children.map(e,e=>w.createElement(`div`,{key:e?.key,style:ve},e))):w.createElement(`ul`,{className:a(`${V}-items`,K,H)},e)}else!y&&!W&&(Q=w.createElement(`div`,{className:`${V}-empty-text`},ne?.emptyText||z?.(`List`)||w.createElement(C,{componentName:`List`})));let $=q.position,ye=w.useMemo(()=>({grid:O,itemLayout:E}),[JSON.stringify(O),E]);return w.createElement(T.Provider,{value:ye},w.createElement(`div`,{ref:t,style:{...R,...h},className:ge,...re},($===`top`||$===`both`)&&J,j&&w.createElement(`div`,{className:`${V}-header`},j),w.createElement(S,{...U},Q,y),M&&w.createElement(`div`,{className:`${V}-footer`},M),D||($===`bottom`||$===`both`)&&J))});j.Item=D;export{j as t};