UNPKG

@accounter/client

Version:

2 lines (1 loc) 713 B
import{r,j as t,bU as i,bV as d,B as p,h6 as h,bW as x}from"./index-DRqooPz9.js";function u(n,s){const e=new Uint8Array([239,187,191]),c=new Blob([e,n],{type:"text/csv;charset=UTF-8"}),a=URL.createObjectURL(c),o=document.createElement("a");o.href=a,o.download=`${s}.csv`,document.body.appendChild(o),o.click(),document.body.removeChild(o)}const m=({createFileVariables:n,buttonProps:s,buttonContent:e,label:c})=>{const a=r.useCallback(()=>{n().then(({fileContent:o,fileName:l})=>{u(o,l)})},[n]);return t.jsxs(i,{children:[t.jsx(d,{children:t.jsx(p,{variant:"outline",className:"p-2",...s,onClick:a,children:e||t.jsx(h,{size:20})})}),t.jsx(x,{children:t.jsx("p",{children:c||"Download CSV"})})]})};export{m as D};