You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
845 B
34 lines
845 B
3 years ago
|
import type { InjectionKey } from 'vue';
|
||
|
import { inject, provide } from 'vue';
|
||
|
import type { GetComponent, TransformCellText } from '../interface';
|
||
|
import type { FixedInfo } from '../utils/fixUtil';
|
||
|
|
||
|
export interface TableContextProps {
|
||
|
// Table context
|
||
|
prefixCls: string;
|
||
|
|
||
|
getComponent: GetComponent;
|
||
|
|
||
|
scrollbarSize: number;
|
||
|
|
||
|
direction: 'ltr' | 'rtl';
|
||
|
|
||
|
fixedInfoList: readonly FixedInfo[];
|
||
|
|
||
|
isSticky: boolean;
|
||
|
|
||
|
summaryCollect: (uniKey: string, fixed: boolean | string) => void;
|
||
|
|
||
|
transformCellText: TransformCellText<unknown>;
|
||
|
}
|
||
|
|
||
|
export const TableContextKey: InjectionKey<TableContextProps> = Symbol('TableContextProps');
|
||
|
|
||
|
export const useProvideTable = (props: TableContextProps) => {
|
||
|
provide(TableContextKey, props);
|
||
|
};
|
||
|
|
||
|
export const useInjectTable = () => {
|
||
|
return inject(TableContextKey, {} as TableContextProps);
|
||
|
};
|