{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "sign-in-minimal",
  "type": "registry:block",
  "title": "Sign In Minimal",
  "description": "Editorial single-column sign-in with an optional magic-link mode.",
  "files": [
    {
      "path": "src/registry/blocks/auth/sign-in-minimal.tsx",
      "type": "registry:block",
      "content": "\"use client\";\n\nimport {\n  useEffect,\n  useId,\n  useRef,\n  useState,\n  type ChangeEvent,\n  type ComponentProps,\n  type CSSProperties,\n  type FormEvent,\n} from \"react\";\nimport { Eye, EyeOff, Loader2 } from \"lucide-react\";\n\nimport { Button } from \"@/components/ui/button\";\nimport { Input } from \"@/components/ui/input\";\nimport { Label } from \"@/components/ui/label\";\nimport { cn } from \"@/lib/utils\";\n\nexport type SignInMinimalMethod = \"password\" | \"magic-link\";\n\nexport type SignInMinimalValues =\n  | { method: \"password\"; email: string; password: string }\n  | { method: \"magic-link\"; email: string };\n\nexport type SignInMinimalProvider = { id: string; label: string };\n\nexport type SignInMinimalProps = {\n  title?: string;\n  /** Mono context line under the headline, e.g. the workspace address. */\n  context?: string;\n  /** Short lines in the left margin column. */\n  notes?: string[];\n  providers?: SignInMinimalProvider[];\n  onProviderClick?: (id: string) => void;\n  onSubmit?: (values: SignInMinimalValues) => void | Promise<void>;\n  /** Show the \"Email me a sign-in link\" toggle. */\n  allowMagicLink?: boolean;\n  defaultMethod?: SignInMinimalMethod;\n  forgotPasswordHref?: string;\n  signUpHref?: string;\n  termsHref?: string;\n  privacyHref?: string;\n  /** Service status line in the footer row. Pass an empty string to hide it. */\n  statusLabel?: string;\n  /** Wordmark square, status marker and primary button. Defaults to Devsloka blue. */\n  accent?: string;\n  /** Text colour on `accent`. Defaults to white. */\n  accentForeground?: string;\n} & Omit<ComponentProps<\"section\">, \"onSubmit\">;\n\nconst DEFAULTS = {\n  title: \"Welcome back.\",\n  context: \"Workspace: field-notes.larch.app\",\n  notes: [\n    \"Larch is a shared notebook for small research teams.\",\n    \"Interviews, field notes and tags in one place.\",\n  ],\n  providers: [\n    { id: \"google\", label: \"Continue with Google\" },\n    { id: \"sso\", label: \"Continue with SSO\" },\n  ],\n  statusLabel: \"All systems normal\",\n  accent: \"#0A6EFF\",\n  accentForeground: \"#FFFFFF\",\n};\n\ntype Field = \"email\" | \"password\";\ntype Errors = Partial<Record<Field, string>>;\ntype Status = \"idle\" | \"submitting\" | \"success\" | \"error\";\n\nconst EMAIL_PATTERN = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/;\n\nfunction validate(values: Record<Field, string>, method: SignInMinimalMethod): Errors {\n  const errors: Errors = {};\n  const email = values.email.trim();\n  if (!email) errors.email = \"Enter the email you use for Larch.\";\n  else if (!EMAIL_PATTERN.test(email))\n    errors.email = \"That email looks incomplete. Check for a typo.\";\n  if (method === \"password\" && !values.password) errors.password = \"Enter your password.\";\n  return errors;\n}\n\nconst defaultSubmit = () =>\n  new Promise<void>((resolve) => setTimeout(resolve, 900));\n\nconst linkClass =\n  \"rounded-sm underline decoration-1 underline-offset-4 outline-none hover:decoration-2 focus-visible:ring-2 focus-visible:ring-ring\";\n\nexport function SignInMinimal({\n  title = DEFAULTS.title,\n  context = DEFAULTS.context,\n  notes = DEFAULTS.notes,\n  providers = DEFAULTS.providers,\n  onProviderClick,\n  onSubmit = defaultSubmit,\n  allowMagicLink = true,\n  defaultMethod = \"password\",\n  forgotPasswordHref = \"#\",\n  signUpHref = \"#\",\n  termsHref = \"#\",\n  privacyHref = \"#\",\n  statusLabel = DEFAULTS.statusLabel,\n  accent = DEFAULTS.accent,\n  accentForeground = DEFAULTS.accentForeground,\n  className,\n  style,\n  ...props\n}: SignInMinimalProps) {\n  const id = useId();\n  const inboxHeadingRef = useRef<HTMLHeadingElement>(null);\n  const [method, setMethod] = useState<SignInMinimalMethod>(\n    allowMagicLink ? defaultMethod : \"password\"\n  );\n  const [values, setValues] = useState<Record<Field, string>>({ email: \"\", password: \"\" });\n  const [showPassword, setShowPassword] = useState(false);\n  const [errors, setErrors] = useState<Errors>({});\n  const [attempted, setAttempted] = useState(false);\n  const [status, setStatus] = useState<Status>(\"idle\");\n  const [message, setMessage] = useState(\"\");\n\n  const fieldId = (name: Field) => `${id}-${name}`;\n  const errorId = (name: Field) => `${id}-${name}-error`;\n  const submitting = status === \"submitting\";\n  const linkSent = method === \"magic-link\" && status === \"success\";\n\n  useEffect(() => {\n    if (linkSent) inboxHeadingRef.current?.focus();\n  }, [linkSent]);\n\n  const switchMethod = () => {\n    setMethod((current) => (current === \"password\" ? \"magic-link\" : \"password\"));\n    setErrors({});\n    setStatus(\"idle\");\n    setMessage(\"\");\n  };\n\n  const handleSubmit = async (event: FormEvent<HTMLFormElement>) => {\n    event.preventDefault();\n    setAttempted(true);\n    const nextErrors = validate(values, method);\n    setErrors(nextErrors);\n    const firstInvalid = (Object.keys(nextErrors) as Field[])[0];\n    if (firstInvalid) {\n      document.getElementById(fieldId(firstInvalid))?.focus();\n      return;\n    }\n\n    const email = values.email.trim();\n    setStatus(\"submitting\");\n    setMessage(\"\");\n    try {\n      await onSubmit(\n        method === \"password\"\n          ? { method, email, password: values.password }\n          : { method, email }\n      );\n      setStatus(\"success\");\n      setMessage(\n        method === \"password\"\n          ? \"Signed in. Opening your workspace…\"\n          : `Check your inbox. We sent a sign-in link to ${email}.`\n      );\n    } catch (error) {\n      setStatus(\"error\");\n      setMessage(\n        error instanceof Error && error.message\n          ? error.message\n          : method === \"password\"\n            ? \"That email and password don't match an account here. Check both and try again.\"\n            : \"We couldn't send the link just now. Wait a minute and try again.\"\n      );\n    }\n  };\n\n  const fieldProps = (name: Field) => ({\n    id: fieldId(name),\n    name,\n    value: values[name],\n    \"aria-invalid\": errors[name] ? true : undefined,\n    \"aria-describedby\": errors[name] ? errorId(name) : undefined,\n    onChange: (event: ChangeEvent<HTMLInputElement>) =>\n      setValues((current) => ({ ...current, [name]: event.target.value })),\n    onBlur: () => {\n      if (attempted)\n        setErrors((current) => ({ ...current, [name]: validate(values, method)[name] }));\n    },\n  });\n\n  const errorText = (name: Field) =>\n    errors[name] ? (\n      <p id={errorId(name)} className=\"text-xs text-destructive\">\n        {errors[name]}\n      </p>\n    ) : null;\n\n  return (\n    <section\n      data-slot=\"sign-in-minimal\"\n      aria-labelledby={`${id}-title`}\n      style={\n        {\n          \"--block-accent\": accent,\n          \"--block-accent-fg\": accentForeground,\n          ...style,\n        } as CSSProperties\n      }\n      className={cn(\"w-full bg-background text-foreground\", className)}\n      {...props}\n    >\n      <div className=\"mx-auto max-w-6xl px-6 py-16 md:py-24\">\n        <div className=\"grid gap-12 md:grid-cols-12 md:gap-8\">\n          <div className=\"md:col-span-4\">\n            <span className=\"inline-flex items-center gap-2 text-lg font-semibold tracking-tight\">\n              <span aria-hidden=\"true\" className=\"size-2.5 bg-[var(--block-accent)]\" />\n              Larch\n            </span>\n            {notes.length > 0 ? (\n              <ul className=\"mt-6 hidden max-w-[16rem] space-y-2 text-sm leading-relaxed text-muted-foreground md:block\">\n                {notes.map((note) => (\n                  <li key={note}>{note}</li>\n                ))}\n              </ul>\n            ) : null}\n          </div>\n\n          <div className=\"md:col-span-6 md:col-start-6\">\n            <h2\n              id={`${id}-title`}\n              className=\"text-5xl font-semibold tracking-[-0.04em] md:text-7xl\"\n            >\n              {title}\n            </h2>\n            {context ? (\n              <p className=\"mt-4 font-mono text-xs tracking-wider text-muted-foreground\">\n                {context}\n              </p>\n            ) : null}\n\n            <div className=\"mt-12 max-w-md border-t pt-8\">\n              <p role=\"status\" aria-live=\"polite\" className=\"sr-only\">\n                {linkSent ? message : \"\"}\n              </p>\n\n              {linkSent ? (\n                <div>\n                  <p className=\"font-mono text-xs tracking-wider text-muted-foreground uppercase\">\n                    Link sent\n                  </p>\n                  <h3\n                    ref={inboxHeadingRef}\n                    tabIndex={-1}\n                    className=\"mt-3 text-2xl font-semibold tracking-tight outline-none\"\n                  >\n                    Check your inbox\n                  </h3>\n                  <p className=\"mt-3 text-sm leading-relaxed text-muted-foreground\">\n                    We sent a sign-in link to{\" \"}\n                    <span className=\"font-medium text-foreground\">{values.email.trim()}</span>.\n                    It works once and expires in 15 minutes. Nothing there? Check spam, or\n                    ask your admin whether Larch emails are filtered.\n                  </p>\n                  <div className=\"mt-8 flex flex-wrap gap-x-6 gap-y-3 text-sm\">\n                    <button\n                      type=\"button\"\n                      onClick={() => {\n                        setStatus(\"idle\");\n                        setMessage(\"\");\n                      }}\n                      className={cn(linkClass, \"font-medium\")}\n                    >\n                      Use a different email\n                    </button>\n                    <button type=\"button\" onClick={switchMethod} className={cn(linkClass, \"text-muted-foreground hover:text-foreground\")}>\n                      Sign in with a password\n                    </button>\n                  </div>\n                </div>\n              ) : (\n                <form\n                  noValidate\n                  onSubmit={handleSubmit}\n                  aria-busy={submitting}\n                  className=\"grid gap-6\"\n                >\n                  <div className=\"grid gap-2\">\n                    <Label htmlFor={fieldId(\"email\")}>Email</Label>\n                    <Input\n                      {...fieldProps(\"email\")}\n                      type=\"email\"\n                      autoComplete=\"email\"\n                      inputMode=\"email\"\n                      required\n                    />\n                    {errorText(\"email\")}\n                  </div>\n\n                  {method === \"password\" ? (\n                    <div className=\"grid gap-2\">\n                      <div className=\"flex items-baseline justify-between gap-4\">\n                        <Label htmlFor={fieldId(\"password\")}>Password</Label>\n                        <a\n                          href={forgotPasswordHref}\n                          className={cn(linkClass, \"text-xs text-muted-foreground hover:text-foreground\")}\n                        >\n                          Forgot password?\n                        </a>\n                      </div>\n                      <div className=\"relative\">\n                        <Input\n                          {...fieldProps(\"password\")}\n                          type={showPassword ? \"text\" : \"password\"}\n                          autoComplete=\"current-password\"\n                          required\n                          className=\"pr-10\"\n                        />\n                        <button\n                          type=\"button\"\n                          aria-label={showPassword ? \"Hide password\" : \"Show password\"}\n                          onClick={() => setShowPassword((current) => !current)}\n                          className=\"absolute inset-y-0 right-0 flex w-10 items-center justify-center rounded-r-md text-muted-foreground outline-none hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring\"\n                        >\n                          {showPassword ? (\n                            <EyeOff aria-hidden=\"true\" className=\"size-4\" />\n                          ) : (\n                            <Eye aria-hidden=\"true\" className=\"size-4\" />\n                          )}\n                        </button>\n                      </div>\n                      {errorText(\"password\")}\n                    </div>\n                  ) : (\n                    <p className=\"text-sm leading-relaxed text-muted-foreground\">\n                      We&apos;ll email you a link that signs you in once. No password needed.\n                    </p>\n                  )}\n\n                  <div className=\"flex flex-wrap items-center justify-between gap-x-6 gap-y-4\">\n                    <Button\n                      type=\"submit\"\n                      size=\"lg\"\n                      disabled={submitting}\n                      className=\"rounded-none bg-[var(--block-accent)] text-[var(--block-accent-fg)] shadow-none hover:bg-[var(--block-accent)] hover:underline hover:underline-offset-4\"\n                    >\n                      {submitting ? (\n                        <>\n                          <Loader2 aria-hidden=\"true\" className=\"animate-spin motion-reduce:animate-none\" />\n                          {method === \"password\" ? \"Signing in…\" : \"Sending link…\"}\n                        </>\n                      ) : method === \"password\" ? (\n                        \"Sign in\"\n                      ) : (\n                        \"Email me a sign-in link\"\n                      )}\n                    </Button>\n                    {allowMagicLink ? (\n                      <button\n                        type=\"button\"\n                        onClick={switchMethod}\n                        className={cn(linkClass, \"text-sm text-muted-foreground hover:text-foreground\")}\n                      >\n                        {method === \"password\"\n                          ? \"Email me a sign-in link instead\"\n                          : \"Use my password instead\"}\n                      </button>\n                    ) : null}\n                  </div>\n\n                  <p\n                    role=\"status\"\n                    aria-live=\"polite\"\n                    className={cn(\n                      \"text-sm empty:hidden\",\n                      status === \"error\" && \"border-l-2 border-destructive pl-3 text-destructive\"\n                    )}\n                  >\n                    {message}\n                  </p>\n                </form>\n              )}\n\n              {providers.length > 0 && !linkSent ? (\n                <div className=\"mt-10 border-t pt-6\">\n                  <p className=\"font-mono text-[11px] tracking-wider text-muted-foreground uppercase\">\n                    Or\n                  </p>\n                  <ul className=\"mt-3 flex flex-wrap gap-x-6 gap-y-2 text-sm\">\n                    {providers.map((provider) => (\n                      <li key={provider.id}>\n                        <button\n                          type=\"button\"\n                          onClick={() => onProviderClick?.(provider.id)}\n                          className={cn(linkClass, \"font-medium\")}\n                        >\n                          {provider.label}\n                        </button>\n                      </li>\n                    ))}\n                  </ul>\n                </div>\n              ) : null}\n\n              <p className=\"mt-10 text-sm text-muted-foreground\">\n                No account yet?{\" \"}\n                <a href={signUpHref} className={cn(linkClass, \"font-medium text-foreground\")}>\n                  Create one\n                </a>\n              </p>\n            </div>\n          </div>\n        </div>\n\n        <div className=\"mt-16 flex flex-wrap items-center justify-between gap-4 border-t pt-6 font-mono text-[11px] tracking-wider text-muted-foreground uppercase md:mt-24\">\n          <nav aria-label=\"Legal\" className=\"flex gap-6\">\n            <a href={termsHref} className={cn(linkClass, \"hover:text-foreground\")}>\n              Terms\n            </a>\n            <a href={privacyHref} className={cn(linkClass, \"hover:text-foreground\")}>\n              Privacy\n            </a>\n          </nav>\n          {statusLabel ? (\n            <p className=\"flex items-center gap-2\">\n              <span aria-hidden=\"true\" className=\"size-1.5 bg-[var(--block-accent)]\" />\n              {statusLabel}\n            </p>\n          ) : null}\n        </div>\n      </div>\n    </section>\n  );\n}\n"
    }
  ],
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [
    "button",
    "input",
    "label"
  ]
}
