"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.Textarea = exports.Select = exports.Input = exports.inputClasses = exports.inputOutlineClasses = void 0;

var _preact = require("preact");

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

var _icon = require("./icon");

var _getStyledComponent = _interopRequireDefault(require("./utils/get-styled-component"));

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

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

const inputOutlineClasses = 'ba b--gray';
exports.inputOutlineClasses = inputOutlineClasses;
const inputClasses = 'pa2 input-reset ' + inputOutlineClasses;
exports.inputClasses = inputClasses;
const Input = (0, _getStyledComponent.default)({
  baseClasses: inputClasses,
  tagName: 'input',
  options: {
    disabled: ['disabled']
  },
  fn: ({
    disabled
  }) => disabled ? 'mid-gray bg-near-white not-allowed' : 'bg-white'
});
exports.Input = Input;

const Select = (_ref) => {
  let {
    className,
    children
  } = _ref,
      rest = _objectWithoutProperties(_ref, ["className", "children"]);

  return (0, _preact.h)("span", {
    className: "flex items-center"
  }, (0, _preact.h)("select", _extends({}, rest, {
    className: (0, _classnames.default)(inputClasses, 'pr4', className)
  }), children), !rest.multiple && (0, _preact.h)(_icon.Icon, {
    style: {
      marginLeft: '-30px',
      pointerEvents: 'none'
    },
    icon: "arrow_drop_down",
    size: "24"
  }));
};

exports.Select = Select;
const Textarea = (0, _getStyledComponent.default)({
  baseClasses: inputClasses,
  tagName: 'textarea'
});
exports.Textarea = Textarea;