import { useEffect } from 'react';
import { usePrevious } from '../../../../common/Hooks';
export var useOnBlur = function useOnBlur(_ref) {
  var _ref$current;
  var ref = _ref.ref,
    onBlur = _ref.onBlur;
  var isFocused = ref === null || ref === void 0 || (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.contains(document.activeElement);
  var wasFocused = usePrevious(isFocused);
  useEffect(function () {
    if (wasFocused && !isFocused) {
      onBlur();
    }
  }, [isFocused, onBlur, wasFocused]);
};