"use client"; import { useUiDefaults } from "@suphark/ui/components/shared/ui-defaults"; import { useUiText } from "@suphark/ui/components/shared/ui-text"; import { cn } from "@suphark/ui/lib/utils"; import { ChevronRightIcon } from "lucide-react"; import type { ElementType, ReactNode } from "react"; export interface DocumentFlowItem { key: string; /** เลขเอกสาร หรือชื่อขั้น เช่น "PR-0418" */ label: ReactNode; /** ป้ายสถานะ (StatusBadge) — ไม่ส่ง + ไม่มี href = "ยังไม่สร้าง" */ status?: ReactNode; /** ประเภทเอกสารเล็ก ๆ ใต้เลข เช่น "ใบขอซื้อ" */ description?: ReactNode; href?: string; } /** * โซ่เอกสารแนวนอน เช่น ใบขอซื้อ → ใบสั่งซื้อ → ใบรับของ → ใบสำคัญจ่าย: แต่ละช่องเป็นลิงก์ไปเอกสาร * ช่องที่ `current` มีกรอบเน้น + `aria-current` · จอแคบเลื่อนแนวนอนในกล่องตัวเอง * * อนุมัติ, href }, * { key: "po", label: "PO-0142", description: "ใบสั่งซื้อ", status: …, href }, * { key: "dp", label: "DP", description: "ใบรับของ" }, * ]} /> * * แอป Next ส่ง `linkComponent={Link}` (barrel ไม่พึ่ง next/link) */ export function DocumentFlow({ items, current, linkComponent: linkComponentProp, className, "aria-label": ariaLabel, }: { items: ReadonlyArray; current?: string; linkComponent?: ElementType; className?: string; "aria-label"?: string; }) { const defaultLink = useUiDefaults().linkComponent; const LinkComponent = linkComponentProp ?? defaultLink ?? "a"; const text = useUiText().documentFlow; return ( ); }