"use client"
import * as React from "react"
import { useNavigate } from "react-router-dom"
import {
Command,
CommandEmpty,
CommandGroup,
CommandInput,
CommandItem,
CommandList,
} from "@/components/ui/command"
import {
Avatar,
AvatarFallback,
AvatarGroup,
AvatarGroupCount,
AvatarImage,
AvatarInitials,
AvatarStatus,
AvatarVerified,
} from "@/components/ui/avatar"
import { Field, FieldContent, FieldDescription, FieldGroup, FieldLabel } from "@/components/ui/field"
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from "@/components/ui/select"
import { SelectionTileGrid } from "@/components/ui/selection-tile-grid"
import { Tip } from "@/components/ui/tip"
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "@/components/ui/table"
import { ToggleSwitch } from "@/components/ui/toggle-switch"
import { Button } from "@/components/ui/button"
import { ColumnsShowcase } from "@/components/columns-showcase"
import { DataTable } from "@/components/data-table"
import { useTableState } from "@/components/data-table/use-table-state"
import type { ColumnDef } from "@/components/data-table/types"
import { DS_DOC_BODY, DS_DOC_BODY_EMPHASIS } from "@/lib/design-system/doc-typography"
import { useProductDashboardHref } from "@/contexts/product-route-sync"
import { stockPortraitUrl } from "@/lib/stock-portrait"
const DS_PEOPLE = [
{ initials: "AC", name: "Alex Chen" },
{ initials: "MR", name: "Morgan Rivera" },
{ initials: "JT", name: "Jordan Taylor" },
{ initials: "PL", name: "Priya Lakshmi" },
] as const
export function AvatarInitialsPreview() {
return
}
export function AvatarSizesPreview() {
return (
)
}
export function AvatarImagePreview() {
return (
AC
)
}
export function AvatarStatusPreview() {
return (
)
}
export function AvatarGroupPreview() {
const visible = DS_PEOPLE.slice(0, 3)
const overflow = DS_PEOPLE.length - visible.length
return (
{visible.map((person) => (
))}
{overflow > 0 ? (
p.name).join(", ")}
>
+{overflow}
) : null}
)
}
export function AvatarVerifiedPreview() {
return (
)
}
/** @deprecated Use section-specific previews — kept for catalog re-export. */
export function AvatarPreview() {
return
}
export function TablePreview() {
return (
Name
Kind
HubTable
Composition
)
}
/** Full column catalog — same HubTable as `/columns` (Column types showcase). */
export function TableColumnsPreview() {
const navigate = useNavigate()
const dashboardHref = useProductDashboardHref()
const columnsHref = `${dashboardHref.replace(/\/dashboard$/, "")}/columns`
return (
Every shipped cell pattern: person identity, status, progress, currency, rating, tags,
attachments, links, and row actions. Preview shows five rows —{" "}
View more opens the Column types hub.
Select rows to open the floating bulk-action bar.
{}}
embeddedPreview
persistKey="design-system-table-columns"
onEmbeddedPreviewViewMore={() => navigate(columnsHref)}
/>
)
}
type BulkBarDemoRow = {
id: string
name: string
status: string
} & Record
const BULK_BAR_DEMO_ROWS: BulkBarDemoRow[] = [
{ id: "q_101", name: "Diaphragm innervation", status: "Published" },
{ id: "q_102", name: "Brachial plexus roots", status: "Draft" },
{ id: "q_103", name: "Cranial nerve functions", status: "In review" },
{ id: "q_104", name: "Lower limb dermatomes", status: "Published" },
]
const BULK_BAR_DEMO_COLUMNS: ColumnDef[] = [
{ key: "select", label: "", width: 40, minWidth: 40, defaultPin: "left", lockPin: true },
{ key: "name", label: "Question", width: 280 },
{ key: "status", label: "Status", width: 120 },
]
/** Compact grid with two rows pre-selected so the bulk-action bar is visible in docs. */
export function TableBulkActionBarPreview() {
const columns = React.useMemo(() => BULK_BAR_DEMO_COLUMNS, [])
const state = useTableState(BULK_BAR_DEMO_ROWS, columns, { key: "name", dir: "asc" })
const seededRef = React.useRef(false)
React.useEffect(() => {
if (seededRef.current) return
seededRef.current = true
state.setSelected(new Set(["q_101", "q_102"]))
}, [state.setSelected])
return (
Two rows are pre-selected. The bar pins to the viewport bottom, aligned to the table width.
Pass structured bulkActions on{" "}
HubTable or a custom{" "}
bulkActionsSlot on{" "}
DataTable .{" "}
Esc clears selection.
row.id}
getRowSelectionLabel={(row) => row.name}
state={state}
defaultSort={{ key: "name", dir: "asc" }}
emptyState="No questions match your filters."
edgeInset={false}
bulkActionsSlot={() => (
<>
Export
Archive
>
)}
/>
)
}
export function SelectPreview() {
const [value, setValue] = React.useState("pt")
return (
Program
Physical therapy
Nursing
)
}
export function CommandPreview() {
return (
No results.
Go to Library
Open settings
)
}
export function SelectionTileGridPreview() {
const [tile, setTile] = React.useState("csv")
return (
)
}
/** Settings rows — fixed label column prevents wrap in doc examples */
const TOGGLE_SETTINGS_LABEL = "min-w-0 shrink-0 sm:min-w-[9rem]"
export function ToggleSwitchLabelLeftPreview() {
const [on, setOn] = React.useState(true)
return (
Notifications
Email when published
)
}
export function ToggleSwitchLabelRightPreview() {
const [on, setOn] = React.useState(false)
return (
Dark mode
)
}
export function ToggleSwitchGroupPreview() {
const [email, setEmail] = React.useState(true)
const [push, setPush] = React.useState(false)
const [digest, setDigest] = React.useState(true)
return (
Email alerts
Push notifications
Weekly digest
)
}
/** @deprecated Use section-specific previews — kept for catalog re-export. */
export function ToggleSwitchPreview() {
return
}