{
  "$schema": "https://ui.shadcn.com/schema/registry-item.json",
  "name": "auth-01",
  "title": "分屏登录页",
  "description": "左侧品牌面板 + 右侧表单的分屏登录页：登录（密码 / 验证码）、注册（带强度条）、找回密码，zod 校验。",
  "dependencies": [
    "motion",
    "zod",
    "lucide-react"
  ],
  "registryDependencies": [
    "button",
    "label",
    "checkbox",
    "https://yiui.dev/r/ripple.json",
    "https://yiui.dev/r/glyph-field.json",
    "https://yiui.dev/r/text-animate.json",
    "https://yiui.dev/r/segmented-control.json",
    "https://yiui.dev/r/toggle-switch.json",
    "https://yiui.dev/r/phone-input.json",
    "https://yiui.dev/r/bar-field.json"
  ],
  "files": [
    {
      "path": "src/registry/blocks/auth-01/page.tsx",
      "content": "\"use client\"\n\nimport { Auth01 } from \"@/components/auth-01/auth-01\"\n\n/**\n * 登录页入口：把下面几个回调换成你自己的认证实现。\n * 回调返回 Promise；失败时 throw new Error(\"中文原因\")，组件会显示在表单上方。\n * 登录成功后的跳转请在 onSignIn / onSocialSignIn 里自行处理，例如 router.push(\"/\")。\n */\nexport default function LoginPage() {\n  return (\n    <Auth01\n      brand={{ name: \"Acme\" }}\n      onSignIn={async (values) => {\n        // TODO: 调用你的认证服务，例如 authClient.signIn.email(...)\n        console.info(\"sign in\", values)\n        await new Promise((resolve) => setTimeout(resolve, 600))\n      }}\n      onSignUp={async (values) => {\n        console.info(\"sign up\", values)\n        await new Promise((resolve) => setTimeout(resolve, 600))\n      }}\n      onForgotPassword={async (email) => {\n        console.info(\"forgot password\", email)\n        await new Promise((resolve) => setTimeout(resolve, 600))\n      }}\n      onSendCode={async (phone) => {\n        console.info(\"send code\", phone)\n        await new Promise((resolve) => setTimeout(resolve, 600))\n      }}\n      onSocialSignIn={async (provider) => {\n        console.info(\"social sign in\", provider)\n        await new Promise((resolve) => setTimeout(resolve, 600))\n      }}\n    />\n  )\n}\n",
      "type": "registry:page",
      "target": "app/login/page.tsx"
    },
    {
      "path": "src/registry/blocks/auth-01/auth-01.tsx",
      "content": "\"use client\"\n\nimport { AnimatePresence, motion, useReducedMotion } from \"motion/react\"\nimport { useState } from \"react\"\n\nimport { cn } from \"@/lib/utils\"\n\nimport { defaultBrand, type BrandConfig, type BrandFeature } from \"./brand\"\nimport { BrandPanel, MobileBrand } from \"./brand-panel\"\nimport type { Auth01Labels } from \"./config\"\nimport { ForgotPasswordForm } from \"./forgot-password-form\"\nimport { SignInForm, type SignInValues } from \"./sign-in-form\"\nimport { SignUpForm, type SignUpValues } from \"./sign-up-form\"\nimport type { SocialProvider } from \"./social-buttons\"\n\ntype AuthView = \"sign-in\" | \"sign-up\" | \"forgot-password\"\n\nconst wait = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms))\n// 未传回调时的示例实现：只在控制台打印，并模拟 0.8 秒的网络请求\nconst demo =\n  <Args extends unknown[]>(name: string) =>\n  async (...args: Args) => {\n    console.info(`[auth-01] ${name}`, ...args)\n    await wait(800)\n  }\n\n/**\n * 分屏式登录 / 注册页：左侧品牌面板 + 右侧表单，窄屏只显示表单。\n * 回调返回 Promise；组件管理 loading，回调 throw 的 Error.message 会显示为表单错误。\n */\nfunction Auth01({\n  brand,\n  defaultView = \"sign-in\",\n  socialProviders = [\"github\", \"google\"],\n  allowSignUp = true,\n  termsHref = \"#\",\n  privacyHref = \"#\",\n  onSignIn = demo<[SignInValues]>(\"onSignIn\"),\n  onSignUp = demo<[SignUpValues]>(\"onSignUp\"),\n  onForgotPassword = demo<[string]>(\"onForgotPassword\"),\n  onSendCode = demo<[string]>(\"onSendCode\"),\n  onSocialSignIn = demo<[SocialProvider]>(\"onSocialSignIn\"),\n  labels,\n  className,\n}: {\n  /** 品牌信息，逐项覆盖默认的示例品牌 */\n  brand?: Partial<BrandConfig>\n  defaultView?: AuthView\n  /** 启用的第三方登录，传空数组隐藏该区域 */\n  socialProviders?: readonly SocialProvider[]\n  /** 设为 false 隐藏「注册」入口（仅邀请制的产品） */\n  allowSignUp?: boolean\n  termsHref?: string\n  privacyHref?: string\n  onSignIn?: (values: SignInValues) => Promise<void>\n  onSignUp?: (values: SignUpValues) => Promise<void>\n  onForgotPassword?: (email: string) => Promise<void>\n  onSendCode?: (phone: string) => Promise<void>\n  onSocialSignIn?: (provider: SocialProvider) => Promise<void>\n  /** 覆盖默认文案，见 config.ts 的 DEFAULT_LABELS */\n  labels?: Partial<Auth01Labels>\n  className?: string\n}) {\n  const [view, setView] = useState<AuthView>(defaultView)\n  const reducedMotion = useReducedMotion()\n  const resolved: BrandConfig = { ...defaultBrand, ...brand }\n  return (\n    <div data-slot=\"auth-01\" className={cn(\"relative flex min-h-svh\", className)}>\n      <BrandPanel brand={resolved} labels={labels} />\n      <main className=\"relative flex flex-1 items-center justify-center bg-background p-6 pb-16 sm:p-12 sm:pb-16\">\n        <div className=\"w-full max-w-md\">\n          <MobileBrand brand={resolved} />\n          <AnimatePresence mode=\"wait\" initial={false}>\n            <motion.div\n              key={view}\n              initial={{ opacity: 0, y: reducedMotion ? 0 : 8 }}\n              animate={{ opacity: 1, y: 0 }}\n              exit={{ opacity: 0, y: reducedMotion ? 0 : -8 }}\n              transition={{ duration: 0.18 }}\n            >\n              {view === \"sign-in\" && (\n                <SignInForm\n                  socialProviders={socialProviders}\n                  allowSignUp={allowSignUp}\n                  onSignIn={onSignIn}\n                  onSendCode={onSendCode}\n                  onSocialSignIn={onSocialSignIn}\n                  onForgotPassword={() => setView(\"forgot-password\")}\n                  onSwitchToSignUp={() => setView(\"sign-up\")}\n                  labels={labels}\n                />\n              )}\n              {view === \"sign-up\" && (\n                <SignUpForm\n                  termsHref={termsHref}\n                  privacyHref={privacyHref}\n                  onSignUp={onSignUp}\n                  onSwitchToSignIn={() => setView(\"sign-in\")}\n                  labels={labels}\n                />\n              )}\n              {view === \"forgot-password\" && (\n                <ForgotPasswordForm\n                  onForgotPassword={onForgotPassword}\n                  onSwitchToSignIn={() => setView(\"sign-in\")}\n                  labels={labels}\n                />\n              )}\n            </motion.div>\n          </AnimatePresence>\n        </div>\n        <p className=\"absolute right-6 bottom-4 text-xs text-muted-foreground\">\n          {resolved.copyright}\n        </p>\n      </main>\n    </div>\n  )\n}\n\nexport { Auth01 }\nexport type {\n  Auth01Labels,\n  AuthView,\n  BrandConfig,\n  BrandFeature,\n  SignInValues,\n  SignUpValues,\n  SocialProvider,\n}\n",
      "type": "registry:component",
      "target": "@components/auth-01/auth-01.tsx"
    },
    {
      "path": "src/registry/blocks/auth-01/config.ts",
      "content": "/**\n * 登录页所有用户可见的文案，包含表单校验提示（validation* 键）。\n * 校验提示里的 {min}、{length} 由 schemas.ts 的规则常量填入；只改规则（密码策略、手机号格式）\n * 不用动文案，想换提示语则覆盖对应的 validation* 键。\n * 品牌名、标题、特性列表属于品牌数据，见 brand.ts。\n */\nconst DEFAULT_LABELS = {\n  // 品牌面板\n  brandPanelLabel: \"{name} 品牌介绍\",\n  // 登录\n  signInTitle: \"欢迎回来\",\n  signInDescription: \"输入账号信息即可登录\",\n  signInMethodLabel: \"登录方式\",\n  signInPasswordTab: \"密码登录\",\n  signInCodeTab: \"验证码登录\",\n  accountLabel: \"用户名或邮箱\",\n  accountPlaceholder: \"请输入用户名或邮箱\",\n  passwordLabel: \"密码\",\n  passwordPlaceholder: \"请输入密码\",\n  forgotPassword: \"忘记密码？\",\n  remember: \"记住登录状态\",\n  signInSubmit: \"登录\",\n  signInPending: \"登录中…\",\n  phoneLabel: \"手机号\",\n  phonePlaceholder: \"请输入 11 位手机号\",\n  codeLabel: \"验证码\",\n  codePlaceholder: \"6 位数字验证码\",\n  sendCode: \"获取验证码\",\n  sendCodePending: \"发送中…\",\n  resendCode: \"{seconds}s 后重发\",\n  socialDivider: \"或\",\n  noAccount: \"还没有账号？\",\n  signUpLink: \"注册\",\n  // 注册\n  signUpTitle: \"创建账号\",\n  signUpDescription: \"填写以下信息即可完成注册\",\n  nameLabel: \"姓名\",\n  namePlaceholder: \"请输入姓名\",\n  emailLabel: \"邮箱\",\n  emailPlaceholder: \"name@example.com\",\n  newPasswordPlaceholder: \"至少 8 位，包含字母和数字\",\n  confirmPasswordLabel: \"确认密码\",\n  confirmPasswordPlaceholder: \"再次输入密码\",\n  termsPrefix: \"我已阅读并同意\",\n  termsOfService: \"服务条款\",\n  termsConjunction: \"和\",\n  privacyPolicy: \"隐私政策\",\n  signUpSubmit: \"注册\",\n  signUpPending: \"注册中…\",\n  haveAccount: \"已有账号？\",\n  signInLink: \"登录\",\n  // 找回密码\n  forgotPasswordTitle: \"找回密码\",\n  forgotPasswordDescription: \"输入注册时使用的邮箱，我们会发送重置链接\",\n  sendResetLink: \"发送重置链接\",\n  sendResetLinkPending: \"发送中…\",\n  backToSignIn: \"返回登录\",\n  emailSentTitle: \"邮件已发送\",\n  emailSentDescription:\n    \"我们已向 {email} 发送了重置密码的链接，请查收邮件。没收到？请检查垃圾邮件箱。\",\n  // 输入框与密码强度\n  showPassword: \"显示密码\",\n  hidePassword: \"隐藏密码\",\n  passwordStrength: \"强度：{level}\",\n  passwordStrengthEmpty: \"强度：—\",\n  strengthWeak: \"弱\",\n  strengthFair: \"一般\",\n  strengthGood: \"较强\",\n  strengthStrong: \"强\",\n  // 校验提示（schemas.ts 使用，{min}、{length} 由规则常量填入）\n  validationAccountRequired: \"请输入用户名或邮箱\",\n  validationPasswordRequired: \"请输入密码\",\n  validationEmailRequired: \"请输入邮箱\",\n  validationEmailInvalid: \"请输入有效的邮箱地址\",\n  validationPhoneInvalid: \"请输入有效的 {length} 位手机号\",\n  validationCodeInvalid: \"请输入 {length} 位数字验证码\",\n  validationPasswordMin: \"密码至少 {min} 位\",\n  validationPasswordLetter: \"密码需要包含字母\",\n  validationPasswordDigit: \"密码需要包含数字\",\n  validationNameMin: \"姓名至少 {min} 个字符\",\n  validationConfirmRequired: \"请再次输入密码\",\n  validationTermsRequired: \"请先阅读并同意服务条款\",\n  validationPasswordMismatch: \"两次输入的密码不一致\",\n  // 通用\n  requestFailed: \"操作失败，请稍后重试\",\n} as const\n\ntype Auth01Labels = { [Key in keyof typeof DEFAULT_LABELS]: string }\n\n/** 合并用户传入的文案与默认文案。 */\nfunction resolveLabels(labels?: Partial<Auth01Labels>): Auth01Labels {\n  return { ...DEFAULT_LABELS, ...labels }\n}\n\n/** 把文案里的 {key} 占位符替换成实际值，例如「强度：{level}」。 */\nfunction formatLabel(\n  template: string,\n  values: Record<string, string | number>,\n): string {\n  return Object.entries(values).reduce(\n    (text, [key, value]) => text.replaceAll(`{${key}}`, String(value)),\n    template,\n  )\n}\n\n/** 以 {key} 为界把文案拆成前后两段，便于把值渲染成强调元素。 */\nfunction splitLabel(template: string, key: string): [string, string] {\n  const [before = template, after = \"\"] = template.split(`{${key}}`)\n  return [before, after]\n}\n\nexport { DEFAULT_LABELS, formatLabel, resolveLabels, splitLabel }\nexport type { Auth01Labels }\n",
      "type": "registry:component",
      "target": "@components/auth-01/config.ts"
    },
    {
      "path": "src/registry/blocks/auth-01/brand.tsx",
      "content": "import { Gauge, Hexagon, ShieldCheck, Zap } from \"lucide-react\"\nimport type { ReactNode } from \"react\"\n\ntype BrandFeature = {\n  icon: ReactNode\n  title: string\n  description: string\n}\n\ntype BrandConfig = {\n  /** 产品名，显示在 Logo 旁 */\n  name: string\n  /** Logo 节点：建议用 currentColor 的 SVG，这样在品牌面板（反色）和表单上方（正常色）都能看清 */\n  logo: ReactNode\n  /** 品牌面板的大标题 */\n  title: string\n  description: string\n  /** 品牌面板上的特性列表，建议 2–3 条 */\n  features: BrandFeature[]\n  /** 右下角的版权文字 */\n  copyright: string\n}\n\n/** 示例品牌：换成自己的产品信息，或通过 Auth01 的 brand 属性逐项覆盖。 */\nconst defaultBrand: BrandConfig = {\n  name: \"Acme\",\n  logo: <Hexagon strokeWidth={1.5} />,\n  title: \"把想法变成可用的产品\",\n  description: \"一个账号，打开全部工具。登录后继续上次的工作，随时随地保持同步。\",\n  features: [\n    {\n      icon: <Zap />,\n      title: \"快速上手\",\n      description: \"几分钟完成配置，立刻开始使用\",\n    },\n    {\n      icon: <Gauge />,\n      title: \"稳定可靠\",\n      description: \"全天候运行，关键数据实时同步\",\n    },\n    {\n      icon: <ShieldCheck />,\n      title: \"安全优先\",\n      description: \"加密传输，权限精细可控\",\n    },\n  ],\n  copyright: \"© 2026 Acme. 保留所有权利。\",\n}\n\nexport { defaultBrand }\nexport type { BrandConfig, BrandFeature }\n",
      "type": "registry:component",
      "target": "@components/auth-01/brand.tsx"
    },
    {
      "path": "src/registry/blocks/auth-01/brand-panel.tsx",
      "content": "import { cn } from \"@/lib/utils\"\nimport { GlyphField } from \"@/components/ui/glyph-field/glyph-field\"\nimport { Ripple } from \"@/components/ui/ripple/ripple\"\nimport { TextReveal } from \"@/components/ui/text-animate/text-animate\"\n\nimport type { BrandConfig } from \"./brand\"\nimport { formatLabel, resolveLabels, type Auth01Labels } from \"./config\"\n\nfunction Logo({\n  logo,\n  className,\n}: {\n  logo: BrandConfig[\"logo\"]\n  className: string\n}) {\n  // 外层限定尺寸，内部的 svg / img 自动缩放到框内\n  return (\n    <span\n      data-slot=\"auth-01-brand-logo\"\n      aria-hidden=\"true\"\n      className={cn(\n        \"flex shrink-0 items-center justify-center [&>*]:max-h-full [&>*]:max-w-full [&>svg]:size-full\",\n        className,\n      )}\n    >\n      {logo}\n    </span>\n  )\n}\n\n/**\n * 大屏左半边的品牌面板：主色渐变 + 模糊光斑 + 向外扩散的波纹 + 四周的字符矩阵。\n * 亮色下是主色底配 primary-foreground 文字；暗色下 primary 会变成浅色，整块面板会变亮，\n * 所以暗色改为 card 深底，只用 primary 的低透明度渐变染上主题色，文字回到 foreground。\n * 光斑、波纹、字符矩阵、图标底共用 --panel-glow，随亮暗一起切换。\n */\nfunction BrandPanel({\n  brand,\n  labels,\n}: {\n  brand: BrandConfig\n  labels?: Partial<Auth01Labels>\n}) {\n  const text = resolveLabels(labels)\n  return (\n    <aside\n      data-slot=\"auth-01-brand-panel\"\n      aria-label={formatLabel(text.brandPanelLabel, { name: brand.name })}\n      className=\"relative hidden overflow-hidden bg-linear-to-br from-primary/90 via-primary to-primary/80 text-primary-foreground [--panel-glow:var(--primary-foreground)] lg:flex lg:w-1/2 dark:bg-card dark:from-primary/16 dark:via-primary/7 dark:to-primary/3 dark:text-foreground dark:[--panel-glow:var(--primary)]\"\n    >\n      <div aria-hidden=\"true\" className=\"absolute inset-0\">\n        <div className=\"absolute top-20 left-10 size-72 rounded-full bg-(--panel-glow)/10 blur-3xl\" />\n        <div className=\"absolute right-10 bottom-20 size-96 rounded-full bg-(--panel-glow)/5 blur-3xl\" />\n        {/* 字符矩阵只铺在四周，中间留白给文字；GlyphField 自带底色，这里改成透明 */}\n        <GlyphField\n          fade=\"center\"\n          glyphs=\"01\"\n          tone=\"var(--panel-glow)\"\n          density={0.4}\n          fontSize={13}\n          speed={0.02}\n          className=\"absolute inset-0 min-h-0 bg-transparent opacity-25\"\n        />\n        <Ripple\n          size={720}\n          rings={4}\n          ringGap={140}\n          baseSize={200}\n          duration={8}\n          background=\"none\"\n          tone=\"var(--panel-glow)\"\n          className=\"absolute inset-0 h-full\"\n        />\n      </div>\n      <div className=\"relative z-10 flex flex-col justify-center px-12 xl:px-20\">\n        <div className=\"mb-8 flex items-center gap-3\">\n          <Logo logo={brand.logo} className=\"size-14\" />\n          <span className=\"text-2xl font-bold\" translate=\"no\">\n            {brand.name}\n          </span>\n        </div>\n        <p className=\"mb-6 text-2xl leading-tight font-bold text-balance xl:text-3xl\">\n          <TextReveal by=\"word\" trigger=\"mount\" stagger={70}>\n            {brand.title}\n          </TextReveal>\n        </p>\n        <p className=\"mb-10 max-w-md text-lg leading-8 text-current/80\">\n          {brand.description}\n        </p>\n        <ul className=\"flex flex-col gap-4\">\n          {brand.features.map((feature) => (\n            <li key={feature.title} className=\"flex items-center gap-4\">\n              <span\n                aria-hidden=\"true\"\n                className=\"rounded-lg bg-(--panel-glow)/20 p-2 [&_svg]:size-5\"\n              >\n                {feature.icon}\n              </span>\n              <div>\n                <div className=\"font-medium\">{feature.title}</div>\n                <div className=\"text-sm text-current/70\">\n                  {feature.description}\n                </div>\n              </div>\n            </li>\n          ))}\n        </ul>\n      </div>\n    </aside>\n  )\n}\n\n/** 窄屏下表单上方的 Logo + 名称（品牌面板此时被隐藏）。 */\nfunction MobileBrand({ brand }: { brand: BrandConfig }) {\n  return (\n    <div\n      data-slot=\"auth-01-mobile-brand\"\n      className=\"mb-8 flex items-center justify-center gap-2 lg:hidden\"\n    >\n      <Logo logo={brand.logo} className=\"size-10\" />\n      <span className=\"text-xl font-bold\" translate=\"no\">\n        {brand.name}\n      </span>\n    </div>\n  )\n}\n\nexport { BrandPanel, MobileBrand }\n",
      "type": "registry:component",
      "target": "@components/auth-01/brand-panel.tsx"
    },
    {
      "path": "src/registry/blocks/auth-01/sign-in-form.tsx",
      "content": "\"use client\"\n\nimport { useMemo, useState } from \"react\"\n\nimport {\n  PhoneInput,\n  PhoneInputSendButton,\n} from \"@/components/ui/phone-input/phone-input\"\nimport { SegmentedControl } from \"@/components/ui/segmented-control/segmented-control\"\nimport { ToggleSwitch } from \"@/components/ui/toggle-switch/toggle-switch\"\n\nimport { formatLabel, resolveLabels, type Auth01Labels } from \"./config\"\nimport {\n  FormError,\n  LinkButton,\n  PasswordField,\n  SubmitButton,\n  TextField,\n  ViewHeading,\n} from \"./form-parts\"\nimport {\n  PHONE_LENGTH,\n  createCodeSignInSchema,\n  createSignInSchema,\n} from \"./schemas\"\nimport { SocialButtons, type SocialProvider } from \"./social-buttons\"\nimport { useAsyncAction, useAuthForm } from \"./use-auth-form\"\n\ntype SignInValues =\n  | { method: \"password\"; account: string; password: string; remember: boolean }\n  | { method: \"code\"; phone: string; code: string }\n\ntype SignInMethod = SignInValues[\"method\"]\n\nconst CODE_COOLDOWN = 60\n\nfunction PasswordSignIn({\n  onSignIn,\n  onForgotPassword,\n  labels,\n}: {\n  onSignIn: (values: SignInValues) => Promise<void>\n  onForgotPassword: () => void\n  labels?: Partial<Auth01Labels>\n}) {\n  // labels 引用不变时 text 与 schema 都不重建，避免每次输入都重新编译 zod schema\n  const text = useMemo(() => resolveLabels(labels), [labels])\n  const schema = useMemo(() => createSignInSchema(text), [text])\n  const form = useAuthForm(\n    schema,\n    { account: \"\", password: \"\", remember: false },\n    { fallbackError: text.requestFailed },\n  )\n  return (\n    <form\n      data-slot=\"auth-01-sign-in-password\"\n      noValidate\n      onSubmit={form.handleSubmit((values) =>\n        onSignIn({ method: \"password\", ...values }),\n      )}\n      className=\"flex flex-col gap-5\"\n    >\n      <FormError message={form.formError} />\n      <TextField\n        id=\"sign-in-account\"\n        label={text.accountLabel}\n        autoComplete=\"username\"\n        placeholder={text.accountPlaceholder}\n        value={form.values.account}\n        error={form.errors.account}\n        onChange={(event) => form.setValue(\"account\", event.target.value)}\n        onBlur={() => form.blur(\"account\")}\n      />\n      <PasswordField\n        id=\"sign-in-password\"\n        label={text.passwordLabel}\n        autoComplete=\"current-password\"\n        placeholder={text.passwordPlaceholder}\n        value={form.values.password}\n        error={form.errors.password}\n        onChange={(event) => form.setValue(\"password\", event.target.value)}\n        onBlur={() => form.blur(\"password\")}\n        labels={labels}\n        footerAction={\n          <LinkButton className=\"text-xs\" onClick={onForgotPassword}>\n            {text.forgotPassword}\n          </LinkButton>\n        }\n      />\n      {/* 记住登录状态是即时生效的开关，不是需要同意的声明，所以用开关而不是复选框 */}\n      <ToggleSwitch\n        label={text.remember}\n        tone=\"primary\"\n        checked={form.values.remember}\n        onCheckedChange={(checked) => form.setValue(\"remember\", checked)}\n      />\n      <SubmitButton pending={form.pending} pendingText={text.signInPending}>\n        {text.signInSubmit}\n      </SubmitButton>\n    </form>\n  )\n}\n\nfunction CodeSignIn({\n  onSignIn,\n  onSendCode,\n  labels,\n}: {\n  onSignIn: (values: SignInValues) => Promise<void>\n  onSendCode: (phone: string) => Promise<void>\n  labels?: Partial<Auth01Labels>\n}) {\n  const text = useMemo(() => resolveLabels(labels), [labels])\n  const schema = useMemo(() => createCodeSignInSchema(text), [text])\n  const form = useAuthForm(\n    schema,\n    { phone: \"\", code: \"\" },\n    { fallbackError: text.requestFailed },\n  )\n  const sender = useAsyncAction(text.requestFailed)\n\n  // 失败时必须 throw：PhoneInputSendButton 遇到抛错就不进入倒计时，用户可以马上重试\n  const sendCode = async () => {\n    if (!form.validateField(\"phone\")) throw new Error(text.validationPhoneInvalid)\n    const sent = await sender.run(() => onSendCode(form.values.phone))\n    if (!sent) throw new Error(text.requestFailed)\n  }\n  const phoneInvalid = formatLabel(text.validationPhoneInvalid, {\n    length: PHONE_LENGTH,\n  })\n  return (\n    <form\n      data-slot=\"auth-01-sign-in-code\"\n      noValidate\n      onSubmit={form.handleSubmit((values) =>\n        onSignIn({ method: \"code\", ...values }),\n      )}\n      className=\"flex flex-col gap-5\"\n    >\n      <FormError message={form.formError ?? sender.error} />\n      <PhoneInput\n        id=\"sign-in-phone\"\n        size=\"lg\"\n        label={text.phoneLabel}\n        placeholder={text.phonePlaceholder}\n        value={form.values.phone}\n        error={form.errors.phone}\n        labels={{ invalid: phoneInvalid, required: phoneInvalid }}\n        onValueChange={(phone) => form.setValue(\"phone\", phone)}\n        onBlur={() => form.blur(\"phone\")}\n        action={\n          <PhoneInputSendButton\n            cooldown={CODE_COOLDOWN}\n            onSend={sendCode}\n            labels={{\n              send: text.sendCode,\n              sending: text.sendCodePending,\n              countdown: text.resendCode,\n              resend: text.sendCode,\n            }}\n          />\n        }\n      />\n      <TextField\n        id=\"sign-in-code\"\n        label={text.codeLabel}\n        inputMode=\"numeric\"\n        maxLength={6}\n        autoComplete=\"one-time-code\"\n        placeholder={text.codePlaceholder}\n        value={form.values.code}\n        error={form.errors.code}\n        onChange={(event) => form.setValue(\"code\", event.target.value)}\n        onBlur={() => form.blur(\"code\")}\n      />\n      <SubmitButton pending={form.pending} pendingText={text.signInPending}>\n        {text.signInSubmit}\n      </SubmitButton>\n    </form>\n  )\n}\n\nfunction SignInForm({\n  socialProviders,\n  allowSignUp,\n  onSignIn,\n  onSendCode,\n  onSocialSignIn,\n  onForgotPassword,\n  onSwitchToSignUp,\n  labels,\n}: {\n  socialProviders: readonly SocialProvider[]\n  allowSignUp: boolean\n  onSignIn: (values: SignInValues) => Promise<void>\n  onSendCode: (phone: string) => Promise<void>\n  onSocialSignIn: (provider: SocialProvider) => Promise<void>\n  onForgotPassword: () => void\n  onSwitchToSignUp: () => void\n  labels?: Partial<Auth01Labels>\n}) {\n  const text = resolveLabels(labels)\n  const [method, setMethod] = useState<SignInMethod>(\"password\")\n  const methodOptions = [\n    { value: \"password\", label: text.signInPasswordTab },\n    { value: \"code\", label: text.signInCodeTab },\n  ] as const\n  const social = useAsyncAction(text.requestFailed)\n  return (\n    <div data-slot=\"auth-01-sign-in\" className=\"flex flex-col gap-5\">\n      <ViewHeading\n        title={text.signInTitle}\n        description={text.signInDescription}\n      />\n      <div className=\"flex flex-col gap-3\">\n        <SegmentedControl\n          aria-label={text.signInMethodLabel}\n          size=\"lg\"\n          options={methodOptions}\n          value={method}\n          onValueChange={(value) => setMethod(value as SignInMethod)}\n        />\n        {method === \"password\" ? (\n          <PasswordSignIn\n            onSignIn={onSignIn}\n            onForgotPassword={onForgotPassword}\n            labels={labels}\n          />\n        ) : (\n          <CodeSignIn\n            onSignIn={onSignIn}\n            onSendCode={onSendCode}\n            labels={labels}\n          />\n        )}\n      </div>\n      {socialProviders.length > 0 && (\n        <>\n          <div\n            role=\"separator\"\n            className=\"flex items-center gap-3 text-xs text-muted-foreground before:h-px before:flex-1 before:bg-border after:h-px after:flex-1 after:bg-border\"\n          >\n            {text.socialDivider}\n          </div>\n          <FormError message={social.error} />\n          <SocialButtons\n            providers={socialProviders}\n            pending={social.pending}\n            onSelect={(provider) => social.run(() => onSocialSignIn(provider))}\n          />\n        </>\n      )}\n      {allowSignUp && (\n        <p className=\"text-center text-sm text-muted-foreground\">\n          {text.noAccount}{\" \"}\n          <LinkButton onClick={onSwitchToSignUp}>{text.signUpLink}</LinkButton>\n        </p>\n      )}\n    </div>\n  )\n}\n\nexport { SignInForm }\nexport type { SignInValues }\n",
      "type": "registry:component",
      "target": "@components/auth-01/sign-in-form.tsx"
    },
    {
      "path": "src/registry/blocks/auth-01/sign-up-form.tsx",
      "content": "\"use client\"\n\nimport { useMemo } from \"react\"\n\nimport { Checkbox } from \"@/components/ui/checkbox\"\nimport { Label } from \"@/components/ui/label\"\n\nimport { resolveLabels, type Auth01Labels } from \"./config\"\nimport {\n  FormError,\n  LinkButton,\n  PasswordField,\n  SubmitButton,\n  TextField,\n  ViewHeading,\n} from \"./form-parts\"\nimport { PasswordStrength } from \"./password-strength\"\nimport { createSignUpSchema } from \"./schemas\"\nimport { useAuthForm } from \"./use-auth-form\"\n\ntype SignUpValues = { name: string; email: string; password: string }\n\nfunction SignUpForm({\n  termsHref,\n  privacyHref,\n  onSignUp,\n  onSwitchToSignIn,\n  labels,\n}: {\n  termsHref: string\n  privacyHref: string\n  onSignUp: (values: SignUpValues) => Promise<void>\n  onSwitchToSignIn: () => void\n  labels?: Partial<Auth01Labels>\n}) {\n  // labels 引用不变时 text 与 schema 都不重建，避免每次输入都重新编译 zod schema\n  const text = useMemo(() => resolveLabels(labels), [labels])\n  const schema = useMemo(() => createSignUpSchema(text), [text])\n  const form = useAuthForm(\n    schema,\n    {\n      name: \"\",\n      email: \"\",\n      password: \"\",\n      confirm: \"\",\n      terms: false,\n    },\n    { fallbackError: text.requestFailed },\n  )\n  return (\n    <div data-slot=\"auth-01-sign-up\" className=\"flex flex-col gap-5\">\n      <ViewHeading title={text.signUpTitle} description={text.signUpDescription} />\n      <form\n        noValidate\n        onSubmit={form.handleSubmit(({ name, email, password }) =>\n          onSignUp({ name: name.trim(), email: email.trim(), password }),\n        )}\n        className=\"flex flex-col gap-4\"\n      >\n        <FormError message={form.formError} />\n        <TextField\n          id=\"sign-up-name\"\n          label={text.nameLabel}\n          autoComplete=\"name\"\n          placeholder={text.namePlaceholder}\n          value={form.values.name}\n          error={form.errors.name}\n          onChange={(event) => form.setValue(\"name\", event.target.value)}\n          onBlur={() => form.blur(\"name\")}\n        />\n        <TextField\n          id=\"sign-up-email\"\n          label={text.emailLabel}\n          type=\"email\"\n          autoComplete=\"email\"\n          placeholder={text.emailPlaceholder}\n          value={form.values.email}\n          error={form.errors.email}\n          onChange={(event) => form.setValue(\"email\", event.target.value)}\n          onBlur={() => form.blur(\"email\")}\n        />\n        <div className=\"flex flex-col gap-2\">\n          <PasswordField\n            id=\"sign-up-password\"\n            label={text.passwordLabel}\n            autoComplete=\"new-password\"\n            placeholder={text.newPasswordPlaceholder}\n            value={form.values.password}\n            error={form.errors.password}\n            onChange={(event) => form.setValue(\"password\", event.target.value)}\n            onBlur={() => form.blur(\"password\")}\n            labels={labels}\n          />\n          <PasswordStrength password={form.values.password} labels={labels} />\n        </div>\n        <PasswordField\n          id=\"sign-up-confirm\"\n          label={text.confirmPasswordLabel}\n          autoComplete=\"new-password\"\n          placeholder={text.confirmPasswordPlaceholder}\n          value={form.values.confirm}\n          error={form.errors.confirm}\n          onChange={(event) => form.setValue(\"confirm\", event.target.value)}\n          onBlur={() => form.blur(\"confirm\")}\n          labels={labels}\n        />\n        <div className=\"flex flex-col gap-2\">\n          <div className=\"flex items-center gap-2\">\n            <Checkbox\n              id=\"sign-up-terms\"\n              checked={form.values.terms}\n              aria-invalid={form.errors.terms ? true : undefined}\n              aria-describedby={form.errors.terms ? \"sign-up-terms-error\" : undefined}\n              onCheckedChange={(checked) =>\n                form.setValue(\"terms\", checked === true)\n              }\n            />\n            <Label\n              htmlFor=\"sign-up-terms\"\n              className=\"cursor-pointer leading-5 font-normal\"\n            >\n              {text.termsPrefix}\n              <a\n                href={termsHref}\n                className=\"text-primary underline-offset-4 hover:underline\"\n              >\n                {text.termsOfService}\n              </a>\n              {text.termsConjunction}\n              <a\n                href={privacyHref}\n                className=\"text-primary underline-offset-4 hover:underline\"\n              >\n                {text.privacyPolicy}\n              </a>\n            </Label>\n          </div>\n          {form.errors.terms ? (\n            <p id=\"sign-up-terms-error\" className=\"text-xs text-destructive\">\n              {form.errors.terms}\n            </p>\n          ) : null}\n        </div>\n        <SubmitButton pending={form.pending} pendingText={text.signUpPending}>\n          {text.signUpSubmit}\n        </SubmitButton>\n      </form>\n      <p className=\"text-center text-sm text-muted-foreground\">\n        {text.haveAccount}{\" \"}\n        <LinkButton onClick={onSwitchToSignIn}>{text.signInLink}</LinkButton>\n      </p>\n    </div>\n  )\n}\n\nexport { SignUpForm }\nexport type { SignUpValues }\n",
      "type": "registry:component",
      "target": "@components/auth-01/sign-up-form.tsx"
    },
    {
      "path": "src/registry/blocks/auth-01/forgot-password-form.tsx",
      "content": "\"use client\"\n\nimport { MailCheck } from \"lucide-react\"\nimport { useMemo, useState } from \"react\"\n\nimport { Button } from \"@/components/ui/button\"\nimport { Ripple } from \"@/components/ui/ripple/ripple\"\n\nimport { resolveLabels, splitLabel, type Auth01Labels } from \"./config\"\nimport { FormError, SubmitButton, TextField, ViewHeading } from \"./form-parts\"\nimport { createForgotPasswordSchema } from \"./schemas\"\nimport { useAuthForm } from \"./use-auth-form\"\n\nfunction ForgotPasswordForm({\n  onForgotPassword,\n  onSwitchToSignIn,\n  labels,\n}: {\n  onForgotPassword: (email: string) => Promise<void>\n  onSwitchToSignIn: () => void\n  labels?: Partial<Auth01Labels>\n}) {\n  // labels 引用不变时 text 与 schema 都不重建，避免每次输入都重新编译 zod schema\n  const text = useMemo(() => resolveLabels(labels), [labels])\n  const schema = useMemo(() => createForgotPasswordSchema(text), [text])\n  const form = useAuthForm(\n    schema,\n    { email: \"\" },\n    { fallbackError: text.requestFailed },\n  )\n  const [sentTo, setSentTo] = useState<string | null>(null)\n\n  if (sentTo) {\n    const [before, after] = splitLabel(text.emailSentDescription, \"email\")\n    return (\n      <div\n        data-slot=\"auth-01-email-sent\"\n        className=\"flex flex-col items-center gap-4 text-center\"\n        role=\"status\"\n      >\n        {/* 以邮件图标为圆心向外扩散的波纹，表达「已发出」；纯装饰，状态由下方文字播报 */}\n        <Ripple\n          size={192}\n          rings={3}\n          ringGap={44}\n          baseSize={56}\n          duration={3.5}\n          background=\"none\"\n          tone=\"primary\"\n          className=\"h-48 w-48 max-w-full\"\n        >\n          <span className=\"absolute top-1/2 left-1/2 flex size-14 -translate-x-1/2 -translate-y-1/2 items-center justify-center rounded-full border border-edge bg-background text-primary [&_svg]:size-7\">\n            <MailCheck />\n          </span>\n        </Ripple>\n        <div className=\"flex flex-col gap-1\">\n          <h1 className=\"text-2xl font-bold tracking-tight\">\n            {text.emailSentTitle}\n          </h1>\n          <p className=\"text-sm leading-6 text-muted-foreground\">\n            {before}\n            <span className=\"font-medium text-foreground\">{sentTo}</span>\n            {after}\n          </p>\n        </div>\n        <Button size=\"lg\" className=\"w-full\" onClick={onSwitchToSignIn}>\n          {text.backToSignIn}\n        </Button>\n      </div>\n    )\n  }\n  return (\n    <div data-slot=\"auth-01-forgot-password\" className=\"flex flex-col gap-5\">\n      <ViewHeading\n        title={text.forgotPasswordTitle}\n        description={text.forgotPasswordDescription}\n      />\n      <form\n        noValidate\n        onSubmit={form.handleSubmit(async ({ email }) => {\n          await onForgotPassword(email.trim())\n          setSentTo(email.trim())\n        })}\n        className=\"flex flex-col gap-5\"\n      >\n        <FormError message={form.formError} />\n        <TextField\n          id=\"forgot-email\"\n          label={text.emailLabel}\n          type=\"email\"\n          autoComplete=\"email\"\n          placeholder={text.emailPlaceholder}\n          value={form.values.email}\n          error={form.errors.email}\n          onChange={(event) => form.setValue(\"email\", event.target.value)}\n          onBlur={() => form.blur(\"email\")}\n        />\n        <SubmitButton\n          pending={form.pending}\n          pendingText={text.sendResetLinkPending}\n        >\n          {text.sendResetLink}\n        </SubmitButton>\n      </form>\n      <Button variant=\"ghost\" size=\"lg\" onClick={onSwitchToSignIn}>\n        {text.backToSignIn}\n      </Button>\n    </div>\n  )\n}\n\nexport { ForgotPasswordForm }\n",
      "type": "registry:component",
      "target": "@components/auth-01/forgot-password-form.tsx"
    },
    {
      "path": "src/registry/blocks/auth-01/form-parts.tsx",
      "content": "\"use client\"\n\nimport { Eye, EyeOff, Loader2 } from \"lucide-react\"\nimport { useState, type ComponentProps, type ReactNode } from \"react\"\n\nimport { Button } from \"@/components/ui/button\"\nimport { BarField } from \"@/components/ui/bar-field/bar-field\"\nimport { cn } from \"@/lib/utils\"\n\nimport { resolveLabels, type Auth01Labels } from \"./config\"\n\n/**\n * 方条输入框：标签在条内左侧，值靠右；错误文字在条下方，通过 aria-describedby 关联，读屏会一并读出。\n * 高度取 lg 档（36px，触屏 44px），与区块里 size=\"lg\" 的按钮等高。\n */\nfunction TextField({\n  id,\n  label,\n  error,\n  footerAction,\n  trailing,\n  className,\n  value,\n  defaultValue,\n  ...props\n}: Omit<ComponentProps<\"input\">, \"id\" | \"size\"> & {\n  id: string\n  label: string\n  error?: string\n  /** 条下方右侧的操作，例如「忘记密码？」；有错误文字时错误在左、操作在右 */\n  footerAction?: ReactNode\n  /** 条内最右侧的元素，例如显示/隐藏密码按钮 */\n  trailing?: ReactNode\n}) {\n  return (\n    <BarField\n      {...props}\n      value={value === undefined ? undefined : String(value)}\n      defaultValue={\n        defaultValue === undefined ? undefined : String(defaultValue)\n      }\n      id={id}\n      label={label}\n      error={error}\n      footerAction={footerAction}\n      suffix={trailing}\n      size=\"lg\"\n      className={cn(\n        \"[&_[data-slot=bar-field-label-above]]:hidden! [&_[data-slot=bar-field-label]]:not-sr-only! [&_input]:text-right!\",\n        className,\n      )}\n    />\n  )\n}\n\n/** 带显示/隐藏切换的密码框。 */\nfunction PasswordField({\n  labels,\n  ...props\n}: Omit<ComponentProps<typeof TextField>, \"type\" | \"trailing\"> & {\n  labels?: Partial<Auth01Labels>\n}) {\n  const text = resolveLabels(labels)\n  const [visible, setVisible] = useState(false)\n  return (\n    <TextField\n      {...props}\n      type={visible ? \"text\" : \"password\"}\n      trailing={\n        <Button\n          type=\"button\"\n          variant=\"ghost\"\n          size=\"icon-lg\"\n          onClick={() => setVisible((value) => !value)}\n          aria-label={visible ? text.hidePassword : text.showPassword}\n          aria-pressed={visible}\n          // 按钮比条内边距大，向右让出 8px，图标视觉上仍与条的右缘留足间距\n          className=\"shrink-0 text-muted-foreground hover:text-foreground\"\n        >\n          {visible ? <EyeOff aria-hidden=\"true\" /> : <Eye aria-hidden=\"true\" />}\n        </Button>\n      }\n    />\n  )\n}\n\n/** 表单级错误（接口返回的失败原因等），出现时读屏会立即朗读。 */\nfunction FormError({ message }: { message: string | null }) {\n  if (!message) return null\n  return (\n    <p\n      data-slot=\"auth-01-form-error\"\n      role=\"alert\"\n      className=\"rounded-lg border border-destructive/30 bg-destructive/10 px-3 py-2 text-sm text-destructive\"\n    >\n      {message}\n    </p>\n  )\n}\n\n/** 提交按钮：pending 时显示转圈并禁用。 */\nfunction SubmitButton({\n  pending,\n  pendingText,\n  children,\n}: {\n  pending: boolean\n  pendingText: string\n  children: ReactNode\n}) {\n  return (\n    <Button\n      data-slot=\"auth-01-submit-button\"\n      type=\"submit\"\n      size=\"lg\"\n      className=\"w-full\"\n      disabled={pending}\n    >\n      {pending ? (\n        <>\n          <Loader2 aria-hidden=\"true\" className=\"animate-spin\" />\n          {pendingText}\n        </>\n      ) : (\n        children\n      )}\n    </Button>\n  )\n}\n\n/** 视图头部：标题 + 说明。每个视图只有一个 h1。 */\nfunction ViewHeading({\n  title,\n  description,\n}: {\n  title: string\n  description: string\n}) {\n  return (\n    <div data-slot=\"auth-01-view-heading\" className=\"flex flex-col gap-1\">\n      <h1 className=\"text-2xl font-bold tracking-tight\">{title}</h1>\n      <p className=\"text-sm text-muted-foreground\">{description}</p>\n    </div>\n  )\n}\n\n/** 文字链接样式的按钮，用于视图切换。 */\nfunction LinkButton({ className, ...props }: ComponentProps<\"button\">) {\n  return (\n    <button\n      data-slot=\"auth-01-link-button\"\n      type=\"button\"\n      className={cn(\n        \"rounded-sm font-medium text-primary underline-offset-4 hover:underline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring\",\n        className,\n      )}\n      {...props}\n    />\n  )\n}\n\nexport {\n  FormError,\n  LinkButton,\n  PasswordField,\n  SubmitButton,\n  TextField,\n  ViewHeading,\n}\n",
      "type": "registry:component",
      "target": "@components/auth-01/form-parts.tsx"
    },
    {
      "path": "src/registry/blocks/auth-01/password-strength.tsx",
      "content": "import { cn } from \"@/lib/utils\"\n\nimport { formatLabel, resolveLabels, type Auth01Labels } from \"./config\"\n\n// 四段强度条：颜色从 destructive 过渡到主色，跟随主题；文字在 DEFAULT_LABELS 里\nconst levels = [\n  { label: \"strengthWeak\", bar: \"bg-destructive\" },\n  { label: \"strengthFair\", bar: \"bg-destructive/50\" },\n  { label: \"strengthGood\", bar: \"bg-primary/60\" },\n  { label: \"strengthStrong\", bar: \"bg-primary\" },\n] as const satisfies readonly { label: keyof Auth01Labels; bar: string }[]\n\n/** 按长度与字符种类打分：0 表示尚未输入，1–4 对应 弱 / 一般 / 较强 / 强。 */\nfunction getPasswordStrength(password: string) {\n  if (!password) return 0\n  const score =\n    Number(password.length >= 8) +\n    Number(password.length >= 12) +\n    Number(/[a-z]/.test(password) && /[A-Z]/.test(password)) +\n    Number(/\\d/.test(password)) +\n    Number(/[^A-Za-z0-9]/.test(password))\n  return Math.min(4, Math.max(1, score <= 1 ? 1 : score >= 4 ? 4 : score))\n}\n\n/** 四段强度条 + 文字说明。 */\nfunction PasswordStrength({\n  password,\n  labels,\n}: {\n  password: string\n  labels?: Partial<Auth01Labels>\n}) {\n  const text = resolveLabels(labels)\n  const strength = getPasswordStrength(password)\n  const level = strength ? levels[strength - 1] : null\n  return (\n    <div\n      data-slot=\"auth-01-password-strength\"\n      data-strength={strength}\n      className=\"flex items-center gap-3\"\n    >\n      <div aria-hidden=\"true\" className=\"grid flex-1 grid-cols-4 gap-1\">\n        {levels.map((item, index) => (\n          <span\n            key={item.label}\n            className={cn(\n              \"h-1 rounded-full bg-muted transition-colors motion-reduce:transition-none\",\n              index < strength && item.bar,\n            )}\n          />\n        ))}\n      </div>\n      <span\n        aria-live=\"polite\"\n        className=\"w-16 text-xs whitespace-nowrap text-muted-foreground\"\n      >\n        {level\n          ? formatLabel(text.passwordStrength, { level: text[level.label] })\n          : text.passwordStrengthEmpty}\n      </span>\n    </div>\n  )\n}\n\nexport { PasswordStrength, getPasswordStrength }\n",
      "type": "registry:component",
      "target": "@components/auth-01/password-strength.tsx"
    },
    {
      "path": "src/registry/blocks/auth-01/schemas.ts",
      "content": "import { z } from \"zod\"\n\nimport { formatLabel, type Auth01Labels } from \"./config\"\n\n/**\n * 校验规则常量：改策略只改这里，提示文案里的 {min}、{length} 会自动带入新值。\n * 提示文案本身全部来自 labels（config.ts 的 validation* 键），可逐实例覆盖。\n */\n\n/** 密码最少位数 */\nconst PASSWORD_MIN_LENGTH = 8\n\n/** 姓名最少字符数 */\nconst NAME_MIN_LENGTH = 2\n\n/** 短信验证码位数 */\nconst CODE_LENGTH = 6\n\n/** 中国大陆手机号位数，需与 PHONE_PATTERN 的位数一致 */\nconst PHONE_LENGTH = 11\n\n/** 中国大陆 11 位手机号；面向海外用户时替换这条规则 */\nconst PHONE_PATTERN = /^1[3-9]\\d{9}$/\n\n/** 验证码只接受数字，位数由 CODE_LENGTH 决定 */\nconst CODE_PATTERN = new RegExp(`^\\\\d{${CODE_LENGTH}}$`)\n\nfunction emailField(labels: Auth01Labels) {\n  return z\n    .string()\n    .trim()\n    .min(1, labels.validationEmailRequired)\n    .email(labels.validationEmailInvalid)\n}\n\nfunction passwordField(labels: Auth01Labels) {\n  return z\n    .string()\n    .min(\n      PASSWORD_MIN_LENGTH,\n      formatLabel(labels.validationPasswordMin, { min: PASSWORD_MIN_LENGTH }),\n    )\n    .regex(/[A-Za-z]/, labels.validationPasswordLetter)\n    .regex(/\\d/, labels.validationPasswordDigit)\n}\n\nfunction phoneField(labels: Auth01Labels) {\n  return z\n    .string()\n    .trim()\n    .regex(\n      PHONE_PATTERN,\n      formatLabel(labels.validationPhoneInvalid, { length: PHONE_LENGTH }),\n    )\n}\n\n/** 密码登录。labels 需是合并过默认值的完整文案。 */\nfunction createSignInSchema(labels: Auth01Labels) {\n  return z.object({\n    account: z.string().trim().min(1, labels.validationAccountRequired),\n    password: z.string().min(1, labels.validationPasswordRequired),\n    remember: z.boolean(),\n  })\n}\n\n/** 验证码登录。 */\nfunction createCodeSignInSchema(labels: Auth01Labels) {\n  return z.object({\n    phone: phoneField(labels),\n    code: z\n      .string()\n      .trim()\n      .regex(\n        CODE_PATTERN,\n        formatLabel(labels.validationCodeInvalid, { length: CODE_LENGTH }),\n      ),\n  })\n}\n\n/** 注册：确认密码与条款勾选也在前端校验。 */\nfunction createSignUpSchema(labels: Auth01Labels) {\n  return z\n    .object({\n      name: z\n        .string()\n        .trim()\n        .min(\n          NAME_MIN_LENGTH,\n          formatLabel(labels.validationNameMin, { min: NAME_MIN_LENGTH }),\n        ),\n      email: emailField(labels),\n      password: passwordField(labels),\n      confirm: z.string().min(1, labels.validationConfirmRequired),\n      terms: z.boolean().refine((value) => value, labels.validationTermsRequired),\n    })\n    .refine((values) => values.password === values.confirm, {\n      message: labels.validationPasswordMismatch,\n      path: [\"confirm\"],\n    })\n}\n\n/** 找回密码。 */\nfunction createForgotPasswordSchema(labels: Auth01Labels) {\n  return z.object({ email: emailField(labels) })\n}\n\nexport {\n  CODE_LENGTH,\n  NAME_MIN_LENGTH,\n  PASSWORD_MIN_LENGTH,\n  PHONE_LENGTH,\n  PHONE_PATTERN,\n  createCodeSignInSchema,\n  createForgotPasswordSchema,\n  createSignInSchema,\n  createSignUpSchema,\n}\n",
      "type": "registry:component",
      "target": "@components/auth-01/schemas.ts"
    },
    {
      "path": "src/registry/blocks/auth-01/social-buttons.tsx",
      "content": "import type { SVGProps } from \"react\"\n\nimport { Button } from \"@/components/ui/button\"\n\ntype SocialProvider = \"github\" | \"google\"\n\nfunction GitHubIcon(props: SVGProps<SVGSVGElement>) {\n  return (\n    <svg\n      data-slot=\"auth-01-github-icon\"\n      viewBox=\"0 0 24 24\"\n      fill=\"currentColor\"\n      aria-hidden=\"true\"\n      {...props}\n    >\n      <path d=\"M12 2a10 10 0 0 0-3.16 19.49c.5.09.68-.22.68-.48v-1.87c-2.78.6-3.37-1.18-3.37-1.18-.45-1.16-1.11-1.47-1.11-1.47-.91-.62.07-.61.07-.61 1 .07 1.53 1.03 1.53 1.03.89 1.53 2.34 1.09 2.91.83.09-.65.35-1.09.64-1.34-2.22-.25-4.56-1.11-4.56-4.94 0-1.09.39-1.98 1.03-2.68-.1-.25-.45-1.27.1-2.65 0 0 .84-.27 2.75 1.02A9.6 9.6 0 0 1 12 6.81c.85 0 1.71.11 2.51.34 1.91-1.29 2.75-1.02 2.75-1.02.55 1.38.2 2.4.1 2.65.64.7 1.03 1.59 1.03 2.68 0 3.84-2.34 4.69-4.57 4.94.36.31.68.92.68 1.85v2.76c0 .27.18.58.69.48A10 10 0 0 0 12 2Z\" />\n    </svg>\n  )\n}\n\n// 单色 G 标识：用 currentColor，不引入品牌多色，跟随主题\nfunction GoogleIcon(props: SVGProps<SVGSVGElement>) {\n  return (\n    <svg\n      data-slot=\"auth-01-google-icon\"\n      viewBox=\"0 0 24 24\"\n      fill=\"currentColor\"\n      aria-hidden=\"true\"\n      {...props}\n    >\n      <path d=\"M12.48 10.92v3.28h7.84c-.24 1.84-.853 3.187-1.787 4.133-1.147 1.147-2.933 2.4-6.053 2.4-4.827 0-8.6-3.893-8.6-8.72s3.773-8.72 8.6-8.72c2.6 0 4.507 1.027 5.907 2.347l2.307-2.307C18.747 1.44 16.133 0 12.48 0 5.867 0 .307 5.387.307 12s5.56 12 12.173 12c3.573 0 6.267-1.173 8.373-3.36 2.16-2.16 2.84-5.213 2.84-7.667 0-.76-.053-1.467-.173-2.053H12.48z\" />\n    </svg>\n  )\n}\n\n// 品牌名是专有名词，不放进 labels\nconst providers = {\n  github: { label: \"GitHub\", Icon: GitHubIcon },\n  google: { label: \"Google\", Icon: GoogleIcon },\n} as const\n\n/** 第三方登录按钮行：点击后交给 onSelect，pending 时全部禁用。 */\nfunction SocialButtons({\n  providers: enabled,\n  pending,\n  onSelect,\n}: {\n  providers: readonly SocialProvider[]\n  pending: boolean\n  onSelect: (provider: SocialProvider) => void\n}) {\n  if (!enabled.length) return null\n  return (\n    <div\n      data-slot=\"auth-01-social-buttons\"\n      className=\"grid gap-2\"\n      style={{\n        gridTemplateColumns: `repeat(${enabled.length}, minmax(0, 1fr))`,\n      }}\n    >\n      {enabled.map((provider) => {\n        const { label, Icon } = providers[provider]\n        return (\n          <Button\n            key={provider}\n            type=\"button\"\n            variant=\"outline\"\n            size=\"lg\"\n            disabled={pending}\n            onClick={() => onSelect(provider)}\n          >\n            <Icon data-icon=\"inline-start\" />\n            {label}\n          </Button>\n        )\n      })}\n    </div>\n  )\n}\n\nexport { SocialButtons }\nexport type { SocialProvider }\n",
      "type": "registry:component",
      "target": "@components/auth-01/social-buttons.tsx"
    },
    {
      "path": "src/registry/blocks/auth-01/use-auth-form.ts",
      "content": "\"use client\"\n\nimport { useCallback, useState, type FormEvent } from \"react\"\nimport type { z } from \"zod\"\n\nimport { DEFAULT_LABELS } from \"./config\"\n\ntype FieldErrors = Record<string, string>\n// 字面量初始值（false、\"\"）会被推断成字面量类型，这里放宽为 boolean / string\ntype Widen<T> = {\n  [K in keyof T]: T[K] extends boolean ? boolean : T[K] extends string ? string : T[K]\n}\n\n/** 每个字段只保留第一条错误，避免一次堆出一长串提示 */\nfunction toErrors(error: z.ZodError): FieldErrors {\n  const errors: FieldErrors = {}\n  for (const issue of error.issues) {\n    const key = String(issue.path[0] ?? \"\")\n    if (key && !(key in errors)) errors[key] = issue.message\n  }\n  return errors\n}\n\n/** 把未知错误转成可展示的中文文案；没有 message 时用传入的兜底文案。 */\nfunction errorMessage(\n  error: unknown,\n  fallback: string = DEFAULT_LABELS.requestFailed,\n) {\n  return error instanceof Error && error.message ? error.message : fallback\n}\n\n/** 包装一个异步动作：管理 loading，并把抛出的错误转成可展示的中文文案。 */\nfunction useAsyncAction(fallbackError: string = DEFAULT_LABELS.requestFailed) {\n  const [pending, setPending] = useState(false)\n  const [error, setError] = useState<string | null>(null)\n  const run = useCallback(\n    async (action: () => Promise<void>) => {\n      setPending(true)\n      setError(null)\n      try {\n        await action()\n        return true\n      } catch (caught) {\n        setError(errorMessage(caught, fallbackError))\n        return false\n      } finally {\n        setPending(false)\n      }\n    },\n    [fallbackError],\n  )\n  return { pending, error, run, clearError: () => setError(null) }\n}\n\n/**\n * 极简受控表单：zod 校验 + 字段错误 + 提交状态。\n * 首次提交前，字段失焦时校验该字段；提交失败后，输入时实时重新校验。\n */\nfunction useAuthForm<I extends Record<string, string | boolean>>(\n  schema: z.ZodType,\n  initial: I,\n  options: { fallbackError?: string } = {},\n) {\n  type V = Widen<I>\n  const [values, setValues] = useState<V>(initial as V)\n  const [errors, setErrors] = useState<FieldErrors>({})\n  const [submitted, setSubmitted] = useState(false)\n  const action = useAsyncAction(options.fallbackError)\n\n  const check = useCallback(\n    (next: V) => {\n      const result = schema.safeParse(next)\n      return result.success ? {} : toErrors(result.error)\n    },\n    [schema],\n  )\n\n  const setValue = <K extends keyof V & string>(key: K, value: V[K]) => {\n    const next = { ...values, [key]: value }\n    setValues(next)\n    if (submitted) setErrors(check(next))\n    else if (errors[key]) setErrors((prev) => ({ ...prev, [key]: \"\" }))\n  }\n  const blur = (key: keyof V & string) => {\n    if (values[key] === \"\" && !submitted) return\n    const found = check(values)[key] ?? \"\"\n    setErrors((prev) => ({ ...prev, [key]: found }))\n  }\n  const handleSubmit =\n    (onValid: (values: V) => Promise<void>) =>\n    async (event: FormEvent<HTMLFormElement>) => {\n      event.preventDefault()\n      setSubmitted(true)\n      const found = check(values)\n      setErrors(found)\n      if (Object.keys(found).length) return\n      await action.run(() => onValid(values))\n    }\n\n  return {\n    values,\n    errors,\n    setValue,\n    blur,\n    handleSubmit,\n    pending: action.pending,\n    formError: action.error,\n    run: action.run,\n    /** 校验单个字段并返回是否通过（用于「发送验证码」前校验手机号） */\n    validateField: (key: keyof V & string) => {\n      const found = check(values)[key] ?? \"\"\n      setSubmitted(true)\n      setErrors((prev) => ({ ...prev, [key]: found }))\n      return !found\n    },\n  }\n}\n\nexport { errorMessage, useAsyncAction, useAuthForm }\nexport type { FieldErrors }\n",
      "type": "registry:component",
      "target": "@components/auth-01/use-auth-form.ts"
    }
  ],
  "cssVars": {
    "theme": {
      "color-edge": "var(--edge)"
    },
    "light": {
      "edge": "color-mix(in oklch, var(--foreground) 12%, transparent)"
    },
    "dark": {
      "edge": "color-mix(in oklch, var(--foreground) 18%, transparent)"
    }
  },
  "meta": {
    "iframeHeight": "800px"
  },
  "type": "registry:block"
}
