import { Observable } from 'rxjs';
import { QdTableDataRow, QdTableRecentSecondaryAction, QdTableRowIdentifier } from './table-data.interface';
import { QdTableSelectedRows } from './table-row-selection.interface';
/**
 * @description Defines the primary action that can be triggered by clicking on a row.
 */
export interface QdTablePrimaryAction<T extends string> {
    /**
     * @description Function executed when the action is triggered.
     *
     * - Accepts row data and its index.
     * - Returns `void` for synchronous actions or `Observable<boolean>` for asynchronous ones.
     *
     * Example:
     * ```typescript
     * handler: ({ rowData, index }) => of(true); // Action succeeded
     * ```
     */
    handler?: (data: {
        rowData: QdTableDataRow<T>;
        index: number;
    }) => QdTableActionResult;
    /**
     * @description Refresh configuration for the table after the action completes.
     */
    refresh?: QdTableRefreshConfig;
}
/**
 * @description Defines a secondary action that is shown in the menu. Can be disabled.
 */
export interface QdTableSecondaryAction<T extends string> {
    /**
     * @description Defines the secondary action type for the table.
     */
    type: QdTableConfigSecondaryActionType;
    /**
     * @description Sets the inline action to disabled
     */
    isDisabled?: boolean | ((row: QdTableDataRow<T>) => boolean);
    /**
     * @description Function executed when the action is triggered.
     *
     * - Accepts row data and its index.
     * - Returns `void` for synchronous actions or `Observable<boolean>` for asynchronous ones.
     *
     * Example:
     * ```typescript
     * handler: ({ rowData, index }) => of(true); // Action succeeded
     * ```
     */
    handler?: (selectedRow: QdTableRecentSecondaryAction<T>) => QdTableActionResult;
    /**
     * @description Refresh configuration for the table after the action completes.
     */
    refresh?: QdTableRefreshConfig;
    /**
     * @description Controls in which operation mode this action is shown. May be set by the Quadrel Framework ('edit' or 'view').
     *
     * - Use `'edit'` to show the action only in editable mode.
     * - Use `'view'` to show the action only in viewonly mode.
     * - If not set, the action is shown in **both modes**.
     *
     * **Note:** The `viewonly` flag in the table configuration overrides any external operation mode.
     *
     * * @example
     * ```ts
     * {
     *   type: 'edit',
     *   operationMode: 'edit',
     *   handler: ...
     * }
     * ```
     */
    operationMode?: 'edit' | 'view';
}
/**
 * @description Defines the secondaryAction type for the table. For 'edit', 'delete' & 'view' types, an icon will be provided.
 */
export type QdTableConfigSecondaryActionType = 'edit' | 'delete' | 'view' | string;
/**
 * @description Uses a column for a secondary action. For example in the case of a status information.
 */
export type QdTableConfigSecondaryActionTypeColumn<T> = T;
/**
 * @description Defines the actions that can be called in the row menu.
 */
export type QdTableConfigColumnRowAction = 'edit';
/**
 * @description Configures the behavior of the groups in the tree view.
 */
export interface QdTableConfigGroup {
    /**
     * @description Click/tap to release the groups.
     *
     * * @default: false
     */
    toggle?: boolean;
    /**
     * @description Rows that are grouped together are aggregated.
     *
     * * @default: true
     */
    aggregation?: boolean;
}
/**
 * @description Configures selection options for table rows.
 */
export interface QdTableConfigSelection<T extends string> {
    /**
     * @description Defines the selection type for the table.
     */
    type?: QdTableConfigSelectionType;
    /**
     * @description Configure the rows that are initially selected. You can indicate a row by its uid or its index.
     * The uids can be defined in the table data row objects.
     *
     * * @default: []
     */
    selectedRows?: QdTableRowIdentifier[];
    /**
     * @description Set to emit the initial selection in the selection output.
     *
     * * @default: false
     */
    emitOutputInitially?: boolean;
    /**
     * @description Defines a handler that is triggered by a selection.
     */
    handler?: (selectedRows: QdTableSelectedRows<T>) => void;
}
/**
 * @description Defines the selection type for the table. For 'singleSelect' radio buttons will be displayed and for
 * 'multiSelect' checkboxes will be provided.
 */
export type QdTableConfigSelectionType = 'singleSelect' | 'multiSelect';
/**
 * @description Defines the result of a table action handler.
 *
 * - **`void`**: For synchronous actions.
 * - **`Observable<boolean>`**: For asynchronous actions:
 *   - Emits **`true`** if the action succeeds and triggers further logic (e.g., refresh).
 *   - Emits **`false`** if the action fails or is canceled.
 */
export type QdTableActionResult = void | Observable<boolean>;
/**
 * @description Configuration for the table refresh after an action completes.
 */
export interface QdTableRefreshConfig {
    /**
     * @description Enables a table refresh after the action completes successfully if `true`.
     *
     * - Note: Requires both a handler and a resolver to be defined.
     *
     * @default false
     */
    isEnabled?: boolean;
    /**
     * @description Specifies the page to load when refreshing the table.
     * - A specific page number (e.g., `2`) can be provided.
     *
     * @default 0
     */
    page?: number;
}
//# sourceMappingURL=table-config-actions.interface.d.ts.map