UNPKG

igniteui-react-core

Version:
108 lines (107 loc) 4.05 kB
/* THIS INFRAGISTICS ULTIMATE SOFTWARE LICENSE AGREEMENT ("AGREEMENT") LOCATED HERE: https://www.infragistics.com/legal/license/igultimate-la https://www.infragistics.com/legal/license/igultimate-eula GOVERNS THE LICENSING, INSTALLATION AND USE OF INFRAGISTICS SOFTWARE. BY DOWNLOADING AND/OR INSTALLING AND USING INFRAGISTICS SOFTWARE: you are indicating that you have read and understand this Agreement, and agree to be legally bound by it on behalf of the yourself and your company. */ import * as React from 'react'; import { IgrTemplateContent } from './igr-template-content'; import { FontDefaults } from "./FontDefaults"; let requiredStyle = ` .ig-tooltip-container { padding: 5px; padding: var(--tooltip-container-padding, 5px); background-color: white; background-color: var(--tooltip-container-background-color, white); border-style: solid; border-style: var(--tooltip-container-border-style, solid); border-width: 1px; border-width: var(--tooltip-container-border-width, 1px); color: ${FontDefaults.tooltipLabelsBrush.fill}; color: var(--tooltip-container-text-color, ${FontDefaults.tooltipLabelsBrush.fill}); pointer-events: none; white-space: nowrap; border-color: #666; border-color: var(--tooltip-container-border-color, #666); font: ${FontDefaults.tooltipLabelsFontSize}px ${FontDefaults.tooltipLabelsFontFamily}; font: var(--tooltip-container-font, ${FontDefaults.tooltipLabelsFontSize}px ${FontDefaults.tooltipLabelsFontFamily}); } `; let checked = /*@__PURE__*/ new WeakMap(); function ensureCss() { if (!document) { return; } if (checked.has(document)) { return; } for (let i = document.head.children.length - 1; i >= 0; i--) { let child = document.head.children[i]; if (child.tagName && child.tagName.toLowerCase() == "style" && child.hasAttribute("data-ig-tooltip-style")) { return; } } let style = document.createElement("style"); style.textContent = requiredStyle; style.setAttribute('data-ig-tooltip-style', 'true'); document.head.appendChild(style); checked.set(document, true); } export class IgrTooltipContainer extends React.Component { constructor(props) { super(props); this._template = null; this._containerTemplate = null; this._dataContext = null; ensureCss(); if (props.owner) { this._currentOwner = props.owner; } } render() { if (!this._template || !this._dataContext || !this.dataContext.item) { return null; } let ele = React.createElement(IgrTemplateContent, { dataContext: this._dataContext, template: this._template }); if (this._containerTemplate !== null) { } else { return (React.createElement("div", { className: 'ig-tooltip-container igr-tooltip-container ig-tooltip-container-background', style: {} }, ele)); } return ele; } get currentOwner() { return this._currentOwner; } shouldComponentUpdate(nextProps, nextState) { if (nextProps.owner !== undefined) { this._currentOwner = nextProps.owner; } return true; } set template(value) { this._template = value; this.setState({ template: this._template }); } get template() { return this._template; } set containerTemplate(value) { this._containerTemplate = value; this.setState({ containerTemplate: this._containerTemplate }); } get containerTemplate() { return this._containerTemplate; } set dataContext(value) { if (this._dataContext == null && value == null) { return; } this._dataContext = value; this.setState({ dataContext: this._dataContext }); } get dataContext() { return this._dataContext; } }