spst-member-table
These examples do not call the service. Model rendering is a static placeholder.
Source commit: d204666f04a0ee7b6f18543f8aec414b4128874e · shadcn build 4.23.1
Noto Sans JP · @fontsource/noto-sans-jp 5.3.1 · OFL-1.1
Preview
Install (publication pending)
These URLs are planned for publication and are not available yet. Inspect existing file differences before installing; do not use --overwrite by default.
npx shadcn@latest add https://spritestack.dev/r/spst-member-table.jsonAdd to registries in components.json
{"registries":{"@spritestack":"https://spritestack.dev/r/{name}.json"}}npx shadcn@latest add @spritestack/spst-member-tableTargets React 19, Tailwind v4 and shadcn projects with src/. Layouts without src/ are unverified. Installation copies source files; updates are not automatic.
import "./styles/spritestack/theme.css";
<div className="spst-theme" data-theme="light">
{/* Render components here. */}
</div>Pass an element inside .spst-theme to container / portalContainer for portals. Self-host Noto Sans JP weights 400, 600 and 700 in your application; system-ui is the fallback.
Dependencies
Props / API
Generated by parsing the actual source. Rows marked … reference inherited React / Radix public types. — means no default is declared in this function parameter. See the type declarations for union-specific requirements.
src/components/spritestack/member-table.tsx
MemberTable
MemberTable({
messages,
rows,
search,
onSearchChange,
onSuspend,
onRestore,
loading,
error,
pending,
portalContainer,
}: MemberTableProps)| Prop | Type | Required | Default | Event |
|---|---|---|---|---|
messages | Partial<MemberTableMessages> | No | — | — |
rows | readonly MemberRow[] | Yes | — | — |
search | string | Yes | — | — |
onSearchChange | (search: string) => void | Yes | — | Yes |
onSuspend | (id: string) => void | Yes | — | Yes |
onRestore | (id: string) => void | Yes | — | Yes |
loading | boolean | No | — | — |
error | string | No | — | — |
pending | boolean | No | — | — |
portalContainer | HTMLElement | null | No | — | — |
Inspect type declarations and source
// 出典: SpriteStack デザインシステム設計 §4.2・§4.4(Issue 313)。基本部品は同梱の shadcn/ui 派生を合成。
"use client";
import { useState } from "react";
import { Alert } from "../ui/alert";
import {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogTitle,
AlertDialogTrigger,
} from "../ui/alert-dialog";
import { Badge } from "../ui/badge";
import { Button } from "../ui/button";
import { Input } from "../ui/input";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "../ui/table";
export type MemberRow = { id: string; name: string; status: "active" | "suspended" };
export type MemberTableMessages = {
title: string;
search: string;
name: string;
status: string;
actions: string;
loading: string;
error: string;
active: string;
suspended: string;
restore: string;
suspend: string;
confirmTitle: string;
cancel: string;
confirm: string;
empty: string;
restoreLabel: (name: string) => string;
suspendLabel: (name: string) => string;
confirmDescription: (name: string) => string;
};
const defaultMessages: MemberTableMessages = {
title: "会員一覧",
search: "会員を検索",
name: "名前",
status: "状態",
actions: "操作",
loading: "読み込み中",
error: "会員を表示できません",
active: "有効",
suspended: "停止中",
restore: "解除",
suspend: "停止",
confirmTitle: "会員を停止しますか",
cancel: "戻る",
confirm: "停止する",
empty: "会員はありません",
restoreLabel: (name: string) => `${name} の停止を解除`,
suspendLabel: (name: string) => `${name} を停止`,
confirmDescription: (name: string) => `${name} の利用を停止します。`,
};
export type MemberTableProps = {
messages?: Partial<MemberTableMessages>;
rows: readonly MemberRow[];
search: string;
onSearchChange: (search: string) => void;
onSuspend: (id: string) => void;
onRestore: (id: string) => void;
loading?: boolean;
error?: string;
pending?: boolean;
portalContainer?: HTMLElement | null;
};
export function MemberTable({
messages,
rows,
search,
onSearchChange,
onSuspend,
onRestore,
loading,
error,
pending,
portalContainer,
}: MemberTableProps) {
const m = { ...defaultMessages, ...messages };
const [target, setTarget] = useState<string | null>(null);
const blocked = pending || loading || !!error;
return (
<section
data-component="member-table"
className="grid min-w-0 content-start gap-4"
aria-label={m.title}
aria-busy={loading || pending || undefined}
>
<h2 className="text-xl font-(weight:--spst-font-weight-heading)">{m.title}</h2>
<Input
type="search"
aria-label={m.search}
value={search}
disabled={pending}
onChange={(event) => onSearchChange(event.target.value)}
/>
{error && <Alert variant="error">{error}</Alert>}
<Table>
<TableHeader>
<TableRow>
{[m.name, m.status, m.actions].map((name) => (
<TableHead key={name} scope="col">
{name}
</TableHead>
))}
</TableRow>
</TableHeader>
<TableBody>
{loading || error ? (
<TableRow>
<TableCell colSpan={3}>{loading ? m.loading : m.error}</TableCell>
</TableRow>
) : rows.length ? (
rows.map((row) => (
<TableRow key={row.id}>
<TableCell>{row.name}</TableCell>
<TableCell>
<Badge variant={row.status === "active" ? "success" : "neutral"}>
{row.status === "active" ? m.active : m.suspended}
</Badge>
</TableCell>
<TableCell>
{row.status === "suspended" ? (
<Button
disabled={blocked}
onClick={() => onRestore(row.id)}
aria-label={m.restoreLabel(row.name)}
>
{m.restore}
</Button>
) : (
<AlertDialog
open={target === row.id}
onOpenChange={(open) => {
if (!pending) setTarget(open ? row.id : null);
}}
pending={pending}
>
<AlertDialogTrigger asChild>
<Button
variant="outline"
disabled={blocked}
aria-label={m.suspendLabel(row.name)}
>
{m.suspend}
</Button>
</AlertDialogTrigger>
<AlertDialogContent container={portalContainer}>
<AlertDialogTitle>{m.confirmTitle}</AlertDialogTitle>
<AlertDialogDescription>
{m.confirmDescription(row.name)}
</AlertDialogDescription>
<AlertDialogFooter>
<AlertDialogCancel>{m.cancel}</AlertDialogCancel>
<AlertDialogAction
onClick={() => {
if (!blocked) onSuspend(row.id);
}}
>
{m.confirm}
</AlertDialogAction>
</AlertDialogFooter>
</AlertDialogContent>
</AlertDialog>
)}
</TableCell>
</TableRow>
))
) : (
<TableRow>
<TableCell colSpan={3}>{m.empty}</TableCell>
</TableRow>
)}
</TableBody>
</Table>
</section>
);
}
Accessibility requirements
- Give inputs a label or accessible name and associate errors with aria-describedby. Do not communicate state using color alone.
- Provide model names and image fallbacks. Icon-only buttons need accessible names.
- Provide dialog and sheet titles and descriptions, and place portals inside the theme. Test Tab, arrow keys, Escape and focus restoration in the consuming app.
- Slider requires a name and finite min < max. ToggleGroup requires a nonempty single value. The parent controls pending state.
Reference images: 09 · Dark mode and error states extend the reference design.