import React from "react"; import { useClientConfig } from "@/lib/clientConfig"; import type { ButtonProps } from "./button"; import { Button } from "./button"; import LoadingSpinner from "./spinner"; import { Tooltip, TooltipContent, TooltipPortal, TooltipTrigger, } from "./tooltip"; interface ActionButtonProps extends ButtonProps { loading: boolean; spinner?: React.ReactNode; ignoreDemoMode?: boolean; } const ActionButton = React.forwardRef( ( { children, loading, spinner, disabled, ignoreDemoMode = false, ...props }, ref, ) => { const clientConfig = useClientConfig(); spinner ||= ; if (!ignoreDemoMode && clientConfig.demoMode) { disabled = true; } else if (disabled !== undefined) { disabled ||= loading; } else if (loading) { disabled = true; } return ( ); }, ); ActionButton.displayName = "ActionButton"; const ActionButtonWithTooltip = React.forwardRef< HTMLButtonElement, ActionButtonProps & { tooltip: string; delayDuration?: number } >(({ tooltip, delayDuration, ...props }, ref) => { return ( {tooltip} ); }); ActionButtonWithTooltip.displayName = "ActionButtonWithTooltip"; export { ActionButton, ActionButtonWithTooltip }; export type { ActionButtonProps };