{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"sign-in","type":"registry:block","title":"Sign in","description":"Google and GitHub, or email and password with Forgot password, remember me, loading and a wrong-password error.","dependencies":["lucide-react"],"registryDependencies":["https://dashral.com/r/utils.json","https://dashral.com/r/alert.json","https://dashral.com/r/button.json","https://dashral.com/r/checkbox.json","https://dashral.com/r/input.json","https://dashral.com/r/separator.json"],"files":[{"path":"registry/dashral/blocks/sign-in.tsx","type":"registry:file","target":"components/dashral/blocks/sign-in.tsx","content":"\"use client\"\n\nimport { useState } from \"react\"\nimport { Sparkles } from \"lucide-react\"\nimport { Alert } from \"../alert\"\nimport { Button } from \"../button\"\nimport { Checkbox } from \"../checkbox\"\nimport { Input } from \"../input\"\nimport { Separator } from \"../separator\"\n\nconst google = (\n  <svg viewBox=\"0 0 24 24\" aria-hidden className=\"size-4\">\n    <path fill=\"#4285F4\" d=\"M23.5 12.3c0-.8-.1-1.6-.2-2.3H12v4.4h6.5a5.6 5.6 0 0 1-2.4 3.6v3h3.9c2.2-2.1 3.5-5.1 3.5-8.7Z\" />\n    <path fill=\"#34A853\" d=\"M12 24c3.2 0 6-1.1 7.9-2.9l-3.9-3c-1 .7-2.4 1.2-4 1.2-3.1 0-5.7-2.1-6.6-4.9h-4v3.1A12 12 0 0 0 12 24Z\" />\n    <path fill=\"#FBBC05\" d=\"M5.4 14.4a7.2 7.2 0 0 1 0-4.7V6.6h-4a12 12 0 0 0 0 10.9l4-3.1Z\" />\n    <path fill=\"#EA4335\" d=\"M12 4.8c1.8 0 3.3.6 4.6 1.8l3.4-3.4A12 12 0 0 0 1.4 6.6l4 3.1C6.3 6.9 8.9 4.8 12 4.8Z\" />\n  </svg>\n)\nconst github = (\n  <svg viewBox=\"0 0 24 24\" fill=\"currentColor\" aria-hidden className=\"size-4\">\n    <path d=\"M12 .5a11.5 11.5 0 0 0-3.64 22.41c.58.1.79-.25.79-.56v-2c-3.2.7-3.88-1.37-3.88-1.37-.52-1.33-1.28-1.69-1.28-1.69-1.05-.71.08-.7.08-.7 1.16.08 1.77 1.19 1.77 1.19 1.03 1.77 2.7 1.26 3.36.96.1-.75.4-1.26.73-1.55-2.55-.29-5.24-1.28-5.24-5.69 0-1.26.45-2.29 1.19-3.1-.12-.29-.52-1.46.11-3.05 0 0 .97-.31 3.17 1.18a11 11 0 0 1 5.77 0c2.2-1.49 3.17-1.18 3.17-1.18.63 1.59.23 2.76.11 3.05.74.81 1.19 1.84 1.19 3.1 0 4.42-2.7 5.4-5.26 5.68.41.36.78 1.06.78 2.14v3.17c0 .31.21.67.8.56A11.5 11.5 0 0 0 12 .5Z\" />\n  </svg>\n)\n\nexport type SignInValues = { email: string; password: string; remember: boolean }\n\nexport type SignInProps = {\n  title?: React.ReactNode\n  description?: React.ReactNode\n  /** The buttons above the form; none hides them and the \"or\" under them. */\n  providers?: { id: string; label: string; icon?: React.ReactNode }[]\n  /** Called with a provider's id when its button is pressed, e.g. to start its sign-in. */\n  onProvider?: (id: string) => void\n  /**\n   * Your sign-in. Resolve to sign in (the card says so); throw an Error to show its message above the form. Without\n   * it, the card plays a sample: any email with the password \"password\".\n   */\n  onSubmit?: (values: SignInValues) => Promise<void> | void\n  /** Where \"Forgot password?\" and \"Create an account\" go; none hides them. */\n  forgotHref?: string\n  signUpHref?: string\n  /** The words before \"Create an account\". */\n  signUpPrompt?: string\n  /** What the card says once signed in. */\n  done?: { title: string; description?: string }\n}\n\n/**\n * A sign-in card: providers such as Google and GitHub, or email and password with \"Forgot password?\" by the label, a\n * remember-me box and a loading state. An error shows above the form. Every part comes from props; wire `onSubmit`\n * to your auth (without it, try any email with the password \"password\").\n */\nexport function SignIn({\n  title = \"Welcome back\",\n  description = \"Sign in to your Acme workspace\",\n  providers = [\n    { id: \"google\", label: \"Google\", icon: google },\n    { id: \"github\", label: \"GitHub\", icon: github },\n  ],\n  onProvider,\n  onSubmit,\n  forgotHref = \"#\",\n  signUpHref = \"#\",\n  signUpPrompt = \"New to Acme?\",\n  done = { title: \"Signed in\", description: \"Taking you to your dashboard…\" },\n}: SignInProps) {\n  const [email, setEmail] = useState(\"\")\n  const [password, setPassword] = useState(\"\")\n  const [remember, setRemember] = useState(true)\n  const [state, setState] = useState<\"idle\" | \"loading\" | \"wrong\" | \"done\">(\"idle\")\n  const [error, setError] = useState<string | null>(null)\n\n  async function submit(event: React.FormEvent) {\n    event.preventDefault()\n    setState(\"loading\")\n    if (!onSubmit) {\n      window.setTimeout(() => {\n        setError(password === \"password\" ? null : \"That password isn't right\")\n        setState(password === \"password\" ? \"done\" : \"wrong\")\n      }, 800)\n      return\n    }\n    try {\n      await onSubmit({ email, password, remember })\n      setState(\"done\")\n    } catch (e) {\n      setError(e instanceof Error ? e.message : \"Couldn't sign you in\")\n      setState(\"wrong\")\n    }\n  }\n\n  return (\n    <section className=\"flex min-h-svh items-center justify-center bg-muted/40 px-4 py-16\">\n      <div className=\"w-full max-w-sm\">\n        <div className=\"mb-6 flex flex-col items-center text-center\">\n          <span aria-hidden className=\"grid size-10 place-items-center rounded-xl bg-primary text-primary-foreground\">\n            <Sparkles className=\"size-5\" />\n          </span>\n          <h2 className=\"mt-4 text-xl font-semibold tracking-tight\">{title}</h2>\n          {description && <p className=\"mt-1 text-sm text-muted-foreground\">{description}</p>}\n        </div>\n\n        <div className=\"grid gap-5 rounded-2xl border bg-card p-6 shadow-sm\">\n          {state === \"done\" ? (\n            <Alert color=\"success\" title={done.title} description={done.description} />\n          ) : (\n            <>\n              {providers.length > 0 && (\n                <>\n                  <div className=\"grid grid-cols-[repeat(var(--count),minmax(0,1fr))] gap-2\" style={{ \"--count\": Math.min(providers.length, 2) } as React.CSSProperties}>\n                    {providers.map((provider) => (\n                      <Button key={provider.id} variant=\"outline\" onClick={() => onProvider?.(provider.id)}>\n                        {provider.icon} {provider.label}\n                      </Button>\n                    ))}\n                  </div>\n                  <div className=\"flex items-center gap-3\">\n                    <Separator className=\"flex-1\" />\n                    <span className=\"text-xs text-muted-foreground uppercase\">or</span>\n                    <Separator className=\"flex-1\" />\n                  </div>\n                </>\n              )}\n              {state === \"wrong\" && error && <Alert color=\"destructive\" title={error} description={onSubmit ? undefined : \"Try again, or reset it.\"} />}\n              <form noValidate onSubmit={submit} className=\"grid gap-4\">\n                <Input label=\"Email\" type=\"email\" autoComplete=\"email\" placeholder=\"olivia@acme.com\" value={email} onChange={(e) => setEmail(e.target.value)} required />\n                <Input\n                  label=\"Password\"\n                  labelAction={\n                    forgotHref && (\n                      <a href={forgotHref} className=\"font-medium text-primary-text underline-offset-4 hover:underline\">\n                        Forgot password?\n                      </a>\n                    )\n                  }\n                  type=\"password\"\n                  autoComplete=\"current-password\"\n                  value={password}\n                  onChange={(e) => {\n                    setPassword(e.target.value)\n                    if (state === \"wrong\") setState(\"idle\")\n                  }}\n                  aria-invalid={state === \"wrong\" || undefined}\n                  required\n                />\n                <Checkbox label=\"Keep me signed in on this device\" checked={remember} onCheckedChange={(on) => setRemember(on === true)} />\n                <Button type=\"submit\" loading={state === \"loading\"} disabled={!email || !password}>\n                  Sign in\n                </Button>\n              </form>\n            </>\n          )}\n        </div>\n        {signUpHref && (\n          <p className=\"mt-6 text-center text-sm text-muted-foreground\">\n            {signUpPrompt}{\" \"}\n            <a href={signUpHref} className=\"font-medium text-primary-text underline-offset-4 hover:underline\">\n              Create an account\n            </a>\n          </p>\n        )}\n      </div>\n    </section>\n  )\n}\n"}],"cssVars":{"theme":{"color-primary-text":"var(--primary-text, var(--primary))"},"light":{},"dark":{}}}