UNPKG

@braineet/ui

Version:

Braineet design system

37 lines 1.6 kB
var _excluded = ["children", "unprotected", "options", "size"]; function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; } 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);