"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.SlidingPanelDropdown = exports.SlidingPanelSection = exports.SlidingPanelHeader = exports.SlidingPanel = exports.ToggleIcon = void 0;

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

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

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

require("./SlidingPanel.css");

var _FilterVariantIcon = _interopRequireDefault(require("mdi-react/FilterVariantIcon"));

var _ArrowRightIcon = _interopRequireDefault(require("mdi-react/ArrowRightIcon"));

var _ChevronRightIcon = _interopRequireDefault(require("mdi-react/ChevronRightIcon"));

var _Button = require("../Button.js");

var R = _interopRequireWildcard(require("ramda"));

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

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }

function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }

function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }

var Badge = function Badge(_ref) {
  var children = _ref.children;
  return _react.default.createElement("div", {
    className: "vs-badge"
  }, children);
};

var removeUnrelatedProps = R.omit(["initialActive", "syncStateToOpen", "expandFilterDropdown", "hideFilterDropdown", "toggleSlidingPanel", "setSlidingPanelActiveState"]);

var ToggleIcon = function ToggleIcon(_ref2) {
  var onClick = _ref2.onClick,
      hoverText = _ref2.hoverText,
      toggleIconState = _ref2.toggleIconState,
      className = _ref2.className,
      restProps = _objectWithoutProperties(_ref2, ["onClick", "hoverText", "toggleIconState", "className"]);

  var Icon = toggleIconState ? _ArrowRightIcon.default : _FilterVariantIcon.default;
  return _react.default.createElement("a", _extends({}, restProps, {
    className: "vs-sliding-panel-toggle-icon ".concat(className),
    onClick: onClick,
    title: hoverText
  }), _react.default.createElement(_Button.Button, {
    type: "inline-outline-secondary"
  }, _react.default.createElement(Icon, {
    className: "vs-sliding-panel-section-icon"
  })));
};

exports.ToggleIcon = ToggleIcon;
ToggleIcon.propTypes = {
  onClick: _propTypes.default.func.isRequired,
  toggleIconState: _propTypes.default.bool,
  hoverText: _propTypes.default.string,
  label: _propTypes.default.string
};

var SlidingPanel = function SlidingPanel(_ref3) {
  var _ref3$className = _ref3.className,
      className = _ref3$className === void 0 ? '' : _ref3$className,
      children = _ref3.children,
      active = _ref3.active,
      restProps = _objectWithoutProperties(_ref3, ["className", "children", "active"]);

  return _react.default.createElement("div", _extends({
    className: (0, _classnames.default)("".concat(className, " vs-sliding-panel"), {
      'vs-active': active
    })
  }, removeUnrelatedProps(restProps)), _react.default.createElement("ul", {
    className: "vs-force-sliding-panel-width"
  }, children));
};

exports.SlidingPanel = SlidingPanel;
SlidingPanel.propTypes = {
  children: _propTypes.default.any,
  active: _propTypes.default.bool
};

var SlidingPanelHeader = function SlidingPanelHeader(_ref4) {
  var _ref4$className = _ref4.className,
      className = _ref4$className === void 0 ? '' : _ref4$className,
      children = _ref4.children,
      restProps = _objectWithoutProperties(_ref4, ["className", "children"]);

  return _react.default.createElement("li", _extends({
    className: "".concat(className, " vs-sliding-panel-header")
  }, restProps), children);
};

exports.SlidingPanelHeader = SlidingPanelHeader;
SlidingPanelHeader.propTypes = {
  children: _propTypes.default.any,
  className: _propTypes.default.string
};

var SlidingPanelSection = function SlidingPanelSection(_ref5) {
  var _ref5$className = _ref5.className,
      className = _ref5$className === void 0 ? '' : _ref5$className,
      children = _ref5.children,
      restProps = _objectWithoutProperties(_ref5, ["className", "children"]);

  return _react.default.createElement("li", _extends({
    className: "".concat(className, " vs-sliding-panel-section")
  }, restProps), children);
};

exports.SlidingPanelSection = SlidingPanelSection;
SlidingPanelSection.propTypes = {
  children: _propTypes.default.any
};

var SlidingPanelDropdown = function SlidingPanelDropdown(_ref6) {
  var _ref6$className = _ref6.className,
      className = _ref6$className === void 0 ? '' : _ref6$className,
      label = _ref6.label,
      children = _ref6.children,
      onClick = _ref6.onClick,
      badge = _ref6.badge,
      expanded = _ref6.expanded,
      _ref6$id = _ref6.id,
      id = _ref6$id === void 0 ? '' : _ref6$id,
      restProps = _objectWithoutProperties(_ref6, ["className", "label", "children", "onClick", "badge", "expanded", "id"]);

  var containerClasses = (0, _classnames.default)("".concat(className, " vs-sliding-panel-section-container"), {
    'vs-expanded': expanded
  });
  var optionsClasses = (0, _classnames.default)('vs-sliding-panel-section-options', {
    'vs-expanded': expanded
  });
  return _react.default.createElement("ul", _extends({
    className: containerClasses,
    id: id
  }, removeUnrelatedProps(restProps)), _react.default.createElement("li", null, _react.default.createElement("a", {
    onClick: onClick,
    className: "vs-sliding-panel-section-container-label"
  }, _react.default.createElement("div", {
    className: "vs-sliding-panel-section-label"
  }, label, badge && _react.default.createElement(Badge, null, badge)), _react.default.createElement("div", {
    className: "vs-sliding-panel-chevron-container"
  }, _react.default.createElement(_ChevronRightIcon.default, null)))), _react.default.createElement("ul", null, _react.default.createElement("div", {
    className: optionsClasses
  }, children)));
};

exports.SlidingPanelDropdown = SlidingPanelDropdown;
SlidingPanelDropdown.propTypes = {
  id: _propTypes.default.string,
  children: _propTypes.default.any,
  label: _propTypes.default.any,
  onClick: _propTypes.default.func,
  expanded: _propTypes.default.bool
};