import { useState } from 'react';
import { c as _slicedToArray } from './_rollupPluginBabelHelpers-539c1155.js';

function useInput(inputDOM, onFocus, onBlur) {
  var _useState = useState(false),
      _useState2 = _slicedToArray(_useState, 2),
      focused = _useState2[0],
      setFocused = _useState2[1];

  var handleFocus = function handleFocus(e) {
    e.preventDefault();
    setFocused(true);
    onFocus(e);
    inputDOM.current && inputDOM.current.focus();
  };

  var handleBlur = function handleBlur(e) {
    setFocused(false);
    onBlur(e);
    inputDOM.current && inputDOM.current.blur();
  };

  return {
    focused: focused,
    setFocused: setFocused,
    handleFocus: handleFocus,
    handleBlur: handleBlur
  };
}

export { useInput as u };
