import{j as t}from"./index-Dyazi077.js";import{b as p}from"./react-vendor-CjpoAPrF.js";import{h as g}from"./format-flB0hImb.js";function u(s,e,i){return typeof e=="function"?e(s,i):typeof e=="string"&&(s==null?void 0:s[e])!==void 0?s[e]:i}function k({columns:s,rows:e,rowKey:i="id",pageSize:c=8,emptyText:m="暂无数据",minWidth:x=640}){const[b,h]=p.useState(1);if(p.useEffect(()=>{h(1)},[e,c]),!(e!=null&&e.length))return t.jsx("div",{className:"empty-state compact",children:t.jsx("p",{children:m})});const l=Math.max(1,Math.ceil(e.length/c)),d=Math.min(b,l),r=(d-1)*c,j=e.slice(r,r+c);return t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"table-wrap",children:t.jsxs("table",{className:"data-table",style:{minWidth:x},children:[t.jsx("thead",{children:t.jsx("tr",{children:s.map(a=>t.jsx("th",{children:a.label},a.key))})}),t.jsx("tbody",{children:j.map((a,f)=>t.jsx("tr",{children:s.map(n=>t.jsx("td",{className:n.className||"",style:n.style||void 0,children:n.render?n.render(a):g(a==null?void 0:a[n.key])},n.key))},u(a,i,f)))})]})}),l>1?t.jsxs("div",{className:"table-pagination",children:[t.jsx("button",{className:"page-btn",type:"button",onClick:()=>h(a=>Math.max(1,a-1)),disabled:d<=1,children:"上一页"}),t.jsxs("span",{className:"page-info",children:["第 ",d,"/",l," 页 · 共 ",e.length," 条"]}),t.jsx("button",{className:"page-btn",type:"button",onClick:()=>h(a=>Math.min(l,a+1)),disabled:d>=l,children:"下一页"})]}):null]})}export{k as D};
