import { TableV2FixedDir } from 'element-plus' import type { VNode } from 'vue' import type { TableColumn } from '@/views/_components/table/IvyTableColumn' import { actionsCellRenderer } from '@/views/_components/table/renderers' import type { ActionsCellOptions, CellAction, } from '@/views/_components/table/renderers/actionsCellRenderer' export interface ActionsColumnOptions> { actions: CellAction[] | ((row: Row) => CellAction[]) idKey?: ActionsCellOptions['idKey'] onButtonRef?: ActionsCellOptions['onButtonRef'] headerRenderer?: () => VNode title?: string width?: number minWidth?: number className?: string overrides?: Partial } export function actionsColumn>( options: ActionsColumnOptions, ): TableColumn { const width = options.width ?? 120 return { key: 'actions', width, minWidth: options.minWidth ?? width, title: options.title, class: options.className, headerRenderer: options.headerRenderer, cellRenderer: actionsCellRenderer({ actions: options.actions, idKey: options.idKey, onButtonRef: options.onButtonRef, }), visible: true, showInModal: false, fixed: TableV2FixedDir.RIGHT, ...options.overrides, } }