import { jsx as ___EmotionJSX } from "@emotion/core";

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

import React from 'react';
import PropTypes from 'prop-types';
import { css } from '@emotion/core';
import OffClickWrapper from '../offClickWrapper';
import ChevronIcon from '../../svgs/icons/chevron-icon.svg';
import { DropdownContainer, dropdownInputStyle, IconContainer, DropdownOptionsContainer, DropdownOption } from './style';

var _ref = process.env.NODE_ENV === "production" ? {
  name: "5y5tsw-DesktopDropdown",
  styles: "width:100%;label:DesktopDropdown;"
} : {
  name: "5y5tsw-DesktopDropdown",
  styles: "width:100%;label:DesktopDropdown;",
  map: "/*# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9zaGFyZWQtY29tcG9uZW50cy9kcm9wZG93bi9kZXNrdG9wRHJvcGRvd24uanMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBd0JzRCIsImZpbGUiOiIuLi8uLi8uLi9zcmMvc2hhcmVkLWNvbXBvbmVudHMvZHJvcGRvd24vZGVza3RvcERyb3Bkb3duLmpzIiwic291cmNlc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A8L2Rpdj5cbiAgICAgICAgPEljb25Db250YWluZXI+XG4gICAgICAgICAgPENoZXZyb25JY29uIHdpZHRoPXsxMH0gaGVpZ2h0PXsxMH0gcm90YXRlPXtpc09wZW4gPyA5MCA6IDB9IC8+XG4gICAgICAgIDwvSWNvbkNvbnRhaW5lcj5cbiAgICAgIDwvZGl2PlxuXG4gICAgICA8RHJvcGRvd25PcHRpb25zQ29udGFpbmVyIGlzT3Blbj17aXNPcGVufT5cbiAgICAgICAge29wdGlvbnMubWFwKG9wdGlvbiA9PiB7XG4gICAgICAgICAgY29uc3QgeyB2YWx1ZTogb3B0aW9uVmFsdWUsIGRpc2FibGVkLCBsYWJlbCwgLi4ucmVzdCB9ID0gb3B0aW9uO1xuXG4gICAgICAgICAgcmV0dXJuIChcbiAgICAgICAgICAgIDxEcm9wZG93bk9wdGlvblxuICAgICAgICAgICAgICBrZXk9e29wdGlvblZhbHVlfVxuICAgICAgICAgICAgICB2YWx1ZT17b3B0aW9uVmFsdWV9XG4gICAgICAgICAgICAgIHNlbGVjdGVkPXt2YWx1ZSA9PT0gb3B0aW9uVmFsdWV9XG4gICAgICAgICAgICAgIGRpc2FibGVkPXtkaXNhYmxlZH1cbiAgICAgICAgICAgICAgb25DbGljaz17b25PcHRpb25DbGlja31cbiAgICAgICAgICAgICAgey4uLnJlc3R9XG4gICAgICAgICAgICA+XG4gICAgICAgICAgICAgIHtvcHRpb24ubGFiZWx9XG4gICAgICAgICAgICA8L0Ryb3Bkb3duT3B0aW9uPlxuICAgICAgICAgIClcbiAgICAgICAgfSl9XG4gICAgICA8L0Ryb3Bkb3duT3B0aW9uc0NvbnRhaW5lcj5cbiAgICA8L0Ryb3Bkb3duQ29udGFpbmVyPlxuICA8L09mZkNsaWNrV3JhcHBlcj5cbik7XG5cbkRlc2t0b3BEcm9wZG93bi5kZWZhdWx0UHJvcHMgPSB7XG4gIHZhbHVlOiBudWxsLFxuICBvcHRpb25zOiBbeyB2YWx1ZTogbnVsbCwgbGF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9uU2VsZWN0Q2xpY2s6IFByb3BUeXBlcy5mdW5jLFxuICBpc09wZW46IFByb3BUeXBlcy5ib29sLFxufTtcblxuZXhwb3J0IGRlZmF1bHQgRGVza3RvcERyb3Bkb3duO1xuIl19 */"
};

var DesktopDropdown = function DesktopDropdown(_ref2) {
  var value = _ref2.value,
      options = _ref2.options,
      textAlign = _ref2.textAlign,
      currentOption = _ref2.currentOption,
      closeDropdown = _ref2.closeDropdown,
      onOptionClick = _ref2.onOptionClick,
      onSelectClick = _ref2.onSelectClick,
      isOpen = _ref2.isOpen;
  return ___EmotionJSX(OffClickWrapper, {
    onOffClick: closeDropdown,
    css: _ref
  }, ___EmotionJSX(DropdownContainer, {
    textAlign: textAlign
  }, ___EmotionJSX("div", {
    id: "select-input-box",
    onClick: onSelectClick
  }, ___EmotionJSX("div", {
    css: dropdownInputStyle({
      textAlign: textAlign
    })
  }, currentOption && currentOption.label), ___EmotionJSX(IconContainer, null, ___EmotionJSX(ChevronIcon, {
    width: 10,
    height: 10,
    rotate: isOpen ? 90 : 0
  }))), ___EmotionJSX(DropdownOptionsContainer, {
    isOpen: isOpen
  }, options.map(function (option) {
    var optionValue = option.value,
        disabled = option.disabled,
        label = option.label,
        rest = _objectWithoutProperties(option, ["value", "disabled", "label"]);

    return ___EmotionJSX(DropdownOption, _extends({
      key: optionValue,
      value: optionValue,
      selected: value === optionValue,
      disabled: disabled,
      onClick: onOptionClick
    }, rest), option.label);
  }))));
};

DesktopDropdown.defaultProps = {
  value: null,
  options: [{
    value: null,
    label: ''
  }],
  currentOption: {
    value: null,
    label: ''
  },
  textAlign: 'left',
  closeDropdown: function closeDropdown() {},
  onOptionClick: function onOptionClick() {},
  onSelectClick: function onSelectClick() {},
  isOpen: false
};
DesktopDropdown.propTypes = {
  // eslint-disable-next-line react/forbid-prop-types
  value: PropTypes.any,
  options: PropTypes.arrayOf(PropTypes.shape({
    // eslint-disable-next-line react/forbid-prop-types
    value: PropTypes.any,
    label: PropTypes.string,
    disabled: PropTypes.bool
  })),
  textAlign: PropTypes.oneOf(['left', 'center']),
  currentOption: PropTypes.shape({
    // eslint-disable-next-line react/forbid-prop-types
    value: PropTypes.any,
    label: PropTypes.string,
    disabled: PropTypes.bool
  }),
  closeDropdown: PropTypes.func,
  onOptionClick: PropTypes.func,
  onSelectClick: PropTypes.func,
  isOpen: PropTypes.bool
};
export default DesktopDropdown;