ตารางที่ยังไม่มีข้อมูล
TableFirstUse
Shown instead of the whole table when nothing exists yet, on first use: no headers, search, criteria, pager or total. Say what will appear here and what to do. Pass the action only when the user may create a record.
ใช้แทนตารางทั้งหมดเมื่อยังไม่มีข้อมูลเลย เช่น ใช้งานครั้งแรก โดยไม่มีหัวตาราง ช่องค้นหา เงื่อนไข ตัวแบ่งหน้า หรือยอดรวม ถ้ามีข้อมูลแต่ค้นหาไม่พบ หรือโหลดไม่สำเร็จ ใช้ TableState ในตาราง
import { TableFirstUse } from "@bsru/ui";ตัวอย่าง
ผู้ใช้สร้างรายการได้
บอกว่าอะไรจะแสดงที่นี่ และให้ปุ่มสร้างรายการแรก ไอคอนเริ่มต้นคือ Inbox
ยังไม่มีคำขอซื้อขอจ้าง
คำขอที่คุณสร้างหรือที่รอคุณอนุมัติจะแสดงที่นี่
<TableFirstUse
title="ยังไม่มีคำขอซื้อขอจ้าง"
body="คำขอที่คุณสร้างหรือที่รอคุณอนุมัติจะแสดงที่นี่"
action={<Component
label="สร้างคำขอ"
tone="primary"
icon={Plus}
onClick={handleClick}
/>}
/>| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| title* จำเป็น | "ยังไม่มีคำขอซื้อขอจ้าง" | string | Says there are no records yet, such as ยังไม่มีคำขอซื้อขอจ้าง. |
| body* จำเป็น | "คำขอที่คุณสร้างหรือที่รอคุณอนุมัติจะแสดงที่นี่" | string | Says what will appear here, and how it gets here. |
| action | <Component
label="สร้างคำขอ"
tone="primary"
icon={Plus}
onClick={handleClick}
/> | ReactNode | The button that creates the first record. Leave out for people who may not create one. |
ผู้ใช้ดูได้อย่างเดียว
ไม่ส่ง action เมื่อผู้ใช้ไม่มีสิทธิ์สร้าง แล้วบอกว่ารายการจะมาจากไหน ส่ง icon ให้ตรงกับชนิดของรายการ
ยังไม่มีใบสำคัญจ่าย
ใบสำคัญจ่ายจะแสดงที่นี่เมื่อการเงินบันทึกการจ่ายเงินตามคำขอที่อนุมัติแล้ว
<TableFirstUse
icon={ReceiptText}
title="ยังไม่มีใบสำคัญจ่าย"
body="ใบสำคัญจ่ายจะแสดงที่นี่เมื่อการเงินบันทึกการจ่ายเงินตามคำขอที่อนุมัติแล้ว"
/>| Prop | ค่าในตัวอย่างนี้ | ชนิดข้อมูล | คำอธิบาย |
|---|---|---|---|
| icon | ReceiptText | LucideIcon | A Lucide icon for the kind of record. |
| title* จำเป็น | "ยังไม่มีใบสำคัญจ่าย" | string | Says there are no records yet, such as ยังไม่มีคำขอซื้อขอจ้าง. |
| body* จำเป็น | "ใบสำคัญจ่ายจะแสดงที่นี่เมื่อการเงินบันทึกการจ่ายเงินตามคำขอที่อนุมัติแล้ว" | string | Says what will appear here, and how it gets here. |
props ทั้งหมด
ตัวอย่างด้านบนใช้ props เพียงบางตัว ตารางนี้แสดงทุกตัวที่คอมโพเนนต์รับ พร้อมค่าเริ่มต้นและค่าที่ใช้ได้
| ชื่อ | ชนิดข้อมูล | ค่าเริ่มต้น | คำอธิบาย |
|---|---|---|---|
| icon | LucideIcon | Inbox | A Lucide icon for the kind of record. |
| title* จำเป็น | string | — | Says there are no records yet, such as ยังไม่มีคำขอซื้อขอจ้าง. |
| body* จำเป็น | string | — | Says what will appear here, and how it gets here. |
| action | ReactNode | — | The button that creates the first record. Leave out for people who may not create one. |
ข้อควรปฏิบัติ
- แสดงปุ่มสร้างเฉพาะผู้ที่มีสิทธิ์สร้าง ตามสิทธิ์จาก core API
- ส่ง title และ body ในภาษาของหน้าจอ เขียนสั้นและบอกสิ่งที่ทำต่อได้
- บอกว่ายังไม่มีข้อมูลใน live region ของหน้า เหมือนสถานะอื่นของตาราง
ซอร์สโค้ด: ui/src/data-table.tsx