{"$schema":"https://ui.shadcn.com/schema/registry-item.json","name":"sign-up-form","type":"registry:block","title":"Sign Up Form","description":"Sign-up card with a GitHub button, an email field that validates and shakes, an animated password-strength meter, a stateful submit and a success state that morphs in with a drawn check.","author":"GetUrUI <hello@geturui.dev>","dependencies":["motion","lucide-react"],"registryDependencies":["@geturui/button","@geturui/input"],"files":[{"path":"registry/geturui/blocks/sign-up-form.tsx","type":"registry:block","target":"components/blocks/sign-up-form.tsx","content":"\"use client\";\n\nimport * as React from \"react\";\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\";\nimport { Eye, EyeOff, Lock, Mail } from \"lucide-react\";\nimport { cn } from \"@/lib/utils\";\nimport { Button, StatefulButton } from \"@/components/ui/button\";\nimport { Input } from \"@/components/ui/input\";\n\nexport interface SignUpValues {\n  email: string;\n  password: string;\n}\n\nexport interface SignUpFormProps {\n  title?: string;\n  description?: string;\n  /** Called with valid values. Reject to keep the form open and shake the button. */\n  onSubmit?: (values: SignUpValues) => Promise<void> | void;\n  onGithub?: () => void;\n  /** Show the \"Continue with GitHub\" button and divider. */\n  showGithub?: boolean;\n  githubLabel?: string;\n  minPasswordLength?: number;\n  submitLabel?: string;\n  termsHref?: string;\n  privacyHref?: string;\n  /** Shows \"Already have an account?\" with this link. */\n  signInHref?: string;\n  successTitle?: string;\n  className?: string;\n}\n\nconst EMAIL_RE = /^[^\\s@]+@[^\\s@]+\\.[^\\s@]{2,}$/;\nconst LEVELS = [\n  { label: \"Too short\", tone: \"bg-danger\", text: \"text-danger\" },\n  { label: \"Weak\", tone: \"bg-danger\", text: \"text-danger\" },\n  { label: \"Fair\", tone: \"bg-warning\", text: \"text-warning\" },\n  { label: \"Good\", tone: \"bg-info\", text: \"text-info\" },\n  { label: \"Strong\", tone: \"bg-success\", text: \"text-success\" },\n] as const;\n\nfunction scorePassword(pw: string, min: number) {\n  if (pw.length < min) return 0;\n  let s = 1;\n  if (/[a-z]/.test(pw) && /[A-Z]/.test(pw)) s++;\n  if (/\\d/.test(pw)) s++;\n  if (/[^A-Za-z0-9]/.test(pw)) s++;\n  if (pw.length >= min + 6 && s < 4) s++;\n  return s;\n}\n\nfunction GithubMark({ className }: { className?: string }) {\n  return (\n    <svg viewBox=\"0 0 24 24\" aria-hidden className={className} fill=\"currentColor\">\n      <path d=\"M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12\" />\n    </svg>\n  );\n}\n\nfunction StrengthMeter({ score, visible }: { score: number; visible: boolean }) {\n  const level = LEVELS[score];\n  return (\n    <AnimatePresence initial={false}>\n      {visible && (\n        <motion.div\n          initial={{ height: 0, opacity: 0 }}\n          animate={{ height: \"auto\", opacity: 1 }}\n          exit={{ height: 0, opacity: 0 }}\n          transition={{ height: { type: \"spring\", stiffness: 320, damping: 32 }, opacity: { duration: 0.15 } }}\n          className=\"overflow-hidden\"\n        >\n          <div className=\"flex items-center gap-3 pt-2\">\n            <div className=\"grid flex-1 grid-cols-4 gap-1.5\" aria-hidden>\n              {[1, 2, 3, 4].map((seg) => (\n                <span key={seg} className=\"h-1.5 overflow-hidden rounded-full bg-surface-sunken ring-1 ring-inset ring-border\">\n                  <motion.span\n                    className={cn(\"block h-full origin-left rounded-full transition-colors duration-300\", level.tone)}\n                    initial={false}\n                    animate={{ scaleX: score >= seg ? 1 : 0 }}\n                    transition={{ type: \"spring\", stiffness: 380, damping: 30, delay: score >= seg ? (seg - 1) * 0.04 : 0 }}\n                  />\n                </span>\n              ))}\n            </div>\n            <span className={cn(\"w-16 text-right text-xs font-medium\", level.text)} aria-live=\"polite\">\n              {level.label}\n            </span>\n          </div>\n        </motion.div>\n      )}\n    </AnimatePresence>\n  );\n}\n\n/** Sign-up card: GitHub button, validated email that shakes on error, animated password-strength meter, stateful submit and a success state that morphs in. */\nexport function SignUpForm({\n  title = \"Create your GetUrUI account\",\n  description = \"Free forever for the open library. Upgrade when you need Pro blocks.\",\n  onSubmit,\n  onGithub,\n  showGithub = true,\n  githubLabel = \"Continue with GitHub\",\n  minPasswordLength = 8,\n  submitLabel = \"Create account\",\n  termsHref = \"#\",\n  privacyHref = \"#\",\n  signInHref,\n  successTitle = \"Check your inbox\",\n  className,\n}: SignUpFormProps) {\n  const reduce = useReducedMotion() ?? false;\n  const [email, setEmail] = React.useState(\"\");\n  const [password, setPassword] = React.useState(\"\");\n  const [reveal, setReveal] = React.useState(false);\n  const [errors, setErrors] = React.useState<{ email?: string; password?: string }>({});\n  const [done, setDone] = React.useState<string | null>(null);\n  const timer = React.useRef<ReturnType<typeof setTimeout> | null>(null);\n  const emailRef = React.useRef<HTMLInputElement>(null);\n  const score = scorePassword(password, minPasswordLength);\n\n  React.useEffect(\n    () => () => {\n      if (timer.current) clearTimeout(timer.current);\n    },\n    [],\n  );\n\n  async function submit() {\n    const next: typeof errors = {};\n    if (!EMAIL_RE.test(email.trim())) next.email = email ? \"Enter a valid email, like you@company.com\" : \"Email is required\";\n    if (password.length < minPasswordLength) next.password = `Use at least ${minPasswordLength} characters`;\n    setErrors(next);\n    if (next.email || next.password) throw new Error(\"invalid\");\n    if (onSubmit) await onSubmit({ email: email.trim(), password });\n    else await new Promise((r) => setTimeout(r, 1100));\n    const submitted = email.trim();\n    timer.current = setTimeout(() => setDone(submitted), 650);\n  }\n\n  function reset() {\n    setDone(null);\n    setPassword(\"\");\n    setErrors({});\n    timer.current = setTimeout(() => emailRef.current?.focus(), 50);\n  }\n\n  return (\n    <motion.div\n      layout\n      transition={{ type: \"spring\", stiffness: 300, damping: 32 }}\n      className={cn(\"mx-auto w-full max-w-[420px] overflow-hidden rounded-xl border border-border bg-surface p-6 shadow-lg sm:p-8\", className)}\n    >\n      <AnimatePresence mode=\"popLayout\" initial={false}>\n        {done === null ? (\n          <motion.div\n            key=\"form\"\n            layout=\"position\"\n            initial={{ opacity: 0, filter: \"blur(8px)\", scale: 0.98 }}\n            animate={{ opacity: 1, filter: \"blur(0px)\", scale: 1 }}\n            exit={{ opacity: 0, filter: \"blur(8px)\", scale: 0.98 }}\n            transition={{ duration: 0.25 }}\n            className=\"grid gap-6\"\n          >\n            <header className=\"grid gap-1.5\">\n              <h2 className=\"font-display text-2xl font-semibold tracking-[-0.5px] text-ink\">{title}</h2>\n              {description && <p className=\"text-sm leading-[22px] text-ink-muted\">{description}</p>}\n            </header>\n\n            {showGithub ? (\n              <>\n                <Button variant=\"secondary\" size=\"lg\" block onClick={onGithub}>\n                  <GithubMark className=\"size-[18px]\" />\n                  {githubLabel}\n                </Button>\n                <div className=\"flex items-center gap-3 text-xs font-medium uppercase tracking-[0.5px] text-ink-subtle\">\n                  <span className=\"h-px flex-1 bg-border\" />\n                  or\n                  <span className=\"h-px flex-1 bg-border\" />\n                </div>\n              </>\n            ) : null}\n\n            <form\n              noValidate\n              className=\"grid gap-4\"\n              onSubmit={(e) => {\n                e.preventDefault();\n              }}\n            >\n              <Input\n                ref={emailRef}\n                type=\"email\"\n                name=\"email\"\n                label=\"Work email\"\n                placeholder=\"you@company.com\"\n                autoComplete=\"email\"\n                icon={<Mail className=\"size-4\" aria-hidden />}\n                value={email}\n                error={errors.email}\n                onChange={(e) => {\n                  setEmail(e.target.value);\n                  if (errors.email) setErrors((x) => ({ ...x, email: undefined }));\n                }}\n                onBlur={() => {\n                  if (email && !EMAIL_RE.test(email.trim())) setErrors((x) => ({ ...x, email: \"Enter a valid email, like you@company.com\" }));\n                }}\n              />\n              <div className=\"grid\">\n                <Input\n                  type={reveal ? \"text\" : \"password\"}\n                  name=\"password\"\n                  label=\"Password\"\n                  placeholder={`At least ${minPasswordLength} characters`}\n                  autoComplete=\"new-password\"\n                  icon={<Lock className=\"size-4\" aria-hidden />}\n                  value={password}\n                  error={errors.password}\n                  onChange={(e) => {\n                    setPassword(e.target.value);\n                    if (errors.password) setErrors((x) => ({ ...x, password: undefined }));\n                  }}\n                  trailing={\n                    <button\n                      type=\"button\"\n                      onClick={() => setReveal((r) => !r)}\n                      aria-label={reveal ? \"Hide password\" : \"Show password\"}\n                      aria-pressed={reveal}\n                      className=\"-mr-1.5 grid size-7 place-items-center rounded-md text-ink-subtle outline-none transition-colors hover:bg-surface-hover hover:text-ink focus-visible:shadow-[var(--focus-ring)]\"\n                    >\n                      {reveal ? <EyeOff className=\"size-4\" /> : <Eye className=\"size-4\" />}\n                    </button>\n                  }\n                />\n                <StrengthMeter score={score} visible={password.length > 0} />\n              </div>\n              <StatefulButton type=\"submit\" size=\"lg\" block className=\"mt-1\" onAction={submit} successLabel=\"Account created\">\n                {submitLabel}\n              </StatefulButton>\n            </form>\n\n            <p className=\"text-center text-xs leading-5 text-ink-subtle\">\n              By continuing you agree to the{\" \"}\n              <a href={termsHref} className=\"text-ink-muted underline underline-offset-2 hover:text-ink\">\n                Terms\n              </a>{\" \"}\n              and{\" \"}\n              <a href={privacyHref} className=\"text-ink-muted underline underline-offset-2 hover:text-ink\">\n                Privacy policy\n              </a>\n              .\n              {signInHref && (\n                <>\n                  <br />\n                  Already have an account?{\" \"}\n                  <a href={signInHref} className=\"font-medium text-volt-ink hover:underline\">\n                    Sign in\n                  </a>\n                </>\n              )}\n            </p>\n          </motion.div>\n        ) : (\n          <motion.div\n            key=\"done\"\n            layout=\"position\"\n            role=\"status\"\n            initial={{ opacity: 0, filter: \"blur(8px)\", scale: 0.96 }}\n            animate={{ opacity: 1, filter: \"blur(0px)\", scale: 1 }}\n            exit={{ opacity: 0, filter: \"blur(8px)\" }}\n            transition={{ type: \"spring\", stiffness: 300, damping: 28 }}\n            className=\"grid justify-items-center gap-4 py-6 text-center\"\n          >\n            <motion.span\n              className=\"grid size-16 place-items-center rounded-full bg-volt-soft text-volt-ink\"\n              initial={reduce ? false : { scale: 0.4 }}\n              animate={{ scale: 1 }}\n              transition={{ type: \"spring\", stiffness: 420, damping: 16, delay: 0.05 }}\n            >\n              <svg viewBox=\"0 0 24 24\" className=\"size-8\" fill=\"none\" stroke=\"currentColor\" strokeWidth={2.5} strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden>\n                <motion.path\n                  d=\"M5 12.5l4.5 4.5L19 7.5\"\n                  initial={reduce ? false : { pathLength: 0 }}\n                  animate={{ pathLength: 1 }}\n                  transition={{ duration: 0.45, ease: [0.22, 1, 0.36, 1], delay: 0.2 }}\n                />\n              </svg>\n            </motion.span>\n            <div className=\"grid gap-1.5\">\n              <h2 className=\"font-display text-2xl font-semibold tracking-[-0.5px] text-ink\">{successTitle}</h2>\n              <p className=\"text-sm leading-[22px] text-ink-muted\">\n                We sent a confirmation link to <span className=\"font-medium text-ink\">{done}</span>. It expires in 24 hours.\n              </p>\n            </div>\n            <Button variant=\"ghost\" size=\"sm\" onClick={reset}>\n              Use a different email\n            </Button>\n          </motion.div>\n        )}\n      </AnimatePresence>\n    </motion.div>\n  );\n}\n"},{"path":"LICENSE-geturui.md","type":"registry:file","target":"LICENSE-geturui.md","content":"MIT License\n\nCopyright (c) 2026 geturui.com\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"}],"categories":["blocks","sign up","auth","form","validation","password strength","register"],"meta":{"tier":"free","license":"MIT","docs":"https://geturui.com/docs/sign-up-form"}}