import { MotionProps } from 'motion/react';
import { HTMLAttributes, MouseEvent as ReactMouseEvent, ReactNode } from 'react';
export type TableHorizontalAlign = 'left' | 'center' | 'right';
export type TableVerticalAlign = 'top' | 'middle' | 'bottom';
export type TableCellOverflow = 'hidden' | 'visible' | 'ellipsis' | 'ellipsis-2' | 'ellipsis-3';
export type TableViewType = 'TABLE' | 'SINGLE_CARD' | 'MULTI_CARDS';
export type TableSortDirection = 'asc' | 'desc';
export type TableRowId = string | number;
export type TableRowData = Record<string, unknown>;
export type TableStickyReference = 'applicationLayout' | 'container';
export type TableCardsStyleSettings = {
    /**
     * Minimum card width for `MULTI_CARDS` view.
     */
    minWidth?: number | string;
    /**
     * Maximum card width for `MULTI_CARDS` view.
     */
    maxWidth?: number | string;
    /**
     * Additional classes for each card row in card views.
     */
    className?: string;
    /**
     * Additional classes for each card cell in card views.
     */
    rowClassName?: string;
    /**
     * Additional classes for each card label in card views.
     */
    labelClassName?: string;
    /**
     * Additional classes for each card content in card views.
     */
    contentClassName?: string;
};
export type TableResponsiveBreakpoint = {
    /**
     * Switch to `MULTI_CARDS` below this rendered table width.
     */
    cards?: number | string;
    /**
     * Switch to `SINGLE_CARD` below this rendered table width.
     */
    list?: number | string;
};
/**
 * High-level animation settings for expanded table rows.
 *
 * Use `false` to disable built-in expanded-row animations entirely.
 * Use `duration` to keep the default expanded-row animation behavior
 * while making it faster or slower.
 */
export type TableExpandedRowAnimation = false | {
    duration?: number;
};
export type TableHtmlAttributes = Omit<HTMLAttributes<HTMLDivElement>, 'id' | 'children' | 'className' | 'onClick' | 'onKeyDown' | 'onDrag' | 'onDragCapture' | 'onDragEnd' | 'onDragEndCapture' | 'onDragEnter' | 'onDragEnterCapture' | 'onDragExit' | 'onDragExitCapture' | 'onDragLeave' | 'onDragLeaveCapture' | 'onDragOver' | 'onDragOverCapture' | 'onDragStart' | 'onDragStartCapture' | 'onDrop' | 'onDropCapture' | 'role'>;
export type TableStickyColumns = {
    /**
     * Number of currently leftmost visible data columns to keep sticky in `TABLE` view.
     *
     * This is position-based and follows column reordering.
     * Selection columns and group rows are ignored.
     *
     * The public API currently supports `1`.
     */
    left?: 1;
    /**
     * Number of currently rightmost visible data columns to keep sticky in `TABLE` view.
     *
     * This is position-based and follows column reordering.
     * Selection columns and group rows are ignored.
     *
     * The public API currently supports `1`.
     */
    right?: 1;
    /**
     * Aligns footer cells with the sticky column behavior.
     *
     * By default, the footer stays independent so it can still span the selection column
     * or the full table width for summary and batch-action use cases.
     */
    footer?: boolean;
};
export type TableColumnDefinition<RowType extends TableRowData> = {
    /**
     * Unique key of the column.
     */
    key: Extract<keyof RowType, string> | string;
    /**
     * Column label shown in the header.
     */
    label: ReactNode;
    /**
     * Optional rioglyph class rendered before the header label in table view.
     */
    icon?: string;
    /**
     * Optional column label shown on mobile cards.
     */
    mobileLabel?: string;
    /**
     * Optional custom filter control rendered next to the header label.
     *
     * Useful for column-specific filter dropdowns or other header actions.
     */
    filter?: ReactNode;
    /**
     * Hides the visible label in table header cells while keeping the label for
     * cards, mobile labels, settings dialogs, and other metadata consumers.
     *
     * @default false
     */
    hideLabel?: boolean;
    /**
     * Minimum width of a flexible column.
     *
     * Adds a fixed width to the column.
     */
    width?: number | string;
    /**
     * Minimum resize width in px for the header drag handle.
     *
     * @default 50
     */
    minResizeWidth?: number;
    /**
     * Maximum resize width in px for the header drag handle.
     *
     * @default 1000
     */
    maxResizeWidth?: number;
    /**
     * Enables drag-reordering for this column in `TABLE` view.
     *
     * When `columnOrder` and `onColumnOrderChange` are provided, reordering is controlled from the outside.
     * When they are omitted, the table keeps the reordered state internally.
     *
     * @default false
     */
    draggable?: boolean;
    /**
     * Enables resize handles for this column in `TABLE` view.
     *
     * When `onColumnResize` is provided, resized widths are controlled from the outside.
     * When it is omitted, the table keeps resized widths internally.
     *
     * @default false
     */
    resizeable?: boolean;
    /**
     * Horizontal alignment of body cells in this column.
     *
     * @default 'left'
     */
    horizontalAlign?: TableHorizontalAlign;
    /**
     * Additional class names for body cells in this column.
     */
    className?: string;
    /**
     * Additional class names for header cells in this column.
     */
    headerClassName?: string;
    /**
     * Hide this column on mobile card layout.
     *
     * @default false
     */
    hideOnMobile?: boolean;
    /**
     * Allow sorting via clickable table header.
     *
     * Sorting itself stays controlled outside the table.
     *
     * @default false
     */
    sortable?: boolean;
};
export type TableColumn<RowType extends TableRowData> = TableColumnDefinition<RowType>;
export type TableRowClassName<RowType extends TableRowData> = string | ((row: RowType, rowIndex: number) => string);
export type TableCellClassName<RowType extends TableRowData> = (row: RowType, column: TableColumnDefinition<RowType>, rowIndex: number, columnIndex: number) => string;
export type TableRowAnimationProps<RowType extends TableRowData> = MotionProps | ((row: RowType, rowIndex: number) => MotionProps);
export type TableRowSelectable<RowType extends TableRowData> = (row: RowType, rowIndex: number) => boolean;
export type TableProps<RowType extends TableRowData> = Omit<HTMLAttributes<HTMLDivElement>, 'draggable' | 'onClick'> & {
    /**
     * Row key accessor for resolving a stable unique row id.
     *
     * This is recommended whenever rows have their own identifier such as `id`, `vehicleId`, or `uuid`, especially
     * when using selection, active rows, expanded rows, or virtualization.
     *
     * If omitted, the row index is used as a fallback.
     *
     * @default row index
     */
    rowKey?: keyof RowType | ((row: RowType, rowIndex: number) => string | number);
    /**
     * Controls table or card rendering modes.
     *
     * @default 'TABLE'
     */
    viewType?: TableViewType;
    /**
     * Card width configuration for `MULTI_CARDS` view.
     */
    cardsStyle?: TableCardsStyleSettings;
    /**
     * Automatically switches `TABLE` view when the rendered table width changes.
     *
     * Use `cards` to switch to `MULTI_CARDS` and `list` to switch to `SINGLE_CARD`.
     * The object may contain either key or both.
     *
     * Accepts pixel numbers or CSS length values such as `720`, `'720px'`, or `'50vw'`.
     */
    responsiveBreakpoint?: TableResponsiveBreakpoint;
    /**
     * Called whenever the effective rendered view changes after applying responsive breakpoint logic.
     *
     * This can differ from `viewType` when `responsiveBreakpoint` forces an automatic switch.
     * In controlled setups, you can use this callback to keep the external `viewType` state in sync.
     *
     * Only used when `responsiveBreakpoint` is provided.
     */
    onViewTypeChange?: (viewType: TableViewType) => void;
    /**
     * Compact row/cell spacing like old `table-condensed`.
     *
     * @default false
     */
    condensed?: boolean;
    /**
     * Zebra rows like old `table-striped`.
     *
     * @default false
     */
    striped?: boolean;
    /**
     * Hover effect like old `table-hover`.
     *
     * @default false
     */
    hover?: boolean;
    /**
     * Apply table shadow.
     *
     * @default false
     */
    shadow?: boolean;
    /**
     * Simple outer border on table wrapper and card variants.
     *
     * @default true
     */
    border?: boolean;
    /**
     * Rounded table corners and card variants.
     * Top corners are applied to header or body (if no header),
     * bottom corners are applied to footer or body (if no footer).
     *
     * @default true
     */
    rounded?: boolean;
    /**
     * Show vertical and header row grid lines.
     *
     * @default false
     */
    gridLines?: boolean;
    /**
     * Optional classes for rows.
     *
     * Accepts either a static class string for all rows or a callback that resolves
     * row-specific classes from the current row data and row index.
     *
     * @example
     * rowClassName={(row) => (row.disabled ? 'my-class-name' : '')}
     */
    rowClassName?: TableRowClassName<RowType>;
    /**
     * Width of the separator between regular body rows in table view.
     *
     * This affects normal data rows and expanded child rows.
     * Group rows, group footers, footer rows, and full-width expanded rows keep their own fixed separators.
     *
     * @default '1px'
     */
    rowSeparatorWidth?: number | string;
    /**
     * Controls which scroll context sticky headers and sticky rows align to in `TABLE` view.
     *
     * Use `applicationLayout` when the page scroll happens in the default app body.
     * Use `container` when the table sits inside its own explicit overflow container.
     *
     * Sticky rows inside `TableBody maxHeight` continue to pin within that internal body scroller.
     *
     * @default 'applicationLayout'
     */
    stickyReference?: TableStickyReference;
    /**
     * Sticky column behavior in `TABLE` view.
     *
     * `left` and `right` are position-based and follow column reordering.
     * Selection columns and group rows are ignored.
     *
     * The public API currently supports `left: 1` and `right: 1`.
     *
     * @example
     * stickyColumns={{ left: 1, right: 1, footer: true }}
     */
    stickyColumns?: TableStickyColumns;
    /**
     * Current active row key for detail context or external side panels.
     */
    activeRowId?: TableRowId;
    /**
     * Called when a row is activated or deactivated by row click.
     */
    onActiveRowChange?: (rowId: TableRowId | undefined, row: RowType, rowIndex: number) => void;
    /**
     * Optional low-level motion props applied to data rows for enter, exit, and layout animations.
     *
     * This is intended as an advanced escape hatch when the built-in row animation behavior is not sufficient.
     * Can be defined once for all rows or resolved per row.
     * A stable `rowKey` is recommended so animations keep working predictably across inserts, removals, and reordering.
     * Ignored when `virtualizedRows` is enabled.
     */
    rowAnimationProps?: TableRowAnimationProps<RowType>;
    /**
     * High-level animation settings for expanded rows.
     *
     * Pass `false` to disable expanded-row animations entirely.
     * Pass a `duration` to keep the built-in expanded-row animations but make them faster or slower.
     */
    expandedRowAnimation?: TableExpandedRowAnimation;
    /**
     * Current sorted column key.
     */
    sortBy?: string | string[];
    /**
     * Current sort direction for `sortBy`.
     */
    sortDirection?: TableSortDirection;
    /**
     * Called when a sortable header is clicked.
     *
     * Sorting itself remains controlled outside the table.
     * The click event is passed through as an optional third argument for modifier-key scenarios such as shift-click.
     */
    onSortChange?: (columnKey: string, direction: TableSortDirection, event: ReactMouseEvent<HTMLButtonElement>) => void;
    /**
     * Optional classes for each cell.
     *
     * The callback is resolved per rendered body cell and receives the current
     * row data, the resolved column definition, the row index, and the column index.
     *
     * @example
     * cellClassName={(row, column) => (column.key === 'status' && row.disabled ? 'text-color-muted' : '')}
     */
    cellClassName?: TableCellClassName<RowType>;
    /**
     * Row click callback. Adds keyboard support and pointer cursor.
     */
    onRowClick?: (row: RowType, rowIndex: number) => void;
    /**
     * Called when checkbox selection changes.
     */
    onSelectionChange?: (rowIds: TableRowId[]) => void;
    /**
     * Hides selection checkboxes for rows marked with `selectable={false}`.
     *
     * Those rows stay interactive for hover, click handling, and active-row state.
     *
     * @default false
     */
    hideSelectionCheckboxesForExcludedRows?: boolean;
    /**
     * Currently selected row keys for multi-selection use cases.
     */
    selectedRowIds?: TableRowId[];
    /**
     * Optional custom header content for the selection column.
     * If omitted, the header renders the default select-all checkbox.
     */
    selectionHeaderContent?: ReactNode;
    /**
     * Vertical alignment for selection checkboxes in the header and body rows.
     *
     * @default 'middle'
     */
    selectionCheckboxVerticalAlignment?: TableVerticalAlign;
    /**
     * Controlled column order for drag-reordering.
     *
     * Reordering interactions are enabled when reorderable header columns set `draggable`
     * and the table is in `TABLE` view.
     *
     * Keys not present in the current table columns are ignored.
     */
    columnOrder?: string[];
    /**
     * Called while a column is resized via the header handle.
     *
     * Resize handles are shown only for header columns that set `resizeable`.
     *
     * When omitted, the table keeps resized widths internally.
     * Pass `undefined` to clear a previously configured width.
     *
     * Drag-resizing emits pixel widths as numbers. A reset can restore the original
     * configured width, which may also be a string such as `'20%'`.
     */
    onColumnResize?: (columnKey: string, width?: number | string) => void;
    /**
     * Called when drag-reordering produces a new column order.
     *
     * When omitted, the table keeps the reordered column state internally.
     * Drag interactions are enabled only for header columns that set `draggable`.
     */
    onColumnOrderChange?: (columnOrder: string[]) => void;
    /**
     * Render a selection checkbox column as the first column.
     */
    showSelectionColumn?: boolean;
    /**
     * Fallback content when there are no rows.
     *
     * @default 'No data available'
     */
    noRowsState?: ReactNode;
    /**
     * Enables table-specific row virtualization for vertically scrolling table bodies.
     *
     * Virtualization is currently only active in `TABLE` view with `bodyMaxHeight`.
     *
     * @default false
     */
    virtualizedRows?: boolean;
    /**
     * Extra row count rendered above and below the visible area when virtualization is enabled.
     *
     * @default 5
     */
    virtualizationOverscan?: number;
};
