{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "authentication-15",
  "type": "registry:block",
  "description": "Phone number sign-in with a country code picker, one-time code step and an SMS preview mockup.",
  "dependencies": [
    "lucide-react"
  ],
  "registryDependencies": [
    "button",
    "input",
    "label"
  ],
  "files": [
    {
      "path": "registry/designali/blocks/authentication/authentication-15.tsx",
      "content": "\"use client\"\n\nimport { useState } from \"react\"\nimport {\n  ArrowLeft,\n  ChevronDown,\n  MessageSquare,\n  Phone,\n} from \"@designali/icons\"\n\nimport { Button } from \"@workspace/ui/components/button\"\nimport { Input } from \"@workspace/ui/components/input\"\nimport { Label } from \"@workspace/ui/components/label\"\n\nimport { IPhone } from \"@/registry/designali/ui/apple/iphone\"\n\nconst countries = [\n  { code: \"US\", dial: \"+1\", flag: \"US\" },\n  { code: \"GB\", dial: \"+44\", flag: \"GB\" },\n  { code: \"IN\", dial: \"+91\", flag: \"IN\" },\n  { code: \"BR\", dial: \"+55\", flag: \"BR\" },\n  { code: \"NG\", dial: \"+234\", flag: \"NG\" },\n  { code: \"DE\", dial: \"+49\", flag: \"DE\" },\n]\n\nfunction formatPhone(value: string) {\n  const digits = value.replace(/\\D/g, \"\").slice(0, 10)\n  const parts = [digits.slice(0, 3), digits.slice(3, 6), digits.slice(6)]\n  return parts.filter(Boolean).join(\" \")\n}\n\nexport default function Authentication15() {\n  const [country, setCountry] = useState(countries[0]!)\n  const [phone, setPhone] = useState(\"\")\n  const [sent, setSent] = useState(false)\n  const [code, setCode] = useState(\"\")\n\n  const valid = phone.replace(/\\D/g, \"\").length >= 9\n\n  return (\n    <section className=\"w-full bg-background\">\n      <div className=\"mx-auto grid min-h-[640px] max-w-6xl md:grid-cols-2\">\n        <div className=\"relative hidden items-center justify-center overflow-hidden bg-gradient-to-br from-chart-1 via-primary to-chart-2 md:flex\">\n          <IPhone size=\"lg\" color=\"silver\" className=\"max-h-full\">\n            <div className=\"flex h-full flex-col bg-white p-5 pt-12 text-black\">\n              <p className=\"text-center text-xs text-black/50\">Messages &middot; now</p>\n              <div className=\"mt-4 max-w-[85%] rounded-2xl bg-black/5 p-3 text-sm\">\n                Your Designali code is <span className=\"font-semibold\">482 913</span>. It expires in 5 minutes. Don&apos;t share it with anyone.\n              </div>\n              <div className=\"mt-3 max-w-[70%] rounded-2xl bg-black/5 p-3 text-sm\">Designali will never call you for this code.</div>\n            </div>\n          </IPhone>\n        </div>\n\n        <div className=\"flex items-center px-6 py-16 md:px-16\">\n          <div className=\"w-full max-w-sm space-y-8\">\n            {!sent ? (\n              <form\n                className=\"space-y-6\"\n                onSubmit={(event) => {\n                  event.preventDefault()\n                  if (valid) setSent(true)\n                }}\n              >\n                <Phone className=\"size-6\" />\n                <div>\n                  <h2 className=\"text-3xl font-semibold tracking-tight\">Sign in with your phone</h2>\n                  <p className=\"mt-2 text-sm text-muted-foreground\">We&apos;ll text you a one-time code. No password needed.</p>\n                </div>\n                <div className=\"space-y-2\">\n                  <Label htmlFor=\"auth-15-phone\">Mobile number</Label>\n                  <div className=\"flex h-11 border focus-within:border-foreground\">\n                    <label className=\"relative flex shrink-0 items-center border-e\">\n                      <span className=\"sr-only\">Country code</span>\n                      <select\n                        value={country.code}\n                        onChange={(event) => setCountry(countries.find((item) => item.code === event.target.value) ?? countries[0]!)}\n                        className=\"h-full appearance-none bg-transparent ps-3 pe-8 text-sm outline-none\"\n                      >\n                        {countries.map((item) => (\n                          <option key={item.code} value={item.code}>\n                            {item.flag} {item.dial}\n                          </option>\n                        ))}\n                      </select>\n                      <ChevronDown className=\"pointer-events-none absolute end-2.5 size-3.5 text-muted-foreground\" />\n                    </label>\n                    <input\n                      id=\"auth-15-phone\"\n                      type=\"tel\"\n                      inputMode=\"tel\"\n                      value={phone}\n                      onChange={(event) => setPhone(formatPhone(event.target.value))}\n                      placeholder=\"Mobile number\"\n                      className=\"w-full min-w-0 bg-transparent px-3 text-sm tabular-nums outline-none placeholder:text-muted-foreground\"\n                    />\n                  </div>\n                </div>\n                <Button type=\"submit\" size=\"lg\" className=\"w-full\" disabled={!valid}>\n                  <MessageSquare />\n                  Text me a code\n                </Button>\n                <p className=\"text-center text-sm text-muted-foreground\">\n                  Prefer email? <a href=\"#\" className=\"text-foreground underline underline-offset-4\">Use email instead</a>\n                </p>\n              </form>\n            ) : (\n              <form className=\"space-y-6\" onSubmit={(event) => event.preventDefault()}>\n                <button type=\"button\" onClick={() => setSent(false)} className=\"flex items-center gap-1.5 text-sm text-muted-foreground hover:text-foreground\">\n                  <ArrowLeft className=\"size-4\" />\n                  Change number\n                </button>\n                <div>\n                  <h2 className=\"text-3xl font-semibold tracking-tight\">Enter the code</h2>\n                  <p className=\"mt-2 text-sm text-muted-foreground\">\n                    Sent to <span className=\"text-foreground tabular-nums\">{country.dial} {phone}</span>\n                  </p>\n                </div>\n                <div className=\"space-y-2\">\n                  <Label htmlFor=\"auth-15-code\">6-digit code</Label>\n                  <Input\n                    id=\"auth-15-code\"\n                    inputMode=\"numeric\"\n                    autoComplete=\"one-time-code\"\n                    value={code}\n                    onChange={(event) => setCode(event.target.value.replace(/\\D/g, \"\").slice(0, 6))}\n                    className=\"h-12 font-sans text-lg tracking-[0.4em]\"\n                  />\n                </div>\n                <Button type=\"submit\" size=\"lg\" className=\"w-full\" disabled={code.length !== 6}>\n                  Verify and sign in\n                </Button>\n                <p className=\"text-sm text-muted-foreground\">\n                  Didn&apos;t get it? <button type=\"button\" className=\"text-foreground underline underline-offset-4\">Resend</button> or{\" \"}\n                  <button type=\"button\" className=\"text-foreground underline underline-offset-4\">call me instead</button>\n                </p>\n              </form>\n            )}\n          </div>\n        </div>\n      </div>\n    </section>\n  )\n}\n",
      "type": "registry:component"
    }
  ],
  "meta": {
    "iframeHeight": "700px"
  },
  "categories": [
    "authentication"
  ]
}