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

جست‌وجوی پزشک با نام، تخصص یا بیماری، چیپِ تخصص، نوبتِ امروز و ویزیتِ آنلاین، مرتب‌سازی؛ کارتِ پزشک با عکس، شمارهٔ نظام پزشکی، امتیاز، مطب و فاصله و نزدیک‌ترین نوبت، و «خبرم کن» برای پزشکِ بی‌نوبت.

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

این بلاک از ۱۱ آیتم دیگ استفاده می‌کند: avatarbadgebuttonchoice-chipscontrol-sizeempty-stateiconspersiansearch-fieldselectswitch

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

۲. کد صفحه

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

doctor-list.tsx
"use client"

import * as React from "react"

import { CalendarIcon, ChatIcon, LocationIcon, StarIcon } from "@/components/icons"
import { Avatar } from "@/components/ui/avatar"
import { Badge } from "@/components/ui/badge"
import { Button } from "@/components/ui/button"
import { ChoiceChip, ChoiceChips } from "@/components/ui/choice-chips"
import { ControlSizeProvider } from "@/components/ui/control-size"
import { EmptyState, EmptyStateActions, EmptyStateDescription, EmptyStateTitle } from "@/components/ui/empty-state"
import { SearchField } from "@/components/ui/search-field"
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select"
import { Switch } from "@/components/ui/switch"
import { toFaDigits, toSearchKey } from "@/lib/persian"
import { stockImages, type StockImageName } from "@/lib/stock-images"

type Doctor = {
  id: string
  name: string
  specialty: string
  group: string
  photo: StockImageName
  council: string
  rating: number
  reviews: number
  clinic: string
  km: number
  online: boolean
  /** نزدیک‌ترین نوبت؛ dayOffset صفر یعنی امروز. */
  next: { dayOffset: number; time: string } | null
}

const DOCTORS: Doctor[] = [
  { id: "1", name: "دکتر سارا محمدی", specialty: "متخصصِ قلب و عروق", group: "heart", photo: "doctorWomanCurly", council: "۱۲۳۴۵۶", rating: 4.8, reviews: 412, clinic: "ونک، ساختمانِ پزشکانِ آرین", km: 1.2, online: true, next: { dayOffset: 0, time: "۱۶:۳۰" } },
  { id: "2", name: "دکتر علی رضایی", specialty: "پزشکِ عمومی", group: "general", photo: "doctorManGlasses", council: "۲۳۴۵۶۷", rating: 4.6, reviews: 289, clinic: "یوسف‌آباد، کلینیکِ سینا", km: 2.4, online: true, next: { dayOffset: 1, time: "۱۰:۰۰" } },
  { id: "3", name: "دکتر مریم کاظمی", specialty: "متخصصِ پوست و مو", group: "skin", photo: "doctorWomanRed", council: "۳۴۵۶۷۸", rating: 4.9, reviews: 530, clinic: "سعادت‌آباد، کلینیکِ پوستِ نیکان", km: 4.1, online: false, next: { dayOffset: 3, time: "۱۱:۳۰" } },
  { id: "4", name: "دکتر رضا احمدی", specialty: "متخصصِ کودکان", group: "kids", photo: "doctorManScrubs", council: "۴۵۶۷۸۹", rating: 4.7, reviews: 198, clinic: "پاسداران، کلینیکِ آوا", km: 3.0, online: true, next: { dayOffset: 0, time: "۱۸:۰۰" } },
  { id: "5", name: "دکتر کامران نوری", specialty: "متخصصِ چشم", group: "eye", photo: "doctorManOffice", council: "۵۶۷۸۹۰", rating: 4.5, reviews: 147, clinic: "ولیعصر، بیمارستانِ نور", km: 5.6, online: false, next: null },
]

const GROUPS = [
  { value: "all", label: "همه" },
  { value: "general", label: "عمومی" },
  { value: "heart", label: "قلب" },
  { value: "skin", label: "پوست" },
  { value: "kids", label: "کودکان" },
  { value: "eye", label: "چشم" },
]

const dayLabel = (offset: number) => (offset === 0 ? "امروز" : offset === 1 ? "فردا" : `${toFaDigits(offset)} روزِ دیگر`)

/**
 * فهرستِ پزشکان برای نوبت‌دهیِ آنلاین: جست‌وجو با نام، تخصص یا بیماری، چیپِ تخصص، «فقط نوبتِ امروز» و
 * «ویزیتِ آنلاین»، و مرتب‌سازی. کارتِ هر پزشک عکس، تخصص و شمارهٔ نظام پزشکی (برای اعتماد)، امتیاز با تعدادِ
 * نظر، مطب و فاصله، و نزدیک‌ترین نوبت را دارد؛ نوبتِ امروز سبز است. پزشکِ بی‌نوبت دکمهٔ «خبرم کن» دارد، نه
 * دکمهٔ غیرفعال. نتیجهٔ خالی راهِ برگشت دارد.
 */
export default function DoctorListBlock() {
  const [query, setQuery] = React.useState("")
  const [group, setGroup] = React.useState("all")
  const [today, setToday] = React.useState(false)
  const [online, setOnline] = React.useState(false)
  const [sort, setSort] = React.useState("soonest")
  const key = toSearchKey(query)

  const visible = DOCTORS.filter(
    (doctor) =>
      (!key || toSearchKey(doctor.name + doctor.specialty).includes(key)) &&
      (group === "all" || doctor.group === group) &&
      (!today || doctor.next?.dayOffset === 0) &&
      (!online || doctor.online)
  ).sort((a, b) => (sort === "rating" ? b.rating - a.rating : sort === "nearest" ? a.km - b.km : (a.next?.dayOffset ?? 99) - (b.next?.dayOffset ?? 99)))

  const reset = () => {
    setQuery("")
    setGroup("all")
    setToday(false)
    setOnline(false)
  }

  return (
    <ControlSizeProvider size="xl" asChild>
      <main className="mx-auto flex w-full max-w-5xl flex-col gap-6 p-4 sm:p-6">
        <header className="flex flex-col gap-1">
          <h1 className="text-2xl leading-snug font-bold sm:text-3xl">نوبتِ پزشک</h1>
          <p className="text-muted-foreground">از بیش از ۴۰۰ پزشکِ تهران، بی‌تماس و بی‌صف.</p>
        </header>

        <div className="flex flex-col gap-4">
          <SearchField aria-label="جست‌وجوی پزشک" placeholder="نامِ پزشک، تخصص یا بیماری" value={query} onValueChange={setQuery} />
          {/* تخصص‌ها چیپ‌اند و می‌شکنند؛ گزینه‌ای در لبه بریده نمی‌شود. */}
          <ChoiceChips type="single" value={group} onValueChange={(value) => value && setGroup(value)} aria-label="تخصص">
            {GROUPS.map((item) => (
              <ChoiceChip key={item.value} value={item.value}>
                {item.label}
              </ChoiceChip>
            ))}
          </ChoiceChips>
          <div className="flex flex-wrap items-center justify-between gap-x-6 gap-y-3">
            <div className="flex flex-wrap items-center gap-x-6 gap-y-3 text-sm">
              <label className="flex cursor-pointer items-center gap-2">
                <Switch checked={today} onCheckedChange={setToday} />
                فقط نوبتِ امروز
              </label>
              <label className="flex cursor-pointer items-center gap-2">
                <Switch checked={online} onCheckedChange={setOnline} />
                ویزیتِ آنلاین
              </label>
            </div>
            <ControlSizeProvider size="lg" mobileSize="default" asChild>
              <div className="flex items-center gap-2 text-sm">
                <span id="doctor-sort" className="text-muted-foreground">
                  مرتب‌سازی
                </span>
                <Select value={sort} onValueChange={setSort}>
                  <SelectTrigger aria-labelledby="doctor-sort" className="w-auto min-w-36">
                    <SelectValue />
                  </SelectTrigger>
                  <ControlSizeProvider size="xl" asChild>
                    <SelectContent>
                      <SelectItem value="soonest">نزدیک‌ترین نوبت</SelectItem>
                      <SelectItem value="rating">بیشترین امتیاز</SelectItem>
                      <SelectItem value="nearest">نزدیک‌ترین مطب</SelectItem>
                    </SelectContent>
                  </ControlSizeProvider>
                </Select>
              </div>
            </ControlSizeProvider>
          </div>
        </div>

        <p className="text-sm text-muted-foreground" aria-live="polite">
          {toFaDigits(visible.length)} پزشک
        </p>

        {visible.length === 0 ? (
          <EmptyState variant="bordered">
            <EmptyStateTitle>پزشکی با این شرایط پیدا نشد</EmptyStateTitle>
            <EmptyStateDescription>فیلترها را کم کن یا نامِ تخصص را بنویس؛ مثلاً «قلب» به‌جای نامِ بیماری.</EmptyStateDescription>
            <EmptyStateActions>
              <Button variant="outline" onClick={reset}>
                پاک‌کردنِ فیلترها
              </Button>
            </EmptyStateActions>
          </EmptyState>
        ) : (
          <ul className="flex flex-col gap-3">
            {visible.map((doctor) => (
              <li key={doctor.id} className="flex flex-col gap-4 rounded-xl border border-border bg-card p-4 sm:flex-row sm:items-center sm:gap-5 sm:p-5">
                <div className="flex min-w-0 flex-1 gap-4">
                  <Avatar src={stockImages[doctor.photo].src} alt="" name={doctor.name} className="size-16 shrink-0 sm:size-20" />
                  <div className="flex min-w-0 flex-col gap-1.5">
                    <a href="#" className="leading-snug font-bold hover:underline">
                      {doctor.name}
                    </a>
                    <span className="text-sm text-muted-foreground">
                      {doctor.specialty} · ن.ن.پ {doctor.council}
                    </span>
                    <span className="flex flex-wrap items-center gap-x-3 gap-y-1 text-sm">
                      <span className="flex items-center gap-1">
                        <StarIcon aria-hidden className="size-4 fill-[var(--dig-amber-400)] text-[var(--dig-amber-400)]" />
                        <span className="font-medium">{toFaDigits(String(doctor.rating).replace(".", "٫"))}</span>
                        <span className="text-muted-foreground">({toFaDigits(doctor.reviews)} نظر)</span>
                      </span>
                      {doctor.online && (
                        <Badge variant="soft" color="info">
                          <ChatIcon aria-hidden />
                          ویزیتِ آنلاین
                        </Badge>
                      )}
                    </span>
                    <span className="flex items-center gap-1 text-sm text-muted-foreground">
                      <LocationIcon aria-hidden className="size-4 shrink-0" />
                      <span className="truncate">{doctor.clinic}</span>
                      <span className="shrink-0">· {toFaDigits(String(doctor.km).replace(".", "٫"))} کیلومتر</span>
                    </span>
                  </div>
                </div>

                {/* ستونِ نوبت: در موبایل زیرِ اطلاعات با خطِ جداکننده، در دسکتاپ کنارش. */}
                <div className="flex items-center justify-between gap-3 border-t border-border pt-4 sm:w-52 sm:flex-col sm:items-stretch sm:border-t-0 sm:border-s sm:ps-5 sm:pt-0">
                  {doctor.next ? (
                    <span className="flex flex-col gap-0.5 text-sm">
                      <span className="text-muted-foreground">نزدیک‌ترین نوبت</span>
                      <span className={`flex items-center gap-1.5 font-semibold ${doctor.next.dayOffset === 0 ? "text-success-subtle-foreground" : ""}`}>
                        <CalendarIcon aria-hidden className="size-4" />
                        {dayLabel(doctor.next.dayOffset)}، {doctor.next.time}
                      </span>
                    </span>
                  ) : (
                    <span className="text-sm text-muted-foreground">نوبتِ خالی در این هفته نیست</span>
                  )}
                  <ControlSizeProvider size="lg" mobileSize="default" asChild>
                    {doctor.next ? <Button>دریافتِ نوبت</Button> : <Button variant="outline">نوبت باز شد خبرم کن</Button>}
                  </ControlSizeProvider>
                </div>
              </li>
            ))}
          </ul>
        )}
      </main>
    </ControlSizeProvider>
  )
}
doctor-list.vue
<script setup lang="ts">
import { computed, ref } from "vue"

import Avatar from "@/components/ui/Avatar.vue"
import Badge from "@/components/ui/Badge.vue"
import Button from "@/components/ui/Button.vue"
import ChoiceChip from "@/components/ui/ChoiceChip.vue"
import ChoiceChips from "@/components/ui/ChoiceChips.vue"
import ControlSize from "@/components/ui/ControlSize.vue"
import EmptyState from "@/components/ui/EmptyState.vue"
import EmptyStateActions from "@/components/ui/EmptyStateActions.vue"
import EmptyStateDescription from "@/components/ui/EmptyStateDescription.vue"
import EmptyStateTitle from "@/components/ui/EmptyStateTitle.vue"
import SearchField from "@/components/ui/SearchField.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 Switch from "@/components/ui/Switch.vue"
import { DigIcon } from "@/lib/icons"
import { toFaDigits, toSearchKey } from "@/lib/persian"

const IMAGES = "https://docs.digdesign.ir/images"

type Doctor = {
  id: string
  name: string
  specialty: string
  group: string
  photo: string
  council: string
  rating: number
  reviews: number
  clinic: string
  km: number
  online: boolean
  /** نزدیک‌ترین نوبت؛ dayOffset صفر یعنی امروز. */
  next: { dayOffset: number; time: string } | null
}

const DOCTORS: Doctor[] = [
  { id: "1", name: "دکتر سارا محمدی", specialty: "متخصصِ قلب و عروق", group: "heart", photo: `${IMAGES}/doctor-woman-curly.webp`, council: "۱۲۳۴۵۶", rating: 4.8, reviews: 412, clinic: "ونک، ساختمانِ پزشکانِ آرین", km: 1.2, online: true, next: { dayOffset: 0, time: "۱۶:۳۰" } },
  { id: "2", name: "دکتر علی رضایی", specialty: "پزشکِ عمومی", group: "general", photo: `${IMAGES}/doctor-man-glasses.webp`, council: "۲۳۴۵۶۷", rating: 4.6, reviews: 289, clinic: "یوسف‌آباد، کلینیکِ سینا", km: 2.4, online: true, next: { dayOffset: 1, time: "۱۰:۰۰" } },
  { id: "3", name: "دکتر مریم کاظمی", specialty: "متخصصِ پوست و مو", group: "skin", photo: `${IMAGES}/doctor-woman-red.webp`, council: "۳۴۵۶۷۸", rating: 4.9, reviews: 530, clinic: "سعادت‌آباد، کلینیکِ پوستِ نیکان", km: 4.1, online: false, next: { dayOffset: 3, time: "۱۱:۳۰" } },
  { id: "4", name: "دکتر رضا احمدی", specialty: "متخصصِ کودکان", group: "kids", photo: `${IMAGES}/doctor-man-scrubs.webp`, council: "۴۵۶۷۸۹", rating: 4.7, reviews: 198, clinic: "پاسداران، کلینیکِ آوا", km: 3.0, online: true, next: { dayOffset: 0, time: "۱۸:۰۰" } },
  { id: "5", name: "دکتر کامران نوری", specialty: "متخصصِ چشم", group: "eye", photo: `${IMAGES}/doctor-man-office.webp`, council: "۵۶۷۸۹۰", rating: 4.5, reviews: 147, clinic: "ولیعصر، بیمارستانِ نور", km: 5.6, online: false, next: null },
]

const GROUPS = [
  { value: "all", label: "همه" },
  { value: "general", label: "عمومی" },
  { value: "heart", label: "قلب" },
  { value: "skin", label: "پوست" },
  { value: "kids", label: "کودکان" },
  { value: "eye", label: "چشم" },
]

const dayLabel = (offset: number) => (offset === 0 ? "امروز" : offset === 1 ? "فردا" : `${toFaDigits(offset)} روزِ دیگر`)

/**
 * فهرستِ پزشکان برای نوبت‌دهیِ آنلاین: جست‌وجو با نام، تخصص یا بیماری، چیپِ تخصص، «فقط نوبتِ امروز» و
 * «ویزیتِ آنلاین»، و مرتب‌سازی. کارتِ هر پزشک عکس، تخصص و شمارهٔ نظام پزشکی (برای اعتماد)، امتیاز با تعدادِ
 * نظر، مطب و فاصله، و نزدیک‌ترین نوبت را دارد؛ نوبتِ امروز سبز است. پزشکِ بی‌نوبت دکمهٔ «خبرم کن» دارد، نه
 * دکمهٔ غیرفعال. نتیجهٔ خالی راهِ برگشت دارد.
 */
const query = ref("")
const group = ref("all")
const today = ref(false)
const online = ref(false)
const sort = ref("soonest")

const visible = computed(() => {
  const key = toSearchKey(query.value)
  return DOCTORS.filter(
    (doctor) =>
      (!key || toSearchKey(doctor.name + doctor.specialty).includes(key)) &&
      (group.value === "all" || doctor.group === group.value) &&
      (!today.value || doctor.next?.dayOffset === 0) &&
      (!online.value || doctor.online)
  ).sort((a, b) => (sort.value === "rating" ? b.rating - a.rating : sort.value === "nearest" ? a.km - b.km : (a.next?.dayOffset ?? 99) - (b.next?.dayOffset ?? 99)))
})

function reset() {
  query.value = ""
  group.value = "all"
  today.value = false
  online.value = false
}

function onGroup(value: string | string[] | undefined) {
  if (value) group.value = value as string
}
</script>

<template>
  <ControlSize size="xl" as-child>
    <main class="mx-auto flex w-full max-w-5xl flex-col gap-6 p-4 sm:p-6">
      <header class="flex flex-col gap-1">
        <h1 class="text-2xl leading-snug font-bold sm:text-3xl">نوبتِ پزشک</h1>
        <p class="text-muted-foreground">از بیش از ۴۰۰ پزشکِ تهران، بی‌تماس و بی‌صف.</p>
      </header>

      <div class="flex flex-col gap-4">
        <SearchField v-model="query" aria-label="جست‌وجوی پزشک" placeholder="نامِ پزشک، تخصص یا بیماری" />
        <!-- تخصص‌ها چیپ‌اند و می‌شکنند؛ گزینه‌ای در لبه بریده نمی‌شود. -->
        <ChoiceChips type="single" :value="group" aria-label="تخصص" @update:value="onGroup">
          <ChoiceChip v-for="item in GROUPS" :key="item.value" :value="item.value">{{ item.label }}</ChoiceChip>
        </ChoiceChips>
        <div class="flex flex-wrap items-center justify-between gap-x-6 gap-y-3">
          <div class="flex flex-wrap items-center gap-x-6 gap-y-3 text-sm">
            <label class="flex cursor-pointer items-center gap-2">
              <Switch :checked="today" @update:checked="(value) => (today = value)" />
              فقط نوبتِ امروز
            </label>
            <label class="flex cursor-pointer items-center gap-2">
              <Switch :checked="online" @update:checked="(value) => (online = value)" />
              ویزیتِ آنلاین
            </label>
          </div>
          <ControlSize size="lg" mobile-size="default" as-child>
            <div class="flex items-center gap-2 text-sm">
              <span id="doctor-sort" class="text-muted-foreground">مرتب‌سازی</span>
              <Select :value="sort" @update:value="(value) => (sort = value as string)">
                <SelectTrigger aria-labelledby="doctor-sort" class="w-auto min-w-36">
                  <SelectValue />
                </SelectTrigger>
                <ControlSize size="xl" as-child>
                  <SelectContent>
                    <SelectItem value="soonest">نزدیک‌ترین نوبت</SelectItem>
                    <SelectItem value="rating">بیشترین امتیاز</SelectItem>
                    <SelectItem value="nearest">نزدیک‌ترین مطب</SelectItem>
                  </SelectContent>
                </ControlSize>
              </Select>
            </div>
          </ControlSize>
        </div>
      </div>

      <p class="text-sm text-muted-foreground" aria-live="polite">{{ toFaDigits(visible.length) }} پزشک</p>

      <EmptyState v-if="visible.length === 0" variant="bordered">
        <EmptyStateTitle>پزشکی با این شرایط پیدا نشد</EmptyStateTitle>
        <EmptyStateDescription>فیلترها را کم کن یا نامِ تخصص را بنویس؛ مثلاً «قلب» به‌جای نامِ بیماری.</EmptyStateDescription>
        <EmptyStateActions>
          <Button variant="outline" @click="reset">پاک‌کردنِ فیلترها</Button>
        </EmptyStateActions>
      </EmptyState>
      <ul v-else class="flex flex-col gap-3">
        <li v-for="doctor in visible" :key="doctor.id" class="flex flex-col gap-4 rounded-xl border border-border bg-card p-4 sm:flex-row sm:items-center sm:gap-5 sm:p-5">
          <div class="flex min-w-0 flex-1 gap-4">
            <Avatar :src="doctor.photo" alt="" :name="doctor.name" class="size-16 shrink-0 sm:size-20" />
            <div class="flex min-w-0 flex-col gap-1.5">
              <a href="#" class="leading-snug font-bold hover:underline">{{ doctor.name }}</a>
              <span class="text-sm text-muted-foreground">{{ doctor.specialty }} · ن.ن.پ {{ doctor.council }}</span>
              <span class="flex flex-wrap items-center gap-x-3 gap-y-1 text-sm">
                <span class="flex items-center gap-1">
                  <DigIcon name="star" aria-hidden="true" class="size-4 fill-[var(--dig-amber-400)] text-[var(--dig-amber-400)]" />
                  <span class="font-medium">{{ toFaDigits(String(doctor.rating).replace(".", "٫")) }}</span>
                  <span class="text-muted-foreground">({{ toFaDigits(doctor.reviews) }} نظر)</span>
                </span>
                <Badge v-if="doctor.online" variant="soft" color="info">
                  <DigIcon name="chat" aria-hidden="true" />
                  ویزیتِ آنلاین
                </Badge>
              </span>
              <span class="flex items-center gap-1 text-sm text-muted-foreground">
                <DigIcon name="location" aria-hidden="true" class="size-4 shrink-0" />
                <span class="truncate">{{ doctor.clinic }}</span>
                <span class="shrink-0">· {{ toFaDigits(String(doctor.km).replace(".", "٫")) }} کیلومتر</span>
              </span>
            </div>
          </div>

          <!-- ستونِ نوبت: در موبایل زیرِ اطلاعات با خطِ جداکننده، در دسکتاپ کنارش. -->
          <div class="flex items-center justify-between gap-3 border-t border-border pt-4 sm:w-52 sm:flex-col sm:items-stretch sm:border-t-0 sm:border-s sm:ps-5 sm:pt-0">
            <span v-if="doctor.next" class="flex flex-col gap-0.5 text-sm">
              <span class="text-muted-foreground">نزدیک‌ترین نوبت</span>
              <span :class="`flex items-center gap-1.5 font-semibold ${doctor.next.dayOffset === 0 ? 'text-success-subtle-foreground' : ''}`">
                <DigIcon name="calendar" aria-hidden="true" class="size-4" />
                {{ dayLabel(doctor.next.dayOffset) }}، {{ doctor.next.time }}
              </span>
            </span>
            <span v-else class="text-sm text-muted-foreground">نوبتِ خالی در این هفته نیست</span>
            <ControlSize size="lg" mobile-size="default" as-child>
              <Button v-if="doctor.next">دریافتِ نوبت</Button>
              <Button v-else variant="outline">نوبت باز شد خبرم کن</Button>
            </ControlSize>
          </div>
        </li>
      </ul>
    </main>
  </ControlSize>
</template>

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

این موارد هنوز برای Svelte آماده نیستند: avatarbadgechoice-chipscontrol-sizeempty-statepersiansearch-fieldselectswitchآیکون calendarآیکون chatآیکون locationآیکون star

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

doctor-list.ts
import { Component, ChangeDetectionStrategy, signal, computed } from "@angular/core"

import { DigControlSize } from "@/components/ui/control-size"
import { DigSearchField } from "@/components/ui/search-field"
import { DigChoiceChips, DigChoiceChip } from "@/components/ui/choice-chips"
import { DigSwitch } from "@/components/ui/switch"
import { DigSelect, DigSelectTrigger, DigSelectValue, DigSelectContent, DigSelectItem } from "@/components/ui/select"
import {
  DigEmptyState,
  DigEmptyStateTitle,
  DigEmptyStateDescription,
  DigEmptyStateActions,
} from "@/components/ui/empty-state"
import { DigButton } from "@/components/ui/button"
import { DigAvatar } from "@/components/ui/avatar"
import { DigIcon } from "@/lib/icons"
import { DigBadge } from "@/components/ui/badge"
import { toFaDigits, toSearchKey } from "@/lib/persian"

const IMAGES = "https://docs.digdesign.ir/images"

type Doctor = {
  id: string
  name: string
  specialty: string
  group: string
  photo: string
  council: string
  rating: number
  reviews: number
  clinic: string
  km: number
  online: boolean
  /** نزدیک‌ترین نوبت؛ dayOffset صفر یعنی امروز. */
  next: { dayOffset: number; time: string } | null
}

const DOCTORS: Doctor[] = [
  {
    id: "1",
    name: "دکتر سارا محمدی",
    specialty: "متخصصِ قلب و عروق",
    group: "heart",
    photo: `${IMAGES}/doctor-woman-curly.webp`,
    council: "۱۲۳۴۵۶",
    rating: 4.8,
    reviews: 412,
    clinic: "ونک، ساختمانِ پزشکانِ آرین",
    km: 1.2,
    online: true,
    next: { dayOffset: 0, time: "۱۶:۳۰" },
  },
  {
    id: "2",
    name: "دکتر علی رضایی",
    specialty: "پزشکِ عمومی",
    group: "general",
    photo: `${IMAGES}/doctor-man-glasses.webp`,
    council: "۲۳۴۵۶۷",
    rating: 4.6,
    reviews: 289,
    clinic: "یوسف‌آباد، کلینیکِ سینا",
    km: 2.4,
    online: true,
    next: { dayOffset: 1, time: "۱۰:۰۰" },
  },
  {
    id: "3",
    name: "دکتر مریم کاظمی",
    specialty: "متخصصِ پوست و مو",
    group: "skin",
    photo: `${IMAGES}/doctor-woman-red.webp`,
    council: "۳۴۵۶۷۸",
    rating: 4.9,
    reviews: 530,
    clinic: "سعادت‌آباد، کلینیکِ پوستِ نیکان",
    km: 4.1,
    online: false,
    next: { dayOffset: 3, time: "۱۱:۳۰" },
  },
  {
    id: "4",
    name: "دکتر رضا احمدی",
    specialty: "متخصصِ کودکان",
    group: "kids",
    photo: `${IMAGES}/doctor-man-scrubs.webp`,
    council: "۴۵۶۷۸۹",
    rating: 4.7,
    reviews: 198,
    clinic: "پاسداران، کلینیکِ آوا",
    km: 3.0,
    online: true,
    next: { dayOffset: 0, time: "۱۸:۰۰" },
  },
  {
    id: "5",
    name: "دکتر کامران نوری",
    specialty: "متخصصِ چشم",
    group: "eye",
    photo: `${IMAGES}/doctor-man-office.webp`,
    council: "۵۶۷۸۹۰",
    rating: 4.5,
    reviews: 147,
    clinic: "ولیعصر، بیمارستانِ نور",
    km: 5.6,
    online: false,
    next: null,
  },
]

const GROUPS = [
  { value: "all", label: "همه" },
  { value: "general", label: "عمومی" },
  { value: "heart", label: "قلب" },
  { value: "skin", label: "پوست" },
  { value: "kids", label: "کودکان" },
  { value: "eye", label: "چشم" },
]

const dayLabel = (offset: number) => (offset === 0 ? "امروز" : offset === 1 ? "فردا" : `${toFaDigits(offset)} روزِ دیگر`)

@Component({
  selector: "dig-block-doctor-list",
  imports: [
    DigControlSize,
    DigSearchField,
    DigChoiceChips,
    DigChoiceChip,
    DigSwitch,
    DigSelect,
    DigSelectTrigger,
    DigSelectValue,
    DigSelectContent,
    DigSelectItem,
    DigEmptyState,
    DigEmptyStateTitle,
    DigEmptyStateDescription,
    DigEmptyStateActions,
    DigButton,
    DigAvatar,
    DigIcon,
    DigBadge,
  ],
  changeDetection: ChangeDetectionStrategy.OnPush,
  template: `
    <main digControlSize="xl" class="mx-auto flex w-full max-w-5xl flex-col gap-6 p-4 sm:p-6">
      <header class="flex flex-col gap-1">
        <h1 class="text-2xl leading-snug font-bold sm:text-3xl">نوبتِ پزشک</h1>
        <p class="text-muted-foreground">از بیش از ۴۰۰ پزشکِ تهران، بی‌تماس و بی‌صف.</p>
      </header>

      <div class="flex flex-col gap-4">
        <div
          digSearchField
          [value]="query()"
          (valueChange)="query.set($event)"
          aria-label="جست‌وجوی پزشک"
          placeholder="نامِ پزشک، تخصص یا بیماری"
        ></div>
        <!-- تخصص‌ها چیپ‌اند و می‌شکنند؛ گزینه‌ای در لبه بریده نمی‌شود. -->
        <div digChoiceChips type="single" [value]="group()" aria-label="تخصص" (valueChange)="onGroup($event)">
          @for (item of GROUPS; track item.value) {
            <button digChoiceChip [value]="item.value">{{ item.label }}</button>
          }
        </div>
        <div class="flex flex-wrap items-center justify-between gap-x-6 gap-y-3">
          <div class="flex flex-wrap items-center gap-x-6 gap-y-3 text-sm">
            <label class="flex cursor-pointer items-center gap-2"
              ><button digSwitch [checked]="today()" (checkedChange)="today.set($event)"></button>
              فقط نوبتِ امروز
            </label>
            <label class="flex cursor-pointer items-center gap-2"
              ><button digSwitch [checked]="online()" (checkedChange)="online.set($event)"></button>
              ویزیتِ آنلاین
            </label>
          </div>
          <div digControlSize="lg" mobileSize="default" class="flex items-center gap-2 text-sm">
            <span id="doctor-sort" class="text-muted-foreground">مرتب‌سازی</span>
            <ng-container digSelect [value]="sort()" (valueChange)="typeof $event === 'string' && sort.set($event)"
              ><button digSelectTrigger aria-labelledby="doctor-sort" class="w-auto min-w-36">
                <span digSelectValue></span>
              </button>
              <div digControlSize="xl" digSelectContent>
                <div digSelectItem value="soonest">نزدیک‌ترین نوبت</div>
                <div digSelectItem value="rating">بیشترین امتیاز</div>
                <div digSelectItem value="nearest">نزدیک‌ترین مطب</div>
              </div></ng-container
            >
          </div>
        </div>
      </div>

      <p class="text-sm text-muted-foreground" aria-live="polite">{{ toFaDigits(visible().length) }} پزشک</p>

      @if (visible().length === 0) {
        <div digEmptyState variant="bordered">
          <h3 digEmptyStateTitle>پزشکی با این شرایط پیدا نشد</h3>
          <p digEmptyStateDescription>فیلترها را کم کن یا نامِ تخصص را بنویس؛ مثلاً «قلب» به‌جای نامِ بیماری.</p>
          <div digEmptyStateActions>
            <button digButton type="button" variant="outline" (click)="reset()">پاک‌کردنِ فیلترها</button>
          </div>
        </div>
      } @else {
        <ul class="flex flex-col gap-3">
          @for (doctor of visible(); track doctor.id) {
            <li
              class="flex flex-col gap-4 rounded-xl border border-border bg-card p-4 sm:flex-row sm:items-center sm:gap-5 sm:p-5"
            >
              <div class="flex min-w-0 flex-1 gap-4">
                <span
                  digAvatar
                  [src]="doctor.photo"
                  alt=""
                  [name]="doctor.name"
                  class="size-16 shrink-0 sm:size-20"
                ></span>
                <div class="flex min-w-0 flex-col gap-1.5">
                  <a href="#" class="leading-snug font-bold hover:underline">{{ doctor.name }}</a>
                  <span class="text-sm text-muted-foreground">{{ doctor.specialty }} · ن.ن.پ {{ doctor.council }}</span>
                  <span class="flex flex-wrap items-center gap-x-3 gap-y-1 text-sm"
                    ><span class="flex items-center gap-1"
                      ><svg
                        digIcon="star"
                        aria-hidden="true"
                        class="size-4 fill-[var(--dig-amber-400)] text-[var(--dig-amber-400)]"
                      ></svg>
                      <span class="font-medium">{{ toFaDigits(string(doctor.rating).replace(".", "٫")) }}</span>
                      <span class="text-muted-foreground">({{ toFaDigits(doctor.reviews) }} نظر)</span></span
                    >
                    @if (doctor.online) {
                      <span digBadge variant="soft" color="info"
                        ><svg digIcon="chat" aria-hidden="true"></svg>
                        ویزیتِ آنلاین
                      </span>
                    }
                  </span>
                  <span class="flex items-center gap-1 text-sm text-muted-foreground"
                    ><svg digIcon="location" aria-hidden="true" class="size-4 shrink-0"></svg>
                    <span class="truncate">{{ doctor.clinic }}</span>
                    <span class="shrink-0">· {{ toFaDigits(string(doctor.km).replace(".", "٫")) }} کیلومتر</span></span
                  >
                </div>
              </div>

              <!-- ستونِ نوبت: در موبایل زیرِ اطلاعات با خطِ جداکننده، در دسکتاپ کنارش. -->
              <div
                class="flex items-center justify-between gap-3 border-t border-border pt-4 sm:w-52 sm:flex-col sm:items-stretch sm:border-t-0 sm:border-s sm:ps-5 sm:pt-0"
              >
                @if (doctor.next) {
                  <span class="flex flex-col gap-0.5 text-sm"
                    ><span class="text-muted-foreground">نزدیک‌ترین نوبت</span>
                    <span
                      [class]="\`flex items-center gap-1.5 font-semibold \${doctor.next.dayOffset === 0 ? 'text-success-subtle-foreground' : ''}\`"
                      ><svg digIcon="calendar" aria-hidden="true" class="size-4"></svg>
                      {{ dayLabel(doctor.next.dayOffset) }}، {{ doctor.next.time }}</span
                    ></span
                  >
                } @else {
                  <span class="text-sm text-muted-foreground">نوبتِ خالی در این هفته نیست</span>
                }
                <button digControlSize="lg" mobileSize="default" digButton type="button">دریافتِ نوبت</button>
              </div>
            </li>
          }
        </ul>
      }
    </main>
  `,
})
export class DoctorListBlock {
  readonly string = String

  readonly toFaDigits = toFaDigits

  readonly dayLabel = dayLabel

  readonly GROUPS = GROUPS

  readonly query = signal("")

  readonly group = signal("all")

  readonly today = signal(false)

  readonly online = signal(false)

  readonly sort = signal("soonest")

  readonly visible = computed(() => {
    const key = toSearchKey(this.query())
    return DOCTORS.filter(
      (doctor) =>
        (!key || toSearchKey(doctor.name + doctor.specialty).includes(key)) &&
        (this.group() === "all" || doctor.group === this.group()) &&
        (!this.today() || doctor.next?.dayOffset === 0) &&
        (!this.online() || doctor.online)
    ).sort((a, b) =>
      this.sort() === "rating"
        ? b.rating - a.rating
        : this.sort() === "nearest"
          ? a.km - b.km
          : (a.next?.dayOffset ?? 99) - (b.next?.dayOffset ?? 99)
    )
  })

  reset() {
    this.query.set("")
    this.group.set("all")
    this.today.set(false)
    this.online.set(false)
  }

  onGroup(value: string | string[] | undefined) {
    if (value) this.group.set(value as string)
  }
}

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

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

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