"use strict";

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

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

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

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

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

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

var _Icon = _interopRequireDefault(require("../Icon"));

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

var _excluded = ["className", "isSorted", "isSortedDesc", "sortType"];

function TableSorting(_ref) {
  var className = _ref.className,
      isSorted = _ref.isSorted,
      isSortedDesc = _ref.isSortedDesc,
      sortType = _ref.sortType,
      other = (0, _objectWithoutProperties2.default)(_ref, _excluded);
  var classes = (0, _classnames.default)(className, 'wfp--table--sorting', {
    'wfp--table--is-sorted': isSorted,
    'wfp--table--is-sortable': sortType
  });
  return /*#__PURE__*/_react.default.createElement("span", {
    className: classes
  }, isSorted ? isSortedDesc ? /*#__PURE__*/_react.default.createElement(_iconsReact.CaretDown16, null) : /*#__PURE__*/_react.default.createElement(_iconsReact.CaretUp16, null) : '');
}

TableSorting.propTypes = {
  /**
   * Provide the content for the Table, usually `<thead />` or `<tbody/>`
   */
  children: _propTypes.default.node,

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

  /**
   * Displays a border around the  <table /> node
   */
  withBorder: _propTypes.default.bool
};