import { type TableSortDirection, type RowHighlightBehavior, type TableDisplayMode, PropertyType } from "../../../fd-toolbox/enums/enums";
import { PropertyMeta } from "../core/property-meta";
import { WithId } from "../../../fd-toolbox-core/types/resource-with-id";
import { Func, SetStateFunc, VoidFunc, VoidFuncNoParam } from "../../../fd-toolbox/functions/internal-getter-setter-functions";
import { ResourceMeta } from "../core/resource-meta";
import { UiPropertyMeta } from "../core/ui-property-meta";
import { UiResourceMeta } from "../ui-resource-meta";
import { WithIndexer } from "../../../fd-toolbox-core/types/with-indexer";
import type { Element, ElementNode } from "../../../fd-toolbox/types/react-types";
/** Defines the available column types for the {@link Table} component. */
export declare const internalTableColumnTypes: {
    default: number;
    action: number;
    checkBox: number;
    checkMark: number;
    customHeaderAction: number;
};
/** Type for {@link internalTableColumnTypes} enum. */
export type InternalTableColumnType = (typeof internalTableColumnTypes)[keyof typeof internalTableColumnTypes];
/** Positions for custom actions in {@link Table}. */
export declare const tableCustomActionPositions: {
    default: number;
    lastColumn: number;
    dropdown: number;
};
/** Type for {@link tableCustomActionPositions} enum. */
export type TableCustomActionPosition = (typeof tableCustomActionPositions)[keyof typeof tableCustomActionPositions];
/** Types of custom actions in {@link Table}. */
export declare const tableCustomActionTypes: {
    icon: number;
    text: number;
    create: number;
    link: number;
    view: number;
    template: number;
};
/** Type for {@link tableCustomActionTypes} enum. */
export type TableCustomActionType = (typeof tableCustomActionTypes)[keyof typeof tableCustomActionTypes];
export declare const tableDimensions: {
    readonly cellPadding: 15;
    readonly compactCellPadding: 7;
    readonly compactMinWidth: 250;
    readonly defaultMinWidth: 500;
};
/**
 * Internal representation of a table column in the {@link Table} component.
 * Contains all configuration and metadata needed to render and interact with a column.
 */
export interface InternalTableColumn {
    /** Unique identifier for the column, value comes from {@link UiPropertyMeta.name} */
    name: string;
    /** Human-readable name shown in the column header, value comes from {@link PropertyMeta.displayName} */
    displayName: string;
    /** Type of column, determines its rendering and behavior */
    type: InternalTableColumnType;
    /** Width of the column as a percentage */
    width: number;
    /** Position index of this column in the table */
    index: number;
    /** Configuration for expandable rows, values comes from {@link PropertyMeta.relation} */
    expandInfo?: ExpandInfo;
    /**
     * Name of the property in the data item that this column displays,
     * value comes from {@link UiPropertyMeta.name}
     */
    itemPropertyName?: string;
    /** Metadata about the property being displayed */
    propertyMeta?: PropertyMeta;
    /**
     * Type format for Ui rendering and validation
     * @see {@link PropertyMeta.typeFormat}
     */
    propertyTypeFormat?: string;
    propertyType?: PropertyType;
    /** Ui-specific metadata for the property being displayed */
    uiPropertyMeta?: UiPropertyMeta;
    /** Whether this column is the current sort column */
    isActiveSort?: boolean;
    /** Direction of sorting for this column when it is the active sort column */
    sortDirection?: TableSortDirection;
    /** Priority value for this column (used for column ordering) */
    priority?: number;
    /** Custom template function to render cell content */
    cellTemplate?: (props: TableCellTemplateProps) => ElementNode;
    /** Type of action for action columns */
    actionType?: TableCustomActionType;
    /** Position of action column in the table (default or last column) */
    actionPosition?: TableCustomActionPosition;
    /** Whether date values should be displayed as relative time (e.g., "2 days ago") */
    isDateAsTimeAgo?: boolean;
    enumInfo?: EnumInfo;
}
export interface ColumnDirective {
    cellTemplate?: (context: CellContext) => HTMLElement | string | undefined;
    displayName?: string;
    type?: InternalTableColumnType;
    name?: string;
    width?: number;
    index?: number;
}
/** Represents a row in the {@link Table} component. */
export interface TableRow<T extends WithId = WithId> {
    /** Whether this row is currently selected in the table */
    selected: boolean;
    /** The data item being displayed in this row, must have an id property */
    item: T;
    /** Zero-based index position of this row in the table */
    index: number;
}
export interface TableColumnPossibleValues extends Map<unknown, unknown> {
}
/** Table instance representation for {@link Table}. */
export interface TableInstance {
    /** Unique identifier for the table instance */
    id?: string;
    name?: string;
    /** Array of rows to display in the table */
    tableRows: TableRow[];
    /** Array of column definitions */
    internalTableColumns: InternalTableColumn[];
    /** Metadata about the item being displayed */
    uiResourceMeta?: UiResourceMeta;
    /** Whether to hide the delete button in the table actions */
    hideDeleteButton?: boolean;
    /** Custom actions applied to the table */
    customActions?: TableCustomAction[];
    /** Array of property names that should be excluded from the table display. */
    excludeProperties?: string[];
    /** Maximum number of columns to display in the table */
    maxNumberOfColumns?: number;
    /** Whether to enable multi-selection of rows */
    multiSelect?: boolean;
    /**
     * Whether cell URL navigation links should be disabled/removed from the table.
     * When true, URL navigation links are removed from cells (useful for dialogs).
     */
    disableCellNavigationLinks?: boolean;
    /**
     * Function that takes a property name and returns a Map where keys are indices of enum values
     * and values are the actual enum values. Only applicable to enum properties.
     */
    getColumnPossibleValues: Func<string, TableColumnPossibleValues | undefined>;
    /** Event handler called when a row is clicked */
    onRowClicked?: VoidFunc<WithId>;
    dataDescription?: DataDescription;
}
/**
 * Context for a table header cell in {@link Table}.
 * Extends {@link BaseCellContext}.
 */
export interface HeaderCellContext extends BaseCellContext {
    /** Reference to the parent table instance */
    tableInstance: TableInstance;
}
/**
 * Context for a table body cell in {@link Table}.
 * Extends {@link BaseCellContext}.
 */
export interface CellContext extends BaseCellContext {
    /** Information about the table row containing this cell. */
    row: TableRow;
    /** Reference to the parent table instance. */
    tableInstance: TableInstance;
}
export interface RowContext {
    row: TableRow;
    tableInstance: TableInstance;
    internalTableColumns: InternalTableColumn[];
}
/**
 * Configuration for expandable table rows, defines relationships with other items.
 * Used in {@link InternalTableColumn}.
 */
export interface ExpandInfo {
    /** Name of the related item, value comes from {@link PropertyMeta.relation}.relatedResourceName*/
    relatedItemName: string;
    /** Name of the property used for expansion, value comes from {@link PropertyMeta.relation}.expandPropertyName */
    expandPropertyName: string;
    /** Metadata of the resource whose name equals {@link ExpandInfo.relatedItemName} */
    resourceMeta: ResourceMeta;
}
export interface TableResizeColumn {
    width: number;
    index: number;
}
/**
 * Configuration options for customizing the appearance and behavior of the {@link Table} component
 */
export interface TableConfig {
    /** Whether to hide the delete button in the table actions */
    hideDeleteButton?: boolean;
    /** Custom actions to display in the table rows or header */
    customActions?: TableCustomAction[];
    /** Array of property names that should be excluded from the table display. */
    excludeProperties?: string[];
    /** Maximum number of columns to display in the table */
    maxNumberOfColumns?: number;
    /** Properties to specifically include in the table display */
    includeProperties?: string[];
    /** Whether to enable multi-selection of rows */
    multiSelect?: boolean;
    /**
     * Whether cell URL navigation links should be disabled/removed from the table.
     * When true, URL navigation links are removed from cells (useful for dialogs).
     */
    disableCellNavigationLinks?: boolean;
    /**
     * Configuration for specific columns in the table, keyed by column name.
     */
    columnConfigs?: WithIndexer<TableColumnConfig>;
    /** Whether the table is in read-only mode */
    readonly?: boolean;
    /**
     * Whether to use external sorting mechanism
     * If true, sorting will call the {@link sort} function
     * If false, sorting will be applied locally to the provided items
     */
    externalSorting?: boolean;
    /** Current sort configuration */
    sort?: TableSort;
    /**
     * Display mode of the table.
     * {@link tableDisplayModes.default} shows full-sized table with all controls visible.
     * {@link tableDisplayModes.minimal} shows compact table with controls visible only on hover.
     */
    displayMode?: TableDisplayMode;
    /** Number of items per page by default */
    pageSize?: number;
    /**
     * Behavior for highlighting rows when interacting with the table.
     * {@link rowHighlightBehaviors.default} shows standard cursor on hover using "hover:cursor-default" Css class.
     * {@link rowHighlightBehaviors.pointer} shows pointer cursor on hover using "hover:cursor-pointer" Css class.
     */
    rowHighlightBehavior?: RowHighlightBehavior;
    /**
     * Whether to use adaptive width for the entire table.
     * When true: for small screens (screen width < columnsCount * 150px + 10vw) width is 90vw
     * with minimum width of columnsCount * 100px (in rem);
     * for large screens minimum width is columnsCount * 150px (in rem).
     * When false: fixed minimum width of columnsCount * 100px / 16 (calculated based on column content).
     */
    adaptiveWidth?: boolean;
    /** Additional Css class names */
    className?: string;
}
/** Configuration for table column sorting. */
export interface TableSort {
    /** The name of the column to sort by. */
    columnName: string;
    /** The direction of the sort (ascending or descending) */
    direction?: TableSortDirection;
    /**
     * Whether the sorting should be applied locally to the current data (true)
     * or handled externally by a parent component or backend service (false).
     */
    isLocalSort?: boolean;
}
/** Configuration for table pagination. */
export interface Paging {
    /** Number of items to display per page. */
    pageSize: number;
    /** Current page number, 1-based. */
    pageNumber: number;
    /**
     * Number of items to skip when fetching data.
     * Calculated as (pageNumber - 1) * pageSize.
     */
    pagingSkip: number;
}
export interface WithOffsetWidthAndHeight {
    offsetWidth: number;
    offsetHeight: number;
}
/**
 * Base context for any cell in {@link Table}.
 * Used as a base interface for {@link CellContext} and {@link HeaderCellContext}.
 */
export interface BaseCellContext {
    /** Information about the column this cell belongs to */
    internalTableColumn: InternalTableColumn;
    /** Reference to the parent table instance */
    tableInstance: TableInstance;
}
export interface TableContext {
    columnWidths: number[];
    setColumnWidths?: VoidFunc<number[]>;
    tableRows?: TableRow[];
    setTableRows?: SetStateFunc<TableRow[]>;
    loading: boolean;
}
export interface TableCustomActionProps {
    cellContext: CellContext;
    onAction: Func<TableCustomActionResult, unknown>;
    customAction: TableCustomAction;
}
/** Configuration for custom actions in {@link Table}. */
export interface TableCustomAction {
    /** Display name for the action */
    displayName: string;
    /** Position of the action in the table */
    position?: TableCustomActionPosition;
    /** Type of custom action */
    actionType?: TableCustomActionType;
    /** Icon identifier for the action from {@link iconNames} */
    icon?: string;
    /**
     * Handler function called when action is triggered on a body cell.
     * Receives {@link CellContext} as parameter.
     */
    onCellAction?: VoidFunc<CellContext>;
    /**
     * Handler function called when action is triggered on a header cell.
     * Receives {@link HeaderCellContext} as parameter.
     */
    onHeaderCellAction?: VoidFunc<HeaderCellContext>;
    /**
     * Whether the table should refresh after this action is performed.
     * When true, {@link Table}'s `onRefreshItems` callback will be called when action is triggered.
     */
    shouldTableRefreshAfter?: boolean;
    /**
     * Function to determine if the action should be shown.
     * Receives {@link CellContext} or undefined as input parameter and should return boolean.
     */
    shouldBeShown?: Func<CellContext | undefined, boolean>;
    /**
     * Function to generate a dynamic class name based on cell context.
     * Receives {@link CellContext} as input parameter and should return a CSS class name string.
     */
    getDynamicClassName?: Func<CellContext, string>;
    /**
     * Function to generate a dynamic link based on cell context.
     * Receives {@link CellContext} as input parameter and should return a Promise resolving to URL string.
     */
    getDynamicLink?: Func<CellContext, Promise<string>>;
    /**
     * Template function to render the cell content.
     * Receives {@link TableCustomActionTemplateProps} as input and should return a JSX element.
     */
    getTemplate?: (props: TableCustomActionTemplateProps) => Element;
}
export interface TableCustomActionResult {
    shouldTableRefresh?: boolean;
}
/** {@link Table} component */
export interface TableComponent {
    /**
     * Get selected rows.
     *
     * @typeParam T - Resource type.
     * @returns Array of {@link TableRow} of T.
     */
    getSelectedRows<T extends WithId>(): TableRow<T>[];
    /** Get selected row Ids. */
    getSelectedRowsIds(): string[];
    /** Clear all selected rows. */
    resetSelectedRows(): void;
    /**
     * Delete rows locally by item Ids.
     *
     * @param idList - item Ids to delete.
     */
    deleteRowsLocally(idList: string[]): void;
}
/**
 * Props passed to custom cell template functions in {@link Table}.
 */
export interface TableCellTemplateProps<T = WithId> {
    /** The resource data of the table row that contains this cell */
    resource: T;
    /** Name of the property being displayed */
    propertyName?: string;
}
/** Props passed to custom action template component in {@link TableCustomAction}. */
export interface TableCustomActionTemplateProps {
    /** Event handler called when need to trigger the custom action */
    onCustomAction: VoidFuncNoParam;
    /** Name of the property for which the table action is defined */
    propertyName?: string;
}
/** Configuration options for individual table columns in {@link TableConfig}. */
export interface TableColumnConfig {
    /** Whether date values should be displayed as relative time (e.g., "2 days ago") */
    isDateAsTimeAgo?: boolean;
    /** Custom template function to render cell content */
    cellTemplate?: (props: TableCellTemplateProps) => ElementNode;
}
export interface DataInfo {
    name: string;
    properties: WithIndexer<DataInfoProperty>;
    dataDescription?: DataDescription;
}
export interface DataInfoProperty {
    name: string;
    displayName: string;
    priority?: number;
    propertyType?: PropertyType;
    typeFormat?: string;
    enumInfo?: EnumInfo;
    cellTemplate?: (props: TableCellTemplateProps) => ElementNode;
}
export interface EnumInfo {
    enumerationValues: number[];
    enumerationDisplayName: string[];
    isColorful?: boolean;
}
export interface DataDescription {
    descriptionPropertyName: string;
    useImage?: boolean;
}
