{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "sign-in",
  "type": "registry:block",
  "title": "Sign In",
  "description": "A minimal centred sign-in: passkey and single sign-on side by side, email and password with a show toggle, a gentle shake when the password is wrong and a check when you’re in.",
  "categories": [
    "screen",
    "Auth"
  ],
  "dependencies": [
    "lucide-react",
    "motion"
  ],
  "registryDependencies": [
    "utils",
    "https://coss.com/ui/r/button.json",
    "https://coss.com/ui/r/input.json",
    "https://coss.com/ui/r/input-group.json",
    "https://coss.com/ui/r/label.json"
  ],
  "files": [
    {
      "path": "registry/devl/sign-in.tsx",
      "type": "registry:component",
      "content": "\"use client\";\n\nimport { Building2Icon, CheckIcon, EyeIcon, EyeOffIcon, FingerprintIcon } from \"lucide-react\";\nimport { motion, useAnimationControls, useReducedMotion } from \"motion/react\";\nimport { type FormEvent, type ReactNode, useId, useState } from \"react\";\nimport { Button } from \"@/components/ui/button\";\nimport { Input } from \"@/components/ui/input\";\nimport { InputGroup, InputGroupAddon, InputGroupInput } from \"@/components/ui/input-group\";\nimport { Label } from \"@/components/ui/label\";\nimport { cn } from \"@/lib/utils\";\n\nexport type SignInResult = { ok: true } | { ok: false; error: string };\n\nexport interface SignInProps {\n  product?: string;\n  logo?: ReactNode;\n  defaultEmail?: string;\n  onSignIn?: (email: string, password: string) => Promise<SignInResult>;\n  onPasskey?: () => Promise<SignInResult>;\n  onSso?: () => void;\n  onForgotPassword?: () => void;\n  onSignUp?: () => void;\n  className?: string;\n}\n\nconst wait = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));\n\nasync function demoSignIn(_email: string, password: string): Promise<SignInResult> {\n  await wait(900);\n  if (password.length < 8 || password.toLowerCase().includes(\"wrong\")) {\n    return { ok: false, error: \"That password doesn’t match this account.\" };\n  }\n  return { ok: true };\n}\n\nasync function demoPasskey(): Promise<SignInResult> {\n  await wait(1200);\n  return { ok: true };\n}\n\nfunction Mark() {\n  return (\n    <span className=\"flex size-10 items-center justify-center rounded-xl bg-primary text-primary-foreground shadow-xs/5\">\n      <svg aria-hidden className=\"size-6\" fill=\"none\" viewBox=\"0 0 28 28\">\n        <path d=\"M7 18.5 12 12l3.5 4.5 2-2.5 3.5 4.5\" stroke=\"currentColor\" strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth=\"2.2\" />\n      </svg>\n    </span>\n  );\n}\n\nexport function SignIn({\n  product = \"Ridgeline\",\n  logo,\n  defaultEmail = \"ada@ridgeline.app\",\n  onSignIn = demoSignIn,\n  onPasskey = demoPasskey,\n  onSso,\n  onForgotPassword,\n  onSignUp,\n  className,\n}: SignInProps) {\n  const id = useId();\n  const reduce = useReducedMotion();\n  const shake = useAnimationControls();\n  const [email, setEmail] = useState(defaultEmail);\n  const [password, setPassword] = useState(\"\");\n  const [reveal, setReveal] = useState(false);\n  const [busy, setBusy] = useState<\"password\" | \"passkey\" | null>(null);\n  const [error, setError] = useState<string | null>(null);\n  const [done, setDone] = useState(false);\n\n  const finish = async (result: SignInResult) => {\n    setBusy(null);\n    if (result.ok) {\n      setDone(true);\n      return;\n    }\n    setError(result.error);\n    if (!reduce) await shake.start({ x: [0, -6, 6, -4, 4, 0], transition: { duration: 0.36 } });\n  };\n\n  const submit = async (event: FormEvent) => {\n    event.preventDefault();\n    if (busy || done) return;\n    setError(null);\n    setBusy(\"password\");\n    await finish(await onSignIn(email, password));\n  };\n\n  const passkey = async () => {\n    if (busy || done) return;\n    setError(null);\n    setBusy(\"passkey\");\n    await finish(await onPasskey());\n  };\n\n  return (\n    <div className={cn(\"flex h-[760px] w-full flex-col overflow-y-auto bg-background px-6 py-10 text-foreground\", className)}>\n      <div className=\"m-auto flex w-full max-w-[340px] flex-col items-center\">\n        {logo ?? <Mark />}\n        <h1 className=\"mt-6 text-balance text-center font-semibold text-xl tracking-tight\">Sign in to {product}</h1>\n        <p className=\"mt-1.5 text-balance text-center text-muted-foreground text-sm\">Welcome back. Pick up where you left off.</p>\n\n        <div className=\"mt-8 grid w-full grid-cols-2 gap-2\">\n          <Button disabled={done} loading={busy === \"passkey\"} onClick={passkey} type=\"button\" variant=\"outline\">\n            <FingerprintIcon />\n            Passkey\n          </Button>\n          <Button disabled={done || busy !== null} onClick={onSso} type=\"button\" variant=\"outline\">\n            <Building2Icon />\n            SSO\n          </Button>\n        </div>\n\n        <div className=\"my-6 flex w-full items-center gap-3 text-muted-foreground text-xs\">\n          <span className=\"h-px flex-1 bg-border\" />\n          or\n          <span className=\"h-px flex-1 bg-border\" />\n        </div>\n\n        <form className=\"flex w-full flex-col gap-4\" noValidate onSubmit={submit}>\n          <div className=\"flex flex-col gap-2\">\n            <Label htmlFor={`${id}-email`}>Email</Label>\n            <Input\n              autoComplete=\"email\"\n              disabled={done}\n              id={`${id}-email`}\n              onChange={(event) => setEmail(event.target.value)}\n              placeholder=\"you@company.com\"\n              type=\"email\"\n              value={email}\n            />\n          </div>\n          <motion.div animate={shake} className=\"flex flex-col gap-2\">\n            <div className=\"flex items-center justify-between\">\n              <Label htmlFor={`${id}-password`}>Password</Label>\n              <button\n                className=\"cursor-pointer rounded-sm text-muted-foreground text-sm outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring\"\n                onClick={onForgotPassword}\n                type=\"button\"\n              >\n                Forgot password?\n              </button>\n            </div>\n            <InputGroup>\n              <InputGroupInput\n                aria-describedby={error ? `${id}-error` : undefined}\n                aria-invalid={error ? true : undefined}\n                autoComplete=\"current-password\"\n                disabled={done}\n                id={`${id}-password`}\n                onChange={(event) => {\n                  setPassword(event.target.value);\n                  setError(null);\n                }}\n                placeholder=\"Your password\"\n                type={reveal ? \"text\" : \"password\"}\n                value={password}\n              />\n              <InputGroupAddon align=\"inline-end\">\n                <button\n                  aria-label={reveal ? \"Hide password\" : \"Show password\"}\n                  className=\"flex size-6 cursor-pointer items-center justify-center rounded-md text-muted-foreground outline-none transition-colors hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring\"\n                  onClick={() => setReveal((value) => !value)}\n                  type=\"button\"\n                >\n                  {reveal ? <EyeOffIcon className=\"size-4\" /> : <EyeIcon className=\"size-4\" />}\n                </button>\n              </InputGroupAddon>\n            </InputGroup>\n            {error && (\n              <p className=\"text-destructive-foreground text-xs\" id={`${id}-error`} role=\"alert\">\n                {error}\n              </p>\n            )}\n          </motion.div>\n          <Button className={cn(\"mt-2 w-full\", done && \"pointer-events-none\")} loading={busy === \"password\"} type=\"submit\">\n            {done ? (\n              <motion.span animate={{ opacity: 1, scale: 1 }} className=\"flex items-center gap-2\" initial={reduce ? false : { opacity: 0, scale: 0.9 }}>\n                <CheckIcon />\n                Signed in\n              </motion.span>\n            ) : (\n              \"Sign in\"\n            )}\n          </Button>\n        </form>\n\n        <p className=\"mt-8 text-center text-muted-foreground text-sm\">\n          Don’t have an account?{\" \"}\n          <button\n            className=\"cursor-pointer rounded-sm font-medium text-foreground underline-offset-4 outline-none hover:underline focus-visible:ring-2 focus-visible:ring-ring\"\n            onClick={onSignUp}\n            type=\"button\"\n          >\n            Sign up\n          </button>\n        </p>\n      </div>\n    </div>\n  );\n}\n"
    }
  ]
}