{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "auth-forgot-password",
  "title": "Auth Forgot Password",
  "description": "Request password reset link via email.",
  "registryDependencies": [
    "button",
    "card",
    "field",
    "input-group"
  ],
  "files": [
    {
      "path": "registry/new-york/blocks/auth/auth-forgot-password.tsx",
      "content": "\"use client\";\n\nimport { ArrowLeft, CheckCircle2, Loader2, Mail } from \"lucide-react\";\nimport { useCallback, useState } from \"react\";\nimport { cn } from \"@/lib/utils\";\nimport { Button } from \"@/registry/new-york/ui/button\";\nimport {\n  Card,\n  CardContent,\n  CardDescription,\n  CardHeader,\n  CardTitle,\n} from \"@/registry/new-york/ui/card\";\nimport {\n  Field,\n  FieldContent,\n  FieldDescription,\n  FieldError,\n  FieldLabel,\n} from \"@/registry/new-york/ui/field\";\nimport {\n  InputGroup,\n  InputGroupAddon,\n  InputGroupInput,\n} from \"@/registry/new-york/ui/input-group\";\n\nexport interface AuthForgotPasswordProps {\n  onSubmit?: (email: string) => void;\n  onBack?: () => void;\n  className?: string;\n  defaultEmail?: string;\n  isLoading?: boolean;\n  isSuccess?: boolean;\n  errors?: {\n    email?: string;\n    general?: string;\n  };\n  successMessage?: string;\n}\n\nfunction validateEmail(value: string): string | undefined {\n  if (!value.trim()) {\n    return \"Email is required\";\n  }\n  const emailRegex = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n  if (!emailRegex.test(value)) {\n    return \"Please enter a valid email address\";\n  }\n  return;\n}\n\ninterface ErrorAlertProps {\n  message: string;\n}\n\nfunction ErrorAlert({ message }: ErrorAlertProps) {\n  return (\n    <div\n      aria-live=\"polite\"\n      className=\"rounded-lg border border-destructive/50 bg-destructive/10 p-3 text-destructive text-sm\"\n      role=\"alert\"\n    >\n      {message}\n    </div>\n  );\n}\n\ninterface EmailFieldProps {\n  id: string;\n  value: string;\n  onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;\n  error?: string;\n}\n\nfunction EmailField({ id, value, onChange, error }: EmailFieldProps) {\n  return (\n    <Field data-invalid={!!error}>\n      <FieldLabel htmlFor={id}>\n        Email\n        <span aria-label=\"required\" className=\"text-destructive\">\n          *\n        </span>\n      </FieldLabel>\n      <FieldContent>\n        <InputGroup aria-invalid={!!error}>\n          <InputGroupAddon>\n            <Mail aria-hidden=\"true\" className=\"size-4\" />\n          </InputGroupAddon>\n          <InputGroupInput\n            aria-describedby={error ? `${id}-error` : undefined}\n            aria-invalid={!!error}\n            autoComplete=\"email\"\n            id={id}\n            inputMode=\"email\"\n            name=\"email\"\n            onChange={onChange}\n            placeholder=\"name@example.com…\"\n            required\n            type=\"email\"\n            value={value}\n          />\n        </InputGroup>\n        {error && <FieldError id={`${id}-error`}>{error}</FieldError>}\n        <FieldDescription>\n          We&apos;ll send a password reset link to this email address\n        </FieldDescription>\n      </FieldContent>\n    </Field>\n  );\n}\n\ninterface SuccessStateProps {\n  message: string;\n  onBack?: () => void;\n  className?: string;\n}\n\nfunction SuccessState({ message, onBack, className }: SuccessStateProps) {\n  return (\n    <Card className={cn(\"w-full max-w-sm shadow-xs\", className)}>\n      <CardHeader>\n        <CardTitle>Check your email</CardTitle>\n        <CardDescription>\n          We&apos;ve sent you a password reset link\n        </CardDescription>\n      </CardHeader>\n      <CardContent>\n        <div className=\"flex flex-col gap-6\">\n          <div className=\"flex flex-col items-center gap-4 rounded-lg border border-primary/20 bg-primary/5 p-6 text-center\">\n            <div className=\"flex size-12 items-center justify-center rounded-full bg-primary/10\">\n              <CheckCircle2\n                aria-hidden=\"true\"\n                className=\"size-6 text-primary\"\n              />\n            </div>\n            <div className=\"flex flex-col gap-2\">\n              <p className=\"font-medium text-sm\">{message}</p>\n              <p className=\"text-muted-foreground text-sm\">\n                If you don&apos;t see the email, check your spam folder.\n              </p>\n            </div>\n          </div>\n\n          {onBack && (\n            <Button\n              className=\"min-h-[44px] w-full touch-manipulation\"\n              onClick={onBack}\n              type=\"button\"\n              variant=\"outline\"\n            >\n              <ArrowLeft aria-hidden=\"true\" className=\"size-4\" />\n              Back to sign in\n            </Button>\n          )}\n        </div>\n      </CardContent>\n    </Card>\n  );\n}\n\nexport default function AuthForgotPassword({\n  onSubmit,\n  onBack,\n  className,\n  defaultEmail = \"\",\n  isLoading = false,\n  isSuccess = false,\n  errors,\n  successMessage = \"We&apos;ve sent a password reset link to your email address.\",\n}: AuthForgotPasswordProps) {\n  const [email, setEmail] = useState(defaultEmail);\n  const [localErrors, setLocalErrors] = useState<{\n    email?: string;\n  }>({});\n\n  const handleSubmit = useCallback(\n    (e: React.FormEvent) => {\n      e.preventDefault();\n\n      const emailError = validateEmail(email);\n\n      if (emailError) {\n        setLocalErrors({ email: emailError });\n        return;\n      }\n\n      setLocalErrors({});\n      onSubmit?.(email.trim());\n    },\n    [email, onSubmit]\n  );\n\n  const handleEmailChange = useCallback(\n    (e: React.ChangeEvent<HTMLInputElement>) => {\n      const value = e.target.value;\n      setEmail(value);\n      if (localErrors.email) {\n        setLocalErrors((prev) => ({ ...prev, email: validateEmail(value) }));\n      }\n    },\n    [localErrors.email]\n  );\n\n  const emailError = errors?.email || localErrors.email;\n  const generalError = errors?.general;\n\n  if (isSuccess) {\n    return (\n      <SuccessState\n        className={className}\n        message={successMessage}\n        onBack={onBack}\n      />\n    );\n  }\n\n  return (\n    <Card className={cn(\"w-full max-w-sm shadow-xs\", className)}>\n      <CardHeader>\n        <CardTitle>Reset password</CardTitle>\n        <CardDescription>\n          Enter your email address and we&apos;ll send you a link to reset your\n          password\n        </CardDescription>\n      </CardHeader>\n      <CardContent>\n        <form className=\"flex flex-col gap-6\" onSubmit={handleSubmit}>\n          {generalError && <ErrorAlert message={generalError} />}\n\n          <EmailField\n            error={emailError}\n            id=\"forgot-password-email\"\n            onChange={handleEmailChange}\n            value={email}\n          />\n\n          <div className=\"flex flex-col gap-2\">\n            <Button\n              aria-busy={isLoading}\n              className=\"min-h-[44px] w-full touch-manipulation\"\n              data-loading={isLoading}\n              disabled={isLoading}\n              type=\"submit\"\n            >\n              {isLoading ? (\n                <>\n                  <Loader2 aria-hidden=\"true\" className=\"size-4 animate-spin\" />\n                  Sending reset link…\n                </>\n              ) : (\n                \"Send reset link\"\n              )}\n            </Button>\n\n            {onBack && (\n              <Button\n                className=\"min-h-[44px] w-full touch-manipulation\"\n                onClick={onBack}\n                type=\"button\"\n                variant=\"ghost\"\n              >\n                <ArrowLeft aria-hidden=\"true\" className=\"size-4\" />\n                Back to sign in\n              </Button>\n            )}\n          </div>\n        </form>\n      </CardContent>\n    </Card>\n  );\n}\n",
      "type": "registry:ui"
    }
  ],
  "categories": [
    "block",
    "auth"
  ],
  "type": "registry:ui"
}