import type { ColumnType, DefaultRecordType, ColumnsType, TableLayout, RenderExpandIcon, ExpandableType, RowClassName, TriggerEventHandler, ExpandedRowRender, } from '../interface'; import type { InjectionKey } from 'vue'; import { inject, provide } from 'vue'; export interface BodyContextProps { rowClassName: string | RowClassName; expandedRowClassName: RowClassName; columns: ColumnsType; flattenColumns: readonly ColumnType[]; tableLayout: TableLayout; indentSize: number; expandableType: ExpandableType; expandRowByClick: boolean; expandedRowRender: ExpandedRowRender; expandIcon: RenderExpandIcon; onTriggerExpand: TriggerEventHandler; expandIconColumnIndex: number; } export const BodyContextKey: InjectionKey = Symbol('BodyContextProps'); export const useProvideBody = (props: BodyContextProps) => { provide(BodyContextKey, props); }; export const useInjectBody = () => { return inject(BodyContextKey, {} as BodyContextProps); };