UNPKG

@sap-ux/ui-components

Version:

SAP UI Components Library

51 lines 1.58 kB
import React from 'react'; import sanitizeHtml from 'sanitize-html'; import { CALLOUT_STYLES } from '../UICallout/index.js'; /** * UITooltipUtil class for rendering content * * @class UITooltipUtils */ export class UITooltipUtils { /** * Method returns styles for tooltip content. * * @returns {ITooltipStyles} Object with tooltip styles. */ static getStyles() { return { root: {}, content: { background: CALLOUT_STYLES.background, color: 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.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 = sanitizeHtml(content); return { onRenderContent: () => React.createElement("span", { dangerouslySetInnerHTML: { __html: sanitized } }), styles: UITooltipUtils.getStyles() }; } } //# sourceMappingURL=UITooltipUtils.js.map