"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Cell = exports.Row = exports.Rows = exports.Header = exports.ActionButton = exports.Toolbar = exports.List = void 0;

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

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

var _ramda = require("ramda");

require("./List.css");

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); }

var List = function List(_ref) {
  var children = _ref.children;
  return _react.default.createElement("div", null, children);
};

exports.List = List;

var Toolbar = function Toolbar(_ref2) {
  var title = _ref2.title,
      children = _ref2.children;
  return _react.default.createElement("div", {
    className: "vs-list-toolbar vs-toolbar-widget-header"
  }, title && _react.default.createElement("span", {
    className: "vs-list-toolbar-title"
  }, title), children);
};

exports.Toolbar = Toolbar;
Toolbar.propTypes = {
  title: _propTypes.default.string
};

var ActionButton = function ActionButton(_ref3) {
  var icon = _ref3.icon,
      className = _ref3.className,
      onClick = _ref3.onClick;
  return _react.default.createElement("span", {
    className: "".concat(icon, " ").concat(className),
    onClick: onClick
  });
};

exports.ActionButton = ActionButton;
ActionButton.propTypes = {
  icon: _propTypes.default.string.isRequired,
  className: _propTypes.default.string,
  onClick: _propTypes.default.func.isRequired
};
ActionButton.defaultProps = {
  className: ''
};

var renderHeaderCell = function renderHeaderCell(_ref4) {
  var width = _ref4.width,
      alignment = _ref4.alignment,
      text = _ref4.text;
  return _react.default.createElement(Cell, {
    key: text,
    width: width
  }, _react.default.createElement("div", {
    className: "vs-list-header-label text-".concat(alignment || 'left')
  }, text));
};

var Header = function Header(_ref5) {
  var labels = _ref5.labels;
  return _react.default.createElement("div", {
    className: "vs-list-header"
  }, _react.default.createElement(Row, null, (0, _ramda.map)(renderHeaderCell, labels)));
};

exports.Header = Header;
Header.propTypes = {
  labels: _propTypes.default.arrayOf(_propTypes.default.shape({
    alignment: _propTypes.default.oneOf(['left', 'center', 'right']),
    width: _propTypes.default.number,
    text: _propTypes.default.string.isRequired
  })).isRequired
};

var Rows = function Rows(_ref6) {
  var children = _ref6.children;
  return _react.default.createElement("div", {
    className: "vs-list-rows"
  }, children);
};

exports.Rows = Rows;

var Row = function Row(props) {
  return _react.default.createElement("div", _extends({
    className: "vs-list-row"
  }, (0, _ramda.omit)(['children', 'expansion'], props)), _react.default.createElement("div", {
    className: "container-fluid"
  }, _react.default.createElement("div", {
    className: "row"
  }, props.children), props.expansion && _react.default.createElement(ExpandedRowPanel, null, props.expansion)));
};

exports.Row = Row;

var ExpandedRowPanel = function ExpandedRowPanel(_ref7) {
  var children = _ref7.children;
  return _react.default.createElement("div", {
    className: "vs-list-row-expanded"
  }, children);
};

var Cell = function Cell(_ref8) {
  var width = _ref8.width,
      children = _ref8.children;
  return _react.default.createElement("div", {
    className: "vs-list-cell col-xs-".concat(width || 1)
  }, children);
};

exports.Cell = Cell;
Cell.propTypes = {
  width: _propTypes.default.number
};