"use strict";

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

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.default = exports.Item = void 0;

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

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

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

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

var _propTypes = _interopRequireDefault(require("prop-types"));

var _classnames2 = _interopRequireDefault(require("classnames"));

var _js = require("../../globals/js");

var _iconsReact = require("@wfp/icons-react");

var _excluded = ["active", "additional", "button", "children", "className", "href", "subContent", "image", "hint", "noImage", "showAdditionalIcon", "title", "kind", "wrapper"];
var prefix = _js.settings.prefix;

/** The item component to show entries inside a list, like a sidebar or an overview page. */
var Item = function Item(_ref) {
  var _classnames;

  var active = _ref.active,
      additional = _ref.additional,
      button = _ref.button,
      children = _ref.children,
      className = _ref.className,
      href = _ref.href,
      subContent = _ref.subContent,
      image = _ref.image,
      hint = _ref.hint,
      noImage = _ref.noImage,
      showAdditionalIcon = _ref.showAdditionalIcon,
      title = _ref.title,
      _ref$kind = _ref.kind,
      kind = _ref$kind === void 0 ? 'large' : _ref$kind,
      _ref$wrapper = _ref.wrapper,
      wrapper = _ref$wrapper === void 0 ? 'none' : _ref$wrapper,
      other = (0, _objectWithoutProperties2.default)(_ref, _excluded);
  var classNames = (0, _classnames2.default)((_classnames = {}, (0, _defineProperty2.default)(_classnames, "".concat(prefix, "--item"), true), (0, _defineProperty2.default)(_classnames, "".concat(prefix, "--item--").concat(kind), kind), (0, _defineProperty2.default)(_classnames, "".concat(prefix, "--item--").concat(wrapper), wrapper), (0, _defineProperty2.default)(_classnames, "".concat(prefix, "--item--active"), active), _classnames), className);
  return /*#__PURE__*/_react.default.createElement("div", (0, _extends2.default)({
    className: classNames
  }, other), image ? /*#__PURE__*/_react.default.createElement("div", {
    className: "".concat(prefix, "--item__image")
  }, image) : noImage ? /*#__PURE__*/_react.default.createElement("div", {
    className: "".concat(prefix, "--item__image ").concat(prefix, "--item__image-empty")
  }) : null, /*#__PURE__*/_react.default.createElement("div", {
    className: "".concat(prefix, "--item__content")
  }, title && /*#__PURE__*/_react.default.createElement("div", {
    className: "".concat(prefix, "--item__title-wrapper")
  }, /*#__PURE__*/_react.default.createElement("h2", {
    className: "".concat(prefix, "--item__title")
  }, title), additional && /*#__PURE__*/_react.default.createElement("div", {
    className: "".concat(prefix, "--item__additional")
  }, additional, showAdditionalIcon && /*#__PURE__*/_react.default.createElement(_iconsReact.ChevronRight16, {
    className: "".concat(prefix, "--item__additional-icon")
  }))), /*#__PURE__*/_react.default.createElement("div", {
    className: "".concat(prefix, "--item__text-wrapper")
  }, /*#__PURE__*/_react.default.createElement("div", {
    className: "".concat(prefix, "--item__text-wrapper__inner")
  }, children && /*#__PURE__*/_react.default.createElement("div", {
    className: "".concat(prefix, "--item__text")
  }, children), subContent && /*#__PURE__*/_react.default.createElement("div", {
    className: "".concat(prefix, "--item__sub-content")
  }, subContent)), /*#__PURE__*/_react.default.createElement("div", {
    className: "".concat(prefix, "--item__right")
  }, hint && /*#__PURE__*/_react.default.createElement("div", {
    className: "".concat(prefix, "--item__hint")
  }, hint)))));
};

exports.Item = Item;
Item.propTypes = {
  /**
   * Provide the description for the item content
   */
  children: _propTypes.default.node,

  /**
   * Provide the title for the item contet
   */
  title: _propTypes.default.node,

  /**
   * Provide the icon for the item content
   */
  icon: _propTypes.default.node,

  /**
   * Provide one or multiple buttons
   */
  button: _propTypes.default.node,

  /**
   * Provide a custom className to be applied to the containing <a> node
   */
  className: _propTypes.default.string,

  /**
   * Provide a kind to use different appearances.
   */
  kind: _propTypes.default.oneOf(['undefined', 'horizontal', 'large']),

  /**
   * Provide a wrap to use different borders.
   */
  wrapper: _propTypes.default.oneOf(['undefined', 'sidebar', 'repeater'])
};
var _default = Item;
exports.default = _default;