"use client"; import { useUiText } from "@suphark/ui/components/shared/ui-text"; import { cn } from "@suphark/ui/lib/utils"; import { CheckIcon, TriangleAlertIcon } from "lucide-react"; import type { ReactNode } from "react"; export type StepIndicatorStatus = "done" | "current" | "pending" | "error"; export interface StepIndicatorStep { key: string; label: ReactNode; /** บรรทัดรองใต้ชื่อ (จอกว้างเท่านั้น) */ description?: ReactNode; /** ไม่ส่ง = คิดจากตำแหน่ง: ก่อน `current` = done, ที่ `current` = current, หลังจากนั้น = pending */ status?: StepIndicatorStatus; } export interface StepIndicatorProps { steps: ReadonlyArray; /** key ของขั้นปัจจุบัน */ current: string; /** * กดขั้นเพื่อย้อน/ไป — ไม่ส่ง = แสดงอย่างเดียว · กดได้เฉพาะขั้นที่ผ่านมาแล้ว (done/error) และขั้นปัจจุบัน * ขั้นข้างหน้าที่ยังไม่ถึงกดไม่ได้ (ยกเว้น `allowSkipAhead`) */ onStepChange?: (key: string) => void; /** อนุญาตกดข้ามไปขั้นข้างหน้าที่ยังไม่ถึง (ค่าเริ่มต้น false) */ allowSkipAhead?: boolean; orientation?: "horizontal" | "vertical"; "aria-label"?: string; className?: string; } /** * แถบขั้นตอนของ wizard ฝั่ง client (กล่อง/หน้าหลายขั้นที่คุม state เอง) — วงกลมเลข/เครื่องหมายถูก + เส้นเชื่อม * ย้อนกลับขั้นที่ทำแล้วได้ ข้ามไปข้างหน้าไม่ได้ · จอแคบแสดงชื่อเฉพาะขั้นปัจจุบัน * (ขั้นเป็นหน้าแยกที่มี URL → `Stepper` ของ `@suphark/ui/next` ซึ่งเป็นลิงก์) * * const [step, setStep] = useState("upload"); * */ export function StepIndicator({ steps, current, onStepChange, allowSkipAhead = false, orientation = "horizontal", "aria-label": ariaLabel, className, }: StepIndicatorProps) { const t = useUiText().stepIndicator; const currentIndex = Math.max( 0, steps.findIndex((s) => s.key === current), ); const vertical = orientation === "vertical"; return ( ); }