"use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
exports.__esModule = true;
exports["default"] = void 0;
var _icon = _interopRequireDefault(require("@alifd/next/lib/icon"));
var _select = _interopRequireDefault(require("@alifd/next/lib/select"));
var _input = _interopRequireDefault(require("@alifd/next/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 = ["data", "InputType", "size", "placeholder", "defaultValue", "maxLength", "showLimitHint", "autoFocus", "disabled", "cutString", "trim", "hasClear", "hasBorder", "state", "style", "hint", "innerBefore", "innerAfter", "addonBefore", "addonAfter", "addonTextBefore", "addonTextAfter"];
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 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 = (0, _objectWithoutPropertiesLoose2["default"])(_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["default"].TextArea, (0, _extends2["default"])({
      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["default"], {
      "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["default"].Group, {
      addonBefore: select,
      style: {
        width: '300px'
      }
    }, /*#__PURE__*/React.createElement(_input["default"], {
      style: {
        width: "100%"
      },
      hasClear: true,
      defaultValue: defaultValue
    }));
  };
  var Password = function Password() {
    return /*#__PURE__*/React.createElement(_input["default"].Password, (0, _extends2["default"])({
      innerBefore: /*#__PURE__*/React.createElement(_icon["default"], {
        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["default"], (0, _extends2["default"])({
      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';
var _default = myInput;
exports["default"] = _default;