UNPKG

@arche-mc2/arche-controls

Version:

We know that there are a ton of react UI library projects to choose from. Our hope with this one is to provide the next generation of react components that you can use to bootstrap your next project, or as a reference for building a UIKit. Read on to get

85 lines 3.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var React = require("react"); var react_1 = require("react"); var classNames = require("classnames"); var ReactTooltip = require("react-tooltip"); var utils_1 = require("../../../Common/utils"); var styles_1 = require("./styles"); var theming_1 = require("../../../Common/theming"); var UpTooltip = (function (_super) { tslib_1.__extends(UpTooltip, _super); function UpTooltip(props) { var _this = _super.call(this, props) || this; _this.getContent = function () { return (React.createElement("div", { className: 'up-tooltip-content' }, _this.props.title != null && React.createElement("div", { className: 'up-tooltip-header' }, _this.props.title), React.createElement("div", { className: 'up-tooltip-body' }, _this.props.content))); }; return _this; } ; UpTooltip.prototype.componentDidUpdate = function () { ReactTooltip.rebuild(); }; ; UpTooltip.prototype.render = function () { var _a = this.props, id = _a.id, children = _a.children, content = _a.content, others = tslib_1.__rest(_a, ["id", "children", "content"]); var tooltipId = id; if (!tooltipId) { tooltipId = utils_1.generateId(); } ; var childrenWithProps = null; var childrenAsFunction = null; if (children != null && utils_1.isFunction(children)) { childrenAsFunction = children; } else { childrenWithProps = React.Children.map(children, function (child) { if (React.isValidElement(child)) { return React.cloneElement(child, { 'dataFor': tooltipId }); } else { return child; } }); } ; var renderChildren = (React.createElement(React.Fragment, null, childrenWithProps && childrenWithProps, childrenAsFunction && childrenAsFunction({ id: tooltipId, }))); if (utils_1.isEmpty(content)) { return renderChildren; } ; return (React.createElement("div", { className: styles_1.upToolTipWrapper }, renderChildren, React.createElement(ReactTooltip, tslib_1.__assign({ offset: this.props.place === 'bottom' ? { right: 85, top: 5 } : {}, className: classNames('up-tooltip', styles_1.getStyles(this.props)), id: tooltipId, getContent: this.getContent, eventOff: 'click', globalEventOff: 'click' }, others)))); }; ; UpTooltip.defaultProps = { content: '', place: 'right', effect: 'float', type: 'light', multiline: false, html: false, delayHide: 500, delayShow: 500, disable: false, theme: theming_1.default, }; return UpTooltip; }(react_1.Component)); exports.UpTooltip = UpTooltip; ; exports.default = theming_1.withTheme(UpTooltip); //# sourceMappingURL=UpTooltip.js.map