UNPKG

@octavianlab/olab-ui

Version:
47 lines (46 loc) 1.67 kB
import { ref as l, onMounted as m, onBeforeUnmount as u, resolveComponent as d, openBlock as f, createBlock as h, createCommentVNode as p } from "vue"; import { c as y } from "./odialogexport-b6e3ec97.js"; import g from "axios"; const v = "https://cdn.octavianlab.com/v3/bo/common/lottie/", b = { __name: "OLottie", props: { name: { type: String, default: void 0 }, height: { type: [Number, String], default: 190 }, width: { type: [Number, String], default: "100%" } }, setup(n) { const e = n, o = l(null), r = l(null); return m(async () => { var t; try { const a = (t = e.name) != null && t.startsWith("/") ? e.name.replace("/", "") : e.name, { data: i } = await g.get(`${v}${a}.json`); o.value = i; } catch { o.value = y, console.info( `OLottie: "${e.name}" => a default lottie was inserted since it was not present in the assets/lottie folder.` ); } }), u(() => { try { const t = r.value; t && typeof t.destroy == "function" && (t.destroy(), console.info("OLottie: animazione distrutta con successo")); } catch (t) { console.warn("OLottie: errore nella distruzione dell'animazione Lottie", t); } }), (t, a) => { var c, s; const i = d("Vue3Lottie"); return ((s = (c = o.value) == null ? void 0 : c.layers) == null ? void 0 : s.length) > 0 ? (f(), h(i, { key: 0, ref_key: "lottieRef", ref: r, animationData: o.value, height: n.height, width: n.width }, null, 8, ["animationData", "height", "width"])) : p("", !0); }; } }; export { b as _ };