{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "openlmis-forgot-password-page",
  "title": "Forgot Password Page",
  "description": "Mock email reset request page with a neutral confirmation.",
  "dependencies": [
    "@tanstack/react-form@^1",
    "zod@^4",
    "@base-ui/react@^1"
  ],
  "registryDependencies": [
    "card",
    "https://registry.soldevelo.com/r/openlmis-auth-card.json",
    "https://registry.soldevelo.com/r/openlmis-form-dialog.json",
    "https://registry.soldevelo.com/r/openlmis-form-fields.json"
  ],
  "files": [
    {
      "path": "registry/templates/openlmis/forgot-password-page/components/forgot-password-form/forgot-password-form.tsx",
      "content": "\"use client\"\n\nimport { revalidateLogic } from \"@tanstack/react-form\"\nimport { type ReactNode, useId, useState } from \"react\"\nimport { z } from \"zod\"\n\nimport { CardContent, CardDescription } from \"@/components/ui/card\"\nimport {\n  AuthButtonLink,\n  AuthForm,\n  AuthHeader,\n  AuthSubmit,\n  AuthTitle,\n} from \"@/components/blocks/openlmis/auth-card\"\nimport { FormDialogError } from \"@/components/openlmis/form-dialog/form-dialog\"\nimport { useAppForm } from \"@/components/openlmis/form-fields/form\"\n\nconst forgotPasswordSchema = z.object({\n  email: z\n    .string()\n    .trim()\n    .min(1, \"Enter your email address.\")\n    .pipe(z.email(\"Enter a valid email address.\")),\n})\n\ntype ForgotPasswordFormProps = {\n  logo?: ReactNode\n  signInHref?: string\n  /** Called with the trimmed address; request the link, then pass it back as `sentTo`. */\n  onSubmit: (email: string) => void\n  pending?: boolean\n  /** Why the request failed, e.g. too many attempts. */\n  error?: ReactNode\n  /** Set once the link is requested, to show the confirmation in place of the form. */\n  sentTo?: string\n}\n\n/** The forgot-password card's content; render it inside `AuthPage`. */\nexport function ForgotPasswordForm({\n  logo,\n  signInHref = \"/login\",\n  onSubmit,\n  pending = false,\n  error,\n  sentTo,\n}: ForgotPasswordFormProps) {\n  // Focus moves to the confirmation only when it replaces the form, not when it renders first.\n  const [initialSentTo] = useState(sentTo)\n  const form = useAppForm({\n    defaultValues: { email: \"\" },\n    validationLogic: revalidateLogic({\n      mode: \"submit\",\n      modeAfterSubmission: \"change\",\n    }),\n    validators: { onDynamic: forgotPasswordSchema },\n    onSubmit: ({ value }) => onSubmit(value.email.trim()),\n  })\n\n  if (sentTo !== undefined) {\n    return (\n      <ResetRequested\n        email={sentTo}\n        focus={sentTo !== initialSentTo}\n        logo={logo}\n        signInHref={signInHref}\n      />\n    )\n  }\n\n  return (\n    <>\n      <AuthHeader logo={logo}>\n        <AuthTitle>Forgot Password</AuthTitle>\n        <CardDescription>\n          Enter your email address and we will send you a link to reset your\n          password.\n        </CardDescription>\n      </AuthHeader>\n\n      <CardContent>\n        <AuthForm onSubmit={form.handleSubmit}>\n          {error && (\n            <FormDialogError\n              description={error}\n              title=\"Could Not Request A Reset\"\n            />\n          )}\n          <form.AppField name=\"email\">\n            {(field) => (\n              <field.TextField\n                autoComplete=\"email\"\n                dir=\"ltr\"\n                label=\"Email\"\n                placeholder=\"Enter Your Email\"\n                required\n                type=\"email\"\n              />\n            )}\n          </form.AppField>\n          <div className=\"grid gap-2\">\n            <AuthSubmit pending={pending}>\n              {pending ? \"Sending...\" : \"Reset Password\"}\n            </AuthSubmit>\n            <AuthButtonLink href={signInHref} variant=\"outline\">\n              Cancel\n            </AuthButtonLink>\n          </div>\n        </AuthForm>\n      </CardContent>\n    </>\n  )\n}\n\n/** The same for any address, as the server never says whether one has an account. */\nfunction ResetRequested({\n  email,\n  focus,\n  logo,\n  signInHref,\n}: {\n  email: string\n  focus: boolean\n  logo?: ReactNode\n  signInHref: string\n}) {\n  const descriptionId = useId()\n\n  return (\n    <>\n      <AuthHeader logo={logo}>\n        <AuthTitle focus={focus}>Password Reset Requested</AuthTitle>\n        <CardDescription id={descriptionId}>\n          If an account with the email address{\" \"}\n          <bdi className=\"font-medium text-foreground\">{email}</bdi> is active,\n          you will receive an email with instructions to reset your password.\n        </CardDescription>\n      </AuthHeader>\n      <CardContent>\n        <AuthButtonLink describedBy={descriptionId} href={signInHref}>\n          Back To Sign In\n        </AuthButtonLink>\n      </CardContent>\n    </>\n  )\n}",
      "type": "registry:component",
      "target": "components/openlmis/forgot-password-page/forgot-password-form.tsx"
    },
    {
      "path": "registry/templates/openlmis/forgot-password-page/components/forgot-password-page.tsx",
      "content": "\"use client\"\n\nimport { useState } from \"react\"\n\nimport { AuthPage } from \"@/components/blocks/openlmis/auth-card\"\nimport { ForgotPasswordForm } from \"@/components/openlmis/forgot-password-page/forgot-password-form\"\n\n// oxlint-disable-next-line next/no-img-element -- items are framework-neutral\nconst logo = <img alt=\"OpenLMIS\" src=\"https://registry.soldevelo.com/projects/openlmis.png\" />\n\nexport function ForgotPasswordPage() {\n  // Request the reset link here; the confirmation is the same for any address.\n  const [sentTo, setSentTo] = useState<string>()\n\n  return (\n    <AuthPage>\n      <ForgotPasswordForm logo={logo} onSubmit={setSentTo} sentTo={sentTo} />\n    </AuthPage>\n  )\n}",
      "type": "registry:component",
      "target": "components/openlmis/forgot-password-page/forgot-password-page.tsx"
    },
    {
      "path": "registry/templates/openlmis/forgot-password-page/page.tsx",
      "content": "import { ForgotPasswordPage } from \"@/components/openlmis/forgot-password-page/forgot-password-page\"\n\n// A Next.js App Router route; in any other React app, render ForgotPasswordPage from your own route.\nexport default function Page() {\n  return <ForgotPasswordPage />\n}",
      "type": "registry:page",
      "target": "app/forgot-password-page/page.tsx"
    }
  ],
  "cssVars": {
    "light": {
      "destructive": "oklch(0.577 0.245 27.325)",
      "destructive-foreground": "oklch(0.985 0 0)",
      "success": "oklch(0.596 0.145 163.225)",
      "success-foreground": "oklch(0.985 0 0)",
      "warning": "oklch(0.666 0.179 58.318)",
      "warning-foreground": "oklch(0.985 0 0)",
      "info": "oklch(0.55 0.13 237)",
      "info-foreground": "oklch(0.985 0 0)"
    },
    "dark": {
      "destructive": "oklch(0.704 0.191 22.216)",
      "destructive-foreground": "oklch(0.21 0.04 25)",
      "success": "oklch(0.696 0.17 162.48)",
      "success-foreground": "oklch(0.21 0.04 163)",
      "warning": "oklch(0.769 0.188 70.08)",
      "warning-foreground": "oklch(0.22 0.04 60)",
      "info": "oklch(0.7 0.14 237)",
      "info-foreground": "oklch(0.2 0.04 240)"
    }
  },
  "meta": {
    "project": "openlmis",
    "height": "468px"
  },
  "categories": [
    "auth"
  ],
  "type": "registry:page"
}
