// src/hooks/useButton/useButton.tsx
import { useCallback } from "react";
function useButton({
  elementType = "button",
  type = "button",
  isDisabled = false,
  href,
  target,
  rel,
  role,
  name,
  value,
  onClick,
  onPress
}) {
  const realOnClick = useCallback(
    (event) => {
      if (isDisabled) {
        return;
      }
      onClick?.(event);
      onPress?.(event);
    },
    [isDisabled, onClick, onPress]
  );
  function getRole() {
    if (role) {
      return role;
    }
    if (elementType === "a") {
      return void 0;
    }
    return "button";
  }
  const extraProps = elementType === "button" ? { type } : {
    role: getRole()
  };
  return {
    buttonProps: {
      href: elementType === "a" ? href : void 0,
      target: elementType === "a" ? target : void 0,
      rel: elementType === "a" ? rel : void 0,
      tabIndex: isDisabled ? -1 : 0,
      disabled: isDisabled || void 0,
      "aria-disabled": isDisabled || void 0,
      name: elementType === "input" || elementType === "button" ? name : void 0,
      value: elementType === "input" || elementType === "button" ? value : void 0,
      ...extraProps,
      onClick: realOnClick
    }
  };
}

export {
  useButton
};
//# sourceMappingURL=chunk-FB3CIPAZ.js.map
