import { useState, useCallback } from "react";
export var useFocusedState = function useFocusedState(_ref) {
  var _ref$defaultState = _ref.defaultState,
    defaultState = _ref$defaultState === void 0 ? false : _ref$defaultState,
    onBlur = _ref.onBlur,
    onFocus = _ref.onFocus;
  var _useState = useState(defaultState),
    focused = _useState[0],
    setFocused = _useState[1];
  var handleFocus = useCallback(function (e) {
    if (!focused) {
      setFocused(true);
    }
    if (onFocus) {
      onFocus(e);
    }
  }, [onFocus, focused]);
  var handleBlur = useCallback(function (e) {
    setFocused(false);
    if (onBlur) {
      onBlur(e);
    }
  }, [onBlur]);
  return [focused, handleFocus, handleBlur];
};