"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _react = _interopRequireDefault(require("react"));
var _Focusable = require("../common/Focusable");
var _wixUiIconsCommon = require("@wix/wix-ui-icons-common");
var _SidebarSectionItemSt = require("./SidebarSectionItem.st.css.js");
var _constants = require("./constants");
var _Text = _interopRequireDefault(require("../Text"));
var _SidebarAPI = require("../Sidebar/SidebarAPI");
var _constants2 = require("../Sidebar/constants");
var _jsxFileName = "/home/builduser/work/57e038ea7326c1ec/packages/wix-design-system/dist/cjs/SidebarSectionItem/SidebarSectionItem.jsx";
function _callSuper(t, o, e) { return o = (0, _getPrototypeOf2["default"])(o), (0, _possibleConstructorReturn2["default"])(t, _isNativeReflectConstruct() ? Reflect.construct(o, e || [], (0, _getPrototypeOf2["default"])(t).constructor) : o.apply(t, e)); }
function _isNativeReflectConstruct() { try { var t = !Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); } catch (t) {} return (_isNativeReflectConstruct = function _isNativeReflectConstruct() { return !!t; })(); }
/** An item for the section within the sidebar */
var SidebarSectionItem = /*#__PURE__*/function (_React$PureComponent) {
  function SidebarSectionItem() {
    (0, _classCallCheck2["default"])(this, SidebarSectionItem);
    return _callSuper(this, SidebarSectionItem, arguments);
  }
  (0, _inherits2["default"])(SidebarSectionItem, _React$PureComponent);
  return (0, _createClass2["default"])(SidebarSectionItem, [{
    key: "render",
    value: function render() {
      var _this = this;
      var _this$props = this.props,
        dataHook = _this$props.dataHook,
        children = _this$props.children,
        selected = _this$props.selected,
        disabled = _this$props.disabled,
        drillable = _this$props.drillable,
        alwaysDisplayChevron = _this$props.alwaysDisplayChevron,
        prefix = _this$props.prefix,
        suffix = _this$props.suffix,
        _onClick = _this$props.onClick,
        className = _this$props.className,
        focusableOnFocus = _this$props.focusableOnFocus,
        focusableOnBlur = _this$props.focusableOnBlur,
        itemKey = _this$props.itemKey;
      return /*#__PURE__*/_react["default"].createElement(_SidebarAPI.SidebarContext.Consumer, {
        __self: this,
        __source: {
          fileName: _jsxFileName,
          lineNumber: 31,
          columnNumber: 7
        }
      }, function (context) {
        var skin = context && context.getSkin() || _constants2.sidebarSkins.dark;
        return /*#__PURE__*/_react["default"].createElement("button", {
          "data-hook": dataHook,
          "data-selected": selected,
          "data-always-display-chevron": alwaysDisplayChevron,
          onClick: function onClick(e) {
            if (!disabled) {
              _onClick && _onClick(e);
            }
            if (!e.defaultPrevented) {
              context && context.itemClicked(itemKey);
            }
          },
          onFocus: focusableOnFocus,
          onBlur: focusableOnBlur,
          disabled: disabled,
          type: "button",
          tabIndex: "0",
          className: (0, _SidebarSectionItemSt.st)(_SidebarSectionItemSt.classes.root, {
            selected: selected,
            disabled: disabled,
            prefix: Boolean(prefix),
            suffix: Boolean(suffix),
            drillable: drillable,
            skin: skin,
            alwaysDisplayChevron: alwaysDisplayChevron
          }, className),
          __self: _this,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 35,
            columnNumber: 13
          }
        }, prefix && /*#__PURE__*/_react["default"].createElement("span", {
          "data-hook": _constants.dataHooks.prefix,
          className: _SidebarSectionItemSt.classes.prefix,
          __self: _this,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 67,
            columnNumber: 17
          }
        }, prefix), /*#__PURE__*/_react["default"].createElement("span", {
          className: _SidebarSectionItemSt.classes.textWrapper,
          "data-hook": _constants.dataHooks.title,
          __self: _this,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 71,
            columnNumber: 15
          }
        }, /*#__PURE__*/_react["default"].createElement(_Text["default"], {
          className: _SidebarSectionItemSt.classes.text,
          size: "small",
          weight: "normal",
          secondary: skin === _constants2.sidebarSkins.light,
          light: skin === _constants2.sidebarSkins.dark,
          skin: disabled ? 'disabled' : undefined,
          __self: _this,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 72,
            columnNumber: 17
          }
        }, children)), !disabled && (suffix || drillable) && /*#__PURE__*/_react["default"].createElement("span", {
          "data-hook": _constants.dataHooks.suffix,
          className: _SidebarSectionItemSt.classes.suffix,
          __self: _this,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 84,
            columnNumber: 17
          }
        }, suffix || /*#__PURE__*/_react["default"].createElement(_wixUiIconsCommon.ChevronRight, {
          "data-hook": _constants.dataHooks.chevronRight,
          className: _SidebarSectionItemSt.classes.chevron,
          __self: _this,
          __source: {
            fileName: _jsxFileName,
            lineNumber: 86,
            columnNumber: 21
          }
        })));
      });
    }
  }]);
}(_react["default"].PureComponent);
SidebarSectionItem.displayName = 'SidebarSectionItem';
var _default = exports["default"] = (0, _Focusable.withFocusable)(SidebarSectionItem);