import { useState } from "react"; import { Card, CardContent, CardDescription, CardHeader, CardTitle, Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "@godxjp/ui/data-display"; import { Flex, PageContainer } from "@godxjp/ui/layout"; import { Pagination } from "@godxjp/ui/navigation"; /** * Pagination — fully controlled offset/page bar. Sits BELOW a table card. * Pass total as raw item count (not page count). onValueChange receives (page, pageSize). * Composed only from real @godxjp/ui components. */ const yen = new Intl.NumberFormat("ja-JP", { style: "currency", currency: "JPY" }); const invoices = Array.from({ length: 47 }, (_, i) => ({ id: `INV-${String(i + 1).padStart(4, "0")}`, partner: ["株式会社山田商事", "有限会社田中工業", "ABC株式会社", "合同会社鈴木", "株式会社佐藤"][ i % 5 ], amount: (i + 1) * 38500 + 12000, status: ["承認済", "未承認", "取消済"][i % 3], })); export default function Demo() { const [page, setPage] = useState(1); const [pageSize, setPageSize] = useState(10); const [simplePage, setSimplePage] = useState(1); const start = (page - 1) * pageSize; const pageData = invoices.slice(start, start + pageSize); function handleChange(p: number, ps: number) { setPage(p); setPageSize(ps); } return ( {/* Full pagination below a Table */} 請求書一覧 (47 件) Pagination sits BELOW the card. value + pageSize are controlled state. showTotal shows the built-in i18n count label. showSizeChanger lets users pick rows per page. 番号 取引先 金額 (円) ステータス {pageData.map((inv) => ( {inv.id} {inv.partner} {yen.format(inv.amount)} {inv.status} ))}
{/* Pagination component itself — outside the card, below it */} {/* Regression: total=0, exactly one page, multiple pages, + the single-page opt-in. */} 境界状態 · 0 件 / 1 ページ / 複数ページ Pagination は複数ページ間のナビゲーション。0 件と 1 ページ(total ≤ pageSize)は 既定で「非表示」になる(下の 2 例は何もレンダリングしない)。合計だけ見せたい 1 ページでは hideOnSinglePage={"{false}"} で明示的にオプトインする。複数ページでは 1 行のまま折り返さずに全ページャを表示する。 {/* total=0 → hidden (nothing renders). */} {/* exactly one page → hidden by default (nothing renders). */} {/* single-page opt-in → the bar renders so the total stays visible. */} `${from}〜${to} / ${total} 件`} ariaLabel="1 ページのみ・opt-in 表示のページネーション" /> {/* multiple pages → full pager, one horizontal row, no wrap. */} {}} ariaLabel="複数ページの境界状態のページネーション" /> {/* Long localized total label — the row stays ONE line and never wraps on desktop. */} 長いローカライズ済みラベル · 折り返さない 長い合計ラベル(JA/VI)でも Pagination は 1 行を維持する。ラベルは省略記号で切り詰め、 ページ送りを 2 行目に押し出さない。 `${from.toLocaleString("ja-JP")}〜${to.toLocaleString("ja-JP")} 件目 / 全 ${total.toLocaleString("ja-JP")} 件の請求書を表示中` } onValueChange={() => {}} ariaLabel="日本語ラベルのページネーション" /> `Đang hiển thị ${from}–${to} trong tổng số ${total.toLocaleString("vi-VN")} hoá đơn` } onValueChange={() => {}} ariaLabel="Phân trang nhãn tiếng Việt" /> {/* showTotal custom label */} showTotal · カスタムラベル関数 showTotal に関数を渡すと範囲ラベルをカスタマイズできる。 例: "1〜10 / 47 件の請求書" `${from}〜${to} / ${total} 件の請求書`} onValueChange={handleChange} /> {/* Simple mode for compact contexts */} Simple モード · コンパクト表示 simple=true でモーダルフッターやサイドバーに収まるコンパクトな Prev / n/total / Next を表示する。 setSimplePage(p)} /> {/* Disabled state */} Disabled 状態 disabled=true でデータ読み込み中などページ送りを一時的に無効にする。 {}} /> {/* Ant Design parity surface — showQuickJumper / size / align / responsive */} showQuickJumper · size · align (Ant Design パリティ) showQuickJumper はページ番号を直接入力するフィールド(Enter または goButton で確定、範囲外はクランプ)。size="sm" はバーに --control-height を一度だけ再束縛するので、ページボタン・サイズ変更・ジャンプ欄が同時に縮む。align は論理軸(start / center / end)。responsive は既定で有効で、モバイル幅では simple 形態に畳む。
{}} />
{}} />
{}} />
); }