// packages/components/src/navigator/navigator-back-button/hook.ts
import { useCallback } from "@wordpress/element";
import { useContextSystem } from "../../context/index.js";
import Button from "../../button/index.js";
import { useNavigator } from "../use-navigator.js";
function useNavigatorBackButton(props) {
  const {
    onClick,
    as = Button,
    ...otherProps
  } = useContextSystem(props, "Navigator.BackButton");
  const {
    goBack
  } = useNavigator();
  const handleClick = useCallback((e) => {
    e.preventDefault();
    goBack();
    onClick?.(e);
  }, [goBack, onClick]);
  return {
    as,
    onClick: handleClick,
    ...otherProps
  };
}
export {
  useNavigatorBackButton
};
//# sourceMappingURL=hook.js.map
