{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"sign-up-split","type":"registry:block","title":"Sign up, split","description":"The form with a password strength meter and terms beside a soft blue panel: what you get, the product in miniature, a customer's words.","dependencies":["lucide-react"],"registryDependencies":["https://dashral.com/r/utils.json","https://dashral.com/r/lib-motion.json","https://dashral.com/r/avatar.json","https://dashral.com/r/button.json","https://dashral.com/r/checkbox.json","https://dashral.com/r/input.json","https://dashral.com/r/sparkline.json"],"files":[{"path":"registry/dashral/blocks/sign-up-split.tsx","type":"registry:file","target":"components/dashral/blocks/sign-up-split.tsx","content":"\"use client\"\n\nimport { useEffect, useState } from \"react\"\nimport { BellRing, Check, Sparkles } from \"lucide-react\"\nimport { Avatar } from \"../avatar\"\nimport { Button } from \"../button\"\nimport { Checkbox } from \"../checkbox\"\nimport { Input } from \"../input\"\nimport { Sparkline } from \"../sparkline\"\nimport { reducedMotion } from \"../lib/motion\"\nimport { cn } from \"../lib/utils\"\n\nexport type PasswordRule = { label: string; test: (value: string) => boolean }\nexport type Testimonial = { quote: string; name: string; role: string; src?: string }\nexport type SignUpValues = { firstName: string; lastName: string; email: string; password: string }\n\nconst sampleRules: PasswordRule[] = [\n  { label: \"8+ characters\", test: (v: string) => v.length >= 8 },\n  { label: \"A number\", test: (v: string) => /\\d/.test(v) },\n  { label: \"A capital letter\", test: (v: string) => /[A-Z]/.test(v) },\n]\n\nconst sampleTestimonials: Testimonial[] = [\n  { quote: \"We set it up on a Tuesday. By Friday the whole company had it open.\", name: \"Liam Johnson\", role: \"Engineering Manager, Globex\", src: \"https://randomuser.me/api/portraits/men/32.jpg\" },\n  { quote: \"Our Monday meeting used to start with arguing about numbers. Now it starts with decisions.\", name: \"Sofia Davis\", role: \"Head of Growth, Initech\", src: \"https://randomuser.me/api/portraits/women/68.jpg\" },\n  { quote: \"I replaced four spreadsheets and a weekly export with one link I send to the board.\", name: \"Budi Santoso\", role: \"Finance Lead, Umbrella\", src: \"https://randomuser.me/api/portraits/men/75.jpg\" },\n]\n\n/**\n * Customers' words, one at a time: the next fades in every six seconds, and the dots pick one. It holds still while\n * the pointer or focus is on it, and doesn't move on its own with reduced motion. All quotes share one grid cell,\n * so the panel never jumps to a new height.\n */\nfunction Testimonials({ testimonials }: { testimonials: Testimonial[] }) {\n  const [current, setCurrent] = useState(0)\n  const [paused, setPaused] = useState(false)\n\n  useEffect(() => {\n    if (paused || reducedMotion()) return\n    const timer = setTimeout(() => setCurrent((i) => (i + 1) % testimonials.length), 6000)\n    return () => clearTimeout(timer)\n  }, [current, paused, testimonials.length])\n\n  return (\n    <section\n      aria-roledescription=\"carousel\"\n      aria-label=\"What customers say\"\n      onPointerEnter={() => setPaused(true)}\n      onPointerLeave={() => setPaused(false)}\n      onFocus={() => setPaused(true)}\n      onBlur={() => setPaused(false)}\n    >\n      <div className=\"grid\">\n        {testimonials.map((t, i) => (\n          <figure\n            key={t.name}\n            aria-roledescription=\"slide\"\n            aria-label={`${i + 1} of ${testimonials.length}`}\n            aria-hidden={i !== current}\n            className={cn(\n              \"col-start-1 row-start-1 transition-[opacity,translate,filter] duration-(--duration-considered) ease-standard motion-reduce:transition-none\",\n              i === current ? \"translate-y-0 opacity-100 blur-0\" : \"pointer-events-none translate-y-1 opacity-0 blur-[2px]\"\n            )}\n          >\n            <blockquote className=\"text-2xl leading-snug font-medium tracking-tight text-balance\">“{t.quote}”</blockquote>\n            <figcaption className=\"mt-6 flex items-center gap-3\">\n              <Avatar src={t.src} name={t.name} alt=\"\" />\n              <span className=\"grid text-sm\">\n                <span className=\"font-semibold\">{t.name}</span>\n                <span className=\"text-muted-foreground\">{t.role}</span>\n              </span>\n            </figcaption>\n          </figure>\n        ))}\n      </div>\n      <div className=\"mt-8 -ms-1 flex items-center gap-1\">\n        {testimonials.map((t, i) => (\n          <button\n            key={t.name}\n            type=\"button\"\n            aria-label={`Show ${t.name}'s words`}\n            aria-current={i === current || undefined}\n            onClick={() => setCurrent(i)}\n            className=\"grid h-6 place-items-center rounded-full px-1 outline-none focus-visible:ring-2 focus-visible:ring-ring/50\"\n          >\n            <span\n              className={cn(\n                \"block h-1.5 rounded-full transition-[width,background-color] duration-(--duration-considered) ease-standard\",\n                i === current ? \"w-6 bg-primary\" : \"w-1.5 bg-foreground/25 hover:bg-foreground/45\"\n              )}\n            />\n          </button>\n        ))}\n      </div>\n    </section>\n  )\n}\n\n/**\n * Sign-up as a split screen: the form on one side — name, work email, a password with a strength meter and its\n * rules, the terms — and on the other a brand panel in a soft wash of the theme's gradient with what you get, the product in\n * miniature and customers' words that take turns. The panel hides on phones. Every part comes from props; point\n * `onSubmit` at your auth.\n */\nexport type SignUpSplitProps = {\n  title?: React.ReactNode\n  description?: React.ReactNode\n  /**\n   * Your sign-up, once every rule is met and the terms agreed to. Resolve to show `done`; throw an Error to show its\n   * message above the button. Without it, the form plays a sample.\n   */\n  onSubmit?: (values: SignUpValues) => Promise<void> | void\n  /** What it says once the account is made. */\n  done?: React.ReactNode\n  /** The password's rules: one meter segment fills per rule met. */\n  rules?: PasswordRule[]\n  /** Where the terms, the privacy policy and \"Sign in\" go; no signInHref hides the line. */\n  termsHref?: string\n  privacyHref?: string\n  signInHref?: string\n  /** The brand panel beside the form (hidden on phones): what you get, the product in miniature, customers' words; null hides it. */\n  panel?: {\n    points?: string[]\n    preview?: { label: string; value: string; change: string; series: number[]; note?: React.ReactNode } | null\n    testimonials?: Testimonial[]\n  } | null\n}\n\nexport function SignUpSplit({\n  title = \"Create your account\",\n  description = \"Free for 14 days. No card needed.\",\n  onSubmit,\n  done: doneText = \"Check your inbox to confirm your email.\",\n  rules = sampleRules,\n  termsHref = \"#\",\n  privacyHref = \"#\",\n  signInHref = \"#\",\n  panel = {},\n}: SignUpSplitProps) {\n  const [firstName, setFirstName] = useState(\"\")\n  const [lastName, setLastName] = useState(\"\")\n  const [email, setEmail] = useState(\"\")\n  const [password, setPassword] = useState(\"\")\n  const [agreed, setAgreed] = useState(false)\n  const [tried, setTried] = useState(false)\n  const [sending, setSending] = useState(false)\n  const [error, setError] = useState<string | null>(null)\n  const [done, setDone] = useState(false)\n  const passed = rules.filter((r) => r.test(password)).length\n  const points = panel?.points ?? [\"Every source in one place\", \"Live dashboards the whole team opens\", \"Alerts when something changes\"]\n  const preview =\n    panel?.preview === undefined\n      ? {\n          label: \"Revenue · 30 days\",\n          value: \"$48,290\",\n          change: \"+12.5%\",\n          series: [31, 34, 33, 38, 36, 41, 40, 44, 43, 47, 46, 52],\n          note: (\n            <>\n              Signups up <span className=\"font-semibold\">38%</span> since 9 AM\n            </>\n          ),\n        }\n      : panel.preview\n  const testimonials = panel?.testimonials ?? sampleTestimonials\n\n  async function submit(event: React.FormEvent) {\n    event.preventDefault()\n    setTried(true)\n    if (passed < rules.length || !agreed) return\n    if (!onSubmit) return setDone(true)\n    setError(null)\n    setSending(true)\n    try {\n      await onSubmit({ firstName: firstName.trim(), lastName: lastName.trim(), email: email.trim(), password })\n      setDone(true)\n    } catch (e) {\n      setError(e instanceof Error ? e.message : \"Couldn't create your account. Try again.\")\n    } finally {\n      setSending(false)\n    }\n  }\n  const fill = passed <= 1 ? \"bg-destructive\" : passed === 2 ? \"bg-warning\" : \"bg-success\"\n\n  return (\n    <section className={cn(\"grid min-h-svh bg-background\", panel && \"lg:grid-cols-2\")}>\n      <div className=\"flex items-center justify-center px-4 py-16 sm:px-6\">\n        <div className=\"w-full max-w-sm\">\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-6 text-2xl font-semibold tracking-tight\">{title}</h2>\n          {description && <p className=\"mt-1 text-sm text-muted-foreground\">{description}</p>}\n\n          {done ? (\n            <p role=\"status\" className=\"mt-8 flex items-center gap-2 rounded-lg bg-success/10 px-3 py-3 text-sm text-success-text\">\n              <Check className=\"size-4\" aria-hidden /> {doneText}\n            </p>\n          ) : (\n            <form noValidate className=\"mt-8 grid gap-4\" onSubmit={submit}>\n              <div className=\"grid gap-4 sm:grid-cols-2\">\n                <Input label=\"First name\" autoComplete=\"given-name\" placeholder=\"Olivia\" value={firstName} onChange={(e) => setFirstName(e.target.value)} />\n                <Input label=\"Last name\" autoComplete=\"family-name\" placeholder=\"Martin\" value={lastName} onChange={(e) => setLastName(e.target.value)} />\n              </div>\n              <Input label=\"Work email\" type=\"email\" autoComplete=\"email\" placeholder=\"olivia@acme.com\" value={email} onChange={(e) => setEmail(e.target.value)} />\n              <div className=\"grid gap-2\">\n                <Input\n                  label=\"Password\"\n                  type=\"password\"\n                  autoComplete=\"new-password\"\n                  value={password}\n                  onChange={(e) => setPassword(e.target.value)}\n                  error={tried && passed < rules.length ? (rules.length === 1 ? \"Meet the rule below.\" : `Meet all ${rules.length} rules below.`) : undefined}\n                />\n                {/* Neutral until you type; one segment fills per rule met. */}\n                <div aria-hidden className=\"grid grid-cols-[repeat(var(--count),minmax(0,1fr))] gap-1.5\" style={{ \"--count\": rules.length } as React.CSSProperties}>\n                  {rules.map((rule, i) => (\n                    <span key={rule.label} className={cn(\"h-1 rounded-full transition-colors duration-(--duration-standard)\", i < passed ? fill : \"bg-muted\")} />\n                  ))}\n                </div>\n                <ul className=\"flex flex-wrap gap-x-4 gap-y-1 text-xs text-muted-foreground\">\n                  {rules.map((rule) => {\n                    const met = rule.test(password)\n                    return (\n                      <li key={rule.label} className={cn(\"flex items-center gap-1 transition-colors\", met && \"text-foreground\")}>\n                        <Check className={cn(\"size-3\", met ? \"text-success-text\" : \"opacity-30\")} aria-hidden />\n                        {rule.label}\n                        <span className=\"sr-only\">{met ? \"(done)\" : \"(not yet)\"}</span>\n                      </li>\n                    )\n                  })}\n                </ul>\n              </div>\n              <Checkbox\n                label={\n                  // One span: the label lays its parts out in a row, and this sentence is one part.\n                  <span>\n                    I agree to the{\" \"}\n                    <a href={termsHref} className=\"font-medium text-primary-text underline-offset-4 hover:underline\">\n                      terms\n                    </a>{\" \"}\n                    and{\" \"}\n                    <a href={privacyHref} className=\"font-medium text-primary-text underline-offset-4 hover:underline\">\n                      privacy policy\n                    </a>\n                  </span>\n                }\n                checked={agreed}\n                onCheckedChange={(on) => setAgreed(on === true)}\n                error={tried && !agreed ? \"Agree to continue.\" : undefined}\n              />\n              {error && (\n                <p role=\"alert\" className=\"text-sm text-destructive-text\">\n                  {error}\n                </p>\n              )}\n              <Button type=\"submit\" loading={sending}>\n                Create account\n              </Button>\n              {signInHref && (\n                <p className=\"text-center text-sm text-muted-foreground\">\n                  Already have one?{\" \"}\n                  <a href={signInHref} className=\"font-medium text-primary-text underline-offset-4 hover:underline\">\n                    Sign in\n                  </a>\n                </p>\n              )}\n            </form>\n          )}\n        </div>\n      </div>\n\n      {/* The brand panel in the theme's gradient wash (--gradient-*): its three colors pooling at the edges, a faint grid,\n          and the product itself in the middle. */}\n      {panel && (\n        <aside\n          className=\"relative isolate hidden flex-col justify-between overflow-hidden border-s p-12 text-foreground lg:flex [--wash-base:color-mix(in_oklch,var(--gradient-via)_4%,var(--background))] [--wash-blue:color-mix(in_oklch,var(--gradient-via)_50%,var(--background))] [--wash-grid:color-mix(in_oklch,var(--gradient-via)_8%,transparent)] [--wash-indigo:color-mix(in_oklch,var(--gradient-to)_45%,var(--background))] [--wash-sky:color-mix(in_oklch,var(--gradient-from)_45%,var(--background))]\"\n          style={{\n            background:\n              \"radial-gradient(ellipse 70% 55% at 100% 0%, var(--wash-blue), transparent), radial-gradient(ellipse 60% 50% at 0% 100%, var(--wash-sky), transparent), radial-gradient(ellipse 55% 45% at 70% 105%, var(--wash-indigo), transparent), var(--wash-base)\",\n          }}\n        >\n          <div\n            aria-hidden\n            className=\"absolute inset-0 -z-10 [mask-image:radial-gradient(ellipse_70%_60%_at_50%_45%,#000_25%,transparent_80%)]\"\n            style={{\n              backgroundImage: \"linear-gradient(to right, var(--wash-grid) 1px, transparent 1px), linear-gradient(to bottom, var(--wash-grid) 1px, transparent 1px)\",\n              backgroundSize: \"48px 48px\",\n            }}\n          />\n          <ul className=\"grid gap-3 text-sm\">\n            {points.map((point) => (\n              <li key={point} className=\"flex items-center gap-3\">\n                <span className=\"grid size-5 place-items-center rounded-full bg-primary/15 text-primary-text\">\n                  <Check className=\"size-3\" aria-hidden />\n                </span>\n                {point}\n              </li>\n            ))}\n          </ul>\n\n          {/* What you're signing up for, in miniature. */}\n          {preview ? (\n            <div aria-hidden className=\"relative mx-auto w-full max-w-sm\">\n              <div className=\"rounded-2xl border bg-card/80 p-5 text-card-foreground shadow-[0_24px_60px_-24px_rgb(30_41_90/0.35)] backdrop-blur-sm dark:shadow-[0_24px_60px_-24px_rgb(0_0_0/0.8)]\">\n                <div className=\"flex items-baseline justify-between\">\n                  <span className=\"text-xs text-muted-foreground\">{preview.label}</span>\n                  <span className=\"text-xs font-medium text-success-text\">{preview.change}</span>\n                </div>\n                <p className=\"mt-1 text-2xl font-semibold tracking-[-0.02em] tabular-nums\">{preview.value}</p>\n                <Sparkline data={preview.series} variant=\"area\" showLast className=\"mt-3 h-16 text-primary\" />\n              </div>\n              {preview.note && (\n                <div className=\"absolute -end-6 -bottom-6 flex items-center gap-2.5 rounded-xl border bg-card px-3 py-2 text-xs text-card-foreground shadow-lg\">\n                  <span className=\"grid size-7 place-items-center rounded-lg bg-warning/15 text-warning-text\">\n                    <BellRing className=\"size-3.5\" />\n                  </span>\n                  <span>{preview.note}</span>\n                </div>\n              )}\n            </div>\n          ) : (\n            <span />\n          )}\n\n          {testimonials.length > 0 ? <Testimonials testimonials={testimonials} /> : <span />}\n        </aside>\n      )}\n    </section>\n  )\n}\n"}],"cssVars":{"theme":{"color-primary-text":"var(--primary-text, var(--primary))","color-destructive-foreground":"var(--destructive-foreground)","color-destructive-text":"var(--destructive-text)","color-success":"var(--success)","color-success-foreground":"var(--success-foreground)","color-success-text":"var(--success-text)","color-warning":"var(--warning)","color-warning-foreground":"var(--warning-foreground)","color-warning-text":"var(--warning-text)","ease-standard":"var(--ease-standard)","ease-enter":"var(--ease-enter)","ease-exit":"var(--ease-exit)","ease-spring":"var(--ease-spring)"},"light":{"destructive-foreground":"oklch(0.985 0 0)","destructive-text":"#bd2800","success":"oklch(0.508 0.118 165.612)","success-foreground":"oklch(0.985 0 0)","success-text":"oklch(0.432 0.095 166.913)","warning":"#f59200","warning-foreground":"oklch(0.3 0.07 60)","warning-text":"#964e00","duration-fast":"160ms","duration-standard":"240ms","duration-considered":"480ms","ease-standard":"cubic-bezier(0.2, 0, 0, 1)","ease-enter":"cubic-bezier(0, 0, 0, 1)","ease-exit":"cubic-bezier(0.3, 0, 1, 1)","ease-spring":"linear(0, 0.071 4%, 0.234 8%, 0.433 12%, 0.626 17%, 0.791 21%, 0.917 25%, 1.004 29%, 1.055 33%, 1.079 38%, 1.083 42%, 1.075 46%, 1.06 50%, 1.043 54%, 1.027 58%, 1.015 62%, 1.005 67%, 0.998 71%, 0.995 75%, 0.993 79%, 0.993 83%, 0.994 88%, 0.995 92%, 0.997 96%, 1)"},"dark":{"destructive-foreground":"oklch(0.2 0 0)","destructive-text":"#ff8a5c","success":"oklch(0.696 0.17 162.48)","success-foreground":"oklch(0.2 0.04 160)","success-text":"oklch(0.765 0.177 163.223)","warning":"#f59200","warning-foreground":"oklch(0.25 0.06 60)","warning-text":"#ffba42"}}}