"use strict";

exports.__esModule = true;
exports.default = exports.HeadBox = exports.TableHeader = exports.SortMark = exports.MarkBox = exports.DownMark = exports.UpMark = void 0;

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

var _styledComponents = _interopRequireWildcard(require("styled-components"));

var _Text = _interopRequireDefault(require("../Text"));

var _Checkbox = _interopRequireDefault(require("../Checkbox"));

var _utils = require("../../utils");

function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }

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

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

(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();

(function () {
  var enterModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.enterModule : undefined;
  enterModule && enterModule(module);
})();

var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};

var __signature__ = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default.signature : function (a) {
  return a;
};

var UpMark = _styledComponents.default.div.withConfig({
  displayName: "HeadCell__UpMark",
  componentId: "sc-1vadnsc-0"
})(["display:inline-block;margin:0.05em;margin-left:0.5em;height:0;border:0.25em solid transparent;border-top-width:0;border-bottom-color:", ";"], (0, _utils.getThemeProp)(["colors", "border"], "#999999"));

exports.UpMark = UpMark;

var DownMark = _styledComponents.default.div.withConfig({
  displayName: "HeadCell__DownMark",
  componentId: "sc-1vadnsc-1"
})(["display:inline-block;margin:0.05em;margin-left:0.5em;height:0;border:0.25em solid transparent;border-bottom-width:0;border-top-color:", ";"], (0, _utils.getThemeProp)(["colors", "border"], "#999999"));

exports.DownMark = DownMark;

var MarkBox = _styledComponents.default.div.withConfig({
  displayName: "HeadCell__MarkBox",
  componentId: "sc-1vadnsc-2"
})(["display:flex;flex-direction:column;justify-content:space-around;"]);

exports.MarkBox = MarkBox;

var SortMark = function SortMark(_ref) {
  var direction = _ref.direction;

  switch (direction) {
    case "desc":
      return /*#__PURE__*/_react.default.createElement(DownMark, null);

    case "asc":
      return /*#__PURE__*/_react.default.createElement(UpMark, null);

    default:
      return /*#__PURE__*/_react.default.createElement(MarkBox, null, /*#__PURE__*/_react.default.createElement(UpMark, null), /*#__PURE__*/_react.default.createElement(DownMark, null));
  }
};

exports.SortMark = SortMark;

var TableHeader = _styledComponents.default.th.withConfig({
  displayName: "HeadCell__TableHeader",
  componentId: "sc-1vadnsc-3"
})(["background-color:#f7f7f7;position:sticky;top:0;z-index:10;padding:0;", ";", ";"], (0, _utils.ifFlag)("select", (0, _styledComponents.css)(["width:56px;"])), (0, _utils.ifFlag)("width", (0, _styledComponents.css)(["width:", ";"], function (props) {
  return props.width + "";
})));

exports.TableHeader = TableHeader;

var HeadBox = _styledComponents.default.div.withConfig({
  displayName: "HeadCell__HeadBox",
  componentId: "sc-1vadnsc-4"
})(["display:flex;align-items:center;height:20px;width:calc(100% - 40px);padding:10px 20px;border-bottom:1px solid ", ";& > span{overflow-x:hidden;white-space:nowrap;text-overflow:ellipsis;}"], (0, _utils.getThemeProp)(["colors", "borderLight"], "#cccccc"));

exports.HeadBox = HeadBox;

var HeadCell = function HeadCell(_ref2) {
  var columnDef = _ref2.columnDef,
      _ref2$rowIds = _ref2.rowIds,
      rowIds = _ref2$rowIds === void 0 ? [] : _ref2$rowIds,
      allSelected = _ref2.allSelected;
  return /*#__PURE__*/_react.default.createElement(TableHeader, {
    onClick: columnDef.sort,
    select: columnDef.type === "select",
    width: columnDef.width
  }, /*#__PURE__*/_react.default.createElement(HeadBox, null, columnDef.type === "select" ? /*#__PURE__*/_react.default.createElement(_Checkbox.default, {
    id: "select_headRow",
    value: !!allSelected,
    onChange: function onChange() {
      return columnDef.onChange(allSelected ? [] : rowIds);
    }
  }) : columnDef.label ? [/*#__PURE__*/_react.default.createElement(_Text.default, {
    key: "msg",
    message: columnDef.label
  }), columnDef.sort ? /*#__PURE__*/_react.default.createElement(SortMark, {
    key: "sort",
    direction: columnDef.sortDirection
  }) : null] : null));
};

var _default = HeadCell;
var _default2 = _default;
var _default3 = _default2;
exports.default = _default3;
;

(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;

  if (!reactHotLoader) {
    return;
  }

  reactHotLoader.register(UpMark, "UpMark", "/home/vsts/work/1/s/src/components/List/HeadCell.js");
  reactHotLoader.register(DownMark, "DownMark", "/home/vsts/work/1/s/src/components/List/HeadCell.js");
  reactHotLoader.register(MarkBox, "MarkBox", "/home/vsts/work/1/s/src/components/List/HeadCell.js");
  reactHotLoader.register(SortMark, "SortMark", "/home/vsts/work/1/s/src/components/List/HeadCell.js");
  reactHotLoader.register(TableHeader, "TableHeader", "/home/vsts/work/1/s/src/components/List/HeadCell.js");
  reactHotLoader.register(HeadBox, "HeadBox", "/home/vsts/work/1/s/src/components/List/HeadCell.js");
  reactHotLoader.register(HeadCell, "HeadCell", "/home/vsts/work/1/s/src/components/List/HeadCell.js");
  reactHotLoader.register(_default, "default", "/home/vsts/work/1/s/src/components/List/HeadCell.js");
})();

;

(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();

;

(function () {
  var reactHotLoader = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.default : undefined;

  if (!reactHotLoader) {
    return;
  }

  reactHotLoader.register(UpMark, "UpMark", "/home/vsts/work/1/s/src/components/List/HeadCell.js");
  reactHotLoader.register(DownMark, "DownMark", "/home/vsts/work/1/s/src/components/List/HeadCell.js");
  reactHotLoader.register(MarkBox, "MarkBox", "/home/vsts/work/1/s/src/components/List/HeadCell.js");
  reactHotLoader.register(SortMark, "SortMark", "/home/vsts/work/1/s/src/components/List/HeadCell.js");
  reactHotLoader.register(TableHeader, "TableHeader", "/home/vsts/work/1/s/src/components/List/HeadCell.js");
  reactHotLoader.register(HeadBox, "HeadBox", "/home/vsts/work/1/s/src/components/List/HeadCell.js");
  reactHotLoader.register(HeadCell, "HeadCell", "/home/vsts/work/1/s/src/components/List/HeadCell.js");
  reactHotLoader.register(_default2, "default", "/home/vsts/work/1/s/src/components/List/HeadCell.js");
})();

;

(function () {
  var leaveModule = typeof reactHotLoaderGlobal !== 'undefined' ? reactHotLoaderGlobal.leaveModule : undefined;
  leaveModule && leaveModule(module);
})();