UNPKG

@atlaskit/editor-core

Version:

A package contains Atlassian editor core functionality

42 lines 2.02 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var tooltip_1 = require("@atlaskit/tooltip"); var React = require("react"); var react_1 = require("react"); var styles_1 = require("./styles"); var ToolbarButton = (function (_super) { tslib_1.__extends(ToolbarButton, _super); function ToolbarButton() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.state = { isTooltipVisible: false }; _this.handleClick = function () { var _a = _this.props, disabled = _a.disabled, onClick = _a.onClick; if (!disabled && onClick) { onClick(); } _this.setState({ isTooltipVisible: false }); }; _this.handleMouseOver = function () { _this.setState({ isTooltipVisible: true }); }; _this.handleMouseOut = function () { _this.setState({ isTooltipVisible: false }); }; return _this; } ToolbarButton.prototype.render = function () { var button = (React.createElement(styles_1.AkButton, { className: "" + this.props.className, ariaHaspopup: true, isDisabled: this.props.disabled, isSelected: this.props.selected, spacing: this.props.spacing || 'none', appearance: "subtle", href: this.props.href, onClick: this.handleClick, target: this.props.target, theme: this.props.theme, iconBefore: this.props.iconBefore, iconAfter: this.props.iconAfter }, this.props.children)); return this.props.title ? (React.createElement(tooltip_1.Tooltip, { position: this.props.titlePosition || 'top', description: this.props.title, visible: this.state.isTooltipVisible, onMouseOver: this.handleMouseOver, onMouseOut: this.handleMouseOut }, button)) : button; }; return ToolbarButton; }(react_1.PureComponent)); ToolbarButton.defaultProps = { className: '', }; exports.default = ToolbarButton; //# sourceMappingURL=index.js.map