UNPKG

@anoki/fse-ui

Version:

FSE UI components library

118 lines (117 loc) 4.22 kB
import { j as e } from "./index.es278.js"; import { clsx as x } from "./index.es280.js"; import { F as y } from "./index.es333.js"; import { ArrowLink as b } from "./index.es21.js"; import { Button as N } from "./index.es36.js"; import './components/ui/CardFile/CardFile.css';/* empty css */ import { File as v } from "./index.es134.js"; import { RichText as u } from "./index.es218.js"; import { Download as g } from "./index.es117.js"; import { ExternalLink as A } from "./index.es128.js"; var z = /* @__PURE__ */ ((r) => (r.DOWNLOAD = "download", r.GOTO = "goto", r.EXTERNAL = "external", r))(z || {}); function G({ title: r, description: c, issued_at: h, file: s, action: t, asLink: n = "a", goToLink: l }) { const m = n, f = async () => { try { const o = t.link.link, a = o.match(/^data:([^;]+);base64,(.+)$/); if (a) { const j = a[1], d = a[2], p = atob(d), w = new Uint8Array(p.length); for (let i = 0; i < p.length; i++) w[i] = p.charCodeAt(i); const k = new Blob([w], { type: j }); y.saveAs(k, r); } else { const d = await (await fetch(o)).blob(); y.saveAs(d, r); } } 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": t.type === "download", "px-x24 ": t.type !== "download" }), children: [ t.type === "download" && /* @__PURE__ */ e.jsx("div", { className: "icon-wrapper", children: /* @__PURE__ */ e.jsx(v, { 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: t.type === "download" ? r : /* @__PURE__ */ e.jsx( m, { className: "link-unstyled", href: t.link.link, children: r } ) } ), s && (s.type || s.size) && /* @__PURE__ */ e.jsx("p", { className: "file-type text-muted", children: s.type && s.size ? `${s.type} | ${s.size}` : s.type || s.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", t.type, { "pt-x4 pb-x16": t.type === "external", "py-x16 ": t.type !== "external", "--between": !!l }), children: t.type === "download" ? /* @__PURE__ */ e.jsxs(e.Fragment, { children: [ /* @__PURE__ */ e.jsxs( N, { className: "bg-transparent download-button", onClick: f, children: [ /* @__PURE__ */ e.jsx(g, {}), t.link.title ] } ), l && /* @__PURE__ */ e.jsx(b, { href: l.link, asLink: n, children: l.title }) ] }) : t.type === "goto" ? /* @__PURE__ */ e.jsx(b, { href: t.link.link, asLink: n, children: t.link.title }) : /* @__PURE__ */ e.jsx( m, { title: t.link.title, href: t.link.link, src: t.link.link, icon: A, decoration: "ui-footer-logo-link", transform: "none", external: !0, asLink: n } ) } ) ] }); } export { G as CardFile, z as CardFileActionTypeEnum }; //# sourceMappingURL=index.es50.js.map