รายการข้อมูล
FieldList
A record's fields as label and value pairs. Mask sensitive values before passing them in.
ใช้แสดงข้อมูลของรายการเป็นคู่ป้ายชื่อกับค่า เช่น แท็บรายละเอียดหรือแผงดูเร็ว ส่งอาร์เรย์ของฟิลด์ตามลำดับที่ต้องการ ถ้าเป็นรายการหลายแถวที่มีคอลัมน์ ใช้ LineItems หรือตาราง ถ้าเป็นตัวเลขสำคัญไม่กี่ตัว ใช้ KeyFigures
import { FieldList } from "@bsru/ui";ตัวอย่าง
รายละเอียดคำขอ
numeric ทำให้ตัวเลข รหัส และวันที่เรียงตรงกัน hint แสดงใต้ค่า ฟิลด์ที่ไม่มี value แสดงขีดยาว และโปรแกรมอ่านหน้าจออ่านว่าไม่มีข้อมูล
- หน่วยงาน
- หน่วยงาน ก
- ผู้ค้า
- บริษัท ตัวอย่าง จำกัด
- เลขประจำตัวผู้เสียภาษี
- 0-1055-XXXXX-XX-1ซ่อนบางส่วนตามสิทธิ์ของคุณ
- รหัสงบประมาณ
- BG-2570-ก-001
- วันที่ขอ
- 1 ต.ค. 2569
- ผู้ขอ
- นายทดสอบ มีสุข
- หมายเหตุ
- ไม่มีข้อมูล
<FieldList
fields={[
{ label: "หน่วยงาน", value: "หน่วยงาน ก" },
{ label: "ผู้ค้า", value: "บริษัท ตัวอย่าง จำกัด" },
{
label: "เลขประจำตัวผู้เสียภาษี",
value: "0-1055-XXXXX-XX-1",
numeric: true,
hint: "ซ่อนบางส่วนตามสิทธิ์ของคุณ",
},
{ label: "รหัสงบประมาณ", value: "BG-2570-ก-001", numeric: true },
{ label: "วันที่ขอ", value: "1 ต.ค. 2569", numeric: true },
{ label: "ผู้ขอ", value: "นายทดสอบ มีสุข" },
{ label: "หมายเหตุ" },
]}
/>| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| fields* จำเป็น | รายการ 7 รายการ[
{ label: "หน่วยงาน", value: "หน่วยงาน ก" },
{ label: "ผู้ค้า", value: "บริษัท ตัวอย่าง จำกัด" },
{
label: "เลขประจำตัวผู้เสียภาษี",
value: "0-1055-XXXXX-XX-1",
numeric: true,
hint: "ซ่อนบางส่วนตามสิทธิ์ของคุณ",
},
{ label: "รหัสงบประมาณ", value: "BG-2570-ก-001", numeric: true },
{ label: "วันที่ขอ", value: "1 ต.ค. 2569", numeric: true },
{ label: "ผู้ขอ", value: "นายทดสอบ มีสุข" },
{ label: "หมายเหตุ" },
] | readonly Field[] | The fields, in the order to show them. |
ค่าเป็นส่วนประกอบ
value รับส่วนประกอบได้ เช่น Badge สำหรับสถานะ จำนวนเงินจัดรูปแบบด้วย money() ก่อนส่ง
- เลขที่
- PR-2570-0001
- สถานะ
- รออนุมัติ
- วงเงิน (บาท)
- 150,000.00
<FieldList
fields={[
{ label: "เลขที่", value: "PR-2570-0001", numeric: true },
{
label: "สถานะ",
value: <Component tone="pending" icon={Clock}>รออนุมัติ</Component>,
},
{ label: "วงเงิน (บาท)", value: "150,000.00", numeric: true },
]}
/>| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| fields* จำเป็น | รายการ 3 รายการ[
{ label: "เลขที่", value: "PR-2570-0001", numeric: true },
{
label: "สถานะ",
value: <Component tone="pending" icon={Clock}>รออนุมัติ</Component>,
},
{ label: "วงเงิน (บาท)", value: "150,000.00", numeric: true },
] | readonly Field[] | The fields, in the order to show them. |
props ทั้งหมด
ตัวอย่างด้านบนใช้ props เพียงบางตัว ตารางนี้แสดงทุกตัวที่คอมโพเนนต์รับ พร้อมค่าเริ่มต้นและค่าที่ใช้ได้
| ชื่อ | ชนิดข้อมูล | ค่าเริ่มต้น | คำอธิบาย |
|---|---|---|---|
| fields* จำเป็น | readonly Field[] | — | The fields, in the order to show them. |
| className | string | — | Classes for the list, such as a top margin. |
ชนิดข้อมูล
Field
One label and value pair in a FieldList.
| ชื่อ | ชนิดข้อมูล | ค่าเริ่มต้น | คำอธิบาย |
|---|---|---|---|
| label* จำเป็น | string | — | The field name. Unique within the list. |
| value | ReactNode | — | Leave out, or pass an empty string, when there is no value: the list shows an em dash, never a blank. |
| hint | string | — | A note under the value, such as why it is partly hidden. |
| numeric | boolean | — | Figures, codes and dates line up in tabular figures. |
ข้อควรปฏิบัติ
- ปิดบังข้อมูลอ่อนไหวก่อนส่ง เช่น เลขประจำตัวผู้เสียภาษี แล้วบอกเหตุผลใน hint
- label ต้องไม่ซ้ำกันในรายการเดียว เพราะใช้เป็น key
- ไม่มีค่าให้ละ value ไว้ อย่าส่งขีดหรือข้อความว่างเอง
ซอร์สโค้ด: ui/src/record.tsx