UNPKG

@sap-ux/ui-components

Version:
58 lines 1.97 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.UITooltipUtils = void 0; const react_1 = __importDefault(require("react")); const sanitize_html_1 = __importDefault(require("sanitize-html")); const UICallout_1 = require("../UICallout"); /** * UITooltipUtil class for rendering content * * @class UITooltipUtils */ class UITooltipUtils { /** * Method returns styles for tooltip content. * * @returns {ITooltipStyles} Object with tooltip styles. */ static getStyles() { return { root: {}, content: { background: UICallout_1.CALLOUT_STYLES.background, color: UICallout_1.CALLOUT_STYLES.text }, subText: {} }; } /** * Method returns object which can be used to render tooltip's text content. * * @param content Content to render in tooltip. * @returns {ITooltipProps} Tooltip properties. */ static renderContent(content) { return { onRenderContent: () => react_1.default.createElement("span", null, content ?? ''), styles: UITooltipUtils.getStyles() }; } /** * Method returns object which can be used to render tooltip's content with custom HTML content. * * @param content HTML content to render in tooltip. * @returns {ITooltipProps} Tooltip properties. */ static renderHTMLContent(content) { const sanitized = (0, sanitize_html_1.default)(content); return { onRenderContent: () => react_1.default.createElement("span", { dangerouslySetInnerHTML: { __html: sanitized } }), styles: UITooltipUtils.getStyles() }; } } exports.UITooltipUtils = UITooltipUtils; //# sourceMappingURL=UITooltipUtils.js.map