Files
neta/components/ui/pending-submit-button.tsx
T
Poyraz 24fcdf9a77 feat: add new UI components and improve existing ones
- Introduced `Field` and `Label` components for better form handling.
- Refactored `Input` and `Textarea` components to use forward refs and improved styling.
- Updated `PendingSubmitButton` to use the new `Button` component.
- Enhanced `Skeleton` component for better layout handling.
- Revamped `Toast` component to support live regions and improved accessibility.
- Updated sidebar configuration to use typed icons.
- Added phase 3 UI boundary checks to prevent usage of deprecated imports.
- Implemented new authentication action handler for better cookie management.
- Improved setup logic for freelancer accounts with repair functionality.
2026-07-10 22:47:02 +03:00

44 lines
968 B
TypeScript

"use client";
import { Loader2 } from "lucide-react";
import { Button } from "@/components/ui/button";
import type { ComponentProps, ReactNode } from "react";
import { useFormStatus } from "react-dom";
import { cn } from "@/lib/utils";
type PendingSubmitButtonProps = ComponentProps<typeof Button> & {
idleIcon?: ReactNode;
pendingIcon?: ReactNode;
pendingChildren?: ReactNode;
};
export function PendingSubmitButton({
children,
className,
disabled,
idleIcon,
pendingChildren,
pendingIcon,
type = "submit",
...props
}: PendingSubmitButtonProps) {
const { pending } = useFormStatus();
const icon = pending
? pendingIcon ?? <Loader2 className="h-4 w-4 animate-spin" />
: idleIcon;
return (
<Button
{...props}
type={type}
disabled={disabled || pending}
aria-busy={pending}
className={cn(className)}
>
{icon}
{pending ? pendingChildren ?? children : children}
</Button>
);
}