"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _input = _interopRequireDefault(require("antd/lib/input"));
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
var React = _interopRequireWildcard(require("react"));
require("./index.less");
var _excluded = ["InputType", "groupAgeType", "groupLaterType", "maxLength", "showCount", "defaultValue", "defaultColor", "size", "status", "autoSize", "prefixType", "prefixWord", "prefixIcon", "suffixType", "suffixWord", "suffixIcon", "hasBorder", "placeholder", "allowClear", "visibilityToggle", "pullHeadData", "backHeadData", "pullHeadValue", "backHeadValue", "style"];
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; }
var antInput = function antInput(_ref) {
  var InputType = _ref.InputType,
    groupAgeType = _ref.groupAgeType,
    groupLaterType = _ref.groupLaterType,
    maxLength = _ref.maxLength,
    showCount = _ref.showCount,
    defaultValue = _ref.defaultValue,
    defaultColor = _ref.defaultColor,
    size = _ref.size,
    status = _ref.status,
    autoSize = _ref.autoSize,
    prefixType = _ref.prefixType,
    prefixWord = _ref.prefixWord,
    prefixIcon = _ref.prefixIcon,
    suffixType = _ref.suffixType,
    suffixWord = _ref.suffixWord,
    suffixIcon = _ref.suffixIcon,
    hasBorder = _ref.hasBorder,
    placeholder = _ref.placeholder,
    allowClear = _ref.allowClear,
    visibilityToggle = _ref.visibilityToggle,
    pullHeadData = _ref.pullHeadData,
    backHeadData = _ref.backHeadData,
    pullHeadValue = _ref.pullHeadValue,
    backHeadValue = _ref.backHeadValue,
    style = _ref.style,
    otherProps = (0, _objectWithoutPropertiesLoose2["default"])(_ref, _excluded);
  var _style = style || {};
  // _style['height'] = _style['height'] ? _style['height'] : '30px';
  _style['width'] = _style['width'] ? _style['width'] : '300px';
  _style['color'] = _style['color'] ? _style['color'] : defaultColor;
  var _otherProps = otherProps || {};
  _otherProps.style = _style;

  // const Group = () => {
  //   const [pullHeadValues, setPullHeadValue] = useState(pullHeadValue)
  //   const [backHeadValues, setBackHeadValue] = useState(backHeadValue)
  //   const [value, setValue] = useState(defaultValue)
  //   const { Option } = Select;

  //   const pullHeadChange = (value: string) => {
  //     pullHeadValue = value
  //     setPullHeadValue(value)
  //     defaultValue = pullHeadValues + value + backHeadValues
  //     console.log(`selected1 ${pullHeadValue}`);
  //   };
  //   const backHeadChange = (value: string) => {
  //     backHeadValue = value
  //     setBackHeadValue(value)
  //     defaultValue = pullHeadValues + value + backHeadValues
  //     console.log(`selected2 ${backHeadValue}`);
  //   };
  //   const onChange = (e) => {
  //     setValue(e.target.value)
  //     defaultValue = pullHeadValues + value + backHeadValues
  //     console.log(e.target.value, '-------value')
  //   };

  //   const selectBefore = (
  //     <Select defaultValue={pullHeadValues} value={pullHeadValues} style={{ width: 90 }} onChange={pullHeadChange}>
  //       {
  //         pullHeadData.map((item, index) => {
  //           return <Option key={index} value={item.value}>{item.label}</Option>
  //         })
  //       }
  //     </Select>
  //   );

  //   const selectAfter = (
  //     <Select defaultValue={backHeadValues} value={backHeadValues} style={{ width: 80 }} onChange={backHeadChange}>
  //       {
  //         backHeadData.map((item, index) => {
  //           return <Option key={index} value={item.value}>{item.label}</Option>
  //         })
  //       }
  //     </Select>
  //   );

  //   return (
  //     <Input
  //       addonBefore={groupAgeType === '空' ? "" : (groupAgeType === '文本' ? 'Http://' : (groupAgeType === '下拉' ? selectBefore : <UserOutlined />))}
  //       addonAfter={groupLaterType === '空' ? "" : (groupLaterType === '文本' ? '.com' : (groupLaterType === '下拉' ? selectAfter : <UserOutlined />))}
  //       value={value}
  //       // defaultValue="mysite"
  //       onChange={onChange}
  //       size={size}
  //       {..._otherProps} />
  //   );
  // };
  var Password = function Password() {
    return /*#__PURE__*/React.createElement(_input["default"].Password, (0, _extends2["default"])({
      className: status === 'success' ? '' : status === 'error' ? 'ant-input-status-error' : 'ant-input-status-warning',
      defaultValue: defaultValue,
      value: defaultValue,
      bordered: !hasBorder,
      visibilityToggle: visibilityToggle,
      size: size,
      placeholder: placeholder,
      allowClear: allowClear
    }, _otherProps));
  };
  var TextArea = function TextArea() {
    var TextArea = _input["default"].TextArea;
    return /*#__PURE__*/React.createElement(TextArea, (0, _extends2["default"])({
      defaultValue: defaultValue,
      value: defaultValue,
      bordered: !hasBorder,
      size: size,
      showCount: showCount,
      autoSize: autoSize,
      maxLength: maxLength,
      placeholder: placeholder,
      allowClear: allowClear
    }, _otherProps));
  };
  var InputD = function InputD() {
    return /*#__PURE__*/React.createElement(_input["default"], (0, _extends2["default"])({
      id: "abcd",
      className: status === 'success' ? '' : status === 'error' ? 'ant-input-status-error' : 'ant-input-status-warning',
      defaultValue: defaultValue,
      value: defaultValue,
      bordered: !hasBorder,
      size: size,
      prefix: prefixType === '空' ? '' : prefixType === '文本' ? prefixWord : prefixIcon,
      maxLength: maxLength,
      suffix: showCount ? /*#__PURE__*/React.createElement("span", null, defaultValue.length, "/", maxLength) : suffixType === '空' ? '' : suffixType === '文本' ? suffixWord : suffixIcon,
      placeholder: placeholder,
      allowClear: allowClear
    }, _otherProps));
  };
  return function () {
    switch (InputType) {
      case '普通':
        return InputD();
        break;
      case '文本':
        return TextArea();
        break;
      case '组合':
        return Group();
        break;
      case '密码':
        return Password();
        break;
      default:
        return false;
    }
  }();
};
antInput.displayName = 'antInput';
var _default = antInput;
exports["default"] = _default;