ขั้นตอน
Steps
The steps of a process, with the finished ones ticked. `current` is the index of the step in progress.
ใช้แสดงว่ารายการอยู่ขั้นไหนของกระบวนงานที่มีลำดับตายตัว เช่น จากคำขอถึงเบิกจ่าย หรือขั้นของฟอร์มหลายหน้า ส่งรายการขั้นและลำดับของขั้นปัจจุบัน ถ้าต้องบอกว่าใครอนุมัติและเมื่อไร ใช้ ApprovalChain ถ้าแค่บอกสถานะของรายการ ใช้ Badge ถ้าผู้ใช้ต้องกดสลับส่วน ใช้ Tabs
import { Steps } from "@bsru/ui";ตัวอย่าง
อยู่ระหว่างกระบวนงาน
current เป็นลำดับเริ่มจาก 0 ขั้นก่อนหน้ามีเครื่องหมายถูก ขั้นปัจจุบันเป็นตัวหนา
- คำขอ
- อนุมัติ
- 3ใบสั่งซื้อ
- 4ตรวจรับ
- 5เบิกจ่าย
<Steps
current={2}
steps={[
{ label: "คำขอ" },
{ label: "อนุมัติ" },
{ label: "ใบสั่งซื้อ" },
{ label: "ตรวจรับ" },
{ label: "เบิกจ่าย" },
]}
/>| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| current* จำเป็น | 2 | number | The index of the step in progress, from 0. Steps before it are ticked. Use steps.length when all are done. |
| steps* จำเป็น | รายการ 5 รายการ[
{ label: "คำขอ" },
{ label: "อนุมัติ" },
{ label: "ใบสั่งซื้อ" },
{ label: "ตรวจรับ" },
{ label: "เบิกจ่าย" },
] | readonly Step[] | The steps, in order. |
ขั้นแรก
- 1คำขอ
- 2อนุมัติ
- 3ใบสั่งซื้อ
- 4ตรวจรับ
- 5เบิกจ่าย
<Steps
current={0}
steps={[
{ label: "คำขอ" },
{ label: "อนุมัติ" },
{ label: "ใบสั่งซื้อ" },
{ label: "ตรวจรับ" },
{ label: "เบิกจ่าย" },
]}
/>| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| current* จำเป็น | 0 | number | The index of the step in progress, from 0. Steps before it are ticked. Use steps.length when all are done. |
| steps* จำเป็น | รายการ 5 รายการ[
{ label: "คำขอ" },
{ label: "อนุมัติ" },
{ label: "ใบสั่งซื้อ" },
{ label: "ตรวจรับ" },
{ label: "เบิกจ่าย" },
] | readonly Step[] | The steps, in order. |
เสร็จทุกขั้น
ส่ง current เท่ากับจำนวนขั้น เพื่อให้ทุกขั้นมีเครื่องหมายถูก
- คำขอ
- อนุมัติ
- ใบสั่งซื้อ
- ตรวจรับ
- เบิกจ่าย
<Steps
current={5}
steps={[
{ label: "คำขอ" },
{ label: "อนุมัติ" },
{ label: "ใบสั่งซื้อ" },
{ label: "ตรวจรับ" },
{ label: "เบิกจ่าย" },
]}
/>| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| current* จำเป็น | 5 | number | The index of the step in progress, from 0. Steps before it are ticked. Use steps.length when all are done. |
| steps* จำเป็น | รายการ 5 รายการ[
{ label: "คำขอ" },
{ label: "อนุมัติ" },
{ label: "ใบสั่งซื้อ" },
{ label: "ตรวจรับ" },
{ label: "เบิกจ่าย" },
] | readonly Step[] | The steps, in order. |
props ทั้งหมด
ตัวอย่างด้านบนใช้ props เพียงบางตัว ตารางนี้แสดงทุกตัวที่คอมโพเนนต์รับ พร้อมค่าเริ่มต้นและค่าที่ใช้ได้
| ชื่อ | ชนิดข้อมูล | ค่าเริ่มต้น | คำอธิบาย |
|---|---|---|---|
| steps* จำเป็น | readonly Step[] | — | The steps, in order. |
| current* จำเป็น | number | — | The index of the step in progress, from 0. Steps before it are ticked. Use steps.length when all are done. |
| className | string | — | Extra classes for the list, such as spacing. |
ชนิดข้อมูล
Step
One step of a process.
| ชื่อ | ชนิดข้อมูล | ค่าเริ่มต้น | คำอธิบาย |
|---|---|---|---|
| label* จำเป็น | ReactNode | — | The step's name, already in the screen language. |
ข้อควรปฏิบัติ
- ขั้นปัจจุบันมี aria-current="step" ส่ง label ในภาษาของหน้าจอ และสั้นพอให้อยู่ใต้วงกลม
- เครื่องหมายถูกของขั้นที่เสร็จเป็นไอคอนตกแต่ง โปรแกรมอ่านหน้าจอไม่ได้ยินว่าเสร็จแล้ว บอกสถานะของรายการเป็นข้อความด้วย เช่น Badge
- Steps แสดงอย่างเดียว กดไม่ได้ ถ้าให้ย้อนกลับไปแก้ขั้นก่อนหน้า ใส่ปุ่มย้อนกลับไว้ในฟอร์ม
- บนจอแคบ รายการเลื่อนในแนวนอนได้ ใช้ไม่เกินประมาณ 6 ขั้น
ซอร์สโค้ด: ui/src/progress.tsx