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

فرمِ رزرو و درخواست

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

تماس با فرمِ رزرو: نام، ایمیل، موبایل، مسیر، تاریخِ شمسی، تعداد و توضیح با اعتبارسنجی؛ عکسِ مسیر کنارش و سه ستونِ راهِ تماس و ساعتِ کار.

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

این بلاک از ۹ آیتم دیگ استفاده می‌کند: buttoncontrol-sizedate-pickericonsnumber-fieldpersianselecttext-fieldtextarea

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

۲. کد صفحه

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

contact-booking.tsx
"use client"

import * as React from "react"

import { CalendarIcon, CheckCircleIcon, ClockIcon, EnvelopeIcon, PhoneIcon } from "@/components/icons"
import { Button } from "@/components/ui/button"
import { ControlSizeProvider } from "@/components/ui/control-size"
import { DatePicker } from "@/components/ui/date-picker"
import { NumberField } from "@/components/ui/number-field"
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
import { TextField } from "@/components/ui/text-field"
import { Textarea } from "@/components/ui/textarea"
import { toFaDigits } from "@/lib/persian"
import { stockImages } from "@/lib/stock-images"

const ROUTES = [
  { value: "kavir", label: "کویرِ مرنجاب، دو روز" },
  { value: "qeshm", label: "جزیرهٔ قشم، سه روز" },
  { value: "alamut", label: "درهٔ الموت، یک روز" },
  { value: "kaluts", label: "کلوت‌های شهداد، سه روز" },
]

/**
 * رزرو با فرمِ درخواست: برچسبِ «رزرو» و تیترِ درشت، فرمِ دوستونه (نام، ایمیل، تلفن، مسیر،
 * تاریخِ شمسی، تعدادِ نفرات، توضیح) روی سطحِ subtle و عکسِ مسیر کنارش؛ پیامِ ثبت در همان
 * کارت، و سه ستونِ راهِ تماس و ساعتِ کار پایین.
 */
export default function ContactBookingBlock() {
  const [route, setRoute] = React.useState("")
  const [errors, setErrors] = React.useState<Record<string, string>>({})
  const [sent, setSent] = React.useState(false)

  const submit = (event: React.FormEvent<HTMLFormElement>) => {
    event.preventDefault()
    const data = new FormData(event.currentTarget)
    const next: Record<string, string> = {}
    if (!String(data.get("name")).trim()) next.name = "نامِ کامل را بنویسید."
    if (!/^09\d{9}$/.test(String(data.get("phone")))) next.phone = "شمارهٔ موبایل ۱۱ رقم است و با ۰۹ شروع می‌شود."
    if (!route) next.route = "یک مسیر انتخاب کنید."
    setErrors(next)
    if (Object.keys(next).length === 0) setSent(true)
  }

  return (
    <ControlSizeProvider size="xl" asChild>
      <section aria-labelledby="cb-title" className="mx-auto flex w-full max-w-6xl flex-col gap-10 px-4 py-20 sm:px-6">
        <div className="flex flex-col items-start justify-between gap-6 md:flex-row md:items-end">
          <div className="flex flex-col items-start gap-3">
            <span className="rounded-full bg-muted px-3 py-1 text-sm font-semibold">رزرو</span>
            <h2 id="cb-title" className="text-3xl leading-snug font-black sm:text-4xl">
              مسیرت را رزرو کن
            </h2>
          </div>
          <p className="max-w-xs leading-7 text-muted-foreground">تاریخ و مسیرِ دلخواه را بگویید؛ همان روز ظرفیتِ خالی را خبر می‌دهیم.</p>
        </div>

        <div className="grid grid-cols-1 gap-4 lg:grid-cols-[1.6fr_1fr]">
          <div className="rounded-xl bg-subtle p-5 sm:p-6">
            {sent ? (
              <div role="status" className="flex min-h-96 flex-col items-center justify-center gap-3 text-center">
                <CheckCircleIcon aria-hidden className="size-12 text-success-subtle-foreground" />
                <p className="text-xl font-bold">درخواستتان ثبت شد</p>
                <p className="max-w-sm leading-7 text-muted-foreground">کارشناسِ سفر تا چند ساعتِ دیگر برای هماهنگیِ ظرفیت تماس می‌گیرد.</p>
                <Button variant="outline" onClick={() => setSent(false)}>
                  درخواستِ دیگر
                </Button>
              </div>
            ) : (
              <form noValidate onSubmit={submit} className="grid grid-cols-1 gap-4 sm:grid-cols-2">
                <TextField name="name" label="نامِ کامل" placeholder="نام و نام خانوادگی" invalid={!!errors.name} errorMessage={errors.name} />
                <TextField name="email" type="email" dir="ltr" label="ایمیل" placeholder="name@mail.com" optional />
                <TextField name="phone" type="tel" dir="ltr" label="موبایل" placeholder="۰۹۱۲ ۰۰۰ ۰۰۰۰" faDigits invalid={!!errors.phone} errorMessage={errors.phone} />
                <div className="flex flex-col gap-2">
                  <span id="cb-route" className="text-sm font-medium">
                    مسیر
                  </span>
                  <Select value={route} onValueChange={(value) => setRoute(value as string)}>
                    <SelectTrigger aria-labelledby="cb-route" aria-invalid={!!errors.route} className="w-full">
                      <SelectValue placeholder="انتخابِ مسیر" />
                    </SelectTrigger>
                    <SelectContent>
                      {ROUTES.map((item) => (
                        <SelectItem key={item.value} value={item.value}>
                          {item.label}
                        </SelectItem>
                      ))}
                    </SelectContent>
                  </Select>
                  {errors.route && <p className="text-sm text-destructive">{errors.route}</p>}
                </div>
                <DatePicker label="تاریخِ رفت" calendar="jalali" placeholder="انتخابِ روز" minDate={new Date()} className="w-full" />
                <div className="flex flex-col gap-2">
                  <span id="cb-people" className="text-sm font-medium">
                    چند نفر
                  </span>
                  <NumberField aria-labelledby="cb-people" defaultValue={2} min={1} max={12} className="w-full" />
                </div>
                <div className="flex flex-col gap-2 sm:col-span-2">
                  <label htmlFor="cb-notes" className="text-sm font-medium">
                    چیزی که باید بدانیم
                  </label>
                  <Textarea id="cb-notes" name="notes" rows={3} placeholder="رژیمِ غذایی، همراهِ کودک، سؤال درباره مسیر…" />
                </div>
                <div className="sm:col-span-2">
                  <Button type="submit">
                    <CalendarIcon />
                    بررسیِ ظرفیت
                  </Button>
                </div>
              </form>
            )}
          </div>
          <div className="relative min-h-72 overflow-hidden rounded-xl">
            {/* eslint-disable-next-line @next/next/no-img-element -- عکس از کتابخانهٔ تصویرِ دیگ */}
            <img src={stockImages.planeWindow.src} alt={stockImages.planeWindow.alt} className="absolute inset-0 size-full object-cover" />
            <span className="absolute end-4 top-4 rounded-full bg-card px-3 py-1.5 text-sm font-semibold shadow-sm">سفرِ شما</span>
          </div>
        </div>

        <ul className="grid grid-cols-1 gap-8 pt-4 text-center sm:grid-cols-3">
          {[
            { icon: <EnvelopeIcon />, title: "برایمان بنویسید", lines: ["hello@masir.travel"], ltr: true },
            { icon: <PhoneIcon />, title: "تماس یا پیامک", lines: [toFaDigits("0912 345 6789"), toFaDigits("021 4433 2211")], ltr: true },
            { icon: <ClockIcon />, title: "ساعتِ کار", lines: ["شنبه تا چهارشنبه، ۹ تا ۱۸", "پنجشنبه تا ۱۴"] },
          ].map((item) => (
            <li key={item.title} className="flex flex-col items-center gap-2">
              <span aria-hidden className="mb-1 flex size-10 items-center justify-center rounded-full bg-muted [&>svg]:size-5">
                {item.icon}
              </span>
              <span className="font-bold">{item.title}</span>
              {item.lines.map((line) =>
                item.ltr ? (
                  <bdi key={line} dir="ltr" className="text-sm text-muted-foreground">
                    {line}
                  </bdi>
                ) : (
                  <span key={line} className="text-sm text-muted-foreground">
                    {line}
                  </span>
                )
              )}
            </li>
          ))}
        </ul>
      </section>
    </ControlSizeProvider>
  )
}
contact-booking.vue
<script setup lang="ts">
import { reactive, ref } from "vue"

import Button from "@/components/ui/Button.vue"
import ControlSize from "@/components/ui/ControlSize.vue"
import DatePicker from "@/components/ui/DatePicker.vue"
import NumberField from "@/components/ui/NumberField.vue"
import Select from "@/components/ui/Select.vue"
import SelectContent from "@/components/ui/SelectContent.vue"
import SelectItem from "@/components/ui/SelectItem.vue"
import SelectTrigger from "@/components/ui/SelectTrigger.vue"
import SelectValue from "@/components/ui/SelectValue.vue"
import TextField from "@/components/ui/TextField.vue"
import Textarea from "@/components/ui/Textarea.vue"
import { DigIcon } from "@/lib/icons"
import { toFaDigits } from "@/lib/persian"

const planeWindow = { src: "https://docs.digdesign.ir/images/plane-window.webp", alt: "منظرهٔ ابرها و غروب از پنجرهٔ هواپیما" }

const ROUTES = [
  { value: "kavir", label: "کویرِ مرنجاب، دو روز" },
  { value: "qeshm", label: "جزیرهٔ قشم، سه روز" },
  { value: "alamut", label: "درهٔ الموت، یک روز" },
  { value: "kaluts", label: "کلوت‌های شهداد، سه روز" },
]

const CONTACTS = [
  { icon: "envelope", title: "برایمان بنویسید", lines: ["hello@masir.travel"], ltr: true },
  { icon: "phone", title: "تماس یا پیامک", lines: [toFaDigits("0912 345 6789"), toFaDigits("021 4433 2211")], ltr: true },
  { icon: "clock", title: "ساعتِ کار", lines: ["شنبه تا چهارشنبه، ۹ تا ۱۸", "پنجشنبه تا ۱۴"], ltr: false },
]

/**
 * رزرو با فرمِ درخواست: برچسبِ «رزرو» و تیترِ درشت، فرمِ دوستونه (نام، ایمیل، تلفن، مسیر،
 * تاریخِ شمسی، تعدادِ نفرات، توضیح) روی سطحِ subtle و عکسِ مسیر کنارش؛ پیامِ ثبت در همان
 * کارت، و سه ستونِ راهِ تماس و ساعتِ کار پایین.
 */
const route = ref("")
const errors = reactive<Record<string, string>>({})
const sent = ref(false)
const minDate = new Date()

function submit(event: Event) {
  const data = new FormData(event.currentTarget as HTMLFormElement)
  const next: Record<string, string> = {}
  if (!String(data.get("name")).trim()) next.name = "نامِ کامل را بنویسید."
  if (!/^09\d{9}$/.test(String(data.get("phone")))) next.phone = "شمارهٔ موبایل ۱۱ رقم است و با ۰۹ شروع می‌شود."
  if (!route.value) next.route = "یک مسیر انتخاب کنید."
  for (const key of Object.keys(errors)) delete errors[key]
  Object.assign(errors, next)
  if (Object.keys(next).length === 0) sent.value = true
}

function onRoute(value: string | string[]) {
  route.value = value as string
}
</script>

<template>
  <ControlSize size="xl" as-child>
    <section aria-labelledby="cb-title" class="mx-auto flex w-full max-w-6xl flex-col gap-10 px-4 py-20 sm:px-6">
      <div class="flex flex-col items-start justify-between gap-6 md:flex-row md:items-end">
        <div class="flex flex-col items-start gap-3">
          <span class="rounded-full bg-muted px-3 py-1 text-sm font-semibold">رزرو</span>
          <h2 id="cb-title" class="text-3xl leading-snug font-black sm:text-4xl">مسیرت را رزرو کن</h2>
        </div>
        <p class="max-w-xs leading-7 text-muted-foreground">تاریخ و مسیرِ دلخواه را بگویید؛ همان روز ظرفیتِ خالی را خبر می‌دهیم.</p>
      </div>
      <div class="grid grid-cols-1 gap-4 lg:grid-cols-[1.6fr_1fr]">
        <div class="rounded-xl bg-subtle p-5 sm:p-6">
          <div v-if="sent" role="status" class="flex min-h-96 flex-col items-center justify-center gap-3 text-center">
            <DigIcon name="check-circle" aria-hidden="true" class="size-12 text-success-subtle-foreground" />
            <p class="text-xl font-bold">درخواستتان ثبت شد</p>
            <p class="max-w-sm leading-7 text-muted-foreground">کارشناسِ سفر تا چند ساعتِ دیگر برای هماهنگیِ ظرفیت تماس می‌گیرد.</p>
            <Button variant="outline" @click="sent = false">درخواستِ دیگر</Button>
          </div>
          <form v-else novalidate class="grid grid-cols-1 gap-4 sm:grid-cols-2" @submit.prevent="submit">
            <TextField name="name" label="نامِ کامل" placeholder="نام و نام خانوادگی" :invalid="!!errors.name" :error-message="errors.name" />
            <TextField name="email" type="email" dir="ltr" label="ایمیل" placeholder="name@mail.com" optional />
            <TextField name="phone" type="tel" dir="ltr" label="موبایل" placeholder="۰۹۱۲ ۰۰۰ ۰۰۰۰" fa-digits :invalid="!!errors.phone" :error-message="errors.phone" />
            <div class="flex flex-col gap-2">
              <span id="cb-route" class="text-sm font-medium">مسیر</span>
              <Select :value="route" @update:value="onRoute">
                <SelectTrigger aria-labelledby="cb-route" :aria-invalid="!!errors.route" class="w-full">
                  <SelectValue placeholder="انتخابِ مسیر" />
                </SelectTrigger>
                <SelectContent>
                  <SelectItem v-for="item in ROUTES" :key="item.value" :value="item.value">{{ item.label }}</SelectItem>
                </SelectContent>
              </Select>
              <p v-if="errors.route" class="text-sm text-destructive">{{ errors.route }}</p>
            </div>
            <DatePicker label="تاریخِ رفت" calendar="jalali" placeholder="انتخابِ روز" :min-date="minDate" class="w-full" />
            <div class="flex flex-col gap-2">
              <span id="cb-people" class="text-sm font-medium">چند نفر</span>
              <NumberField aria-labelledby="cb-people" :default-value="2" :min="1" :max="12" class="w-full" />
            </div>
            <div class="flex flex-col gap-2 sm:col-span-2">
              <label for="cb-notes" class="text-sm font-medium">چیزی که باید بدانیم</label>
              <Textarea id="cb-notes" name="notes" :rows="3" placeholder="رژیمِ غذایی، همراهِ کودک، سؤال درباره مسیر…" />
            </div>
            <div class="sm:col-span-2">
              <Button type="submit">
                <DigIcon name="calendar" />
                بررسیِ ظرفیت
              </Button>
            </div>
          </form>
        </div>
        <div class="relative min-h-72 overflow-hidden rounded-xl">
          <img :src="planeWindow.src" :alt="planeWindow.alt" class="absolute inset-0 size-full object-cover" />
          <span class="absolute end-4 top-4 rounded-full bg-card px-3 py-1.5 text-sm font-semibold shadow-sm">سفرِ شما</span>
        </div>
      </div>
      <ul class="grid grid-cols-1 gap-8 pt-4 text-center sm:grid-cols-3">
        <li v-for="item in CONTACTS" :key="item.title" class="flex flex-col items-center gap-2">
          <span aria-hidden="true" class="mb-1 flex size-10 items-center justify-center rounded-full bg-muted [&>svg]:size-5">
            <DigIcon :name="item.icon" />
          </span>
          <span class="font-bold">{{ item.title }}</span>
          <template v-for="line in item.lines" :key="line">
            <bdi v-if="item.ltr" dir="ltr" class="text-sm text-muted-foreground">{{ line }}</bdi>
            <span v-else class="text-sm text-muted-foreground">{{ line }}</span>
          </template>
        </li>
      </ul>
    </section>
  </ControlSize>
</template>

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

این موارد هنوز برای Svelte آماده نیستند: control-sizedate-pickernumber-fieldpersianselecttext-fieldtextareaآیکون calendarآیکون check-circleآیکون clockآیکون envelopeآیکون phone

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

contact-booking.ts
import { ChangeDetectionStrategy, Component, signal } from "@angular/core"

import { DigIcon } from "@/lib/icons"
import { toEnDigits, toFaDigits } from "@/lib/persian"
import { DigButton } from "@/components/ui/button"
import { DigControlSize } from "@/components/ui/control-size"
import { DigDatePicker } from "@/components/ui/date-picker"
import { DigInput, DigInputField } from "@/components/ui/input"
import { DigNumberField } from "@/components/ui/number-field"
import {
  DigSelect,
  DigSelectContent,
  DigSelectItem,
  DigSelectTrigger,
  DigSelectValue,
} from "@/components/ui/select"
import { DigTextField } from "@/components/ui/text-field"
import { DigTextarea } from "@/components/ui/textarea"

const planeWindow = {
  src: "https://docs.digdesign.ir/images/plane-window.webp",
  alt: "منظرهٔ ابرها و غروب از پنجرهٔ هواپیما",
}

const ROUTES = [
  { value: "kavir", label: "کویرِ مرنجاب، دو روز" },
  { value: "qeshm", label: "جزیرهٔ قشم، سه روز" },
  { value: "alamut", label: "درهٔ الموت، یک روز" },
  { value: "kaluts", label: "کلوت‌های شهداد، سه روز" },
]

const CONTACTS = [
  {
    icon: "envelope",
    title: "برایمان بنویسید",
    lines: ["hello@masir.travel"],
    ltr: true,
  },
  {
    icon: "phone",
    title: "تماس یا پیامک",
    lines: [toFaDigits("0912 345 6789"), toFaDigits("021 4433 2211")],
    ltr: true,
  },
  {
    icon: "clock",
    title: "ساعتِ کار",
    lines: ["شنبه تا چهارشنبه، ۹ تا ۱۸", "پنجشنبه تا ۱۴"],
    ltr: false,
  },
] as const

@Component({
  selector: "dig-block-contact-booking",
  imports: [
    DigButton,
    DigControlSize,
    DigDatePicker,
    DigIcon,
    DigInput,
    DigInputField,
    DigNumberField,
    DigSelect,
    DigSelectContent,
    DigSelectItem,
    DigSelectTrigger,
    DigSelectValue,
    DigTextField,
    DigTextarea,
  ],
  changeDetection: ChangeDetectionStrategy.OnPush,
  template: `
    <section
      digControlSize="xl"
      aria-labelledby="cb-title"
      class="mx-auto flex w-full max-w-6xl flex-col gap-10 px-4 py-20 sm:px-6"
    >
      <div
        class="flex flex-col items-start justify-between gap-6 md:flex-row md:items-end"
      >
        <div class="flex flex-col items-start gap-3">
          <span class="rounded-full bg-muted px-3 py-1 text-sm font-semibold"
            >رزرو</span
          >
          <h2
            id="cb-title"
            class="text-3xl leading-snug font-black sm:text-4xl"
          >
            مسیرت را رزرو کن
          </h2>
        </div>
        <p class="max-w-xs leading-7 text-muted-foreground">
          تاریخ و مسیرِ دلخواه را بگویید؛ همان روز ظرفیتِ خالی را خبر می‌دهیم.
        </p>
      </div>
      <div class="grid grid-cols-1 gap-4 lg:grid-cols-[1.6fr_1fr]">
        <div class="rounded-xl bg-subtle p-5 sm:p-6">
          @if (sent()) {
            <div
              role="status"
              class="flex min-h-96 flex-col items-center justify-center gap-3 text-center"
            >
              <svg
                digIcon="check-circle"
                aria-hidden="true"
                class="size-12 text-success-subtle-foreground"
              ></svg>
              <p class="text-xl font-bold">درخواستتان ثبت شد</p>
              <p class="max-w-sm leading-7 text-muted-foreground">
                کارشناسِ سفر تا چند ساعتِ دیگر برای هماهنگیِ ظرفیت تماس می‌گیرد.
              </p>
              <button
                digButton
                type="button"
                variant="outline"
                (click)="reset()"
              >
                درخواستِ دیگر
              </button>
            </div>
          } @else {
            <form
              novalidate
              class="grid grid-cols-1 gap-4 sm:grid-cols-2"
              (submit)="$event.preventDefault(); submit($event)"
            >
              <div
                digTextField
                label="نامِ کامل"
                [invalid]="!!errors().name"
                [errorMessage]="errors().name"
              >
                <dig-input
                  ><input digInput name="name" placeholder="نام و نام خانوادگی"
                /></dig-input>
              </div>
              <div digTextField label="ایمیل" optional>
                <dig-input
                  ><input
                    digInput
                    name="email"
                    type="email"
                    dir="ltr"
                    placeholder="name@mail.com"
                /></dig-input>
              </div>
              <div
                digTextField
                label="موبایل"
                [invalid]="!!errors().phone"
                [errorMessage]="errors().phone"
              >
                <dig-input
                  ><input
                    digInput
                    name="phone"
                    type="tel"
                    dir="ltr"
                    placeholder="۰۹۱۲ ۰۰۰ ۰۰۰۰"
                    faDigits
                /></dig-input>
              </div>
              <div class="flex flex-col gap-2">
                <span id="cb-route" class="text-sm font-medium">مسیر</span>
                <ng-container
                  digSelect
                  [value]="route()"
                  (valueChange)="onRoute($event)"
                >
                  <button
                    digSelectTrigger
                    type="button"
                    aria-labelledby="cb-route"
                    [attr.aria-invalid]="!!errors().route"
                    class="w-full"
                  >
                    <span digSelectValue placeholder="انتخابِ مسیر"></span>
                  </button>
                  <div digSelectContent>
                    @for (item of ROUTES; track item.value) {
                      <div digSelectItem [value]="item.value">
                        {{ item.label }}
                      </div>
                    }
                  </div>
                </ng-container>
                @if (errors().route) {
                  <p class="text-sm text-destructive">{{ errors().route }}</p>
                }
              </div>
              <div
                digDatePicker
                label="تاریخِ رفت"
                calendar="jalali"
                placeholder="انتخابِ روز"
                [minDate]="minDate"
                class="w-full"
              ></div>
              <div class="flex flex-col gap-2">
                <span id="cb-people" class="text-sm font-medium">چند نفر</span>
                <div
                  digNumberField
                  aria-label="تعدادِ نفرات"
                  [value]="2"
                  [min]="1"
                  [max]="12"
                  class="w-full"
                ></div>
              </div>
              <div class="flex flex-col gap-2 sm:col-span-2">
                <label htmlFor="cb-notes" class="text-sm font-medium"
                  >چیزی که باید بدانیم</label
                >
                <textarea
                  digTextarea
                  id="cb-notes"
                  name="notes"
                  [rows]="3"
                  placeholder="رژیمِ غذایی، همراهِ کودک، سؤال درباره مسیر…"
                ></textarea>
              </div>
              <div class="sm:col-span-2">
                <button digButton type="submit">
                  <svg digIcon="calendar"></svg>
                  بررسیِ ظرفیت
                </button>
              </div>
            </form>
          }
        </div>
        <div class="relative min-h-72 overflow-hidden rounded-xl">
          <img
            [src]="planeWindow.src"
            [alt]="planeWindow.alt"
            class="absolute inset-0 size-full object-cover"
          />
          <span
            class="absolute end-4 top-4 rounded-full bg-card px-3 py-1.5 text-sm font-semibold shadow-sm"
            >سفرِ شما</span
          >
        </div>
      </div>
      <ul class="grid grid-cols-1 gap-8 pt-4 text-center sm:grid-cols-3">
        @for (item of CONTACTS; track item.title) {
          <li class="flex flex-col items-center gap-2">
            <span
              aria-hidden="true"
              class="mb-1 flex size-10 items-center justify-center rounded-full bg-muted [&>svg]:size-5"
            >
              <svg [digIcon]="item.icon"></svg>
            </span>
            <span class="font-bold">{{ item.title }}</span>
            @for (line of item.lines; track line) {
              @if (item.ltr) {
                <bdi dir="ltr" class="text-sm text-muted-foreground">{{
                  line
                }}</bdi>
              } @else {
                <span class="text-sm text-muted-foreground">{{ line }}</span>
              }
            }
          </li>
        }
      </ul>
    </section>
  `,
})
export class ContactBookingBlock {
  readonly planeWindow = planeWindow
  readonly ROUTES = ROUTES
  readonly CONTACTS = CONTACTS

  readonly route = signal<string | undefined>(undefined)
  readonly errors = signal<Partial<Record<"name" | "phone" | "route", string>>>(
    {}
  )
  readonly sent = signal(false)
  readonly minDate = new Date()

  submit(event: Event) {
    const data = new FormData(event.currentTarget as HTMLFormElement)
    const errors: Partial<Record<"name" | "phone" | "route", string>> = {}
    const phone = toEnDigits(String(data.get("phone") ?? "")).replace(
      /[\s-]/g,
      ""
    )
    if (!String(data.get("name") ?? "").trim())
      errors.name = "نامِ کامل را بنویسید."
    if (!/^09\d{9}$/.test(phone))
      errors.phone = "شمارهٔ موبایل ۱۱ رقم است و با ۰۹ شروع می‌شود."
    if (!this.route()) errors.route = "یک مسیر انتخاب کنید."
    this.errors.set(errors)
    if (Object.keys(errors).length === 0) this.sent.set(true)
  }

  onRoute(value: string | string[] | undefined) {
    if (typeof value === "string") this.route.set(value)
  }

  reset() {
    this.route.set(undefined)
    this.errors.set({})
    this.sent.set(false)
  }
}

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

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

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