From 1a2241c40e10193c5ff7008a7b7b36cc1d855d96 Mon Sep 17 00:00:00 2001 From: joonhoekim <26rote@gmail.com> Date: Tue, 25 Mar 2025 15:55:45 +0900 Subject: initial commit --- components/data-table/data-table-pin-right.tsx | 88 ++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 components/data-table/data-table-pin-right.tsx (limited to 'components/data-table/data-table-pin-right.tsx') diff --git a/components/data-table/data-table-pin-right.tsx b/components/data-table/data-table-pin-right.tsx new file mode 100644 index 00000000..051dd985 --- /dev/null +++ b/components/data-table/data-table-pin-right.tsx @@ -0,0 +1,88 @@ +"use client" + +import * as React from "react" +import { type Table } from "@tanstack/react-table" +import { Check, ChevronsUpDown, MoveRight } from "lucide-react" + +import { cn, toSentenceCase } from "@/lib/utils" +import { Button } from "@/components/ui/button" +import { + Command, + CommandEmpty, + CommandGroup, + CommandInput, + CommandItem, + CommandList, +} from "@/components/ui/command" +import { + Popover, + PopoverContent, + PopoverTrigger, +} from "@/components/ui/popover" + +/** + * “Pin Right” Popover. Similar to PinLeftButton, but pins columns to "right". + */ +export function PinRightButton({ table }: { table: Table }) { + const [open, setOpen] = React.useState(false) + const triggerRef = React.useRef(null) + + return ( + + + + + + triggerRef.current?.focus()} + > + + + + No columns found. + + {table + .getAllLeafColumns() + .filter((col) => col.getCanPin?.()) + .map((column) => { + const pinned = column.getIsPinned?.() + return ( + { + column.pin?.(pinned === "right" ? false : "right") + }} + > + + {toSentenceCase(column.id)} + + + + ) + })} + + + + + + ) +} \ No newline at end of file -- cgit v1.2.3