@anoki/fse-ui
Version:
FSE UI components library
3 lines (2 loc) • 3 kB
JavaScript
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});require('./components/ui/CardFile/CardFile.css');const e=require("./index.cjs278.js"),c=require("./index.cjs280.js"),E=require("./index.cjs333.js"),y=require("./index.cjs21.js"),k=require("./index.cjs36.js");;/* empty css */const v=require("./index.cjs134.js"),N=require("./index.cjs218.js"),g=require("./index.cjs117.js"),q=require("./index.cjs128.js");var R=(s=>(s.DOWNLOAD="download",s.GOTO="goto",s.EXTERNAL="external",s))(R||{});function f({title:s,description:p,issued_at:u,file:r,action:t,asLink:n="a",goToLink:i}){const j=n,w=async()=>{try{const x=t.link.link,l=x.match(/^data:([^;]+);base64,(.+)$/);if(l){const m=l[1],d=l[2],a=atob(d),h=new Uint8Array(a.length);for(let o=0;o<a.length;o++)h[o]=a.charCodeAt(o);const b=new Blob([h],{type:m});E.FileSaver_minExports.saveAs(b,s)}else{const d=await(await fetch(x)).blob();E.FileSaver_minExports.saveAs(d,s)}}catch(x){console.error("Error downloading file:",x)}};return e.jsxRuntimeExports.jsxs("div",{className:"card-file shadow rounded h-100 w-100 bg-white",children:[e.jsxRuntimeExports.jsxs("div",{className:c.clsx("top-container pt-x16 pb-x12",{"px-x16":t.type==="download","px-x24 ":t.type!=="download"}),children:[t.type==="download"&&e.jsxRuntimeExports.jsx("div",{className:"icon-wrapper",children:e.jsxRuntimeExports.jsx(v.File,{height:27,width:27})}),e.jsxRuntimeExports.jsxs("div",{className:"content-container",children:[e.jsxRuntimeExports.jsxs("div",{children:[e.jsxRuntimeExports.jsx("h3",{className:c.clsx("card-file-title text-slate-20 mt-x8","cursor-pointer hover-underline"),children:t.type==="download"?s:e.jsxRuntimeExports.jsx(j,{className:"link-unstyled",href:t.link.link,children:s})}),r&&(r.type||r.size)&&e.jsxRuntimeExports.jsx("p",{className:"file-type text-muted",children:r.type&&r.size?`${r.type} | ${r.size}`:r.type||r.size})]}),p&&e.jsxRuntimeExports.jsx("div",{className:"description text-slate-28",children:e.jsxRuntimeExports.jsx(N.RichText,{description:p})}),u&&e.jsxRuntimeExports.jsx("p",{className:"description text-slate-28",children:u})]})]}),e.jsxRuntimeExports.jsx("div",{className:c.clsx("card-file-footer px-x24",t.type,{"pt-x4 pb-x16":t.type==="external","py-x16 ":t.type!=="external","--between":!!i}),children:t.type==="download"?e.jsxRuntimeExports.jsxs(e.jsxRuntimeExports.Fragment,{children:[e.jsxRuntimeExports.jsxs(k.Button,{className:"bg-transparent download-button",onClick:w,children:[e.jsxRuntimeExports.jsx(g.Download,{}),t.link.title]}),i&&e.jsxRuntimeExports.jsx(y.ArrowLink,{href:i.link,asLink:n,children:i.title})]}):t.type==="goto"?e.jsxRuntimeExports.jsx(y.ArrowLink,{href:t.link.link,asLink:n,children:t.link.title}):e.jsxRuntimeExports.jsx(j,{title:t.link.title,href:t.link.link,src:t.link.link,icon:q.ExternalLink,decoration:"ui-footer-logo-link",transform:"none",external:!0,asLink:n})})]})}exports.CardFile=f;exports.CardFileActionTypeEnum=R;
//# sourceMappingURL=index.cjs50.js.map