import _Icon from "@alifd/next/es/icon";
import _Select from "@alifd/next/es/select";
import _Input from "@alifd/next/es/input";
import _extends from "@babel/runtime/helpers/extends";
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
var _excluded = ["data", "InputType", "size", "placeholder", "defaultValue", "maxLength", "showLimitHint", "autoFocus", "disabled", "cutString", "trim", "hasClear", "hasBorder", "state", "style", "hint", "innerBefore", "innerAfter", "addonBefore", "addonAfter", "addonTextBefore", "addonTextAfter"];
/* eslint-disable @typescript-eslint/no-shadow */
import * as React from 'react';
import "./index.less";
var myInput = function myInput(_ref) {
  var data = _ref.data,
    InputType = _ref.InputType,
    size = _ref.size,
    placeholder = _ref.placeholder,
    defaultValue = _ref.defaultValue,
    maxLength = _ref.maxLength,
    showLimitHint = _ref.showLimitHint,
    autoFocus = _ref.autoFocus,
    disabled = _ref.disabled,
    cutString = _ref.cutString,
    trim = _ref.trim,
    hasClear = _ref.hasClear,
    hasBorder = _ref.hasBorder,
    state = _ref.state,
    style = _ref.style,
    hint = _ref.hint,
    innerBefore = _ref.innerBefore,
    innerAfter = _ref.innerAfter,
    addonBefore = _ref.addonBefore,
    addonAfter = _ref.addonAfter,
    addonTextBefore = _ref.addonTextBefore,
    addonTextAfter = _ref.addonTextAfter,
    otherProps = _objectWithoutPropertiesLoose(_ref, _excluded);
  // const [value, setValue] = useState('');

  // const MyInput =InputTypeList[InputType]
  var _style = style || {};
  _style['height'] = _style['height'] ? _style['height'] : '30px';
  _style['width'] = _style['width'] ? _style['width'] : '300px';
  var _otherProps = otherProps || {};
  _otherProps.style = _style;

  // const onchange = (e) => {
  //   // defaultValue = e
  //   setValue(e);
  // };
  var TextArea = function TextArea() {
    return /*#__PURE__*/React.createElement(_Input.TextArea, _extends({
      size: size,
      placeholder: placeholder,
      value: defaultValue
      // defaultValue={defaultValue}
      ,
      maxLength: maxLength,
      autoFocus: autoFocus,
      disabled: disabled
      // cutString={cutString}
      ,
      trim: trim,
      hasClear: hasClear,
      hasBorder: hasBorder,
      showLimitHint: showLimitHint,
      state: state,
      hint: hint,
      innerBefore: innerBefore,
      innerAfter: innerAfter,
      addonBefore: addonBefore,
      addonAfter: addonAfter,
      addonTextBefore: addonTextBefore,
      addonTextAfter: addonTextAfter
    }, _otherProps));
  };
  var Group = function Group() {
    // const data=[{
    //   value:'https',
    //   name:'https'
    // },{
    //   value:'http',
    //   name:'http'
    // },]
    var select = /*#__PURE__*/React.createElement(_Select, {
      "aria-label": "please select"
    }, data.map(function (i) {
      return /*#__PURE__*/React.createElement("option", {
        value: i.value
      }, i.name);
    }));
    // const button = <Button>search</Button>;
    return /*#__PURE__*/React.createElement(_Input.Group, {
      addonBefore: select,
      style: {
        width: '300px'
      }
    }, /*#__PURE__*/React.createElement(_Input, {
      style: {
        width: "100%"
      },
      hasClear: true,
      defaultValue: defaultValue
    }));
  };
  var Password = function Password() {
    return /*#__PURE__*/React.createElement(_Input.Password, _extends({
      innerBefore: /*#__PURE__*/React.createElement(_Icon, {
        type: "lock",
        style: {
          margin: 4
        }
      })
      // onChange={onchange}
      ,
      innerAfter: innerAfter,
      addonBefore: addonBefore,
      addonAfter: addonAfter,
      addonTextBefore: addonTextBefore,
      addonTextAfter: addonTextAfter,
      size: size,
      placeholder: placeholder,
      value: defaultValue
      // defaultValue={defaultValue}
      ,
      maxLength: maxLength,
      autoFocus: autoFocus,
      disabled: disabled
      // cutString={cutString}
      ,
      showLimitHint: showLimitHint,
      trim: trim,
      hasClear: hasClear,
      hasBorder: hasBorder,
      state: state
    }, _otherProps));
  };
  var InputD = function InputD() {
    return /*#__PURE__*/React.createElement(_Input, _extends({
      hint: hint,
      innerBefore: innerBefore,
      innerAfter: innerAfter,
      addonBefore: addonBefore,
      addonAfter: addonAfter,
      addonTextBefore: addonTextBefore,
      addonTextAfter: addonTextAfter,
      size: size,
      showLimitHint: showLimitHint,
      placeholder: placeholder,
      value: defaultValue
      // defaultValue={defaultValue}
      ,
      maxLength: maxLength,
      autoFocus: autoFocus,
      disabled: disabled
      // cutString={cutString}
      ,
      trim: trim,
      hasClear: hasClear,
      hasBorder: hasBorder,
      state: state
    }, _otherProps, {
      // onChange={(e) => {
      //   onchange(e);
      // }}
      "aria-label": "style width 400"
    }));
  };
  return (
    // eslint-disable-next-line no-nested-ternary
    InputType === '密码' ? Password() : InputType === '文本' ? TextArea() : InputType === '组合' ? Group() : InputD()
  );
};
myInput.displayName = 'myInput';
export default myInput;