import { ReactNode } from 'react';
/**
 * Defines bulk actions available when rows are selected
 */
export interface BulkAction {
    /** Unique identifier for the action */
    id: string;
    /** Display label for the action button */
    label: string;
    /** Optional icon component to display in the action button */
    icon?: React.ComponentType<{
        className?: string;
    }>;
    /** Visual style variant for the action button */
    variant?: 'primary' | 'secondary' | 'danger';
    /** Callback function when action is triggered with selected row IDs */
    onClick: (selectedRows: string[]) => void;
}
/** Table visual variants for different styling approaches */
export type TableVariant = 'default' | 'striped' | 'bordered' | 'compact';
/** Text alignment options for table cells and headers */
export type TableAlignment = 'left' | 'center' | 'right';
/** Selection control types for row selection */
export type SelectionType = 'checkbox' | 'radio';
/** Filter operator types for column filtering */
export type FilterOperator = 'equals' | 'notEquals' | 'contains' | 'notContains' | 'startsWith' | 'endsWith' | 'greaterThan' | 'lessThan' | 'greaterThanOrEqual' | 'lessThanOrEqual' | 'isEmpty' | 'isNotEmpty' | 'isTrue' | 'isFalse' | 'before' | 'after' | 'between';
/** Filter type for column filter UI */
export type FilterType = 'text' | 'number' | 'select' | 'multiSelect' | 'date' | 'boolean';
/** Filter logic for combining multiple filters */
export type FilterLogic = 'and' | 'or';
/** Possible filter value types used in FilterConfig */
export type FilterValue = string | number | boolean | string[];
/** Option for select-type filter columns */
export interface FilterOption {
    label: string;
    value: string;
}
/**
 * Column definition for table data display and behavior
 */
export interface Column<T = unknown> {
    /** Unique identifier for the column */
    id: string;
    /** Header content - can be string or React element */
    header: string | ReactNode;
    /** Property key or function to extract cell data from row object */
    accessor: keyof T | ((row: T) => ReactNode | string | number | boolean | null | undefined);
    /** Optional custom renderer for cell content */
    cell?: (row: T) => ReactNode;
    /** Enable sorting for this column */
    sortable?: boolean;
    /** Enable filtering for this column */
    filterable?: boolean;
    /** Type of filter UI to display */
    filterType?: FilterType;
    /** Options for select-type filter columns */
    filterOptions?: FilterOption[];
    /** Truncate long content with ellipsis */
    ellipsis?: boolean;
    /** Show tooltip on hover - boolean or function returning tooltip text */
    tooltip?: boolean | ((row: T) => string);
    /** Fixed width for the column */
    width?: string | number;
    /** Text alignment for column content */
    align?: TableAlignment;
    /** Whether column is hidden by default */
    hidden?: boolean;
    /** Whether column is locked and cannot be hidden or reordered */
    locked?: boolean;
}
/**
 * Configuration for column sorting state
 */
export interface SortConfig {
    /** ID of the column being sorted */
    columnId: string;
    /** Sort direction - ascending or descending */
    direction: 'asc' | 'desc';
    /** Priority for multi-column sorting (lower numbers = higher priority) */
    priority: number;
}
/**
 * Configuration for column filtering state
 */
export interface FilterConfig {
    /** Unique identifier for this filter instance */
    id?: string;
    /** ID of the column being filtered */
    columnId: string;
    /** Filter value - type depends on column data type */
    value: FilterValue;
    /** Filter operator for comparison */
    operator?: FilterOperator;
}
export interface TableThemeOverrides {
    baseStyle?: string;
    variants?: Partial<Record<TableVariant, string>>;
    headerStyle?: string;
    cellStyle?: string;
    rowStyle?: string;
    selectedRowStyle?: string;
    hoverRowStyle?: string;
    frozenColumnStyle?: string;
    lastFrozenColumnStyle?: string;
    frozenHeaderStyle?: string;
    bodyStyle?: string;
    headerContainerStyle?: string;
    columnManagerButton?: string;
    columnManagerContainer?: string;
}
export interface TableContextType {
    theme: TableThemeOverrides;
    variant: TableVariant;
    freezeHeader?: boolean;
    freezeFirstColumn?: boolean;
    freezeLastColumn?: boolean;
    sortable?: boolean;
    sortConfig?: SortConfig[];
    onSortChange?: (sortConfig: SortConfig[]) => void;
    filterable?: boolean;
    filterConfig?: FilterConfig[];
    onFilterChange?: (filterConfig: FilterConfig[]) => void;
    filterLogic?: FilterLogic;
    expandable?: boolean;
    expandedRows?: string[];
    onExpandedRowsChange?: (expandedRows: string[]) => void;
    selectable?: boolean;
    selectionType?: SelectionType;
    selectedRows?: string[];
    onSelectionChange?: (selectedRows: string[]) => void;
}
/**
 * Main Table component props supporting both data-driven and declarative APIs
 *
 * @template T The type of data objects in each table row
 */
export interface TableProps<T = unknown> {
    /** Array of data objects to display - required for data-driven API */
    data?: T[];
    /** Column definitions for data display and behavior - required for data-driven API */
    columns?: Column<T>[];
    /**
     * Property name or function to extract stable row identifiers for React keys and selection.
     * Provides consistent component identity during row reordering or updates.
     */
    rowKey?: keyof T | ((row: T, index: number) => string | number);
    /** Visual variant for different table styles */
    variant?: TableVariant;
    /** Theme overrides for custom styling */
    theme?: TableThemeOverrides;
    /** Additional CSS classes for customization */
    className?: string;
    /** Keep header visible when scrolling vertically */
    freezeHeader?: boolean;
    /** Keep first column visible when scrolling horizontally */
    freezeFirstColumn?: boolean;
    /** Keep last column visible when scrolling horizontally */
    freezeLastColumn?: boolean;
    /** Enable sorting functionality for sortable columns */
    sortable?: boolean;
    /** Current sort configuration state */
    sortConfig?: SortConfig[];
    /** Callback when sort configuration changes */
    onSortChange?: (sortConfig: SortConfig[]) => void;
    /** Enable filtering functionality for filterable columns */
    filterable?: boolean;
    /** Current filter configuration state */
    filterConfig?: FilterConfig[];
    /** Callback when filter configuration changes */
    onFilterChange?: (filterConfig: FilterConfig[]) => void;
    /** Logic for combining multiple filters (default: 'and') */
    filterLogic?: FilterLogic;
    /** Enable built-in automatic data filtering (opt-in). When true, the table filters data internally. */
    enableBuiltInFilter?: boolean;
    expandable?: boolean;
    expandedRowRender?: (row: T) => ReactNode;
    expandedRows?: string[];
    onExpandedRowsChange?: (expandedRows: string[]) => void;
    selectable?: boolean;
    selectionType?: SelectionType;
    selectedRows?: string[];
    onSelectionChange?: (selectedRows: string[]) => void;
    bulkActions?: BulkAction[];
    showColumnManager?: boolean;
    visibleColumns?: string[];
    onVisibleColumnsChange?: (visibleColumns: string[]) => void;
    onColumnReorder?: (fromIndex: number, toIndex: number) => void;
    pagination?: {
        pageSize: number;
        currentPage: number;
        totalItems: number;
    };
    children?: ReactNode;
}
export interface TableHeaderProps {
    children?: ReactNode;
    freezeHeader?: boolean;
    className?: string;
}
export interface TableBodyProps {
    children?: ReactNode;
    className?: string;
}
export interface TableRowProps {
    children?: ReactNode;
    isExpandable?: boolean;
    isExpanded?: boolean;
    onExpandToggle?: () => void;
    isSelected?: boolean;
    onSelectToggle?: () => void;
    className?: string;
}
export interface TableCellProps {
    children?: ReactNode;
    isFrozen?: boolean;
    isLastFrozen?: boolean;
    align?: TableAlignment;
    width?: string | number;
    className?: string;
    colSpan?: number;
}
export interface TableHeaderCellProps extends Omit<TableCellProps, 'colSpan'> {
    isSortable?: boolean;
    sortDirection?: 'asc' | 'desc' | undefined;
    onSort?: () => void;
}
export interface InternalTableHeaderProps<T> {
    columns: Column<T>[];
    sortConfig?: SortConfig[];
    onSortChange?: (sortConfig: SortConfig[]) => void;
    filterConfig?: FilterConfig[];
    onFilterChange?: (filterConfig: FilterConfig[]) => void;
    freezeHeader?: boolean;
    freezeFirstColumn?: boolean;
    freezeLastColumn?: boolean;
    expandable?: boolean;
    expandedRowRender?: (row: T) => ReactNode;
    selectable?: boolean;
    selectionType?: SelectionType;
    selectedRows?: string[];
    onSelectionChange?: (selectedRows: string[]) => void;
    totalRowCount?: number;
    theme?: TableThemeOverrides;
    data?: T[];
    rowKey?: keyof T | ((row: T, index: number) => string | number);
}
export interface InternalTableBodyProps<T> {
    data: T[];
    columns: Column<T>[];
    rowKey?: keyof T | ((row: T, index: number) => string | number);
    expandedRowRender?: (row: T) => ReactNode;
    expandedRows?: string[];
    onExpandedRowsChange?: (expandedRows: string[]) => void;
    selectable?: boolean;
    selectionType?: SelectionType;
    selectedRows?: string[];
    onSelectionChange?: (selectedRows: string[]) => void;
    freezeFirstColumn?: boolean;
    freezeLastColumn?: boolean;
    theme?: TableThemeOverrides;
}
export interface InternalTableRowProps<T> {
    row: T;
    rowId: string;
    columns: Column<T>[];
    expandedRowRender?: (row: T) => ReactNode;
    isExpanded?: boolean;
    onExpandChange?: (expanded: boolean) => void;
    selectable?: boolean;
    selectionType?: SelectionType;
    isSelected?: boolean;
    onSelectionChange?: (selected: boolean) => void;
    freezeFirstColumn?: boolean;
    freezeLastColumn?: boolean;
    theme?: TableThemeOverrides;
}
export interface InternalTableCellProps<T> {
    column: Column<T>;
    row: T;
    rowId: string;
    isHeader?: boolean;
    isFrozen?: boolean;
    isLastFrozen?: boolean;
    isSelected?: boolean;
    theme?: TableThemeOverrides;
    children?: ReactNode;
}
export type ActionVariant = 'default' | 'danger';
export type ActionPriority = 'high' | 'normal';
export interface ActionItem<T = unknown> {
    /** Unique identifier for the action */
    id: string;
    /** Display label for the action */
    label: string;
    /** Icon component to display */
    icon: React.ComponentType<{
        className?: string;
    }>;
    /** Click handler that receives the row data */
    onClick: (row: T) => void;
    /** Visual variant for styling (default: 'default') */
    variant?: ActionVariant;
    /** Priority level for display ordering (default: 'normal') */
    priority?: ActionPriority;
    /** Function to determine if action should be disabled */
    disabled?: (row: T) => boolean;
}
export interface TableActionsProps<T = unknown> {
    /** Array of action items to display */
    actions: ActionItem<T>[];
    /** Row data to pass to action handlers */
    row: T;
    /** Maximum number of actions to show inline before using menu (default: 2) */
    maxVisibleActions?: number;
    /** Additional CSS class name */
    className?: string;
}
export interface TableActionsMenuProps<T = unknown> {
    /** Array of action items to display in menu */
    actions: ActionItem<T>[];
    /** Row data to pass to action handlers */
    row: T;
    /** Function to close the menu */
    onClose: () => void;
    /** Additional CSS class name */
    className?: string;
}
export interface TablePaginationProps {
    /** Current active page number (1-based) */
    currentPage: number;
    /** Total number of items across all pages */
    totalItems: number;
    /** Number of items per page */
    pageSize: number;
    /** Available page size options */
    pageSizeOptions?: number[];
    /** Callback when page changes */
    onPageChange: (page: number) => void;
    /** Callback when page size changes */
    onPageSizeChange: (pageSize: number) => void;
    /** Whether to show the page size selector */
    showPageSizeSelector?: boolean;
    /** Additional CSS classes */
    className?: string;
}
export interface TableSelectionHeaderProps {
    selectedCount: number;
    totalCount: number;
    selectedRows: string[];
    bulkActions?: BulkAction[];
    onClearSelection: () => void;
    className?: string;
}
export interface TableColumnManagerProps<T = unknown> {
    columns: Column<T>[];
    visibleColumns: string[];
    columnOrder: string[];
    onToggleColumn: (columnId: string) => void;
    onResetToDefault: () => void;
    onColumnReorder?: (fromIndex: number, toIndex: number) => void;
}
export interface TableFilterProps<T = unknown> {
    columns: Column<T>[];
    filterConfig: FilterConfig[];
    onFilterChange: (filterConfig: FilterConfig[]) => void;
    /** Logic for combining multiple filters */
    filterLogic?: FilterLogic;
    /** Callback when filter logic changes */
    onFilterLogicChange?: (logic: FilterLogic) => void;
    /** Data array for auto-detecting filter types from column values */
    data?: T[];
    className?: string;
}
