UNPKG

cosmo-ui

Version:
47 lines 2.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var React = require("react"); var cx = require("classnames"); var flex_1 = require("./flex"); var row_1 = require("./row"); var icon_1 = require("./icon"); var styles = require('../../src/styles/components/tray-item.scss'); var TrayItem = (function (_super) { tslib_1.__extends(TrayItem, _super); function TrayItem() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.setContainerRef = function (e) { return _this.container = e; }; return _this; } TrayItem.prototype.render = function () { var _a = this.props, id = _a.id, style = _a.style, children = _a.children, icon = _a.icon, iconSize = _a.iconSize, text = _a.text, onClick = _a.onClick, tooltip = _a.tooltip, input = _a.input, selected = _a.selected; return (React.createElement("div", { id: id, ref: this.setContainerRef, className: this.classNames(), style: style, onClick: onClick, "data-tooltip": !text ? tooltip : undefined, "data-tooltip-pos": "right" }, icon !== undefined ? React.createElement(icon_1.Icon, { icon: icon, size: iconSize || (input ? 14 : 18) }) : null, text !== undefined ? React.createElement("a", { "data-tooltip": tooltip }, text) : null, children)); }; TrayItem.prototype.classNames = function () { return cx(_super.prototype.classNames.call(this), styles.item, (_a = {}, _a[styles.primary] = this.props.primary, _a[styles.secondary] = this.props.secondary, _a[styles.active] = this.props.active, _a[styles.stroke] = this.props.stroke, _a[styles.onClick] = typeof this.props.onClick === 'function', _a[styles.disabled] = this.props.disabled, _a[styles.input] = this.props.input, _a[styles.dynamic] = this.props.dynamic, _a[styles.selected] = this.props.selected, _a[styles.disabledStroke] = this.props.disabled && this.props.stroke, _a)); var _a; }; return TrayItem; }(flex_1.Flex)); TrayItem.defaultProps = tslib_1.__assign({}, row_1.Row.defaultProps, { fullWidth: false, justify: 'center' }); exports.TrayItem = TrayItem; //# sourceMappingURL=tray-item.js.map