UNPKG

@braineet/ui

Version:

Braineet design system

37 lines 1.43 kB
var _excluded = ["children", "unprotected", "options", "size"]; function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); } function _objectWithoutPropertiesLoose(r, e) { if (null == r) return {}; var t = {}; for (var n in r) if ({}.hasOwnProperty.call(r, n)) { if (-1 !== e.indexOf(n)) continue; t[n] = r[n]; } return t; } import React from 'react'; import DOMPurify from 'dompurify'; import ReactHtmlParser from 'react-html-parser'; import { withTheme } from 'styled-components'; import { Wrapper } from './styles'; import { jsx as _jsx } from "react/jsx-runtime"; var zooms = { md: 1, sm: 0.875, xs: 0.75, xxs: 0.625 }; var Html = function Html(_ref) { var children = _ref.children, unprotected = _ref.unprotected, options = _ref.options, size = _ref.size, restProps = _objectWithoutPropertiesLoose(_ref, _excluded); return /*#__PURE__*/_jsx(Wrapper, _extends({ zoomFont: zooms[size] || 1 }, restProps, { children: ReactHtmlParser(unprotected ? children : DOMPurify.sanitize(children, { USE_PROFILES: { html: true } }), options) })); }; Html.defaultProps = { size: 'md', options: {}, unprotected: false }; export default withTheme(Html);