import { type Table } from '@tanstack/react-table'; import React, { type ReactNode } from 'react'; import type { EDSBase, Size, Status, Align } from '../../util/variant-types'; import { type IconName } from '../Icon/Icon'; export type DataTableProps = EDSBase & { /** * Collection of buttons/menus to control the table contents */ actions?: React.ReactNode; /** * Set whether the table has interactive rows * * **Default is `false`**. */ isInteractive?: boolean; /** * Data table controller for rendering the contents of the table * * See Doc.s: https://tanstack.com/table/latest/docs/framework/react/guide/table-state */ table?: Table; /** * Classes to add to the table to control height, width, and other non-stylistic behaviors */ tableClassName?: string; /** * Method to call when content is entered into the search field. Also causes the field * to appear. * @returns void */ onSearchChange?: () => void; /** * Main caption text to use for the table. Will show a visible title, and add text for * the accessible caption within the table. */ caption?: string; /** * Controls whether the table allows rows for a status color/icon treatment. */ isStatusEligible?: boolean; /** * Controls the treatment of alternating rows in the table. * * **Default is `"striped"`**. */ rowStyle?: 'striped' | 'lined'; /** * Size of the padding for the table * * **Default is `"md"`**. */ size?: Extract; /** * Sub-caption text to use for the table. This text should be used with `caption` and is not * meant to be standalone. */ subCaption?: string; /** * Controls the treatment of the table container. * * **Default is `"basic"`**. */ tableStyle?: 'basic' | 'border'; }; export type DataTableTableProps = EDSBase & Pick; export type DataTableRowProps = Pick & StatusColumn & { 'aria-label'?: string; isInteractive?: boolean; isSelected?: boolean; }; export type DataTableHeaderCellProps = EDSBase & { /** * Handler for clicking on the individual column header sort buttons. */ onSortClick?: React.MouseEventHandler; /** * Determines the edge alignment of content within the cell */ alignment?: Extract; /** * Whether the cell has a divider between adjacent cells */ hasHorizontalDivider?: boolean; /** * Marks the header cell as sortable (used in conjunction with `sortDirection`) */ isSortable?: boolean; /** * An icon that prefixes the field input. */ leadingIcon?: IconName; /** * SubLabel to use next to table cell text content * * ---- * * **Note**: Will warn when used in the wrong context */ subLabel?: ReactNode; /** * The direction to apply to the icon (for visual treatment) * * **Default is `"default"`**. */ sortDirection?: DataTableSortDirection; }; type StatusColumn = { status?: Extract; }; export declare const SORT_DIRECTION: { ascending: string; descending: string; default: string; }; export type DataTableSortDirection = keyof typeof SORT_DIRECTION; export type DataTableDataCellProps = DataTableHeaderCellProps & { children: React.ReactNode; }; export type DataTableStatusCellProps = StatusColumn & { 'aria-label'?: string; }; export type DataTableWithStatus = S & StatusColumn; /** * `import {DataTable} from "@chanzuckerberg/eds";` * * DataTable represents a full-featured data view for controlling and sorting. It: * - handles responsive behaviors * - sort behavior on individual columns */ export declare function DataTable({ actions, children, className, caption, isInteractive, isStatusEligible, onSearchChange, rowStyle, size, subCaption, table, tableClassName, tableStyle, ...rest }: DataTableProps): React.JSX.Element; export declare namespace DataTable { var displayName: string; var Search: () => React.JSX.Element; var Actions: ({ children }: Pick) => React.JSX.Element; var Table: ({ children, tableClassName, tableStyle, rowStyle, size, }: DataTableTableProps) => React.JSX.Element; var Header: ({ children, ...rest }: Pick) => React.JSX.Element; var Row: ({ "aria-label": ariaLabel, children, className, isInteractive, isSelected, status, ...rest }: DataTableRowProps) => React.JSX.Element; var GroupRow: ({ colSpan, title, }: { title: string; colSpan: number; }) => React.JSX.Element; var HeaderCell: ({ alignment, children, className, hasHorizontalDivider, isSortable, leadingIcon, sortDirection, onSortClick, subLabel, ...rest }: DataTableHeaderCellProps) => React.JSX.Element; var DataCell: ({ alignment, children, className, hasHorizontalDivider, leadingIcon, subLabel, ...rest }: DataTableDataCellProps) => React.JSX.Element; var StatusCell: ({ "aria-label": ariaLabel, status, ...rest }: DataTableStatusCellProps) => React.JSX.Element; var StatusHeaderCell: ({ "aria-label": ariaLabel, status, ...rest }: DataTableStatusCellProps) => React.JSX.Element; var __StatusColumnId__: "status"; var SORT_DIRECTION: { ascending: string; descending: string; default: string; }; } export declare const DataTableHeaderCell: ({ alignment, children, className, hasHorizontalDivider, isSortable, leadingIcon, sortDirection, onSortClick, subLabel, ...rest }: DataTableHeaderCellProps) => React.JSX.Element; export declare const DataTableDataCell: ({ alignment, children, className, hasHorizontalDivider, leadingIcon, subLabel, ...rest }: DataTableDataCellProps) => React.JSX.Element; export declare const DataTableStatusHeaderCell: ({ "aria-label": ariaLabel, status, ...rest }: DataTableStatusCellProps) => React.JSX.Element; export declare const DataTableStatusCell: ({ "aria-label": ariaLabel, status, ...rest }: DataTableStatusCellProps) => React.JSX.Element; export declare const DataTableTable: ({ children, tableClassName, tableStyle, rowStyle, size, }: DataTableTableProps) => React.JSX.Element; export declare const DataTableHeader: ({ children, ...rest }: Pick) => React.JSX.Element; export declare const DataTableRow: ({ "aria-label": ariaLabel, children, className, isInteractive, isSelected, status, ...rest }: DataTableRowProps) => React.JSX.Element; export declare const DataTableGroupRow: ({ colSpan, title, }: { title: string; colSpan: number; }) => React.JSX.Element; export {};