码桶
发现社区成员的开源项目
ExportButton-ChE0FTgH.js1.3 KB
import{E as v,r as i,u as w,j as e,B as j,G as c,H as y,J as E}from"./index-GWuvg2UH.js";import{T as x}from"./index-BW_2QB9V.js";function k(t){return i.createElement("svg",Object.assign({viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",focusable:!1,"aria-hidden":!0},t),i.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M17.84 8.06A6.5 6.5 0 1 0 5.18 11 4.5 4.5 0 0 0 5.5 20H17a6 6 0 0 0 .84-11.94Zm-6.16 9.67a.5.5 0 0 0 .64 0l5.15-4.29a.25.25 0 0 0-.16-.44H14V9.5a.5.5 0 0 0-.5-.5h-3a.5.5 0 0 0-.5.5V13H6.7c-.24 0-.35.3-.17.44l5.15 4.3Z",fill:"currentColor"}))}const B=v(k,"download");function R({siteId:t,items:n=[],params:l={},size:f="small",type:h="tertiary"}){const{t:s}=w(),[g,d]=i.useState(!1);if(!t||!n.length)return null;const u=async o=>{d(!0);try{const a=typeof l=="function"?l():l,{blob:m,filename:b}=await y(o,t,a||{});E(m,b),x.success(s("expOk"))}catch(a){x.error(`${s("expFail")}: ${a.message}`)}finally{d(!1)}},r=n.length===1,p=e.jsx(j,{size:f,type:h,icon:e.jsx(B,{}),loading:g,onClick:r?()=>u(n[0].kind):void 0,children:r?n[0].label:s("export")});return r?p:e.jsx(c,{trigger:"click",position:"bottomRight",render:e.jsx(c.Menu,{children:n.map(o=>e.jsx(c.Item,{onClick:()=>u(o.kind),children:o.label},o.kind))}),children:e.jsx("span",{style:{display:"inline-flex"},children:p})})}export{R as E};