cpui-components
Version:
58 lines (44 loc) • 2.45 kB
JavaScript
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Tag = undefined;
var _react = require("react");
var _react2 = _interopRequireDefault(_react);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
var Tag = exports.Tag = function (_Component) {
_inherits(Tag, _Component);
function Tag(props) {
_classCallCheck(this, Tag);
var _this = _possibleConstructorReturn(this, (Tag.__proto__ || Object.getPrototypeOf(Tag)).call(this, props));
_this.render = function () {
var tagType = _this.state.type + "";
var tagIsRemovable = _this.state.isRemovable;
return _react2.default.createElement(
"div",
{ className: "cp-tag " + (tagType.toLowerCase() === "contenttype" ? 'cp-tag--contentType' : tagType.toLowerCase() === "super" || tagType.toLowerCase() === "supertag" ? 'cp-tag--superTag' : '') + " " + (tagIsRemovable ? 'cp-tag--removable' : '') + " " + (_this.state.isDraggable ? 'cp-tag--draggable' : '') },
_this.props.children,
tagIsRemovable ? _react2.default.createElement(
"button",
{ className: "cp-tag-remove", "aria-label": "Remove Tag", title: "Remove Tag" },
_react2.default.createElement(
"svg",
null,
_react2.default.createElement("use", { xlinkHref: "#iconClose" })
)
) : ''
);
};
_this.state = {
isRemovable: _this.props.removable,
isDraggable: _this.props.draggable,
type: _this.props.type
};
return _this;
}
return Tag;
}(_react.Component);
exports.default = Tag;
;