@nextcloud/vue
Version:
Nextcloud vue components
69 lines (68 loc) • 2.41 kB
JavaScript
import '../assets/NcIconSvgWrapper-N3OwSN9O.css';
import { defineComponent, useCssVars, computed, warn, createElementBlock, openBlock, normalizeClass, createElementVNode } from "vue";
import DOMPurify from "dompurify";
import { _ as _export_sfc } from "./_plugin-vue_export-helper-1tPrXgE0.mjs";
const _hoisted_1 = ["aria-hidden", "aria-label"];
const _hoisted_2 = {
key: 0,
viewBox: "0 0 24 24",
xmlns: "http://www.w3.org/2000/svg"
};
const _hoisted_3 = ["d"];
const _hoisted_4 = ["innerHTML"];
const _sfc_main = /* @__PURE__ */ defineComponent({
__name: "NcIconSvgWrapper",
props: {
directional: { type: Boolean },
inline: { type: Boolean },
svg: { default: "" },
name: { default: void 0 },
path: { default: "" },
size: { default: 20 }
},
setup(__props) {
useCssVars((_ctx) => ({
"fb515064": iconSize.value
}));
const props = __props;
const iconSize = computed(() => typeof props.size === "number" ? `${props.size}px` : props.size);
const cleanSvg = computed(() => {
if (!props.svg || props.path) {
return;
}
const svg = DOMPurify.sanitize(props.svg);
const svgDocument = new DOMParser().parseFromString(svg, "image/svg+xml");
if (svgDocument.querySelector("parsererror")) {
warn("SVG is not valid");
return "";
}
if (svgDocument.documentElement.id) {
svgDocument.documentElement.removeAttribute("id");
}
return svgDocument.documentElement.outerHTML;
});
return (_ctx, _cache) => {
return openBlock(), createElementBlock("span", {
"aria-hidden": _ctx.name ? void 0 : "true",
"aria-label": _ctx.name || void 0,
class: normalizeClass(["icon-vue", {
"icon-vue--directional": _ctx.directional,
"icon-vue--inline": _ctx.inline
}]),
role: "img"
}, [
!cleanSvg.value ? (openBlock(), createElementBlock("svg", _hoisted_2, [
createElementVNode("path", { d: _ctx.path }, null, 8, _hoisted_3)
])) : (openBlock(), createElementBlock("span", {
key: 1,
innerHTML: cleanSvg.value
}, null, 8, _hoisted_4))
], 10, _hoisted_1);
};
}
});
const NcIconSvgWrapper = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-aaedb1c3"]]);
export {
NcIconSvgWrapper as N
};
//# sourceMappingURL=NcIconSvgWrapper-BvLanNaW.mjs.map