import { useRef as t, useLayoutEffect as e } from "react";
function n(r) {
  const u = t(null);
  return e(() => {
    r && u.current?.focus({ preventScroll: !0 });
  }, [r]), {
    ref: u,
    tabIndex: r ? 0 : -1
  };
}
export {
  n as useFocusRef
};
