fixed table, changed color
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { useRef, useState } from 'react'
|
||||
import { useRef, useState } from "react";
|
||||
import {
|
||||
flexRender,
|
||||
getCoreRowModel,
|
||||
@@ -8,16 +8,9 @@ import {
|
||||
type RowSelectionState,
|
||||
type SortingState,
|
||||
getSortedRowModel,
|
||||
} from '@tanstack/react-table'
|
||||
import {
|
||||
Table,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeader,
|
||||
TableRow,
|
||||
} from '@/components/ui/table'
|
||||
import { Checkbox } from '@/components/ui/checkbox'
|
||||
} from "@tanstack/react-table";
|
||||
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
|
||||
import { Checkbox } from "@/components/ui/checkbox";
|
||||
import {
|
||||
Pagination,
|
||||
PaginationContent,
|
||||
@@ -26,45 +19,41 @@ import {
|
||||
PaginationLink,
|
||||
PaginationNext,
|
||||
PaginationPrevious,
|
||||
} from '@/components/ui/pagination'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { useOutsideClick } from '@/lib/hooks/useOutsideClick'
|
||||
import { ChevronDown } from 'lucide-react'
|
||||
} from "@/components/ui/pagination";
|
||||
import { cn } from "@/lib/utils";
|
||||
import { useOutsideClick } from "@/lib/hooks/useOutsideClick";
|
||||
import { ChevronDown } from "lucide-react";
|
||||
|
||||
export type { ColumnDef }
|
||||
export type { ColumnDef };
|
||||
|
||||
// ─── Pagination ───────────────────────────────────────────────────────────────
|
||||
|
||||
interface DataTablePaginationProps {
|
||||
currentPage: number
|
||||
totalPages: number
|
||||
onPageChange: (page: number) => void
|
||||
currentPage: number;
|
||||
totalPages: number;
|
||||
onPageChange: (page: number) => void;
|
||||
}
|
||||
|
||||
function DataTablePagination({
|
||||
currentPage,
|
||||
totalPages,
|
||||
onPageChange,
|
||||
}: DataTablePaginationProps) {
|
||||
if (totalPages <= 1) return null
|
||||
function DataTablePagination({ currentPage, totalPages, onPageChange }: DataTablePaginationProps) {
|
||||
if (totalPages <= 1) return null;
|
||||
|
||||
const getPages = (): (number | 'ellipsis')[] => {
|
||||
if (totalPages <= 7) return Array.from({ length: totalPages }, (_, i) => i + 1)
|
||||
const getPages = (): (number | "ellipsis")[] => {
|
||||
if (totalPages <= 7) return Array.from({ length: totalPages }, (_, i) => i + 1);
|
||||
|
||||
const pages: (number | 'ellipsis')[] = [1]
|
||||
const pages: (number | "ellipsis")[] = [1];
|
||||
|
||||
if (currentPage > 3) pages.push('ellipsis')
|
||||
if (currentPage > 3) pages.push("ellipsis");
|
||||
|
||||
const start = Math.max(2, currentPage - 1)
|
||||
const end = Math.min(totalPages - 1, currentPage + 1)
|
||||
const start = Math.max(2, currentPage - 1);
|
||||
const end = Math.min(totalPages - 1, currentPage + 1);
|
||||
|
||||
for (let i = start; i <= end; i++) pages.push(i)
|
||||
for (let i = start; i <= end; i++) pages.push(i);
|
||||
|
||||
if (currentPage < totalPages - 2) pages.push('ellipsis')
|
||||
if (currentPage < totalPages - 2) pages.push("ellipsis");
|
||||
|
||||
pages.push(totalPages)
|
||||
return pages
|
||||
}
|
||||
pages.push(totalPages);
|
||||
return pages;
|
||||
};
|
||||
|
||||
return (
|
||||
<Pagination className="justify-center mt-3">
|
||||
@@ -73,15 +62,15 @@ function DataTablePagination({
|
||||
<PaginationPrevious
|
||||
href="#"
|
||||
onClick={(e) => {
|
||||
e.preventDefault()
|
||||
if (currentPage > 1) onPageChange(currentPage - 1)
|
||||
e.preventDefault();
|
||||
if (currentPage > 1) onPageChange(currentPage - 1);
|
||||
}}
|
||||
className={cn(currentPage === 1 && 'pointer-events-none opacity-40')}
|
||||
className={cn(currentPage === 1 && "pointer-events-none opacity-40")}
|
||||
/>
|
||||
</PaginationItem>
|
||||
|
||||
{getPages().map((page, i) =>
|
||||
page === 'ellipsis' ? (
|
||||
page === "ellipsis" ? (
|
||||
<PaginationItem key={`ellipsis-${i}`}>
|
||||
<PaginationEllipsis />
|
||||
</PaginationItem>
|
||||
@@ -91,43 +80,43 @@ function DataTablePagination({
|
||||
href="#"
|
||||
isActive={page === currentPage}
|
||||
onClick={(e) => {
|
||||
e.preventDefault()
|
||||
onPageChange(page)
|
||||
e.preventDefault();
|
||||
onPageChange(page);
|
||||
}}
|
||||
>
|
||||
{page}
|
||||
</PaginationLink>
|
||||
</PaginationItem>
|
||||
)
|
||||
),
|
||||
)}
|
||||
|
||||
<PaginationItem>
|
||||
<PaginationNext
|
||||
href="#"
|
||||
onClick={(e) => {
|
||||
e.preventDefault()
|
||||
if (currentPage < totalPages) onPageChange(currentPage + 1)
|
||||
e.preventDefault();
|
||||
if (currentPage < totalPages) onPageChange(currentPage + 1);
|
||||
}}
|
||||
className={cn(currentPage === totalPages && 'pointer-events-none opacity-40')}
|
||||
className={cn(currentPage === totalPages && "pointer-events-none opacity-40")}
|
||||
/>
|
||||
</PaginationItem>
|
||||
</PaginationContent>
|
||||
</Pagination>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// ─── Select All Dropdown ──────────────────────────────────────────────────────
|
||||
|
||||
interface SelectAllDropdownProps {
|
||||
isAllPageSelected: boolean
|
||||
isSomePageSelected: boolean
|
||||
isAllTotalSelected: boolean
|
||||
totalCount: number
|
||||
pageCount: number
|
||||
onTogglePage: (checked: boolean) => void
|
||||
onSelectThisPage: () => void
|
||||
onSelectAll: () => void
|
||||
onClearAll: () => void
|
||||
isAllPageSelected: boolean;
|
||||
isSomePageSelected: boolean;
|
||||
isAllTotalSelected: boolean;
|
||||
totalCount: number;
|
||||
pageCount: number;
|
||||
onTogglePage: (checked: boolean) => void;
|
||||
onSelectThisPage: () => void;
|
||||
onSelectAll: () => void;
|
||||
onClearAll: () => void;
|
||||
}
|
||||
|
||||
function SelectAllDropdown({
|
||||
@@ -141,15 +130,11 @@ function SelectAllDropdown({
|
||||
onSelectAll,
|
||||
onClearAll,
|
||||
}: SelectAllDropdownProps) {
|
||||
const [open, setOpen] = useState(false)
|
||||
const ref = useRef<HTMLDivElement>(null)
|
||||
useOutsideClick(ref, () => setOpen(false))
|
||||
const [open, setOpen] = useState(false);
|
||||
const ref = useRef<HTMLDivElement>(null);
|
||||
useOutsideClick(ref, () => setOpen(false));
|
||||
|
||||
const checkboxChecked = isAllTotalSelected || isAllPageSelected
|
||||
? true
|
||||
: isSomePageSelected
|
||||
? 'indeterminate'
|
||||
: false
|
||||
const checkboxChecked = isAllTotalSelected || isAllPageSelected ? true : isSomePageSelected ? "indeterminate" : false;
|
||||
|
||||
return (
|
||||
<div ref={ref} className="flex items-center gap-1">
|
||||
@@ -163,9 +148,9 @@ function SelectAllDropdown({
|
||||
<button
|
||||
type="button"
|
||||
onClick={(e) => {
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
setOpen((v) => !v)
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
setOpen((v) => !v);
|
||||
}}
|
||||
className="relative z-10 flex items-center justify-center w-5 h-5 text-muted-foreground hover:text-foreground hover:bg-muted transition-colors rounded"
|
||||
aria-label="Selection options"
|
||||
@@ -178,10 +163,10 @@ function SelectAllDropdown({
|
||||
<button
|
||||
type="button"
|
||||
onClick={(e) => {
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
onSelectThisPage()
|
||||
setOpen(false)
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
onSelectThisPage();
|
||||
setOpen(false);
|
||||
}}
|
||||
className="w-full text-left px-3 py-2 text-sm hover:bg-muted/50 transition-colors"
|
||||
>
|
||||
@@ -191,10 +176,10 @@ function SelectAllDropdown({
|
||||
<button
|
||||
type="button"
|
||||
onClick={(e) => {
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
onSelectAll()
|
||||
setOpen(false)
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
onSelectAll();
|
||||
setOpen(false);
|
||||
}}
|
||||
className="w-full text-left px-3 py-2 text-sm hover:bg-muted/50 transition-colors"
|
||||
>
|
||||
@@ -207,10 +192,10 @@ function SelectAllDropdown({
|
||||
<button
|
||||
type="button"
|
||||
onClick={(e) => {
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
onClearAll()
|
||||
setOpen(false)
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
onClearAll();
|
||||
setOpen(false);
|
||||
}}
|
||||
className="w-full text-left px-3 py-2 text-sm text-destructive hover:bg-destructive/10 transition-colors"
|
||||
>
|
||||
@@ -221,31 +206,32 @@ function SelectAllDropdown({
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// ─── DataTable ────────────────────────────────────────────────────────────────
|
||||
|
||||
interface DataTableProps<TData> {
|
||||
columns: ColumnDef<TData>[]
|
||||
data: TData[]
|
||||
isLoading?: boolean
|
||||
columnVisibility?: VisibilityState
|
||||
onColumnVisibilityChange?: (visibility: VisibilityState) => void
|
||||
columnOrder?: string[]
|
||||
onColumnOrderChange?: (order: string[]) => void
|
||||
enableRowSelection?: boolean
|
||||
onRowSelectionChange?: (rows: TData[]) => void
|
||||
getRowId?: (row: TData) => string
|
||||
columns: ColumnDef<TData>[];
|
||||
data: TData[];
|
||||
isLoading?: boolean;
|
||||
columnVisibility?: VisibilityState;
|
||||
onColumnVisibilityChange?: (visibility: VisibilityState) => void;
|
||||
columnOrder?: string[];
|
||||
onColumnOrderChange?: (order: string[]) => void;
|
||||
enableRowSelection?: boolean;
|
||||
onRowSelectionChange?: (rows: TData[]) => void;
|
||||
getRowId?: (row: TData) => string;
|
||||
|
||||
// Pagination — server-side
|
||||
currentPage?: number
|
||||
totalPages?: number
|
||||
totalCount?: number
|
||||
onPageChange?: (page: number) => void
|
||||
currentPage?: number;
|
||||
totalPages?: number;
|
||||
totalCount?: number;
|
||||
onPageChange?: (page: number) => void;
|
||||
|
||||
// Optional content rendered above the table (e.g. month selector)
|
||||
headerContent?: React.ReactNode
|
||||
headerContent?: React.ReactNode;
|
||||
toolbar?: React.ReactNode;
|
||||
}
|
||||
|
||||
export function DataTable<TData>({
|
||||
@@ -264,17 +250,18 @@ export function DataTable<TData>({
|
||||
totalCount,
|
||||
onPageChange,
|
||||
headerContent,
|
||||
toolbar,
|
||||
}: DataTableProps<TData>) {
|
||||
const [sorting, setSorting] = useState<SortingState>([])
|
||||
const [rowSelection, setRowSelection] = useState<RowSelectionState>({})
|
||||
const [sorting, setSorting] = useState<SortingState>([]);
|
||||
const [rowSelection, setRowSelection] = useState<RowSelectionState>({});
|
||||
// Tracks whether ALL records (across pages) are logically selected
|
||||
const [allTotalSelected, setAllTotalSelected] = useState(false)
|
||||
const [allTotalSelected, setAllTotalSelected] = useState(false);
|
||||
|
||||
const resolvedTotalCount = totalCount ?? data.length
|
||||
const resolvedTotalCount = totalCount ?? data.length;
|
||||
|
||||
// ── Build selection column ──────────────────────────────────────────────────
|
||||
const selectionColumn: ColumnDef<TData> = {
|
||||
id: 'select',
|
||||
id: "select",
|
||||
header: ({ table }) => (
|
||||
<div className="relative">
|
||||
<SelectAllDropdown
|
||||
@@ -285,69 +272,67 @@ export function DataTable<TData>({
|
||||
pageCount={data.length}
|
||||
onTogglePage={(checked) => {
|
||||
if (!checked) {
|
||||
if (allTotalSelected) setAllTotalSelected(false)
|
||||
table.toggleAllPageRowsSelected(false)
|
||||
table.setRowSelection({})
|
||||
if (allTotalSelected) setAllTotalSelected(false);
|
||||
table.toggleAllPageRowsSelected(false);
|
||||
table.setRowSelection({});
|
||||
} else {
|
||||
table.toggleAllPageRowsSelected(true)
|
||||
table.toggleAllPageRowsSelected(true);
|
||||
}
|
||||
}}
|
||||
onSelectThisPage={() => {
|
||||
table.toggleAllPageRowsSelected(true)
|
||||
setAllTotalSelected(false)
|
||||
table.toggleAllPageRowsSelected(true);
|
||||
setAllTotalSelected(false);
|
||||
}}
|
||||
onSelectAll={() => {
|
||||
table.toggleAllPageRowsSelected(true)
|
||||
setAllTotalSelected(true)
|
||||
table.toggleAllPageRowsSelected(true);
|
||||
setAllTotalSelected(true);
|
||||
}}
|
||||
onClearAll={() => {
|
||||
table.toggleAllPageRowsSelected(false)
|
||||
table.setRowSelection({})
|
||||
setAllTotalSelected(false)
|
||||
table.toggleAllPageRowsSelected(false);
|
||||
table.setRowSelection({});
|
||||
setAllTotalSelected(false);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
),
|
||||
cell: ({ row, table }) => {
|
||||
const isSelected = allTotalSelected || row.getIsSelected()
|
||||
const isSelected = allTotalSelected || row.getIsSelected();
|
||||
return (
|
||||
<Checkbox
|
||||
checked={isSelected}
|
||||
onCheckedChange={(value) => {
|
||||
if (allTotalSelected && !value) {
|
||||
const newSelection: RowSelectionState = {}
|
||||
const newSelection: RowSelectionState = {};
|
||||
table.getRowModel().rows.forEach((r) => {
|
||||
if (r.id !== row.id) {
|
||||
newSelection[r.id] = true
|
||||
newSelection[r.id] = true;
|
||||
}
|
||||
})
|
||||
table.setRowSelection(newSelection)
|
||||
setAllTotalSelected(false)
|
||||
});
|
||||
table.setRowSelection(newSelection);
|
||||
setAllTotalSelected(false);
|
||||
} else {
|
||||
row.toggleSelected(!!value)
|
||||
row.toggleSelected(!!value);
|
||||
}
|
||||
}}
|
||||
aria-label="Select row"
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
/>
|
||||
)
|
||||
);
|
||||
},
|
||||
enableSorting: false,
|
||||
enableHiding: false,
|
||||
size: 48,
|
||||
}
|
||||
};
|
||||
|
||||
const allColumns: ColumnDef<TData>[] = enableRowSelection
|
||||
? [selectionColumn, ...columns]
|
||||
: columns
|
||||
const allColumns: ColumnDef<TData>[] = enableRowSelection ? [selectionColumn, ...columns] : columns;
|
||||
|
||||
const effectiveColumnOrder: string[] = enableRowSelection
|
||||
? columnOrder && columnOrder.length > 0
|
||||
? columnOrder[0] === 'select'
|
||||
? columnOrder[0] === "select"
|
||||
? columnOrder
|
||||
: ['select', ...columnOrder.filter((id) => id !== 'select')]
|
||||
: ["select", ...columnOrder.filter((id) => id !== "select")]
|
||||
: []
|
||||
: (columnOrder ?? [])
|
||||
: (columnOrder ?? []);
|
||||
|
||||
const table = useReactTable({
|
||||
data,
|
||||
@@ -361,47 +346,40 @@ export function DataTable<TData>({
|
||||
getRowId,
|
||||
enableRowSelection,
|
||||
onRowSelectionChange: (updater) => {
|
||||
const newSelection =
|
||||
typeof updater === 'function' ? updater(rowSelection) : updater
|
||||
setRowSelection(newSelection)
|
||||
const newSelection = typeof updater === "function" ? updater(rowSelection) : updater;
|
||||
setRowSelection(newSelection);
|
||||
// If deselecting anything, clear allTotalSelected
|
||||
if (Object.keys(newSelection).length < data.length) {
|
||||
setAllTotalSelected(false)
|
||||
setAllTotalSelected(false);
|
||||
}
|
||||
if (onRowSelectionChange) {
|
||||
const selectedRows = data.filter((_, index) =>
|
||||
newSelection[getRowId ? getRowId(data[index]) : String(index)]
|
||||
)
|
||||
onRowSelectionChange(selectedRows)
|
||||
const selectedRows = data.filter((_, index) => newSelection[getRowId ? getRowId(data[index]) : String(index)]);
|
||||
onRowSelectionChange(selectedRows);
|
||||
}
|
||||
},
|
||||
onSortingChange: setSorting,
|
||||
onColumnVisibilityChange: (updater) => {
|
||||
if (!onColumnVisibilityChange) return
|
||||
const next =
|
||||
typeof updater === 'function' ? updater(columnVisibility ?? {}) : updater
|
||||
onColumnVisibilityChange(next)
|
||||
if (!onColumnVisibilityChange) return;
|
||||
const next = typeof updater === "function" ? updater(columnVisibility ?? {}) : updater;
|
||||
onColumnVisibilityChange(next);
|
||||
},
|
||||
onColumnOrderChange: (updater) => {
|
||||
if (!onColumnOrderChange) return
|
||||
const next =
|
||||
typeof updater === 'function' ? updater(columnOrder ?? []) : updater
|
||||
onColumnOrderChange(next)
|
||||
if (!onColumnOrderChange) return;
|
||||
const next = typeof updater === "function" ? updater(columnOrder ?? []) : updater;
|
||||
onColumnOrderChange(next);
|
||||
},
|
||||
getCoreRowModel: getCoreRowModel(),
|
||||
getSortedRowModel: getSortedRowModel(),
|
||||
})
|
||||
});
|
||||
|
||||
// ── Selection banner ────────────────────────────────────────────────────────
|
||||
const selectedCount = Object.keys(rowSelection).length
|
||||
const showBanner = enableRowSelection && (selectedCount > 0 || allTotalSelected)
|
||||
const selectedCount = Object.keys(rowSelection).length;
|
||||
const showBanner = enableRowSelection && (selectedCount > 0 || allTotalSelected);
|
||||
|
||||
return (
|
||||
<div className="space-y-0">
|
||||
<div className="space-y-0 bg-sidebar">
|
||||
{/* Header content (e.g. month selector) */}
|
||||
{headerContent && (
|
||||
<div className="mb-3">{headerContent}</div>
|
||||
)}
|
||||
{headerContent && <div className="mb-3">{headerContent}</div>}
|
||||
|
||||
{/* Selection banner */}
|
||||
{showBanner && (
|
||||
@@ -409,13 +387,13 @@ export function DataTable<TData>({
|
||||
<span className="text-primary font-medium">
|
||||
{allTotalSelected
|
||||
? `All ${resolvedTotalCount} records selected`
|
||||
: `${selectedCount} row${selectedCount !== 1 ? 's' : ''} selected`}
|
||||
: `${selectedCount} row${selectedCount !== 1 ? "s" : ""} selected`}
|
||||
</span>
|
||||
<button
|
||||
onClick={() => {
|
||||
table.toggleAllPageRowsSelected(false)
|
||||
table.setRowSelection({})
|
||||
setAllTotalSelected(false)
|
||||
table.toggleAllPageRowsSelected(false);
|
||||
table.setRowSelection({});
|
||||
setAllTotalSelected(false);
|
||||
}}
|
||||
className="text-xs text-muted-foreground hover:text-foreground transition-colors"
|
||||
>
|
||||
@@ -425,12 +403,8 @@ export function DataTable<TData>({
|
||||
)}
|
||||
|
||||
{/* Table */}
|
||||
<div
|
||||
className={cn(
|
||||
'border border-border overflow-hidden',
|
||||
showBanner ? 'rounded-b-lg rounded-t-none' : 'rounded-md'
|
||||
)}
|
||||
>
|
||||
<div className={cn("border border-border overflow-hidden", showBanner ? "rounded-b-lg rounded-t-none" : "rounded-md")}>
|
||||
{toolbar && <div className="flex items-end justify-end gap-3 px-3 py-2.5 border-b border-border bg-muted/20">{toolbar}</div>}
|
||||
<Table>
|
||||
<TableHeader>
|
||||
{table.getHeaderGroups().map((headerGroup) => (
|
||||
@@ -442,14 +416,12 @@ export function DataTable<TData>({
|
||||
width: header.getSize() !== 150 ? header.getSize() : undefined,
|
||||
}}
|
||||
className={cn(
|
||||
'text-xs font-semibold text-muted-foreground uppercase tracking-wider whitespace-nowrap',
|
||||
header.column.getCanSort() && 'cursor-pointer select-none'
|
||||
"text-xs font-semibold text-muted-foreground uppercase tracking-wider whitespace-nowrap",
|
||||
header.column.getCanSort() && "cursor-pointer select-none",
|
||||
)}
|
||||
onClick={header.column.getToggleSortingHandler()}
|
||||
>
|
||||
{header.isPlaceholder
|
||||
? null
|
||||
: flexRender(header.column.columnDef.header, header.getContext())}
|
||||
{header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext())}
|
||||
</TableHead>
|
||||
))}
|
||||
</TableRow>
|
||||
@@ -468,10 +440,7 @@ export function DataTable<TData>({
|
||||
))
|
||||
) : table.getRowModel().rows.length === 0 ? (
|
||||
<TableRow>
|
||||
<TableCell
|
||||
colSpan={allColumns.length}
|
||||
className="text-center py-16 text-muted-foreground"
|
||||
>
|
||||
<TableCell colSpan={allColumns.length} className="text-center py-16 text-muted-foreground">
|
||||
No data found
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
@@ -479,7 +448,7 @@ export function DataTable<TData>({
|
||||
table.getRowModel().rows.map((row) => (
|
||||
<TableRow
|
||||
key={row.id}
|
||||
data-state={row.getIsSelected() ? 'selected' : undefined}
|
||||
data-state={row.getIsSelected() ? "selected" : undefined}
|
||||
className="hover:bg-muted/30 transition-colors border-border"
|
||||
>
|
||||
{row.getVisibleCells().map((cell) => (
|
||||
@@ -502,13 +471,13 @@ export function DataTable<TData>({
|
||||
onPageChange={(page) => {
|
||||
// Clear selection on page change (server-side pattern)
|
||||
if (!allTotalSelected) {
|
||||
table.toggleAllPageRowsSelected(false)
|
||||
setRowSelection({})
|
||||
table.toggleAllPageRowsSelected(false);
|
||||
setRowSelection({});
|
||||
}
|
||||
onPageChange(page)
|
||||
onPageChange(page);
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -177,7 +177,7 @@ function ToggleColumnsDropdown({
|
||||
id={`col-toggle-${col.id}`}
|
||||
checked={isVisible(col.id)}
|
||||
onChange={() => toggle(col.id)}
|
||||
className="w-4 h-4 rounded cursor-pointer accent-[#005f78] dark:accent-primary"
|
||||
className="w-4 h-4 rounded cursor-pointer accent-[#18b69b] dark:accent-primary"
|
||||
/>
|
||||
<label htmlFor={`col-toggle-${col.id}`} className="text-sm text-foreground cursor-pointer flex-1 truncate select-none">
|
||||
{col.label}
|
||||
@@ -405,7 +405,7 @@ export function DataTableToolbar({
|
||||
extraActions,
|
||||
}: DataTableToolbarProps) {
|
||||
return (
|
||||
<div className={cn("flex items-center gap-3 mb-3", hideSearch ? "justify-end" : "justify-between")}>
|
||||
<div className={cn("flex items-center gap-3 ", hideSearch ? "justify-end" : "justify-between")}>
|
||||
{!hideSearch && <TableSearchInput value={searchValue} onChange={onSearchChange} placeholder={searchPlaceholder} />}
|
||||
|
||||
<div className="flex items-center gap-2">
|
||||
|
||||
@@ -123,8 +123,8 @@ export function StepBarCards({ steps, onGoTo }: StepBarCardsProps) {
|
||||
className={cn(
|
||||
"relative flex items-center justify-center rounded-full w-11 h-11 shrink-0 transition-all duration-300",
|
||||
isActive &&
|
||||
"bg-[#005f78] text-white ring-4 ring-[#005f78]/15 dark:bg-primary dark:text-primary-foreground dark:ring-primary/15",
|
||||
isDone && "bg-[#005f78]/10 text-[#005f78] dark:bg-muted dark:text-foreground",
|
||||
"bg-[#18b69b] text-white ring-4 ring-[#18b69b]/15 dark:bg-primary dark:text-primary-foreground dark:ring-primary/15",
|
||||
isDone && "bg-[#18b69b]/10 text-[#18b69b] dark:bg-muted dark:text-foreground",
|
||||
isError && "bg-destructive/10 text-destructive ring-2 ring-destructive/30",
|
||||
isIdle && "bg-muted text-muted-foreground",
|
||||
reachable && !isActive && "group-hover:scale-105",
|
||||
@@ -144,8 +144,8 @@ export function StepBarCards({ steps, onGoTo }: StepBarCardsProps) {
|
||||
<span
|
||||
className={cn(
|
||||
"text-sm font-semibold tracking-tight",
|
||||
isActive && "text-[#005f78] dark:text-foreground",
|
||||
isDone && "text-[#005f78] dark:text-foreground",
|
||||
isActive && "text-[#18b69b] dark:text-foreground",
|
||||
isDone && "text-[#18b69b] dark:text-foreground",
|
||||
!isActive && !isDone && !isError && "text-foreground/90",
|
||||
isError && "text-destructive",
|
||||
)}
|
||||
|
||||
@@ -1,36 +1,33 @@
|
||||
import * as React from "react"
|
||||
import { cva, type VariantProps } from "class-variance-authority"
|
||||
import { Slot } from "radix-ui"
|
||||
import * as React from "react";
|
||||
import { cva, type VariantProps } from "class-variance-authority";
|
||||
import { Slot } from "radix-ui";
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { cn } from "@/lib/utils";
|
||||
|
||||
const buttonVariants = cva(
|
||||
"group/button inline-flex cursor-pointer shrink-0 items-center justify-center rounded-md border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
||||
{
|
||||
variants: {
|
||||
variant: {
|
||||
default: "bg-[#005f78] dark:bg-primary text-primary-foreground [a]:hover:bg-primary/80",
|
||||
default: "bg-[#18b69b] dark:bg-primary text-primary-foreground [a]:hover:bg-primary/80",
|
||||
outline:
|
||||
"border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",
|
||||
secondary:
|
||||
"bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",
|
||||
ghost:
|
||||
"hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
|
||||
ghost: "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",
|
||||
destructive:
|
||||
"bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",
|
||||
link: "text-primary underline-offset-4 hover:underline",
|
||||
},
|
||||
size: {
|
||||
default:
|
||||
"h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
||||
default: "h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
||||
xs: "h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",
|
||||
sm: "h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-md has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
|
||||
lg: "h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
|
||||
icon: "size-8",
|
||||
"icon-xs":
|
||||
"size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-md [&_svg:not([class*='size-'])]:size-3",
|
||||
"icon-sm":
|
||||
"size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-md",
|
||||
"icon-sm": "size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-md",
|
||||
"icon-lg": "size-9",
|
||||
},
|
||||
},
|
||||
@@ -38,8 +35,8 @@ const buttonVariants = cva(
|
||||
variant: "default",
|
||||
size: "default",
|
||||
},
|
||||
}
|
||||
)
|
||||
},
|
||||
);
|
||||
|
||||
function Button({
|
||||
className,
|
||||
@@ -49,9 +46,9 @@ function Button({
|
||||
...props
|
||||
}: React.ComponentProps<"button"> &
|
||||
VariantProps<typeof buttonVariants> & {
|
||||
asChild?: boolean
|
||||
asChild?: boolean;
|
||||
}) {
|
||||
const Comp = asChild ? Slot.Root : "button"
|
||||
const Comp = asChild ? Slot.Root : "button";
|
||||
|
||||
return (
|
||||
<Comp
|
||||
@@ -61,7 +58,7 @@ function Button({
|
||||
className={cn(buttonVariants({ variant, size, className }))}
|
||||
{...props}
|
||||
/>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export { Button, buttonVariants }
|
||||
export { Button, buttonVariants };
|
||||
|
||||
@@ -1,19 +1,16 @@
|
||||
import * as React from "react"
|
||||
import { Checkbox as CheckboxPrimitive } from "radix-ui"
|
||||
import * as React from "react";
|
||||
import { Checkbox as CheckboxPrimitive } from "radix-ui";
|
||||
|
||||
import { cn } from "@/lib/utils"
|
||||
import { CheckIcon } from "lucide-react"
|
||||
import { cn } from "@/lib/utils";
|
||||
import { CheckIcon } from "lucide-react";
|
||||
|
||||
function Checkbox({
|
||||
className,
|
||||
...props
|
||||
}: React.ComponentProps<typeof CheckboxPrimitive.Root>) {
|
||||
function Checkbox({ className, ...props }: React.ComponentProps<typeof CheckboxPrimitive.Root>) {
|
||||
return (
|
||||
<CheckboxPrimitive.Root
|
||||
data-slot="checkbox"
|
||||
className={cn(
|
||||
"peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input transition-colors outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-[#005f78] data-checked:bg-[#005f78] data-checked:text-white dark:data-checked:border-primary dark:data-checked:bg-primary dark:data-checked:text-primary-foreground",
|
||||
className
|
||||
"peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input transition-colors outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-[#18b69b] data-checked:bg-[#18b69b] data-checked:text-white dark:data-checked:border-primary dark:data-checked:bg-primary dark:data-checked:text-primary-foreground",
|
||||
className,
|
||||
)}
|
||||
{...props}
|
||||
>
|
||||
@@ -24,7 +21,7 @@ function Checkbox({
|
||||
<CheckIcon />
|
||||
</CheckboxPrimitive.Indicator>
|
||||
</CheckboxPrimitive.Root>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
export { Checkbox }
|
||||
export { Checkbox };
|
||||
|
||||
Reference in New Issue
Block a user