Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the user info to use example instead #6766

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/www/app/(app)/examples/mail/data.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ export const accounts = [
},
{
label: "Alicia Koch",
email: "alicia@gmail.com",
email: "alicia@example.com",
icon: (
<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<title>Gmail</title>
Expand All @@ -199,7 +199,7 @@ export const accounts = [
},
{
label: "Alicia Koch",
email: "alicia@me.com",
email: "alicia@example.com",
icon: (
<svg role="img" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
<title>iCloud</title>
Expand Down
8 changes: 4 additions & 4 deletions apps/www/components/cards/data-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,25 +48,25 @@ const data: Payment[] = [
id: "m5gr84i9",
amount: 316,
status: "success",
email: "ken99@yahoo.com",
email: "ken99@example.com",
},
{
id: "3u1reuv4",
amount: 242,
status: "success",
email: "Abe45@gmail.com",
email: "Abe45@example.com",
},
{
id: "derv1ws0",
amount: 837,
status: "processing",
email: "Monserrat44@gmail.com",
email: "Monserrat44@example.com",
},
{
id: "bhqecj4p",
amount: 721,
status: "failed",
email: "carmella@hotmail.com",
email: "carmella@example.com",
},
]

Expand Down
2 changes: 1 addition & 1 deletion apps/www/public/r/styles/default/data-table-demo.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"files": [
{
"path": "examples/data-table-demo.tsx",
"content": "\"use client\"\n\nimport * as React from \"react\"\nimport {\n ColumnDef,\n ColumnFiltersState,\n SortingState,\n VisibilityState,\n flexRender,\n getCoreRowModel,\n getFilteredRowModel,\n getPaginationRowModel,\n getSortedRowModel,\n useReactTable,\n} from \"@tanstack/react-table\"\nimport { ArrowUpDown, ChevronDown, MoreHorizontal } from \"lucide-react\"\n\nimport { Button } from \"@/registry/default/ui/button\"\nimport { Checkbox } from \"@/registry/default/ui/checkbox\"\nimport {\n DropdownMenu,\n DropdownMenuCheckboxItem,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuLabel,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n} from \"@/registry/default/ui/dropdown-menu\"\nimport { Input } from \"@/registry/default/ui/input\"\nimport {\n Table,\n TableBody,\n TableCell,\n TableHead,\n TableHeader,\n TableRow,\n} from \"@/registry/default/ui/table\"\n\nconst data: Payment[] = [\n {\n id: \"m5gr84i9\",\n amount: 316,\n status: \"success\",\n email: \"[email protected]\",\n },\n {\n id: \"3u1reuv4\",\n amount: 242,\n status: \"success\",\n email: \"[email protected]\",\n },\n {\n id: \"derv1ws0\",\n amount: 837,\n status: \"processing\",\n email: \"[email protected]\",\n },\n {\n id: \"5kma53ae\",\n amount: 874,\n status: \"success\",\n email: \"[email protected]\",\n },\n {\n id: \"bhqecj4p\",\n amount: 721,\n status: \"failed\",\n email: \"[email protected]\",\n },\n]\n\nexport type Payment = {\n id: string\n amount: number\n status: \"pending\" | \"processing\" | \"success\" | \"failed\"\n email: string\n}\n\nexport const columns: ColumnDef<Payment>[] = [\n {\n id: \"select\",\n header: ({ table }) => (\n <Checkbox\n checked={\n table.getIsAllPageRowsSelected() ||\n (table.getIsSomePageRowsSelected() && \"indeterminate\")\n }\n onCheckedChange={(value) => table.toggleAllPageRowsSelected(!!value)}\n aria-label=\"Select all\"\n />\n ),\n cell: ({ row }) => (\n <Checkbox\n checked={row.getIsSelected()}\n onCheckedChange={(value) => row.toggleSelected(!!value)}\n aria-label=\"Select row\"\n />\n ),\n enableSorting: false,\n enableHiding: false,\n },\n {\n accessorKey: \"status\",\n header: \"Status\",\n cell: ({ row }) => (\n <div className=\"capitalize\">{row.getValue(\"status\")}</div>\n ),\n },\n {\n accessorKey: \"email\",\n header: ({ column }) => {\n return (\n <Button\n variant=\"ghost\"\n onClick={() => column.toggleSorting(column.getIsSorted() === \"asc\")}\n >\n Email\n <ArrowUpDown />\n </Button>\n )\n },\n cell: ({ row }) => <div className=\"lowercase\">{row.getValue(\"email\")}</div>,\n },\n {\n accessorKey: \"amount\",\n header: () => <div className=\"text-right\">Amount</div>,\n cell: ({ row }) => {\n const amount = parseFloat(row.getValue(\"amount\"))\n\n // Format the amount as a dollar amount\n const formatted = new Intl.NumberFormat(\"en-US\", {\n style: \"currency\",\n currency: \"USD\",\n }).format(amount)\n\n return <div className=\"text-right font-medium\">{formatted}</div>\n },\n },\n {\n id: \"actions\",\n enableHiding: false,\n cell: ({ row }) => {\n const payment = row.original\n\n return (\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button variant=\"ghost\" className=\"h-8 w-8 p-0\">\n <span className=\"sr-only\">Open menu</span>\n <MoreHorizontal />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\">\n <DropdownMenuLabel>Actions</DropdownMenuLabel>\n <DropdownMenuItem\n onClick={() => navigator.clipboard.writeText(payment.id)}\n >\n Copy payment ID\n </DropdownMenuItem>\n <DropdownMenuSeparator />\n <DropdownMenuItem>View customer</DropdownMenuItem>\n <DropdownMenuItem>View payment details</DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n )\n },\n },\n]\n\nexport default function DataTableDemo() {\n const [sorting, setSorting] = React.useState<SortingState>([])\n const [columnFilters, setColumnFilters] = React.useState<ColumnFiltersState>(\n []\n )\n const [columnVisibility, setColumnVisibility] =\n React.useState<VisibilityState>({})\n const [rowSelection, setRowSelection] = React.useState({})\n\n const table = useReactTable({\n data,\n columns,\n onSortingChange: setSorting,\n onColumnFiltersChange: setColumnFilters,\n getCoreRowModel: getCoreRowModel(),\n getPaginationRowModel: getPaginationRowModel(),\n getSortedRowModel: getSortedRowModel(),\n getFilteredRowModel: getFilteredRowModel(),\n onColumnVisibilityChange: setColumnVisibility,\n onRowSelectionChange: setRowSelection,\n state: {\n sorting,\n columnFilters,\n columnVisibility,\n rowSelection,\n },\n })\n\n return (\n <div className=\"w-full\">\n <div className=\"flex items-center py-4\">\n <Input\n placeholder=\"Filter emails...\"\n value={(table.getColumn(\"email\")?.getFilterValue() as string) ?? \"\"}\n onChange={(event) =>\n table.getColumn(\"email\")?.setFilterValue(event.target.value)\n }\n className=\"max-w-sm\"\n />\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button variant=\"outline\" className=\"ml-auto\">\n Columns <ChevronDown />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\">\n {table\n .getAllColumns()\n .filter((column) => column.getCanHide())\n .map((column) => {\n return (\n <DropdownMenuCheckboxItem\n key={column.id}\n className=\"capitalize\"\n checked={column.getIsVisible()}\n onCheckedChange={(value) =>\n column.toggleVisibility(!!value)\n }\n >\n {column.id}\n </DropdownMenuCheckboxItem>\n )\n })}\n </DropdownMenuContent>\n </DropdownMenu>\n </div>\n <div className=\"rounded-md border\">\n <Table>\n <TableHeader>\n {table.getHeaderGroups().map((headerGroup) => (\n <TableRow key={headerGroup.id}>\n {headerGroup.headers.map((header) => {\n return (\n <TableHead key={header.id}>\n {header.isPlaceholder\n ? null\n : flexRender(\n header.column.columnDef.header,\n header.getContext()\n )}\n </TableHead>\n )\n })}\n </TableRow>\n ))}\n </TableHeader>\n <TableBody>\n {table.getRowModel().rows?.length ? (\n table.getRowModel().rows.map((row) => (\n <TableRow\n key={row.id}\n data-state={row.getIsSelected() && \"selected\"}\n >\n {row.getVisibleCells().map((cell) => (\n <TableCell key={cell.id}>\n {flexRender(\n cell.column.columnDef.cell,\n cell.getContext()\n )}\n </TableCell>\n ))}\n </TableRow>\n ))\n ) : (\n <TableRow>\n <TableCell\n colSpan={columns.length}\n className=\"h-24 text-center\"\n >\n No results.\n </TableCell>\n </TableRow>\n )}\n </TableBody>\n </Table>\n </div>\n <div className=\"flex items-center justify-end space-x-2 py-4\">\n <div className=\"flex-1 text-sm text-muted-foreground\">\n {table.getFilteredSelectedRowModel().rows.length} of{\" \"}\n {table.getFilteredRowModel().rows.length} row(s) selected.\n </div>\n <div className=\"space-x-2\">\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={() => table.previousPage()}\n disabled={!table.getCanPreviousPage()}\n >\n Previous\n </Button>\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={() => table.nextPage()}\n disabled={!table.getCanNextPage()}\n >\n Next\n </Button>\n </div>\n </div>\n </div>\n )\n}\n",
"content": "\"use client\"\n\nimport * as React from \"react\"\nimport {\n ColumnDef,\n ColumnFiltersState,\n SortingState,\n VisibilityState,\n flexRender,\n getCoreRowModel,\n getFilteredRowModel,\n getPaginationRowModel,\n getSortedRowModel,\n useReactTable,\n} from \"@tanstack/react-table\"\nimport { ArrowUpDown, ChevronDown, MoreHorizontal } from \"lucide-react\"\n\nimport { Button } from \"@/registry/default/ui/button\"\nimport { Checkbox } from \"@/registry/default/ui/checkbox\"\nimport {\n DropdownMenu,\n DropdownMenuCheckboxItem,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuLabel,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n} from \"@/registry/default/ui/dropdown-menu\"\nimport { Input } from \"@/registry/default/ui/input\"\nimport {\n Table,\n TableBody,\n TableCell,\n TableHead,\n TableHeader,\n TableRow,\n} from \"@/registry/default/ui/table\"\n\nconst data: Payment[] = [\n {\n id: \"m5gr84i9\",\n amount: 316,\n status: \"success\",\n email: \"[email protected]\",\n },\n {\n id: \"3u1reuv4\",\n amount: 242,\n status: \"success\",\n email: \"[email protected]\",\n },\n {\n id: \"derv1ws0\",\n amount: 837,\n status: \"processing\",\n email: \"[email protected]\",\n },\n {\n id: \"5kma53ae\",\n amount: 874,\n status: \"success\",\n email: \"[email protected]\",\n },\n {\n id: \"bhqecj4p\",\n amount: 721,\n status: \"failed\",\n email: \"[email protected]\",\n },\n]\n\nexport type Payment = {\n id: string\n amount: number\n status: \"pending\" | \"processing\" | \"success\" | \"failed\"\n email: string\n}\n\nexport const columns: ColumnDef<Payment>[] = [\n {\n id: \"select\",\n header: ({ table }) => (\n <Checkbox\n checked={\n table.getIsAllPageRowsSelected() ||\n (table.getIsSomePageRowsSelected() && \"indeterminate\")\n }\n onCheckedChange={(value) => table.toggleAllPageRowsSelected(!!value)}\n aria-label=\"Select all\"\n />\n ),\n cell: ({ row }) => (\n <Checkbox\n checked={row.getIsSelected()}\n onCheckedChange={(value) => row.toggleSelected(!!value)}\n aria-label=\"Select row\"\n />\n ),\n enableSorting: false,\n enableHiding: false,\n },\n {\n accessorKey: \"status\",\n header: \"Status\",\n cell: ({ row }) => (\n <div className=\"capitalize\">{row.getValue(\"status\")}</div>\n ),\n },\n {\n accessorKey: \"email\",\n header: ({ column }) => {\n return (\n <Button\n variant=\"ghost\"\n onClick={() => column.toggleSorting(column.getIsSorted() === \"asc\")}\n >\n Email\n <ArrowUpDown />\n </Button>\n )\n },\n cell: ({ row }) => <div className=\"lowercase\">{row.getValue(\"email\")}</div>,\n },\n {\n accessorKey: \"amount\",\n header: () => <div className=\"text-right\">Amount</div>,\n cell: ({ row }) => {\n const amount = parseFloat(row.getValue(\"amount\"))\n\n // Format the amount as a dollar amount\n const formatted = new Intl.NumberFormat(\"en-US\", {\n style: \"currency\",\n currency: \"USD\",\n }).format(amount)\n\n return <div className=\"text-right font-medium\">{formatted}</div>\n },\n },\n {\n id: \"actions\",\n enableHiding: false,\n cell: ({ row }) => {\n const payment = row.original\n\n return (\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button variant=\"ghost\" className=\"h-8 w-8 p-0\">\n <span className=\"sr-only\">Open menu</span>\n <MoreHorizontal />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\">\n <DropdownMenuLabel>Actions</DropdownMenuLabel>\n <DropdownMenuItem\n onClick={() => navigator.clipboard.writeText(payment.id)}\n >\n Copy payment ID\n </DropdownMenuItem>\n <DropdownMenuSeparator />\n <DropdownMenuItem>View customer</DropdownMenuItem>\n <DropdownMenuItem>View payment details</DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n )\n },\n },\n]\n\nexport default function DataTableDemo() {\n const [sorting, setSorting] = React.useState<SortingState>([])\n const [columnFilters, setColumnFilters] = React.useState<ColumnFiltersState>(\n []\n )\n const [columnVisibility, setColumnVisibility] =\n React.useState<VisibilityState>({})\n const [rowSelection, setRowSelection] = React.useState({})\n\n const table = useReactTable({\n data,\n columns,\n onSortingChange: setSorting,\n onColumnFiltersChange: setColumnFilters,\n getCoreRowModel: getCoreRowModel(),\n getPaginationRowModel: getPaginationRowModel(),\n getSortedRowModel: getSortedRowModel(),\n getFilteredRowModel: getFilteredRowModel(),\n onColumnVisibilityChange: setColumnVisibility,\n onRowSelectionChange: setRowSelection,\n state: {\n sorting,\n columnFilters,\n columnVisibility,\n rowSelection,\n },\n })\n\n return (\n <div className=\"w-full\">\n <div className=\"flex items-center py-4\">\n <Input\n placeholder=\"Filter emails...\"\n value={(table.getColumn(\"email\")?.getFilterValue() as string) ?? \"\"}\n onChange={(event) =>\n table.getColumn(\"email\")?.setFilterValue(event.target.value)\n }\n className=\"max-w-sm\"\n />\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button variant=\"outline\" className=\"ml-auto\">\n Columns <ChevronDown />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\">\n {table\n .getAllColumns()\n .filter((column) => column.getCanHide())\n .map((column) => {\n return (\n <DropdownMenuCheckboxItem\n key={column.id}\n className=\"capitalize\"\n checked={column.getIsVisible()}\n onCheckedChange={(value) =>\n column.toggleVisibility(!!value)\n }\n >\n {column.id}\n </DropdownMenuCheckboxItem>\n )\n })}\n </DropdownMenuContent>\n </DropdownMenu>\n </div>\n <div className=\"rounded-md border\">\n <Table>\n <TableHeader>\n {table.getHeaderGroups().map((headerGroup) => (\n <TableRow key={headerGroup.id}>\n {headerGroup.headers.map((header) => {\n return (\n <TableHead key={header.id}>\n {header.isPlaceholder\n ? null\n : flexRender(\n header.column.columnDef.header,\n header.getContext()\n )}\n </TableHead>\n )\n })}\n </TableRow>\n ))}\n </TableHeader>\n <TableBody>\n {table.getRowModel().rows?.length ? (\n table.getRowModel().rows.map((row) => (\n <TableRow\n key={row.id}\n data-state={row.getIsSelected() && \"selected\"}\n >\n {row.getVisibleCells().map((cell) => (\n <TableCell key={cell.id}>\n {flexRender(\n cell.column.columnDef.cell,\n cell.getContext()\n )}\n </TableCell>\n ))}\n </TableRow>\n ))\n ) : (\n <TableRow>\n <TableCell\n colSpan={columns.length}\n className=\"h-24 text-center\"\n >\n No results.\n </TableCell>\n </TableRow>\n )}\n </TableBody>\n </Table>\n </div>\n <div className=\"flex items-center justify-end space-x-2 py-4\">\n <div className=\"flex-1 text-sm text-muted-foreground\">\n {table.getFilteredSelectedRowModel().rows.length} of{\" \"}\n {table.getFilteredRowModel().rows.length} row(s) selected.\n </div>\n <div className=\"space-x-2\">\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={() => table.previousPage()}\n disabled={!table.getCanPreviousPage()}\n >\n Previous\n </Button>\n <Button\n variant=\"outline\"\n size=\"sm\"\n onClick={() => table.nextPage()}\n disabled={!table.getCanNextPage()}\n >\n Next\n </Button>\n </div>\n </div>\n </div>\n )\n}\n",
"type": "registry:example",
"target": ""
}
Expand Down
Loading