import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
import _createClass from "@babel/runtime/helpers/createClass";
import _inherits from "@babel/runtime/helpers/inherits";
import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
var _excluded = ["children", "className", "onRemoveClick", "size"];

function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }

function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }

import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import IconButton from '../iconButton';
import Box from '../box';
import { UITextBody, UITextSmall, UITextDisplay } from '../typography';
import cx from 'classnames';
import theme from './theme.css';
import { IconCloseSmallOutline } from '@teamleader/ui-icons';
/** @type {React.ComponentType<any>} */

var Tag = /*#__PURE__*/function (_PureComponent) {
  _inherits(Tag, _PureComponent);

  var _super = _createSuper(Tag);

  function Tag() {
    _classCallCheck(this, Tag);

    return _super.apply(this, arguments);
  }

  _createClass(Tag, [{
    key: "render",
    value: function render() {
      var _this$props = this.props,
          children = _this$props.children,
          className = _this$props.className,
          onRemoveClick = _this$props.onRemoveClick,
          size = _this$props.size,
          others = _objectWithoutProperties(_this$props, _excluded);

      var classNames = cx(theme["is-".concat(size)], theme['wrapper'], className);
      var TextElement = size === 'small' ? UITextSmall : size === 'large' ? UITextDisplay : UITextBody;
      return /*#__PURE__*/React.createElement(Box, _extends({}, others, {
        className: classNames,
        "data-teamleader-ui": "tag",
        display: "inline-flex"
      }), /*#__PURE__*/React.createElement(TextElement, {
        color: "teal",
        marginLeft: size === 'small' ? 2 : 3,
        marginRight: onRemoveClick ? 1 : size === 'small' ? 2 : 3,
        marginVertical: size === 'small' ? 0 : 1,
        maxLines: 1,
        tint: "darkest"
      }, children), onRemoveClick && /*#__PURE__*/React.createElement(IconButton, {
        className: theme['remove-button'],
        flexShrink: 0,
        icon: /*#__PURE__*/React.createElement(IconCloseSmallOutline, null),
        onClick: onRemoveClick
      }));
    }
  }]);

  return Tag;
}(PureComponent);

Tag.defaultProps = {
  size: 'medium'
};
export default Tag;