'use strict';

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

var _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; };

var _react = require('react');

var _react2 = _interopRequireDefault(_react);

var _propTypes = require('prop-types');

var _propTypes2 = _interopRequireDefault(_propTypes);

var _ramda = require('ramda');

require('./List.css');

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

var List = exports.List = function List(_ref) {
  var children = _ref.children;
  return _react2.default.createElement(
    'div',
    null,
    children
  );
};

var Toolbar = exports.Toolbar = function Toolbar(_ref2) {
  var title = _ref2.title,
      children = _ref2.children;
  return _react2.default.createElement(
    'div',
    { className: 'vs-list-toolbar vs-toolbar-widget-header' },
    title && _react2.default.createElement(
      'span',
      { className: 'vs-list-toolbar-title' },
      title
    ),
    children
  );
};
Toolbar.propTypes = {
  title: _propTypes2.default.string
};

var ActionButton = exports.ActionButton = function ActionButton(_ref3) {
  var icon = _ref3.icon,
      className = _ref3.className,
      onClick = _ref3.onClick;

  return _react2.default.createElement('span', { className: icon + ' ' + className, onClick: onClick });
};
ActionButton.propTypes = {
  icon: _propTypes2.default.string.isRequired,
  className: _propTypes2.default.string,
  onClick: _propTypes2.default.func.isRequired
};
ActionButton.defaultProps = {
  className: ''
};

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

var Header = exports.Header = function Header(_ref5) {
  var labels = _ref5.labels;
  return _react2.default.createElement(
    'div',
    { className: 'vs-list-header' },
    _react2.default.createElement(
      Row,
      null,
      (0, _ramda.map)(renderHeaderCell, labels)
    )
  );
};
Header.propTypes = {
  labels: _propTypes2.default.arrayOf(_propTypes2.default.shape({
    alignment: _propTypes2.default.oneOf(['left', 'center', 'right']),
    width: _propTypes2.default.number,
    text: _propTypes2.default.string.isRequired
  })).isRequired
};

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

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

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

var Cell = exports.Cell = function Cell(_ref8) {
  var width = _ref8.width,
      children = _ref8.children;
  return _react2.default.createElement(
    'div',
    { className: 'vs-list-cell col-xs-' + (width || 1) },
    children
  );
};
Cell.propTypes = {
  width: _propTypes2.default.number
};