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

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

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

این بلاک از ۱۲ آیتم دیگ استفاده می‌کند: alertbuttoncheckboxcontrol-sizeiconslabellinkpassword-fieldpersianseparatorsocial-auth-buttonstext-field

پکیج‌منیجر پیش‌فرض Node.jsنصب سریع با لینک سخت و دیسک مشترکYarn نسخهٔ ۲ به بالا (Berry)رانتایم و پکیج‌منیجر Bun
npx digdesign@latest add https://docs.digdesign.ir/r/alert.json https://docs.digdesign.ir/r/button.json https://docs.digdesign.ir/r/checkbox.json https://docs.digdesign.ir/r/control-size.json https://docs.digdesign.ir/r/icons.json https://docs.digdesign.ir/r/label.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/separator.json https://docs.digdesign.ir/r/social-auth-buttons.json https://docs.digdesign.ir/r/text-field.json
pnpm dlx digdesign@latest add https://docs.digdesign.ir/r/alert.json https://docs.digdesign.ir/r/button.json https://docs.digdesign.ir/r/checkbox.json https://docs.digdesign.ir/r/control-size.json https://docs.digdesign.ir/r/icons.json https://docs.digdesign.ir/r/label.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/separator.json https://docs.digdesign.ir/r/social-auth-buttons.json https://docs.digdesign.ir/r/text-field.json
yarn dlx digdesign@latest add https://docs.digdesign.ir/r/alert.json https://docs.digdesign.ir/r/button.json https://docs.digdesign.ir/r/checkbox.json https://docs.digdesign.ir/r/control-size.json https://docs.digdesign.ir/r/icons.json https://docs.digdesign.ir/r/label.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/separator.json https://docs.digdesign.ir/r/social-auth-buttons.json https://docs.digdesign.ir/r/text-field.json
bunx --bun digdesign@latest add https://docs.digdesign.ir/r/alert.json https://docs.digdesign.ir/r/button.json https://docs.digdesign.ir/r/checkbox.json https://docs.digdesign.ir/r/control-size.json https://docs.digdesign.ir/r/icons.json https://docs.digdesign.ir/r/label.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/separator.json https://docs.digdesign.ir/r/social-auth-buttons.json https://docs.digdesign.ir/r/text-field.json
پکیج‌منیجر پیش‌فرض Node.jsنصب سریع با لینک سخت و دیسک مشترکYarn نسخهٔ ۲ به بالا (Berry)رانتایم و پکیج‌منیجر Bun
npx digdesign@latest add alert button checkbox control-size label link password-field persian separator social-auth-buttons text-field --framework vue
pnpm dlx digdesign@latest add alert button checkbox control-size label link password-field persian separator social-auth-buttons text-field --framework vue
yarn dlx digdesign@latest add alert button checkbox control-size label link password-field persian separator social-auth-buttons text-field --framework vue
bunx --bun digdesign@latest add alert button checkbox control-size label link password-field persian separator social-auth-buttons 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 alert button checkbox control-size icons input label link password-field persian separator social-auth-buttons text-field --framework angular
pnpm dlx digdesign@latest add alert button checkbox control-size icons input label link password-field persian separator social-auth-buttons text-field --framework angular
yarn dlx digdesign@latest add alert button checkbox control-size icons input label link password-field persian separator social-auth-buttons text-field --framework angular
bunx --bun digdesign@latest add alert button checkbox control-size icons input label link password-field persian separator social-auth-buttons text-field --framework angular
پکیج‌منیجر پیش‌فرض Node.jsنصب سریع با لینک سخت و دیسک مشترکYarn نسخهٔ ۲ به بالا (Berry)رانتایم و پکیج‌منیجر Bun
npx digdesign@latest add alert button checkbox control-size label link password-field persian separator social-auth-buttons text-field --framework android
pnpm dlx digdesign@latest add alert button checkbox control-size label link password-field persian separator social-auth-buttons text-field --framework android
yarn dlx digdesign@latest add alert button checkbox control-size label link password-field persian separator social-auth-buttons text-field --framework android
bunx --bun digdesign@latest add alert button checkbox control-size label link password-field persian separator social-auth-buttons text-field --framework android

۲. کد صفحه

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

login-simple.tsx
"use client"

import * as React from "react"

import { SparklesIcon } from "@/components/icons"
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"
import { Button } from "@/components/ui/button"
import { Checkbox } from "@/components/ui/checkbox"
import { ControlSizeProvider } from "@/components/ui/control-size"
import { Label } from "@/components/ui/label"
import { Link } from "@/components/ui/link"
import { PasswordField } from "@/components/ui/password-field"
import { Separator } from "@/components/ui/separator"
import { SocialAuthButtons } from "@/components/ui/social-auth-buttons"
import { TextField } from "@/components/ui/text-field"
import { isValidEmail, isValidMobile } from "@/lib/persian"

/** نشانِ برند بالای فرم. */
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 LoginSimpleBlock() {
  const [error, setError] = React.useState(false)
  const [signing, setSigning] = React.useState(false)

  async function onSubmit(event: React.FormEvent<HTMLFormElement>) {
    event.preventDefault()
    setSigning(true)
    setError(false)
    // جای درخواستِ واقعی ورود؛ این نمونه همیشه «اطلاعات نادرست» برمی‌گرداند.
    await new Promise((resolve) => setTimeout(resolve, 800))
    setSigning(false)
    setError(true)
  }

  return (
    <main className="flex min-h-svh flex-col items-center bg-background p-4">
      <div className="flex w-full flex-1 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">
          <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">ورود به حساب</h1>
              <p className="text-sm text-muted-foreground">با ایمیل یا شمارهٔ موبایل وارد شوید.</p>
            </div>
          </header>

          <div className="flex flex-col gap-4">
            <Button variant="outline" fullWidth>
              ورود با رمزِ یک‌بارمصرف
            </Button>
            <div className="flex items-center gap-3 text-xs text-muted-foreground">
              <Separator className="flex-1" />
              یا با رمز عبور
              <Separator className="flex-1" />
            </div>
          </div>

          <form onSubmit={onSubmit} className="flex flex-col gap-4">
            {error && (
              <Alert color="destructive">
                <AlertTitle>ورود ناموفق بود</AlertTitle>
                <AlertDescription>ایمیل، شماره یا رمز عبور درست نیست.</AlertDescription>
              </Alert>
            )}
            <TextField
              label="ایمیل یا شمارهٔ موبایل"
              name="identifier"
              dir="ltr"
              autoComplete="username"
              required
              validate={(value) => (isValidEmail(value) || isValidMobile(value) ? undefined : "یک ایمیل یا شماره موبایلِ معتبر وارد کنید.")}
              disabled={signing}
            />
            <PasswordField label="رمز عبور" name="password" autoComplete="current-password" required disabled={signing} />
            <div className="flex items-center justify-between gap-2">
              <div className="flex items-center gap-2">
                <Checkbox id="remember" name="remember" />
                <Label htmlFor="remember">مرا به خاطر بسپار</Label>
              </div>
              <Link href="/forgot-password" size="sm">
                فراموشی رمز
              </Link>
            </div>
            <Button type="submit" fullWidth loading={signing} className="mt-4">
              ورود
            </Button>
          </form>

          <SocialAuthButtons />

          <p className="text-center text-sm text-muted-foreground">
            حساب ندارید؟ <Link href="/signup">ثبت‌نام کنید</Link>
          </p>
        </ControlSizeProvider>
        <p className="pt-10 text-xs text-muted-foreground">
          <Link href="#" size="sm">
            قوانین
          </Link>{" "}
          و{" "}
          <Link href="#" size="sm">
            حریم خصوصی
          </Link>
        </p>
      </div>
    </main>
  )
}
login-simple.vue
<script setup lang="ts">
import { ref } from "vue"

import Alert from "@/components/ui/Alert.vue"
import AlertDescription from "@/components/ui/AlertDescription.vue"
import AlertTitle from "@/components/ui/AlertTitle.vue"
import Button from "@/components/ui/Button.vue"
import Checkbox from "@/components/ui/Checkbox.vue"
import ControlSize from "@/components/ui/ControlSize.vue"
import Label from "@/components/ui/Label.vue"
import Link from "@/components/ui/Link.vue"
import PasswordField from "@/components/ui/PasswordField.vue"
import Separator from "@/components/ui/Separator.vue"
import SocialAuthButtons from "@/components/ui/SocialAuthButtons.vue"
import TextField from "@/components/ui/TextField.vue"
import { DigIcon } from "@/lib/icons"
import { isValidEmail, isValidMobile } from "@/lib/persian"

/**
 * مدلِ ساده: فرمِ ورود وسطِ صفحه، بدونِ پنلِ کناری؛ برای اپ‌هایی که برند را در خودِ فرم نشان می‌دهند.
 * همان صفحهٔ `login-simple` نسخهٔ React.
 */
const error = ref(false)
const signing = ref(false)

async function onSubmit() {
  signing.value = true
  error.value = false
  // جای درخواستِ واقعیِ ورود؛ این نمونه همیشه «اطلاعات نادرست» برمی‌گرداند.
  await new Promise((resolve) => setTimeout(resolve, 800))
  signing.value = false
  error.value = true
}

function validateIdentifier(value: string) {
  return isValidEmail(value) || isValidMobile(value) ? undefined : "یک ایمیل یا شماره موبایلِ معتبر وارد کنید."
}
</script>

<template>
  <main class="flex min-h-svh flex-col items-center bg-background p-4">
    <div class="flex w-full flex-1 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">
        <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">ورود به حساب</h1>
            <p class="text-sm text-muted-foreground">با ایمیل یا شمارهٔ موبایل وارد شوید.</p>
          </div>
        </header>

        <div class="flex flex-col gap-4">
          <Button variant="outline" full-width>ورود با رمزِ یک‌بارمصرف</Button>
          <div class="flex items-center gap-3 text-xs text-muted-foreground">
            <Separator class="flex-1" />
            یا با رمز عبور
            <Separator class="flex-1" />
          </div>
        </div>

        <form class="flex flex-col gap-4" @submit.prevent="onSubmit">
          <Alert v-if="error" color="destructive">
            <AlertTitle>ورود ناموفق بود</AlertTitle>
            <AlertDescription>ایمیل، شماره یا رمز عبور درست نیست.</AlertDescription>
          </Alert>
          <TextField
            label="ایمیل یا شمارهٔ موبایل"
            name="identifier"
            dir="ltr"
            autocomplete="username"
            required
            :validate="validateIdentifier"
            :disabled="signing"
          />
          <PasswordField label="رمز عبور" name="password" autocomplete="current-password" required :disabled="signing" />
          <div class="flex items-center justify-between gap-2">
            <div class="flex items-center gap-2">
              <Checkbox id="remember" name="remember" />
              <Label for="remember">مرا به خاطر بسپار</Label>
            </div>
            <Link href="/forgot-password" size="sm">فراموشی رمز</Link>
          </div>
          <Button type="submit" full-width :loading="signing" class="mt-4">ورود</Button>
        </form>

        <SocialAuthButtons />

        <p class="text-center text-sm text-muted-foreground">
          حساب ندارید؟ <Link href="/signup">ثبت‌نام کنید</Link>
        </p>
      </ControlSize>
      <p class="pt-10 text-xs text-muted-foreground">
        <Link href="#" size="sm">قوانین</Link>
        و
        <Link href="#" size="sm">حریم خصوصی</Link>
      </p>
    </div>
  </main>
</template>

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

این موارد هنوز برای Svelte آماده نیستند: alertcheckboxcontrol-sizelabellinkpassword-fieldpersianseparatorsocial-auth-buttonstext-fieldآیکون sparkles

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

login-simple.ts
import {
  ChangeDetectionStrategy,
  ChangeDetectorRef,
  Component,
  inject,
} from "@angular/core"

import {
  DigAlert,
  DigAlertDescription,
  DigAlertTitle,
} from "@/components/ui/alert"
import { DigButton } from "@/components/ui/button"
import { DigCheckbox } from "@/components/ui/checkbox"
import { DigControlSize } from "@/components/ui/control-size"
import { DigIcon } from "@/lib/icons"
import { DigInput, DigInputField } from "@/components/ui/input"
import { DigLabel } from "@/components/ui/label"
import { DigLink } from "@/components/ui/link"
import { DigPasswordField } from "@/components/ui/password-field"
import { DigSeparator } from "@/components/ui/separator"
import { DigSocialAuthButtons } from "@/components/ui/social-auth-buttons"
import { DigTextField } from "@/components/ui/text-field"
import { isValidEmail, isValidMobile } from "@/lib/persian"

let nextFieldId = 0

@Component({
  selector: "dig-block-login-simple",
  changeDetection: ChangeDetectionStrategy.OnPush,
  imports: [
    DigAlert,
    DigAlertDescription,
    DigAlertTitle,
    DigButton,
    DigCheckbox,
    DigControlSize,
    DigIcon,
    DigInput,
    DigInputField,
    DigLabel,
    DigLink,
    DigPasswordField,
    DigSeparator,
    DigSocialAuthButtons,
    DigTextField,
  ],
  template: `
    <main class="flex min-h-svh flex-col items-center bg-background p-4">
      <div class="flex w-full flex-1 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"
        >
          <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">ورود به حساب</h1>
              <p class="text-sm text-muted-foreground">
                با ایمیل یا شمارهٔ موبایل وارد شوید.
              </p>
            </div>
          </header>

          <div class="flex flex-col gap-4">
            <button digButton type="button" variant="outline" fullWidth>
              ورود با رمزِ یک‌بارمصرف
            </button>
            <div class="flex items-center gap-3 text-xs text-muted-foreground">
              <div digSeparator class="flex-1"></div>
              یا با رمز عبور
              <div digSeparator class="flex-1"></div>
            </div>
          </div>

          <form
            class="flex flex-col gap-4"
            (submit)="$event.preventDefault(); onSubmit()"
          >
            @if (error) {
              <div digAlert color="destructive">
                <h2 digAlertTitle>ورود ناموفق بود</h2>
                <div digAlertDescription>
                  ایمیل، شماره یا رمز عبور درست نیست.
                </div>
              </div>
            }
            <div
              digTextField
              label="ایمیل یا شمارهٔ موبایل"
              required
              [validate]="validateIdentifier"
              [disabled]="signing"
            >
              <dig-input>
                <input
                  digInput
                  name="identifier"
                  [value]="identifier"
                  (valueChange)="identifier = $event"
                  dir="ltr"
                  autocomplete="username"
                />
              </dig-input>
            </div>
            <div
              digPasswordField
              label="رمز عبور"
              name="password"
              autocomplete="current-password"
              required
              [disabled]="signing"
            ></div>
            <div class="flex items-center justify-between gap-2">
              <div class="flex items-center gap-2">
                <button digCheckbox type="button" [attr.id]="fieldId"></button>
                <label digLabel [attr.for]="fieldId">مرا به خاطر بسپار</label>
              </div>
              <a digLink href="/forgot-password" size="sm">فراموشی رمز</a>
            </div>
            <button
              digButton
              type="submit"
              fullWidth
              [loading]="signing"
              class="mt-4"
            >
              ورود
            </button>
          </form>

          <dig-social-auth-buttons></dig-social-auth-buttons>

          <p class="text-center text-sm text-muted-foreground">
            حساب ندارید؟ <a digLink href="/signup">ثبت‌نام کنید</a>
          </p>
        </div>
        <p class="pt-10 text-xs text-muted-foreground">
          <a digLink href="#" size="sm">قوانین</a>
          و
          <a digLink href="#" size="sm">حریم خصوصی</a>
        </p>
      </div>
    </main>
  `,
})
export class LoginSimpleBlock {
  private readonly changeDetector = inject(ChangeDetectorRef)
  readonly fieldId = `login-simple-${++nextFieldId}`

  /**
   * مدلِ ساده: فرمِ ورود وسطِ صفحه، بدونِ پنلِ کناری؛ برای اپ‌هایی که برند را در خودِ فرم نشان می‌دهند.
   * همان صفحهٔ `login-simple` نسخهٔ React.
   */
  error = false
  signing = false
  identifier = ""

  async onSubmit() {
    if (this.signing || this.validateIdentifier(this.identifier)) return
    this.signing = true
    this.error = false
    // جای درخواستِ واقعیِ ورود؛ این نمونه همیشه «اطلاعات نادرست» برمی‌گرداند.
    await new Promise((resolve) => setTimeout(resolve, 800))
    this.signing = false
    this.error = true
    this.changeDetector.markForCheck()
  }

  validateIdentifier(value: string) {
    return isValidEmail(value) || isValidMobile(value)
      ? undefined
      : "یک ایمیل یا شماره موبایلِ معتبر وارد کنید."
  }
}
LoginSimpleScreen.kt
package ir.digdesign.compose.demo.blocks

// sync: src/blocks/login-simple.tsx

import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.imePadding
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.safeDrawingPadding
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.widthIn
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.text.BasicText
import androidx.compose.foundation.verticalScroll
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import ir.digdesign.compose.Alert
import ir.digdesign.compose.AlertColor
import ir.digdesign.compose.Button
import ir.digdesign.compose.ButtonVariant
import ir.digdesign.compose.Checkbox
import ir.digdesign.compose.ControlSize
import ir.digdesign.compose.ControlSizeProvider
import ir.digdesign.compose.DigIcon
import ir.digdesign.compose.DigIcons
import ir.digdesign.compose.DigRadius
import ir.digdesign.compose.DigSpacing
import ir.digdesign.compose.DigText
import ir.digdesign.compose.DigTheme
import ir.digdesign.compose.Link
import ir.digdesign.compose.LinkSize
import ir.digdesign.compose.PasswordField
import ir.digdesign.compose.Separator
import ir.digdesign.compose.SocialAuthButtons
import ir.digdesign.compose.SocialAuthMode
import ir.digdesign.compose.TextField
import ir.digdesign.compose.TypographyH3
import ir.digdesign.compose.isValidEmail
import ir.digdesign.compose.isValidMobile
import kotlinx.coroutines.delay

/** صفحهٔ ورود با ایمیل یا موبایل و رمز عبور، با ورود با رمزِ یک‌بارمصرف و ورود اجتماعی. */
@Composable
fun LoginSimpleScreen(onNavigate: (String) -> Unit = {}) {
    var identifier by remember { mutableStateOf("") }
    var password by remember { mutableStateOf("") }
    var rememberMe by remember { mutableStateOf(false) }
    var signing by remember { mutableStateOf(false) }
    var error by remember { mutableStateOf(false) }

    // جای درخواستِ واقعی ورود؛ این نمونه همیشه «اطلاعات نادرست» برمی‌گرداند.
    LaunchedEffect(signing) {
        if (signing) {
            delay(800)
            signing = false
            error = true
        }
    }

    Box(
        Modifier.fillMaxSize().background(DigTheme.colors.background).safeDrawingPadding(),
        contentAlignment = Alignment.TopCenter,
    ) {
        ControlSizeProvider(ControlSize.Xl) {
            Column(
                Modifier
                    .widthIn(max = 480.dp)
                    .fillMaxWidth()
                    .verticalScroll(rememberScrollState())
                    .imePadding()
                    .padding(horizontal = DigSpacing * 6, vertical = DigSpacing * 10),
                verticalArrangement = Arrangement.spacedBy(DigSpacing * 8),
                horizontalAlignment = Alignment.CenterHorizontally,
            ) {
                BrandMark()
                Column(verticalArrangement = Arrangement.spacedBy(DigSpacing * 2), horizontalAlignment = Alignment.CenterHorizontally) {
                    TypographyH3("ورود به حساب")
                    Txt("با ایمیل یا شمارهٔ موبایل وارد شوید.")
                }

                Column(Modifier.fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(DigSpacing * 4)) {
                    Button("ورود با رمزِ یک‌بارمصرف", onClick = { onNavigate("login-otp") }, variant = ButtonVariant.Outline, fullWidth = true)
                    Row(horizontalArrangement = Arrangement.spacedBy(DigSpacing * 3), verticalAlignment = Alignment.CenterVertically) {
                        Separator(Modifier.weight(1f))
                        Txt("یا با رمز عبور", size = DigText.xs)
                        Separator(Modifier.weight(1f))
                    }
                }

                Column(Modifier.fillMaxWidth(), verticalArrangement = Arrangement.spacedBy(DigSpacing * 4)) {
                    if (error) {
                        Alert(title = "ورود ناموفق بود", description = "ایمیل، شماره یا رمز عبور درست نیست.", color = AlertColor.Destructive)
                    }
                    TextField(
                        value = identifier,
                        onValueChange = { identifier = it },
                        label = "ایمیل یا شمارهٔ موبایل",
                        required = true,
                        enabled = !signing,
                        validate = { if (isValidEmail(it) || isValidMobile(it)) null else "یک ایمیل یا شماره موبایلِ معتبر وارد کنید." },
                    )
                    PasswordField(value = password, onValueChange = { password = it }, label = "رمز عبور", required = true, enabled = !signing)
                    Row(Modifier.fillMaxWidth(), horizontalArrangement = Arrangement.SpaceBetween, verticalAlignment = Alignment.CenterVertically) {
                        Checkbox(checked = rememberMe, onCheckedChange = { rememberMe = it }, label = "مرا به خاطر بسپار")
                        Link("فراموشی رمز", onClick = { onNavigate("forgot-password-simple") }, size = LinkSize.Sm)
                    }
                    Button(
                        "ورود",
                        onClick = { error = false; signing = true },
                        fullWidth = true,
                        loading = signing,
                        modifier = Modifier.padding(top = DigSpacing * 2),
                    )
                }

                SocialAuthButtons(onProviderClick = {}, mode = SocialAuthMode.Login)

                Row(horizontalArrangement = Arrangement.spacedBy(DigSpacing), verticalAlignment = Alignment.CenterVertically) {
                    Txt("حساب ندارید؟")
                    Link("ثبت‌نام کنید", onClick = { onNavigate("signup-simple") })
                }
                Row(horizontalArrangement = Arrangement.spacedBy(DigSpacing), verticalAlignment = Alignment.CenterVertically) {
                    Link("قوانین", onClick = {}, size = LinkSize.Sm)
                    Txt("و", size = DigText.xs)
                    Link("حریم خصوصی", onClick = {}, size = LinkSize.Sm)
                }
            }
        }
    }
}

/** نشانِ برند بالای فرم. */
@Composable
private fun BrandMark() {
    Box(
        Modifier.size(48.dp).clip(RoundedCornerShape(DigRadius.xl)).background(DigTheme.colors.violet),
        contentAlignment = Alignment.Center,
    ) {
        DigIcon(DigIcons.BadgeStar, contentDescription = null, size = 24.dp, tint = DigTheme.colors.violetForeground)
    }
}

@Composable
private fun Txt(text: String, modifier: Modifier = Modifier, size: androidx.compose.ui.unit.TextUnit = DigText.sm) {
    BasicText(
        text,
        modifier,
        style = TextStyle(
            color = DigTheme.colors.mutedForeground,
            fontFamily = DigTheme.fontFamily,
            fontSize = size,
            lineHeight = size * DigText.lineHeightBase,
            textAlign = TextAlign.Center,
        ),
    )
}