import _extends from "@babel/runtime/helpers/extends";
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["value", "onChange"];
import React, { forwardRef, useState } from 'react';
import SingleLineInputBase from './SingleLineInputBase';
var Input = /*#__PURE__*/forwardRef(function (_ref, forwardedRef) {
  var value = _ref.value,
      onChange = _ref.onChange,
      others = _objectWithoutProperties(_ref, _excluded);

  var _useState = useState(value),
      _useState2 = _slicedToArray(_useState, 2),
      stateValue = _useState2[0],
      setStateValue = _useState2[1];

  var handleChange = function handleChange(event) {
    setStateValue(event.currentTarget.value);
    onChange && onChange(event, event.currentTarget.value);
  };

  return /*#__PURE__*/React.createElement(SingleLineInputBase, _extends({
    ref: forwardedRef,
    value: typeof value !== 'undefined' ? value : stateValue,
    onChange: handleChange
  }, others));
});
Input.displayName = 'Input';
export default Input;