UNPKG

@anoki/fse-ui

Version:

FSE UI components library

120 lines (119 loc) 4.38 kB
import { j as e } from "./index.es277.js"; import { clsx as x } from "./index.es279.js"; import { F as w } from "./index.es332.js"; import { ArrowLink as b } from "./index.es21.js"; import { Button as v } from "./index.es36.js"; import './components/ui/CardFile/CardFile.css';/* empty css */ import { File as N } from "./index.es133.js"; import { RichText as u } from "./index.es217.js"; import { Download as g } from "./index.es116.js"; import { ExternalLink as A } from "./index.es127.js"; var z = /* @__PURE__ */ ((t) => (t.DOWNLOAD = "download", t.GOTO = "goto", t.EXTERNAL = "external", t))(z || {}); function G({ title: t, description: c, issued_at: h, file: n, action: r, asLink: s = "a", goToLink: l }) { const m = s, f = async () => { try { const o = r.link.link, i = o.match(/^data:([^;]+);base64,(.+)$/); if (i) { const y = i[1], d = i[2], p = atob(d), j = new Uint8Array(p.length); for (let a = 0; a < p.length; a++) j[a] = p.charCodeAt(a); const k = new Blob([j], { type: y }); w.saveAs(k, t); } else { const d = await (await fetch(o)).blob(); w.saveAs(d, t); } } catch (o) { console.error("Error downloading file:", o); } }; return /* @__PURE__ */ e.jsxs("div", { className: "card-file shadow rounded h-100 w-100 bg-white", children: [ /* @__PURE__ */ e.jsxs( "div", { className: x("top-container pt-x16 pb-x12", { "px-x16": r.type === "download", "px-x24 ": r.type !== "download" }), children: [ r.type === "download" && /* @__PURE__ */ e.jsx("div", { className: "icon-wrapper", children: /* @__PURE__ */ e.jsx(N, { height: 27, width: 27 }) }), /* @__PURE__ */ e.jsxs("div", { className: "content-container", children: [ /* @__PURE__ */ e.jsxs("div", { children: [ /* @__PURE__ */ e.jsx( "h3", { className: x( "card-file-title text-slate-20 mt-x8", "cursor-pointer hover-underline" ), children: r.type === "download" ? t : /* @__PURE__ */ e.jsx( m, { className: "link-unstyled", href: r.link.link, target: r.type === "external" ? "_blank" : void 0, rel: r.type === "external" ? "noopener noreferrer" : void 0, children: t } ) } ), n && (n.type || n.size) && /* @__PURE__ */ e.jsx("p", { className: "file-type text-muted", children: n.type && n.size ? `${n.type} | ${n.size}` : n.type || n.size }) ] }), c && /* @__PURE__ */ e.jsx("div", { className: "description text-slate-28", children: /* @__PURE__ */ e.jsx(u, { description: c }) }), h && /* @__PURE__ */ e.jsx("p", { className: "description text-slate-28", children: h }) ] }) ] } ), /* @__PURE__ */ e.jsx( "div", { className: x("card-file-footer px-x24", r.type, { "pt-x4 pb-x16": r.type === "external", "py-x16 ": r.type !== "external", "--between": !!l }), children: r.type === "download" ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [ /* @__PURE__ */ e.jsxs( v, { className: "bg-transparent download-button", onClick: f, children: [ /* @__PURE__ */ e.jsx(g, {}), r.link.title ] } ), l && /* @__PURE__ */ e.jsx(b, { href: l.link, asLink: s, children: l.title }) ] }) : r.type === "goto" ? /* @__PURE__ */ e.jsx(b, { href: r.link.link, asLink: s, children: r.link.title }) : /* @__PURE__ */ e.jsx( m, { title: r.link.title, href: r.link.link, src: r.link.link, icon: A, decoration: "ui-footer-logo-link", transform: "none", external: !0, asLink: s } ) } ) ] }); } export { G as CardFile, z as CardFileActionTypeEnum }; //# sourceMappingURL=index.es50.js.map