بلاک‌ها · ورود و ثبت‌نام
ری‌اکت ۱۹ و Next.js با پیاده‌سازی دسترس‌پذیری داخلی دیگویو ۳ با Composition APISvelte ۵ با runesانگولار با signals و دایرکتیوهای standaloneجتپک کامپوز با KotliniOS — هنوز پورت نشده

فراموشی رمز (عکس)

پیش‌نمایش تمام‌صفحه

فراموشی رمز، مدلِ عکس: فرم در یک ستون و عکسِ واقعیِ تمام‌قد با جملهٔ برند در ستونِ دیگر. همان فرم، اعتبارسنجی و حالت‌های صفحهٔ اصلی.

۱. نصب کامپوننت‌ها

این بلاک از ۹ آیتم دیگ استفاده می‌کند: buttoncontrol-sizeiconsinput-otplinkpassword-fieldpersiansteppertext-field

پکیج‌منیجر پیش‌فرض Node.jsنصب سریع با لینک سخت و دیسک مشترکYarn نسخهٔ ۲ به بالا (Berry)رانتایم و پکیج‌منیجر Bun
npx digdesign@latest add https://docs.digdesign.ir/r/button.json https://docs.digdesign.ir/r/control-size.json https://docs.digdesign.ir/r/icons.json https://docs.digdesign.ir/r/input-otp.json https://docs.digdesign.ir/r/link.json https://docs.digdesign.ir/r/password-field.json https://docs.digdesign.ir/r/persian.json https://docs.digdesign.ir/r/stepper.json https://docs.digdesign.ir/r/text-field.json
pnpm dlx digdesign@latest add https://docs.digdesign.ir/r/button.json https://docs.digdesign.ir/r/control-size.json https://docs.digdesign.ir/r/icons.json https://docs.digdesign.ir/r/input-otp.json https://docs.digdesign.ir/r/link.json https://docs.digdesign.ir/r/password-field.json https://docs.digdesign.ir/r/persian.json https://docs.digdesign.ir/r/stepper.json https://docs.digdesign.ir/r/text-field.json
yarn dlx digdesign@latest add https://docs.digdesign.ir/r/button.json https://docs.digdesign.ir/r/control-size.json https://docs.digdesign.ir/r/icons.json https://docs.digdesign.ir/r/input-otp.json https://docs.digdesign.ir/r/link.json https://docs.digdesign.ir/r/password-field.json https://docs.digdesign.ir/r/persian.json https://docs.digdesign.ir/r/stepper.json https://docs.digdesign.ir/r/text-field.json
bunx --bun digdesign@latest add https://docs.digdesign.ir/r/button.json https://docs.digdesign.ir/r/control-size.json https://docs.digdesign.ir/r/icons.json https://docs.digdesign.ir/r/input-otp.json https://docs.digdesign.ir/r/link.json https://docs.digdesign.ir/r/password-field.json https://docs.digdesign.ir/r/persian.json https://docs.digdesign.ir/r/stepper.json https://docs.digdesign.ir/r/text-field.json
پکیج‌منیجر پیش‌فرض Node.jsنصب سریع با لینک سخت و دیسک مشترکYarn نسخهٔ ۲ به بالا (Berry)رانتایم و پکیج‌منیجر Bun
npx digdesign@latest add button control-size input-otp link password-field persian stepper text-field --framework vue
pnpm dlx digdesign@latest add button control-size input-otp link password-field persian stepper text-field --framework vue
yarn dlx digdesign@latest add button control-size input-otp link password-field persian stepper text-field --framework vue
bunx --bun digdesign@latest add button control-size input-otp link password-field persian stepper text-field --framework vue
پکیج‌منیجر پیش‌فرض Node.jsنصب سریع با لینک سخت و دیسک مشترکYarn نسخهٔ ۲ به بالا (Berry)رانتایم و پکیج‌منیجر Bun
npx digdesign@latest add button --framework svelte
pnpm dlx digdesign@latest add button --framework svelte
yarn dlx digdesign@latest add button --framework svelte
bunx --bun digdesign@latest add button --framework svelte
پکیج‌منیجر پیش‌فرض Node.jsنصب سریع با لینک سخت و دیسک مشترکYarn نسخهٔ ۲ به بالا (Berry)رانتایم و پکیج‌منیجر Bun
npx digdesign@latest add button control-size icons input input-otp link password-field persian stepper text-field --framework angular
pnpm dlx digdesign@latest add button control-size icons input input-otp link password-field persian stepper text-field --framework angular
yarn dlx digdesign@latest add button control-size icons input input-otp link password-field persian stepper text-field --framework angular
bunx --bun digdesign@latest add button control-size icons input input-otp link password-field persian stepper text-field --framework angular
پکیج‌منیجر پیش‌فرض Node.jsنصب سریع با لینک سخت و دیسک مشترکYarn نسخهٔ ۲ به بالا (Berry)رانتایم و پکیج‌منیجر Bun
npx digdesign@latest add button control-size input-otp link password-field persian stepper text-field --framework android
pnpm dlx digdesign@latest add button control-size input-otp link password-field persian stepper text-field --framework android
yarn dlx digdesign@latest add button control-size input-otp link password-field persian stepper text-field --framework android
bunx --bun digdesign@latest add button control-size input-otp link password-field persian stepper text-field --framework android

۲. کد صفحه

کد را در صفحهٔ پروژه‌تان بگذارید (React: app/<route>/page.tsx) و متن‌ها، داده و هندلرها را با محصول خودتان عوض کنید. با سوییچر فریم‌ورک کدِ همین صفحه در فریم‌ورک دیگر را ببینید.

forgot-password-image.tsx
"use client"

import * as React from "react"
import NextLink from "next/link"

import { CheckIcon, SparklesIcon } from "@/components/icons"
import { Button } from "@/components/ui/button"
import { ControlSizeProvider } from "@/components/ui/control-size"
import { InputOTP, InputOTPGroup, InputOTPSlot } from "@/components/ui/input-otp"
import { Link } from "@/components/ui/link"
import { PasswordField } from "@/components/ui/password-field"
import { Stepper, StepperItem, StepperTitle } from "@/components/ui/stepper"
import { TextField } from "@/components/ui/text-field"
import { isValidMobile, toFaDigits } from "@/lib/persian"
import { stockImages } from "@/lib/stock-images"

/** نشانِ برند بالای فرم. */
function BrandMark() {
  return (
    <span aria-hidden className="flex size-12 items-center justify-center rounded-xl bg-[var(--dig-violet-700)] text-[var(--dig-white)] [&>svg]:size-6">
      <SparklesIcon />
    </span>
  )
}

/**
 * بازیابی رمز با همان ساختارِ ورود و ثبت‌نام: فرم در ستونِ شروع، پنلِ برند در
 * ستونِ پایان. سه قدم (شماره ← کد ← رمزِ تازه) در همان ستون عوض می‌شوند.
 */
/** مدلِ عکس: فرم در یک ستون و عکسِ واقعی تمام‌قد با جملهٔ برند در ستونِ دیگر. */
export default function ForgotPasswordImageBlock() {
  const [step, setStep] = React.useState(0)
  const [mobile, setMobile] = React.useState("")
  const [password, setPassword] = React.useState("")
  const [confirm, setConfirm] = React.useState("")
  const [loading, setLoading] = React.useState(false)
  const mismatch = confirm.length > 0 && confirm !== password

  const next = async () => {
    setLoading(true)
    await new Promise((resolve) => setTimeout(resolve, 600))
    setLoading(false)
    setStep((value) => value + 1)
  }

  const titles = [
    { title: "فراموشی رمز", text: "شمارهٔ موبایلِ حساب را بنویسید تا کدِ بازیابی بفرستیم." },
    { title: "کد تأیید", text: "" },
    { title: "رمز تازه", text: "رمزی بسازید که جای دیگری استفاده نکرده‌اید." },
  ]

  return (
    <main className="grid grid-cols-1 min-h-svh gap-4 bg-background p-4 lg:grid-cols-2">
      <div className="flex flex-col items-center px-4 py-10">
        <ControlSizeProvider size="xl" className="flex w-full max-w-sm flex-1 flex-col justify-center gap-8">
          {step < 3 ? (
            <>
              <header className="flex flex-col items-center gap-4 text-center">
                <BrandMark />
                <div className="flex flex-col gap-2">
                  <h1 className="text-2xl font-bold">{titles[step].title}</h1>
                  <p className="text-sm leading-6 text-muted-foreground">
                    {step === 1 ? (
                      <>
                        کدِ ۶ رقمی به <bdi dir="ltr" className="font-medium text-foreground">{toFaDigits(mobile)}</bdi> پیامک شد.
                      </>
                    ) : (
                      titles[step].text
                    )}
                  </p>
                </div>
              </header>

              <Stepper value={step} className="w-full">
                <StepperItem>
                  <StepperTitle>شماره</StepperTitle>
                </StepperItem>
                <StepperItem>
                  <StepperTitle>کد تأیید</StepperTitle>
                </StepperItem>
                <StepperItem>
                  <StepperTitle>رمز تازه</StepperTitle>
                </StepperItem>
              </Stepper>

              {step === 0 && (
                <form
                  onSubmit={(event) => {
                    event.preventDefault()
                    if (isValidMobile(mobile)) void next()
                  }}
                  className="flex flex-col gap-4"
                >
                  <TextField
                    label="شماره موبایل"
                    type="tel"
                    dir="ltr"
                    maxLength={11}
                    autoComplete="tel"
                    placeholder="۰۹۱۲۳۴۵۶۷۸۹"
                    value={mobile}
                    onValueChange={setMobile}
                    required
                    validate={(value) => (isValidMobile(value) ? undefined : "شماره موبایل باید با ۰۹ شروع شود و ۱۱ رقم باشد.")}
                  />
                  <Button type="submit" fullWidth loading={loading} className="mt-4">
                    ارسال کد
                  </Button>
                </form>
              )}

              {step === 1 && (
                <div className="flex flex-col items-center gap-6">
                  <InputOTP aria-label="کد تأیید" onComplete={next} disabled={loading}>
                    <InputOTPGroup>
                      {[0, 1, 2, 3, 4, 5].map((index) => (
                        <InputOTPSlot key={index} index={index} />
                      ))}
                    </InputOTPGroup>
                  </InputOTP>
                  <p className="text-sm text-muted-foreground">
                    شماره اشتباه است؟{" "}
                    <Button variant="link" className="h-auto p-0" onClick={() => setStep(0)}>
                      تغییر شماره
                    </Button>
                  </p>
                </div>
              )}

              {step === 2 && (
                <form
                  onSubmit={(event) => {
                    event.preventDefault()
                    if (password && !mismatch) void next()
                  }}
                  className="flex flex-col gap-4"
                >
                  <PasswordField label="رمز تازه" autoComplete="new-password" value={password} onValueChange={setPassword} strength requirements requirementsWhen="weak" required />
                  <PasswordField
                    label="تکرار رمز تازه"
                    autoComplete="new-password"
                    value={confirm}
                    onValueChange={setConfirm}
                    invalid={mismatch}
                    errorMessage="با رمز بالا یکی نیست."
                    required
                  />
                  <Button type="submit" fullWidth loading={loading} disabled={!password || mismatch} className="mt-4">
                    ذخیرهٔ رمز
                  </Button>
                </form>
              )}

              <p className="text-center text-sm text-muted-foreground">
                رمز یادتان آمد؟ <Link href="/login">وارد شوید</Link>
              </p>
            </>
          ) : (
            <div className="flex flex-col items-center gap-4 text-center" role="status">
              <span aria-hidden className="flex size-12 items-center justify-center rounded-xl bg-success-subtle text-success-subtle-foreground [&_svg]:size-6">
                <CheckIcon />
              </span>
              <div className="flex flex-col gap-2">
                <h1 className="text-2xl font-bold">رمز عبور تغییر کرد</h1>
                <p className="text-sm text-muted-foreground">از این به بعد با رمز تازه وارد شوید.</p>
              </div>
              <Button asChild fullWidth className="mt-4">
                <NextLink href="/login">ورود به حساب</NextLink>
              </Button>
            </div>
          )}
        </ControlSizeProvider>
        <p className="text-xs text-muted-foreground">
          <Link href="#" size="sm">
            قوانین
          </Link>{" "}
          و{" "}
          <Link href="#" size="sm">
            حریم خصوصی
          </Link>
        </p>
      </div>
      <aside className="relative hidden overflow-hidden rounded-xl bg-muted lg:block">
        {/* eslint-disable-next-line @next/next/no-img-element -- عکس از کتابخانهٔ تصویرِ دیگ */}
        <img src={stockImages.coverNotebook.src} alt="" className="absolute inset-0 size-full object-cover" />
        <div className="absolute inset-x-0 bottom-0 flex flex-col gap-2 bg-linear-to-t from-[var(--dig-graphite-950)] to-transparent p-8 pt-24 text-[var(--dig-white)] sm:p-12 sm:pt-32">
          <p className="max-w-md text-2xl leading-relaxed font-bold sm:text-3xl sm:leading-relaxed">نگران نباش، پیش می‌آید.</p>
          <p className="text-sm text-[var(--dig-neutral-300)]">با چند قدمِ ساده دوباره به حسابت برمی‌گردی.</p>
        </div>
      </aside>
    </main>
  )
}
forgot-password-image.vue
<script setup lang="ts">
import { computed, ref } from "vue"

import Button from "@/components/ui/Button.vue"
import ControlSize from "@/components/ui/ControlSize.vue"
import InputOTP from "@/components/ui/InputOTP.vue"
import InputOTPGroup from "@/components/ui/InputOTPGroup.vue"
import InputOTPSlot from "@/components/ui/InputOTPSlot.vue"
import Link from "@/components/ui/Link.vue"
import PasswordField from "@/components/ui/PasswordField.vue"
import Stepper from "@/components/ui/Stepper.vue"
import StepperItem from "@/components/ui/StepperItem.vue"
import StepperTitle from "@/components/ui/StepperTitle.vue"
import TextField from "@/components/ui/TextField.vue"
import { DigIcon } from "@/lib/icons"
import { isValidMobile, toFaDigits } from "@/lib/persian"

/**
 * بازیابی رمز با همان ساختارِ ورود و ثبت‌نام: فرم در ستونِ شروع، پنلِ برند در
 * ستونِ پایان. سه قدم (شماره ← کد ← رمزِ تازه) در همان ستون عوض می‌شوند.
 * مدلِ عکس: فرم در یک ستون و عکسِ واقعی تمام‌قد با جملهٔ برند در ستونِ دیگر.
 */
const coverNotebookSrc = "https://docs.digdesign.ir/images/cover-notebook.webp"
const step = ref(0)
const mobile = ref("")
const password = ref("")
const confirm = ref("")
const loading = ref(false)
const mismatch = computed(() => confirm.value.length > 0 && confirm.value !== password.value)

async function next() {
  loading.value = true
  await new Promise((resolve) => setTimeout(resolve, 600))
  loading.value = false
  step.value += 1
}

const titles = [
  { title: "فراموشی رمز", text: "شمارهٔ موبایلِ حساب را بنویسید تا کدِ بازیابی بفرستیم." },
  { title: "کد تأیید", text: "" },
  { title: "رمز تازه", text: "رمزی بسازید که جای دیگری استفاده نکرده‌اید." },
]

function validateMobile(value: string) {
  return isValidMobile(value) ? undefined : "شماره موبایل باید با ۰۹ شروع شود و ۱۱ رقم باشد."
}

function onMobileSubmit() {
  if (isValidMobile(mobile.value)) void next()
}

function onPasswordSubmit() {
  if (password.value && !mismatch.value) void next()
}
</script>

<template>
  <main class="grid grid-cols-1 min-h-svh gap-4 bg-background p-4 lg:grid-cols-2">
    <div class="flex flex-col items-center px-4 py-10">
      <ControlSize size="xl" class="flex w-full max-w-sm flex-1 flex-col justify-center gap-8">
        <template v-if="step < 3">
          <header class="flex flex-col items-center gap-4 text-center">
            <span aria-hidden="true" class="flex size-12 items-center justify-center rounded-xl bg-[var(--dig-violet-700)] text-[var(--dig-white)] [&>svg]:size-6">
              <DigIcon name="sparkles" />
            </span>
            <div class="flex flex-col gap-2">
              <h1 class="text-2xl font-bold">{{ titles[step].title }}</h1>
              <p class="text-sm leading-6 text-muted-foreground">
                <template v-if="step === 1">
                  کدِ ۶ رقمی به <bdi dir="ltr" class="font-medium text-foreground">{{ toFaDigits(mobile) }}</bdi> پیامک شد.
                </template>
                <template v-else>{{ titles[step].text }}</template>
              </p>
            </div>
          </header>

          <Stepper :value="step" class="w-full">
            <StepperItem>
              <StepperTitle>شماره</StepperTitle>
            </StepperItem>
            <StepperItem>
              <StepperTitle>کد تأیید</StepperTitle>
            </StepperItem>
            <StepperItem>
              <StepperTitle>رمز تازه</StepperTitle>
            </StepperItem>
          </Stepper>

          <form v-if="step === 0" class="flex flex-col gap-4" @submit.prevent="onMobileSubmit">
            <TextField
              v-model="mobile"
              label="شماره موبایل"
              type="tel"
              dir="ltr"
              maxlength="11"
              autocomplete="tel"
              placeholder="۰۹۱۲۳۴۵۶۷۸۹"
              required
              :validate="validateMobile"
            />
            <Button type="submit" full-width :loading="loading" class="mt-4">ارسال کد</Button>
          </form>

          <div v-if="step === 1" class="flex flex-col items-center gap-6">
            <InputOTP aria-label="کد تأیید" :disabled="loading" @complete="next">
              <InputOTPGroup>
                <InputOTPSlot v-for="index in [0, 1, 2, 3, 4, 5]" :key="index" :index="index" />
              </InputOTPGroup>
            </InputOTP>
            <p class="text-sm text-muted-foreground">
              شماره اشتباه است؟
              <Button variant="link" class="h-auto p-0" @click="step = 0">تغییر شماره</Button>
            </p>
          </div>

          <form v-if="step === 2" class="flex flex-col gap-4" @submit.prevent="onPasswordSubmit">
            <PasswordField v-model="password" label="رمز تازه" autocomplete="new-password" strength requirements requirements-when="weak" required />
            <PasswordField
              v-model="confirm"
              label="تکرار رمز تازه"
              autocomplete="new-password"
              :invalid="mismatch"
              error-message="با رمز بالا یکی نیست."
              required
            />
            <Button type="submit" full-width :loading="loading" :disabled="!password || mismatch" class="mt-4">ذخیرهٔ رمز</Button>
          </form>

          <p class="text-center text-sm text-muted-foreground">
            رمز یادتان آمد؟ <Link href="/login">وارد شوید</Link>
          </p>
        </template>
        <div v-else class="flex flex-col items-center gap-4 text-center" role="status">
          <span aria-hidden="true" class="flex size-12 items-center justify-center rounded-xl bg-success-subtle text-success-subtle-foreground [&_svg]:size-6">
            <DigIcon name="check" />
          </span>
          <div class="flex flex-col gap-2">
            <h1 class="text-2xl font-bold">رمز عبور تغییر کرد</h1>
            <p class="text-sm text-muted-foreground">از این به بعد با رمز تازه وارد شوید.</p>
          </div>
          <Button as-child full-width class="mt-4">
            <a href="/login">ورود به حساب</a>
          </Button>
        </div>
      </ControlSize>
      <p class="text-xs text-muted-foreground">
        <Link href="#" size="sm">قوانین</Link>
        و
        <Link href="#" size="sm">حریم خصوصی</Link>
      </p>
    </div>
    <aside class="relative hidden overflow-hidden rounded-xl bg-muted lg:block">
      <img :src="coverNotebookSrc" alt="" class="absolute inset-0 size-full object-cover" />
      <div class="absolute inset-x-0 bottom-0 flex flex-col gap-2 bg-linear-to-t from-[var(--dig-graphite-950)] to-transparent p-8 pt-24 text-[var(--dig-white)] sm:p-12 sm:pt-32">
        <p class="max-w-md text-2xl leading-relaxed font-bold sm:text-3xl sm:leading-relaxed">نگران نباش، پیش می‌آید.</p>
        <p class="text-sm text-[var(--dig-neutral-300)]">با چند قدمِ ساده دوباره به حسابت برمی‌گردی.</p>
      </div>
    </aside>
  </main>
</template>

کدِ این بلاک هنوز برای Svelte نوشته نشده است.

این موارد هنوز برای Svelte آماده نیستند: control-sizeinput-otplinkpassword-fieldpersiansteppertext-fieldآیکون checkآیکون sparkles

کدِ React همین بلاک مرجع است. با MCP دیگ و get_block با framework="svelte" ایجنت آن را با کامپوننت‌های Svelte می‌سازد.

forgot-password-image.ts
import {
  ChangeDetectionStrategy,
  ChangeDetectorRef,
  Component,
  inject,
} from "@angular/core"

import { DigButton } from "@/components/ui/button"
import { DigControlSize } from "@/components/ui/control-size"
import { DigIcon } from "@/lib/icons"
import { DigInput, DigInputField } from "@/components/ui/input"
import {
  DigInputOtp,
  DigInputOtpGroup,
  DigInputOtpSlot,
} from "@/components/ui/input-otp"
import { DigLink } from "@/components/ui/link"
import { DigPasswordField } from "@/components/ui/password-field"
import {
  DigStepper,
  DigStepperItem,
  DigStepperTitle,
} from "@/components/ui/stepper"
import { DigTextField } from "@/components/ui/text-field"
import { isValidMobile, toFaDigits } from "@/lib/persian"

@Component({
  selector: "dig-block-forgot-password-image",
  changeDetection: ChangeDetectionStrategy.OnPush,
  imports: [
    DigButton,
    DigControlSize,
    DigIcon,
    DigInput,
    DigInputField,
    DigInputOtp,
    DigInputOtpGroup,
    DigInputOtpSlot,
    DigLink,
    DigPasswordField,
    DigStepper,
    DigStepperItem,
    DigStepperTitle,
    DigTextField,
  ],
  template: `
    <main
      class="grid grid-cols-1 min-h-svh gap-4 bg-background p-4 lg:grid-cols-2"
    >
      <div class="flex flex-col items-center px-4 py-10">
        <div
          digControlSize="xl"
          class="flex w-full max-w-sm flex-1 flex-col justify-center gap-8"
        >
          @if (step < 3) {
            <header class="flex flex-col items-center gap-4 text-center">
              <span
                aria-hidden="true"
                class="flex size-12 items-center justify-center rounded-xl bg-[var(--dig-violet-700)] text-[var(--dig-white)] [&>svg]:size-6"
              >
                <svg digIcon="sparkles"></svg>
              </span>
              <div class="flex flex-col gap-2">
                <h1 class="text-2xl font-bold">{{ titles[step].title }}</h1>
                <p class="text-sm leading-6 text-muted-foreground">
                  @if (step === 1) {
                    کدِ ۶ رقمی به
                    <bdi dir="ltr" class="font-medium text-foreground">{{
                      toFaDigits(mobile)
                    }}</bdi>
                    پیامک شد.
                  } @else {
                    {{ titles[step].text }}
                  }
                </p>
              </div>
            </header>

            <ol digStepper [value]="step" class="w-full">
              <li digStepperItem>
                <span digStepperTitle>شماره</span>
              </li>
              <li digStepperItem>
                <span digStepperTitle>کد تأیید</span>
              </li>
              <li digStepperItem>
                <span digStepperTitle>رمز تازه</span>
              </li>
            </ol>

            @if (step === 0) {
              <form
                class="flex flex-col gap-4"
                (submit)="$event.preventDefault(); onMobileSubmit()"
              >
                <div
                  digTextField
                  label="شماره موبایل"
                  required
                  [validate]="validateMobile"
                >
                  <dig-input>
                    <input
                      digInput
                      [value]="mobile"
                      (valueChange)="mobile = $event"
                      type="tel"
                      dir="ltr"
                      maxlength="11"
                      autocomplete="tel"
                      placeholder="۰۹۱۲۳۴۵۶۷۸۹"
                    />
                  </dig-input>
                </div>
                <button
                  digButton
                  type="submit"
                  fullWidth
                  [loading]="loading"
                  class="mt-4"
                >
                  ارسال کد
                </button>
              </form>
            }

            @if (step === 1) {
              <div class="flex flex-col items-center gap-6">
                <div
                  digInputOtp
                  aria-label="کد تأیید"
                  [disabled]="loading"
                  (complete)="next()"
                >
                  <div digInputOtpGroup>
                    @for (index of [0, 1, 2, 3, 4, 5]; track index) {
                      <input digInputOtpSlot [index]="index" />
                    }
                  </div>
                </div>
                <p class="text-sm text-muted-foreground">
                  شماره اشتباه است؟
                  <button
                    digButton
                    type="button"
                    variant="link"
                    class="h-auto p-0"
                    [disabled]="loading"
                    (click)="step = 0"
                  >
                    تغییر شماره
                  </button>
                </p>
              </div>
            }

            @if (step === 2) {
              <form
                class="flex flex-col gap-4"
                (submit)="$event.preventDefault(); onPasswordSubmit()"
              >
                <div
                  digPasswordField
                  [(value)]="password"
                  label="رمز تازه"
                  autocomplete="new-password"
                  strength
                  requirements
                  requirementsWhen="weak"
                  required
                ></div>
                <div
                  digPasswordField
                  [(value)]="confirm"
                  label="تکرار رمز تازه"
                  autocomplete="new-password"
                  [invalid]="mismatch"
                  errorMessage="با رمز بالا یکی نیست."
                  required
                ></div>
                <button
                  digButton
                  type="submit"
                  fullWidth
                  [loading]="loading"
                  [disabled]="!password || mismatch"
                  class="mt-4"
                >
                  ذخیرهٔ رمز
                </button>
              </form>
            }

            <p class="text-center text-sm text-muted-foreground">
              رمز یادتان آمد؟ <a digLink href="/login">وارد شوید</a>
            </p>
          } @else {
            <div
              class="flex flex-col items-center gap-4 text-center"
              role="status"
            >
              <span
                aria-hidden="true"
                class="flex size-12 items-center justify-center rounded-xl bg-success-subtle text-success-subtle-foreground [&_svg]:size-6"
              >
                <svg digIcon="check"></svg>
              </span>
              <div class="flex flex-col gap-2">
                <h1 class="text-2xl font-bold">رمز عبور تغییر کرد</h1>
                <p class="text-sm text-muted-foreground">
                  از این به بعد با رمز تازه وارد شوید.
                </p>
              </div>
              <a digButton fullWidth class="mt-4" href="/login">ورود به حساب</a>
            </div>
          }
        </div>
        <p class="text-xs text-muted-foreground">
          <a digLink href="#" size="sm">قوانین</a>
          و
          <a digLink href="#" size="sm">حریم خصوصی</a>
        </p>
      </div>
      <aside
        class="relative hidden overflow-hidden rounded-xl bg-muted lg:block"
      >
        <img
          [src]="coverNotebookSrc"
          alt=""
          class="absolute inset-0 size-full object-cover"
        />
        <div
          class="absolute inset-x-0 bottom-0 flex flex-col gap-2 bg-linear-to-t from-[var(--dig-graphite-950)] to-transparent p-8 pt-24 text-[var(--dig-white)] sm:p-12 sm:pt-32"
        >
          <p
            class="max-w-md text-2xl leading-relaxed font-bold sm:text-3xl sm:leading-relaxed"
          >
            نگران نباش، پیش می‌آید.
          </p>
          <p class="text-sm text-[var(--dig-neutral-300)]">
            با چند قدمِ ساده دوباره به حسابت برمی‌گردی.
          </p>
        </div>
      </aside>
    </main>
  `,
})
export class ForgotPasswordImageBlock {
  private readonly changeDetector = inject(ChangeDetectorRef)
  readonly toFaDigits = toFaDigits

  /**
   * بازیابی رمز با همان ساختارِ ورود و ثبت‌نام: فرم در ستونِ شروع، پنلِ برند در
   * ستونِ پایان. سه قدم (شماره ← کد ← رمزِ تازه) در همان ستون عوض می‌شوند.
   * مدلِ عکس: فرم در یک ستون و عکسِ واقعی تمام‌قد با جملهٔ برند در ستونِ دیگر.
   */
  readonly coverNotebookSrc =
    "https://docs.digdesign.ir/images/cover-notebook.webp"
  step = 0
  mobile = ""
  password = ""
  confirm = ""
  loading = false
  get mismatch() {
    return this.confirm.length > 0 && this.confirm !== this.password
  }

  async next() {
    if (this.loading) return
    this.loading = true
    await new Promise((resolve) => setTimeout(resolve, 600))
    this.loading = false
    this.step += 1
    this.changeDetector.markForCheck()
  }

  readonly titles = [
    {
      title: "فراموشی رمز",
      text: "شمارهٔ موبایلِ حساب را بنویسید تا کدِ بازیابی بفرستیم.",
    },
    { title: "کد تأیید", text: "" },
    { title: "رمز تازه", text: "رمزی بسازید که جای دیگری استفاده نکرده‌اید." },
  ]

  validateMobile(value: string) {
    return isValidMobile(value)
      ? undefined
      : "شماره موبایل باید با ۰۹ شروع شود و ۱۱ رقم باشد."
  }

  onMobileSubmit() {
    if (isValidMobile(this.mobile)) void this.next()
  }

  onPasswordSubmit() {
    if (this.password && this.password === this.confirm) void this.next()
  }
}

کدِ این بلاک هنوز برای Android نوشته نشده است.

همهٔ کامپوننت‌های لازم برای Android آماده‌اند؛ با MCP می‌توانید همین صفحه را از روی نسخهٔ React بسازید.

کدِ React همین بلاک مرجع است. با MCP دیگ و get_block با framework="android" ایجنت آن را با کامپوننت‌های Android می‌سازد.