"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Tag = exports.TagLabel = exports.TagIcon = exports.TagCloseButton = void 0;

var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));

var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));

var _CloseIcon = _interopRequireDefault(require("mdi-react/CloseIcon"));

var _react = _interopRequireDefault(require("react"));

var _styles = _interopRequireDefault(require("../Badge/styles"));

var _Box = require("../Box");

var _useVariantColorWarning = require("../hooks/useVariantColorWarning");

var _Icon = require("../Icon");

var _PseudoBox = require("../PseudoBox");

var _styles2 = _interopRequireWildcard(require("./styles"));

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }

var __jsx = _react["default"].createElement;

var TagCloseButton = function TagCloseButton(_ref) {
  var isDisabled = _ref.isDisabled,
      props = (0, _objectWithoutProperties2["default"])(_ref, ["isDisabled"]);
  return __jsx(_PseudoBox.PseudoBox, (0, _extends2["default"])({
    as: "button",
    display: "flex",
    alignItems: "center",
    justifyContent: "center",
    transition: "all 0.2s",
    rounded: "full",
    size: "1.25rem",
    outline: "none",
    ml: 1,
    mr: -1,
    opacity: 0.35,
    disabled: isDisabled,
    _disabled: {
      // @ts-ignore
      opacity: '40%',
      cursor: 'not-allowed',
      boxShadow: 'none'
    },
    _focus: {
      boxShadow: 'outline',
      bg: 'rgba(0, 0, 0, 0.14)'
    },
    _hover: {
      opacity: 0.8
    },
    _active: {
      opacity: 1
    }
  }, props), __jsx(_CloseIcon["default"], {
    size: 18,
    focusable: false
  }));
};

exports.TagCloseButton = TagCloseButton;

var TagIcon = function TagIcon(_ref2) {
  var icon = _ref2.icon,
      props = (0, _objectWithoutProperties2["default"])(_ref2, ["icon"]);
  var tagIconStyleProps = (0, _styles2.useTagIconStyle)();

  if (typeof icon === 'string') {
    return __jsx(_Icon.Icon, (0, _extends2["default"])({
      name: icon
    }, tagIconStyleProps, props));
  }

  return __jsx(_Box.Box, (0, _extends2["default"])({
    as: icon,
    focusable: "false",
    color: "currentColor"
  }, tagIconStyleProps, props));
};

exports.TagIcon = TagIcon;

var TagLabel = function TagLabel(props) {
  return __jsx(_Box.Box, (0, _extends2["default"])({
    isTruncated: true,
    lineHeight: "1.2",
    as: "span"
  }, props));
};

exports.TagLabel = TagLabel;

var Tag = function Tag(_ref3) {
  var _ref3$variant = _ref3.variant,
      variant = _ref3$variant === void 0 ? 'subtle' : _ref3$variant,
      _ref3$size = _ref3.size,
      size = _ref3$size === void 0 ? 'lg' : _ref3$size,
      _ref3$variantColor = _ref3.variantColor,
      variantColor = _ref3$variantColor === void 0 ? 'transparent' : _ref3$variantColor,
      rest = (0, _objectWithoutProperties2["default"])(_ref3, ["variant", "size", "variantColor"]);
  (0, _useVariantColorWarning.useVariantColorWarning)('Tag', variantColor);
  var badgeStyleProps = (0, _styles["default"])({
    color: variantColor,
    variant: variant
  });
  var tagStyleProps = (0, _styles2["default"])({
    size: size
  });
  return __jsx(_PseudoBox.PseudoBox, (0, _extends2["default"])({}, badgeStyleProps, {
    display: "inline-flex",
    alignItems: "center",
    maxW: "100%"
  }, tagStyleProps, rest));
};

exports.Tag = Tag;
//# sourceMappingURL=Tag.js.map