UNPKG

@veracity/vui

Version:

Veracity UI is a React component library crafted for use within Veracity applications and pages. Based on Styled Components and @xstyled.

32 lines (31 loc) 957 B
//#region src/svg/helpers.ts /** Returns an object with given element's HTML attributes. */ function getAttributes(element) { if (!element) return {}; return Array.from(element.attributes).reduce((props, attr) => { const { name, value } = attr; props[name] = value; return props; }, {}); } /** Returns content of the SVG HTML string by stripping the svg tag. */ function getSvgContent(html = "") { return html.replace(/(<\/?svg(?:.|\n)*?>)|(\r\n|\n|\r)/gm, ""); } /** Returns object with initial state values. */ function initState() { return { content: "", svgAttributes: {} }; } /** Returns given HTML string as an HTML element. */ function stringToHTML(html) { const container = document.createElement("div"); container.innerHTML = html; return container.firstElementChild; } //#endregion export { getAttributes, getSvgContent, initState, stringToHTML }; globalThis.__vuiVersion__ = "5.3.0-alpha.2" //# sourceMappingURL=helpers.js.map