{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "login-form",
  "title": "Login Form",
  "description": "A login with labels that stay visible and inline errors, in three forms: beside a calm brand panel with a password you can reveal, one card on a grey ground, or email only with a check-your-inbox screen.",
  "dependencies": [
    "lucide-react",
    "motion"
  ],
  "registryDependencies": [
    "utils",
    "https://miseui.junsu4621.workers.dev/r/motion.json",
    "https://miseui.junsu4621.workers.dev/r/badge.json",
    "https://miseui.junsu4621.workers.dev/r/button.json",
    "https://miseui.junsu4621.workers.dev/r/card.json",
    "https://miseui.junsu4621.workers.dev/r/input.json",
    "https://miseui.junsu4621.workers.dev/r/label.json"
  ],
  "files": [
    {
      "path": "registry/miseui/blocks/login-form.tsx",
      "content": "import type * as React from \"react\"\nimport { cn } from \"@/registry/miseui/lib/utils\"\nimport { LoginFields, SignUpLine, type LoginFieldsProps } from \"./login-form-credentials\"\nimport { LoginFormMagic, type LoginMagicProps } from \"./login-form-magic\"\nimport type { LoginProvider, LoginValues } from \"./login-form-parts\"\nimport { BrandPanel, InvoiceFragments } from \"./login-form-visual\"\n\ntype LoginFormVariant = \"split\" | \"centered\" | \"magic\"\n\nconst PREVIEW_DELAY_MS = 1200\nconst DEFAULT_PROVIDERS: readonly LoginProvider[] = [\n  { id: \"google\", label: \"Google\" },\n  { id: \"github\", label: \"GitHub\" },\n]\n/** Scoped to touch, on this design only: the shared fields stay at 36 px with a mouse. */\nconst LINK_TOUCH_CLASS = \"pointer-coarse:[&_a]:relative pointer-coarse:[&_a]:after:absolute pointer-coarse:[&_a]:after:-inset-x-1 pointer-coarse:[&_a]:after:-inset-y-3\"\nconst TOUCH_TARGETS_CLASS = \"pointer-coarse:[&_[data-slot=button]]:h-10 pointer-coarse:[&_[data-slot=button]]:min-w-10 pointer-coarse:[&_input]:h-10\"\n\n/** Stands in until you pass onSubmit, so the preview shows the loading and error states. Replace it. */\nfunction previewSubmit() {\n  return new Promise<void>((_, reject) => {\n    window.setTimeout(() => reject(new Error(\"That password does not match this email.\")), PREVIEW_DELAY_MS)\n  })\n}\n\ninterface LoginFormProps extends Omit<React.ComponentProps<\"section\">, \"onSubmit\">, LoginMagicProps {\n  /** `split` the form beside a brand panel, `centered` one card on the grey ground, `magic` email only, then check your inbox. */\n  variant?: LoginFormVariant\n  /** Called once the fields pass the basic checks. Return a promise to get the loading state; a rejection's message is shown inline. */\n  onSubmit?: (values: LoginValues) => void | Promise<void>\n  /** An error you already know about, such as a locked account. Shown under the last field. */\n  error?: string\n  /** Forces the loading state, if you track the request yourself. */\n  pending?: boolean\n  brandName?: string\n  /** The one product sentence on the panel, on `split`. Keep it true; this is no place for a testimonial. */\n  tagline?: string\n  /** The muted second sentence of the heading. */\n  headingNote?: string\n  /** Small pieces of your real product for the panel, on `split`. The default is a sample invoice; null leaves only the sentence. */\n  visual?: React.ReactNode\n  forgotPasswordHref?: string\n  /** Where \"Create an account\" goes. Null removes the line, for invite-only products. */\n  signUpHref?: string | null\n  /** Pass an empty list if you only support email. `magic` shows none unless you pass some. */\n  socialProviders?: readonly LoginProvider[]\n  onSocial?: (id: string) => void\n}\n\ntype LoginShellProps = Omit<React.ComponentProps<\"section\">, \"onSubmit\"> & {\n  brandName: string\n  headingNote: string\n  signUpHref: string | null\n  fields: LoginFieldsProps\n}\n\nfunction LoginSplit({ brandName, headingNote, signUpHref, fields, tagline, visual, className, ...props }: LoginShellProps & { tagline: string; visual: React.ReactNode }) {\n  return (\n    <section data-slot=\"login-form\" data-variant=\"split\" className={cn(\"@container flex w-full flex-col bg-background\", className)} {...props}>\n      <div className=\"grid min-h-[640px] flex-1 grid-cols-1 @3xl:grid-cols-2\">\n        <div className=\"flex items-center justify-center px-6 py-12 @3xl:px-12\">\n          <div className=\"flex w-full max-w-sm flex-col gap-8\">\n            <h2 className=\"text-display text-3xl leading-[1.12]! text-balance @2xl:text-4xl\">\n              Log in to {brandName}. <span className=\"text-muted-foreground\">{headingNote}</span>\n            </h2>\n            <LoginFields {...fields} />\n            <SignUpLine href={signUpHref} />\n          </div>\n        </div>\n        <BrandPanel brandName={brandName} tagline={tagline} visual={visual} />\n      </div>\n    </section>\n  )\n}\n\n/** The sign-up line sits outside the card: it is for people who do not belong in the card yet. */\nfunction LoginCentered({ brandName, headingNote, signUpHref, fields, className, ...props }: LoginShellProps) {\n  return (\n    <section data-slot=\"login-form\" data-variant=\"centered\" className={cn(\"@container flex w-full flex-col bg-muted dark:bg-background\", className)} {...props}>\n      <div className={cn(\"flex min-h-[640px] flex-1 flex-col items-center justify-center gap-6 px-4 py-12 @md:px-6\", LINK_TOUCH_CLASS)}>\n        <div className={cn(\"flex w-full max-w-sm flex-col gap-6 rounded-2xl border bg-background p-6 @md:p-8 dark:bg-card\", TOUCH_TARGETS_CLASS)}>\n          <h2 className=\"text-display text-2xl leading-[1.12]! text-balance\">\n            Log in to {brandName}. <span className=\"text-muted-foreground\">{headingNote}</span>\n          </h2>\n          <LoginFields {...fields} />\n        </div>\n        <SignUpLine href={signUpHref} />\n      </div>\n    </section>\n  )\n}\n\nfunction LoginForm({\n  variant,\n  onSendLink,\n  resendAfterSeconds,\n  sentNote,\n  onSubmit = previewSubmit,\n  error,\n  pending = false,\n  brandName = \"Paperline\",\n  tagline = \"Invoices that chase themselves, so you do not have to.\",\n  headingNote,\n  visual = <InvoiceFragments />,\n  forgotPasswordHref = \"#forgot-password\",\n  signUpHref,\n  socialProviders,\n  onSocial,\n  ...props\n}: LoginFormProps) {\n  if (variant === \"magic\") {\n    return (\n      <LoginFormMagic\n        {...{ onSendLink, resendAfterSeconds, sentNote, error, pending, brandName, headingNote, signUpHref, socialProviders, onSocial }}\n        {...props}\n      />\n    )\n  }\n  const fields = { onSubmit, error, pending, forgotPasswordHref, socialProviders: socialProviders ?? DEFAULT_PROVIDERS, onSocial }\n  const shell = { brandName, headingNote: headingNote ?? \"Your invoices are where you left them.\", signUpHref: signUpHref === undefined ? \"#sign-up\" : signUpHref, fields }\n  if (variant === \"centered\") return <LoginCentered {...shell} {...props} />\n  return <LoginSplit {...shell} tagline={tagline} visual={visual} {...props} />\n}\n\nexport { LoginForm, type LoginFormProps, type LoginFormVariant, type LoginProvider, type LoginValues }\n",
      "type": "registry:component"
    },
    {
      "path": "registry/miseui/blocks/login-form-credentials.tsx",
      "content": "import type * as React from \"react\"\nimport { useId, useRef } from \"react\"\nimport { Loader2 } from \"lucide-react\"\nimport { cn } from \"@/registry/miseui/lib/utils\"\nimport { Button } from \"@/registry/miseui/ui/button\"\nimport { Label } from \"@/registry/miseui/ui/label\"\nimport {\n  EmailField,\n  FieldError,\n  PasswordField,\n  SocialRow,\n  useLoginForm,\n  type LoginProvider,\n  type LoginValues,\n} from \"./login-form-parts\"\n\nconst LINK_CLASS =\n  \"rounded-sm underline-offset-4 outline-none hover:underline focus-visible:ring-[3px] focus-visible:ring-ring/50\"\n\nfunction SignUpLine({ href }: { href: string | null }) {\n  if (!href) return null\n  return (\n    <p className=\"text-[13px] leading-relaxed text-muted-foreground\">\n      No account yet?{\" \"}\n      <a href={href} className={cn(LINK_CLASS, \"font-medium text-foreground\")}>\n        Create an account\n      </a>\n    </p>\n  )\n}\n\ninterface CredentialsFormProps {\n  form: ReturnType<typeof useLoginForm>\n  emailRef: React.RefObject<HTMLInputElement | null>\n  passwordRef: React.RefObject<HTMLInputElement | null>\n  busy: boolean\n  error?: string\n  forgotPasswordHref: string\n}\n\n/** Inputs go read-only while busy instead of disabled: disabling would throw away focus and hide the text. */\nfunction CredentialsForm({ form, emailRef, passwordRef, busy, error, forgotPasswordHref }: CredentialsFormProps) {\n  const emailId = useId()\n  const passwordId = useId()\n  const passwordErrorId = `${passwordId}-error`\n  const passwordError = form.errors.password ?? form.submitError ?? error\n\n  const submit = (event: React.FormEvent<HTMLFormElement>) => {\n    event.preventDefault()\n    if (!busy) void form.submit()\n  }\n\n  return (\n    <form noValidate onSubmit={submit} className=\"flex flex-col gap-6\">\n      <EmailField\n        ref={emailRef}\n        id={emailId}\n        error={form.errors.email}\n        readOnly={busy}\n        value={form.values.email}\n        onChange={(event) => form.change(\"email\", event.target.value)}\n      />\n      <div className=\"flex flex-col gap-2\">\n        <Label htmlFor={passwordId}>Password</Label>\n        <PasswordField\n          ref={passwordRef}\n          id={passwordId}\n          readOnly={busy}\n          value={form.values.password}\n          onChange={(event) => form.change(\"password\", event.target.value)}\n          aria-invalid={passwordError ? true : undefined}\n          aria-describedby={passwordError ? passwordErrorId : undefined}\n        />\n        {/* Under the field, not beside its label: there, Tab would land on the link between email and password. */}\n        <div className=\"flex items-start justify-between gap-4\">\n          <div className=\"min-w-0 flex-1\">{passwordError ? <FieldError id={passwordErrorId}>{passwordError}</FieldError> : null}</div>\n          <a href={forgotPasswordHref} className={cn(LINK_CLASS, \"shrink-0 text-[13px] text-muted-foreground hover:text-foreground\")}>\n            Forgot password?\n          </a>\n        </div>\n      </div>\n      <Button type=\"submit\" disabled={busy} aria-busy={busy || undefined} className=\"w-full\">\n        {busy ? <Loader2 aria-hidden=\"true\" className=\"animate-spin motion-reduce:animate-none\" /> : null}\n        {busy ? \"Logging in\" : \"Log in\"}\n      </Button>\n    </form>\n  )\n}\n\ninterface LoginFieldsProps {\n  onSubmit: (values: LoginValues) => void | Promise<void>\n  error?: string\n  pending: boolean\n  forgotPasswordHref: string\n  socialProviders: readonly LoginProvider[]\n  onSocial?: (id: string) => void\n}\n\n/** Social row and password form, the part `split` and `centered` share. Only what is around them differs. */\nfunction LoginFields({ onSubmit, error, pending, forgotPasswordHref, socialProviders, onSocial }: LoginFieldsProps) {\n  const emailRef = useRef<HTMLInputElement>(null)\n  const passwordRef = useRef<HTMLInputElement>(null)\n  const form = useLoginForm(onSubmit, (field) => (field === \"email\" ? emailRef : passwordRef).current?.focus())\n  const busy = pending || form.submitting\n  return (\n    <div className=\"flex flex-col gap-6\">\n      <SocialRow providers={socialProviders} disabled={busy} onSocial={onSocial} />\n      <CredentialsForm form={form} emailRef={emailRef} passwordRef={passwordRef} busy={busy} error={error} forgotPasswordHref={forgotPasswordHref} />\n    </div>\n  )\n}\n\nexport { LINK_CLASS, LoginFields, SignUpLine, type LoginFieldsProps }\n",
      "type": "registry:component"
    },
    {
      "path": "registry/miseui/blocks/login-form-magic.tsx",
      "content": "import type * as React from \"react\"\nimport { useEffect, useId, useRef } from \"react\"\nimport { Loader2, Mail } from \"lucide-react\"\nimport { motion, useReducedMotion } from \"motion/react\"\nimport { SPRING_DEFAULT } from \"@/registry/miseui/lib/motion\"\nimport { cn } from \"@/registry/miseui/lib/utils\"\nimport { Button } from \"@/registry/miseui/ui/button\"\nimport { SignUpLine } from \"./login-form-credentials\"\nimport { useMagicLink, type MagicLink } from \"./login-form-magic-state\"\nimport { EmailField, SocialRow, type LoginProvider } from \"./login-form-parts\"\n\nconst PREVIEW_DELAY_MS = 900\nconst DEFAULT_RESEND_SECONDS = 30\nconst NO_PROVIDERS: readonly LoginProvider[] = []\nconst MARK_START = { opacity: 0, scale: 0.6 }\nconst MARK_END = { opacity: 1, scale: 1 }\n\n/** Stands in until you pass onSendLink, so the preview reaches the inbox screen. Replace it. */\nfunction previewSend() {\n  return new Promise<void>((resolve) => {\n    window.setTimeout(resolve, PREVIEW_DELAY_MS)\n  })\n}\n\ninterface LoginMagicProps {\n  /** Send the link here. Return a promise to get the loading state; a rejection's message is shown inline. */\n  onSendLink?: (email: string) => void | Promise<void>\n  /** How long before another link may be requested. Long enough for mail to arrive, so the button does not invite duplicates. */\n  resendAfterSeconds?: number\n  /** Under the address on the inbox screen. Say how long your link really lasts. */\n  sentNote?: string\n}\n\nfunction RequestForm({ link, pending, error }: { link: MagicLink; pending: boolean; error?: string }) {\n  const fieldId = useId()\n  const fieldRef = useRef<HTMLInputElement>(null)\n  const busy = pending || link.sending\n  // Back from the inbox screen: this form has just replaced the button they pressed, and focus would fall to the page.\n  useEffect(() => {\n    if (link.cameBack) fieldRef.current?.focus()\n  }, [link.cameBack])\n\n  const submit = async (event: React.FormEvent<HTMLFormElement>) => {\n    event.preventDefault()\n    if (busy) return\n    if (!(await link.submit())) fieldRef.current?.focus()\n  }\n\n  return (\n    <form noValidate onSubmit={submit} className=\"flex flex-col gap-4\">\n      <EmailField\n        ref={fieldRef}\n        id={fieldId}\n        error={link.fieldError ?? link.sendError ?? error}\n        readOnly={busy}\n        value={link.email}\n        placeholder=\"maya@northgate.studio\"\n        onChange={(event) => link.change(event.target.value)}\n        className=\"pointer-coarse:h-10\"\n      />\n      <Button type=\"submit\" disabled={busy} aria-busy={busy || undefined} className=\"w-full pointer-coarse:h-10\">\n        {busy ? <Loader2 aria-hidden=\"true\" className=\"animate-spin motion-reduce:animate-none\" /> : null}\n        {busy ? \"Sending the link\" : \"Email me a link\"}\n      </Button>\n    </form>\n  )\n}\n\nfunction InboxScreen({ link, note }: { link: MagicLink; note: string }) {\n  const reduceMotion = useReducedMotion()\n  const headingRef = useRef<HTMLHeadingElement>(null)\n  // Takes focus so a screen reader hears the result instead of silence after the form disappears.\n  useEffect(() => headingRef.current?.focus(), [])\n  const waiting = link.secondsLeft > 0\n  return (\n    <div className=\"flex flex-col items-start gap-6\">\n      <motion.span\n        data-testid=\"inbox-mark\"\n        className=\"grid size-12 place-items-center rounded-full bg-muted\"\n        initial={reduceMotion ? false : MARK_START}\n        animate={MARK_END}\n        transition={SPRING_DEFAULT}\n      >\n        <Mail aria-hidden=\"true\" className=\"size-6\" />\n      </motion.span>\n      <h2 ref={headingRef} tabIndex={-1} className=\"text-display text-3xl leading-[1.12]! text-balance break-words outline-none @2xl:text-4xl\">\n        Check your inbox. <span className=\"text-muted-foreground\">We sent a link to {link.sentTo}.</span>\n      </h2>\n      <p className=\"text-[15px] leading-relaxed text-pretty text-muted-foreground\">{note}</p>\n      {link.sendError ? (\n        <p role=\"alert\" className=\"text-[13px] leading-snug text-pretty text-destructive\">\n          {link.sendError}\n        </p>\n      ) : null}\n      <div className=\"flex w-full flex-col gap-2\">\n        <Button variant=\"outline\" disabled={waiting || link.sending} aria-busy={link.sending || undefined} onClick={() => void link.resend()} className=\"w-full tabular-nums pointer-coarse:h-10\">\n          {link.sending ? <Loader2 aria-hidden=\"true\" className=\"animate-spin motion-reduce:animate-none\" /> : null}\n          {waiting ? `Send again in ${link.secondsLeft}s` : \"Send again\"}\n        </Button>\n        <Button variant=\"ghost\" onClick={link.startOver} className=\"w-full pointer-coarse:h-10\">\n          Use a different email\n        </Button>\n      </div>\n      <p role=\"status\" className=\"min-h-5 text-[13px] leading-5 text-muted-foreground\">\n        {link.resent ? \"Another link is on its way.\" : \"\"}\n      </p>\n    </div>\n  )\n}\n\ninterface LoginFormMagicProps extends Omit<React.ComponentProps<\"section\">, \"onSubmit\">, LoginMagicProps {\n  error?: string\n  pending?: boolean\n  brandName?: string\n  headingNote?: string\n  signUpHref?: string | null\n  socialProviders?: readonly LoginProvider[]\n  onSocial?: (id: string) => void\n}\n\n/** No card and no panel: with one field left, the sentence and the field are the whole design. */\nfunction LoginFormMagic({\n  onSendLink = previewSend,\n  resendAfterSeconds = DEFAULT_RESEND_SECONDS,\n  sentNote = \"It works for 15 minutes. Not there? Look in spam.\",\n  error,\n  pending = false,\n  brandName = \"Paperline\",\n  headingNote = \"No password to remember.\",\n  signUpHref = null,\n  socialProviders = NO_PROVIDERS,\n  onSocial,\n  className,\n  ...props\n}: LoginFormMagicProps) {\n  const link = useMagicLink(onSendLink, resendAfterSeconds)\n  return (\n    <section data-slot=\"login-form\" data-variant=\"magic\" className={cn(\"@container flex w-full flex-col bg-background\", className)} {...props}>\n      <div className=\"flex min-h-[640px] flex-1 flex-col items-center justify-center px-6 py-12\">\n        <div className=\"flex w-full max-w-sm flex-col gap-8\">\n          {link.sentTo === null ? (\n            <>\n              <h2 className=\"text-display text-3xl leading-[1.12]! text-balance @2xl:text-4xl\">\n                Log in to {brandName}. <span className=\"text-muted-foreground\">{headingNote}</span>\n              </h2>\n              <div className=\"flex flex-col gap-6\">\n                <SocialRow providers={socialProviders} disabled={pending || link.sending} onSocial={onSocial} />\n                <RequestForm link={link} pending={pending} error={error} />\n              </div>\n              {signUpHref ? <SignUpLine href={signUpHref} /> : <p className=\"text-[13px] leading-relaxed text-muted-foreground\">New here? The same link creates your account.</p>}\n            </>\n          ) : (\n            <InboxScreen link={link} note={sentNote} />\n          )}\n        </div>\n      </div>\n    </section>\n  )\n}\n\nexport { LoginFormMagic, type LoginMagicProps }\n",
      "type": "registry:component"
    },
    {
      "path": "registry/miseui/blocks/login-form-magic-state.ts",
      "content": "import { useEffect, useState } from \"react\"\nimport { validateEmail } from \"./login-form-parts\"\n\nconst SEND_FAILED = \"Could not send the link. Check your connection and try again.\"\nconst TICK_MS = 1000\n\nfunction useCountdown() {\n  const [secondsLeft, setSecondsLeft] = useState(0)\n  const running = secondsLeft > 0\n  useEffect(() => {\n    if (!running) return\n    const id = window.setInterval(() => setSecondsLeft((seconds) => Math.max(0, seconds - 1)), TICK_MS)\n    return () => window.clearInterval(id)\n  }, [running])\n  return [secondsLeft, setSecondsLeft] as const\n}\n\n/** The request itself and the wait before another may go out. */\nfunction useLinkRequest(onSendLink: (email: string) => void | Promise<void>, resendAfterSeconds: number) {\n  const [sendError, setSendError] = useState<string>()\n  const [sending, setSending] = useState(false)\n  const [sentTo, setSentTo] = useState<string | null>(null)\n  const [secondsLeft, setSecondsLeft] = useCountdown()\n\n  const send = async (address: string) => {\n    setSending(true)\n    setSendError(undefined)\n    try {\n      await onSendLink(address)\n      setSentTo(address)\n      setSecondsLeft(resendAfterSeconds)\n      return true\n    } catch (failure) {\n      setSendError(failure instanceof Error ? failure.message : SEND_FAILED)\n      return false\n    } finally {\n      setSending(false)\n    }\n  }\n\n  const reset = () => {\n    setSentTo(null)\n    setSendError(undefined)\n    setSecondsLeft(0)\n  }\n\n  return { sendError, setSendError, sending, sentTo, secondsLeft, send, reset }\n}\n\n/** The screen's state. The address survives going back, so nobody retypes it. */\nfunction useMagicLink(onSendLink: (email: string) => void | Promise<void>, resendAfterSeconds: number) {\n  const [email, setEmail] = useState(\"\")\n  const [fieldError, setFieldError] = useState<string>()\n  const [resent, setResent] = useState(false)\n  const [cameBack, setCameBack] = useState(false)\n  const { sendError, setSendError, sending, sentTo, secondsLeft, send, reset } = useLinkRequest(onSendLink, resendAfterSeconds)\n\n  /** False when the field holds the person back, so the screen can move focus to it. */\n  const submit = async () => {\n    const problem = validateEmail(email)\n    setFieldError(problem)\n    if (problem) return false\n    return send(email.trim())\n  }\n\n  const resend = async () => {\n    if (sentTo === null || secondsLeft > 0 || sending) return\n    setResent(await send(sentTo))\n  }\n\n  const change = (value: string) => {\n    setEmail(value)\n    setFieldError(undefined)\n    setSendError(undefined)\n  }\n\n  const startOver = () => {\n    reset()\n    setResent(false)\n    setCameBack(true)\n  }\n\n  return { email, fieldError, sendError, sending, sentTo, resent, cameBack, secondsLeft, change, submit, resend, startOver }\n}\n\ntype MagicLink = ReturnType<typeof useMagicLink>\n\nexport { useMagicLink, type MagicLink }\n",
      "type": "registry:component"
    },
    {
      "path": "registry/miseui/blocks/login-form-parts.tsx",
      "content": "import type * as React from \"react\"\nimport { useState } from \"react\"\nimport { Eye, EyeOff } from \"lucide-react\"\nimport { motion, useReducedMotion } from \"motion/react\"\nimport { SPRING_DEFAULT } from \"@/registry/miseui/lib/motion\"\nimport { Button } from \"@/registry/miseui/ui/button\"\nimport { Input } from \"@/registry/miseui/ui/input\"\nimport { Label } from \"@/registry/miseui/ui/label\"\n\ninterface LoginValues {\n  email: string\n  password: string\n}\n\ninterface LoginProvider {\n  id: string\n  label: string\n}\n\ninterface FieldErrors {\n  email?: string\n  password?: string\n}\n\nconst EMAIL_SHAPE = /^\\S+@\\S+$/\nconst FIELD_ERROR_START = { opacity: 0, y: -4 }\nconst FIELD_ERROR_END = { opacity: 1, y: 0 }\nconst SUBMIT_FAILED = \"Could not log in. Check your connection and try again.\"\n\nfunction validateEmail(email: string) {\n  const trimmed = email.trim()\n  if (!trimmed) return \"Enter your email address.\"\n  return EMAIL_SHAPE.test(trimmed) ? undefined : \"That email looks incomplete. Check the @ and what follows it.\"\n}\n\nfunction validate({ email, password }: LoginValues): FieldErrors {\n  return { email: validateEmail(email), password: password ? undefined : \"Enter your password.\" }\n}\n\nfunction useLoginForm(\n  onSubmit: (values: LoginValues) => void | Promise<void>,\n  focusField: (field: keyof LoginValues) => void,\n) {\n  const [values, setValues] = useState<LoginValues>({ email: \"\", password: \"\" })\n  const [errors, setErrors] = useState<FieldErrors>({})\n  const [submitError, setSubmitError] = useState<string>()\n  const [submitting, setSubmitting] = useState(false)\n\n  const change = (field: keyof LoginValues, value: string) => {\n    setValues((current) => ({ ...current, [field]: value }))\n    setErrors((current) => ({ ...current, [field]: undefined }))\n    setSubmitError(undefined)\n  }\n\n  const submit = async () => {\n    const found = validate(values)\n    setErrors(found)\n    setSubmitError(undefined)\n    if (found.email) return focusField(\"email\")\n    if (found.password) return focusField(\"password\")\n    setSubmitting(true)\n    try {\n      await onSubmit({ ...values, email: values.email.trim() })\n    } catch (error) {\n      setSubmitError(error instanceof Error ? error.message : SUBMIT_FAILED)\n      focusField(\"password\")\n    } finally {\n      setSubmitting(false)\n    }\n  }\n\n  return { values, errors, submitError, submitting, change, submit }\n}\n\nfunction FieldError({ id, children }: { id: string; children: React.ReactNode }) {\n  const reduceMotion = useReducedMotion()\n  return (\n    <motion.p\n      id={id}\n      role=\"alert\"\n      className=\"text-[13px] leading-snug text-pretty text-destructive\"\n      initial={reduceMotion ? false : FIELD_ERROR_START}\n      animate={FIELD_ERROR_END}\n      transition={SPRING_DEFAULT}\n    >\n      {children}\n    </motion.p>\n  )\n}\n\ninterface EmailFieldProps extends Omit<React.ComponentProps<typeof Input>, \"type\" | \"id\"> {\n  id: string\n  error?: string\n}\n\nfunction EmailField({ id, error, ...props }: EmailFieldProps) {\n  const errorId = `${id}-error`\n  return (\n    <div className=\"flex flex-col gap-2\">\n      <Label htmlFor={id}>Email</Label>\n      <Input\n        id={id}\n        type=\"email\"\n        autoComplete=\"email\"\n        autoCapitalize=\"none\"\n        spellCheck={false}\n        aria-invalid={error ? true : undefined}\n        aria-describedby={error ? errorId : undefined}\n        {...props}\n      />\n      {error ? <FieldError id={errorId}>{error}</FieldError> : null}\n    </div>\n  )\n}\n\ninterface PasswordFieldProps extends Omit<React.ComponentProps<typeof Input>, \"type\"> {\n  id: string\n}\n\n/** Seeing what was typed beats retyping it blind: the toggle swaps the type and leaves the value and the caret alone. */\nfunction PasswordField({ id, ...props }: PasswordFieldProps) {\n  const [visible, setVisible] = useState(false)\n  return (\n    <div className=\"relative\">\n      <Input id={id} type={visible ? \"text\" : \"password\"} autoComplete=\"current-password\" className=\"pr-12\" {...props} />\n      <Button\n        type=\"button\"\n        variant=\"ghost\"\n        size=\"icon\"\n        aria-label={visible ? \"Hide password\" : \"Show password\"}\n        aria-pressed={visible}\n        onClick={() => setVisible((current) => !current)}\n        className=\"absolute inset-y-0 right-0 text-muted-foreground\"\n      >\n        {visible ? <EyeOff /> : <Eye />}\n      </Button>\n    </div>\n  )\n}\n\ninterface SocialRowProps {\n  providers: readonly LoginProvider[]\n  disabled: boolean\n  onSocial?: (id: string) => void\n}\n\nfunction SocialRow({ providers, disabled, onSocial }: SocialRowProps) {\n  if (providers.length === 0) return null\n  return (\n    <div className=\"flex flex-col gap-6\">\n      <div className=\"flex gap-2\">\n        {providers.map((provider) => (\n          <Button\n            key={provider.id}\n            type=\"button\"\n            variant=\"outline\"\n            disabled={disabled}\n            aria-label={`Continue with ${provider.label}`}\n            onClick={() => onSocial?.(provider.id)}\n            className=\"min-w-0 flex-1\"\n          >\n            {provider.label}\n          </Button>\n        ))}\n      </div>\n      <div className=\"flex items-center gap-3 text-[13px] text-muted-foreground\">\n        <span aria-hidden=\"true\" className=\"h-px flex-1 bg-border\" />\n        or with email\n        <span aria-hidden=\"true\" className=\"h-px flex-1 bg-border\" />\n      </div>\n    </div>\n  )\n}\n\nexport {\n  EmailField,\n  FieldError,\n  PasswordField,\n  SocialRow,\n  useLoginForm,\n  validateEmail,\n  type LoginProvider,\n  type LoginValues,\n}\n",
      "type": "registry:component"
    },
    {
      "path": "registry/miseui/blocks/login-form-visual.tsx",
      "content": "import type * as React from \"react\"\nimport { Check } from \"lucide-react\"\nimport { cn } from \"@/registry/miseui/lib/utils\"\nimport { Badge } from \"@/registry/miseui/ui/badge\"\nimport { Card } from \"@/registry/miseui/ui/card\"\n\nconst SOFT_SHADOW_CLASS = \"shadow-[0_16px_40px_-24px_color-mix(in_oklab,var(--mise)_24%,oklch(0_0_0/40%))]\"\n/** A whisper of the accent on a neutral: the panel belongs to the brand in every palette without shouting. */\nconst PANEL_TINT_CLASS = \"bg-[color-mix(in_oklab,var(--mise)_6%,var(--muted))]\"\nconst GRID_CELL_PX = 32\nconst GRID_STYLE: React.CSSProperties = {\n  backgroundImage:\n    \"linear-gradient(to right, var(--border) 1px, transparent 1px), linear-gradient(to bottom, var(--border) 1px, transparent 1px)\",\n  backgroundSize: `${GRID_CELL_PX}px ${GRID_CELL_PX}px`,\n  maskImage: \"radial-gradient(ellipse at center, #000 20%, transparent 72%)\",\n  opacity: 0.5,\n}\n\n/** Sample product UI, so it is hidden from assistive tech: nobody logging in needs a stranger's invoice read out. */\nfunction InvoiceFragments() {\n  return (\n    <div aria-hidden=\"true\" data-testid=\"login-visual\" className=\"relative mt-8 w-full max-w-xs\">\n      <Card className=\"absolute inset-x-4 -top-8 gap-0 rounded-2xl bg-card px-4 py-2 shadow-none\">\n        <div className=\"flex items-center justify-between gap-3 text-[13px] text-muted-foreground\">\n          Invoice 1041\n          <Badge variant=\"outline\">Paid</Badge>\n        </div>\n      </Card>\n      <Card className={cn(\"relative gap-3 rounded-2xl bg-popover p-6\", SOFT_SHADOW_CLASS)}>\n        <div className=\"flex items-center justify-between gap-3 text-[13px] text-muted-foreground\">\n          Invoice 1042\n          <Badge variant=\"secondary\">Due in 3 days</Badge>\n        </div>\n        <div className=\"flex flex-col gap-1\">\n          <p className=\"text-[15px]\">Northgate Studio</p>\n          <p className=\"text-display text-3xl tabular-nums\">$1,240.00</p>\n        </div>\n      </Card>\n      <Badge variant=\"mise\" className={cn(\"absolute -right-3 -bottom-3\", SOFT_SHADOW_CLASS)}>\n        <Check />\n        Reminder sent\n      </Badge>\n    </div>\n  )\n}\n\ninterface BrandPanelProps {\n  brandName: string\n  tagline: string\n  visual: React.ReactNode\n}\n\n/** Inset from the edge and rounded like the cards, so it reads as a calm surface and not a half-painted page. */\nfunction BrandPanel({ brandName, tagline, visual }: BrandPanelProps) {\n  return (\n    <aside className={cn(\"relative isolate m-2 hidden flex-col justify-between gap-8 overflow-hidden rounded-2xl border p-8 @3xl:flex @5xl:p-12\", PANEL_TINT_CLASS)}>\n      <span aria-hidden=\"true\" className=\"absolute inset-0 -z-10\" style={GRID_STYLE} />\n      <span className=\"text-[15px] font-medium\">{brandName}</span>\n      <div className=\"flex flex-1 items-center justify-center\">{visual}</div>\n      <p className=\"text-display max-w-md text-3xl leading-[1.12]! text-balance @5xl:text-4xl\">{tagline}</p>\n    </aside>\n  )\n}\n\nexport { BrandPanel, InvoiceFragments }\n",
      "type": "registry:component"
    }
  ],
  "categories": [
    "blocks"
  ],
  "type": "registry:block"
}