@epilot/volt-ui 1.1.18 → 1.1.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/data-table/data-table-body.d.ts +25 -0
- package/dist/components/data-table/data-table-column-header.d.ts +18 -0
- package/dist/components/data-table/data-table-column-visibility.d.ts +22 -0
- package/dist/components/data-table/data-table-content.d.ts +18 -0
- package/dist/components/data-table/data-table-context.d.ts +64 -0
- package/dist/components/data-table/data-table-error.d.ts +24 -0
- package/dist/components/data-table/data-table-footer.d.ts +11 -0
- package/dist/components/data-table/data-table-header.d.ts +19 -0
- package/dist/components/data-table/data-table-loading.d.ts +16 -0
- package/dist/components/data-table/data-table-pagination.d.ts +20 -0
- package/dist/components/data-table/data-table-pinning-utils.d.ts +17 -0
- package/dist/components/data-table/data-table-resize-handle.d.ts +16 -0
- package/dist/components/data-table/data-table-row.d.ts +19 -0
- package/dist/components/data-table/data-table-toolbar.d.ts +11 -0
- package/dist/components/data-table/data-table.d.ts +93 -0
- package/dist/components/data-table/get-selected-row-data.d.ts +18 -0
- package/dist/components/data-table/hooks/index.d.ts +2 -0
- package/dist/components/data-table/hooks/use-data-table-virtualizer.d.ts +1 -0
- package/dist/components/data-table/hooks/use-data-table.d.ts +2 -0
- package/dist/components/table/table-pagination.d.ts +48 -0
- package/dist/components/table/table.d.ts +5 -1
- package/dist/hooks/use-client-pagination.d.ts +55 -0
- package/dist/index.cjs.js +63 -39
- package/dist/index.d.ts +39 -0
- package/dist/index.es.js +11411 -7563
- package/dist/lib/pagination.d.ts +71 -0
- package/dist/style.css +1 -1
- package/package.json +3 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export type DataTableBodyProps = {
|
|
3
|
+
/** Additional class name */
|
|
4
|
+
className?: string;
|
|
5
|
+
/** Custom empty state content */
|
|
6
|
+
emptyState?: ReactNode;
|
|
7
|
+
/** Loading state content (shown when isLoading is true) */
|
|
8
|
+
loadingState?: ReactNode;
|
|
9
|
+
/** Whether the table is in loading state */
|
|
10
|
+
isLoading?: boolean;
|
|
11
|
+
/** Error state content (shown when isError is true) */
|
|
12
|
+
errorState?: ReactNode;
|
|
13
|
+
/** Whether the table is in error state */
|
|
14
|
+
isError?: boolean;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Renders the table body with rows.
|
|
18
|
+
* Automatically handles virtualization when used within a DataTableContent with virtualization enabled.
|
|
19
|
+
* Must be used within a DataTable component.
|
|
20
|
+
*/
|
|
21
|
+
declare function DataTableBody({ className, emptyState, loadingState, isLoading, errorState, isError, }: DataTableBodyProps): import("react/jsx-runtime").JSX.Element;
|
|
22
|
+
declare namespace DataTableBody {
|
|
23
|
+
var displayName: string;
|
|
24
|
+
}
|
|
25
|
+
export { DataTableBody };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Column } from "@tanstack/react-table";
|
|
2
|
+
export type DataTableColumnHeaderProps<TData, TValue> = {
|
|
3
|
+
/** The column instance from Tanstack Table */
|
|
4
|
+
column: Column<TData, TValue>;
|
|
5
|
+
/** The header title to display */
|
|
6
|
+
title: string;
|
|
7
|
+
/** Additional class name */
|
|
8
|
+
className?: string;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* A sortable column header component for DataTable.
|
|
12
|
+
* Shows sort indicators and handles sort toggle on click.
|
|
13
|
+
*/
|
|
14
|
+
declare function DataTableColumnHeader<TData, TValue>({ column, title, className, }: DataTableColumnHeaderProps<TData, TValue>): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
declare namespace DataTableColumnHeader {
|
|
16
|
+
var displayName: string;
|
|
17
|
+
}
|
|
18
|
+
export { DataTableColumnHeader };
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ComponentProps, ReactNode } from "react";
|
|
2
|
+
import { DropdownMenu } from "../../components/dropdown-menu/dropdown-menu";
|
|
3
|
+
export type DataTableColumnVisibilityProps = {
|
|
4
|
+
/** Custom trigger element. Defaults to a sliders icon button. */
|
|
5
|
+
trigger?: ReactNode;
|
|
6
|
+
/** Label shown at top of dropdown and as screen reader text for default trigger. Required for i18n. */
|
|
7
|
+
label: string;
|
|
8
|
+
/** Additional class name for the dropdown content */
|
|
9
|
+
contentClassName?: string;
|
|
10
|
+
/** Alignment of dropdown relative to trigger. Default: "end" */
|
|
11
|
+
align?: "start" | "center" | "end";
|
|
12
|
+
} & Omit<ComponentProps<typeof DropdownMenu>, "children">;
|
|
13
|
+
/**
|
|
14
|
+
* A dropdown menu for toggling column visibility in DataTable.
|
|
15
|
+
* Shows checkboxes for each column that can be hidden.
|
|
16
|
+
* Place in DataTableToolbar for consistent layout.
|
|
17
|
+
*/
|
|
18
|
+
declare function DataTableColumnVisibility({ trigger, label, contentClassName, align, ...props }: DataTableColumnVisibilityProps): import("react/jsx-runtime").JSX.Element | null;
|
|
19
|
+
declare namespace DataTableColumnVisibility {
|
|
20
|
+
var displayName: string;
|
|
21
|
+
}
|
|
22
|
+
export { DataTableColumnVisibility };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export type DataTableContentProps = {
|
|
3
|
+
/** Children to render inside the table (DataTableHeader, DataTableBody) */
|
|
4
|
+
children?: ReactNode;
|
|
5
|
+
/** Additional class name */
|
|
6
|
+
className?: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Container component for DataTable that handles the table structure and virtualization.
|
|
10
|
+
* When virtualization is enabled, this component manages the scroll container.
|
|
11
|
+
*
|
|
12
|
+
* If no children are provided, renders DataTableHeader and DataTableBody by default.
|
|
13
|
+
*/
|
|
14
|
+
declare function DataTableContent({ children, className }: DataTableContentProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
declare namespace DataTableContent {
|
|
16
|
+
var displayName: string;
|
|
17
|
+
}
|
|
18
|
+
export { DataTableContent };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { RefObject, MouseEvent } from "react";
|
|
2
|
+
import type { Table as TanstackTable, PaginationState, Row } from "@tanstack/react-table";
|
|
3
|
+
import type { Virtualizer } from "@tanstack/react-virtual";
|
|
4
|
+
export declare const DEFAULT_ROW_HEIGHT = 48;
|
|
5
|
+
export declare const DEFAULT_OVERSCAN = 10;
|
|
6
|
+
export declare const DEFAULT_CONTAINER_HEIGHT = 600;
|
|
7
|
+
/** Controls how cell content handles overflow */
|
|
8
|
+
export type DataTableCellOverflow = "grow" | "wrap" | "truncate";
|
|
9
|
+
export type DataTablePaginationConfig = {
|
|
10
|
+
/** Controlled page index (0-indexed) */
|
|
11
|
+
pageIndex?: number;
|
|
12
|
+
/** Page size (items per page). Default: 10 */
|
|
13
|
+
pageSize?: number;
|
|
14
|
+
/** Available page size options. Default: [10, 25, 50, 100] */
|
|
15
|
+
pageSizeOptions?: number[];
|
|
16
|
+
/** Total items count for server-side pagination */
|
|
17
|
+
totalItems?: number;
|
|
18
|
+
/** Total page count for server-side pagination (optional if totalItems provided) */
|
|
19
|
+
pageCount?: number;
|
|
20
|
+
/** Callback for pagination state changes */
|
|
21
|
+
onPaginationChange?: (state: PaginationState) => void;
|
|
22
|
+
};
|
|
23
|
+
export type DataTableVirtualizationConfig = {
|
|
24
|
+
/** Enable virtualization */
|
|
25
|
+
enabled: boolean;
|
|
26
|
+
/** Estimated row height in pixels. Default: 48 */
|
|
27
|
+
estimateRowHeight?: number;
|
|
28
|
+
/** Number of items to render outside visible area. Default: 10 */
|
|
29
|
+
overscan?: number;
|
|
30
|
+
/** Scroll container height. Default: 600 */
|
|
31
|
+
containerHeight?: number | string;
|
|
32
|
+
};
|
|
33
|
+
export type DataTableContextValue<TData> = {
|
|
34
|
+
table: TanstackTable<TData>;
|
|
35
|
+
pagination?: DataTablePaginationConfig;
|
|
36
|
+
config: {
|
|
37
|
+
enableVirtualization: boolean;
|
|
38
|
+
estimateRowHeight: number;
|
|
39
|
+
overscan: number;
|
|
40
|
+
containerHeight: number | string;
|
|
41
|
+
};
|
|
42
|
+
/** Handler called when a row is clicked. Enables clickable row mode. */
|
|
43
|
+
onRowClick?: (row: Row<TData>, event: MouseEvent<HTMLTableRowElement>) => void;
|
|
44
|
+
/** Custom hover class for clickable rows. Default: 'hover:bg-accent-a3' */
|
|
45
|
+
clickableRowClassName?: string;
|
|
46
|
+
/** Custom class for selected rows. Default: 'data-[state=selected]:bg-accent-a3' */
|
|
47
|
+
selectedRowClassName?: string;
|
|
48
|
+
/** Column sizing mode. 'fixed' maintains column widths with scroll, 'fluid' squeezes to fit. Default: 'fixed' */
|
|
49
|
+
sizing?: "fixed" | "fluid";
|
|
50
|
+
/** Controls how cell content handles overflow. 'grow' expands cells (default), 'wrap' wraps text, 'truncate' shows ellipsis. */
|
|
51
|
+
cellOverflow?: DataTableCellOverflow;
|
|
52
|
+
/** Whether column resizing is disabled (enabled by default) */
|
|
53
|
+
disableColumnResizing?: boolean;
|
|
54
|
+
/** Show bottom border on header row. Default: true */
|
|
55
|
+
showHeaderBorder?: boolean;
|
|
56
|
+
/** Show bottom borders on data rows. Default: true */
|
|
57
|
+
showRowBorders?: boolean;
|
|
58
|
+
};
|
|
59
|
+
export type DataTableVirtualizerContextValue = {
|
|
60
|
+
virtualizer: Virtualizer<HTMLDivElement, Element>;
|
|
61
|
+
scrollContainerRef: RefObject<HTMLDivElement>;
|
|
62
|
+
} | null;
|
|
63
|
+
export declare const DataTableContext: import("react").Context<DataTableContextValue<any> | null>;
|
|
64
|
+
export declare const DataTableVirtualizerContext: import("react").Context<DataTableVirtualizerContextValue>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export type DataTableErrorProps = {
|
|
3
|
+
/** Error title text */
|
|
4
|
+
title?: string;
|
|
5
|
+
/** Error description/message */
|
|
6
|
+
description?: ReactNode;
|
|
7
|
+
/** Retry button text */
|
|
8
|
+
retryLabel?: string;
|
|
9
|
+
/** Callback when retry is clicked */
|
|
10
|
+
onRetry?: () => void;
|
|
11
|
+
/** Additional class name */
|
|
12
|
+
className?: string;
|
|
13
|
+
/** Custom error content (overrides default error display) */
|
|
14
|
+
children?: ReactNode;
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Error state display for DataTable.
|
|
18
|
+
* Shows an error icon, message, and optional retry button.
|
|
19
|
+
*/
|
|
20
|
+
declare function DataTableError({ title, description, retryLabel, onRetry, className, children, }: DataTableErrorProps): import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
declare namespace DataTableError {
|
|
22
|
+
var displayName: string;
|
|
23
|
+
}
|
|
24
|
+
export { DataTableError };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ComponentProps } from "react";
|
|
2
|
+
export type DataTableFooterProps = ComponentProps<"div">;
|
|
3
|
+
/**
|
|
4
|
+
* A footer wrapper for DataTable that sits between the table content and pagination.
|
|
5
|
+
* Use for custom actions like "Show more" links or summary information.
|
|
6
|
+
*/
|
|
7
|
+
declare function DataTableFooter({ className, children, ...props }: DataTableFooterProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
declare namespace DataTableFooter {
|
|
9
|
+
var displayName: string;
|
|
10
|
+
}
|
|
11
|
+
export { DataTableFooter };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type DataTableHeaderProps = {
|
|
2
|
+
/** Additional class name */
|
|
3
|
+
className?: string;
|
|
4
|
+
/** Whether to make header sticky (useful with virtualization) */
|
|
5
|
+
sticky?: boolean;
|
|
6
|
+
/** Background color for sticky header. Default: "var(--volt-gray-2)" */
|
|
7
|
+
stickyBackground?: string;
|
|
8
|
+
/** Accessible label for resize handles. Required for i18n when column resizing is enabled. */
|
|
9
|
+
resizeHandleAriaLabel?: string | ((columnId: string) => string);
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Renders the table header with column headers.
|
|
13
|
+
* Must be used within a DataTable component.
|
|
14
|
+
*/
|
|
15
|
+
declare function DataTableHeader({ className, sticky, stickyBackground, resizeHandleAriaLabel, }: DataTableHeaderProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
declare namespace DataTableHeader {
|
|
17
|
+
var displayName: string;
|
|
18
|
+
}
|
|
19
|
+
export { DataTableHeader };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export type DataTableLoadingProps = {
|
|
3
|
+
/** Additional class name */
|
|
4
|
+
className?: string;
|
|
5
|
+
/** Custom loading content (overrides default spinner) */
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Loading state display for DataTable.
|
|
10
|
+
* Renders a centered spinner by default, or custom content when children are provided.
|
|
11
|
+
*/
|
|
12
|
+
declare function DataTableLoading({ className, children }: DataTableLoadingProps): import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
declare namespace DataTableLoading {
|
|
14
|
+
var displayName: string;
|
|
15
|
+
}
|
|
16
|
+
export { DataTableLoading };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type TablePaginationLabels } from "../../components/table/table-pagination";
|
|
2
|
+
export type DataTablePaginationProps = {
|
|
3
|
+
/** Available page size options */
|
|
4
|
+
pageSizeOptions?: number[];
|
|
5
|
+
/** Number of sibling pages to show on each side of current page */
|
|
6
|
+
siblingCount?: number;
|
|
7
|
+
/** Labels for i18n. See TablePaginationLabels for available options. */
|
|
8
|
+
labels?: TablePaginationLabels;
|
|
9
|
+
/** Additional class name */
|
|
10
|
+
className?: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Pagination component that integrates with DataTable's Tanstack Table instance.
|
|
14
|
+
* Must be used within a DataTable component.
|
|
15
|
+
*/
|
|
16
|
+
declare function DataTablePagination({ pageSizeOptions, siblingCount, labels, className, }: DataTablePaginationProps): import("react/jsx-runtime").JSX.Element;
|
|
17
|
+
declare namespace DataTablePagination {
|
|
18
|
+
var displayName: string;
|
|
19
|
+
}
|
|
20
|
+
export { DataTablePagination };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Column, Table } from "@tanstack/react-table";
|
|
2
|
+
export type PinningPosition = "left" | "right" | false;
|
|
3
|
+
/**
|
|
4
|
+
* Calculate the sticky offset for a pinned column based on the widths
|
|
5
|
+
* of columns pinned before it.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getPinnedColumnOffset<TData>(column: Column<TData, unknown>, table: Table<TData>): number;
|
|
8
|
+
/**
|
|
9
|
+
* Check if this column is the last pinned column on the left side.
|
|
10
|
+
* Used for applying shadow separator on the right edge.
|
|
11
|
+
*/
|
|
12
|
+
export declare function isLastLeftPinnedColumn<TData>(column: Column<TData, unknown>, table: Table<TData>): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Check if this column is the first pinned column on the right side.
|
|
15
|
+
* Used for applying shadow separator on the left edge.
|
|
16
|
+
*/
|
|
17
|
+
export declare function isFirstRightPinnedColumn<TData>(column: Column<TData, unknown>, table: Table<TData>): boolean;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Header } from "@tanstack/react-table";
|
|
2
|
+
export type DataTableResizeHandleProps<TData, TValue> = {
|
|
3
|
+
header: Header<TData, TValue>;
|
|
4
|
+
/** Accessible label for the resize handle. Recommended for i18n and accessibility. Receives column.id as parameter. */
|
|
5
|
+
ariaLabel?: string | ((columnId: string) => string);
|
|
6
|
+
className?: string;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* Resize handle for column headers.
|
|
10
|
+
* Invisible by default, shows a vertical line on hover and during drag.
|
|
11
|
+
*/
|
|
12
|
+
declare function DataTableResizeHandle<TData, TValue>({ header, ariaLabel, className, }: DataTableResizeHandleProps<TData, TValue>): import("react/jsx-runtime").JSX.Element | null;
|
|
13
|
+
declare namespace DataTableResizeHandle {
|
|
14
|
+
var displayName: string;
|
|
15
|
+
}
|
|
16
|
+
export { DataTableResizeHandle };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { CSSProperties } from "react";
|
|
2
|
+
import type { Row } from "@tanstack/react-table";
|
|
3
|
+
export type DataTableRowProps<TData> = {
|
|
4
|
+
/** The row instance from TanStack Table */
|
|
5
|
+
row: Row<TData>;
|
|
6
|
+
/** Optional style (used for virtualized row heights) */
|
|
7
|
+
style?: CSSProperties;
|
|
8
|
+
/** Additional class name */
|
|
9
|
+
className?: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Renders a single table row with its cells.
|
|
13
|
+
* Supports clickable rows when onRowClick is provided via DataTable context.
|
|
14
|
+
*/
|
|
15
|
+
declare function DataTableRow<TData>({ row, style, className, }: DataTableRowProps<TData>): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
declare namespace DataTableRow {
|
|
17
|
+
var displayName: string;
|
|
18
|
+
}
|
|
19
|
+
export { DataTableRow };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ComponentProps } from "react";
|
|
2
|
+
export type DataTableToolbarProps = ComponentProps<"div">;
|
|
3
|
+
/**
|
|
4
|
+
* A toolbar wrapper for DataTable that contains filters, search, and actions.
|
|
5
|
+
* Place above the table for consistent layout.
|
|
6
|
+
*/
|
|
7
|
+
declare function DataTableToolbar({ className, children, ...props }: DataTableToolbarProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
declare namespace DataTableToolbar {
|
|
9
|
+
var displayName: string;
|
|
10
|
+
}
|
|
11
|
+
export { DataTableToolbar };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { MouseEvent } from "react";
|
|
3
|
+
import { type SortingState, type RowSelectionState, type ColumnFiltersState, type VisibilityState, type ColumnDef, type Row, type ColumnSizingState, type ColumnPinningState } from "@tanstack/react-table";
|
|
4
|
+
import { type DataTablePaginationConfig, type DataTableVirtualizationConfig, type DataTableCellOverflow } from "./data-table-context";
|
|
5
|
+
export type DataTableProps<TData> = {
|
|
6
|
+
/** Column definitions */
|
|
7
|
+
columns: ColumnDef<TData, unknown>[];
|
|
8
|
+
/** Data array */
|
|
9
|
+
data: TData[];
|
|
10
|
+
/** Children rendered inside the context (DataTableContent, DataTablePagination, etc.) */
|
|
11
|
+
children?: ReactNode;
|
|
12
|
+
/** Unique key accessor for each row */
|
|
13
|
+
getRowId?: (row: TData) => string;
|
|
14
|
+
/** Enable row selection with checkboxes */
|
|
15
|
+
enableRowSelection?: boolean | ((row: Row<TData>) => boolean);
|
|
16
|
+
/** Enable column sorting */
|
|
17
|
+
enableSorting?: boolean;
|
|
18
|
+
/** Skip client-side sorting (for server-side sorting). When true, sorting state is tracked but rows are not sorted client-side. */
|
|
19
|
+
manualSorting?: boolean;
|
|
20
|
+
/** Enable column filtering */
|
|
21
|
+
enableFiltering?: boolean;
|
|
22
|
+
/** Skip client-side filtering (for server-side filtering). When true, filter state is tracked but rows are not filtered client-side. */
|
|
23
|
+
manualFiltering?: boolean;
|
|
24
|
+
/** Enable global search/filter */
|
|
25
|
+
enableGlobalFilter?: boolean;
|
|
26
|
+
/** Pagination configuration */
|
|
27
|
+
pagination?: DataTablePaginationConfig;
|
|
28
|
+
/** Virtualization configuration (mutually exclusive with pagination) */
|
|
29
|
+
virtualization?: DataTableVirtualizationConfig;
|
|
30
|
+
/** Controlled sorting state */
|
|
31
|
+
sorting?: SortingState;
|
|
32
|
+
/** Callback when sorting changes */
|
|
33
|
+
onSortingChange?: (sorting: SortingState) => void;
|
|
34
|
+
/** Default sorting state */
|
|
35
|
+
defaultSorting?: SortingState;
|
|
36
|
+
/** Controlled row selection state */
|
|
37
|
+
rowSelection?: RowSelectionState;
|
|
38
|
+
/** Callback when row selection changes */
|
|
39
|
+
onRowSelectionChange?: (selection: RowSelectionState) => void;
|
|
40
|
+
/** Default row selection state */
|
|
41
|
+
defaultRowSelection?: RowSelectionState;
|
|
42
|
+
/** Controlled column filters state */
|
|
43
|
+
columnFilters?: ColumnFiltersState;
|
|
44
|
+
/** Callback when column filters change */
|
|
45
|
+
onColumnFiltersChange?: (filters: ColumnFiltersState) => void;
|
|
46
|
+
/** Controlled column visibility state */
|
|
47
|
+
columnVisibility?: VisibilityState;
|
|
48
|
+
/** Callback when column visibility changes */
|
|
49
|
+
onColumnVisibilityChange?: (visibility: VisibilityState) => void;
|
|
50
|
+
/** Controlled global filter value */
|
|
51
|
+
globalFilter?: string;
|
|
52
|
+
/** Callback when global filter changes */
|
|
53
|
+
onGlobalFilterChange?: (value: string) => void;
|
|
54
|
+
/** Handler called when a row is clicked. Enables clickable row mode. */
|
|
55
|
+
onRowClick?: (row: Row<TData>, event: MouseEvent<HTMLTableRowElement>) => void;
|
|
56
|
+
/** Custom hover class for clickable rows. Default: 'hover:bg-accent-a3' */
|
|
57
|
+
clickableRowClassName?: string;
|
|
58
|
+
/** Custom class for selected rows. Default: 'data-[state=selected]:bg-accent-a3' */
|
|
59
|
+
selectedRowClassName?: string;
|
|
60
|
+
/** Column sizing mode. 'fixed' maintains column widths with scroll, 'fluid' squeezes to fit. Default: 'fixed' */
|
|
61
|
+
sizing?: "fixed" | "fluid";
|
|
62
|
+
/** Controls how cell content handles overflow. 'grow' expands cells (default), 'wrap' wraps text, 'truncate' shows ellipsis. Can be overridden per-column via column meta. */
|
|
63
|
+
cellOverflow?: DataTableCellOverflow;
|
|
64
|
+
/** Disable column width resizing (enabled by default) */
|
|
65
|
+
disableColumnResizing?: boolean;
|
|
66
|
+
/** Resize mode: 'onChange' updates during drag, 'onEnd' updates when drag finishes. Default: 'onEnd' */
|
|
67
|
+
columnResizeMode?: "onChange" | "onEnd";
|
|
68
|
+
/** Controlled column sizing state */
|
|
69
|
+
columnSizing?: ColumnSizingState;
|
|
70
|
+
/** Callback when column sizing changes */
|
|
71
|
+
onColumnSizingChange?: (sizing: ColumnSizingState) => void;
|
|
72
|
+
/** Default column sizing for uncontrolled mode */
|
|
73
|
+
defaultColumnSizing?: ColumnSizingState;
|
|
74
|
+
/** Controlled column pinning state */
|
|
75
|
+
columnPinning?: ColumnPinningState;
|
|
76
|
+
/** Callback when column pinning changes */
|
|
77
|
+
onColumnPinningChange?: (pinning: ColumnPinningState) => void;
|
|
78
|
+
/** Default column pinning for uncontrolled mode */
|
|
79
|
+
defaultColumnPinning?: ColumnPinningState;
|
|
80
|
+
/** Auto-pin selection column to left when rows are selected. Default: false */
|
|
81
|
+
autoPinSelection?: boolean;
|
|
82
|
+
/** Show bottom border on header row. Default: true */
|
|
83
|
+
showHeaderBorder?: boolean;
|
|
84
|
+
/** Show bottom borders on data rows. Default: true */
|
|
85
|
+
showRowBorders?: boolean;
|
|
86
|
+
/** Additional class name */
|
|
87
|
+
className?: string;
|
|
88
|
+
};
|
|
89
|
+
declare function DataTable<TData>({ columns, data, children, getRowId, enableRowSelection, enableSorting, manualSorting, enableFiltering, manualFiltering, enableGlobalFilter, pagination, virtualization, sorting: controlledSorting, onSortingChange, defaultSorting, rowSelection: controlledRowSelection, onRowSelectionChange, defaultRowSelection, columnFilters: controlledColumnFilters, onColumnFiltersChange, columnVisibility: controlledColumnVisibility, onColumnVisibilityChange, globalFilter: controlledGlobalFilter, onGlobalFilterChange, onRowClick, clickableRowClassName, selectedRowClassName, sizing, cellOverflow, disableColumnResizing, columnResizeMode, columnSizing: controlledColumnSizing, onColumnSizingChange, defaultColumnSizing, columnPinning: controlledColumnPinning, onColumnPinningChange, defaultColumnPinning, autoPinSelection, showHeaderBorder, showRowBorders, className, }: DataTableProps<TData>): import("react/jsx-runtime").JSX.Element;
|
|
90
|
+
declare namespace DataTable {
|
|
91
|
+
var displayName: string;
|
|
92
|
+
}
|
|
93
|
+
export { DataTable };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { RowSelectionState } from "@tanstack/react-table";
|
|
2
|
+
/**
|
|
3
|
+
* Extracts selected row data from a row selection state.
|
|
4
|
+
*
|
|
5
|
+
* @param rowSelection - The selection state from DataTable (controlled via rowSelection prop)
|
|
6
|
+
* @param data - Your data array
|
|
7
|
+
* @param getRowId - Optional ID accessor function (defaults to `row.id`)
|
|
8
|
+
* @returns Array of selected data items
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```tsx
|
|
12
|
+
* const selectedData = useMemo(
|
|
13
|
+
* () => getSelectedRowData(rowSelection, data),
|
|
14
|
+
* [rowSelection, data]
|
|
15
|
+
* )
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function getSelectedRowData<TData>(rowSelection: RowSelectionState, data: TData[], getRowId?: (row: TData) => string): TData[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function useDataTableVirtualizer(): import("../data-table-context").DataTableVirtualizerContextValue;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { ComponentProps } from "react";
|
|
2
|
+
export type TablePaginationLabels = {
|
|
3
|
+
/** Label for the pagination navigation region. */
|
|
4
|
+
navigation?: string;
|
|
5
|
+
/** Label for first page button. */
|
|
6
|
+
firstPage?: string;
|
|
7
|
+
/** Label for previous page button. */
|
|
8
|
+
previousPage?: string;
|
|
9
|
+
/** Label for next page button. */
|
|
10
|
+
nextPage?: string;
|
|
11
|
+
/** Label for last page button. */
|
|
12
|
+
lastPage?: string;
|
|
13
|
+
/** Label generator for page number buttons. Receives 1-indexed page number. */
|
|
14
|
+
goToPage?: (page: number) => string;
|
|
15
|
+
/** Label generator for ellipsis jump buttons. Receives target page number. */
|
|
16
|
+
jumpToPage?: (page: number) => string;
|
|
17
|
+
/** Label generator for page size selector. Receives current page size. */
|
|
18
|
+
pageSizeSelector?: (pageSize: number) => string;
|
|
19
|
+
/** Label for page size dropdown header. */
|
|
20
|
+
resultsPerPage?: string;
|
|
21
|
+
/** Label generator for the range display. Receives start, end, and total. */
|
|
22
|
+
rangeDisplay?: (start: number, end: number, total: number) => string;
|
|
23
|
+
};
|
|
24
|
+
export type TablePaginationProps = Omit<ComponentProps<"div">, "onChange"> & {
|
|
25
|
+
/** Current page number (1-indexed) */
|
|
26
|
+
page: number;
|
|
27
|
+
/** Total number of items across all pages */
|
|
28
|
+
totalItems: number;
|
|
29
|
+
/** Current page size (items per page) */
|
|
30
|
+
pageSize: number;
|
|
31
|
+
/** Callback fired when the page changes */
|
|
32
|
+
onPageChange: (page: number) => void;
|
|
33
|
+
/** Callback fired when the page size changes */
|
|
34
|
+
onPageSizeChange: (pageSize: number) => void;
|
|
35
|
+
/** Available page size options for the dropdown */
|
|
36
|
+
pageSizeOptions?: number[];
|
|
37
|
+
/** Number of sibling pages to show on each side of current page */
|
|
38
|
+
siblingCount?: number;
|
|
39
|
+
/** Whether the pagination controls are disabled */
|
|
40
|
+
disabled?: boolean;
|
|
41
|
+
/** Labels for i18n. All labels are optional for backwards compatibility but recommended. */
|
|
42
|
+
labels?: TablePaginationLabels;
|
|
43
|
+
};
|
|
44
|
+
declare const TablePagination: {
|
|
45
|
+
({ page, totalItems, pageSize, onPageChange, onPageSizeChange, pageSizeOptions, siblingCount, disabled, labels, className, ...props }: TablePaginationProps): import("react/jsx-runtime").JSX.Element | null;
|
|
46
|
+
displayName: string;
|
|
47
|
+
};
|
|
48
|
+
export { TablePagination };
|
|
@@ -3,7 +3,11 @@ declare const Table: ({ className, ...props }: React.ComponentProps<"table">) =>
|
|
|
3
3
|
declare const TableHeader: ({ className, ...props }: React.ComponentProps<"thead">) => import("react/jsx-runtime").JSX.Element;
|
|
4
4
|
declare const TableBody: ({ className, ...props }: React.ComponentProps<"tbody">) => import("react/jsx-runtime").JSX.Element;
|
|
5
5
|
declare const TableFooter: ({ className, ...props }: React.ComponentProps<"tfoot">) => import("react/jsx-runtime").JSX.Element;
|
|
6
|
-
|
|
6
|
+
type TableRowProps = React.ComponentProps<"tr"> & {
|
|
7
|
+
/** Disable hover background effect */
|
|
8
|
+
noHover?: boolean;
|
|
9
|
+
};
|
|
10
|
+
declare const TableRow: ({ className, noHover, ...props }: TableRowProps) => import("react/jsx-runtime").JSX.Element;
|
|
7
11
|
type TableHeadProps = React.ComponentProps<"th"> & {
|
|
8
12
|
align?: "left" | "center" | "right";
|
|
9
13
|
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { type PaginationMeta } from "../lib/pagination";
|
|
2
|
+
export type UseClientPaginationOptions<T> = {
|
|
3
|
+
/** The full data array to paginate */
|
|
4
|
+
data: T[];
|
|
5
|
+
/** Initial page number (1-indexed). Default: 1 */
|
|
6
|
+
initialPage?: number;
|
|
7
|
+
/** Initial page size. Default: 10 */
|
|
8
|
+
initialPageSize?: number;
|
|
9
|
+
/** Available page size options. Default: [10, 20, 50] */
|
|
10
|
+
pageSizeOptions?: number[];
|
|
11
|
+
};
|
|
12
|
+
export type UseClientPaginationReturn<T> = {
|
|
13
|
+
/** Sliced data for the current page */
|
|
14
|
+
pageData: T[];
|
|
15
|
+
/** Current page number (1-indexed) */
|
|
16
|
+
page: number;
|
|
17
|
+
/** Current page size */
|
|
18
|
+
pageSize: number;
|
|
19
|
+
/** Set the current page */
|
|
20
|
+
setPage: (page: number) => void;
|
|
21
|
+
/** Set the page size (resets to page 1) */
|
|
22
|
+
setPageSize: (size: number) => void;
|
|
23
|
+
/** Pagination metadata */
|
|
24
|
+
meta: PaginationMeta;
|
|
25
|
+
/** Props to spread directly onto TablePagination */
|
|
26
|
+
paginationProps: {
|
|
27
|
+
page: number;
|
|
28
|
+
totalItems: number;
|
|
29
|
+
pageSize: number;
|
|
30
|
+
onPageChange: (page: number) => void;
|
|
31
|
+
onPageSizeChange: (pageSize: number) => void;
|
|
32
|
+
pageSizeOptions: number[];
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Hook for client-side pagination of local data arrays.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```tsx
|
|
40
|
+
* const { pageData, paginationProps } = useClientPagination({
|
|
41
|
+
* data: allItems,
|
|
42
|
+
* initialPageSize: 10,
|
|
43
|
+
* })
|
|
44
|
+
*
|
|
45
|
+
* return (
|
|
46
|
+
* <div>
|
|
47
|
+
* <Table>
|
|
48
|
+
* {pageData.map(item => <TableRow key={item.id}>...</TableRow>)}
|
|
49
|
+
* </Table>
|
|
50
|
+
* <TablePagination {...paginationProps} />
|
|
51
|
+
* </div>
|
|
52
|
+
* )
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare function useClientPagination<T>({ data, initialPage, initialPageSize, pageSizeOptions, }: UseClientPaginationOptions<T>): UseClientPaginationReturn<T>;
|