ส่วนของหน้ารายละเอียด
RecordSection
One part of a record, such as Details or Items, with its heading. Used in the quick view and on the record page.
ใช้แบ่งหน้ารายละเอียดหรือแผงดูเร็วเป็นส่วน เช่น รายละเอียด รายการ ไฟล์แนบ และการอนุมัติ แต่ละส่วนมีหัวข้อที่โปรแกรมอ่านหน้าจอใช้เรียกชื่อส่วน ส่ง title และเนื้อหาเป็น children ถ้าผู้ใช้ต้องสลับดูทีละส่วน ใช้ Tabs
import { RecordSection } from "@bsru/ui";ตัวอย่าง
ส่วนรายละเอียด
เนื้อหาเป็นส่วนประกอบที่รับข้อมูล เช่น FieldList
รายละเอียด
- หน่วยงาน
- หน่วยงาน ก
- รหัสงบประมาณ
- BG-2570-ก-001
- ผู้ขอ
- นายทดสอบ มีสุข
<RecordSection title="รายละเอียด">
<Component
fields={[
{ label: "หน่วยงาน", value: "หน่วยงาน ก" },
{ label: "รหัสงบประมาณ", value: "BG-2570-ก-001", numeric: true },
{ label: "ผู้ขอ", value: "นายทดสอบ มีสุข" },
]}
/>
</RecordSection>| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| title* จำเป็น | "รายละเอียด" | string | The section heading, such as รายละเอียด. It also names the section for screen readers. |
ส่วนไฟล์แนบ
ไฟล์แนบ
- ใบเสนอราคา-บริษัทตัวอย่าง.pdf245 KB
- รายละเอียดคุณลักษณะเฉพาะ.pdf1.4 MB
<RecordSection title="ไฟล์แนบ">
<Component
files={[
{
key: "quote",
name: "ใบเสนอราคา-บริษัทตัวอย่าง.pdf",
size: 250880,
},
{
key: "spec",
name: "รายละเอียดคุณลักษณะเฉพาะ.pdf",
size: 1468006,
},
]}
downloadLabel="ดาวน์โหลด"
onDownload={handleDownload}
/>
</RecordSection>| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| title* จำเป็น | "ไฟล์แนบ" | string | The section heading, such as รายละเอียด. It also names the section for screen readers. |
ส่วนการอนุมัติในกรอบ
ในหน้ารายละเอียด ส่วนการอนุมัติอยู่ในกรอบข้างแท็บ ตอนนี้ต้องส่งคลาสกรอบผ่าน className เอง
การอนุมัติ
ผู้ขอส่งคำขอ
นายทดสอบ มีสุข, 1 ต.ค. 2569 เวลา 09:12 น.หัวหน้าหน่วยงานอนุมัติ
นางทดสอบ รักงาน, 1 ต.ค. 2569 เวลา 10:40 น.รองอธิการบดีที่กำกับ
<RecordSection
title="การอนุมัติ"
className="rounded-panel border border-ink-200 p-4 text-sm"
>
<Component
levels={[
{
state: "done",
title: "ผู้ขอส่งคำขอ",
detail: "นายทดสอบ มีสุข, 1 ต.ค. 2569 เวลา 09:12 น.",
},
{
state: "done",
title: "หัวหน้าหน่วยงานอนุมัติ",
detail: "นางทดสอบ รักงาน, 1 ต.ค. 2569 เวลา 10:40 น.",
},
{ state: "current", title: "รองอธิการบดีที่กำกับ" },
]}
/>
</RecordSection>| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| title* จำเป็น | "การอนุมัติ" | string | The section heading, such as รายละเอียด. It also names the section for screen readers. |
| className | "rounded-panel border border-ink-200 p-4 text-sm" | string | Classes for the section, such as a top margin between sections. |
props ทั้งหมด
ตัวอย่างด้านบนใช้ props เพียงบางตัว ตารางนี้แสดงทุกตัวที่คอมโพเนนต์รับ พร้อมค่าเริ่มต้นและค่าที่ใช้ได้
| ชื่อ | ชนิดข้อมูล | ค่าเริ่มต้น | คำอธิบาย |
|---|---|---|---|
| title* จำเป็น | string | — | The section heading, such as รายละเอียด. It also names the section for screen readers. |
| children* จำเป็น | ReactNode | — | The section's content, such as a FieldList or LineItems. |
| className | string | — | Classes for the section, such as a top margin between sections. |
ข้อควรปฏิบัติ
- หัวข้อเป็น h3 ใช้ภายใต้หัวข้อ h2 ของหน้าหรือแผง และ section มีชื่อจากหัวข้อนั้น
- เรียงส่วนในแผงดูเร็วและในหน้ารายละเอียดให้เหมือนกัน และใช้ชื่อหัวข้อเดียวกัน
- เว้นระยะระหว่างส่วนด้วย className เช่น mt-6
ซอร์สโค้ด: ui/src/record.tsx